remote-codex 0.11.36 → 0.11.37

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.
@@ -1,16 +1,16 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DODVy7wn.js","assets/markdown-vendor-RZk8L7-L.js","assets/react-vendor-Dfg_6BLf.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-C5bTa-Ka.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
2
- import{l as D,R as Ki,I as qi,C as Xi,S as Gs,H as Yi,T as Zi,a as Ji,b as Qi,c as ed,d as td,e as rd,D as nd,P as ad,O as sd,f as od,g as ld,h as id,i as dd,j as cd,k as hd,m as ud,n as md,A as pd,o as fd,p as gd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as xd,j as t,b as Yr}from"./react-vendor-Dfg_6BLf.js";import{u as bd,a as vd,H as Na,P as Gt,b as kd,M as Fs,R as wd,i as yd,C as jd,B as Nd,c as Ca,g as Hs}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as Cd,r as Sd,a as Td,b as Ed}from"./markdown-vendor-RZk8L7-L.js";const Ld="modulepreload",Id=function(e){return"/"+e},Sa={},Xe=function(r,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.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]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=l(n.map(h=>{if(h=Id(h),h in Sa)return;Sa[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Ld,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return o.then(l=>{for(const i of l||[])i.status==="rejected"&&s(i.reason);return r().catch(s)})};function Os(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r<o;r++)e[r]&&(n=Os(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ws(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Os(e))&&(a&&(a+=" "),a+=r);return a}const zd=(e,r)=>{const n=new Array(e.length+r.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<r.length;a++)n[e.length+a]=r[a];return n},Pd=(e,r)=>({classGroupId:e,validator:r}),Us=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Ur="-",Ta=[],Rd="arbitrary..",Md=e=>{const r=_d(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Ad(l);const i=l.split(Ur),d=i[0]===""&&i.length>1?1:0;return Vs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?zd(h,d):d:h||Ta}return n[l]||Ta}}},Vs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Vs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Ur):e.slice(r).join(Ur),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Ad=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),n=r.indexOf(":"),a=r.slice(0,n);return a?Rd+a:void 0})(),_d=e=>{const{theme:r,classGroups:n}=e;return $d(n,r)},$d=(e,r)=>{const n=Us();for(const a in e){const o=e[a];Qn(o,n,a,r)}return n},Qn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Dd(l,r,n,a)}},Dd=(e,r,n,a)=>{if(typeof e=="string"){Bd(e,r,n);return}if(typeof e=="function"){Gd(e,r,n,a);return}Fd(e,r,n,a)},Bd=(e,r,n)=>{const a=e===""?r:Ks(r,e);a.classGroupId=n},Gd=(e,r,n,a)=>{if(Hd(e)){Qn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Pd(n,e))},Fd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Qn(d,Ks(r,i),n,a)}},Ks=(e,r)=>{let n=e;const a=r.split(Ur),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Us(),n.nextPart.set(l,i)),n=i}return n},Hd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Od=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const o=(s,l)=>{n[s]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(s){let l=n[s];if(l!==void 0)return l;if((l=a[s])!==void 0)return o(s,l),l},set(s,l){s in n?n[s]=l:o(s,l)}}},Pn="!",Ea=":",Wd=[],La=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Ud=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=o=>{const s=[];let l=0,i=0,d=0,h;const u=o.length;for(let b=0;b<u;b++){const k=o[b];if(l===0&&i===0){if(k===Ea){s.push(o.slice(d,b)),d=b+1;continue}if(k==="/"){h=b;continue}}k==="["?l++:k==="]"?l--:k==="("?i++:k===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Pn)?(f=m.slice(0,-1),p=!0):m.startsWith(Pn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return La(s,p,f,g)};if(r){const o=r+Ea,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):La(Wd,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Vd=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let o=[];for(let s=0;s<n.length;s++){const l=n[s],i=l[0]==="[",d=r.has(l);i||d?(o.length>0&&(o.sort(),a.push(...o),o=[]),a.push(l)):o.push(l)}return o.length>0&&(o.sort(),a.push(...o)),a}},Kd=e=>({cache:Od(e.cacheSize),parseClassName:Ud(e),sortModifiers:Vd(e),postfixLookupClassGroupIds:qd(e),...Md(e)}),qd=e=>{const r=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a<n.length;a++)r[n[a]]=!0;return r},Xd=/\s+/,Yd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Xd);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:k}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!k,j;if(x){const N=b.substring(0,k);j=a(N);const I=j&&l[j]?a(b):void 0;I&&I!==j&&(j=I,x=!1)}else j=a(b);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(b),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const w=p.length===0?"":p.length===1?p[0]:s(p).join(":"),y=g?w+Pn:w,v=y+j;if(i.indexOf(v)>-1)continue;i.push(v);const S=o(j,x);for(let N=0;N<S.length;++N){const I=S[N];i.push(y+I)}h=m+(h.length>0?" "+h:h)}return h},Zd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=qs(n))&&(o&&(o+=" "),o+=a);return o},qs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=qs(e[a]))&&(n&&(n+=" "),n+=r);return n},Jd=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Kd(h),a=n.cache.get,o=n.cache.set,s=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=Yd(d,n);return o(d,u),u};return s=l,(...d)=>s(Zd(...d))},Qd=[],Qe=e=>{const r=n=>n[e]||Qd;return r.isThemeGetter=!0,r},Xs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ys=/^\((?:(\w[\w-]*):)?(.+)\)$/i,ec=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,tc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,rc=/\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$/,nc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,ac=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,sc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>ec.test(e),Pe=e=>!!e&&!Number.isNaN(Number(e)),ft=e=>!!e&&Number.isInteger(Number(e)),gn=e=>e.endsWith("%")&&Pe(e.slice(0,-1)),wt=e=>tc.test(e),Zs=()=>!0,oc=e=>rc.test(e)&&!nc.test(e),ea=()=>!1,lc=e=>ac.test(e),ic=e=>sc.test(e),dc=e=>!he(e)&&!me(e),cc=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)),hc=e=>zt(e,eo,ea),he=e=>Xs.test(e),$t=e=>zt(e,to,oc),Ia=e=>zt(e,vc,Pe),uc=e=>zt(e,no,Zs),mc=e=>zt(e,ro,ea),za=e=>zt(e,Js,ea),pc=e=>zt(e,Qs,ic),zr=e=>zt(e,ao,lc),me=e=>Ys.test(e),ur=e=>Vt(e,to),fc=e=>Vt(e,ro),Pa=e=>Vt(e,Js),gc=e=>Vt(e,eo),xc=e=>Vt(e,Qs),Pr=e=>Vt(e,ao,!0),bc=e=>Vt(e,no,!0),zt=(e,r,n)=>{const a=Xs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Vt=(e,r,n=!1)=>{const a=Ys.exec(e);return a?a[1]?r(a[1]):n:!1},Js=e=>e==="position"||e==="percentage",Qs=e=>e==="image"||e==="url",eo=e=>e==="length"||e==="size"||e==="bg-size",to=e=>e==="length",vc=e=>e==="number",ro=e=>e==="family-name",no=e=>e==="number"||e==="weight",ao=e=>e==="shadow",kc=()=>{const e=Qe("color"),r=Qe("font"),n=Qe("text"),a=Qe("font-weight"),o=Qe("tracking"),s=Qe("leading"),l=Qe("breakpoint"),i=Qe("container"),d=Qe("spacing"),h=Qe("radius"),u=Qe("shadow"),m=Qe("inset-shadow"),f=Qe("text-shadow"),p=Qe("drop-shadow"),g=Qe("blur"),b=Qe("perspective"),k=Qe("aspect"),x=Qe("ease"),j=Qe("animate"),w=()=>["auto","avoid","all","avoid-page","page","left","right","column"],y=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[...y(),me,he],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],I=()=>[me,he,d],M=()=>[St,"full","auto",...I()],R=()=>[ft,"none","subgrid",me,he],Q=()=>["auto",{span:["full",ft,me,he]},ft,me,he],$=()=>[ft,"auto",me,he],Y=()=>["auto","min","max","fr",me,he],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],P=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...I()],oe=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...I()],T=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...I()],re=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...I()],B=()=>[e,me,he],J=()=>[...y(),Pa,za,{position:[me,he]}],K=()=>["no-repeat",{repeat:["","x","y","space","round"]}],L=()=>["auto","cover","contain",gc,hc,{size:[me,he]}],q=()=>[gn,ur,$t],G=()=>["","none","full",h,me,he],E=()=>["",Pe,ur,$t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>[Pe,gn,Pa,za],se=()=>["","none",g,me,he],V=()=>["none",Pe,me,he],de=()=>["none",Pe,me,he],ee=()=>[Pe,me,he],be=()=>[St,"full",...I()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[wt],breakpoint:[wt],color:[Zs],container:[wt],"drop-shadow":[wt],ease:["in","out","in-out"],font:[dc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[wt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[wt],shadow:[wt],spacing:["px",Pe],text:[wt],"text-shadow":[wt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,he,me,k]}],container:["container"],"container-type":[{"@container":["","normal","size",me,he]}],"container-named":[cc],columns:[{columns:[Pe,he,me,i]}],"break-after":[{"break-after":w()}],"break-before":[{"break-before":w()}],"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:v()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:M()}],"inset-x":[{"inset-x":M()}],"inset-y":[{"inset-y":M()}],start:[{"inset-s":M(),start:M()}],end:[{"inset-e":M(),end:M()}],"inset-bs":[{"inset-bs":M()}],"inset-be":[{"inset-be":M()}],top:[{top:M()}],right:[{right:M()}],bottom:[{bottom:M()}],left:[{left:M()}],visibility:["visible","invisible","collapse"],z:[{z:[ft,"auto",me,he]}],basis:[{basis:[St,"full","auto",i,...I()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Pe,St,"auto","initial","none",he]}],grow:[{grow:["",Pe,me,he]}],shrink:[{shrink:["",Pe,me,he]}],order:[{order:[ft,"first","last","none",me,he]}],"grid-cols":[{"grid-cols":R()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":R()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Y()}],"auto-rows":[{"auto-rows":Y()}],gap:[{gap:I()}],"gap-x":[{"gap-x":I()}],"gap-y":[{"gap-y":I()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...P(),"normal"]}],"justify-self":[{"justify-self":["auto",...P()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...P(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...P(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...P(),"baseline"]}],"place-self":[{"place-self":["auto",...P()]}],p:[{p:I()}],px:[{px:I()}],py:[{py:I()}],ps:[{ps:I()}],pe:[{pe:I()}],pbs:[{pbs:I()}],pbe:[{pbe:I()}],pt:[{pt:I()}],pr:[{pr:I()}],pb:[{pb:I()}],pl:[{pl:I()}],m:[{m:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":I()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":I()}],"space-y-reverse":["space-y-reverse"],size:[{size:oe()}],"inline-size":[{inline:["auto",...T()]}],"min-inline-size":[{"min-inline":["auto",...T()]}],"max-inline-size":[{"max-inline":["none",...T()]}],"block-size":[{block:["auto",...re()]}],"min-block-size":[{"min-block":["auto",...re()]}],"max-block-size":[{"max-block":["none",...re()]}],w:[{w:[i,"screen",...oe()]}],"min-w":[{"min-w":[i,"screen","none",...oe()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...oe()]}],h:[{h:["screen","lh",...oe()]}],"min-h":[{"min-h":["screen","lh","none",...oe()]}],"max-h":[{"max-h":["screen","lh",...oe()]}],"font-size":[{text:["base",n,ur,$t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,bc,uc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",gn,he]}],"font-family":[{font:[fc,mc,r]}],"font-features":[{"font-features":[he]}],"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:[o,me,he]}],"line-clamp":[{"line-clamp":[Pe,"none",me,Ia]}],leading:[{leading:[s,...I()]}],"list-image":[{"list-image":["none",me,he]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,he]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:B()}],"text-color":[{text:B()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Pe,"from-font","auto",me,$t]}],"text-decoration-color":[{decoration:B()}],"underline-offset":[{"underline-offset":[Pe,"auto",me,he]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:I()}],"tab-size":[{tab:[ft,me,he]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,he]}],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",me,he]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:J()}],"bg-repeat":[{bg:K()}],"bg-size":[{bg:L()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ft,me,he],radial:["",me,he],conic:[ft,me,he]},xc,pc]}],"bg-color":[{bg:B()}],"gradient-from-pos":[{from:q()}],"gradient-via-pos":[{via:q()}],"gradient-to-pos":[{to:q()}],"gradient-from":[{from:B()}],"gradient-via":[{via:B()}],"gradient-to":[{to:B()}],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:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:B()}],"border-color-x":[{"border-x":B()}],"border-color-y":[{"border-y":B()}],"border-color-s":[{"border-s":B()}],"border-color-e":[{"border-e":B()}],"border-color-bs":[{"border-bs":B()}],"border-color-be":[{"border-be":B()}],"border-color-t":[{"border-t":B()}],"border-color-r":[{"border-r":B()}],"border-color-b":[{"border-b":B()}],"border-color-l":[{"border-l":B()}],"divide-color":[{divide:B()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Pe,me,he]}],"outline-w":[{outline:["",Pe,ur,$t]}],"outline-color":[{outline:B()}],shadow:[{shadow:["","none",u,Pr,zr]}],"shadow-color":[{shadow:B()}],"inset-shadow":[{"inset-shadow":["none",m,Pr,zr]}],"inset-shadow-color":[{"inset-shadow":B()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:B()}],"ring-offset-w":[{"ring-offset":[Pe,$t]}],"ring-offset-color":[{"ring-offset":B()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":B()}],"text-shadow":[{"text-shadow":["none",f,Pr,zr]}],"text-shadow-color":[{"text-shadow":B()}],opacity:[{opacity:[Pe,me,he]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"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":[Pe]}],"mask-image-linear-from-pos":[{"mask-linear-from":H()}],"mask-image-linear-to-pos":[{"mask-linear-to":H()}],"mask-image-linear-from-color":[{"mask-linear-from":B()}],"mask-image-linear-to-color":[{"mask-linear-to":B()}],"mask-image-t-from-pos":[{"mask-t-from":H()}],"mask-image-t-to-pos":[{"mask-t-to":H()}],"mask-image-t-from-color":[{"mask-t-from":B()}],"mask-image-t-to-color":[{"mask-t-to":B()}],"mask-image-r-from-pos":[{"mask-r-from":H()}],"mask-image-r-to-pos":[{"mask-r-to":H()}],"mask-image-r-from-color":[{"mask-r-from":B()}],"mask-image-r-to-color":[{"mask-r-to":B()}],"mask-image-b-from-pos":[{"mask-b-from":H()}],"mask-image-b-to-pos":[{"mask-b-to":H()}],"mask-image-b-from-color":[{"mask-b-from":B()}],"mask-image-b-to-color":[{"mask-b-to":B()}],"mask-image-l-from-pos":[{"mask-l-from":H()}],"mask-image-l-to-pos":[{"mask-l-to":H()}],"mask-image-l-from-color":[{"mask-l-from":B()}],"mask-image-l-to-color":[{"mask-l-to":B()}],"mask-image-x-from-pos":[{"mask-x-from":H()}],"mask-image-x-to-pos":[{"mask-x-to":H()}],"mask-image-x-from-color":[{"mask-x-from":B()}],"mask-image-x-to-color":[{"mask-x-to":B()}],"mask-image-y-from-pos":[{"mask-y-from":H()}],"mask-image-y-to-pos":[{"mask-y-to":H()}],"mask-image-y-from-color":[{"mask-y-from":B()}],"mask-image-y-to-color":[{"mask-y-to":B()}],"mask-image-radial":[{"mask-radial":[me,he]}],"mask-image-radial-from-pos":[{"mask-radial-from":H()}],"mask-image-radial-to-pos":[{"mask-radial-to":H()}],"mask-image-radial-from-color":[{"mask-radial-from":B()}],"mask-image-radial-to-color":[{"mask-radial-to":B()}],"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":y()}],"mask-image-conic-pos":[{"mask-conic":[Pe]}],"mask-image-conic-from-pos":[{"mask-conic-from":H()}],"mask-image-conic-to-pos":[{"mask-conic-to":H()}],"mask-image-conic-from-color":[{"mask-conic-from":B()}],"mask-image-conic-to-color":[{"mask-conic-to":B()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:J()}],"mask-repeat":[{mask:K()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,he]}],filter:[{filter:["","none",me,he]}],blur:[{blur:se()}],brightness:[{brightness:[Pe,me,he]}],contrast:[{contrast:[Pe,me,he]}],"drop-shadow":[{"drop-shadow":["","none",p,Pr,zr]}],"drop-shadow-color":[{"drop-shadow":B()}],grayscale:[{grayscale:["",Pe,me,he]}],"hue-rotate":[{"hue-rotate":[Pe,me,he]}],invert:[{invert:["",Pe,me,he]}],saturate:[{saturate:[Pe,me,he]}],sepia:[{sepia:["",Pe,me,he]}],"backdrop-filter":[{"backdrop-filter":["","none",me,he]}],"backdrop-blur":[{"backdrop-blur":se()}],"backdrop-brightness":[{"backdrop-brightness":[Pe,me,he]}],"backdrop-contrast":[{"backdrop-contrast":[Pe,me,he]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Pe,me,he]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Pe,me,he]}],"backdrop-invert":[{"backdrop-invert":["",Pe,me,he]}],"backdrop-opacity":[{"backdrop-opacity":[Pe,me,he]}],"backdrop-saturate":[{"backdrop-saturate":[Pe,me,he]}],"backdrop-sepia":[{"backdrop-sepia":["",Pe,me,he]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":I()}],"border-spacing-x":[{"border-spacing-x":I()}],"border-spacing-y":[{"border-spacing-y":I()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,he]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Pe,"initial",me,he]}],ease:[{ease:["linear","initial",x,me,he]}],delay:[{delay:[Pe,me,he]}],animate:[{animate:["none",j,me,he]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,me,he]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:V()}],"rotate-x":[{"rotate-x":V()}],"rotate-y":[{"rotate-y":V()}],"rotate-z":[{"rotate-z":V()}],scale:[{scale:de()}],"scale-x":[{"scale-x":de()}],"scale-y":[{"scale-y":de()}],"scale-z":[{"scale-z":de()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[me,he,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:be()}],"translate-x":[{"translate-x":be()}],"translate-y":[{"translate-y":be()}],"translate-z":[{"translate-z":be()}],"translate-none":["translate-none"],zoom:[{zoom:[ft,me,he]}],accent:[{accent:B()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:B()}],"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",me,he]}],"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":B()}],"scrollbar-track-color":[{"scrollbar-track":B()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":I()}],"scroll-mx":[{"scroll-mx":I()}],"scroll-my":[{"scroll-my":I()}],"scroll-ms":[{"scroll-ms":I()}],"scroll-me":[{"scroll-me":I()}],"scroll-mbs":[{"scroll-mbs":I()}],"scroll-mbe":[{"scroll-mbe":I()}],"scroll-mt":[{"scroll-mt":I()}],"scroll-mr":[{"scroll-mr":I()}],"scroll-mb":[{"scroll-mb":I()}],"scroll-ml":[{"scroll-ml":I()}],"scroll-p":[{"scroll-p":I()}],"scroll-px":[{"scroll-px":I()}],"scroll-py":[{"scroll-py":I()}],"scroll-ps":[{"scroll-ps":I()}],"scroll-pe":[{"scroll-pe":I()}],"scroll-pbs":[{"scroll-pbs":I()}],"scroll-pbe":[{"scroll-pbe":I()}],"scroll-pt":[{"scroll-pt":I()}],"scroll-pr":[{"scroll-pr":I()}],"scroll-pb":[{"scroll-pb":I()}],"scroll-pl":[{"scroll-pl":I()}],"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",me,he]}],fill:[{fill:["none",...B()]}],"stroke-w":[{stroke:[Pe,ur,$t,Ia]}],stroke:[{stroke:["none",...B()]}],"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":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["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-r","border-w-l"],"border-w-y":["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-r","border-color-l"],"border-color-y":["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-mr","scroll-ml"],"scroll-my":["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-pr","scroll-pl"],"scroll-py":["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"]}},wc=Jd(kc),Ra=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ma=Ws,Cr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Ma(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=r,l=Object.keys(o).map(h=>{const u=n==null?void 0:n[h],m=s==null?void 0:s[h];if(u===null)return null;const f=Ra(u)||Ra(m);return o[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[b,k]=g;return Array.isArray(k)?k.includes({...s,...i}[b]):{...s,...i}[b]===k})?[...h,m,f]:h},[]);return Ma(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Zr=c.createContext(null);Zr.displayName="PanelGroupContext";const qe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ta=10,Ot=c.useLayoutEffect,Aa=xd.useId,yc=typeof Aa=="function"?Aa:()=>null;let jc=0;function ra(e=null){const r=yc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+jc++),e??n.current}function so({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const k=c.useContext(Zr);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:w,getPanelStyle:y,groupId:v,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:I,resizePanel:M,unregisterPanel:R}=k,Q=ra(l),$=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Ot(()=>{const{callbacks:Z,constraints:P}=$.current,te={...P};$.current.id=Q,$.current.idIsFromProps=l!==void 0,$.current.order=f,Z.onCollapse=h,Z.onExpand=u,Z.onResize=m,P.collapsedSize=n,P.collapsible=a,P.defaultSize=o,P.maxSize=i,P.minSize=d,(te.collapsedSize!==P.collapsedSize||te.collapsible!==P.collapsible||te.maxSize!==P.maxSize||te.minSize!==P.minSize)&&N($.current,te)}),Ot(()=>{const Z=$.current;return I(Z),()=>{R(Z)}},[f,Q,I,R]),c.useImperativeHandle(s,()=>({collapse:()=>{x($.current)},expand:Z=>{j($.current,Z)},getId(){return Q},getSize(){return w($.current)},isCollapsed(){return S($.current)},isExpanded(){return!S($.current)},resize:Z=>{M($.current,Z)}}),[x,j,w,S,Q,M]);const Y=y($.current,o);return c.createElement(g,{...b,children:e,className:r,id:Q,style:{...Y,...p},[qe.groupId]:v,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:Q,[qe.panelSize]:parseFloat(""+Y.flexGrow).toFixed(1)})}const oo=c.forwardRef((e,r)=>c.createElement(so,{...e,forwardedRef:r}));so.displayName="Panel";oo.displayName="forwardRef(Panel)";let Rn=null,Br=-1,Et=null;function Nc(e,r,n){const a=(r&uo)!==0,o=(r&mo)!==0,s=(r&po)!==0,l=(r&fo)!==0;if(r){if(a)return s?"se-resize":l?"ne-resize":"e-resize";if(o)return s?"sw-resize":l?"nw-resize":"w-resize";if(s)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Cc(){Et!==null&&(document.head.removeChild(Et),Rn=null,Et=null,Br=-1)}function xn(e,r,n){var a,o;const s=Nc(e,r);if(Rn!==s){if(Rn=s,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Br>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Br)}Br=(a=(o=Et.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function lo(e){return e.type==="keydown"}function io(e){return e.type.startsWith("pointer")}function co(e){return e.type.startsWith("mouse")}function Jr(e){if(io(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(co(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Sc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Tc(e,r,n){return e.x<r.x+r.width&&e.x+e.width>r.x&&e.y<r.y+r.height&&e.y+e.height>r.y}function Ec(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Da(e),b:Da(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ie(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:$a(_a(n.a)),b:$a(_a(n.b))};if(o.a===o.b){const s=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=s.length;for(;i--;){const d=s[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(o.a-o.b)}const Lc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ic(e){var r;const n=getComputedStyle((r=ho(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function zc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||Ic(e))||+r.opacity<1||"transform"in r&&r.transform!=="none"||"webkitTransform"in r&&r.webkitTransform!=="none"||"mixBlendMode"in r&&r.mixBlendMode!=="normal"||"filter"in r&&r.filter!=="none"||"webkitFilter"in r&&r.webkitFilter!=="none"||"isolation"in r&&r.isolation==="isolate"||Lc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function _a(e){let r=e.length;for(;r--;){const n=e[r];if(Ie(n,"Missing node"),zc(n))return n}return null}function $a(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Da(e){const r=[];for(;e;)r.push(e),e=ho(e);return r}function ho(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const uo=1,mo=2,po=4,fo=8,Pc=Sc()==="coarse";let mt=[],or=!1,Lt=new Map,Qr=new Map;const yr=new Set;function Rc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Lt.get(l))!==null&&s!==void 0?s:0;return Lt.set(l,d+1),yr.add(i),Vr(),function(){var u;Qr.delete(e),yr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Vr(),m===1&&Lt.delete(l),mt.includes(i)){const f=mt.indexOf(i);f>=0&&mt.splice(f,1),en(),o("up",!0,null)}}}function Mc(e){const{target:r}=e,{x:n,y:a}=Jr(e);or=!0,na({target:r,x:n,y:a}),Vr(),mt.length>0&&(Kr("down",e),en(),e.preventDefault(),go(r)||e.stopImmediatePropagation())}function bn(e){const{x:r,y:n}=Jr(e);if(or&&e.type!=="pointerleave"&&e.buttons===0&&(or=!1,Kr("up",e)),!or){const{target:a}=e;na({target:a,x:r,y:n})}Kr("move",e),en(),mt.length>0&&e.preventDefault()}function vn(e){const{target:r}=e,{x:n,y:a}=Jr(e);Qr.clear(),or=!1,mt.length>0&&(e.preventDefault(),go(r)||e.stopImmediatePropagation()),Kr("up",e),na({target:r,x:n,y:a}),en(),Vr()}function go(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function na({target:e,x:r,y:n}){mt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),yr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Pc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&Ec(a,s)>0){let g=a,b=!1;for(;g&&!g.contains(s);){if(Tc(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}mt.push(o)}})}function kn(e,r){Qr.set(e,r)}function en(){let e=!1,r=!1;mt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Qr.forEach(a=>{n|=a}),e&&r?xn("intersection",n):e?xn("horizontal",n):r?xn("vertical",n):Cc()}let wn;function Vr(){var e;(e=wn)===null||e===void 0||e.abort(),wn=new AbortController;const r={capture:!0,signal:wn.signal};yr.size&&(or?(mt.length>0&&Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",vn,r),o.addEventListener("pointerleave",bn,r),o.addEventListener("pointermove",bn,r))}),Lt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",vn,r),o.addEventListener("pointercancel",vn,r)})):Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",Mc,r),o.addEventListener("pointermove",bn,r))}))}function Kr(e,r){yr.forEach(n=>{const{setResizeHandlerState:a}=n,o=mt.includes(n);a(e,o,r)})}function Ac(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ie(e,r){if(!e)throw console.error(r),Error(r)}function Ut(e,r,n=ta){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function yt(e,r,n=ta){return Ut(e,r,n)===0}function dt(e,r,n){return Ut(e,r,n)===0}function _c(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const o=e[a],s=r[a];if(!dt(o,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ie(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ut(n,i)<0)if(s){const d=(o+i)/2;Ut(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ta)),n}function xr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(dt(e,0))return r;const l=[...r],[i,d]=a;Ie(i!=null,"Invalid first pivot index"),Ie(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Ie(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const k=r[m];if(Ie(k!=null,`Previous layout not found for panel index ${m}`),dt(k,p)){const x=b-k;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ie(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const k=r[m];if(Ie(k!=null,`Previous layout not found for panel index ${m}`),dt(k,b)){const x=k-p;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const b=r[f];Ie(b!=null,`Previous layout not found for panel index ${f}`);const x=ar({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ie(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,k=ar({panelConstraints:n,panelIndex:f,size:b});if(!dt(g,k)&&(h+=g-k,l[f]=k,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(_c(o,l))return o;{const m=e<0?d:i,f=r[m];Ie(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=ar({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!dt(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ie(j!=null,`Previous layout not found for panel index ${x}`);const w=j+b,y=ar({panelConstraints:n,panelIndex:x,size:w});if(dt(j,y)||(b-=y-j,l[x]=y),dt(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return dt(u,100)?l:o}function $c({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Ie(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,o=g):(s+=b,l+=g)});const d=Math.min(o,100-s),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function jr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function xo(e,r,n=document){const o=jr(e,n).findIndex(s=>s.getAttribute(qe.resizeHandleId)===r);return o??null}function bo(e,r,n){const a=xo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Dc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function vo(e,r=document){if(Dc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function tn(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Bc(e,r,n,a=document){var o,s,l,i;const d=tn(r,a),h=jr(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Gc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Ot(()=>{if(!s)return;const i=jr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=$c({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Ie(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,o,s]),c.useEffect(()=>{if(!s)return;const i=r.current;Ie(i,"Eager values not found");const{panelDataArray:d}=i,h=vo(n,s);Ie(h!=null,`No group found for id "${n}"`);const u=jr(n,s);Ie(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);Ie(p,"Resize handle element has no handle id attribute");const[g,b]=Bc(n,p,d,s);if(g==null||b==null)return()=>{};const k=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(w=>w.id===g);if(j>=0){const w=d[j];Ie(w,`No panel data found for index ${j}`);const y=a[j],{collapsedSize:v=0,collapsible:S,minSize:N=0}=w.constraints;if(y!=null&&S){const I=xr({delta:dt(y,v)?N-v:v-y,initialLayout:a,panelConstraints:d.map(M=>M.constraints),pivotIndices:bo(n,p,s),prevLayout:a,trigger:"keyboard"});a!==I&&l(I)}}break}}};return f.addEventListener("keydown",k),()=>{f.removeEventListener("keydown",k)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Ba(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function ko(e,r){const n=e==="horizontal",{x:a,y:o}=Jr(r);return n?a:o}function Fc(e,r,n,a,o){const s=n==="horizontal",l=tn(r,o);Ie(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Ie(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ko(n,e),u=vo(i,o);Ie(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Hc(e,r,n,a,o,s){if(lo(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:o!=null?i=o:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:Fc(e,r,n,a,s)}function Oc({panelDataArray:e}){const r=Array(e.length),n=e.map(s=>s.constraints);let a=0,o=100;for(let s=0;s<e.length;s++){const l=n[s];Ie(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;i!=null&&(a++,r[s]=i,o-=i)}for(let s=0;s<e.length;s++){const l=n[s];Ie(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=o/d;a++,r[s]=h,o-=h}return r}function Jt(e,r,n){r.forEach((a,o)=>{const s=e[o];Ie(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||yt(m,h))&&!yt(a,h)&&p(),f&&(m==null||!yt(m,h))&&yt(a,h)&&f())}})}function Rr(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function Wc({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:o,precision:s=3}){const l=n[o];let i;return l==null?i=e!=null?e.toFixed(s):"1":a.length===1?i="1":i=l.toFixed(s),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function Uc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Ga(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function wo(e){return`react-resizable-panels:${e}`}function yo(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:o,order:s}=r;return o?a:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function jo(e,r){try{const n=wo(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Vc(e,r,n){var a,o;const s=(a=jo(e,n))!==null&&a!==void 0?a:{},l=yo(r);return(o=s[l])!==null&&o!==void 0?o:null}function Kc(e,r,n,a,o){var s;const l=wo(e),i=yo(r),d=(s=jo(e,o))!==null&&s!==void 0?s:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{o.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Fa({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((s,l)=>s+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!dt(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Ie(l!=null,`No layout data found for index ${s}`);const i=100/a*l;n[s]=i}let o=0;for(let s=0;s<r.length;s++){const l=n[s];Ie(l!=null,`No layout data found for index ${s}`);const i=ar({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!dt(o,0))for(let s=0;s<r.length;s++){const l=n[s];Ie(l!=null,`No layout data found for index ${s}`);const i=l+o,d=ar({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,dt(o,0)))break}return n}const qc=100,br={getItem:e=>(Ga(br),br.getItem(e)),setItem:(e,r)=>{Ga(br),br.setItem(e,r)}},Ha={};function No({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=br,style:h,tagName:u="div",...m}){const f=ra(s),p=c.useRef(null),[g,b]=c.useState(null),[k,x]=c.useState([]),j=Ac(),w=c.useRef({}),y=c.useRef(new Map),v=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:k,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:L}=N.current;return L},setLayout:L=>{const{onLayout:q}=S.current,{layout:G,panelDataArray:E}=N.current,C=Fa({layout:L,panelConstraints:E.map(W=>W.constraints)});Ba(G,C)||(x(C),N.current.layout=C,q&&q(C),Jt(E,C,w.current))}}),[]),Ot(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Gc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:k,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:L}=N.current;if(e){if(k.length===0||k.length!==L.length)return;let q=Ha[e];q==null&&(q=Uc(Kc,qc),Ha[e]=q);const G=[...L],E=new Map(y.current);q(e,G,E,k,d)}},[e,k,d]),c.useEffect(()=>{});const I=c.useCallback(L=>{const{onLayout:q}=S.current,{layout:G,panelDataArray:E}=N.current;if(L.constraints.collapsible){const C=E.map(V=>V.constraints),{collapsedSize:W=0,panelSize:H,pivotIndices:se}=Dt(E,L,G);if(Ie(H!=null,`Panel size not found for panel "${L.id}"`),!yt(H,W)){y.current.set(L.id,H);const de=er(E,L)===E.length-1?H-W:W-H,ee=xr({delta:de,initialLayout:G,panelConstraints:C,pivotIndices:se,prevLayout:G,trigger:"imperative-api"});Rr(G,ee)||(x(ee),N.current.layout=ee,q&&q(ee),Jt(E,ee,w.current))}}},[]),M=c.useCallback((L,q)=>{const{onLayout:G}=S.current,{layout:E,panelDataArray:C}=N.current;if(L.constraints.collapsible){const W=C.map(be=>be.constraints),{collapsedSize:H=0,panelSize:se=0,minSize:V=0,pivotIndices:de}=Dt(C,L,E),ee=q??V;if(yt(se,H)){const be=y.current.get(L.id),ie=be!=null&&be>=ee?be:ee,Ae=er(C,L)===C.length-1?se-ie:ie-se,ce=xr({delta:Ae,initialLayout:E,panelConstraints:W,pivotIndices:de,prevLayout:E,trigger:"imperative-api"});Rr(E,ce)||(x(ce),N.current.layout=ce,G&&G(ce),Jt(C,ce,w.current))}}},[]),R=c.useCallback(L=>{const{layout:q,panelDataArray:G}=N.current,{panelSize:E}=Dt(G,L,q);return Ie(E!=null,`Panel size not found for panel "${L.id}"`),E},[]),Q=c.useCallback((L,q)=>{const{panelDataArray:G}=N.current,E=er(G,L);return Wc({defaultSize:q,dragState:g,layout:k,panelData:G,panelIndex:E})},[g,k]),$=c.useCallback(L=>{const{layout:q,panelDataArray:G}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(G,L,q);return Ie(W!=null,`Panel size not found for panel "${L.id}"`),C===!0&&yt(W,E)},[]),Y=c.useCallback(L=>{const{layout:q,panelDataArray:G}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(G,L,q);return Ie(W!=null,`Panel size not found for panel "${L.id}"`),!C||Ut(W,E)>0},[]),Z=c.useCallback(L=>{const{panelDataArray:q}=N.current;q.push(L),q.sort((G,E)=>{const C=G.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Ot(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:L,onLayout:q,storage:G}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(L){const se=Vc(L,C,G);se&&(y.current=new Map(Object.entries(se.expandToSizes)),W=se.layout)}W==null&&(W=Oc({panelDataArray:C}));const H=Fa({layout:W,panelConstraints:C.map(se=>se.constraints)});Ba(E,H)||(x(H),N.current.layout=H,q&&q(H),Jt(C,H,w.current))}}),Ot(()=>{const L=N.current;return()=>{L.layout=[]}},[]);const P=c.useCallback(L=>{let q=!1;const G=p.current;return G&&window.getComputedStyle(G,null).getPropertyValue("direction")==="rtl"&&(q=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:H,dragState:se,id:V,keyboardResizeBy:de,onLayout:ee}=S.current,{layout:be,panelDataArray:ie}=N.current,{initialLayout:ye}=se??{},Ae=bo(V,L,W);let ce=Hc(C,L,H,se,de,W);const Ce=H==="horizontal";Ce&&q&&(ce=-ce);const Le=ie.map(ve=>ve.constraints),X=xr({delta:ce,initialLayout:ye??be,panelConstraints:Le,pivotIndices:Ae,prevLayout:be,trigger:lo(C)?"keyboard":"mouse-or-touch"}),ue=!Rr(be,X);(io(C)||co(C))&&v.current!=ce&&(v.current=ce,!ue&&ce!==0?Ce?kn(L,ce<0?uo:mo):kn(L,ce<0?po:fo):kn(L,0)),ue&&(x(X),N.current.layout=X,ee&&ee(X),Jt(ie,X,w.current))}},[]),te=c.useCallback((L,q)=>{const{onLayout:G}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(be=>be.constraints),{panelSize:H,pivotIndices:se}=Dt(C,L,E);Ie(H!=null,`Panel size not found for panel "${L.id}"`);const de=er(C,L)===C.length-1?H-q:q-H,ee=xr({delta:de,initialLayout:E,panelConstraints:W,pivotIndices:se,prevLayout:E,trigger:"imperative-api"});Rr(E,ee)||(x(ee),N.current.layout=ee,G&&G(ee),Jt(C,ee,w.current))},[]),oe=c.useCallback((L,q)=>{const{layout:G,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=q,{collapsedSize:H=0,collapsible:se,maxSize:V=100,minSize:de=0}=L.constraints,{panelSize:ee}=Dt(E,L,G);ee!=null&&(W&&se&&yt(ee,C)?yt(C,H)||te(L,H):ee<de?te(L,de):ee>V&&te(L,V))},[te]),T=c.useCallback((L,q)=>{const{direction:G}=S.current,{layout:E}=N.current;if(!p.current)return;const C=tn(L,p.current);Ie(C,`Drag handle element not found for id "${L}"`);const W=ko(G,q);b({dragHandleId:L,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),re=c.useCallback(()=>{b(null)},[]),B=c.useCallback(L=>{const{panelDataArray:q}=N.current,G=er(q,L);G>=0&&(q.splice(G,1),delete w.current[L.id],N.current.panelDataArrayChanged=!0,j())},[j]),J=c.useMemo(()=>({collapsePanel:I,direction:a,dragState:g,expandPanel:M,getPanelSize:R,getPanelStyle:Q,groupId:f,isPanelCollapsed:$,isPanelExpanded:Y,reevaluatePanelConstraints:oe,registerPanel:Z,registerResizeHandle:P,resizePanel:te,startDragging:T,stopDragging:re,unregisterPanel:B,panelGroupElement:p.current}),[I,g,a,M,R,Q,f,$,Y,oe,Z,P,te,T,re,B]),K={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Zr.Provider,{value:J},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...K,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const Co=c.forwardRef((e,r)=>c.createElement(No,{...e,forwardedRef:r}));No.displayName="PanelGroup";Co.displayName="forwardRef(PanelGroup)";function er(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=er(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Xc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=tn(r,a);if(o==null)return;const s=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=o.getAttribute(qe.groupId);Ie(i,`No group element found for id "${i}"`);const d=jr(i,a),h=xo(i,r,a);Ie(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[a,e,r,n])}function So({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:o,onBlur:s,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,k;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const w=c.useContext(Zr);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:y,groupId:v,registerResizeHandle:S,startDragging:N,stopDragging:I,panelGroupElement:M}=w,R=ra(o),[Q,$]=c.useState("inactive"),[Y,Z]=c.useState(!1),[P,te]=c.useState(null),oe=c.useRef({state:Q});Ot(()=>{oe.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const J=S(R);te(()=>J)}},[n,R,S]);const T=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,re=(k=a==null?void 0:a.fine)!==null&&k!==void 0?k:5;c.useEffect(()=>{if(n||P==null)return;const J=x.current;Ie(J,"Element ref not attached");let K=!1;return Rc(R,J,y,{coarse:T,fine:re},(q,G,E)=>{if(!G){$("inactive");return}switch(q){case"down":{$("drag"),K=!1,Ie(E,'Expected event to be defined for "down" action'),N(R,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=oe.current;K=!0,C!=="drag"&&$("hover"),Ie(E,'Expected event to be defined for "move" action'),P(E);break}case"up":{$("hover"),I();const{onClick:C,onDragging:W,onPointerUp:H}=j.current;W==null||W(!1),H==null||H(),K||C==null||C();break}}})},[T,y,n,re,S,R,P,N,I]),Xc({disabled:n,handleId:R,resizeHandler:P,panelGroupElement:M});const B={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),d==null||d()},ref:x,role:"separator",style:{...B,...m},tabIndex:f,[qe.groupDirection]:y,[qe.groupId]:v,[qe.resizeHandle]:"",[qe.resizeHandleActive]:Q==="drag"?"pointer":Y?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:R,[qe.resizeHandleState]:Q})}So.displayName="PanelResizeHandle";var Yc=Object.defineProperty,Zc=Object.getOwnPropertyNames,Oe=(e,r)=>function(){return e&&(r=(0,e[Zc(e)[0]])(e=0)),r},Jc=(e,r)=>{for(var n in r)Yc(e,n,{get:r[n],enumerable:!0})};function rt(...e){return wc(Ws(e))}var Pt=Oe({"src/components/graph-ui/utils.ts"(){}});function Nr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?Gs:"button";return t.jsx(s,{"data-slot":"button",className:rt(To({variant:a,size:n,className:r})),...o})}var To,rn=Oe({"src/components/graph-ui/Button.tsx"(){Pt(),To=Cr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function Eo(...e){return e.filter(Boolean).join(" ")}function Mn({className:e,...r}){return t.jsx(Co,{"data-slot":"resizable-panel-group",className:Eo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function sr({...e}){return t.jsx(oo,{"data-slot":"resizable-panel",...e})}function An({withHandle:e,className:r,...n}){return t.jsx(So,{"data-slot":"resizable-handle",className:Eo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(D.GripVerticalIcon,{className:"size-2.5"})}):null})}var Lo=Oe({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function aa(...e){return e.filter(Boolean).join(" ")}function Sr({...e}){return t.jsx(Ki,{"data-slot":"accordion",...e})}function Tr({className:e,...r}){return t.jsx(qi,{"data-slot":"accordion-item",className:aa("border-b last:border-b-0",e),...r})}function nn({className:e,children:r,...n}){return t.jsx(Yi,{className:"flex",children:t.jsxs(Zi,{"data-slot":"accordion-trigger",className:aa("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(D.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Er({className:e,children:r,...n}){return t.jsx(Xi,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:aa("pb-4 pt-0",e),children:r})})}var Lr=Oe({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Qc(e){var n;const r=[];for(const a of e.turns)for(const o of a.items)o.kind==="artifact"&&o.artifact&&r.push(o.artifact);for(const a of((n=e.liveItems)==null?void 0:n.items)??[])a.kind==="artifact"&&a.artifact&&r.push(a.artifact);return r}function eh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Ir(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function th(e){return e.split("/").filter(Boolean).at(-1)??e}function tr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(tr);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function Io(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let o=!1;const s=e.children.map(l=>{const i=Io(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function zo(e){if(e.kind==="file")return e;for(const r of e.children){const n=zo(r);if(n)return n}return null}function _n(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=_n(n,r);if(a)return a}return null}function Po(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function rh(e){const n=Po(e).split("/").filter(Boolean);n.pop();const a=[];let o="";for(const s of n)o=o?`${o}/${s}`:s,a.push(o);return a}function $n(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const o=e.children.map(s=>{const l=$n(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function Dn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Dn(n,r))}function nh(e){if(!e)return null;const r=Ir(e.path);return sa.has(r)?{content:[e.content.endsWith(`
2
+ import{l as _,R as Yi,I as Zi,C as Ji,S as Gs,H as Qi,T as ed,a as td,b as rd,c as nd,d as ad,e as sd,D as od,P as ld,O as id,f as dd,g as cd,h as hd,i as ud,j as md,k as pd,m as fd,n as gd,A as xd,o as bd,p as vd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as kd,j as t,b as Yr}from"./react-vendor-Dfg_6BLf.js";import{u as wd,a as yd,H as Na,P as Gt,b as jd,M as Fs,R as Nd,i as Cd,C as Sd,B as Td,c as Ca,g as Hs}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as Ed,r as Ld,a as Id,b as zd}from"./markdown-vendor-RZk8L7-L.js";const Pd="modulepreload",Rd=function(e){return"/"+e},Sa={},Xe=function(r,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.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]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=l(n.map(h=>{if(h=Rd(h),h in Sa)return;Sa[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":Pd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return o.then(l=>{for(const i of l||[])i.status==="rejected"&&s(i.reason);return r().catch(s)})};function Os(e){var r,n,a="";if(typeof e=="string"||typeof e=="number")a+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r<o;r++)e[r]&&(n=Os(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ws(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Os(e))&&(a&&(a+=" "),a+=r);return a}const Md=(e,r)=>{const n=new Array(e.length+r.length);for(let a=0;a<e.length;a++)n[a]=e[a];for(let a=0;a<r.length;a++)n[e.length+a]=r[a];return n},Ad=(e,r)=>({classGroupId:e,validator:r}),Us=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Ur="-",Ta=[],_d="arbitrary..",$d=e=>{const r=Bd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Dd(l);const i=l.split(Ur),d=i[0]===""&&i.length>1?1:0;return Vs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?Md(h,d):d:h||Ta}return n[l]||Ta}}},Vs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Vs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Ur):e.slice(r).join(Ur),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Dd=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const r=e.slice(1,-1),n=r.indexOf(":"),a=r.slice(0,n);return a?_d+a:void 0})(),Bd=e=>{const{theme:r,classGroups:n}=e;return Gd(n,r)},Gd=(e,r)=>{const n=Us();for(const a in e){const o=e[a];Qn(o,n,a,r)}return n},Qn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Fd(l,r,n,a)}},Fd=(e,r,n,a)=>{if(typeof e=="string"){Hd(e,r,n);return}if(typeof e=="function"){Od(e,r,n,a);return}Wd(e,r,n,a)},Hd=(e,r,n)=>{const a=e===""?r:qs(r,e);a.classGroupId=n},Od=(e,r,n,a)=>{if(Ud(e)){Qn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Ad(n,e))},Wd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Qn(d,qs(r,i),n,a)}},qs=(e,r)=>{let n=e;const a=r.split(Ur),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Us(),n.nextPart.set(l,i)),n=i}return n},Ud=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Vd=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,n=Object.create(null),a=Object.create(null);const o=(s,l)=>{n[s]=l,r++,r>e&&(r=0,a=n,n=Object.create(null))};return{get(s){let l=n[s];if(l!==void 0)return l;if((l=a[s])!==void 0)return o(s,l),l},set(s,l){s in n?n[s]=l:o(s,l)}}},Pn="!",Ea=":",qd=[],La=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Kd=e=>{const{prefix:r,experimentalParseClassName:n}=e;let a=o=>{const s=[];let l=0,i=0,d=0,h;const u=o.length;for(let b=0;b<u;b++){const w=o[b];if(l===0&&i===0){if(w===Ea){s.push(o.slice(d,b)),d=b+1;continue}if(w==="/"){h=b;continue}}w==="["?l++:w==="]"?l--:w==="("?i++:w===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Pn)?(f=m.slice(0,-1),p=!0):m.startsWith(Pn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return La(s,p,f,g)};if(r){const o=r+Ea,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):La(qd,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Xd=e=>{const r=new Map;return e.orderSensitiveModifiers.forEach((n,a)=>{r.set(n,1e6+a)}),n=>{const a=[];let o=[];for(let s=0;s<n.length;s++){const l=n[s],i=l[0]==="[",d=r.has(l);i||d?(o.length>0&&(o.sort(),a.push(...o),o=[]),a.push(l)):o.push(l)}return o.length>0&&(o.sort(),a.push(...o)),a}},Yd=e=>({cache:Vd(e.cacheSize),parseClassName:Kd(e),sortModifiers:Xd(e),postfixLookupClassGroupIds:Zd(e),...$d(e)}),Zd=e=>{const r=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let a=0;a<n.length;a++)r[n[a]]=!0;return r},Jd=/\s+/,Qd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Jd);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:b,maybePostfixModifierPosition:w}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!w,j;if(x){const N=b.substring(0,w);j=a(N);const L=j&&l[j]?a(b):void 0;L&&L!==j&&(j=L,x=!1)}else j=a(b);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(b),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:s(p).join(":"),v=g?y+Pn:y,k=v+j;if(i.indexOf(k)>-1)continue;i.push(k);const S=o(j,x);for(let N=0;N<S.length;++N){const L=S[N];i.push(v+L)}h=m+(h.length>0?" "+h:h)}return h},ec=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Ks(n))&&(o&&(o+=" "),o+=a);return o},Ks=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Ks(e[a]))&&(n&&(n+=" "),n+=r);return n},tc=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Yd(h),a=n.cache.get,o=n.cache.set,s=i,i(d)},i=d=>{const h=a(d);if(h)return h;const u=Qd(d,n);return o(d,u),u};return s=l,(...d)=>s(ec(...d))},rc=[],Je=e=>{const r=n=>n[e]||rc;return r.isThemeGetter=!0,r},Xs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Ys=/^\((?:(\w[\w-]*):)?(.+)\)$/i,nc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,ac=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,sc=/\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$/,oc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,lc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,ic=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,St=e=>nc.test(e),Ie=e=>!!e&&!Number.isNaN(Number(e)),xt=e=>!!e&&Number.isInteger(Number(e)),gn=e=>e.endsWith("%")&&Ie(e.slice(0,-1)),jt=e=>ac.test(e),Zs=()=>!0,dc=e=>sc.test(e)&&!oc.test(e),ea=()=>!1,cc=e=>lc.test(e),hc=e=>ic.test(e),uc=e=>!he(e)&&!me(e),mc=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)),pc=e=>zt(e,eo,ea),he=e=>Xs.test(e),$t=e=>zt(e,to,dc),Ia=e=>zt(e,yc,Ie),fc=e=>zt(e,no,Zs),gc=e=>zt(e,ro,ea),za=e=>zt(e,Js,ea),xc=e=>zt(e,Qs,hc),zr=e=>zt(e,ao,cc),me=e=>Ys.test(e),ur=e=>Vt(e,to),bc=e=>Vt(e,ro),Pa=e=>Vt(e,Js),vc=e=>Vt(e,eo),kc=e=>Vt(e,Qs),Pr=e=>Vt(e,ao,!0),wc=e=>Vt(e,no,!0),zt=(e,r,n)=>{const a=Xs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Vt=(e,r,n=!1)=>{const a=Ys.exec(e);return a?a[1]?r(a[1]):n:!1},Js=e=>e==="position"||e==="percentage",Qs=e=>e==="image"||e==="url",eo=e=>e==="length"||e==="size"||e==="bg-size",to=e=>e==="length",yc=e=>e==="number",ro=e=>e==="family-name",no=e=>e==="number"||e==="weight",ao=e=>e==="shadow",jc=()=>{const e=Je("color"),r=Je("font"),n=Je("text"),a=Je("font-weight"),o=Je("tracking"),s=Je("leading"),l=Je("breakpoint"),i=Je("container"),d=Je("spacing"),h=Je("radius"),u=Je("shadow"),m=Je("inset-shadow"),f=Je("text-shadow"),p=Je("drop-shadow"),g=Je("blur"),b=Je("perspective"),w=Je("aspect"),x=Je("ease"),j=Je("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...v(),me,he],S=()=>["auto","hidden","clip","visible","scroll"],N=()=>["auto","contain","none"],L=()=>[me,he,d],R=()=>[St,"full","auto",...L()],P=()=>[xt,"none","subgrid",me,he],Q=()=>["auto",{span:["full",xt,me,he]},xt,me,he],D=()=>[xt,"auto",me,he],Z=()=>["auto","min","max","fr",me,he],J=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],te=()=>["auto",...L()],se=()=>[St,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],$=()=>[St,"screen","full","dvw","lvw","svw","min","max","fit",...L()],le=()=>[St,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],q=()=>[e,me,he],H=()=>[...v(),Pa,za,{position:[me,he]}],G=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",vc,pc,{size:[me,he]}],F=()=>[gn,ur,$t],B=()=>["","none","full",h,me,he],E=()=>["",Ie,ur,$t],C=()=>["solid","dashed","dotted","double"],W=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],U=()=>[Ie,gn,Pa,za],ne=()=>["","none",g,me,he],K=()=>["none",Ie,me,he],ie=()=>["none",Ie,me,he],ee=()=>[Ie,me,he],ve=()=>[St,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[jt],breakpoint:[jt],color:[Zs],container:[jt],"drop-shadow":[jt],ease:["in","out","in-out"],font:[uc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[jt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[jt],shadow:[jt],spacing:["px",Ie],text:[jt],"text-shadow":[jt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",St,he,me,w]}],container:["container"],"container-type":[{"@container":["","normal","size",me,he]}],"container-named":[mc],columns:[{columns:[Ie,he,me,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"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:k()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:N()}],"overscroll-x":[{"overscroll-x":N()}],"overscroll-y":[{"overscroll-y":N()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:R()}],"inset-x":[{"inset-x":R()}],"inset-y":[{"inset-y":R()}],start:[{"inset-s":R(),start:R()}],end:[{"inset-e":R(),end:R()}],"inset-bs":[{"inset-bs":R()}],"inset-be":[{"inset-be":R()}],top:[{top:R()}],right:[{right:R()}],bottom:[{bottom:R()}],left:[{left:R()}],visibility:["visible","invisible","collapse"],z:[{z:[xt,"auto",me,he]}],basis:[{basis:[St,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Ie,St,"auto","initial","none",he]}],grow:[{grow:["",Ie,me,he]}],shrink:[{shrink:["",Ie,me,he]}],order:[{order:[xt,"first","last","none",me,he]}],"grid-cols":[{"grid-cols":P()}],"col-start-end":[{col:Q()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":P()}],"row-start-end":[{row:Q()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Z()}],"auto-rows":[{"auto-rows":Z()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...J(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...J()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":J()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:L()}],px:[{px:L()}],py:[{py:L()}],ps:[{ps:L()}],pe:[{pe:L()}],pbs:[{pbs:L()}],pbe:[{pbe:L()}],pt:[{pt:L()}],pr:[{pr:L()}],pb:[{pb:L()}],pl:[{pl:L()}],m:[{m:te()}],mx:[{mx:te()}],my:[{my:te()}],ms:[{ms:te()}],me:[{me:te()}],mbs:[{mbs:te()}],mbe:[{mbe:te()}],mt:[{mt:te()}],mr:[{mr:te()}],mb:[{mb:te()}],ml:[{ml:te()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:se()}],"inline-size":[{inline:["auto",...$()]}],"min-inline-size":[{"min-inline":["auto",...$()]}],"max-inline-size":[{"max-inline":["none",...$()]}],"block-size":[{block:["auto",...le()]}],"min-block-size":[{"min-block":["auto",...le()]}],"max-block-size":[{"max-block":["none",...le()]}],w:[{w:[i,"screen",...se()]}],"min-w":[{"min-w":[i,"screen","none",...se()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...se()]}],h:[{h:["screen","lh",...se()]}],"min-h":[{"min-h":["screen","lh","none",...se()]}],"max-h":[{"max-h":["screen","lh",...se()]}],"font-size":[{text:["base",n,ur,$t]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,wc,fc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",gn,he]}],"font-family":[{font:[bc,gc,r]}],"font-features":[{"font-features":[he]}],"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:[o,me,he]}],"line-clamp":[{"line-clamp":[Ie,"none",me,Ia]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",me,he]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,he]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:q()}],"text-color":[{text:q()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...C(),"wavy"]}],"text-decoration-thickness":[{decoration:[Ie,"from-font","auto",me,$t]}],"text-decoration-color":[{decoration:q()}],"underline-offset":[{"underline-offset":[Ie,"auto",me,he]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:L()}],"tab-size":[{tab:[xt,me,he]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,he]}],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",me,he]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:H()}],"bg-repeat":[{bg:G()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},xt,me,he],radial:["",me,he],conic:[xt,me,he]},kc,xc]}],"bg-color":[{bg:q()}],"gradient-from-pos":[{from:F()}],"gradient-via-pos":[{via:F()}],"gradient-to-pos":[{to:F()}],"gradient-from":[{from:q()}],"gradient-via":[{via:q()}],"gradient-to":[{to:q()}],rounded:[{rounded:B()}],"rounded-s":[{"rounded-s":B()}],"rounded-e":[{"rounded-e":B()}],"rounded-t":[{"rounded-t":B()}],"rounded-r":[{"rounded-r":B()}],"rounded-b":[{"rounded-b":B()}],"rounded-l":[{"rounded-l":B()}],"rounded-ss":[{"rounded-ss":B()}],"rounded-se":[{"rounded-se":B()}],"rounded-ee":[{"rounded-ee":B()}],"rounded-es":[{"rounded-es":B()}],"rounded-tl":[{"rounded-tl":B()}],"rounded-tr":[{"rounded-tr":B()}],"rounded-br":[{"rounded-br":B()}],"rounded-bl":[{"rounded-bl":B()}],"border-w":[{border:E()}],"border-w-x":[{"border-x":E()}],"border-w-y":[{"border-y":E()}],"border-w-s":[{"border-s":E()}],"border-w-e":[{"border-e":E()}],"border-w-bs":[{"border-bs":E()}],"border-w-be":[{"border-be":E()}],"border-w-t":[{"border-t":E()}],"border-w-r":[{"border-r":E()}],"border-w-b":[{"border-b":E()}],"border-w-l":[{"border-l":E()}],"divide-x":[{"divide-x":E()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":E()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...C(),"hidden","none"]}],"divide-style":[{divide:[...C(),"hidden","none"]}],"border-color":[{border:q()}],"border-color-x":[{"border-x":q()}],"border-color-y":[{"border-y":q()}],"border-color-s":[{"border-s":q()}],"border-color-e":[{"border-e":q()}],"border-color-bs":[{"border-bs":q()}],"border-color-be":[{"border-be":q()}],"border-color-t":[{"border-t":q()}],"border-color-r":[{"border-r":q()}],"border-color-b":[{"border-b":q()}],"border-color-l":[{"border-l":q()}],"divide-color":[{divide:q()}],"outline-style":[{outline:[...C(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Ie,me,he]}],"outline-w":[{outline:["",Ie,ur,$t]}],"outline-color":[{outline:q()}],shadow:[{shadow:["","none",u,Pr,zr]}],"shadow-color":[{shadow:q()}],"inset-shadow":[{"inset-shadow":["none",m,Pr,zr]}],"inset-shadow-color":[{"inset-shadow":q()}],"ring-w":[{ring:E()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:q()}],"ring-offset-w":[{"ring-offset":[Ie,$t]}],"ring-offset-color":[{"ring-offset":q()}],"inset-ring-w":[{"inset-ring":E()}],"inset-ring-color":[{"inset-ring":q()}],"text-shadow":[{"text-shadow":["none",f,Pr,zr]}],"text-shadow-color":[{"text-shadow":q()}],opacity:[{opacity:[Ie,me,he]}],"mix-blend":[{"mix-blend":[...W(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":W()}],"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":[Ie]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":q()}],"mask-image-linear-to-color":[{"mask-linear-to":q()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":q()}],"mask-image-t-to-color":[{"mask-t-to":q()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":q()}],"mask-image-r-to-color":[{"mask-r-to":q()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":q()}],"mask-image-b-to-color":[{"mask-b-to":q()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":q()}],"mask-image-l-to-color":[{"mask-l-to":q()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":q()}],"mask-image-x-to-color":[{"mask-x-to":q()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":q()}],"mask-image-y-to-color":[{"mask-y-to":q()}],"mask-image-radial":[{"mask-radial":[me,he]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":q()}],"mask-image-radial-to-color":[{"mask-radial-to":q()}],"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":v()}],"mask-image-conic-pos":[{"mask-conic":[Ie]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":q()}],"mask-image-conic-to-color":[{"mask-conic-to":q()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:H()}],"mask-repeat":[{mask:G()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,he]}],filter:[{filter:["","none",me,he]}],blur:[{blur:ne()}],brightness:[{brightness:[Ie,me,he]}],contrast:[{contrast:[Ie,me,he]}],"drop-shadow":[{"drop-shadow":["","none",p,Pr,zr]}],"drop-shadow-color":[{"drop-shadow":q()}],grayscale:[{grayscale:["",Ie,me,he]}],"hue-rotate":[{"hue-rotate":[Ie,me,he]}],invert:[{invert:["",Ie,me,he]}],saturate:[{saturate:[Ie,me,he]}],sepia:[{sepia:["",Ie,me,he]}],"backdrop-filter":[{"backdrop-filter":["","none",me,he]}],"backdrop-blur":[{"backdrop-blur":ne()}],"backdrop-brightness":[{"backdrop-brightness":[Ie,me,he]}],"backdrop-contrast":[{"backdrop-contrast":[Ie,me,he]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Ie,me,he]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Ie,me,he]}],"backdrop-invert":[{"backdrop-invert":["",Ie,me,he]}],"backdrop-opacity":[{"backdrop-opacity":[Ie,me,he]}],"backdrop-saturate":[{"backdrop-saturate":[Ie,me,he]}],"backdrop-sepia":[{"backdrop-sepia":["",Ie,me,he]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":L()}],"border-spacing-x":[{"border-spacing-x":L()}],"border-spacing-y":[{"border-spacing-y":L()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,he]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Ie,"initial",me,he]}],ease:[{ease:["linear","initial",x,me,he]}],delay:[{delay:[Ie,me,he]}],animate:[{animate:["none",j,me,he]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[b,me,he]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:ie()}],"scale-x":[{"scale-x":ie()}],"scale-y":[{"scale-y":ie()}],"scale-z":[{"scale-z":ie()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[me,he,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ve()}],"translate-x":[{"translate-x":ve()}],"translate-y":[{"translate-y":ve()}],"translate-z":[{"translate-z":ve()}],"translate-none":["translate-none"],zoom:[{zoom:[xt,me,he]}],accent:[{accent:q()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:q()}],"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",me,he]}],"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":q()}],"scrollbar-track-color":[{"scrollbar-track":q()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":L()}],"scroll-mx":[{"scroll-mx":L()}],"scroll-my":[{"scroll-my":L()}],"scroll-ms":[{"scroll-ms":L()}],"scroll-me":[{"scroll-me":L()}],"scroll-mbs":[{"scroll-mbs":L()}],"scroll-mbe":[{"scroll-mbe":L()}],"scroll-mt":[{"scroll-mt":L()}],"scroll-mr":[{"scroll-mr":L()}],"scroll-mb":[{"scroll-mb":L()}],"scroll-ml":[{"scroll-ml":L()}],"scroll-p":[{"scroll-p":L()}],"scroll-px":[{"scroll-px":L()}],"scroll-py":[{"scroll-py":L()}],"scroll-ps":[{"scroll-ps":L()}],"scroll-pe":[{"scroll-pe":L()}],"scroll-pbs":[{"scroll-pbs":L()}],"scroll-pbe":[{"scroll-pbe":L()}],"scroll-pt":[{"scroll-pt":L()}],"scroll-pr":[{"scroll-pr":L()}],"scroll-pb":[{"scroll-pb":L()}],"scroll-pl":[{"scroll-pl":L()}],"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",me,he]}],fill:[{fill:["none",...q()]}],"stroke-w":[{stroke:[Ie,ur,$t,Ia]}],stroke:[{stroke:["none",...q()]}],"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":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["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-r","border-w-l"],"border-w-y":["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-r","border-color-l"],"border-color-y":["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-mr","scroll-ml"],"scroll-my":["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-pr","scroll-pl"],"scroll-py":["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"]}},Nc=tc(jc),Ra=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ma=Ws,Cr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return Ma(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=r,l=Object.keys(o).map(h=>{const u=n==null?void 0:n[h],m=s==null?void 0:s[h];if(u===null)return null;const f=Ra(u)||Ra(m);return o[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[b,w]=g;return Array.isArray(w)?w.includes({...s,...i}[b]):{...s,...i}[b]===w})?[...h,m,f]:h},[]);return Ma(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Zr=c.createContext(null);Zr.displayName="PanelGroupContext";const qe={group:"data-panel-group",groupDirection:"data-panel-group-direction",groupId:"data-panel-group-id",panel:"data-panel",panelCollapsible:"data-panel-collapsible",panelId:"data-panel-id",panelSize:"data-panel-size",resizeHandle:"data-resize-handle",resizeHandleActive:"data-resize-handle-active",resizeHandleEnabled:"data-panel-resize-handle-enabled",resizeHandleId:"data-panel-resize-handle-id",resizeHandleState:"data-resize-handle-state"},ta=10,Ot=c.useLayoutEffect,Aa=kd.useId,Cc=typeof Aa=="function"?Aa:()=>null;let Sc=0;function ra(e=null){const r=Cc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+Sc++),e??n.current}function so({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...b}){const w=c.useContext(Zr);if(w===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:v,groupId:k,isPanelCollapsed:S,reevaluatePanelConstraints:N,registerPanel:L,resizePanel:R,unregisterPanel:P}=w,Q=ra(l),D=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:Q,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Ot(()=>{const{callbacks:J,constraints:z}=D.current,te={...z};D.current.id=Q,D.current.idIsFromProps=l!==void 0,D.current.order=f,J.onCollapse=h,J.onExpand=u,J.onResize=m,z.collapsedSize=n,z.collapsible=a,z.defaultSize=o,z.maxSize=i,z.minSize=d,(te.collapsedSize!==z.collapsedSize||te.collapsible!==z.collapsible||te.maxSize!==z.maxSize||te.minSize!==z.minSize)&&N(D.current,te)}),Ot(()=>{const J=D.current;return L(J),()=>{P(J)}},[f,Q,L,P]),c.useImperativeHandle(s,()=>({collapse:()=>{x(D.current)},expand:J=>{j(D.current,J)},getId(){return Q},getSize(){return y(D.current)},isCollapsed(){return S(D.current)},isExpanded(){return!S(D.current)},resize:J=>{R(D.current,J)}}),[x,j,y,S,Q,R]);const Z=v(D.current,o);return c.createElement(g,{...b,children:e,className:r,id:Q,style:{...Z,...p},[qe.groupId]:k,[qe.panel]:"",[qe.panelCollapsible]:a||void 0,[qe.panelId]:Q,[qe.panelSize]:parseFloat(""+Z.flexGrow).toFixed(1)})}const oo=c.forwardRef((e,r)=>c.createElement(so,{...e,forwardedRef:r}));so.displayName="Panel";oo.displayName="forwardRef(Panel)";let Rn=null,Br=-1,Et=null;function Tc(e,r,n){const a=(r&uo)!==0,o=(r&mo)!==0,s=(r&po)!==0,l=(r&fo)!==0;if(r){if(a)return s?"se-resize":l?"ne-resize":"e-resize";if(o)return s?"sw-resize":l?"nw-resize":"w-resize";if(s)return"s-resize";if(l)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}function Ec(){Et!==null&&(document.head.removeChild(Et),Rn=null,Et=null,Br=-1)}function xn(e,r,n){var a,o;const s=Tc(e,r);if(Rn!==s){if(Rn=s,Et===null&&(Et=document.createElement("style"),document.head.appendChild(Et)),Br>=0){var l;(l=Et.sheet)===null||l===void 0||l.removeRule(Br)}Br=(a=(o=Et.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function lo(e){return e.type==="keydown"}function io(e){return e.type.startsWith("pointer")}function co(e){return e.type.startsWith("mouse")}function Jr(e){if(io(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(co(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function Lc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function Ic(e,r,n){return e.x<r.x+r.width&&e.x+e.width>r.x&&e.y<r.y+r.height&&e.y+e.height>r.y}function zc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Da(e),b:Da(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Le(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:$a(_a(n.a)),b:$a(_a(n.b))};if(o.a===o.b){const s=a.childNodes,l={a:n.a.at(-1),b:n.b.at(-1)};let i=s.length;for(;i--;){const d=s[i];if(d===l.a)return 1;if(d===l.b)return-1}}return Math.sign(o.a-o.b)}const Pc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Rc(e){var r;const n=getComputedStyle((r=ho(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function Mc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||Rc(e))||+r.opacity<1||"transform"in r&&r.transform!=="none"||"webkitTransform"in r&&r.webkitTransform!=="none"||"mixBlendMode"in r&&r.mixBlendMode!=="normal"||"filter"in r&&r.filter!=="none"||"webkitFilter"in r&&r.webkitFilter!=="none"||"isolation"in r&&r.isolation==="isolate"||Pc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function _a(e){let r=e.length;for(;r--;){const n=e[r];if(Le(n,"Missing node"),Mc(n))return n}return null}function $a(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Da(e){const r=[];for(;e;)r.push(e),e=ho(e);return r}function ho(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const uo=1,mo=2,po=4,fo=8,Ac=Lc()==="coarse";let pt=[],or=!1,Lt=new Map,Qr=new Map;const yr=new Set;function _c(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Lt.get(l))!==null&&s!==void 0?s:0;return Lt.set(l,d+1),yr.add(i),Vr(),function(){var u;Qr.delete(e),yr.delete(i);const m=(u=Lt.get(l))!==null&&u!==void 0?u:1;if(Lt.set(l,m-1),Vr(),m===1&&Lt.delete(l),pt.includes(i)){const f=pt.indexOf(i);f>=0&&pt.splice(f,1),en(),o("up",!0,null)}}}function $c(e){const{target:r}=e,{x:n,y:a}=Jr(e);or=!0,na({target:r,x:n,y:a}),Vr(),pt.length>0&&(qr("down",e),en(),e.preventDefault(),go(r)||e.stopImmediatePropagation())}function bn(e){const{x:r,y:n}=Jr(e);if(or&&e.type!=="pointerleave"&&e.buttons===0&&(or=!1,qr("up",e)),!or){const{target:a}=e;na({target:a,x:r,y:n})}qr("move",e),en(),pt.length>0&&e.preventDefault()}function vn(e){const{target:r}=e,{x:n,y:a}=Jr(e);Qr.clear(),or=!1,pt.length>0&&(e.preventDefault(),go(r)||e.stopImmediatePropagation()),qr("up",e),na({target:r,x:n,y:a}),en(),Vr()}function go(e){let r=e;for(;r;){if(r.hasAttribute(qe.resizeHandle))return!0;r=r.parentElement}return!1}function na({target:e,x:r,y:n}){pt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),yr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Ac?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&zc(a,s)>0){let g=a,b=!1;for(;g&&!g.contains(s);){if(Ic(g.getBoundingClientRect(),i)){b=!0;break}g=g.parentElement}if(b)return}pt.push(o)}})}function kn(e,r){Qr.set(e,r)}function en(){let e=!1,r=!1;pt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Qr.forEach(a=>{n|=a}),e&&r?xn("intersection",n):e?xn("horizontal",n):r?xn("vertical",n):Ec()}let wn;function Vr(){var e;(e=wn)===null||e===void 0||e.abort(),wn=new AbortController;const r={capture:!0,signal:wn.signal};yr.size&&(or?(pt.length>0&&Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",vn,r),o.addEventListener("pointerleave",bn,r),o.addEventListener("pointermove",bn,r))}),Lt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",vn,r),o.addEventListener("pointercancel",vn,r)})):Lt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",$c,r),o.addEventListener("pointermove",bn,r))}))}function qr(e,r){yr.forEach(n=>{const{setResizeHandlerState:a}=n,o=pt.includes(n);a(e,o,r)})}function Dc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Le(e,r){if(!e)throw console.error(r),Error(r)}function Ut(e,r,n=ta){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function Nt(e,r,n=ta){return Ut(e,r,n)===0}function ht(e,r,n){return Ut(e,r,n)===0}function Bc(e,r,n){if(e.length!==r.length)return!1;for(let a=0;a<e.length;a++){const o=e[a],s=r[a];if(!ht(o,s,n))return!1}return!0}function ar({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Le(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ut(n,i)<0)if(s){const d=(o+i)/2;Ut(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(ta)),n}function xr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(ht(e,0))return r;const l=[...r],[i,d]=a;Le(i!=null,"Invalid first pivot index"),Le(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Le(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const w=r[m];if(Le(w!=null,`Previous layout not found for panel index ${m}`),ht(w,p)){const x=b-w;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Le(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:b=0}=f;if(g){const w=r[m];if(Le(w!=null,`Previous layout not found for panel index ${m}`),ht(w,b)){const x=w-p;Ut(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const b=r[f];Le(b!=null,`Previous layout not found for panel index ${f}`);const x=ar({panelConstraints:n,panelIndex:f,size:100})-b;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Le(g!=null,`Previous layout not found for panel index ${f}`);const b=g-p,w=ar({panelConstraints:n,panelIndex:f,size:b});if(!ht(g,w)&&(h+=g-w,l[f]=w,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Bc(o,l))return o;{const m=e<0?d:i,f=r[m];Le(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=ar({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!ht(g,p)){let b=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Le(j!=null,`Previous layout not found for panel index ${x}`);const y=j+b,v=ar({panelConstraints:n,panelIndex:x,size:y});if(ht(j,v)||(b-=v-j,l[x]=v),ht(b,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return ht(u,100)?l:o}function Gc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Le(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:b=0}=p;f===i?(a=b,o=g):(s+=b,l+=g)});const d=Math.min(o,100-s),h=Math.max(a,100-l),u=e[i];return{valueMax:d,valueMin:h,valueNow:u}}function jr(e,r=document){return Array.from(r.querySelectorAll(`[${qe.resizeHandleId}][data-panel-group-id="${e}"]`))}function xo(e,r,n=document){const o=jr(e,n).findIndex(s=>s.getAttribute(qe.resizeHandleId)===r);return o??null}function bo(e,r,n){const a=xo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Fc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function vo(e,r=document){if(Fc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function tn(e,r=document){const n=r.querySelector(`[${qe.resizeHandleId}="${e}"]`);return n||null}function Hc(e,r,n,a=document){var o,s,l,i;const d=tn(r,a),h=jr(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Oc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Ot(()=>{if(!s)return;const i=jr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Gc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Le(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,o,s]),c.useEffect(()=>{if(!s)return;const i=r.current;Le(i,"Eager values not found");const{panelDataArray:d}=i,h=vo(n,s);Le(h!=null,`No group found for id "${n}"`);const u=jr(n,s);Le(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(qe.resizeHandleId);Le(p,"Resize handle element has no handle id attribute");const[g,b]=Hc(n,p,d,s);if(g==null||b==null)return()=>{};const w=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Le(y,`No panel data found for index ${j}`);const v=a[j],{collapsedSize:k=0,collapsible:S,minSize:N=0}=y.constraints;if(v!=null&&S){const L=xr({delta:ht(v,k)?N-k:k-v,initialLayout:a,panelConstraints:d.map(R=>R.constraints),pivotIndices:bo(n,p,s),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return f.addEventListener("keydown",w),()=>{f.removeEventListener("keydown",w)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Ba(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}function ko(e,r){const n=e==="horizontal",{x:a,y:o}=Jr(r);return n?a:o}function Wc(e,r,n,a,o){const s=n==="horizontal",l=tn(r,o);Le(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(qe.groupId);Le(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ko(n,e),u=vo(i,o);Le(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Uc(e,r,n,a,o,s){if(lo(e)){const l=n==="horizontal";let i=0;e.shiftKey?i=100:o!=null?i=o:i=10;let d=0;switch(e.key){case"ArrowDown":d=l?0:i;break;case"ArrowLeft":d=l?-i:0;break;case"ArrowRight":d=l?i:0;break;case"ArrowUp":d=l?0:-i;break;case"End":d=100;break;case"Home":d=-100;break}return d}else return a==null?0:Wc(e,r,n,a,s)}function Vc({panelDataArray:e}){const r=Array(e.length),n=e.map(s=>s.constraints);let a=0,o=100;for(let s=0;s<e.length;s++){const l=n[s];Le(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;i!=null&&(a++,r[s]=i,o-=i)}for(let s=0;s<e.length;s++){const l=n[s];Le(l,`Panel constraints not found for index ${s}`);const{defaultSize:i}=l;if(i!=null)continue;const d=e.length-a,h=o/d;a++,r[s]=h,o-=h}return r}function Jt(e,r,n){r.forEach((a,o)=>{const s=e[o];Le(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||Nt(m,h))&&!Nt(a,h)&&p(),f&&(m==null||!Nt(m,h))&&Nt(a,h)&&f())}})}function Rr(e,r){if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=r[n])return!1;return!0}function qc({defaultSize:e,dragState:r,layout:n,panelData:a,panelIndex:o,precision:s=3}){const l=n[o];let i;return l==null?i=e!=null?e.toFixed(s):"1":a.length===1?i="1":i=l.toFixed(s),{flexBasis:0,flexGrow:i,flexShrink:1,overflow:"hidden",pointerEvents:r!==null?"none":void 0}}function Kc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Ga(e){try{if(typeof localStorage<"u")e.getItem=r=>localStorage.getItem(r),e.setItem=(r,n)=>{localStorage.setItem(r,n)};else throw new Error("localStorage not supported in this environment")}catch(r){console.error(r),e.getItem=()=>null,e.setItem=()=>{}}}function wo(e){return`react-resizable-panels:${e}`}function yo(e){return e.map(r=>{const{constraints:n,id:a,idIsFromProps:o,order:s}=r;return o?a:s?`${s}:${JSON.stringify(n)}`:JSON.stringify(n)}).sort((r,n)=>r.localeCompare(n)).join(",")}function jo(e,r){try{const n=wo(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Xc(e,r,n){var a,o;const s=(a=jo(e,n))!==null&&a!==void 0?a:{},l=yo(r);return(o=s[l])!==null&&o!==void 0?o:null}function Yc(e,r,n,a,o){var s;const l=wo(e),i=yo(r),d=(s=jo(e,o))!==null&&s!==void 0?s:{};d[i]={expandToSizes:Object.fromEntries(n.entries()),layout:a};try{o.setItem(l,JSON.stringify(d))}catch(h){console.error(h)}}function Fa({layout:e,panelConstraints:r}){const n=[...e],a=n.reduce((s,l)=>s+l,0);if(n.length!==r.length)throw Error(`Invalid ${r.length} panel layout: ${n.map(s=>`${s}%`).join(", ")}`);if(!ht(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Le(l!=null,`No layout data found for index ${s}`);const i=100/a*l;n[s]=i}let o=0;for(let s=0;s<r.length;s++){const l=n[s];Le(l!=null,`No layout data found for index ${s}`);const i=ar({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!ht(o,0))for(let s=0;s<r.length;s++){const l=n[s];Le(l!=null,`No layout data found for index ${s}`);const i=l+o,d=ar({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,ht(o,0)))break}return n}const Zc=100,br={getItem:e=>(Ga(br),br.getItem(e)),setItem:(e,r)=>{Ga(br),br.setItem(e,r)}},Ha={};function No({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=br,style:h,tagName:u="div",...m}){const f=ra(s),p=c.useRef(null),[g,b]=c.useState(null),[w,x]=c.useState([]),j=Dc(),y=c.useRef({}),v=c.useRef(new Map),k=c.useRef(0),S=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),N=c.useRef({layout:w,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:T}=N.current;return T},setLayout:T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current,C=Fa({layout:T,panelConstraints:E.map(W=>W.constraints)});Ba(B,C)||(x(C),N.current.layout=C,F&&F(C),Jt(E,C,y.current))}}),[]),Ot(()=>{S.current.autoSaveId=e,S.current.direction=a,S.current.dragState=g,S.current.id=f,S.current.onLayout=l,S.current.storage=d}),Oc({committedValuesRef:S,eagerValuesRef:N,groupId:f,layout:w,panelDataArray:N.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=N.current;if(e){if(w.length===0||w.length!==T.length)return;let F=Ha[e];F==null&&(F=Kc(Yc,Zc),Ha[e]=F);const B=[...T],E=new Map(v.current);F(e,B,E,w,d)}},[e,w,d]),c.useEffect(()=>{});const L=c.useCallback(T=>{const{onLayout:F}=S.current,{layout:B,panelDataArray:E}=N.current;if(T.constraints.collapsible){const C=E.map(K=>K.constraints),{collapsedSize:W=0,panelSize:U,pivotIndices:ne}=Dt(E,T,B);if(Le(U!=null,`Panel size not found for panel "${T.id}"`),!Nt(U,W)){v.current.set(T.id,U);const ie=er(E,T)===E.length-1?U-W:W-U,ee=xr({delta:ie,initialLayout:B,panelConstraints:C,pivotIndices:ne,prevLayout:B,trigger:"imperative-api"});Rr(B,ee)||(x(ee),N.current.layout=ee,F&&F(ee),Jt(E,ee,y.current))}}},[]),R=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current;if(T.constraints.collapsible){const W=C.map(ve=>ve.constraints),{collapsedSize:U=0,panelSize:ne=0,minSize:K=0,pivotIndices:ie}=Dt(C,T,E),ee=F??K;if(Nt(ne,U)){const ve=v.current.get(T.id),oe=ve!=null&&ve>=ee?ve:ee,Me=er(C,T)===C.length-1?ne-oe:oe-ne,de=xr({delta:Me,initialLayout:E,panelConstraints:W,pivotIndices:ie,prevLayout:E,trigger:"imperative-api"});Rr(E,de)||(x(de),N.current.layout=de,B&&B(de),Jt(C,de,y.current))}}},[]),P=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{panelSize:E}=Dt(B,T,F);return Le(E!=null,`Panel size not found for panel "${T.id}"`),E},[]),Q=c.useCallback((T,F)=>{const{panelDataArray:B}=N.current,E=er(B,T);return qc({defaultSize:F,dragState:g,layout:w,panelData:B,panelIndex:E})},[g,w]),D=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Le(W!=null,`Panel size not found for panel "${T.id}"`),C===!0&&Nt(W,E)},[]),Z=c.useCallback(T=>{const{layout:F,panelDataArray:B}=N.current,{collapsedSize:E=0,collapsible:C,panelSize:W}=Dt(B,T,F);return Le(W!=null,`Panel size not found for panel "${T.id}"`),!C||Ut(W,E)>0},[]),J=c.useCallback(T=>{const{panelDataArray:F}=N.current;F.push(T),F.sort((B,E)=>{const C=B.order,W=E.order;return C==null&&W==null?0:C==null?-1:W==null?1:C-W}),N.current.panelDataArrayChanged=!0,j()},[j]);Ot(()=>{if(N.current.panelDataArrayChanged){N.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:F,storage:B}=S.current,{layout:E,panelDataArray:C}=N.current;let W=null;if(T){const ne=Xc(T,C,B);ne&&(v.current=new Map(Object.entries(ne.expandToSizes)),W=ne.layout)}W==null&&(W=Vc({panelDataArray:C}));const U=Fa({layout:W,panelConstraints:C.map(ne=>ne.constraints)});Ba(E,U)||(x(U),N.current.layout=U,F&&F(U),Jt(C,U,y.current))}}),Ot(()=>{const T=N.current;return()=>{T.layout=[]}},[]);const z=c.useCallback(T=>{let F=!1;const B=p.current;return B&&window.getComputedStyle(B,null).getPropertyValue("direction")==="rtl"&&(F=!0),function(C){C.preventDefault();const W=p.current;if(!W)return()=>null;const{direction:U,dragState:ne,id:K,keyboardResizeBy:ie,onLayout:ee}=S.current,{layout:ve,panelDataArray:oe}=N.current,{initialLayout:ye}=ne??{},Me=bo(K,T,W);let de=Uc(C,T,U,ne,ie,W);const Ce=U==="horizontal";Ce&&F&&(de=-de);const Ee=oe.map(ke=>ke.constraints),Y=xr({delta:de,initialLayout:ye??ve,panelConstraints:Ee,pivotIndices:Me,prevLayout:ve,trigger:lo(C)?"keyboard":"mouse-or-touch"}),ue=!Rr(ve,Y);(io(C)||co(C))&&k.current!=de&&(k.current=de,!ue&&de!==0?Ce?kn(T,de<0?uo:mo):kn(T,de<0?po:fo):kn(T,0)),ue&&(x(Y),N.current.layout=Y,ee&&ee(Y),Jt(oe,Y,y.current))}},[]),te=c.useCallback((T,F)=>{const{onLayout:B}=S.current,{layout:E,panelDataArray:C}=N.current,W=C.map(ve=>ve.constraints),{panelSize:U,pivotIndices:ne}=Dt(C,T,E);Le(U!=null,`Panel size not found for panel "${T.id}"`);const ie=er(C,T)===C.length-1?U-F:F-U,ee=xr({delta:ie,initialLayout:E,panelConstraints:W,pivotIndices:ne,prevLayout:E,trigger:"imperative-api"});Rr(E,ee)||(x(ee),N.current.layout=ee,B&&B(ee),Jt(C,ee,y.current))},[]),se=c.useCallback((T,F)=>{const{layout:B,panelDataArray:E}=N.current,{collapsedSize:C=0,collapsible:W}=F,{collapsedSize:U=0,collapsible:ne,maxSize:K=100,minSize:ie=0}=T.constraints,{panelSize:ee}=Dt(E,T,B);ee!=null&&(W&&ne&&Nt(ee,C)?Nt(C,U)||te(T,U):ee<ie?te(T,ie):ee>K&&te(T,K))},[te]),$=c.useCallback((T,F)=>{const{direction:B}=S.current,{layout:E}=N.current;if(!p.current)return;const C=tn(T,p.current);Le(C,`Drag handle element not found for id "${T}"`);const W=ko(B,F);b({dragHandleId:T,dragHandleRect:C.getBoundingClientRect(),initialCursorPosition:W,initialLayout:E})},[]),le=c.useCallback(()=>{b(null)},[]),q=c.useCallback(T=>{const{panelDataArray:F}=N.current,B=er(F,T);B>=0&&(F.splice(B,1),delete y.current[T.id],N.current.panelDataArrayChanged=!0,j())},[j]),H=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:R,getPanelSize:P,getPanelStyle:Q,groupId:f,isPanelCollapsed:D,isPanelExpanded:Z,reevaluatePanelConstraints:se,registerPanel:J,registerResizeHandle:z,resizePanel:te,startDragging:$,stopDragging:le,unregisterPanel:q,panelGroupElement:p.current}),[L,g,a,R,P,Q,f,D,Z,se,J,z,te,$,le,q]),G={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Zr.Provider,{value:H},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...G,...h},[qe.group]:"",[qe.groupDirection]:a,[qe.groupId]:f}))}const Co=c.forwardRef((e,r)=>c.createElement(No,{...e,forwardedRef:r}));No.displayName="PanelGroup";Co.displayName="forwardRef(PanelGroup)";function er(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function Dt(e,r,n){const a=er(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Jc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=tn(r,a);if(o==null)return;const s=l=>{if(!l.defaultPrevented)switch(l.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":{l.preventDefault(),n(l);break}case"F6":{l.preventDefault();const i=o.getAttribute(qe.groupId);Le(i,`No group element found for id "${i}"`);const d=jr(i,a),h=xo(i,r,a);Le(h!==null,`No resize element found for id "${r}"`);const u=l.shiftKey?h>0?h-1:d.length-1:h+1<d.length?h+1:0;d[u].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}},[a,e,r,n])}function So({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:o,onBlur:s,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var b,w;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(Zr);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:k,registerResizeHandle:S,startDragging:N,stopDragging:L,panelGroupElement:R}=y,P=ra(o),[Q,D]=c.useState("inactive"),[Z,J]=c.useState(!1),[z,te]=c.useState(null),se=c.useRef({state:Q});Ot(()=>{se.current.state=Q}),c.useEffect(()=>{if(n)te(null);else{const H=S(P);te(()=>H)}},[n,P,S]);const $=(b=a==null?void 0:a.coarse)!==null&&b!==void 0?b:15,le=(w=a==null?void 0:a.fine)!==null&&w!==void 0?w:5;c.useEffect(()=>{if(n||z==null)return;const H=x.current;Le(H,"Element ref not attached");let G=!1;return _c(P,H,v,{coarse:$,fine:le},(F,B,E)=>{if(!B){D("inactive");return}switch(F){case"down":{D("drag"),G=!1,Le(E,'Expected event to be defined for "down" action'),N(P,E);const{onDragging:C,onPointerDown:W}=j.current;C==null||C(!0),W==null||W();break}case"move":{const{state:C}=se.current;G=!0,C!=="drag"&&D("hover"),Le(E,'Expected event to be defined for "move" action'),z(E);break}case"up":{D("hover"),L();const{onClick:C,onDragging:W,onPointerUp:U}=j.current;W==null||W(!1),U==null||U(),G||C==null||C();break}}})},[$,v,n,le,S,P,z,N,L]),Jc({disabled:n,handleId:P,resizeHandler:z,panelGroupElement:R});const q={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{J(!1),s==null||s()},onFocus:()=>{J(!0),d==null||d()},ref:x,role:"separator",style:{...q,...m},tabIndex:f,[qe.groupDirection]:v,[qe.groupId]:k,[qe.resizeHandle]:"",[qe.resizeHandleActive]:Q==="drag"?"pointer":Z?"keyboard":void 0,[qe.resizeHandleEnabled]:!n,[qe.resizeHandleId]:P,[qe.resizeHandleState]:Q})}So.displayName="PanelResizeHandle";var Qc=Object.defineProperty,eh=Object.getOwnPropertyNames,He=(e,r)=>function(){return e&&(r=(0,e[eh(e)[0]])(e=0)),r},th=(e,r)=>{for(var n in r)Qc(e,n,{get:r[n],enumerable:!0})};function at(...e){return Nc(Ws(e))}var Pt=He({"src/components/graph-ui/utils.ts"(){}});function Nr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?Gs:"button";return t.jsx(s,{"data-slot":"button",className:at(To({variant:a,size:n,className:r})),...o})}var To,rn=He({"src/components/graph-ui/Button.tsx"(){Pt(),To=Cr("inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}})}});function Eo(...e){return e.filter(Boolean).join(" ")}function Mn({className:e,...r}){return t.jsx(Co,{"data-slot":"resizable-panel-group",className:Eo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function sr({...e}){return t.jsx(oo,{"data-slot":"resizable-panel",...e})}function An({withHandle:e,className:r,...n}){return t.jsx(So,{"data-slot":"resizable-handle",className:Eo("bg-border focus-visible:ring-ring relative flex w-px items-center justify-center after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:outline-hidden data-[panel-group-direction=vertical]:h-px data-[panel-group-direction=vertical]:w-full data-[panel-group-direction=vertical]:after:left-0 data-[panel-group-direction=vertical]:after:h-1 data-[panel-group-direction=vertical]:after:w-full data-[panel-group-direction=vertical]:after:translate-x-0 data-[panel-group-direction=vertical]:after:-translate-y-1/2 [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:e?t.jsx("div",{className:"bg-border z-10 flex h-4 w-3 items-center justify-center rounded-xs border",children:t.jsx(_.GripVerticalIcon,{className:"size-2.5"})}):null})}var Lo=He({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function aa(...e){return e.filter(Boolean).join(" ")}function Sr({...e}){return t.jsx(Yi,{"data-slot":"accordion",...e})}function Tr({className:e,...r}){return t.jsx(Zi,{"data-slot":"accordion-item",className:aa("border-b last:border-b-0",e),...r})}function nn({className:e,children:r,...n}){return t.jsx(Qi,{className:"flex",children:t.jsxs(ed,{"data-slot":"accordion-trigger",className:aa("flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium outline-none transition-all hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",e),...n,children:[r,t.jsx(_.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Er({className:e,children:r,...n}){return t.jsx(Ji,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:t.jsx("div",{className:aa("pb-4 pt-0",e),children:r})})}var Lr=He({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function rh(e){var n;const r=[];for(const a of e.turns)for(const o of a.items)o.kind==="artifact"&&o.artifact&&r.push(o.artifact);for(const a of((n=e.liveItems)==null?void 0:n.items)??[])a.kind==="artifact"&&a.artifact&&r.push(a.artifact);return r}function nh(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Ir(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function ah(e){return e.split("/").filter(Boolean).at(-1)??e}function tr(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(tr);return{id:`workspace:${e.path}`,name:e.name,path:e.path,kind:r,...e.size!==void 0?{size:e.size}:{},...e.hasChildren!==void 0?{hasChildren:e.hasChildren}:r==="directory"?{hasChildren:n.length>0}:{},...e.childrenLoaded!==void 0?{childrenLoaded:e.childrenLoaded}:r==="directory"?{childrenLoaded:e.children!==void 0}:{},...e.truncated!==void 0?{truncated:e.truncated}:{},workspaceNode:e,children:n}}function Io(e,r,n,a={}){if(e.path===r)return{...e,children:n,hasChildren:n.length>0,childrenLoaded:!0,truncated:a.truncated??e.truncated};if(e.children.length===0)return e;let o=!1;const s=e.children.map(l=>{const i=Io(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function zo(e){if(e.kind==="file")return e;for(const r of e.children){const n=zo(r);if(n)return n}return null}function _n(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=_n(n,r);if(a)return a}return null}function Po(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function sh(e){const n=Po(e).split("/").filter(Boolean);n.pop();const a=[];let o="";for(const s of n)o=o?`${o}/${s}`:s,a.push(o);return a}function $n(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const o=e.children.map(s=>{const l=$n(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function Dn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Dn(n,r))}function oh(e){if(!e)return null;const r=Ir(e.path);return sa.has(r)?{content:[e.content.endsWith(`
3
3
  `)?e.content:`${e.content}
4
- `],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function ah(e){const r=Ir(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function sh(e,r){let n=e,a="";for(const o of r){a=a?`${a}/${o}`:o;let s=n.children.find(l=>l.kind==="directory"&&l.name===o);s||(s={id:`dir:${a}`,name:o,path:a,kind:"directory",children:[]},n.children.push(s)),n=s}return n}function oh(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;sh(e,a).children.push({...n,name:n.name||o,path:r})}function lh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Ro(e){e.children.sort(lh);for(const r of e.children)Ro(r);return e}function Oa(e,r,n,a){var u;const o={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},s={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=eh(f)||m.id;s.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),b=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,k="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:th(b),path:b,kind:"event",item:f,preview:k,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}oh(l,b.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),Ro(o)}function ih(e){const r=new Map,n=a=>{r.set(a.id,a);for(const o of a.children)n(o)};return n(e),r}function Mo(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=Mo(r);if(n)return n}return null}function Wa(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var sa,Ao,_o,oa=Oe({"src/components/graph-workspace/workspaceTree.ts"(){sa=new Set(["xyz","extxyz","cif","pdb"]),Ao=new Set(["png","jpg","jpeg","gif","webp","svg"]),_o=new Set(["pdf"])}});function rr({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var $o=Oe({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function dh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(fd,{"data-slot":"separator",decorative:r,orientation:n,className:rt("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var ch=Oe({"src/components/graph-ui/Separator.tsx"(){Pt()}});function hh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:rt(Do({orientation:r}),e),...n})}function uh({className:e,orientation:r="vertical",...n}){return t.jsx(dh,{"data-slot":"button-group-separator",orientation:r,className:rt("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Do,Bo=Oe({"src/components/graph-ui/ButtonGroup.tsx"(){ch(),Pt(),Do=Cr("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function mh({delayDuration:e=0,...r}){return t.jsx(gd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function ph({...e}){return t.jsx(mh,{children:t.jsx(cd,{"data-slot":"tooltip",...e})})}function fh({...e}){return t.jsx(hd,{"data-slot":"tooltip-trigger",...e})}function gh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(ud,{children:t.jsxs(md,{"data-slot":"tooltip-content",sideOffset:n,className:rt("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(pd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var xh=Oe({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function bh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ua(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a)}function Ze({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(ph,{children:[t.jsx(fh,{asChild:!0,children:t.jsx(Nr,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(gh,{children:t.jsx("p",{children:n})})]})}function Bn({children:e,className:r=""}){return t.jsx(hh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Go=Oe({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){rn(),Bo(),xh()}});function vh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Bn,{children:[t.jsx(Ze,{label:"Distance",children:t.jsx(D.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ze,{label:"Connectivity",children:t.jsx(D.Share2,{className:"size-4"})}),t.jsx(Ze,{label:"Angle",children:t.jsx(D.Waypoints,{className:"size-4"})}),t.jsx(Ze,{label:"Dihedral",children:t.jsx(D.Spline,{className:"size-4"})}),t.jsx(Ze,{label:"Add dummy atoms",children:t.jsx(D.Bubbles,{className:"size-4"})}),t.jsx(Ze,{label:"Delete atoms",children:t.jsx(D.CircleX,{className:"size-4"})}),t.jsx(Ze,{label:"Rotate",children:t.jsx(D.Rotate3d,{className:"size-4"})})]}),t.jsxs(Bn,{children:[t.jsx(Ze,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(D.Boxes,{className:"size-4"})}),t.jsx(Ze,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(D.Trash2,{className:"size-4"})}),t.jsx(Ze,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(D.Send,{className:"size-4"})}),t.jsx(Ze,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(D.Box,{className:"size-4"})}),t.jsx(Ze,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(D.Eraser,{className:"size-4"})}),t.jsx(Ze,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(D.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(b=>`${i[b]??"Atom"}(${b})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var kh=Oe({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Go()}});function wh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=bh(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ua(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ua(r,`${i}_trajectory.${l||"xyz"}`)}function m(){o.current&&(o.current.zoom(1.2),o.current.render())}function f(){o.current&&(o.current.zoom(.8),o.current.render())}function p(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Bn,{className:"ml-auto justify-end",children:[t.jsx(Ze,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(D.Copy,{className:"size-3.5"})}),t.jsx(Ze,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(D.Download,{className:"size-3.5"})}),t.jsx(Ze,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(D.Box,{className:"size-3.5"})}),t.jsx(Ze,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(D.Camera,{className:"size-3.5"})}),t.jsx(uh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ze,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(D.ZoomIn,{className:"size-3.5"})}),t.jsx(Ze,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(D.ZoomOut,{className:"size-3.5"})}),t.jsx(Ze,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(D.RotateCcw,{className:"size-3.5"})})]})}var yh=Oe({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Bo(),Go()}});async function jh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Gr||(Gr=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const o=document.createElement("script");o.src="/vendor/3Dmol-min.js",o.async=!0,o.dataset.remoteCodex3dmol="true",o.addEventListener("load",a,{once:!0}),o.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(o)})),Gr)}var Gr,Nh=Oe({"src/components/graph-workspace/load3Dmol.ts"(){Gr=null}});function Ch({className:e,defaultValue:r,max:n=100,min:a=0,value:o,...s}){const l=c.useMemo(()=>Array.isArray(o)?o:Array.isArray(r)?r:[a,n],[r,n,a,o]);return t.jsxs(od,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:rt("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...s,children:[t.jsx(ld,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",children:t.jsx(id,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),Array.from({length:l.length},(i,d)=>t.jsx(dd,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50"},d))]})}var Sh=Oe({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Th(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function Eh(e){var o,s;const r=e.replace(/\r\n/g,`
4
+ `],format:r==="extxyz"?"xyz":r,name:e.name,uuid:e.path}:null}function lh(e){const r=Ir(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function ih(e,r){let n=e,a="";for(const o of r){a=a?`${a}/${o}`:o;let s=n.children.find(l=>l.kind==="directory"&&l.name===o);s||(s={id:`dir:${a}`,name:o,path:a,kind:"directory",children:[]},n.children.push(s)),n=s}return n}function dh(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;ih(e,a).children.push({...n,name:n.name||o,path:r})}function ch(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Ro(e){e.children.sort(ch);for(const r of e.children)Ro(r);return e}function Oa(e,r,n,a){var u;const o={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},s={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=nh(f)||m.id;s.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),b=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,w="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:b,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:ah(b),path:b,kind:"event",item:f,preview:w,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}dh(l,b.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),Ro(o)}function hh(e){const r=new Map,n=a=>{r.set(a.id,a);for(const o of a.children)n(o)};return n(e),r}function Mo(e){if(e.kind==="artifact"||e.kind==="live-artifact"||e.kind==="event"||e.kind==="file")return e;for(const r of e.children){const n=Mo(r);if(n)return n}return null}function Wa(e){const r=e.split("/").filter(Boolean),n=[];for(let a=1;a<=r.length;a+=1)n.push(r.slice(0,a).join("/"));return n}var sa,Ao,_o,oa=He({"src/components/graph-workspace/workspaceTree.ts"(){sa=new Set(["xyz","extxyz","cif","pdb"]),Ao=new Set(["png","jpg","jpeg","gif","webp","svg"]),_o=new Set(["pdf"])}});function rr({label:e,children:r}){return t.jsxs("section",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:e}),t.jsx("div",{className:"mt-2 text-sm text-[var(--theme-fg)]",children:r})]})}var $o=He({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function uh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(bd,{"data-slot":"separator",decorative:r,orientation:n,className:at("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",e),...a})}var mh=He({"src/components/graph-ui/Separator.tsx"(){Pt()}});function ph({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:at(Do({orientation:r}),e),...n})}function fh({className:e,orientation:r="vertical",...n}){return t.jsx(uh,{"data-slot":"button-group-separator",orientation:r,className:at("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Do,Bo=He({"src/components/graph-ui/ButtonGroup.tsx"(){mh(),Pt(),Do=Cr("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md",{variants:{orientation:{horizontal:"[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",vertical:"flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"}},defaultVariants:{orientation:"horizontal"}})}});function gh({delayDuration:e=0,...r}){return t.jsx(vd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function xh({...e}){return t.jsx(gh,{children:t.jsx(md,{"data-slot":"tooltip",...e})})}function bh({...e}){return t.jsx(pd,{"data-slot":"tooltip-trigger",...e})}function vh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(fd,{children:t.jsxs(gd,{"data-slot":"tooltip-content",sideOffset:n,className:at("z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-foreground px-3 py-1.5 text-balance text-xs text-background animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",r),...a,children:[e,t.jsx(xd,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var kh=He({"src/components/graph-ui/Tooltip.tsx"(){Pt()}});function wh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ua(e,r){const n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),o=document.createElement("a");o.href=a,o.download=r,o.click(),URL.revokeObjectURL(a)}function Ye({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(xh,{children:[t.jsx(bh,{asChild:!0,children:t.jsx(Nr,{type:"button",variant:"outline",size:"icon",className:"thread-graph-molecule-button size-8",disabled:r,onClick:a,title:n,"aria-label":n,children:e})}),t.jsx(vh,{children:t.jsx("p",{children:n})})]})}function Bn({children:e,className:r=""}){return t.jsx(ph,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Go=He({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){rn(),Bo(),kh()}});function yh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Bn,{children:[t.jsx(Ye,{label:"Distance",children:t.jsx(_.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ye,{label:"Connectivity",children:t.jsx(_.Share2,{className:"size-4"})}),t.jsx(Ye,{label:"Angle",children:t.jsx(_.Waypoints,{className:"size-4"})}),t.jsx(Ye,{label:"Dihedral",children:t.jsx(_.Spline,{className:"size-4"})}),t.jsx(Ye,{label:"Add dummy atoms",children:t.jsx(_.Bubbles,{className:"size-4"})}),t.jsx(Ye,{label:"Delete atoms",children:t.jsx(_.CircleX,{className:"size-4"})}),t.jsx(Ye,{label:"Rotate",children:t.jsx(_.Rotate3d,{className:"size-4"})})]}),t.jsxs(Bn,{children:[t.jsx(Ye,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(_.Boxes,{className:"size-4"})}),t.jsx(Ye,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(_.Trash2,{className:"size-4"})}),t.jsx(Ye,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(_.Send,{className:"size-4"})}),t.jsx(Ye,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(_.Box,{className:"size-4"})}),t.jsx(Ye,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(_.Eraser,{className:"size-4"})}),t.jsx(Ye,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(_.ArrowUpRight,{className:"size-4"})})]})]}),e?t.jsxs("div",{className:"thread-graph-molecule-camera",children:[t.jsxs("div",{children:[t.jsx("strong",{children:"XYZ: "}),"x=",e.position.x.toFixed(1)," y=",e.position.y.toFixed(1)," z=",e.position.z.toFixed(1),t.jsx("br",{}),t.jsx("strong",{children:"Quat: "}),"qx=",e.position.qx.toFixed(2)," qy=",e.position.qy.toFixed(2)," qz=",e.position.qz.toFixed(2)," qw=",e.position.qw.toFixed(2)]}),t.jsx("div",{className:"thread-graph-molecule-camera-divider"}),t.jsxs("div",{className:"flex flex-col gap-1 text-[10px]",children:[t.jsxs("div",{children:["Selected atoms:"," ",d.length>0?d.map(b=>`${i[b]??"Atom"}(${b})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var jh=He({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Go()}});function Nh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=wh(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ua(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ua(r,`${i}_trajectory.${l||"xyz"}`)}function m(){o.current&&(o.current.zoom(1.2),o.current.render())}function f(){o.current&&(o.current.zoom(.8),o.current.render())}function p(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Bn,{className:"ml-auto justify-end",children:[t.jsx(Ye,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(_.Copy,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(_.Download,{className:"size-3.5"})}),t.jsx(Ye,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(_.Box,{className:"size-3.5"})}),t.jsx(Ye,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(_.Camera,{className:"size-3.5"})}),t.jsx(fh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ye,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(_.ZoomIn,{className:"size-3.5"})}),t.jsx(Ye,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(_.ZoomOut,{className:"size-3.5"})}),t.jsx(Ye,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(_.RotateCcw,{className:"size-3.5"})})]})}var Ch=He({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Bo(),Go()}});async function Sh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Gr||(Gr=new Promise((e,r)=>{const n=document.querySelector('script[data-remote-codex-3dmol="true"]'),a=()=>{if(window["3Dmol"]){e(window["3Dmol"]);return}r(new Error("3Dmol loaded without exposing the expected global."))};if(n){n.addEventListener("load",a,{once:!0}),n.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0});return}const o=document.createElement("script");o.src="/vendor/3Dmol-min.js",o.async=!0,o.dataset.remoteCodex3dmol="true",o.addEventListener("load",a,{once:!0}),o.addEventListener("error",()=>r(new Error("Unable to load 3Dmol viewer runtime.")),{once:!0}),document.head.appendChild(o)})),Gr)}var Gr,Th=He({"src/components/graph-workspace/load3Dmol.ts"(){Gr=null}});function Eh({className:e,defaultValue:r,max:n=100,min:a=0,value:o,...s}){const l=c.useMemo(()=>Array.isArray(o)?o:Array.isArray(r)?r:[a,n],[r,n,a,o]);return t.jsxs(dd,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:at("relative flex w-full touch-none select-none items-center data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",e),...s,children:[t.jsx(cd,{"data-slot":"slider-track",className:"relative grow overflow-hidden rounded-full bg-muted data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5",children:t.jsx(hd,{"data-slot":"slider-range",className:"absolute bg-primary data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full"})}),Array.from({length:l.length},(i,d)=>t.jsx(ud,{"data-slot":"slider-thumb",className:"block size-4 shrink-0 rounded-full border border-primary bg-white shadow-sm transition-[color,box-shadow] hover:ring-4 focus-visible:outline-hidden focus-visible:ring-4 disabled:pointer-events-none disabled:opacity-50"},d))]})}var Lh=He({"src/components/graph-ui/Slider.tsx"(){Pt()}});function Ih(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function zh(e){var o,s;const r=e.replace(/\r\n/g,`
5
5
  `).replace(/\r/g,`
6
6
  `).split(`
7
7
  `),n=[];let a=0;for(;a<r.length;){for(;a<r.length&&((o=r[a])==null?void 0:o.trim())==="";)a+=1;if(a>=r.length)break;const l=Number.parseInt(((s=r[a])==null?void 0:s.trim())??"",10);if(!Number.isFinite(l)||l<0)return[e];const i=l+2;if(a+i>r.length)return[e];n.push(`${r.slice(a,a+i).join(`
8
8
  `)}
9
- `),a+=i}return n.length>0?n:[e]}function Va(e,r){return r!=="xyz"?e:e.flatMap(n=>Eh(n))}function Ka(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
10
- `).join("")}function Lh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=Va([e],"xyz");return{frames:o,format:"xyz",exportContent:Ka(o)}}const r=Th(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:Va(n,r),format:r,exportContent:Ka(n)}}var Ih=Oe({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function zh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:o,title:s="PyMOL-style (PDB/CIF)"}){const l=c.useRef(null),i=c.useRef(null),d=c.useRef(null),h=c.useRef(!1),u=c.useRef(!0),[m,f]=c.useState(null),[p,g]=c.useState(0),[b,k]=c.useState(null),[x,j]=c.useState(!1),[w,y]=c.useState({}),[v,S]=c.useState([]),[N,I]=c.useState({}),[M,R]=c.useState(!1),[Q,$]=c.useState(!1),[Y,Z]=c.useState(null),P=c.useMemo(()=>Lh(o),[o]),te=P.frames,oe=P.format,T=te[p]??null,re=te.length>0&&p===te.length-1,B=r??"current",J=Object.values(N).reduce((E,C)=>E+C.length,0),K=Object.keys(N).length;c.useEffect(()=>{if(te.length===0){g(0);return}g(te.length-1)},[te.length]),c.useEffect(()=>{if(!x||te.length<=1)return;const E=window.setInterval(()=>{g(C=>C>=te.length-1?(window.clearInterval(E),j(!1),C):C+1)},200);return()=>window.clearInterval(E)},[x,te.length]),c.useEffect(()=>{const E=l.current;if(!E||i.current)return;let C=!1;try{const H=document.createElement("canvas");if(!(H.getContext("webgl2")||H.getContext("webgl")||H.getContext("experimental-webgl"))){Z("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{Z("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const W=()=>{var H,se;(H=i.current)==null||H.resize(),(se=i.current)==null||se.render()};return jh().then(H=>{if(!(C||i.current))try{const se=H.createViewer(E,{});i.current=se,se.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",W),window.setTimeout(W,100)}catch(se){console.error("Failed to initialize 3Dmol viewer:",se),Z("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(H=>{console.error("Failed to load 3Dmol viewer runtime:",H),Z("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",W),i.current=null,d.current=null}},[]),c.useEffect(()=>{const E=i.current;if(!(!E||!T))try{E.removeAllModels(),E.removeAllShapes(),E.removeAllLabels();const C=E.addModel(T,oe||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const W=C.getCrystData(),H=!!(W&&typeof W=="object"&&Object.keys(W).length);R(H),$(H?u.current:!1),S([]),y({});const se=T.split(`
11
- `).slice(2).map(V=>V.trim()).filter(Boolean).map(V=>V.split(/\s+/)[0]??"Atom");h.current||(E.zoomTo(),h.current=!0),C.setClickable({},!0,(V,de,ee)=>{const be=V.serial??V.index;if(be===void 0)return;const ie=V.atom||V.elem||se[be]||"Atom";S(ye=>{const ce=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ye.includes(be)?ye.filter(Ce=>Ce!==be):[...ye,be]:ye.length===1&&ye[0]===be?[]:[be];return y(Ce=>{if(ce.length===0)return{};const Le={};return ce.forEach(X=>{Le[X]=Ce[X]||se[X]||ie}),Le}),ce})}),C.setHoverable({},!0,(V,de,ee)=>{!ee||!V||k({x:ee.clientX,y:ee.clientY,label:`${V.atom||V.elem||"Atom"} (${V.serial??V.index??"?"})`,coords:{x:V.x.toFixed(2),y:V.y.toFixed(2),z:V.z.toFixed(2)}})},()=>k(null)),E.render()}catch(C){console.error("Failed to render molecule:",C),Z("Unable to render this molecular structure.")}},[T,oe]),c.useEffect(()=>{const E=i.current,C=d.current;if(!(!E||!C)){try{E.removeUnitCell(C)}catch{}if(Q&&M)try{E.addUnitCell(C,{box:{color:"black",opacity:1,linewidth:5},astyle:{radius:.12,mid:.85,color:"red",opacity:.6},bstyle:{radius:.12,mid:.85,color:"green",opacity:.6},cstyle:{radius:.12,mid:.85,color:"blue",opacity:.6},alabel:"a",blabel:"b",clabel:"c"})}catch{R(!1),$(!1)}E.render()}},[M,Q,T,oe]),c.useEffect(()=>{const E=i.current,C=d.current;!E||!C||!T||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),v.length>0&&C.setStyle({serial:v},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),E.render(),a==null||a({moleculeId:r,atoms:v}))},[r,a,v,T]),c.useEffect(()=>{if(!T)return;let E=0;const C=()=>{var H,se;const W=(se=(H=i.current)==null?void 0:H.getView)==null?void 0:se.call(H);if(Array.isArray(W)&&W.length>=8){const[V,de,ee,be,ie,ye,Ae,ce]=W;if(typeof V=="number"&&typeof de=="number"&&typeof ee=="number"&&typeof be=="number"&&typeof ie=="number"&&typeof ye=="number"&&typeof Ae=="number"&&typeof ce=="number"){const Ce=Math.sqrt(ie*ie+ye*ye+Ae*Ae),Le=Ce>0?{x:ie/Ce,y:ye/Ce,z:Ae/Ce}:{x:0,y:0,z:0};f({position:{x:V,y:de,z:ee,qx:ie,qy:ye,qz:Ae,qw:ce},lookAt:Le,zoom:be})}}E=window.requestAnimationFrame(C)};return E=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(E)},[T]);const L=c.useCallback(async()=>{const E=i.current;if(!(E!=null&&E.pngURI))return;E.render();const C=E.pngURI();if(C){try{const H=await(await fetch(C)).blob(),se=new ClipboardItem({[H.type||"image/png"]:H});await navigator.clipboard.write([se])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function q(){M&&$(E=>{const C=!E;return u.current=C,C})}function G(){v.length!==0&&I(E=>{const C=E[B]??[];return{...E,[B]:Array.from(new Set([...C,...v]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:s}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[Y?t.jsx("div",{"data-testid":"molecule-viewer-error",className:"thread-graph-molecule-error absolute inset-0 flex items-center justify-center bg-red-50 p-4 text-sm text-red-700",children:Y}):null,!Y&&!T?t.jsx("div",{className:"thread-graph-molecule-empty absolute inset-0 flex items-center justify-center p-4 text-sm text-slate-400",children:"No molecule data available."}):null,b?t.jsxs("div",{className:"thread-graph-molecule-tooltip pointer-events-none fixed z-[1000] rounded-md border border-gray-300 bg-white/95 px-2 py-1.5 text-[10px] text-gray-800 shadow-md",style:{left:b.x-20,top:b.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:b.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",b.coords.x]}),t.jsxs("span",{children:["y: ",b.coords.y]}),t.jsxs("span",{children:["z: ",b.coords.z]})]})]}):null]}),t.jsxs("div",{className:"thread-graph-molecule-controls shrink-0",children:[t.jsxs("div",{className:"thread-graph-molecule-control-row",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-graph-molecule-control-title",children:"Ball & Stick"}),t.jsx("p",{className:"thread-graph-molecule-control-subtitle",children:"XYZ / PDB / CIF preview"})]}),t.jsx(wh,{currentIndex:p,exportContent:P.exportContent,moleculeId:r,onScreenshot:()=>void L(),viewerRef:i,xyzContent:T,xyzFormat:oe})]}),te.length>1?t.jsxs("div",{className:"thread-graph-molecule-trajectory",children:[t.jsxs("div",{className:"mb-2 flex justify-between gap-3 text-xs",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:["Trajectory ",p+1," / ",te.length,t.jsx(Nr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(E=>{const C=!E;return C&&p===te.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(D.Pause,{className:"h-3 w-3"}):t.jsx(D.Play,{className:"h-3 w-3"})})]}),t.jsxs(Nr,{type:"button",variant:"ghost",onClick:()=>g(te.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${re?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(Ch,{value:[p],max:te.length-1,step:1,onValueChange:E=>g(E[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(vh,{cameraInfo:m,onClearSelection:()=>S([]),onClearStaged:()=>I({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:v}),onSendStaged:()=>{Object.entries(N).forEach(([E,C])=>{a==null||a({moleculeId:E==="current"?r:E,atoms:C})})},onStageSelection:G,onToggleUnitCell:q,selectedAtomLabels:w,selectedSerials:v,stagedAtoms:J,stagedMolecules:K,unitCellAvailable:M,unitCellVisible:Q})]})]})]})}var Ph=Oe({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){kh(),yh(),Nh(),rn(),Sh(),Ih()}});function Rh(e){return!e.truncated&&e.size<=Fo&&e.content.split(`
12
- `).length<=Ho}function Mh(e){return e&&(e.node.path||e.node.name)||null}function Ah(e){if(!e)return null;switch(e.kind){case"live-artifact":return{kind:"live-molecule",node:e};case"file":return{kind:"workspace-file",node:e};case"artifact":return{kind:"artifact",node:e};case"event":return{kind:"event",node:e};case"meta":return{kind:"meta",node:e};case"directory":return null}}function _h({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[b,k]=c.useState(null),[x,j]=c.useState(!1),w=(u==null?void 0:u.node)??null,y=w!=null&&w.artifact?h.renderArtifact({artifact:w.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,v=nh(i??null),S=(i==null?void 0:i.language)||ah((i==null?void 0:i.path)??""),N=i?Ir(i.path):"",I=Mh(u),M=i!==null&&sa.has(N),R=!!(i&&a)&&!M&&Rh(i),Q=(u==null?void 0:u.kind)==="live-molecule",$=!!(w!=null&&w.artifact&&y),Y=!!v||$;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),k(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function Z(){if(!(!i||!a)){j(!0),k(null);try{await a({path:i.path,content:p}),f(!1)}catch(P){k(P instanceof Error?P.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),I?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:I}):null]}),s?t.jsx("button",{type:"button",onClick:s,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&v?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(zh,{source:v,moleculeId:v.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[M?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),R?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),k(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(D.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void Z(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(D.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),k(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx(D.Pencil,{className:"h-4 w-4"})})}):null]}),b?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-4 py-2 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:b}):null,m?t.jsx("textarea",{value:p,onChange:P=>g(P.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Fr,{content:i.content}),i.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:Y||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:y}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(rr,{label:"Workspace Data",children:t.jsx(Fr,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Fr,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Fo,Ho,Fr,$h=Oe({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){oa(),$o(),Ph(),Fo=50*1024,Ho=1e3,Fr=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Dh({files:e,onCancel:r,onConfirm:n}){return t.jsx("div",{className:"thread-graph-dialog-backdrop fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:t.jsxs("div",{className:"thread-graph-dialog w-full max-w-sm rounded-xl border bg-[var(--theme-panel)] p-6 shadow-xl",children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Empty garbage?"}),t.jsxs("p",{className:"mt-1 text-sm leading-5 text-[var(--theme-fg-muted)]",children:["Permanently delete all files in the"," ",t.jsx("code",{className:"rounded bg-[var(--theme-muted)] px-1 text-xs text-[var(--theme-fg-soft)]",children:"garbage/"})," ","folder."]}),e.length===0?t.jsx("p",{className:"mt-3 text-sm text-[var(--theme-fg-muted)]",children:"Garbage is empty."}):t.jsx("ul",{className:"mt-3 max-h-40 overflow-y-auto rounded-md border border-[var(--theme-border)] bg-[var(--theme-surface)] p-2 text-xs text-[var(--theme-fg-soft)]",children:e.map(a=>t.jsx("li",{className:"truncate py-0.5",title:a,children:a},a))}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"thread-secondary-action rounded-md px-3 py-1.5 text-sm",children:"Cancel"}),e.length>0?t.jsx("button",{type:"button",onClick:n,className:"ui-action-danger rounded-md px-3 py-1.5 text-sm font-medium",children:"Yes, empty garbage"}):null]})]})})}var Bh=Oe({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Oo(e){return`${Uo}${e.workspaceId??"workspace"}:${e.threadId}`}function Gh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Oo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function qa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Oo(e),JSON.stringify([...r]))}catch{}}function Gn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>Gn(s,n.get(s.path)??null)),o=e.childrenLoaded&&e.children.length>0;return{...e,children:o||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Xa(e,r){if(e.kind==="directory")return r?t.jsx(D.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(D.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Ir(e.name);return n==="zip"?t.jsx(D.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(D.FileImage,{className:"h-4 w-4 text-sky-500"}):e.kind==="artifact"||["xyz","extxyz","cif","pdf","json","ts","tsx","js","jsx","md","yaml","yml","py"].includes(n)?t.jsx(D.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(D.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Wo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(D.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(D.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Xa(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(D.Download,{className:"h-3.5 w-3.5"})}):null,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(b=>t.jsx(Wo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:b,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},b.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Xa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(D.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(D.Download,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Fh({liveNodes:e,onSelect:r,selectedNodeId:n}){return e.length===0?null:t.jsxs("div",{className:"border-b border-slate-200 py-2 dark:border-[#2a2f3a]",children:[t.jsx("div",{className:"thread-graph-workspace-label px-3 pb-1 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",children:"Live"}),t.jsx("div",{className:"space-y-0.5",children:e.map(a=>{var s;const o=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((s=a.artifact)==null?void 0:s.id)??a.id,onClick:()=>r(a.id),className:`thread-graph-tree-row flex min-h-9 w-full items-center gap-2 px-3 py-2 text-left text-sm transition sm:min-h-0 sm:py-1.5 ${o?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsx(D.FileCode2,{className:`h-4 w-4 shrink-0 ${o?"text-current":"text-emerald-600 dark:text-emerald-300"}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)})})]})}function Hh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:b,selectedNodeId:k,tree:x,liveNodes:j}){const w=c.useMemo(()=>({...x,children:x.children.filter(y=>y.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const y=b.current;y&&(y.scrollTop=g.current)},[b,g]),t.jsxs("aside",{className:`${Vo} flex flex-col`,children:[t.jsxs("div",{className:Ko,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:qo,children:"Explorer"})}),t.jsxs("div",{className:"flex items-center gap-1",children:[n?t.jsxs("button",{type:"button","data-testid":"collapse-explorer",onClick:n,className:Xo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(D.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Or,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(D.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Or,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(D.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Or,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(D.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:b,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:y=>{g.current=y.currentTarget.scrollTop},children:[t.jsx(Fh,{liveNodes:j??[],onSelect:m,selectedNodeId:k}),t.jsx("div",{className:Yo,children:"Workspace"}),t.jsx(Wo,{depth:0,expandedPaths:a,loadingPaths:o,node:w,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:k}),w.children.length===0?t.jsx("p",{className:Zo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Oh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,focusPathRequest:s,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Oa(r,n),[e,i,n,r,o,l]),u=i??h??Oa(r,n),m=c.useMemo(()=>ih(u),[u]),f=c.useMemo(()=>{var z;return((z=u.children.find(O=>O.path==="live"))==null?void 0:z.children)??[]},[u]),p=Mo(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[k,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Wa((p==null?void 0:p.path)??"")])),[j,w]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[y,v]=c.useState(null),[S,N]=c.useState(!1),[I,M]=c.useState(()=>new Set),[R,Q]=c.useState(!1),[$,Y]=c.useState(!1),[Z,P]=c.useState(!1),[te,oe]=c.useState([]),[T,re]=c.useState(null),[B,J]=c.useState(null),[K,L]=c.useState(null),[q,G]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),H=c.useRef(null),se=!!l,V=(g?m.get(g):null)??p??null,de={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,H.current=null,x(new Set(["","artifacts","thread-events","live",...Gh(de),...Wa((p==null?void 0:p.path)??"")]))},[de.threadId,de.workspaceId]);function ee(){var O;const z=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=z,H.current=z}function be(){const z=H.current??W.current;if(!C.current)return;let ne=0;const ge=()=>{const Te=C.current;Te&&(Te.scrollTop=Math.min(z,Math.max(0,Te.scrollHeight-Te.clientHeight)),W.current=Te.scrollTop,ne+=1,ne<8?window.requestAnimationFrame(ge):H.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&be()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 639px)"),O=()=>G(z.matches);return O(),typeof z.addEventListener=="function"?(z.addEventListener("change",O),()=>z.removeEventListener("change",O)):(z.addListener(O),()=>z.removeListener(O))},[]);async function ie(z){if(!l)return;const O=z??(V==null?void 0:V.path)??null;N(!0),v(null);try{const ne=tr(await l.listTree({...de,path:""}));let ge=i?Gn(ne,i):ne;if(i){const Ee=[...k].filter(fe=>fe).sort((fe,De)=>fe.split("/").length-De.split("/").length);for(const fe of Ee){const De=_n(i,fe);if((De==null?void 0:De.kind)!=="directory"||!De.childrenLoaded)continue;const Be=tr(await l.listTree({...de,path:fe}));ge=$n(ge,fe,Gn(Be,De))}}d(ge);const Te=zo(ge);b(Ee=>{var De;const fe=O??(Ee?(De=m.get(Ee))==null?void 0:De.path:null);return fe&&Dn(ge,fe)?`workspace:${fe}`:(Te==null?void 0:Te.id)??Ee})}catch(ne){v(ne instanceof Error?ne.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function ye(z){if(!(!l||!i)){M(O=>{if(O.has(z))return O;const ne=new Set(O);return ne.add(z),ne}),v(null);try{const O=tr(await l.listTree({...de,path:z}));d(ne=>ne&&Io(ne,z,O.children,{truncated:O.truncated}))}catch(O){v(O instanceof Error?O.message:"Failed to load directory")}finally{M(O=>{if(!O.has(z))return O;const ne=new Set(O);return ne.delete(z),ne})}}}async function Ae(z){const O=Po(z);if(!O)return;const ne=rh(O);if(w(null),x(ge=>{const Te=new Set(ge);Te.add("");for(const Ee of ne)Te.add(Ee);return qa(de,Te),Te}),!l){Dn(u,O)&&b(`workspace:${O}`);return}N(!0),v(null);try{let ge=i??tr(await l.listTree({...de,path:""}));for(const Te of ne){const Ee=_n(ge,Te);if((Ee==null?void 0:Ee.kind)==="directory"&&Ee.childrenLoaded)continue;const fe=tr(await l.listTree({...de,path:Te}));ge=$n(ge,Te,fe)}d(ge),b(`workspace:${O}`)}catch(ge){v(ge instanceof Error?ge.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const z of m.values())z.path&&z.kind==="directory"&&k.has(z.path)&&z.hasChildren&&!z.childrenLoaded&&!I.has(z.path)&&ye(z.path)},[i,k,m,l]),c.useEffect(()=>{d(null),M(new Set),re(null),J(null),L(null),v(null),ie()},[se,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Ae(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,de.threadId,de.workspaceId]),c.useEffect(()=>{const z=l&&(V==null?void 0:V.kind)==="file"?V.path:null;if(!z){re(null),J(null),L(null);return}const O=z;let ne=!1;async function ge(){var Te;if(l){Q(!0),v(null),re(null),J(null),L(null);try{const Ee=Ir(O),fe=(Te=l.getRawFileUrl)==null?void 0:Te.call(l,{...de,path:O});if(fe&&Ao.has(Ee)){ne||J(fe);return}if(fe&&_o.has(Ee)){ne||L(fe);return}const De=await l.readFile({...de,path:O,limit:Hr});ne||re(De)}catch(Ee){ne||v(Ee instanceof Error?Ee.message:"Failed to read file")}finally{ne||Q(!1)}}}return ge(),()=>{ne=!0}},[l,V==null?void 0:V.id]);async function ce(){if(!(!l||!(T!=null&&T.truncated))){Y(!0);try{const z=await l.readFile({...de,path:T.path,offset:T.nextOffset,limit:Hr});re(O=>O&&{...O,content:O.content+z.content,truncated:z.truncated,nextOffset:z.nextOffset,size:z.size})}finally{Y(!1)}}}async function Ce(z){if(!(l!=null&&l.writeFile))return;v(null),await l.writeFile({...de,path:z.path,content:z.content}),await ie(z.path);const O=await l.readFile({...de,path:z.path,limit:Hr});re(O)}async function Le(z){if(!(!(l!=null&&l.uploadFile)||!z)){N(!0),v(null);try{const O=await l.uploadFile({...de,path:z.name,file:z}),ne=O.kind==="archive"?O.paths[0]??null:O.file.path;await ie(ne)}catch(O){v(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function X(z){var ne;const O=(ne=z.target.files)==null?void 0:ne[0];z.target.value="",O&&await Le(O)}function ue(){if(!(l!=null&&l.uploadFile))return;const z=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...de,defaultPick:z,upload:Le});return}z()}function ve(z){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...de,path:z.path,kind:z.kind==="directory"?"directory":"file"})}function ke(z){if(!z.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),ne=z.path.startsWith("/")?z.path:O?`${O}/${z.path.replace(/^\/+/,"")}`:z.path;navigator.clipboard.writeText(ne).catch(ge=>{v(ge instanceof Error?ge.message:"Failed to copy file path")})}function $e(z){z.kind==="file"&&(ee(),b(z.id),w("explorer"))}async function He(){if(l!=null&&l.emptyGarbage){if(v(null),!l.listGarbage){oe([]),P(!0);return}try{const z=await l.listGarbage(de);oe(z.map(O=>`garbage/${O}`))}catch(z){oe([]),v(z instanceof Error?z.message:"Failed to list garbage files")}finally{P(!0)}}}async function _e(){if(l!=null&&l.emptyGarbage){P(!1),v(null);try{await l.emptyGarbage(de),await ie((V==null?void 0:V.path)??null)}catch(z){v(z instanceof Error?z.message:"Failed to empty garbage")}}}const ze={onCopyPath:ke,...l!=null&&l.downloadNode?{onDownload:ve}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:He}:{},...l?{onRefresh:()=>void ie((V==null?void 0:V.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ue}:{}};function F(z){if(!z)return;const O=m.get(`workspace:${z}`),ne=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!I.has(z);x(ge=>{const Te=new Set(ge);return Te.has(z)?Te.delete(z):Te.add(z),qa(de,Te),Te}),!k.has(z)&&ne&&ye(z)}const le=t.jsx(Hh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),w("explorer")},expandedPaths:k,loadingPaths:I,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...ze,onPreview:$e,onSelect:z=>{b(z)},onToggle:F,selectedNodeId:(V==null?void 0:V.id)??null,tree:u,liveNodes:f}),we=t.jsx(_h,{error:y,imageUrl:B,loadingMore:$,onLoadMore:ce,...l!=null&&l.writeFile?{onSaveFile:Ce}:{},onCollapse:()=>{ee(),w("viewer")},pdfUrl:K,previewFile:T,previewLoading:R,plugins:a,selectedTarget:Ah(V)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:we}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:le}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Z?t.jsx(Dh,{files:te,onCancel:()=>P(!1),onConfirm:()=>void _e()}):null,q?t.jsxs(Mn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(sr,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:le})}),t.jsx(An,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:we})})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(sr,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:le})}),t.jsx(An,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:we})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:z=>void X(z)})]})}var Hr,Uo,Vo,Ko,qo,Or,Xo,Yo,Zo,Wh=Oe({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){oa(),$h(),Bh(),Lo(),Hr=24e3,Uo="remote-codex:graphchat:workspace:expanded:",Vo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Ko="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",qo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Or="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",Xo="thread-graph-explorer-collapse-button flex h-8 w-8 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",Yo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Zo="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function yn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function Qt({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Uh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function mr({value:e,title:r,icon:n,children:a}){return t.jsxs(Tr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(nn,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(Uh,{children:n}),r]})}),t.jsx(Er,{className:"space-y-3 pb-3",children:a})]})}function Vh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(Sr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(mr,{value:"start",title:"Getting Started",icon:t.jsx(D.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(Qt,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(mr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(D.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.Upload,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Upload"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Upload files through the Workspace panel when the host exposes workspace upload support. Composer attachments stay available for prompt context."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.Plus,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"New files and folders"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Remote Codex normally creates files through tools and shell commands. They appear in Explorer after workspace refreshes."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.MoveRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Move and organize"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Use the agent or terminal to reorganize files. Explorer keeps the GraphChat file tree and preview flow."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.Trash2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-400"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Garbage folder"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"If the host exposes garbage controls, Explorer can permanently empty unwanted workspace files."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(Qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(mr,{value:"viewer",title:"Viewer",icon:t.jsx(D.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(Qt,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(mr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(D.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(Qt,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(Qt,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(mr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(D.Code2,{className:"h-3 w-3"}),children:t.jsx(Qt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var Kh=Oe({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Lr()}});function qh(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
13
- ...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ya({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:qh(r)})]})}function Xh({event:e}){return t.jsxs(Tr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(nn,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(Er,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ya,{label:"Input",value:e.preview}),t.jsx(Ya,{label:"Output",value:e.detail})]})})]})}function Yh({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[o,s]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{s(i=>{var d;return i??((d=n.at(-1))==null?void 0:d.id)??null})},[n]),c.useEffect(()=>{var i;(i=l.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[n.length]),r.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] p-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Calls this session"}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-[var(--theme-fg-muted)] opacity-60",disabled:!0,title:"Remote Codex streams tool history from thread events",children:[t.jsx(D.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(Sr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Xh,{event:i},i.id))}),t.jsx("div",{ref:l})]})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"No tool calls yet. Run the agent to see usage."}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-2 py-1 text-xs",children:[t.jsx(D.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Zh=Oe({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Lr()}});function Za(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),o=e.internals.positionAbsolute,s=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=o.x+d,m=o.y+h,f=s.x+l/2,p=s.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),k=1/(Math.abs(g)+Math.abs(b)),x=k*g,j=k*b,w=d*(x+j)+u,y=h*(-x+j)+m;return{x:w,y}}function Ja(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),o=Math.round(n.y),s=Math.round(r.x),l=Math.round(r.y);return s<=a+1?Gt.Left:s>=a+(e.measured.width??1)-1?Gt.Right:l<=o+1?Gt.Top:l>=n.y+(e.measured.height??1)-1?Gt.Bottom:Gt.Top}function Jo(e,r){const n=Za(e,r),a=Za(r,e),o=Ja(e,n),s=Ja(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Jh(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,b)=>{const k=g.id.split("").reduce((x,j)=>{const w=(x<<5)-x+j.charCodeAt(0);return w&w},0);f.set(g.id,{x:Math.abs(k)%u+b*100%u,y:Math.abs(k>>16)%m+b*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let b=0;b<p;b+=1)for(let k=b+1;k<p;k+=1){const x=d[b],j=d[k];if(!x||!j)continue;const w=f.get(x.id),y=f.get(j.id);if(!w||!y)continue;const v=w.x-y.x,S=w.y-y.y,N=Math.sqrt(v*v+S*S)||1,M=(200-N)*.5,R=v/N*M,Q=S/N*M;w.vx+=R,w.vy+=Q,y.vx-=R,y.vy-=Q}h.forEach(b=>{const k=f.get(b.source),x=f.get(b.target);if(!k||!x)return;const j=x.x-k.x,w=x.y-k.y,y=Math.sqrt(j*j+w*w)||1,S=(y-120)*.3,N=j/y*S,I=w/y*S;k.vx+=N,k.vy+=I,x.vx-=N,x.vy-=I}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},o=new Set(e.map(d=>d.id)),s=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}})})});const l=a(e,s,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:s}}var la=Oe({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Qh({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:o}){if(!o)return null;const s={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Jo(o,s),[f]=Hs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var eu=Oe({"src/components/graph-chat/FloatingConnectionLine.tsx"(){la()}});function tu({id:e,source:r,target:n,markerEnd:a,style:o}){const s=Ca(r),l=Ca(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Jo(s,l),[p]=Hs({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:o})}var ru=Oe({"src/components/graph-chat/FloatingEdge.tsx"(){la()}});function nu({nodes:e}){const[r,n,a]=bd([]),[o,s,l]=vd([]),i=c.useMemo(()=>Jh(e),[e]),d=c.useMemo(()=>({floating:tu}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Na,{type:"target",position:Gt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Na,{type:"source",position:Gt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>kd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(wd,{children:t.jsxs(yd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Qh,children:[t.jsx(jd,{}),t.jsx(Nd,{gap:16})]})})})}var au=Oe({"src/components/graph-chat/GraphVisualization.tsx"(){eu(),ru(),la()}});function su(e){return{...el,...e}}function Qa(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function ou(e,r){switch(r){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}}function lu(e){var o;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const s of e.turns)for(const l of s.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:qr(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??s.id,status:l.status??null,sequence:a}),a+=1);for(const s of((o=e.liveItems)==null?void 0:o.items)??[])n.has(s.kind)&&(r.push({id:s.id,kind:s.kind,label:qr(s.kind),preview:s.previewText??s.text??s.kind,detail:s.detailText??s.text??s.previewText??s.kind,turnId:s.sourceTurnId??null,status:s.status??null,sequence:a}),a+=1);return r}function qr(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function iu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return qr(e.kind)}}function du(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function cu(e,r){const n=[{id:`thread:${e.thread.id}`,name:e.thread.title||"Thread",description:e.thread.model??e.thread.status},{id:`workspace:${e.workspace.id}`,name:e.workspace.label??"Workspace",description:e.workspace.absPath,out_node_id:`thread:${e.thread.id}`}];let a=null;for(const s of e.turns){const l=`turn:${s.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:s.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of s.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:iu(d),description:du(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const o=new Set(n.map(s=>s.id));for(const s of r){const l=`tool:${s.id}`;o.has(l)||o.has(`item:${s.id}`)||n.push({id:l,name:s.label,description:s.preview,out_node_id:s.turnId?`turn:${s.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function Qo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>su(i),[i]),u=Qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Qc(e),[e]),g=c.useMemo(()=>lu(e),[e]),b=c.useMemo(()=>{const v=new Map;for(const S of g)v.set(S.kind,(v.get(S.kind)??0)+1);return[...v.entries()].sort((S,N)=>N[1]-S[1])},[g]),k=n.getThreadPanels(),x=Math.max(...b.map(([,v])=>v),1),j=c.useMemo(()=>cu(e,g),[e,g]),w=c.useMemo(()=>{const v=[];return h.workspace&&v.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&v.push({id:"tools",label:"Tool Usage",icon:D.BarChart2}),h.guide&&v.push({id:"guide",label:"Guide",icon:D.BookOpen}),v},[h.guide,h.toolUsage,h.workspace]),y=c.useMemo(()=>{const v=[];return h.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:D.GitBranch}),h.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:D.Wrench}),v},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!ou(h,m))&&f(Qa(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[w.map(v=>{const S=v.icon;return t.jsxs("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===v.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),y.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:y.map(v=>{const S=v.icon;return t.jsx("button",{type:"button",onClick:()=>f(v.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Oh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Yh,{formatToolKind:qr,toolCounts:b,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(nu,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(rr,{label:"Plugin Panels",children:k.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:k.map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.label},v.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(rr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(v=>v.enabled).map(v=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:v.name},v.id))})}),t.jsx(rr,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.Terminal,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Terminal stays available when the Terminal plugin and shell adapter are attached."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.Paperclip,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Composer attachments, slash panels, hooks, MCP, goals, and fork controls remain part of the chat surface."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(D.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),o?t.jsx(rr,{label:"Thread Meta",children:o}):null,s?t.jsx(rr,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Vh,{}):null]})]}):null}var el,tl,hu=Oe({"src/components/ThreadGraphWorkspacePanel.tsx"(){Wh(),$o(),Kh(),Zh(),oa(),au(),el={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},tl=c.memo(Qo)}}),rl={};Jc(rl,{MemoizedThreadGraphWorkspacePanel:()=>tl,ThreadGraphWorkspacePanel:()=>Qo});var uu=Oe({"src/workspace-panel.ts"(){hu()}});function ir(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}ir(`.thread-ui-shell,
9
+ `),a+=i}return n.length>0?n:[e]}function Va(e,r){return r!=="xyz"?e:e.flatMap(n=>zh(n))}function qa(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
10
+ `).join("")}function Ph(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=Va([e],"xyz");return{frames:o,format:"xyz",exportContent:qa(o)}}const r=Ih(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:Va(n,r),format:r,exportContent:qa(n)}}var Rh=He({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function Mh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:o,title:s="PyMOL-style (PDB/CIF)"}){const l=c.useRef(null),i=c.useRef(null),d=c.useRef(null),h=c.useRef(!1),u=c.useRef(!0),[m,f]=c.useState(null),[p,g]=c.useState(0),[b,w]=c.useState(null),[x,j]=c.useState(!1),[y,v]=c.useState({}),[k,S]=c.useState([]),[N,L]=c.useState({}),[R,P]=c.useState(!1),[Q,D]=c.useState(!1),[Z,J]=c.useState(null),z=c.useMemo(()=>Ph(o),[o]),te=z.frames,se=z.format,$=te[p]??null,le=te.length>0&&p===te.length-1,q=r??"current",H=Object.values(N).reduce((E,C)=>E+C.length,0),G=Object.keys(N).length;c.useEffect(()=>{if(te.length===0){g(0);return}g(te.length-1)},[te.length]),c.useEffect(()=>{if(!x||te.length<=1)return;const E=window.setInterval(()=>{g(C=>C>=te.length-1?(window.clearInterval(E),j(!1),C):C+1)},200);return()=>window.clearInterval(E)},[x,te.length]),c.useEffect(()=>{const E=l.current;if(!E||i.current)return;let C=!1;try{const U=document.createElement("canvas");if(!(U.getContext("webgl2")||U.getContext("webgl")||U.getContext("experimental-webgl"))){J("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{J("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const W=()=>{var U,ne;(U=i.current)==null||U.resize(),(ne=i.current)==null||ne.render()};return Sh().then(U=>{if(!(C||i.current))try{const ne=U.createViewer(E,{});i.current=ne,ne.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",W),window.setTimeout(W,100)}catch(ne){console.error("Failed to initialize 3Dmol viewer:",ne),J("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(U=>{console.error("Failed to load 3Dmol viewer runtime:",U),J("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{C=!0,window.removeEventListener("resize",W),i.current=null,d.current=null}},[]),c.useEffect(()=>{const E=i.current;if(!(!E||!$))try{E.removeAllModels(),E.removeAllShapes(),E.removeAllLabels();const C=E.addModel($,se||"xyz");d.current=C,C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const W=C.getCrystData(),U=!!(W&&typeof W=="object"&&Object.keys(W).length);P(U),D(U?u.current:!1),S([]),v({});const ne=$.split(`
11
+ `).slice(2).map(K=>K.trim()).filter(Boolean).map(K=>K.split(/\s+/)[0]??"Atom");h.current||(E.zoomTo(),h.current=!0),C.setClickable({},!0,(K,ie,ee)=>{const ve=K.serial??K.index;if(ve===void 0)return;const oe=K.atom||K.elem||ne[ve]||"Atom";S(ye=>{const de=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ye.includes(ve)?ye.filter(Ce=>Ce!==ve):[...ye,ve]:ye.length===1&&ye[0]===ve?[]:[ve];return v(Ce=>{if(de.length===0)return{};const Ee={};return de.forEach(Y=>{Ee[Y]=Ce[Y]||ne[Y]||oe}),Ee}),de})}),C.setHoverable({},!0,(K,ie,ee)=>{!ee||!K||w({x:ee.clientX,y:ee.clientY,label:`${K.atom||K.elem||"Atom"} (${K.serial??K.index??"?"})`,coords:{x:K.x.toFixed(2),y:K.y.toFixed(2),z:K.z.toFixed(2)}})},()=>w(null)),E.render()}catch(C){console.error("Failed to render molecule:",C),J("Unable to render this molecular structure.")}},[$,se]),c.useEffect(()=>{const E=i.current,C=d.current;if(!(!E||!C)){try{E.removeUnitCell(C)}catch{}if(Q&&R)try{E.addUnitCell(C,{box:{color:"black",opacity:1,linewidth:5},astyle:{radius:.12,mid:.85,color:"red",opacity:.6},bstyle:{radius:.12,mid:.85,color:"green",opacity:.6},cstyle:{radius:.12,mid:.85,color:"blue",opacity:.6},alabel:"a",blabel:"b",clabel:"c"})}catch{P(!1),D(!1)}E.render()}},[R,Q,$,se]),c.useEffect(()=>{const E=i.current,C=d.current;!E||!C||!$||(C.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),k.length>0&&C.setStyle({serial:k},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),E.render(),a==null||a({moleculeId:r,atoms:k}))},[r,a,k,$]),c.useEffect(()=>{if(!$)return;let E=0;const C=()=>{var U,ne;const W=(ne=(U=i.current)==null?void 0:U.getView)==null?void 0:ne.call(U);if(Array.isArray(W)&&W.length>=8){const[K,ie,ee,ve,oe,ye,Me,de]=W;if(typeof K=="number"&&typeof ie=="number"&&typeof ee=="number"&&typeof ve=="number"&&typeof oe=="number"&&typeof ye=="number"&&typeof Me=="number"&&typeof de=="number"){const Ce=Math.sqrt(oe*oe+ye*ye+Me*Me),Ee=Ce>0?{x:oe/Ce,y:ye/Ce,z:Me/Ce}:{x:0,y:0,z:0};f({position:{x:K,y:ie,z:ee,qx:oe,qy:ye,qz:Me,qw:de},lookAt:Ee,zoom:ve})}}E=window.requestAnimationFrame(C)};return E=window.requestAnimationFrame(C),()=>window.cancelAnimationFrame(E)},[$]);const T=c.useCallback(async()=>{const E=i.current;if(!(E!=null&&E.pngURI))return;E.render();const C=E.pngURI();if(C){try{const U=await(await fetch(C)).blob(),ne=new ClipboardItem({[U.type||"image/png"]:U});await navigator.clipboard.write([ne])}catch{}n==null||n({moleculeId:r,image:C})}},[r,n]);function F(){R&&D(E=>{const C=!E;return u.current=C,C})}function B(){k.length!==0&&L(E=>{const C=E[q]??[];return{...E,[q]:Array.from(new Set([...C,...k]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:s}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[Z?t.jsx("div",{"data-testid":"molecule-viewer-error",className:"thread-graph-molecule-error absolute inset-0 flex items-center justify-center bg-red-50 p-4 text-sm text-red-700",children:Z}):null,!Z&&!$?t.jsx("div",{className:"thread-graph-molecule-empty absolute inset-0 flex items-center justify-center p-4 text-sm text-slate-400",children:"No molecule data available."}):null,b?t.jsxs("div",{className:"thread-graph-molecule-tooltip pointer-events-none fixed z-[1000] rounded-md border border-gray-300 bg-white/95 px-2 py-1.5 text-[10px] text-gray-800 shadow-md",style:{left:b.x-20,top:b.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:b.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",b.coords.x]}),t.jsxs("span",{children:["y: ",b.coords.y]}),t.jsxs("span",{children:["z: ",b.coords.z]})]})]}):null]}),t.jsxs("div",{className:"thread-graph-molecule-controls shrink-0",children:[t.jsxs("div",{className:"thread-graph-molecule-control-row",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-graph-molecule-control-title",children:"Ball & Stick"}),t.jsx("p",{className:"thread-graph-molecule-control-subtitle",children:"XYZ / PDB / CIF preview"})]}),t.jsx(Nh,{currentIndex:p,exportContent:z.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:$,xyzFormat:se})]}),te.length>1?t.jsxs("div",{className:"thread-graph-molecule-trajectory",children:[t.jsxs("div",{className:"mb-2 flex justify-between gap-3 text-xs",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:["Trajectory ",p+1," / ",te.length,t.jsx(Nr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(E=>{const C=!E;return C&&p===te.length-1&&g(0),C})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==te.length-1?t.jsx(_.Pause,{className:"h-3 w-3"}):t.jsx(_.Play,{className:"h-3 w-3"})})]}),t.jsxs(Nr,{type:"button",variant:"ghost",onClick:()=>g(te.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${le?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(Eh,{value:[p],max:te.length-1,step:1,onValueChange:E=>g(E[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(yh,{cameraInfo:m,onClearSelection:()=>S([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:k}),onSendStaged:()=>{Object.entries(N).forEach(([E,C])=>{a==null||a({moleculeId:E==="current"?r:E,atoms:C})})},onStageSelection:B,onToggleUnitCell:F,selectedAtomLabels:y,selectedSerials:k,stagedAtoms:H,stagedMolecules:G,unitCellAvailable:R,unitCellVisible:Q})]})]})]})}var Ah=He({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){jh(),Ch(),Th(),rn(),Lh(),Rh()}});function _h(e){return!e.truncated&&e.size<=Fo&&e.content.split(`
12
+ `).length<=Ho}function $h(e){return e&&(e.node.path||e.node.name)||null}function Dh(e){if(!e)return null;switch(e.kind){case"live-artifact":return{kind:"live-molecule",node:e};case"file":return{kind:"workspace-file",node:e};case"artifact":return{kind:"artifact",node:e};case"event":return{kind:"event",node:e};case"meta":return{kind:"meta",node:e};case"directory":return null}}function Bh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[b,w]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,v=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,k=oh(i??null),S=(i==null?void 0:i.language)||lh((i==null?void 0:i.path)??""),N=i?Ir(i.path):"",L=$h(u),R=i!==null&&sa.has(N),P=!!(i&&a)&&!R&&_h(i),Q=(u==null?void 0:u.kind)==="live-molecule",D=!!(y!=null&&y.artifact&&v),Z=!!k||D;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),w(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function J(){if(!(!i||!a)){j(!0),w(null);try{await a({path:i.path,content:p}),f(!1)}catch(z){w(z instanceof Error?z.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),L?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:L}):null]}),s?t.jsx("button",{type:"button",onClick:s,"data-testid":"collapse-viewer",className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&k?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(Mh,{source:k,moleculeId:k.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[R?"molecule":S||N||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),P?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),w(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(_.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void J(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(_.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),w(null)},className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition",title:"Edit file","aria-label":"Edit file",children:t.jsx(_.Pencil,{className:"h-4 w-4"})})}):null]}),b?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-4 py-2 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:b}):null,m?t.jsx("textarea",{value:p,onChange:z=>g(z.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Fr,{content:i.content}),i.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:Z||Q?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:v}):u.kind==="meta"?t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-3",children:t.jsx("div",{className:"grid gap-3",children:t.jsx(rr,{label:"Workspace Data",children:t.jsx(Fr,{content:u.node.detail??""})})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"thread-graph-file-preview-header border-b px-4 py-3 text-xs uppercase tracking-[0.12em]",children:u.node.kind}),t.jsx(Fr,{content:u.node.detail??u.node.preview??u.node.name})]}):t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Pick a live molecule, workspace file, artifact, or thread event to preview it."})]})]})}var Fo,Ho,Fr,Gh=He({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){oa(),$o(),Ah(),Fo=50*1024,Ho=1e3,Fr=c.memo(function({content:r}){return t.jsx("div",{className:"thread-graph-code-preview min-h-0 flex-1 overflow-auto",children:t.jsx("pre",{className:"thread-graph-plain-code-preview",children:t.jsx("code",{children:r})})})})}});function Fh({files:e,onCancel:r,onConfirm:n}){return t.jsx("div",{className:"thread-graph-dialog-backdrop fixed inset-0 z-50 flex items-center justify-center bg-black/40 px-4",children:t.jsxs("div",{className:"thread-graph-dialog w-full max-w-sm rounded-xl border bg-[var(--theme-panel)] p-6 shadow-xl",children:[t.jsx("h3",{className:"text-base font-semibold text-[var(--theme-fg)]",children:"Empty garbage?"}),t.jsxs("p",{className:"mt-1 text-sm leading-5 text-[var(--theme-fg-muted)]",children:["Permanently delete all files in the"," ",t.jsx("code",{className:"rounded bg-[var(--theme-muted)] px-1 text-xs text-[var(--theme-fg-soft)]",children:"garbage/"})," ","folder."]}),e.length===0?t.jsx("p",{className:"mt-3 text-sm text-[var(--theme-fg-muted)]",children:"Garbage is empty."}):t.jsx("ul",{className:"mt-3 max-h-40 overflow-y-auto rounded-md border border-[var(--theme-border)] bg-[var(--theme-surface)] p-2 text-xs text-[var(--theme-fg-soft)]",children:e.map(a=>t.jsx("li",{className:"truncate py-0.5",title:a,children:a},a))}),t.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:r,className:"thread-secondary-action rounded-md px-3 py-1.5 text-sm",children:"Cancel"}),e.length>0?t.jsx("button",{type:"button",onClick:n,className:"ui-action-danger rounded-md px-3 py-1.5 text-sm font-medium",children:"Yes, empty garbage"}):null]})]})})}var Hh=He({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Oo(e){return`${Uo}${e.workspaceId??"workspace"}:${e.threadId}`}function Oh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Oo(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Ka(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Oo(e),JSON.stringify([...r]))}catch{}}function Gn(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>Gn(s,n.get(s.path)??null)),o=e.childrenLoaded&&e.children.length>0;return{...e,children:o||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Xa(e,r){if(e.kind==="directory")return r?t.jsx(_.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(_.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Ir(e.name);return n==="zip"?t.jsx(_.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(_.FileImage,{className:"h-4 w-4 text-sky-500"}):e.kind==="artifact"||["xyz","extxyz","cif","pdf","json","ts","tsx","js","jsx","md","yaml","yml","py"].includes(n)?t.jsx(_.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(_.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Wo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(_.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(_.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Xa(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(_.Download,{className:"h-3.5 w-3.5"})}):null,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(b=>t.jsx(Wo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:b,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},b.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Xa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(_.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(_.Download,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Wh({liveNodes:e,onSelect:r,selectedNodeId:n}){return e.length===0?null:t.jsxs("div",{className:"border-b border-slate-200 py-2 dark:border-[#2a2f3a]",children:[t.jsx("div",{className:"thread-graph-workspace-label px-3 pb-1 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",children:"Live"}),t.jsx("div",{className:"space-y-0.5",children:e.map(a=>{var s;const o=n===a.id;return t.jsxs("button",{type:"button","data-testid":"live-molecule-item","data-molecule-id":((s=a.artifact)==null?void 0:s.id)??a.id,onClick:()=>r(a.id),className:`thread-graph-tree-row flex min-h-9 w-full items-center gap-2 px-3 py-2 text-left text-sm transition sm:min-h-0 sm:py-1.5 ${o?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsx(_.FileCode2,{className:`h-4 w-4 shrink-0 ${o?"text-current":"text-emerald-600 dark:text-emerald-300"}`}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:a.name})]},a.id)})})]})}function Uh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:b,selectedNodeId:w,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(v=>v.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const v=b.current;v&&(v.scrollTop=g.current)},[b,g]),t.jsxs("aside",{className:`${Vo} flex flex-col`,children:[t.jsxs("div",{className:qo,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Ko,children:"Explorer"})}),t.jsxs("div",{className:"flex items-center gap-1",children:[n?t.jsxs("button",{type:"button","data-testid":"collapse-explorer",onClick:n,className:Xo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(_.ChevronsLeft,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Collapse Explorer"})]}):null,t.jsx("button",{type:"button",onClick:p,disabled:!r,className:Or,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(_.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Or,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(_.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Or,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(_.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:b,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:v=>{g.current=v.currentTarget.scrollTop},children:[t.jsx(Wh,{liveNodes:j??[],onSelect:m,selectedNodeId:w}),t.jsx("div",{className:Yo,children:"Workspace"}),t.jsx(Wo,{depth:0,expandedPaths:a,loadingPaths:o,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:w}),y.children.length===0?t.jsx("p",{className:Zo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Vh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,focusPathRequest:s,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Oa(r,n),[e,i,n,r,o,l]),u=i??h??Oa(r,n),m=c.useMemo(()=>hh(u),[u]),f=c.useMemo(()=>{var I;return((I=u.children.find(O=>O.path==="live"))==null?void 0:I.children)??[]},[u]),p=Mo(u),[g,b]=c.useState(()=>(p==null?void 0:p.id)??null),[w,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Wa((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[v,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(()=>new Set),[P,Q]=c.useState(!1),[D,Z]=c.useState(!1),[J,z]=c.useState(!1),[te,se]=c.useState([]),[$,le]=c.useState(null),[q,H]=c.useState(null),[G,T]=c.useState(null),[F,B]=c.useState(!1),E=c.useRef(null),C=c.useRef(null),W=c.useRef(0),U=c.useRef(null),ne=!!l,K=(g?m.get(g):null)??p??null,ie={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{W.current=0,U.current=null,x(new Set(["","artifacts","thread-events","live",...Oh(ie),...Wa((p==null?void 0:p.path)??"")]))},[ie.threadId,ie.workspaceId]);function ee(){var O;const I=((O=C.current)==null?void 0:O.scrollTop)??W.current;W.current=I,U.current=I}function ve(){const I=U.current??W.current;if(!C.current)return;let ae=0;const be=()=>{const je=C.current;je&&(je.scrollTop=Math.min(I,Math.max(0,je.scrollHeight-je.clientHeight)),W.current=je.scrollTop,ae+=1,ae<8?window.requestAnimationFrame(be):U.current=null)};window.requestAnimationFrame(be)}c.useLayoutEffect(()=>{j!=="explorer"&&ve()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 639px)"),O=()=>B(I.matches);return O(),typeof I.addEventListener=="function"?(I.addEventListener("change",O),()=>I.removeEventListener("change",O)):(I.addListener(O),()=>I.removeListener(O))},[]);async function oe(I){if(!l)return;const O=I??(K==null?void 0:K.path)??null;N(!0),k(null);try{const ae=tr(await l.listTree({...ie,path:""}));let be=i?Gn(ae,i):ae;if(i){const Te=[...w].filter(fe=>fe).sort((fe,Be)=>fe.split("/").length-Be.split("/").length);for(const fe of Te){const Be=_n(i,fe);if((Be==null?void 0:Be.kind)!=="directory"||!Be.childrenLoaded)continue;const _e=tr(await l.listTree({...ie,path:fe}));be=$n(be,fe,Gn(_e,Be))}}d(be);const je=zo(be);b(Te=>{var Be;const fe=O??(Te?(Be=m.get(Te))==null?void 0:Be.path:null);return fe&&Dn(be,fe)?`workspace:${fe}`:(je==null?void 0:je.id)??Te})}catch(ae){k(ae instanceof Error?ae.message:"Failed to load workspace"),d(null)}finally{N(!1)}}async function ye(I){if(!(!l||!i)){R(O=>{if(O.has(I))return O;const ae=new Set(O);return ae.add(I),ae}),k(null);try{const O=tr(await l.listTree({...ie,path:I}));d(ae=>ae&&Io(ae,I,O.children,{truncated:O.truncated}))}catch(O){k(O instanceof Error?O.message:"Failed to load directory")}finally{R(O=>{if(!O.has(I))return O;const ae=new Set(O);return ae.delete(I),ae})}}}async function Me(I){const O=Po(I);if(!O)return;const ae=sh(O);if(y(null),x(be=>{const je=new Set(be);je.add("");for(const Te of ae)je.add(Te);return Ka(ie,je),je}),!l){Dn(u,O)&&b(`workspace:${O}`);return}N(!0),k(null);try{let be=i??tr(await l.listTree({...ie,path:""}));for(const je of ae){const Te=_n(be,je);if((Te==null?void 0:Te.kind)==="directory"&&Te.childrenLoaded)continue;const fe=tr(await l.listTree({...ie,path:je}));be=$n(be,je,fe)}d(be),b(`workspace:${O}`)}catch(be){k(be instanceof Error?be.message:`Failed to open ${O}`)}finally{N(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const I of m.values())I.path&&I.kind==="directory"&&w.has(I.path)&&I.hasChildren&&!I.childrenLoaded&&!L.has(I.path)&&ye(I.path)},[i,w,m,l]),c.useEffect(()=>{d(null),R(new Set),le(null),H(null),T(null),k(null),oe()},[ne,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Me(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,ie.threadId,ie.workspaceId]),c.useEffect(()=>{const I=l&&(K==null?void 0:K.kind)==="file"?K.path:null;if(!I){le(null),H(null),T(null);return}const O=I;let ae=!1;async function be(){var je;if(l){Q(!0),k(null),le(null),H(null),T(null);try{const Te=Ir(O),fe=(je=l.getRawFileUrl)==null?void 0:je.call(l,{...ie,path:O});if(fe&&Ao.has(Te)){ae||H(fe);return}if(fe&&_o.has(Te)){ae||T(fe);return}const Be=await l.readFile({...ie,path:O,limit:Hr});ae||le(Be)}catch(Te){ae||k(Te instanceof Error?Te.message:"Failed to read file")}finally{ae||Q(!1)}}}return be(),()=>{ae=!0}},[l,K==null?void 0:K.id]);async function de(){if(!(!l||!($!=null&&$.truncated))){Z(!0);try{const I=await l.readFile({...ie,path:$.path,offset:$.nextOffset,limit:Hr});le(O=>O&&{...O,content:O.content+I.content,truncated:I.truncated,nextOffset:I.nextOffset,size:I.size})}finally{Z(!1)}}}async function Ce(I){if(!(l!=null&&l.writeFile))return;k(null),await l.writeFile({...ie,path:I.path,content:I.content}),await oe(I.path);const O=await l.readFile({...ie,path:I.path,limit:Hr});le(O)}async function Ee(I){if(!(!(l!=null&&l.uploadFile)||!I)){N(!0),k(null);try{const O=await l.uploadFile({...ie,path:I.name,file:I}),ae=O.kind==="archive"?O.paths[0]??null:O.file.path;await oe(ae)}catch(O){k(O instanceof Error?O.message:"Failed to upload file")}finally{N(!1)}}}async function Y(I){var ae;const O=(ae=I.target.files)==null?void 0:ae[0];I.target.value="",O&&await Ee(O)}function ue(){if(!(l!=null&&l.uploadFile))return;const I=()=>{var O;return(O=E.current)==null?void 0:O.click()};if(l.pickUploadFile){l.pickUploadFile({...ie,defaultPick:I,upload:Ee});return}I()}function ke(I){var O;(O=l==null?void 0:l.downloadNode)==null||O.call(l,{...ie,path:I.path,kind:I.kind==="directory"?"directory":"file"})}function we(I){if(!I.path||typeof navigator>"u"||!navigator.clipboard)return;const O=r.workspace.absPath.replace(/\/+$/,""),ae=I.path.startsWith("/")?I.path:O?`${O}/${I.path.replace(/^\/+/,"")}`:I.path;navigator.clipboard.writeText(ae).catch(be=>{k(be instanceof Error?be.message:"Failed to copy file path")})}function De(I){I.kind==="file"&&(ee(),b(I.id),y("explorer"))}async function Fe(){if(l!=null&&l.emptyGarbage){if(k(null),!l.listGarbage){se([]),z(!0);return}try{const I=await l.listGarbage(ie);se(I.map(O=>`garbage/${O}`))}catch(I){se([]),k(I instanceof Error?I.message:"Failed to list garbage files")}finally{z(!0)}}}async function Ae(){if(l!=null&&l.emptyGarbage){z(!1),k(null);try{await l.emptyGarbage(ie),await oe((K==null?void 0:K.path)??null)}catch(I){k(I instanceof Error?I.message:"Failed to empty garbage")}}}const Oe={onCopyPath:we,...l!=null&&l.downloadNode?{onDownload:ke}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Fe}:{},...l?{onRefresh:()=>void oe((K==null?void 0:K.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ue}:{}};function V(I){if(!I)return;const O=m.get(`workspace:${I}`),ae=(O==null?void 0:O.kind)==="directory"&&O.hasChildren&&!O.childrenLoaded&&!L.has(I);x(be=>{const je=new Set(be);return je.has(I)?je.delete(I):je.add(I),Ka(ie,je),je}),!w.has(I)&&ae&&ye(I)}const ce=t.jsx(Uh,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{ee(),y("explorer")},expandedPaths:w,loadingPaths:L,loading:S,explorerScrollTopRef:W,explorerScrollerRef:C,...Oe,onPreview:De,onSelect:I=>{b(I)},onToggle:V,selectedNodeId:(K==null?void 0:K.id)??null,tree:u,liveNodes:f}),xe=t.jsx(Bh,{error:v,imageUrl:q,loadingMore:D,onLoadMore:de,...l!=null&&l.writeFile?{onSaveFile:Ce}:{},onCollapse:()=>{ee(),y("viewer")},pdfUrl:G,previewFile:$,previewLoading:P,plugins:a,selectedTarget:Dh(K)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:xe}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:ce}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[J?t.jsx(Fh,{files:te,onCancel:()=>z(!1),onConfirm:()=>void Ae()}):null,F?t.jsxs(Mn,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(sr,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:ce})}),t.jsx(An,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:xe})})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(sr,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:ce})}),t.jsx(An,{className:"thread-graph-workspace-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:xe})})]}),t.jsx("input",{ref:E,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:I=>void Y(I)})]})}var Hr,Uo,Vo,qo,Ko,Or,Xo,Yo,Zo,qh=He({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){oa(),Gh(),Hh(),Lo(),Hr=24e3,Uo="remote-codex:graphchat:workspace:expanded:",Vo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",qo="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Ko="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Or="thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",Xo="thread-graph-explorer-collapse-button flex h-8 w-8 items-center justify-center rounded-full text-slate-500 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-400 dark:hover:bg-[#222733] dark:hover:text-slate-100",Yo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Zo="thread-graph-workspace-empty mx-4 mt-3 rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-4 text-sm text-slate-500 dark:border-[#303642] dark:bg-[#1b1f29] dark:text-slate-400"}});function yn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function Qt({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Kh({children:e}){return t.jsx("span",{className:"thread-guide-icon flex h-5 w-5 shrink-0 items-center justify-center rounded-md",children:e})}function mr({value:e,title:r,icon:n,children:a}){return t.jsxs(Tr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(nn,{className:"py-3 hover:no-underline [&[data-state=open]]:pb-2",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-[var(--theme-fg)]",children:[t.jsx(Kh,{children:n}),r]})}),t.jsx(Er,{className:"space-y-3 pb-3",children:a})]})}function Xh(){return t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] px-4 py-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"What can I do?"}),t.jsx("p",{className:"mt-0.5 text-[11px] text-[var(--theme-fg-muted)]",children:"Upload files, ask in plain language, get results."})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto px-3 pb-6",children:t.jsxs(Sr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(mr,{value:"start",title:"Getting Started",icon:t.jsx(_.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(Qt,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(mr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(_.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Upload,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Upload"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Upload files through the Workspace panel when the host exposes workspace upload support. Composer attachments stay available for prompt context."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Plus,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"New files and folders"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Remote Codex normally creates files through tools and shell commands. They appear in Explorer after workspace refreshes."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.MoveRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Move and organize"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Use the agent or terminal to reorganize files. Explorer keeps the GraphChat file tree and preview flow."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Trash2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-400"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Garbage folder"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"If the host exposes garbage controls, Explorer can permanently empty unwanted workspace files."})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(Qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(yn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(mr,{value:"viewer",title:"Viewer",icon:t.jsx(_.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(Qt,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(mr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(_.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(Qt,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(Qt,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(mr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(_.Code2,{className:"h-3 w-3"}),children:t.jsx(Qt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var Yh=He({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Lr()}});function Zh(e){if(e==null)return"—";if(typeof e=="string")return e.length>2e3?`${e.slice(0,2e3)}
13
+ ...(truncated)`:e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function Ya({label:e,value:r}){return t.jsxs("div",{children:[t.jsx("p",{className:"mb-1 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:e}),t.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-[var(--theme-surface-strong)] p-2 text-[11px] leading-relaxed text-[var(--theme-fg-soft)]",children:Zh(r)})]})}function Jh({event:e}){return t.jsxs(Tr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(nn,{className:"px-3 py-2 text-xs font-medium text-[var(--theme-fg)] hover:bg-[var(--theme-hover)] hover:no-underline [&[data-state=open]]:bg-[var(--theme-hover)]",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--theme-accent-strong)]"}),t.jsx("span",{className:"truncate font-mono text-xs font-medium text-[var(--theme-fg)]",children:e.label}),e.status?t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:e.status}):null]}),t.jsx("div",{className:"ml-auto flex shrink-0 items-center gap-2",children:e.turnId?t.jsx("span",{className:"max-w-20 truncate text-[10px] text-[var(--theme-fg-muted)]",children:e.turnId}):null})]}),t.jsx(Er,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ya,{label:"Input",value:e.preview}),t.jsx(Ya,{label:"Output",value:e.detail})]})})]})}function Qh({formatToolKind:e,toolCounts:r,toolEvents:n,maxToolCount:a}){const[o,s]=c.useState(()=>{var i;return((i=n.at(-1))==null?void 0:i.id)??null}),l=c.useRef(null);return c.useEffect(()=>{s(i=>{var d;return i??((d=n.at(-1))==null?void 0:d.id)??null})},[n]),c.useEffect(()=>{var i;(i=l.current)==null||i.scrollIntoView({behavior:"smooth",block:"nearest"})},[n.length]),r.length?t.jsxs("div",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 border-b border-[var(--theme-border)] p-4",children:[t.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[t.jsx("h2",{className:"text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Calls this session"}),t.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] text-[var(--theme-fg-muted)] opacity-60",disabled:!0,title:"Remote Codex streams tool history from thread events",children:[t.jsx(_.RefreshCw,{className:"h-3 w-3"}),"Reload"]})]}),t.jsx("div",{className:"space-y-2",children:r.map(([i,d])=>t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("span",{className:"w-40 shrink-0 truncate text-right font-mono text-[11px] text-[var(--theme-fg-muted)]",title:e(i),children:e(i)}),t.jsxs("div",{className:"flex flex-1 items-center gap-2",children:[t.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded-sm bg-[var(--theme-muted)]",children:t.jsx("div",{className:"h-full rounded-sm bg-[var(--theme-accent-strong)] transition-all duration-300",style:{width:`${d/a*100}%`}})}),t.jsx("span",{className:"w-5 shrink-0 text-right text-[11px] font-medium text-[var(--theme-fg-soft)]",children:d})]})]},i))})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[t.jsx("h2",{className:"mb-3 text-xs font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Call log"}),t.jsx(Sr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Jh,{event:i},i.id))}),t.jsx("div",{ref:l})]})]}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 text-sm text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"No tool calls yet. Run the agent to see usage."}),t.jsxs("span",{className:"inline-flex items-center gap-1 rounded px-2 py-1 text-xs",children:[t.jsx(_.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var eu=He({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Lr()}});function Za(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),o=e.internals.positionAbsolute,s=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=o.x+d,m=o.y+h,f=s.x+l/2,p=s.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),b=(f-u)/(2*d)+(p-m)/(2*h),w=1/(Math.abs(g)+Math.abs(b)),x=w*g,j=w*b,y=d*(x+j)+u,v=h*(-x+j)+m;return{x:y,y:v}}function Ja(e,r){const n={...e.internals.positionAbsolute,...e},a=Math.round(n.x),o=Math.round(n.y),s=Math.round(r.x),l=Math.round(r.y);return s<=a+1?Gt.Left:s>=a+(e.measured.width??1)-1?Gt.Right:l<=o+1?Gt.Top:l>=n.y+(e.measured.height??1)-1?Gt.Bottom:Gt.Top}function Jo(e,r){const n=Za(e,r),a=Za(r,e),o=Ja(e,n),s=Ja(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function tu(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,b)=>{const w=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(w)%u+b*100%u,y:Math.abs(w>>16)%m+b*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let b=0;b<p;b+=1)for(let w=b+1;w<p;w+=1){const x=d[b],j=d[w];if(!x||!j)continue;const y=f.get(x.id),v=f.get(j.id);if(!y||!v)continue;const k=y.x-v.x,S=y.y-v.y,N=Math.sqrt(k*k+S*S)||1,R=(200-N)*.5,P=k/N*R,Q=S/N*R;y.vx+=P,y.vy+=Q,v.vx-=P,v.vy-=Q}h.forEach(b=>{const w=f.get(b.source),x=f.get(b.target);if(!w||!x)return;const j=x.x-w.x,y=x.y-w.y,v=Math.sqrt(j*j+y*y)||1,S=(v-120)*.3,N=j/v*S,L=y/v*S;w.vx+=N,w.vy+=L,x.vx-=N,x.vy-=L}),f.forEach(b=>{b.x+=b.vx*.1,b.y+=b.vy*.1,b.vx*=.9,b.vy*=.9,b.x=Math.max(80,Math.min(u-80,b.x)),b.y=Math.max(80,Math.min(m-80,b.y))})}return f},o=new Set(e.map(d=>d.id)),s=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}})})});const l=a(e,s,r,n);return{nodes:e.map(d=>({id:d.id,type:"styledNode",position:l.get(d.id)??{x:100,y:100},data:{label:t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:"text-sm font-semibold",children:d.name}),d.description?t.jsx("div",{className:"mt-1 max-w-32 overflow-hidden text-ellipsis text-xs text-slate-500 dark:text-slate-400",children:d.description}):null]})}})),edges:s}}var la=He({"src/components/graph-chat/FloatingHelper.tsx"(){}});function ru({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:o}){if(!o)return null;const s={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Jo(o,s),[f]=Hs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var nu=He({"src/components/graph-chat/FloatingConnectionLine.tsx"(){la()}});function au({id:e,source:r,target:n,markerEnd:a,style:o}){const s=Ca(r),l=Ca(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Jo(s,l),[p]=Hs({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:o})}var su=He({"src/components/graph-chat/FloatingEdge.tsx"(){la()}});function ou({nodes:e}){const[r,n,a]=wd([]),[o,s,l]=yd([]),i=c.useMemo(()=>tu(e),[e]),d=c.useMemo(()=>({floating:au}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(Na,{type:"target",position:Gt.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(Na,{type:"source",position:Gt.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>jd({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Fs.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(Nd,{children:t.jsxs(Cd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:ru,children:[t.jsx(Sd,{}),t.jsx(Td,{gap:16})]})})})}var lu=He({"src/components/graph-chat/GraphVisualization.tsx"(){nu(),su(),la()}});function iu(e){return{...el,...e}}function Qa(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function du(e,r){switch(r){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}}function cu(e){var o;const r=[],n=new Set(["toolCall","commandExecution","webSearch","fileRead","fileChange","agentToolCall","skillToolCall","hook"]);let a=0;for(const s of e.turns)for(const l of s.items)n.has(l.kind)&&(r.push({id:l.id,kind:l.kind,label:Kr(l.kind),preview:l.previewText??l.text??l.kind,detail:l.detailText??l.text??l.previewText??l.kind,turnId:l.sourceTurnId??s.id,status:l.status??null,sequence:a}),a+=1);for(const s of((o=e.liveItems)==null?void 0:o.items)??[])n.has(s.kind)&&(r.push({id:s.id,kind:s.kind,label:Kr(s.kind),preview:s.previewText??s.text??s.kind,detail:s.detailText??s.text??s.previewText??s.kind,turnId:s.sourceTurnId??null,status:s.status??null,sequence:a}),a+=1);return r}function Kr(e){switch(e){case"toolCall":return"Tool call";case"agentToolCall":return"Agent tool";case"skillToolCall":return"Skill tool";case"commandExecution":return"Command";case"webSearch":return"Search";case"fileRead":return"File read";case"fileChange":return"File change";case"hook":return"Hook";default:return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase())}}function hu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Kr(e.kind)}}function uu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function mu(e,r){const n=[{id:`thread:${e.thread.id}`,name:e.thread.title||"Thread",description:e.thread.model??e.thread.status},{id:`workspace:${e.workspace.id}`,name:e.workspace.label??"Workspace",description:e.workspace.absPath,out_node_id:`thread:${e.thread.id}`}];let a=null;for(const s of e.turns){const l=`turn:${s.id}`;n.push({id:l,name:`Turn ${n.filter(d=>d.id.startsWith("turn:")).length+1}`,description:s.status,out_node_id:a?[`thread:${e.thread.id}`,a]:`thread:${e.thread.id}`}),a=l;let i=null;for(const d of s.items){const h=`item:${d.id}`,u=[l];i&&u.push(i),n.push({id:h,name:hu(d),description:uu(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const o=new Set(n.map(s=>s.id));for(const s of r){const l=`tool:${s.id}`;o.has(l)||o.has(`item:${s.id}`)||n.push({id:l,name:s.label,description:s.preview,out_node_id:s.turnId?`turn:${s.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function Qo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>iu(i),[i]),u=Qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>rh(e),[e]),g=c.useMemo(()=>cu(e),[e]),b=c.useMemo(()=>{const k=new Map;for(const S of g)k.set(S.kind,(k.get(S.kind)??0)+1);return[...k.entries()].sort((S,N)=>N[1]-S[1])},[g]),w=n.getThreadPanels(),x=Math.max(...b.map(([,k])=>k),1),j=c.useMemo(()=>mu(e,g),[e,g]),y=c.useMemo(()=>{const k=[];return h.workspace&&k.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&k.push({id:"tools",label:"Tool Usage",icon:_.BarChart2}),h.guide&&k.push({id:"guide",label:"Guide",icon:_.BookOpen}),k},[h.guide,h.toolUsage,h.workspace]),v=c.useMemo(()=>{const k=[];return h.threadGraph&&k.push({id:"graph",label:"Thread graph",icon:_.GitBranch}),h.extensions&&k.push({id:"extensions",label:"Remote Codex extensions",icon:_.Wrench}),k},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!du(h,m))&&f(Qa(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[y.map(k=>{const S=k.icon;return t.jsxs("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===k.id?"is-active":""}`,children:[S?t.jsx(S,{className:"h-3.5 w-3.5"}):null,k.label]},k.id)}),v.length?t.jsx("div",{className:"thread-graph-right-tab-secondary ml-auto flex min-w-0 shrink items-center gap-1 border-l pl-2","aria-label":"Remote Codex workspace extensions",children:v.map(k=>{const S=k.icon;return t.jsx("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===k.id?"is-active":""}`,title:k.label,"aria-label":k.label,children:t.jsx(S,{className:"h-3.5 w-3.5"})},k.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Vh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Qh,{formatToolKind:Kr,toolCounts:b,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(ou,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(rr,{label:"Plugin Panels",children:w.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:w.map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.label},k.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(rr,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(k=>k.enabled).map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.name},k.id))})}),t.jsx(rr,{label:"Remote Codex Tools",children:t.jsxs("div",{className:"grid gap-2 text-[var(--theme-fg-muted)]",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Terminal,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Terminal stays available when the Terminal plugin and shell adapter are attached."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Paperclip,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Composer attachments, slash panels, hooks, MCP, goals, and fork controls remain part of the chat surface."})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(_.Trash2,{className:"mt-0.5 h-4 w-4 shrink-0"}),t.jsx("p",{children:"Destructive actions stay explicit: delete thread, interrupt, compact, and hook trust controls remain host governed."})]})]})}),o?t.jsx(rr,{label:"Thread Meta",children:o}):null,s?t.jsx(rr,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Xh,{}):null]})]}):null}var el,tl,pu=He({"src/components/ThreadGraphWorkspacePanel.tsx"(){qh(),$o(),Yh(),eu(),oa(),lu(),el={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},tl=c.memo(Qo)}}),rl={};th(rl,{MemoizedThreadGraphWorkspacePanel:()=>tl,ThreadGraphWorkspacePanel:()=>Qo});var fu=He({"src/workspace-panel.ts"(){pu()}});function ir(e,{insertAt:r}={}){if(!e||typeof document>"u")return;const n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",r==="top"&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}ir(`.thread-ui-shell,
14
14
  .thread-graph-dialog {
15
15
  color-scheme: light;
16
16
  --radius: 0.625rem;
@@ -593,6 +593,39 @@ import{l as D,R as Ki,I as qi,C as Xi,S as Gs,H as Yi,T as Zi,a as Ji,b as Qi,c
593
593
  .thread-ui-shell .thread-card-session-copy-button {
594
594
  opacity: 0;
595
595
  }
596
+ .thread-ui-shell .thread-composer-pending-queue {
597
+ border-color: var(--theme-border);
598
+ background: color-mix(in srgb, var(--theme-panel) 94%, transparent);
599
+ box-shadow: 0 8px 24px color-mix(in srgb, var(--app-bg) 18%, transparent);
600
+ }
601
+ .thread-ui-shell .thread-composer-pending-row {
602
+ border-color: var(--theme-border);
603
+ background: var(--theme-surface);
604
+ }
605
+ .thread-ui-shell .thread-composer-steer-button {
606
+ border-color: color-mix(in srgb, var(--theme-accent) 35%, var(--theme-border));
607
+ background: color-mix(in srgb, var(--theme-accent) 10%, var(--theme-surface));
608
+ color: var(--theme-fg);
609
+ }
610
+ .thread-ui-shell .thread-composer-steer-button:hover:not(:disabled) {
611
+ background: color-mix(in srgb, var(--theme-accent) 18%, var(--theme-surface));
612
+ }
613
+ .thread-ui-shell .thread-composer-queue-remove {
614
+ color: var(--theme-fg-muted);
615
+ }
616
+ .thread-ui-shell .thread-composer-queue-remove:hover:not(:disabled) {
617
+ background: var(--theme-hover);
618
+ color: var(--theme-fg);
619
+ }
620
+ @media (max-width: 639px) {
621
+ .thread-ui-shell .thread-composer-pending-queue {
622
+ margin-bottom: 0.375rem;
623
+ border-radius: 0.75rem;
624
+ }
625
+ .thread-ui-shell .thread-composer-pending-row {
626
+ min-height: 2.75rem;
627
+ }
628
+ }
596
629
  .thread-ui-shell .thread-graph-room-card:hover .thread-card-session-copy-button,
597
630
  .thread-ui-shell .thread-card-session-copy-button:focus-visible,
598
631
  .thread-ui-shell .thread-card-session-copy-button:active {
@@ -3635,13 +3668,13 @@ import{l as D,R as Ki,I as qi,C as Xi,S as Gs,H as Yi,T as Zi,a as Ji,b as Qi,c
3635
3668
  padding: 1.5rem;
3636
3669
  }
3637
3670
  }
3638
- `);function mu(e){return e.replace(/\u00a0/g," ")}function pu(e,r){if(!e)return[];const n=[],a=[...r].sort((l,i)=>i.placeholder.length-l.placeholder.length);let o=0,s=0;for(;o<e.length;){const l=a.find(h=>e.startsWith(h.placeholder,o));if(l){n.push({type:"attachment",key:`${l.clientId}-${o}`,attachment:l}),o+=l.placeholder.length;continue}let i=e.length;for(const h of a){const u=e.indexOf(h.placeholder,o);u!==-1&&u<i&&(i=u)}const d=e.slice(o,i);d&&(n.push({type:"text",key:`text-${s}`,text:d}),s+=1),o=i}return n}function fu(e,r,n){const a=e==="photo"?"PHOTO":"FILE";let o=0;for(;;){const s=o===0?r:`${r} (${o+1})`,l=`[${a} ${s}]`;if(!n.has(l))return l;o+=1}}function gu(e,r,n){const a=r.start>0?e[r.start-1]:"",o=r.end<e.length?e[r.end]:"",s=!!(a&&!/\s/.test(a)),l=!o||!/\s/.test(o);return`${s?" ":""}${n.join(" ")}${l?" ":""}`}function xu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(o=>{const s=r(o),l=Iu(o,s),i=fu(s,zu(l),n);return n.add(i),{clientId:a(),kind:s,originalName:l,placeholder:i,file:o}})}function bu({prompt:e,attachments:r,files:n,selection:a,kindForFile:o,buildClientId:s}){const l=new Set(r.map(p=>p.placeholder)),i=xu({files:n,kindForFile:o,usedPlaceholders:l,buildClientId:s}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=gu(e,d,i.map(p=>p.placeholder)),u=`${e.slice(0,d.start)}${h}${e.slice(d.end)}`,m=h.endsWith(" ")?1:0,f=d.start+h.length-m;return{draft:{prompt:u,attachments:[...r,...i]},selection:{start:f,end:f},insertedAttachmentIds:i.map(p=>p.clientId)}}function vu({prompt:e,attachments:r,isShellView:n}){if(n)return{prompt:e};const a=e.trim();if(!a)return null;const o=r.filter(s=>a.includes(s.placeholder));return o.length>0?{prompt:a,attachments:o}:{prompt:a}}function ku({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const o=r||a(n);return!o&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:o}}function es(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function wu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function yu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:o}){const s=e==="Enter"&&(r||n);return{preventDefault:s,submit:s&&!a&&!o}}function ju({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Mr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function ts(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function Nu(e){const r=e.trim();if(!r)return null;const n=Number(r);return!Number.isFinite(n)||n<=0?Number.NaN:Math.round(n*1e3)}function Cu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Fn(e){return e.replace(/\r\n/g,`
3639
- `)}function Su(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function Tu(e){const n=Fn(e).split(`
3640
- `).map(o=>o.trim()).filter(Boolean).find(o=>/^\[mcp_servers\.[^\]]+\]$/.test(o));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function Eu(e,r){return`[mcp_servers.${e}]
3671
+ `);function gu(e){return e.replace(/\u00a0/g," ")}function xu(e,r){if(!e)return[];const n=[],a=[...r].sort((l,i)=>i.placeholder.length-l.placeholder.length);let o=0,s=0;for(;o<e.length;){const l=a.find(h=>e.startsWith(h.placeholder,o));if(l){n.push({type:"attachment",key:`${l.clientId}-${o}`,attachment:l}),o+=l.placeholder.length;continue}let i=e.length;for(const h of a){const u=e.indexOf(h.placeholder,o);u!==-1&&u<i&&(i=u)}const d=e.slice(o,i);d&&(n.push({type:"text",key:`text-${s}`,text:d}),s+=1),o=i}return n}function bu(e,r,n){const a=e==="photo"?"PHOTO":"FILE";let o=0;for(;;){const s=o===0?r:`${r} (${o+1})`,l=`[${a} ${s}]`;if(!n.has(l))return l;o+=1}}function vu(e,r,n){const a=r.start>0?e[r.start-1]:"",o=r.end<e.length?e[r.end]:"",s=!!(a&&!/\s/.test(a)),l=!o||!/\s/.test(o);return`${s?" ":""}${n.join(" ")}${l?" ":""}`}function ku({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(o=>{const s=r(o),l=Ru(o,s),i=bu(s,Mu(l),n);return n.add(i),{clientId:a(),kind:s,originalName:l,placeholder:i,file:o}})}function wu({prompt:e,attachments:r,files:n,selection:a,kindForFile:o,buildClientId:s}){const l=new Set(r.map(p=>p.placeholder)),i=ku({files:n,kindForFile:o,usedPlaceholders:l,buildClientId:s}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=vu(e,d,i.map(p=>p.placeholder)),u=`${e.slice(0,d.start)}${h}${e.slice(d.end)}`,m=h.endsWith(" ")?1:0,f=d.start+h.length-m;return{draft:{prompt:u,attachments:[...r,...i]},selection:{start:f,end:f},insertedAttachmentIds:i.map(p=>p.clientId)}}function yu({prompt:e,attachments:r,isShellView:n}){if(n)return{prompt:e};const a=e.trim();if(!a)return null;const o=r.filter(s=>a.includes(s.placeholder));return o.length>0?{prompt:a,attachments:o}:{prompt:a}}function ju({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const o=r||a(n);return!o&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:o}}function es(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Nu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function Cu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:o}){const s=e==="Enter"&&(r||n);return{preventDefault:s,submit:s&&!a&&!o}}function Su({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Mr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function ts(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function Tu(e){const r=e.trim();if(!r)return null;const n=Number(r);return!Number.isFinite(n)||n<=0?Number.NaN:Math.round(n*1e3)}function Eu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function Fn(e){return e.replace(/\r\n/g,`
3672
+ `)}function Lu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function Iu(e){const n=Fn(e).split(`
3673
+ `).map(o=>o.trim()).filter(Boolean).find(o=>/^\[mcp_servers\.[^\]]+\]$/.test(o));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function zu(e,r){return`[mcp_servers.${e}]
3641
3674
  url = ${JSON.stringify(r.trim())}
3642
3675
  `}function rs(e,r,n){var m,f;const a=Fn(e),o=`${Fn(n).trim()}
3643
3676
  `,s=a.split(`
3644
- `),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=s.length;for(let p=0;p<s.length;p+=1)if((((m=s[p])==null?void 0:m.trim())??"")===l){d=p;break}if(d>=0){for(let b=d+1;b<s.length;b+=1){const k=((f=s[b])==null?void 0:f.trim())??"";if(k.startsWith("[")&&!(k===l||k.startsWith(i))){h=b;break}}const p=s.slice(0,d).join(`
3677
+ `),l=`[mcp_servers.${r}]`,i=`[mcp_servers.${r}.`;let d=-1,h=s.length;for(let p=0;p<s.length;p+=1)if((((m=s[p])==null?void 0:m.trim())??"")===l){d=p;break}if(d>=0){for(let b=d+1;b<s.length;b+=1){const w=((f=s[b])==null?void 0:f.trim())??"";if(w.startsWith("[")&&!(w===l||w.startsWith(i))){h=b;break}}const p=s.slice(0,d).join(`
3645
3678
  `).trimEnd(),g=s.slice(h).join(`
3646
3679
  `).trim();return[p,o.trimEnd(),g].filter(Boolean).join(`
3647
3680
 
@@ -3650,28 +3683,28 @@ url = ${JSON.stringify(r.trim())}
3650
3683
  `).concat(`
3651
3684
  `)}const u=a.trimEnd();return u?`${u}
3652
3685
 
3653
- ${o}`:o}function nl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function jn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Lu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${jn(n)} used / ${jn(a)}`,`${jn(o)} left`,`${nl(r.remainingPercent)}% context left`].join(" · ")}function Iu(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function zu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Hn(e){return e.type.startsWith("image/")?"photo":"file"}function On(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ns(e,r){return On(e,r).length>0}function Pu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function as(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Pu(e.originalName)}var Xr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function Ru({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Mu({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${o?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${s?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Au(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function _u(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function $u(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Du(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Bu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Wn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Gu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Fu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Hu(e){var r;return((r=Xr.find(n=>n.value===e))==null?void 0:r.label)??e}function Ou(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function Wu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Uu(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Vu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function al(e){const r=Vu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function Ku(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function qu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=nl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Xu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Yu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Zu(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?Ku(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Ju(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function Qu(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function em(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function tm(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function sl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ss(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return sl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function rm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ss(e,n.startContainer,n.startOffset),end:ss(e,n.endContainer,n.endOffset)}}function os(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function nm(e,r){const n=os(e,r.start),a=os(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function am(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}rn();Pt();function sm({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:rt("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var om=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function lm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:rt(om({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');o==null||o.focus()},...n})}var im=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function jt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:rt(im({size:a}),e),...o})}function dm({className:e,...r}){return t.jsx("span",{className:rt("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function cm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function hm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function um({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),o=a.map(s=>{const l=Math.max(0,100-s.usedPercent);return`${s.label}: ${l}% remaining, ${hm(s.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-1 right-2 inline-flex h-5 items-center gap-1.5 rounded-full border border-stone-500/45 bg-stone-950/20 px-1.5 text-[8px] font-normal leading-none text-stone-200/90 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/70 hover:bg-stone-900/40 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 ${e.stale?"opacity-60":"opacity-90"}`,"aria-label":`${e.provider} subscription usage. ${o}`,"aria-expanded":r,onClick:()=>n(s=>!s),children:[a.map(s=>{const l=Math.max(0,Math.min(100,100-s.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{children:s.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-[3px] w-8 overflow-hidden rounded-full bg-stone-600/55 sm:w-10",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},s.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((s,l)=>t.jsxs("span",{children:[l>0?" · ":"",s.label," ",Math.round(100-s.usedPercent),"%"]},s.id)),e.stale?" · last known":""]})]})}function mm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(um,{usage:i})]})}function pm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:k,formRef:x,promptSlot:j,toolbarSlot:w,goalSlot:y,shellPromptSlot:v}){return t.jsxs("div",{className:r,children:[t.jsx(cm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(mm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:k,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(sm,{className:o,children:[j,w]}),y,v]}),s?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:s}):null]})]})}function fm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(_u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var ol=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ls(e){var r;return((r=ol.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function gm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:k,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:w,effortControlsDisabled:y,effortControlTitle:v,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:I,sendButtonBaseClassName:M,onSetOpenMenu:R,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:w||n.length===0,onClick:()=>R($=>$==="model"?null:"model"),title:k?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(qu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map($=>t.jsx("button",{type:"button",onClick:()=>Q({model:$.model,reasoningEffort:$.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.model})},$.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>R($=>$==="effort"?null:"effort"),title:v,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ts(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map($=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:$.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ts($.reasoningEffort)})},$.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ls(d)}`,disabled:m,onClick:()=>R($=>$==="sandbox"?null:"sandbox"),title:`Sandbox: ${ls(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:ol.map($=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:$.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.label})},$.mode))})})]}),h&&t.jsx(jt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${I} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(jt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${M} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function xm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function bm({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:s=>{s.stopPropagation(),o()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function vm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((s=e.data)==null?void 0:s.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function km({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:k,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:w,onSetHookEventName:y,onSetHookMatcher:v,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:I,onSaveHook:M,onStartEditingHook:R,onTrustHook:Q,onUntrustHook:$}){var Y,Z,P,te,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Y=r.data)==null?void 0:Y.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),b(),k("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Uu((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:T=>w(T.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:T=>y(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Xr.map(T=>t.jsx("option",{value:T.value,children:T.label},T.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:T=>v(T.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:T=>S(T.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:T=>N(T.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:T=>I(T.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{k("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void M(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(T=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:T},T))}):null,e==="list"&&((P=r.data)!=null&&P.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(T=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:T.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:T.path})]},`${T.path}:${T.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(T=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Hu(T.eventName),T.matcher?` · ${T.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:T.command??T.handlerType}),T.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:T.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[al(T)?t.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),R(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&T.trustStatus==="trusted"&&!T.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:re=>{re.stopPropagation(),$(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,(T.trustStatus==="untrusted"||T.trustStatus==="modified")&&!T.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!T.currentHash,onClick:re=>{re.stopPropagation(),Q(T)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:Wu(T.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Ou(T.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:T.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[T.timeoutSec,"s"]})]})]},T.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Wr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function wm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Wr(o);return a.has(s)?!1:(a.add(s),!0)})}function ym(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function jm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Nm({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=wm(e.data,r),l=e.data?Wr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Wr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:jm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[ym(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Wr(i))})})]})}function Cm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:k,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:w}){var y,v;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>k(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void w(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((y=r.data)!=null&&y.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Gu(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((v=r.data)==null?void 0:v.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Sm({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var o,s,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Fu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Wn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function Tm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,iconButtonClassName:re,menuClassName:B,menuItemClassName:J,panelButtonClassName:K,chipButtonClassName:L,onToggle:q,onToolboxItemClick:G,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:H,onViewGoals:se,onUpdateGoal:V,onOpenForkTurns:de,onForkLatest:ee,onForkTurn:be,onCopySkillInvokeName:ie,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee}){return t.jsxs("div",{className:"relative",children:[t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:q,className:`${re} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx($u,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${B} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,De)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{H("goals"),se==null||se()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:Be=>G(fe,Be),className:`${C(fe)} ${De===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Nm,{goalState:i,goalHistory:d,busy:h,onBack:()=>H("root"),onUpdateGoal:V}):r==="fork"?t.jsx(bm,{busy:a,forkBusy:o,composerMenuItemClassName:J,onForkLatest:ee,onSelectForkTurnPanel:()=>(H("forkTurns"),de())}):r==="forkTurns"?t.jsx(vm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:K,onForkTurn:be}):r==="skills"?t.jsx(Sm,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:L,onCopySkillInvokeName:ie}):r==="hooks"?t.jsx(km,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:k,hookConfigSuccess:x,editingHookTarget:j,hookScope:w,hookEventName:y,hookMatcher:v,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:I,composerChipButtonClassName:L,onResetHookForm:ye,onSetHooksPanelMode:Ae,onClearHookConfigStatus:ce,onSetEditingHookTarget:Ce,onSetHookScope:Le,onSetHookEventName:X,onSetHookMatcher:ue,onSetHookCommand:ve,onSetHookTimeoutSec:ke,onSetHookStatusMessage:$e,onSaveHook:He,onStartEditingHook:_e,onTrustHook:ze,onUntrustHook:F}):t.jsx(Cm,{mcpPanelMode:M,mcpState:R,mcpConfigEditing:Q,mcpConfigPath:$,mcpConfigError:Y,mcpConfigSuccess:Z,mcpConfigBusy:P,mcpHttpName:te,mcpHttpUrl:oe,mcpRawBlock:T,composerPanelButtonClassName:K,composerChipButtonClassName:L,onSetMcpPanelMode:le,onClearMcpConfigStatus:we,onSetMcpHttpName:z,onSetMcpHttpUrl:O,onSetMcpRawBlock:ne,onPrepareRawMcpBlock:ge,onSaveHttpMcp:Te,onSaveRawMcpBlock:Ee})})})]})}function Em({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(lm,{align:"block-end",className:`${s} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(Tm,{...i}):null,!e&&d?t.jsx(fm,{...d}):null,r&&t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Du,{}):t.jsx(Au,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(gm,{...h}):null,e&&a?t.jsx(dm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Bu,{})}),o==="shellTools"&&u?t.jsx(xm,{...u}):null]})]})]})}function Lm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Im(e){return[...e.filter(r=>Hn(r)==="photo"),...e.filter(r=>Hn(r)==="file")]}function zm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Lm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=bu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(Im(f),Hn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function is(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function Pm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){is(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{is(s)}},[]),a}var Rm=180;function Nn(e,r){return{prompt:e??"",attachments:r??[]}}function Mm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Nn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Nn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const w=Nn(r,n),y=Mr(w);y!==p.current&&(p.current=y,u.current=y,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,m]);const g=c.useCallback(w=>{if(!m||!a)return;const y=Mr(w);y!==u.current&&(u.current=y,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((w,y)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),y==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},Rm)}},[m,g]),k=c.useCallback((w=h.current)=>{b(w,"immediate")},[b]),x=c.useCallback((w,y="immediate")=>{if(m){const v=w(h.current);h.current=v,i(v),b(v,y);return}s(v=>w(v))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:k}}function Am({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function _m({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,k]=c.useState(null),x=c.useCallback(async()=>{const y=e.trim();if(!y)return k("Goal objective cannot be empty."),!1;const v=m.trim(),S=Nu(v);if(v.length>0&&(S===null||!Number.isInteger(S)||S<=0))return k("Token budget must be a positive number in thousands."),!1;if(!s)return k("/goal is unavailable in this view."),!1;g(!0),k(null);try{return o&&await o({objective:y,tokenBudget:S})===!1?!1:(await s({objective:y,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return k(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Cu(r==null?void 0:r.tokenBudget)),k(null),a==null||a(),requestAnimationFrame(()=>{var y;(y=n.current)==null||y.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),w=c.useCallback(()=>{u(!1),k(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:w}}var Cn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function $m(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Dm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Cn),[k,x]=c.useState("30"),[j,w]=c.useState("Running hook"),[y,v]=c.useState(null),[S,N]=c.useState(!1),[I,M]=c.useState(null),[R,Q]=c.useState(null),$=c.useMemo(()=>$m(r),[r]),Y=c.useCallback(J=>$.get(J)??$.get("preToolUse")??Cn,[$]),Z=c.useMemo(()=>new Set([Cn,...$.values()]),[$]),P=c.useCallback(()=>{M(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),P())},[P,e]),c.useEffect(()=>{const J=Xr.find(K=>K.value===u);p(K=>{const L=K.trim(),q=new Set(Xr.map(G=>G.matcherHint).filter(Boolean));return L&&!q.has(L)?K:(J==null?void 0:J.matcherHint)??""}),b(K=>Z.has(K.trim())?Y(u):K)},[Y,Z,u]);const te=c.useCallback(()=>{v(null),h("project"),m("preToolUse"),p("Bash"),b(Y("preToolUse")),x("30"),w("Running hook")},[Y]),oe=c.useCallback(J=>{const K=al(J);if(!K){M("Only command hooks in global or project hooks.json can be edited here.");return}v(K),h(K.scope),m(K.eventName),p(K.matcher??""),b(K.command),x(K.timeoutSec?String(K.timeoutSec):""),w(K.statusMessage??""),M(null),Q(null),i("edit")},[]),T=c.useCallback(async()=>{if(l==="edit"&&!a){M("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){M("Hook editing is unavailable in this view.");return}if(l==="edit"&&!y){M("Select a hook to edit first.");return}const J=g.trim();if(!J){M("Hook command cannot be empty.");return}const K=k.trim(),L=K?Number(K):null;if(K&&(L===null||!Number.isInteger(L)||L<=0)){M("Timeout must be a positive number of seconds.");return}N(!0),M(null),Q(null);try{const q={scope:d,eventName:u,matcher:f.trim()||null,command:J,timeoutSec:L,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...q,target:y})):await(n==null?void 0:n(q)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),v(null)}catch(q){M(q instanceof Error?q.message:"Unable to write hooks.json.")}finally{N(!1)}},[y,g,u,f,d,j,k,l,n,a]),re=c.useCallback(async J=>{if(!o||!J.currentHash){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await o({key:J.key,currentHash:J.currentHash}),Q("Hook trusted.")}catch(K){M(K instanceof Error?K.message:"Unable to trust hook.")}finally{N(!1)}},[o]),B=c.useCallback(async J=>{if(!s){M("Hook trust is unavailable in this view.");return}N(!0),M(null),Q(null);try{await s({key:J.key}),Q("Hook untrusted.")}catch(K){M(K instanceof Error?K.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:k,hookStatusMessage:j,editingHookTarget:y,hookConfigBusy:S,hookConfigError:I,hookConfigSuccess:R,setHooksPanelMode:i,setEditingHookTarget:v,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:w,clearHookConfigStatus:P,resetHookForm:te,startEditingHook:oe,saveHook:T,trustHook:re,untrustHook:B}}var Bm=`[mcp_servers.example_stdio]
3686
+ ${o}`:o}function nl(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function jn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function Pu(e,r){if(!e)return"Select model";if((r==null?void 0:r.availability)!=="available"||typeof r.tokensInContextWindow!="number"||typeof r.modelContextWindow!="number")return`${e} · context unavailable`;const n=Math.max(r.tokensInContextWindow,0),a=Math.max(r.modelContextWindow,0),o=Math.max(a-n,0);return[e,`${jn(n)} used / ${jn(a)}`,`${jn(o)} left`,`${nl(r.remainingPercent)}% context left`].join(" · ")}function Ru(e,r){const n=e.name.trim();if(n)return n;const a=r==="photo"?e.type.includes("png")?".png":e.type.includes("heic")?".heic":e.type.includes("heif")?".heif":e.type.includes("webp")?".webp":".jpg":"";return`${r==="photo"?"photo":"file"}-${Date.now()}${a}`}function Mu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Hn(e){return e.type.startsWith("image/")?"photo":"file"}function On(e,r){const n=[];if(e)for(const a of Array.from(e)){if(a.kind!=="file")continue;const o=a.getAsFile();o&&n.push(o)}return n.length>0?n:r?Array.from(r):[]}function ns(e,r){return On(e,r).length>0}function Au(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function as(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Au(e.originalName)}var Xr=[{value:"preToolUse",label:"PreToolUse",matcherHint:"Bash"},{value:"permissionRequest",label:"PermissionRequest",matcherHint:"Bash"},{value:"postToolUse",label:"PostToolUse",matcherHint:"Bash"},{value:"sessionStart",label:"SessionStart",matcherHint:"startup|resume"},{value:"userPromptSubmit",label:"UserPromptSubmit",matcherHint:""},{value:"stop",label:"Stop",matcherHint:""},{value:"preCompact",label:"PreCompact",matcherHint:""},{value:"postCompact",label:"PostCompact",matcherHint:""}];function _u({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function $u({isShellView:e,edgeToEdgeMobile:r,isMobileShell:n,openMenu:a,isDragTargetActive:o,busy:s}){const l=e?"thread-composer-layer thread-shell-composer-layer":"thread-graph-composer-layer",i=e?"thread-composer-form":"thread-graph-composer-form",d=e?"thread-composer-form-floating":"thread-graph-composer-form-floating",h=e?"thread-composer-input":"thread-graph-composer-input";return{composerLayerClassName:a?`${l} relative z-[80] shrink-0`:`${l} relative z-20 shrink-0`,formClassName:e?r||n?`${i} ${d} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} relative z-20 shrink-0 border-t border-[var(--theme-border)] bg-[var(--theme-surface)] px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`:`${i} ${r?d:""} relative z-20 shrink-0 border-t px-3 py-2 pb-[calc(env(safe-area-inset-bottom)+0.5rem)] sm:px-4 sm:py-3`,composerShellClassName:e?"thread-composer-shell":"thread-graph-composer-shell",composerToolbarClassName:e?"thread-composer-toolbar":"thread-graph-composer-toolbar",composerInputClassName:h,composerIconButtonClassName:e?"thread-composer-icon-button":"thread-graph-composer-icon-button",composerMenuClassName:e?"thread-composer-menu":"thread-graph-composer-menu",composerMenuItemClassName:e?"thread-composer-menu-item":"thread-graph-composer-menu-item",composerInlineToggleClassName:e?"thread-composer-inline-toggle":"thread-graph-composer-inline-toggle",composerPanelButtonClassName:e?"thread-composer-panel-button":"thread-graph-composer-panel-button",composerChipButtonClassName:e?"thread-composer-chip-button":"thread-graph-composer-chip-button",composerPlanToggleActiveClassName:e?"thread-composer-plan-toggle-active":"thread-graph-composer-plan-toggle-active",composerSendButtonClassName:e?"thread-composer-send-button":"thread-graph-composer-send-button",composerPromptRegionClassName:e?"thread-composer-prompt-region":"thread-graph-composer-prompt-region",promptInputClassName:`${h} min-h-[5.25rem] w-full px-4 pr-14 pt-3 outline-none transition sm:min-h-[5.75rem] ${o?"is-drag-target border-sky-300/80 bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`,graphChatInputGroupClassName:`thread-graph-composer-input-group relative border-0 bg-transparent shadow-none ring-0 ${s?"bg-amber-50/40 dark:bg-amber-400/10":"bg-transparent"}`,graphChatInputClassName:`${h} min-h-[68px] max-h-32 w-full overflow-y-auto px-3 pt-3 text-[16px] leading-relaxed text-slate-800 outline-none transition sm:min-h-[92px] sm:max-h-40 sm:px-4 sm:pt-4 sm:text-[14px] dark:text-slate-100 ${o?"is-drag-target bg-sky-300/[0.08] shadow-[0_0_0_1px_rgba(125,211,252,0.2)]":""}`}}function Du(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"m4 5 2 2-2 2"}),t.jsx("path",{d:"M7.75 9.5h4.25"})]})}function Bu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",children:t.jsx("path",{d:"M8 3.25v9.5M3.25 8h9.5"})})}function Gu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.75 2.5 5.25 13.5"}),t.jsx("path",{d:"M4.25 5.25h2.25"}),t.jsx("path",{d:"M9.5 10.75h2.25"})]})}function Fu(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3 4.5A1.75 1.75 0 0 1 4.75 2.75h6.5A1.75 1.75 0 0 1 13 4.5v4A1.75 1.75 0 0 1 11.25 10.25H8l-2.75 2v-2H4.75A1.75 1.75 0 0 1 3 8.5v-4Z"})})}function Hu(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-3.5 w-3.5 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Wn(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function Ou(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Wu(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Uu(e){var r;return((r=Xr.find(n=>n.value===e))==null?void 0:r.label)??e}function Vu(e){var r;switch(e){case"cloudRequirements":return"Cloud";case"legacyManagedConfigFile":case"legacyManagedConfigMdm":return"Managed";case"sessionFlags":return"Session";default:return((r=e[0])==null?void 0:r.toUpperCase())+e.slice(1)}}function qu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Ku(e){switch(e){case"preToolUse":return"PreToolUse";case"permissionRequest":return"PermissionRequest";case"postToolUse":return"PostToolUse";case"preCompact":return"PreCompact";case"postCompact":return"PostCompact";case"sessionStart":return"SessionStart";case"userPromptSubmit":return"UserPromptSubmit";case"stop":return"Stop"}}function Xu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function al(e){const r=Xu(e);return!r||e.handlerType!=="command"||!e.command||e.isManaged?null:{scope:r,eventName:e.eventName,matcher:e.matcher,command:e.command,timeoutSec:e.timeoutSec,statusMessage:e.statusMessage}}function Yu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Zu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=nl(e==null?void 0:e.remainingPercent);if(r!=="available")return null;const a=n<=20?"rgba(251,113,133,0.90)":n<=40?"rgba(252,211,77,0.85)":"rgba(125,211,252,0.80)";return t.jsx("span",{"aria-hidden":"true",className:"thread-context-progress-track pointer-events-none mt-0.5 block",children:t.jsx("span",{className:"thread-context-progress-fill block",style:{width:`${n}%`,backgroundColor:a}})})}function Bt({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-50":"border-stone-700/90 bg-stone-900/80 text-stone-100";return t.jsx("span",{className:`inline-flex min-w-[3rem] items-center justify-center rounded-full border px-2 py-1.5 text-[10px] font-medium tracking-[0.12em] ${n}`,children:e})}function Ju(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Qu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function em(e,{fastMode:r,compactBusy:n,goalComposeMode:a,goalStatus:o,busy:s}){switch(e.action){case"fast":return r?"On":"Off";case"compact":return n?"Busy":"Run";case"goal":return a?"Composing":o?Yu(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function tm(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function rm(e,{fastMode:r,goalComposeMode:n,goalStatus:a,menuItemClassName:o}){return`${e.action==="fast"&&r||e.action==="goal"&&(n||a==="active")?"ui-status-warning":o} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`}function nm(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function am(e){return!!e.querySelector("[style], font")}function Ft(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function sl(e){let r="";for(const n of Array.from(e.childNodes))r+=Ft(n);return r.replace(/\u00a0/g," ")}function ss(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Ft(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return sl(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Ft(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Ft(d).length}}}const s=Array.from(e.childNodes);let l=0;for(const d of s){if(d===a)return d.nodeType===Node.TEXT_NODE?l+o:l+Math.min(o,Ft(d).length);l+=Ft(d).length}return l}function sm(e){const r=window.getSelection();if(!r||r.rangeCount===0)return null;const n=r.getRangeAt(0);return!e.contains(n.startContainer)||!e.contains(n.endContainer)?null:{start:ss(e,n.startContainer,n.startOffset),end:ss(e,n.endContainer,n.endOffset)}}function os(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Ft(s).length;if(s.nodeType===Node.TEXT_NODE){if(n<=i)return{node:s,offset:n};n-=i;continue}if(s instanceof HTMLElement&&s.dataset.segmentType==="attachment"){if(n===0)return{node:e,offset:o};if(n<=i){const d=a[o+1];return n===i&&(d==null?void 0:d.nodeType)===Node.TEXT_NODE?{node:d,offset:0}:{node:e,offset:o+1}}n-=i;continue}if(n<=i)return{node:e,offset:o+1};n-=i}return{node:e,offset:e.childNodes.length}}function om(e,r){const n=os(e,r.start),a=os(e,r.end),o=document.createRange();o.setStart(n.node,n.offset),o.setEnd(a.node,a.offset);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function lm(e,r){if(r.length===0)return!1;const n=r.at(-1);if(!n)return!1;const a=Array.from(e.childNodes).find(i=>i instanceof HTMLElement&&i.dataset.segmentType==="attachment"&&i.dataset.clientId===n);if(!(a instanceof HTMLElement))return!1;const o=document.createRange(),s=a.nextSibling;(s==null?void 0:s.nodeType)===Node.TEXT_NODE?o.setStart(s,0):o.setStartAfter(a),o.collapse(!0);const l=window.getSelection();return l==null||l.removeAllRanges(),l==null||l.addRange(o),!0}rn();Pt();function im({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:at("group/input-group relative flex w-full min-w-0 items-center rounded-md border shadow-xs outline-none transition-[color,box-shadow]","h-9 has-[>textarea]:h-auto","has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col","has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col",e),...r})}var dm=Cr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium select-none [&>svg:not([class*=size-])]:size-4",{variants:{align:{"inline-start":"order-first pl-3 has-[>button]:ml-[-0.45rem]","inline-end":"order-last pr-3 has-[>button]:mr-[-0.45rem]","block-start":"order-first w-full justify-start px-3 pt-3","block-end":"order-last w-full justify-start px-3 pb-3"}},defaultVariants:{align:"inline-start"}});function cm({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:at(dm({align:r}),e),onClick:a=>{var s;if(a.target.closest("button"))return;const o=(s=a.currentTarget.parentElement)==null?void 0:s.querySelector('[data-slot="input-group-control"] [contenteditable="true"], [data-slot="input-group-control"] textarea, [data-slot="input-group-control"] input, [data-slot="input-group-control"]');o==null||o.focus()},...n})}var hm=Cr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*=size-])]:size-3.5",sm:"h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5","icon-xs":"size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function Ct({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(Nr,{type:r,"data-size":a,variant:n,className:at(hm({size:a}),e),...o})}function um({className:e,...r}){return t.jsx("span",{className:at("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function mm({photoInputRef:e,fileInputRef:r,onAppendAttachments:n}){function a(o,s){n(o.target.files,s),o.target.value=""}return t.jsxs(t.Fragment,{children:[t.jsx("input",{ref:e,type:"file",accept:"image/*",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"photo")}),t.jsx("input",{ref:r,type:"file",multiple:!0,tabIndex:-1,className:"sr-only",onChange:o=>a(o,"file")})]})}function pm(e){if(!e)return"reset time unavailable";const r=new Date(e);return Number.isNaN(r.getTime())?"reset time unavailable":`resets ${r.toLocaleString()}`}function fm({usage:e}){const[r,n]=c.useState(!1);if(!e||e.authKind!=="subscription"||e.windows.length===0)return null;const a=e.windows.slice(0,2),o=a.map(s=>{const l=Math.max(0,100-s.usedPercent);return`${s.label}: ${l}% remaining, ${pm(s.resetsAt)}`}).join(". ");return t.jsxs("button",{type:"button",className:`thread-subscription-usage group pointer-events-auto absolute bottom-0 right-2 inline-flex h-4 items-center gap-1 rounded-t-md border border-b-0 border-stone-500/50 bg-stone-950 px-1 text-[7px] font-normal leading-none text-stone-200 shadow-sm transition-[border-color,background-color,opacity] duration-200 hover:border-stone-400/75 hover:bg-stone-900 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-sky-200/70 sm:right-3 sm:text-[7px] ${e.stale?"opacity-70":"opacity-95"}`,"aria-label":`${e.provider} subscription usage. ${o}`,"aria-expanded":r,onClick:()=>n(s=>!s),children:[a.map(s=>{const l=Math.max(0,Math.min(100,100-s.usedPercent)),i=Math.round(18+l/100*190);return t.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[t.jsx("span",{className:"font-normal tracking-[-0.01em]",children:s.label}),t.jsx("span",{"data-subscription-window-track":"true",className:"h-0.5 w-7 overflow-hidden rounded-full bg-stone-600/55 sm:w-9",children:t.jsx("span",{className:"block h-full rounded-full transition-[width] duration-500 ease-out",style:{width:`${l}%`,backgroundImage:`linear-gradient(90deg, oklch(68% 0.17 ${i}), oklch(82% 0.13 ${Math.min(i+18,235)}))`}})})]},s.id)}),t.jsxs("span",{"aria-hidden":!r,className:`pointer-events-none absolute right-0 bottom-full mb-1 whitespace-nowrap rounded-md border border-stone-600/65 bg-stone-950/95 px-1.5 py-1 text-[9px] font-normal leading-none text-stone-100 shadow-lg transition-[opacity,transform] duration-200 group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100 ${r?"translate-y-0 opacity-100":"translate-y-0.5 opacity-0"}`,children:[a.map((s,l)=>t.jsxs("span",{children:[l>0?" · ":"",s.label," ",Math.round(100-s.usedPercent),"%"]},s.id)),e.stale?" · last known":""]})]})}function gm({activeView:e,followTail:r,onToggleFollow:n,canJumpToPreviousTurn:a,onJumpToPreviousTurn:o,canJumpToNextTurn:s,onJumpToNextTurn:l,subscriptionUsage:i}){return e!=="chat"?null:t.jsxs("div",{className:"pointer-events-none absolute inset-x-0 top-0 z-[90] h-11 -translate-y-full bg-transparent touch-manipulation sm:h-10",children:[t.jsxs("span",{role:"group","aria-label":"Timeline navigation",className:`thread-jump-latest-badge pointer-events-auto absolute bottom-1 left-1/2 inline-flex h-5 min-w-[7.5rem] -translate-x-1/2 overflow-hidden rounded-[0.7rem] border shadow-sm transition ${r?"is-active border-sky-300/36 bg-sky-300/[0.03] text-sky-100/86":"border-stone-500/70 bg-stone-950/[0.08] text-stone-200/86"}`,children:[t.jsx("button",{type:"button","aria-label":"Jump to previous turn",title:a?"Jump to the start of the previous turn":"No earlier turn",disabled:!a,onClick:()=>o==null?void 0:o(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 12h9M8 10V5M6 7l2-2 2 2"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest messages are in view":"Jump to the bottom",onClick:()=>n==null?void 0:n(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m4 5.5 4 4 4-4M3.5 12.5h9"})})}),t.jsx("span",{"aria-hidden":"true",className:"w-px bg-current opacity-20"}),t.jsx("button",{type:"button","aria-label":"Jump to next turn",title:s?"Jump to the start of the next turn":"No later turn",disabled:!s,onClick:()=>l==null?void 0:l(),className:"inline-flex w-10 items-center justify-center transition hover:bg-sky-300/10 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-sky-200/70 disabled:cursor-default disabled:opacity-35",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M3.5 4h9M8 6v5m-2-2 2 2 2-2"})})})]}),t.jsx(fm,{usage:i})]})}function xm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b,onSubmit:w,formRef:x,promptSlot:j,pendingQueueSlot:y,toolbarSlot:v,goalSlot:k,shellPromptSlot:S}){return t.jsxs("div",{className:r,children:[t.jsx(mm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(gm,{activeView:e,followTail:l,onToggleFollow:u,canJumpToPreviousTurn:m,onJumpToPreviousTurn:f,canJumpToNextTurn:p,onJumpToNextTurn:g,subscriptionUsage:b}),y,t.jsxs("form",{ref:x,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:w,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(im,{className:o,children:[j,v]}),k,S]}),s?t.jsx("div",{className:"mt-2 rounded-2xl border border-rose-500/40 bg-rose-500/10 px-4 py-3 text-sm text-rose-200",children:s}):null]})]})}function bm({prompts:e,onSteer:r,onCancel:n}){const[a,o]=c.useState(()=>new Set);async function s(l,i){if(!(!i||a.has(l))){o(d=>new Set(d).add(l));try{await i(l)}catch{}finally{o(d=>{const h=new Set(d);return h.delete(l),h})}}}return t.jsxs("section",{"aria-label":"Queued prompts",className:"thread-composer-pending-queue mx-auto mb-2 w-full max-w-4xl overflow-hidden rounded-xl border",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 text-[11px] font-medium text-[var(--theme-fg-muted)]",children:[t.jsx("span",{children:"Queued"}),t.jsx("span",{children:e.length})]}),t.jsx("div",{className:"max-h-36 overflow-y-auto",children:e.map(l=>{const i=a.has(l.id);return t.jsxs("div",{className:"thread-composer-pending-row flex min-h-10 items-center gap-2 border-t px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 truncate text-sm text-[var(--theme-fg)]",title:l.prompt,children:l.prompt}),l.optimistic?t.jsxs("span",{className:"inline-flex h-8 items-center gap-1.5 px-1.5 text-xs text-[var(--theme-fg-muted)]",children:[t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}),"Queueing"]}):t.jsxs(t.Fragment,{children:[r?t.jsxs("button",{type:"button",disabled:i,onClick:()=>void s(l.id,r),className:"thread-composer-steer-button inline-flex h-8 items-center gap-1.5 rounded-lg border px-2.5 text-xs font-medium transition disabled:cursor-wait disabled:opacity-60",children:[i?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):t.jsx(_.CornerUpRight,{className:"h-3.5 w-3.5","aria-hidden":"true"}),"Steer"]}):null,n?t.jsx("button",{type:"button",disabled:i,"aria-label":"Remove queued prompt",title:"Remove from queue",onClick:()=>void s(l.id,n),className:"thread-composer-queue-remove inline-flex h-8 w-8 items-center justify-center rounded-lg transition disabled:cursor-wait disabled:opacity-60",children:t.jsx(_.X,{className:"h-4 w-4","aria-hidden":"true"})}):null]})]},l.id)})})]})}function vm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Add attachment",title:"Add attachment",onClick:o,className:`${r} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Bu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var ol=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function ls(e){var r;return((r=ol.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function km({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:b,fastMode:w,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:v,effortControlTitle:k,inlineToggleClassName:S,menuItemClassName:N,planToggleActiveClassName:L,sendButtonBaseClassName:R,onSetOpenMenu:P,onUpdateSettings:Q}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>P(D=>D==="model"?null:"model"),title:w?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${S} relative min-w-0 max-w-[8.75rem] overflow-hidden rounded-full px-2.5 text-left text-stone-300 disabled:cursor-not-allowed disabled:text-stone-600 sm:max-w-[11rem]`,children:t.jsx("span",{className:"relative z-[1] block min-w-0 truncate whitespace-nowrap [direction:rtl]",children:r??"Select model"})}),r?t.jsx(Zu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({model:D.model,reasoningEffort:D.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.model})},D.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:v,onClick:()=>P(D=>D==="effort"?null:"effort"),title:k,className:`${S} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${v?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:ts(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({reasoningEffort:D.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:ts(D.reasoningEffort)})},D.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${ls(d)}`,disabled:m,onClick:()=>P(D=>D==="sandbox"?null:"sandbox"),title:`Sandbox: ${ls(d)}`,className:`${S} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:ol.map(D=>t.jsx("button",{type:"button",onClick:()=>Q({sandboxMode:D.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${D.mode===d?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:D.label})},D.mode))})})]}),h&&t.jsx(Ct,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>Q({collaborationMode:i==="plan"?"default":"plan"}),className:`${S} rounded-full px-2.5 ${i==="plan"?`${L} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(Ct,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?b:!1),className:`${R} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function wm({busy:e,shellControlState:r,onPaste:n,onCopy:a,onClear:o,onShellControl:s}){const l=!!(r!=null&&r.shellInputEnabled),i=!!(r!=null&&r.isCommandRunning);return t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute right-0 top-full z-40 mt-2 w-[11.5rem] max-w-[calc(100vw-1.5rem)] rounded-[1rem] border border-stone-700/90 bg-stone-950/96 p-2 shadow-2xl shadow-stone-950/40 sm:w-48",onMouseDown:d=>{d.stopPropagation()},onPointerDown:d=>{d.stopPropagation()},onTouchStart:d=>{d.stopPropagation()},children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2 py-2 text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:a,className:"inline-flex items-center justify-center rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-2 text-stone-100",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(Wn,{}),t.jsx("span",{className:"text-[10px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:e,onClick:o,className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!l||!i,onClick:()=>s("ctrl_c"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-C",tone:"rose"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("ctrl_d"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Bt,{label:"DOWN"})})]})})}function ym({busy:e,forkBusy:r,composerMenuItemClassName:n,onForkLatest:a,onSelectForkTurnPanel:o}){return t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",disabled:e||r,onClick:()=>void a(),className:`${n} block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from latest"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:r?"Forking":"Run"})]})}),t.jsx("button",{type:"button",disabled:e||r,onClick:s=>{s.stopPropagation(),o()},className:`${n} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:"Fork from selected turn"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:"Pick"})]})}),e?t.jsx("p",{className:"mt-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Fork is only available while the thread is idle."}):null]})}function jm({forkTurnOptionsState:e,forkBusy:r,composerPanelButtonClassName:n,onForkTurn:a}){var o,s;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading turns..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.length?t.jsx("div",{className:"space-y-2",children:e.data.map(l=>t.jsx("button",{type:"button",disabled:r,onClick:()=>void a(l.turnId),className:`${n} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition disabled:cursor-not-allowed disabled:opacity-60`,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("span",{className:"text-sm text-stone-100",children:["Turn ",l.turnIndex]}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:r?"Forking":l.status})]})},l.turnId))}):null,e.status!=="loading"&&!e.error&&(((s=e.data)==null?void 0:s.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No turns available to fork yet."}):null]})}function Nm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:b,onSetHooksPanelMode:w,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:v,onSetHookMatcher:k,onSetHookCommand:S,onSetHookTimeoutSec:N,onSetHookStatusMessage:L,onSaveHook:R,onStartEditingHook:P,onTrustHook:Q,onUntrustHook:D}){var Z,J,z,te,se;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Z=r.data)==null?void 0:Z.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),b(),w("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Ku((i==null?void 0:i.eventName)??h)," ","in ",(i==null?void 0:i.scope)==="global"?"global":"project"," ","hooks.json"]}):null,t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Scope",t.jsxs("select",{"aria-label":"Hook scope",value:d,onChange:$=>y($.target.value),disabled:e==="edit",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:[t.jsx("option",{value:"project",children:"Project"}),t.jsx("option",{value:"global",children:"Global"})]})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Event",t.jsx("select",{"aria-label":"Hook event",value:h,onChange:$=>v($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-2.5 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50",children:Xr.map($=>t.jsx("option",{value:$.value,children:$.label},$.value))})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Matcher"}),t.jsx("input",{"aria-label":"Hook matcher",value:u,onChange:$=>k($.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:$=>S($.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:$=>N($.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:$=>L($.target.value),className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>{w("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void R(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((J=r.data)!=null&&J.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map($=>t.jsx("p",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:$},$))}):null,e==="list"&&((z=r.data)!=null&&z.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map($=>t.jsxs("div",{className:"rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-2 text-xs text-rose-100/90",children:[t.jsx("p",{className:"font-medium",children:$.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:$.path})]},`${$.path}:${$.message}`))}):null,e==="list"&&((te=r.data)!=null&&te.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map($=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("p",{className:"truncate text-sm font-medium text-stone-100",children:[Uu($.eventName),$.matcher?` · ${$.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:$.command??$.handlerType}),$.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:$.statusMessage}):null]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.08em] text-stone-500",children:[al($)?t.jsx("button",{type:"button",onClick:le=>{le.stopPropagation(),P($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-sky-100 transition hover:border-sky-300/35 hover:bg-sky-300/10`,children:"Edit"}):null,a&&$.trustStatus==="trusted"&&!$.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:le=>{le.stopPropagation(),D($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-amber-100 transition hover:border-amber-300/35 hover:bg-amber-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Untrust"}):null,($.trustStatus==="untrusted"||$.trustStatus==="modified")&&!$.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!$.currentHash,onClick:le=>{le.stopPropagation(),Q($)},className:`${g} rounded-full border border-stone-700 px-2 py-0.5 text-[10px] normal-case tracking-normal text-emerald-100 transition hover:border-emerald-300/35 hover:bg-emerald-300/10 disabled:cursor-not-allowed disabled:opacity-50`,children:"Trust"}):null,t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-0.5 text-stone-300",children:qu($.trustStatus)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em] text-stone-500",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:Vu($.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:$.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[$.timeoutSec,"s"]})]})]},$.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((se=r.data)==null?void 0:se.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function Wr(e){return e.localGoalId??`${e.createdAt}:${e.objective}`}function Cm(e,r){const n=e?[e,...r]:r,a=new Set;return n.filter(o=>{const s=Wr(o);return a.has(s)?!1:(a.add(s),!0)})}function Sm(e){if(e<60)return`${e}s`;const r=Math.floor(e/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`}function Tm(e){switch(e){case"budgetLimited":return"Budget limited";case"complete":return"Complete";case"terminated":return"Terminated";case"paused":return"Paused";default:return"Active"}}function Em({goalState:e,goalHistory:r,busy:n,onBack:a,onUpdateGoal:o}){const s=Cm(e.data,r),l=e.data?Wr(e.data):null;return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 py-2",children:[t.jsx("button",{type:"button",onClick:a,className:"min-h-9 rounded-lg px-2 text-xs font-medium text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--theme-accent-border)]",children:"Back"}),t.jsx("span",{className:"text-xs font-semibold text-[var(--theme-fg)]",children:"Goals"})]}),e.error?t.jsx("p",{className:"m-3 rounded-lg border border-[var(--status-danger-border)] bg-[var(--status-danger-bg)] px-3 py-2 text-xs text-[var(--status-danger-fg)]",children:e.error}):null,e.status==="loading"&&s.length===0?t.jsxs("div",{className:"space-y-2 p-3",role:"status","aria-label":"Loading goals",children:[t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"}),t.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-[var(--theme-muted)] motion-reduce:animate-none"})]}):s.length===0?t.jsx("p",{className:"px-4 py-5 text-center text-sm text-[var(--theme-fg-muted)]",children:"No goals in this thread yet."}):t.jsx("div",{className:"max-h-72 divide-y divide-[var(--theme-border)] overflow-y-auto",children:s.map(i=>{const d=Wr(i)===l&&["active","paused","budgetLimited"].includes(i.status);return t.jsxs("div",{className:"px-3 py-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("p",{className:"min-w-0 flex-1 text-sm font-medium leading-5 text-[var(--theme-fg)]",children:i.objective}),t.jsx("span",{className:"shrink-0 rounded-full border border-[var(--theme-border)] px-2 py-1 text-[10px] font-medium text-[var(--theme-fg-muted)]",children:Tm(i.status)})]}),t.jsxs("p",{className:"mt-1.5 text-[11px] text-[var(--theme-fg-muted)]",children:[Sm(i.timeUsedSeconds)," · ",i.tokensUsed.toLocaleString()," tokens"]}),d&&o?t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsx("button",{type:"button",disabled:n||i.status==="active",onClick:()=>void o({status:"active"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Continue"}),t.jsx("button",{type:"button",disabled:n||i.status==="paused",onClick:()=>void o({status:"paused"}),className:"min-h-9 rounded-lg border border-[var(--theme-border)] px-3 text-xs font-medium text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] disabled:cursor-not-allowed disabled:opacity-45",children:"Pause"}),t.jsx("button",{type:"button",disabled:n,onClick:()=>void o({status:"terminated"}),className:"min-h-9 rounded-lg px-3 text-xs font-medium text-[var(--status-danger-fg)] transition hover:bg-[var(--status-danger-bg)] disabled:cursor-not-allowed disabled:opacity-45",children:"Terminate"})]}):null]},Wr(i))})})]})}function Lm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:b,onSetMcpRawBlock:w,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var v,k;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:S=>{S.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:S=>g(S.target.value),placeholder:"openaiDeveloperDocs",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"URL"}),t.jsx("input",{"aria-label":"URL",value:d,onChange:S=>b(S.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:S=>w(S.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((v=r.data)!=null&&v.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(S=>t.jsxs("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:S.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[S.tools.length," tools · ",S.resourceCount," ","resources · ",S.resourceTemplateCount," templates"]})]}),t.jsx("span",{className:"shrink-0 rounded-full border border-stone-700 px-2 py-1 text-[10px] uppercase tracking-[0.14em] text-stone-300",children:Ou(S.authStatus)})]}),S.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:S.tools.slice(0,4).map(N=>N.title??N.name).join(" · ")}):null]},S.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function Im({skillsState:e,copiedSkillName:r,composerChipButtonClassName:n,onCopySkillInvokeName:a}){var o,s,l,i;return t.jsxs("div",{className:"p-2",children:[e.status==="loading"&&!e.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading skills..."}):null,e.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:e.error}):null,(o=e.data)!=null&&o.skills.length?t.jsx("div",{className:"space-y-2",children:e.data.skills.map(d=>{var h,u;return t.jsx("div",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-2.5",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:((h=d.interface)==null?void 0:h.displayName)??d.name}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-[0.14em]",children:[t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1 text-stone-400",children:Wu(d.scope)}),t.jsxs("button",{type:"button",className:`inline-flex items-center gap-1 rounded-full border px-2 py-1 normal-case tracking-normal transition ${r===d.name?"border-emerald-400/45 bg-emerald-400/12 text-emerald-100":`${n} border-stone-700 text-stone-300 hover:border-stone-500`}`,onClick:()=>void a(d.name),title:`Copy $${d.name}`,"aria-label":`Copy $${d.name}`,children:[t.jsx(Wn,{}),"$",d.name]})]}),t.jsx("p",{className:"text-xs leading-5 text-stone-400",children:((u=d.interface)==null?void 0:u.shortDescription)??d.shortDescription??d.description})]})},d.path)})}):null,(s=e.data)!=null&&s.errors.length?t.jsx("div",{className:"mt-2 space-y-2",children:e.data.errors.map(d=>t.jsxs("div",{className:"rounded-xl border border-amber-500/25 bg-amber-500/10 px-3 py-2 text-xs text-amber-100/85",children:[t.jsx("p",{className:"font-medium",children:d.message}),t.jsx("p",{className:"mt-1 break-all text-amber-100/60",children:d.path})]},`${d.path}:${d.message}`))}):null,e.status!=="loading"&&!e.error&&(((l=e.data)==null?void 0:l.skills.length)??0)===0&&(((i=e.data)==null?void 0:i.errors.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No skills available right now."}):null]})}function zm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,goalState:i,goalHistory:d,goalBusy:h,copiedSkillName:u,hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:v,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:$,iconButtonClassName:le,menuClassName:q,menuItemClassName:H,panelButtonClassName:G,chipButtonClassName:T,onToggle:F,onToolboxItemClick:B,toolboxItemDisabled:E,toolboxItemClassName:C,toolboxItemStatus:W,onSetSlashPanelView:U,onViewGoals:ne,onUpdateGoal:K,onOpenForkTurns:ie,onForkLatest:ee,onForkTurn:ve,onCopySkillInvokeName:oe,onResetHookForm:ye,onSetHooksPanelMode:Me,onClearHookConfigStatus:de,onSetEditingHookTarget:Ce,onSetHookScope:Ee,onSetHookEventName:Y,onSetHookMatcher:ue,onSetHookCommand:ke,onSetHookTimeoutSec:we,onSetHookStatusMessage:De,onSaveHook:Fe,onStartEditingHook:Ae,onTrustHook:Oe,onUntrustHook:V,onSetMcpPanelMode:ce,onClearMcpConfigStatus:xe,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:ae,onPrepareRawMcpBlock:be,onSaveHttpMcp:je,onSaveRawMcpBlock:Te}){return t.jsxs("div",{className:"relative",children:[t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:F,className:`${le} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Gu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${q} absolute bottom-full left-0 z-40 mb-2 w-72 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20 backdrop-blur-xl`,onClick:fe=>{fe.stopPropagation()},onMouseDown:fe=>{fe.stopPropagation()},onPointerDown:fe=>{fe.stopPropagation()},onTouchStart:fe=>{fe.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((fe,Be)=>fe.action==="goal"?t.jsxs("div",{className:`mt-1 flex min-h-11 overflow-hidden rounded-xl border border-[var(--theme-border)] ${Be===0?"mt-0":""}`,title:fe.description??fe.label,children:[t.jsx("button",{type:"button",disabled:E(fe),onClick:()=>{U("goals"),ne==null||ne()},className:"min-w-0 flex-1 px-3 py-2.5 text-left text-sm text-[var(--theme-fg)] transition hover:bg-[var(--theme-hover)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"View goals",children:t.jsx("span",{children:fe.command})}),t.jsx("button",{type:"button",disabled:E(fe),onClick:_e=>B(fe,_e),className:"min-w-14 border-l border-[var(--theme-border)] px-3 text-xs font-semibold text-[var(--theme-fg-muted)] transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)] focus-visible:z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--theme-accent-border)] disabled:cursor-not-allowed disabled:opacity-45","aria-label":"Open goal composer",children:"Open"})]},`${fe.action}:${fe.command}`):t.jsx("button",{type:"button",disabled:E(fe),onClick:_e=>B(fe,_e),className:`${C(fe)} ${Be===0?"mt-0":""}`,title:fe.description??fe.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:fe.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:W(fe)})]})},`${fe.action}:${fe.command}`)),n.length===0?t.jsx("p",{className:"px-3 py-2 text-sm text-stone-400",children:"No backend tools are available for this thread."}):null]}):t.jsx("div",{className:"max-h-80 overflow-auto",children:r==="goals"?t.jsx(Em,{goalState:i,goalHistory:d,busy:h,onBack:()=>U("root"),onUpdateGoal:K}):r==="fork"?t.jsx(ym,{busy:a,forkBusy:o,composerMenuItemClassName:H,onForkLatest:ee,onSelectForkTurnPanel:()=>(U("forkTurns"),ie())}):r==="forkTurns"?t.jsx(jm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:G,onForkTurn:ve}):r==="skills"?t.jsx(Im,{skillsState:l,copiedSkillName:u,composerChipButtonClassName:T,onCopySkillInvokeName:oe}):r==="hooks"?t.jsx(Nm,{hooksPanelMode:m,hooksState:f,hostConfigFilesAvailable:p,hookTrustAvailable:g,hookConfigBusy:b,hookConfigError:w,hookConfigSuccess:x,editingHookTarget:j,hookScope:y,hookEventName:v,hookMatcher:k,hookCommand:S,hookTimeoutSec:N,hookStatusMessage:L,composerChipButtonClassName:T,onResetHookForm:ye,onSetHooksPanelMode:Me,onClearHookConfigStatus:de,onSetEditingHookTarget:Ce,onSetHookScope:Ee,onSetHookEventName:Y,onSetHookMatcher:ue,onSetHookCommand:ke,onSetHookTimeoutSec:we,onSetHookStatusMessage:De,onSaveHook:Fe,onStartEditingHook:Ae,onTrustHook:Oe,onUntrustHook:V}):t.jsx(Lm,{mcpPanelMode:R,mcpState:P,mcpConfigEditing:Q,mcpConfigPath:D,mcpConfigError:Z,mcpConfigSuccess:J,mcpConfigBusy:z,mcpHttpName:te,mcpHttpUrl:se,mcpRawBlock:$,composerPanelButtonClassName:G,composerChipButtonClassName:T,onSetMcpPanelMode:ce,onClearMcpConfigStatus:xe,onSetMcpHttpName:I,onSetMcpHttpUrl:O,onSetMcpRawBlock:ae,onPrepareRawMcpBlock:be,onSaveHttpMcp:je,onSaveRawMcpBlock:Te})})})]})}function Pm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(cm,{align:"block-end",className:`${s} relative z-30 mb-0 flex items-center gap-2 text-xs`,children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[!e&&i?t.jsx(zm,{...i}):null,!e&&d?t.jsx(vm,{...d}):null,r&&t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Fu,{}):t.jsx(Du,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(km,{...h}):null,e&&a?t.jsx(um,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(Hu,{})}),o==="shellTools"&&u?t.jsx(wm,{...u}):null]})]})]})}function Rm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function Mm(e){return[...e.filter(r=>Hn(r)==="photo"),...e.filter(r=>Hn(r)==="file")]}function Am({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=Rm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=wu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(Mm(f),Hn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function is(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function _m({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){is(s),o({});return}const l={},i=new Set;for(const d of e){if(d.kind!=="photo")continue;i.add(d.clientId);let h=s.get(d.clientId);h||(h=URL.createObjectURL(d.file),s.set(d.clientId,h)),l[d.clientId]=h}for(const[d,h]of s.entries())i.has(d)||(URL.revokeObjectURL(h),s.delete(d));o(l)},[e,r]),c.useEffect(()=>{const s=n.current;return()=>{is(s)}},[]),a}var $m=180;function Nn(e,r){return{prompt:e??"",attachments:r??[]}}function Dm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>Nn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Mr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Mr(Nn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=Nn(r,n),v=Mr(y);v!==p.current&&(p.current=v,u.current=v,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const v=Mr(y);v!==u.current&&(u.current=v,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const b=c.useCallback((y,v)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),v==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},$m)}},[m,g]),w=c.useCallback((y=h.current)=>{b(y,"immediate")},[b]),x=c.useCallback((y,v="immediate")=>{if(m){const k=y(h.current);h.current=k,i(k),b(k,v);return}s(k=>y(k))},[m,b]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:w}}function Bm({slashPanelView:e,onForkLatest:r,onForkTurn:n,closeMenu:a}){const[o,s]=c.useState(!1);c.useEffect(()=>{e!=="forkTurns"&&s(!1)},[e]);const l=c.useCallback(async()=>{if(r){s(!0);try{await r(),a()}finally{s(!1)}}},[a,r]),i=c.useCallback(async d=>{if(n){s(!0);try{await n(d),a()}finally{s(!1)}}},[a,n]);return{forkBusy:o,forkLatest:l,forkTurn:i}}function Gm({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[b,w]=c.useState(null),x=c.useCallback(async()=>{const v=e.trim();if(!v)return w("Goal objective cannot be empty."),!1;const k=m.trim(),S=Tu(k);if(k.length>0&&(S===null||!Number.isInteger(S)||S<=0))return w("Token budget must be a positive number in thousands."),!1;if(!s)return w("/goal is unavailable in this view."),!1;g(!0),w(null);try{return o&&await o({objective:v,tokenBudget:S})===!1?!1:(await s({objective:v,status:"active",tokenBudget:S}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(N){return w(N instanceof Error?N.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(Eu(r==null?void 0:r.tokenBudget)),w(null),a==null||a(),requestAnimationFrame(()=>{var v;(v=n.current)==null||v.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),w(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:b,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var Cn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Fm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Hm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,b]=c.useState(Cn),[w,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[v,k]=c.useState(null),[S,N]=c.useState(!1),[L,R]=c.useState(null),[P,Q]=c.useState(null),D=c.useMemo(()=>Fm(r),[r]),Z=c.useCallback(H=>D.get(H)??D.get("preToolUse")??Cn,[D]),J=c.useMemo(()=>new Set([Cn,...D.values()]),[D]),z=c.useCallback(()=>{R(null),Q(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),z())},[z,e]),c.useEffect(()=>{const H=Xr.find(G=>G.value===u);p(G=>{const T=G.trim(),F=new Set(Xr.map(B=>B.matcherHint).filter(Boolean));return T&&!F.has(T)?G:(H==null?void 0:H.matcherHint)??""}),b(G=>J.has(G.trim())?Z(u):G)},[Z,J,u]);const te=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),b(Z("preToolUse")),x("30"),y("Running hook")},[Z]),se=c.useCallback(H=>{const G=al(H);if(!G){R("Only command hooks in global or project hooks.json can be edited here.");return}k(G),h(G.scope),m(G.eventName),p(G.matcher??""),b(G.command),x(G.timeoutSec?String(G.timeoutSec):""),y(G.statusMessage??""),R(null),Q(null),i("edit")},[]),$=c.useCallback(async()=>{if(l==="edit"&&!a){R("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){R("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){R("Select a hook to edit first.");return}const H=g.trim();if(!H){R("Hook command cannot be empty.");return}const G=w.trim(),T=G?Number(G):null;if(G&&(T===null||!Number.isInteger(T)||T<=0)){R("Timeout must be a positive number of seconds.");return}N(!0),R(null),Q(null);try{const F={scope:d,eventName:u,matcher:f.trim()||null,command:H,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...F,target:v})):await(n==null?void 0:n(F)),Q(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(F){R(F instanceof Error?F.message:"Unable to write hooks.json.")}finally{N(!1)}},[v,g,u,f,d,j,w,l,n,a]),le=c.useCallback(async H=>{if(!o||!H.currentHash){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await o({key:H.key,currentHash:H.currentHash}),Q("Hook trusted.")}catch(G){R(G instanceof Error?G.message:"Unable to trust hook.")}finally{N(!1)}},[o]),q=c.useCallback(async H=>{if(!s){R("Hook trust is unavailable in this view.");return}N(!0),R(null),Q(null);try{await s({key:H.key}),Q("Hook untrusted.")}catch(G){R(G instanceof Error?G.message:"Unable to untrust hook.")}finally{N(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:w,hookStatusMessage:j,editingHookTarget:v,hookConfigBusy:S,hookConfigError:L,hookConfigSuccess:P,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:b,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:z,resetHookForm:te,startEditingHook:se,saveHook:$,trustHook:le,untrustHook:q}}var Om=`[mcp_servers.example_stdio]
3654
3687
  command = "npx"
3655
3688
  args = ["-y", "your-mcp-server"]
3656
- `,ds="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Gm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,k]=c.useState(null),[x,j]=c.useState(null),w=c.useCallback(()=>{k(null),j(null)},[]),y=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const M=await r();return f(M.path),M},[e,r]),v=c.useCallback(async M=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const R=await n(M);return f(R.path),R},[e,n]),S=c.useCallback(async()=>{const M=Su(s),R=i.trim();if(!M){k("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(R)){k("HTTP MCP URL must start with http:// or https://");return}g(!0),k(null),j(null);try{const Q=await y(),$=rs(Q.content,M,Eu(M,R));await v($),j(ds),a("list"),l(""),d(""),o==null||o()}catch(Q){k(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[y,s,i,o,a,v]),N=c.useCallback(async()=>{g(!0),k(null),j(null);try{await y(),u(M=>M||Bm),a("stdio")}catch(M){k(M instanceof Error?M.message:"Unable to load provider config.")}finally{g(!1)}},[y,a]),I=c.useCallback(async()=>{const M=Tu(h);if(!M){k("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),k(null),j(null);try{const R=await y(),Q=rs(R.content,M,h);await v(Q),j(ds),a("list"),o==null||o()}catch(R){k(R instanceof Error?R.message:"Unable to update provider config.")}finally{g(!1)}},[y,h,o,a,v]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:w,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:I}}function Fm({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Hm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=as(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const o=document.createElement("span");o.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",o.textContent="FILE";const s=document.createElement("span");return s.className="inline-flex max-w-[10rem] truncate",s.textContent=as(n),a.append(o,s),a}function Om(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(Hm(a,r))}return n}function Wm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,k=f()!==n||u.current!==s||m.current!==l;k&&(g.replaceChildren(Om(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),am(g,d.current)||p(b),h.current=b):document.activeElement===g&&k&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Um({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:o=>n(o.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Vm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:k,onDragLeave:x,onDrop:j}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:b,onDragOver:k,onDragLeave:x,onDrop:j,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(jt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:w=>{w.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Km({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function qm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:k,onInterrupt:x,onPromptInput:j,onPromptPaste:w,onPromptKeyDown:y,onPromptKeyUp:v,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:I,onPromptDragOver:M,onPromptDragLeave:R,onPromptDrop:Q,onGoalTokenBudgetChange:$,onCancelGoal:Y,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Vm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:w,onKeyDown:y,onKeyUp:v,onMouseUp:S,onBlur:N,onDragEnter:I,onDragOver:M,onDragLeave:R,onDrop:Q}),goalSlot:u&&!e?t.jsx(Um,{tokenBudget:m,error:f,onTokenBudgetChange:$,onCancel:Y}):null,shellPromptSlot:e?t.jsx(Km,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:k,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:y,onInterrupt:x}):null}}function Xm({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,o]=c.useState(null),s=a??e;c.useEffect(()=>{o(null)},[e]);const l=c.useCallback(async i=>{const d=ju({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&o(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&o(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:s,updateSettings:l}}function Ym({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:k,settingsBusy:x,compactBusy:j,forkBusy:w,fastMode:y,goalComposeMode:v,goalBusy:S,goalStatus:N,activeView:I,disabled:M,model:R,modelOptions:Q,modelContextTitle:$,contextUsage:Y,reasoningEffort:Z,supportedEfforts:P,displayedCollaborationMode:te,sandboxMode:oe,sendButtonLabel:T,sendButtonClassName:re,modelControlsDisabled:B,effortControlsDisabled:J,effortControlTitle:K,forkTurnOptionsState:L,skillsState:q,goalState:G,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:H,hookConfigBusy:se,hookConfigError:V,hookConfigSuccess:de,editingHookTarget:ee,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:$e,mcpHttpName:He,mcpHttpUrl:_e,mcpRawBlock:ze,capabilities:F,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O,onToolboxItemClick:ne,onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:A,onSetHookTimeoutSec:U,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct,onPickPhoto:_,onPickFile:pe,onUpdateSettings:Re,onPasteShell:Ge,onCopyShell:Ue,onClearShell:ct,onShellControl:kt}){const qt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:k,forkBusy:w,forkTurnOptionsState:L,skillsState:q,goalState:G,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:H,hostConfigFilesAvailable:F.hostConfigFiles,hookTrustAvailable:F.hookTrust,hookConfigBusy:se,hookConfigError:V,hookConfigSuccess:de,editingHookTarget:ee,hookScope:be,hookEventName:ie,hookMatcher:ye,hookCommand:Ae,hookTimeoutSec:ce,hookStatusMessage:Ce,mcpPanelMode:Le,mcpState:X,mcpConfigEditing:F.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ve,mcpConfigSuccess:ke,mcpConfigBusy:$e,mcpHttpName:He,mcpHttpUrl:_e,mcpRawBlock:ze,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(at=>at==="slash"?null:"slash"),onToolboxItemClick:ne,toolboxItemDisabled:at=>Ju(at,{settingsBusy:x,compactBusy:j,busy:k,forkBusy:w}),toolboxItemClassName:at=>Qu(at,{fastMode:y,goalComposeMode:v,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:at=>Zu(at,{fastMode:y,compactBusy:j,goalComposeMode:v,goalStatus:N,busy:k}),onSetSlashPanelView:ge,onViewGoals:Te,onUpdateGoal:Ee,onOpenForkTurns:fe,onForkLatest:De,onForkTurn:Be,onCopySkillInvokeName:et,onResetHookForm:Ve,onSetHooksPanelMode:pt,onClearHookConfigStatus:nt,onSetEditingHookTarget:We,onSetHookScope:ot,onSetHookEventName:ht,onSetHookMatcher:ut,onSetHookCommand:A,onSetHookTimeoutSec:U,onSetHookStatusMessage:xe,onSaveHook:je,onStartEditingHook:Ne,onTrustHook:Ye,onUntrustHook:tt,onSetMcpPanelMode:Fe,onClearMcpConfigStatus:Ke,onSetMcpHttpName:lt,onSetMcpHttpUrl:vt,onSetMcpRawBlock:it,onPrepareRawMcpBlock:Nt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:Ct},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(at=>at==="attachments"?null:"attachments"),onPickPhoto:_,onPickFile:pe},Mt=e?null:{openMenu:o,model:R,modelOptions:Q,modelContextTitle:$,contextUsage:Y,reasoningEffort:Z,supportedEfforts:P,displayedCollaborationMode:te,sandboxMode:oe,planModeAvailable:F.planMode,sandboxModeAvailable:F.sandboxMode,settingsBusy:x,goalComposeMode:v,goalBusy:S,activeView:I,disabled:M,fastMode:y,sendButtonLabel:T,sendButtonClassName:re,modelControlsDisabled:B,effortControlsDisabled:J,effortControlTitle:K,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:Re};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:qt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:k,shellControlState:le,onPaste:Ge,onCopy:Ue,onClear:ct,onShellControl:kt}:null,shellControlState:le,onToggleView:we,onDismissPromptFocus:z,onSetOpenMenu:O}}function Un({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:k=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:w=!0,shellAvailable:y=!0,disabled:v=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:I,draftAttachments:M,onPickAttachment:R,skillsState:Q={status:"idle",data:null,error:null},mcpState:$={status:"idle",data:null,error:null},hooksState:Y={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},goalHistory:P=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:oe,onSubmit:T,onInterrupt:re,onCompact:B,onOpenSkills:J,onOpenMcp:K,onOpenHooks:L,onCreateHook:q,onUpdateHook:G,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:H,onUpdateGoal:se,onOpenForkTurns:V,onForkLatest:de,onForkTurn:ee,onReadProviderConfig:be,onWriteProviderConfig:ie,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onUpdateSettings:ue,onToggleView:ve,onShellCopy:ke,onShellControl:$e,canInterrupt:He=!1}){var ja;const[_e,ze]=c.useState(null),[F,le]=c.useState("root"),we=c.useRef(!1),[z,O]=c.useState("list"),ne=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!be&&!!ie,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,be,ie]),ge=c.useMemo(()=>Xu(b,ne),[ne,b]),Te=c.useRef(null),Ee=c.useRef(null),fe=c.useRef(null),De=c.useRef(null),Be=c.useRef(null),et=c.useRef([]),Ve=c.useRef(null),pt=c.useRef(""),nt=c.useRef(0),We=e==="shell",ot=y||We,ht=!!(We&&(N!=null&&N.isMobileShell)),ut=(N==null?void 0:N.promptLabel)??null,[A,U]=c.useState(!1),[xe,je]=c.useState(0),{prompt:Ne,attachments:Ye,isDraftControlled:tt,updateDraft:Fe,flushControlledDraftToHost:Ke}=Mm({isShellView:We,draftPrompt:I,draftAttachments:M,onDraftChange:oe}),lt=Pm({attachments:Ye,isShellView:We}),{displayedCollaborationMode:vt,updateSettings:it}=Xm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>ze(null)}),{forkBusy:Nt,forkLatest:Rt,forkTurn:Ct}=Am({slashPanelView:F,onForkLatest:de,onForkTurn:ee,closeMenu:()=>ze(null)}),{hooksPanelMode:_,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,editingHookTarget:qt,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,setHooksPanelMode:at,setEditingHookTarget:dn,setHookScope:cn,setHookEventName:Il,setHookMatcher:zl,setHookCommand:Pl,setHookTimeoutSec:Rl,setHookStatusMessage:Ml,clearHookConfigStatus:pa,resetHookForm:Al,startEditingHook:_l,saveHook:$l,trustHook:Dl,untrustHook:Bl}=Dm({slashPanelView:F,hookCommandTemplates:k,onCreateHook:q,onUpdateHook:G,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Gl,goalBusy:hn,goalLocalError:Fl,setGoalTokenBudget:Hl,submitGoal:Ol,enterGoalComposeMode:Wl,exitGoalComposeMode:fa}=_m({prompt:Ne,goalTokenBudgetSource:Z.data,promptRef:Ee,onOpenGoal:W,onPrepareGoalSubmit:H,onUpdateGoal:se,updateDraft:Fe,closeMenu:()=>ze(null),resetSlashPanel:()=>le("root")}),{mcpHttpName:Ul,mcpHttpUrl:Vl,mcpRawBlock:Kl,mcpConfigPath:ql,mcpConfigBusy:Xl,mcpConfigError:Yl,mcpConfigSuccess:Zl,setMcpHttpName:Jl,setMcpHttpUrl:Ql,setMcpRawBlock:ei,clearMcpConfigStatus:ga,prepareRawMcpBlock:ti,saveHttpMcp:ri,saveRawMcpBlock:ni}=Gm({hostConfigFilesAvailable:ne.hostConfigFiles,onReadProviderConfig:be,onWriteProviderConfig:ie,setMcpPanelMode:O,onOpenMcp:K}),{copiedSkillName:ai,copySkillInvokeName:si}=Fm({openMenu:_e,setOpenMenu:ze,slashPanelView:F,setSlashPanelView:le,setMcpPanelMode:O,clearMcpConfigStatus:ga,clearHookConfigStatus:pa}),oi=c.useCallback(ae=>{Fe(Se=>{if(typeof ae=="function"){const Me=ae(Se.prompt,Se.attachments);return{prompt:Me.prompt,attachments:Me.attachments??Se.attachments}}return{prompt:ae,attachments:Se.attachments}})},[Fe]),un=c.useMemo(()=>f.find(ae=>ae.model===l)??null,[l,f]),li=Lu(l,p),xa=(un==null?void 0:un.supportedReasoningEfforts)??[],ii=c.useMemo(()=>pu(Ne,Ye),[Ye,Ne]),di=c.useMemo(()=>Object.entries(lt).sort(([ae],[Se])=>ae.localeCompare(Se)).map(([ae,Se])=>`${ae}:${Se}`).join("|"),[lt]);function ci(ae,Se){Se.stopPropagation();const Me=Yu(ae,{fastMode:d,goalComposeMode:hr});switch(Me.type){case"toggleFast":it({fastMode:Me.fastMode});break;case"runCompact":ze(null),B==null||B();break;case"enterGoalCompose":Wl();break;case"exitGoalCompose":fa(),ze(null);break;case"openPanel":le(Me.panel),Me.panel==="skills"?J==null||J():Me.panel==="mcp"?K==null||K():Me.panel==="hooks"&&(L==null||L());break;case"insertPrompt":fn(Me.text),le("root"),ze(null);break}}function Yt(){const ae=Ee.current;return ae?rm(ae):null}const hi=c.useCallback(ae=>{const Se=Ee.current;!Se||!ae||nm(Se,ae)},[]),mn=c.useCallback(()=>{const ae=Ee.current;return ae?sl(ae):Ne},[Ne]),{appendAttachments:pn,appendDroppedAttachments:ba}=zm({prompt:Ne,attachments:Ye,updateDraft:Fe,getSelection:Yt,selectionSnapshotRef:Ve,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,onInserted:()=>ze(null)}),va=c.useCallback((ae,Se)=>{var Me;if(At(),R){R({kind:ae,appendAttachments:(Je,st=ae)=>pn(Je,st),defaultPick:()=>{var Je;return(Je=Se.current)==null?void 0:Je.click()}});return}(Me=Se.current)==null||Me.click()},[pn,At,R]);function fn(ae){if(!ae)return;const Se=Yt()??Ve.current,Me=(Se==null?void 0:Se.start)??Ne.length,Je=(Se==null?void 0:Se.end)??Me,st=mu(ae),Zt=`${Ne.slice(0,Me)}${st}${Ne.slice(Je)}`;Fe(Vi=>({prompt:Zt,attachments:Vi.attachments}));const _t=Me+st.length;Be.current={start:_t,end:_t},Ve.current={start:_t,end:_t}}Wm({promptRef:Ee,isShellView:We,prompt:Ne,promptSegments:ii,attachmentPreviewUrls:lt,previewSignature:di,editorSanitizeNonce:xe,pendingSelectionRef:Be,pendingInsertedAttachmentIdsRef:et,selectionSnapshotRef:Ve,renderedPreviewSignatureRef:pt,renderedSanitizeNonceRef:nt,serializeEditorPrompt:mn,restoreSelection:hi});function At(){var ae;(ae=Ee.current)==null||ae.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ui(){var ae;if(At(),ze(null),!!((ae=navigator.clipboard)!=null&&ae.readText))try{const Se=await navigator.clipboard.readText();fn(Se)}catch{return}}async function ka(){if(!we.current){we.current=!0;try{if(tt&&Ke(),hr&&!We){await Ol();return}const ae=vu({prompt:Ne,attachments:Ye,isShellView:We});if(!ae||await T(ae)===!1)return;Fe(()=>({prompt:"",attachments:[]}))}finally{we.current=!1}}}async function mi(ae){ae.preventDefault(),await ka()}function pi(){const ae=mn(),Se=Yt();Ve.current=Se;const Me=Ee.current;(Me?tm(Me):!1)&&(Be.current=Se,je(st=>st+1)),Fe(st=>({prompt:ae,attachments:st.attachments.filter(Zt=>ae.includes(Zt.placeholder))}),"deferred")}function fi(ae){var Je,st,Zt,_t;const Se=On((Je=ae.clipboardData)==null?void 0:Je.items,(st=ae.clipboardData)==null?void 0:st.files),Me=ku({files:Se,plainText:((Zt=ae.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:((_t=ae.clipboardData)==null?void 0:_t.getData("text/html"))??"",htmlToText:em});Me.preventDefault&&ae.preventDefault(),Me.type==="insert-text"?fn(Me.text):Me.type==="append-files"&&ba(Me.files)}function gi(ae){var Me,Je;const Se=es(ns((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&U(!0)}function xi(ae){var Me,Je;const Se=es(ns((Me=ae.dataTransfer)==null?void 0:Me.items,(Je=ae.dataTransfer)==null?void 0:Je.files));Se.preventDefault&&ae.preventDefault(),Se.activateDragTarget&&ae.dataTransfer&&(ae.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&U(!0)}function bi(ae){ae.currentTarget.contains(ae.relatedTarget)||U(!1)}function vi(ae){var Je,st;const Se=On((Je=ae.dataTransfer)==null?void 0:Je.items,(st=ae.dataTransfer)==null?void 0:st.files),Me=wu(Se);Me.preventDefault&&ae.preventDefault(),Me.type==="accept-files"&&(U(!1),ba(Me.files??[]))}function ki(ae){if(ae.key==="Enter"&&ae.repeat){ae.preventDefault();return}if(e==="chat"&&ae.key==="/"&&!ae.metaKey&&!ae.ctrlKey&&!ae.altKey&&!n&&!v&&ge.length>0&&mn().trim().length===0){ae.preventDefault(),le("root"),ze("slash");return}const Se=yu({key:ae.key,metaKey:ae.metaKey,ctrlKey:ae.ctrlKey,busy:n,disabled:v});Se.preventDefault&&ae.preventDefault(),Se.submit&&ka()}const{promptPlaceholder:wi,interruptLabel:yi,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:ji,effortControlsDisabled:Ni,effortControlTitle:Ci}=Ru({goalComposeMode:hr,goalBusy:hn,threadConnected:w,busy:n,isShellView:We,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:xa.length,fastMode:d}),{composerLayerClassName:Si,formClassName:Ti,composerShellClassName:Ei,composerToolbarClassName:Li,composerIconButtonClassName:Ii,composerMenuClassName:zi,composerMenuItemClassName:Pi,composerInlineToggleClassName:Ri,composerPanelButtonClassName:Mi,composerChipButtonClassName:Ai,composerPlanToggleActiveClassName:_i,composerSendButtonClassName:$i,composerPromptRegionClassName:Di,promptInputClassName:Bi,graphChatInputGroupClassName:Gi,graphChatInputClassName:Fi}=Mu({isShellView:We,edgeToEdgeMobile:r,isMobileShell:ht,openMenu:_e!==null,isDragTargetActive:A,busy:n}),Hi=Ym({isShellView:We,canToggleShellView:ot,isMobileShell:ht,shellPromptLabel:ut,openMenu:_e,toolbarClassName:Li,iconButtonClassName:Ii,menuClassName:zi,menuItemClassName:Pi,panelButtonClassName:Mi,chipButtonClassName:Ai,inlineToggleClassName:Ri,planToggleActiveClassName:_i,sendButtonBaseClassName:$i,slashPanelView:F,availableToolboxItems:ge,busy:n,settingsBusy:a,compactBusy:o,forkBusy:Nt,fastMode:d,goalComposeMode:hr,goalBusy:hn,goalStatus:(ja=Z.data)==null?void 0:ja.status,activeView:e,disabled:v,model:l,modelOptions:f,modelContextTitle:li,contextUsage:p,reasoningEffort:i,supportedEfforts:xa,displayedCollaborationMode:vt,sandboxMode:u,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:ji,effortControlsDisabled:Ni,effortControlTitle:Ci,forkTurnOptionsState:te,skillsState:Q,goalState:Z,goalHistory:P,copiedSkillName:ai,hooksPanelMode:_,hooksState:Y,hookConfigBusy:Xt,hookConfigError:Mt,hookConfigSuccess:cr,editingHookTarget:qt,hookScope:pe,hookEventName:Re,hookMatcher:Ge,hookCommand:Ue,hookTimeoutSec:ct,hookStatusMessage:kt,mcpPanelMode:z,mcpState:$,mcpConfigPath:ql,mcpConfigError:Yl,mcpConfigSuccess:Zl,mcpConfigBusy:Xl,mcpHttpName:Ul,mcpHttpUrl:Vl,mcpRawBlock:Kl,capabilities:{hostConfigFiles:ne.hostConfigFiles,hookTrust:ne.hookTrust,mcpConfigEditing:ne.mcpConfigEditing,planMode:ne.planMode,sandboxMode:m?!1:ne.sandboxMode},shellControlState:N,onToggleView:ve,onDismissPromptFocus:At,onSetOpenMenu:ze,onToolboxItemClick:ci,onSetSlashPanelView:le,onViewGoals:W,onUpdateGoal:se,onOpenForkTurns:()=>V==null?void 0:V(),onForkLatest:Rt,onForkTurn:Ct,onCopySkillInvokeName:si,onResetHookForm:Al,onSetHooksPanelMode:at,onClearHookConfigStatus:pa,onSetEditingHookTarget:dn,onSetHookScope:cn,onSetHookEventName:Il,onSetHookMatcher:zl,onSetHookCommand:Pl,onSetHookTimeoutSec:Rl,onSetHookStatusMessage:Ml,onSaveHook:$l,onStartEditingHook:_l,onTrustHook:Dl,onUntrustHook:Bl,onSetMcpPanelMode:O,onClearMcpConfigStatus:ga,onSetMcpHttpName:Jl,onSetMcpHttpUrl:Ql,onSetMcpRawBlock:ei,onPrepareRawMcpBlock:ti,onSaveHttpMcp:ri,onSaveRawMcpBlock:ni,onPickPhoto:()=>va("photo",fe),onPickFile:()=>va("file",De),onUpdateSettings:ae=>void it(ae),onPasteShell:()=>void ui(),onCopyShell:()=>{At(),ze(null),ke==null||ke()},onClearShell:()=>{At(),ze(null),T({prompt:"clear"})},onShellControl:ae=>{At(),ze(null),$e==null||$e(ae)}}),{promptSlot:Oi,goalSlot:Wi,shellPromptSlot:Ui}=qm({isShellView:We,promptRef:Ee,prompt:Ne,disabled:v,promptPlaceholder:wi,canInterrupt:He,interruptLabel:yi,composerPromptRegionClassName:Di,graphChatInputClassName:Fi,promptInputClassName:Bi,goalComposeMode:hr,goalTokenBudget:Gl,goalLocalError:Fl,goalBusy:hn,busy:n,sendButtonLabel:wa,sendButtonClassName:ya,onInterrupt:re,onPromptInput:pi,onPromptPaste:fi,onPromptKeyDown:ki,onPromptKeyUp:()=>{Ve.current=Yt()},onPromptMouseUp:()=>{Ve.current=Yt()},onPromptBlur:()=>{Ve.current=Yt(),U(!1),tt&&Ke()},onPromptDragEnter:gi,onPromptDragOver:xi,onPromptDragLeave:bi,onPromptDrop:vi,onGoalTokenBudgetChange:Hl,onCancelGoal:fa,onShellPromptChange:oi});return t.jsx(pm,{activeView:e,layerClassName:Si,formClassName:Ti,shellClassName:Ei,inputGroupClassName:Gi,error:s,followTail:j,photoInputRef:fe,fileInputRef:De,onAppendAttachments:pn,onToggleFollow:ye,canJumpToPreviousTurn:Ae,onJumpToPreviousTurn:ce,canJumpToNextTurn:Ce,onJumpToNextTurn:Le,subscriptionUsage:X,onSubmit:mi,formRef:Te,promptSlot:Oi,toolbarSlot:t.jsx(Em,{...Hi}),goalSlot:Wi,shellPromptSlot:Ui})}var Zm=c.createContext(null);function ll(){return c.useContext(Zm)}function xt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Jm(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function Qm(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function il(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function ep({open:e,title:r,label:n,value:a,busy:o=!1,onChange:s,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[o,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>s(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:o||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function tp({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:o}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${o?"thread-ui-viewport-constrained":""} ${o?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function rp({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function np({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function ap({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function sp({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function op({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function lp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Lo();Pt();function cs({...e}){return t.jsx(Ji,{"data-slot":"dialog",...e})}function hs({...e}){return t.jsx(Qi,{"data-slot":"dialog-trigger",...e})}function ip({...e}){return t.jsx(ad,{"data-slot":"dialog-portal",...e})}function dp({className:e,...r}){return t.jsx(sd,{"data-slot":"dialog-overlay",className:rt("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function us({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(ip,{"data-slot":"dialog-portal",children:[t.jsx(dp,{}),t.jsxs(ed,{"data-slot":"dialog-content",className:rt("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(td,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(D.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function ms({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:rt("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ps({className:e,...r}){return t.jsx(rd,{"data-slot":"dialog-title",className:rt("text-lg font-semibold leading-none",e),...r})}function fs({className:e,...r}){return t.jsx(nd,{"data-slot":"dialog-description",className:rt("text-sm text-muted-foreground",e),...r})}var cp=[{value:"system",label:"Follow system",icon:D.Monitor},{value:"dark",label:"Dark",icon:D.Moon},{value:"light",label:"Light",icon:D.Sun}];function hp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],k=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const w=()=>o(e.id),y=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,v=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(D.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(D.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[k?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:k,children:k}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${Qm(e.status)}`,children:Jm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:xt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(D.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:v,className:y,onClick:w})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),w()},title:m?e.title:void 0,className:y,children:v}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),w())},title:m?e.title:void 0,className:y,children:v})}function up({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(hp,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function mp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:k=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:w,topbarActions:y,metaContent:v,settingsContent:S,globalSettingsContent:N,workspaceLabels:I={},workspaceReturnHref:M,onWorkspaceReturn:R,getThreadHref:Q,onOpenThread:$,getNewThreadHref:Y,newThreadHref:Z,newThreadLabel:P="New Chat",onNewThread:te,onNewThreadTitle:oe,renderNewThreadDialogContent:T,renderThreadLink:re,onCloseAppNavigation:B,onRenameThread:J,onDeleteThread:K,workspaceContent:L,workspaceTitle:q="Workspace",workspaceActions:G,children:E}){const C=ll(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[H,se]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),V=i??(C==null?void 0:C.themeMode)??"system",de=l??(C==null?void 0:C.effectiveTheme)??(V==="system"?H?"dark":"light":V),[ee,be]=c.useState(!1),[ie,ye]=c.useState(!1),[Ae,ce]=c.useState(!W),[Ce,Le]=c.useState(W),[X,ue]=c.useState("chat"),[ve,ke]=c.useState(null),[$e,He]=c.useState(""),[_e,ze]=c.useState(null),[F,le]=c.useState(!1),[we,z]=c.useState(""),[O,ne]=c.useState(!1),[ge,Te]=c.useState(!1),[Ee,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(max-width: 639px)"),pe=()=>{Le(_.matches)};return pe(),_.addEventListener("change",pe),()=>{_.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const _=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{se(_.matches)};return pe(),_.addEventListener("change",pe),()=>{_.removeEventListener("change",pe)}},[]);const De=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,Re)=>{if(pe.id===p)return-1;if(Re.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(Re.lastTurnStartedAt??Re.updatedAt)-Ge}),[p,b,e]),Be=Z??(Y==null?void 0:Y(b)),et=k??b??"all",Ve=x??g??p??"default_session",pt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),nt=d??(C==null?void 0:C.setThemeMode),We=!!nt,ot=()=>{be(!1),B==null||B()};async function ht(_){if(!J)return;const pe=$e.trim();if(pe){ze(_);try{await J(_,pe),ke(null),He("")}finally{ze(null)}}}function ut(_){ke(_.id),He(_.title)}function A(){ke(null),He("")}function U(_){$==null||$(_),ot()}function xe(){le(!1),z("")}function je(_){if(!Be||!_.trim())return Be;try{const pe=new URL(Be,window.location.origin);return pe.searchParams.set("title",_.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=Be.includes("?")?"&":"?";return`${Be}${pe}title=${encodeURIComponent(_.trim())}`}}async function Ne(){const _=we.trim();ne(!0);try{if(_&&oe){await oe(_),z(""),le(!1),ot();return}if(Be){window.location.assign(je(_)??Be);return}await(te==null?void 0:te()),z(""),le(!1),ot()}finally{ne(!1)}}function Ye(_,pe=!1){const Re=pe?t.jsxs(t.Fragment,{children:[t.jsx(D.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:P})]}):t.jsxs(t.Fragment,{children:[t.jsx(D.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:P})]});return t.jsxs(cs,{open:F,onOpenChange:Ge=>{O||le(Ge)},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?P:void 0,title:P,className:_,children:Re})}),t.jsx(us,{"data-testid":"create-thread-dialog","data-theme-effective":de,"data-theme-mode":V,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:T?T({close:xe,closeNavigation:ot,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Create New Chat"}),t.jsx(fs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Ge=>z(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Ne())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void Ne(),disabled:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function tt(){if(!S&&!v&&!N&&!We)return null;const _=!!(S||v),pe=!!N,Re=_&&pe,Ge=Ee==="global"&&pe||!_&&pe?"global":"session";return t.jsxs(cs,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(D.Settings,{className:"h-4 w-4"})})}),t.jsxs(us,{"data-testid":"settings-dialog","data-theme-effective":de,"data-theme-mode":V,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Settings"}),t.jsx(fs,{children:"Manage this session and host-wide preferences."})]}),We?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",de]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:cp.map(Ue=>{const ct=Ue.icon,kt=V===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":kt,disabled:!We,onClick:()=>nt==null?void 0:nt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${kt?"is-selected":""}`,children:[t.jsx(ct,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,Re?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,v?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:v}):null,_?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function Fe(_=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${_?"justify-center":""}`,children:[t.jsx(D.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:_?"sr-only":"",children:"Rooms"}),!_&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&De.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,De.length>0?t.jsx(up,{threads:De,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:I,onOpenThread:U,collapsed:_,...J?{onBeginRenameThread:ut}:{},showDeleteButton:!!K,...Q?{getThreadHref:Q}:{},...re?{renderThreadLink:re}:{},...K?{onDeleteThread:K}:{}}):null]})]})})}function Ke(){return L?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})}),G?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:G})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:L})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:q}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:k??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G,t.jsx("button",{type:"button",onClick:()=>ce(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(D.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:L??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:k??b??"All threads"})]})]})})]})}const lt=!!L,vt=s==="mobile"||s==="responsive"&&Ce,it=vt,Nt=it&&!ee,Ct=!!(M||R)?t.jsx("a",{href:M??"#",onClick:_=>{R&&(_.preventDefault(),R())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(D.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(tp,{effectiveTheme:de,layoutMode:s,themeMode:V,viewportConstrained:o,children:t.jsxs(rp,{roomsRailCollapsed:ie,children:[t.jsx(np,{open:ee,onClose:()=>be(!1)}),t.jsxs(ap,{collapsed:ie,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${ie?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${ie?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>ye(_=>!_),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:ie?"Expand rooms":"Collapse rooms","aria-label":ie?"Expand rooms":"Collapse rooms",children:ie?t.jsx(D.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(D.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${ie?"thread-desktop-collapsed-hidden":""}`,children:(k??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:k??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${ie?"thread-desktop-collapsed-hidden":""}`,children:[tt(),Ct,t.jsx("button",{type:"button",onClick:()=>be(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(D.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${ie?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ye(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${ie?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,ie)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${ie?"w-full px-2 py-2":"px-3 py-3"}`,children:Fe(ie)})]}),t.jsxs(sp,{children:[t.jsx(op,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[Nt?t.jsx("button",{type:"button",onClick:()=>be(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(D.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Te(_=>!_)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var _;Ve&&((_=navigator.clipboard)==null||_.writeText(Ve))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:Ve})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:pt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[w||y?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[w,y]}):null,it&&w?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:w}):null,it&&lt?t.jsx("button",{type:"button",onClick:()=>ue(_=>_==="workspace"?"chat":"workspace"),"aria-label":X==="workspace"?"Show chat":"Show workspace",title:X==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:X==="workspace"?t.jsx(D.MessageSquare,{className:"h-4 w-4"}):t.jsx(D.Folder,{className:"h-4 w-4"})}):null,it?f:null,it&&h?Ye("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(lp,{children:lt&&!Ae?vt?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${X==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:Ke()})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(An,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:Ke()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[lt&&Ae?t.jsx("button",{type:"button",onClick:()=>ce(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(D.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(ep,{open:ve!==null,title:"Rename Thread",label:"Thread Title",value:$e,busy:_e!==null,onChange:He,onCancel:A,onSubmit:()=>ve?ht(ve):void 0})]})}function pp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function o(s){s.key==="Escape"&&a()}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var fp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],gp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,xp=/!?\[[^\]\n]+\]\([^)]+\)/,bp=/`[^`\n]+`/,vp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,kp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,wp=/~~[^~\n]+~~/;function yp(e){const r=e.trim();return r?fp.some(n=>n.test(r))||gp.test(r)?!0:/[`[\]*_~!]/.test(r)?xp.test(r)||bp.test(r)||vp.test(r)||kp.test(r)||wp.test(r):!1:!1}rn();function Vn(e,r){const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{var l,i;return{...s.manifest,enabled:((l=n.get(s.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(s.manifest.id))==null?void 0:i.source)??"builtin"}}),o=new Set(e.map(s=>s.manifest.id));for(const s of r)o.has(s.id)||a.push(s);return a}function ia(e=[]){const r=Vn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:s=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===s.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,s))??null},renderInlineCode:s=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(s.language.trim().toLowerCase()))continue;const d=i.render(s);if(d)return d}return null},hasRendererForArtifact:s=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===s.type)),getThreadPanels:()=>n.flatMap(s=>s.threadPanels??[])}}var da=c.createContext(ia());function ca(){return c.useContext(da)??ia()}Lr();function dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gs(e){return dl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function cl(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function jp(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):cl(r)}function xs({callId:e,toolName:r,status:n,parameters:a,result:o}){const s=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>gs(o),[o]),i=c.useMemo(()=>gs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:dl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsx(nn,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(D.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${s.className}`,title:s.label,"aria-label":`Status: ${s.label}`,children:[s.icon,t.jsx("span",{className:"thread-graph-status-label",children:s.label})]})]})}),t.jsxs(Er,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),cl(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),jp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var bs=null;function Np(){return bs??(bs=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,k,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,k.default,x.default,j.default]}))),bs}function an(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kn(e){if(!e)return{};if(an(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function qn(){return{finalResult:null,stdout:"",stderr:""}}function Cp(e){return typeof e=="string"?{result:e}:e}function hl(e){const r=an(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function vs(e){if(!e)return"pending";if(!an(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Sp(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=Cp(d.result),m=r.get(h)??qn();return an(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Kn(d.args);if(typeof h=="string"&&r.has(h)){const f=hl(r.get(h)??qn());return`\`\`\`tool-merged
3689
+ `,ds="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Wm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[b,w]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{w(null),j(null)},[]),v=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const R=await r();return f(R.path),R},[e,r]),k=c.useCallback(async R=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const P=await n(R);return f(P.path),P},[e,n]),S=c.useCallback(async()=>{const R=Lu(s),P=i.trim();if(!R){w("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(P)){w("HTTP MCP URL must start with http:// or https://");return}g(!0),w(null),j(null);try{const Q=await v(),D=rs(Q.content,R,zu(R,P));await k(D),j(ds),a("list"),l(""),d(""),o==null||o()}catch(Q){w(Q instanceof Error?Q.message:"Unable to update provider config.")}finally{g(!1)}},[v,s,i,o,a,k]),N=c.useCallback(async()=>{g(!0),w(null),j(null);try{await v(),u(R=>R||Om),a("stdio")}catch(R){w(R instanceof Error?R.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),L=c.useCallback(async()=>{const R=Iu(h);if(!R){w("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),w(null),j(null);try{const P=await v(),Q=rs(P.content,R,h);await k(Q),j(ds),a("list"),o==null||o()}catch(P){w(P instanceof Error?P.message:"Unable to update provider config.")}finally{g(!1)}},[v,h,o,a,k]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:b,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:N,saveHttpMcp:S,saveRawMcpBlock:L}}function Um({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Vm(e,r){const{attachment:n}=e,a=document.createElement("span");if(a.dataset.segmentType="attachment",a.dataset.clientId=n.clientId,a.dataset.placeholder=n.placeholder,a.contentEditable="false",a.className="thread-composer-attachment-chip mx-[0.12rem] inline-flex max-w-full align-baseline",n.kind==="photo"){a.classList.add("thread-composer-attachment-chip-photo","rounded-[0.95rem]","border","border-sky-300/35","bg-sky-300/10","p-1","shadow-sm","shadow-stone-950/20");const l=r[n.clientId];if(l){const d=document.createElement("img");d.src=l,d.alt=n.originalName||"Pasted image",d.className="thread-composer-attachment-thumb h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-950 object-contain",d.draggable=!1,a.append(d)}else{const d=document.createElement("span");d.className="thread-composer-attachment-thumb inline-block h-[4.5rem] w-[6rem] rounded-[0.7rem] bg-stone-900/80",d.setAttribute("aria-hidden","true"),a.append(d)}const i=document.createElement("span");return i.className="thread-composer-attachment-caption ml-2 inline-flex max-w-[8rem] items-center text-[10px] font-medium tracking-[0.08em] text-sky-50",i.textContent=as(n),a.append(i),a}a.classList.add("items-center","gap-2","rounded-[0.95rem]","border","border-emerald-300/35","bg-emerald-300/10","px-2.5","py-2","text-[10px]","font-medium","tracking-[0.08em]","text-emerald-50","shadow-sm","shadow-stone-950/20");const o=document.createElement("span");o.className="inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/25 bg-emerald-300/12 text-[9px]",o.textContent="FILE";const s=document.createElement("span");return s.className="inline-flex max-w-[10rem] truncate",s.textContent=as(n),a.append(o,s),a}function qm(e,r){const n=document.createDocumentFragment();for(const a of e){if(a.type==="text"){n.append(document.createTextNode(a.text===" "?" ":a.text));continue}n.append(Vm(a,r))}return n}function Km({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const b=i.current,w=f()!==n||u.current!==s||m.current!==l;w&&(g.replaceChildren(qm(a,o)),u.current=s,m.current=l),b!==null?(g.focus(),lm(g,d.current)||p(b),h.current=b):document.activeElement===g&&w&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function Xm({tokenBudget:e,error:r,onTokenBudgetChange:n,onCancel:a}){return t.jsxs("div",{className:"thread-goal-compose-card relative z-20 mb-1.5 flex flex-wrap items-center gap-2 rounded-2xl border px-3 py-2 text-xs shadow-sm",children:[t.jsx("span",{className:"thread-goal-compose-label font-medium uppercase tracking-[0.16em]",children:"Goal"}),t.jsxs("label",{className:"thread-goal-compose-field flex items-center gap-2",children:[t.jsx("span",{children:"Max tokens (k)"}),t.jsx("input",{"aria-label":"Goal token budget",value:e,onChange:o=>n(o.target.value),inputMode:"numeric",placeholder:"Optional",className:"thread-goal-compose-input h-7 w-24 rounded-full border px-3 text-xs outline-none"})]}),r?t.jsx("span",{className:"thread-goal-compose-error min-w-0 flex-1",children:r}):null,t.jsx("button",{type:"button",onClick:a,className:"thread-goal-compose-cancel rounded-full border px-2.5 py-1 text-[11px] transition",children:"Cancel"})]})}function Ym({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPointerDown:u,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:b,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,inputMode:"text",suppressContentEditableWarning:!0,onPointerDown:v=>{!n&&document.activeElement!==v.currentTarget&&v.currentTarget.focus({preventScroll:!0}),u==null||u(v)},onInput:h,onPaste:m,onKeyDown:f,onKeyUp:p,onMouseUp:g,onBlur:b,onDragEnter:w,onDragOver:x,onDragLeave:j,onDrop:y,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(Ct,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:v=>{v.preventDefault(),d==null||d()},className:"thread-graph-composer-stop-button ui-action-danger absolute right-2 top-2 z-30 h-8 w-8 rounded-full text-sm font-medium",children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}):null]})}function Zm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function Jm({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:b,sendButtonClassName:w,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:v,onPromptKeyUp:k,onPromptMouseUp:S,onPromptBlur:N,onPromptDragEnter:L,onPromptDragOver:R,onPromptDragLeave:P,onPromptDrop:Q,onGoalTokenBudgetChange:D,onCancelGoal:Z,onShellPromptChange:J}){return{promptSlot:e?null:t.jsx(Ym,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:v,onKeyUp:k,onMouseUp:S,onBlur:N,onDragEnter:L,onDragOver:R,onDragLeave:P,onDrop:Q}),goalSlot:u&&!e?t.jsx(Xm,{tokenBudget:m,error:f,onTokenBudgetChange:D,onCancel:Z}):null,shellPromptSlot:e?t.jsx(Zm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:b,sendButtonClassName:w,sendDisabled:p||g,onPromptChange:J,onPromptKeyDown:v,onInterrupt:x}):null}}function Qm({collaborationMode:e,onUpdateSettings:r,closeMenu:n}){const[a,o]=c.useState(null),s=a??e;c.useEffect(()=>{o(null)},[e]);const l=c.useCallback(async i=>{const d=Su({nextMode:i.collaborationMode,previousOptimisticMode:a});d.optimisticMode&&o(d.optimisticMode);try{await(r==null?void 0:r(i)),d.closeMenuOnSuccess&&n()}catch(h){throw d.shouldRollbackMode&&o(d.rollbackMode),h}},[n,r,a]);return{displayedCollaborationMode:s,updateSettings:l}}function ep({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:b,busy:w,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:v,goalComposeMode:k,goalBusy:S,goalStatus:N,activeView:L,disabled:R,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,sendButtonLabel:$,sendButtonClassName:le,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hookConfigBusy:ne,hookConfigError:K,hookConfigSuccess:ie,editingHookTarget:ee,hookScope:ve,hookEventName:oe,hookMatcher:ye,hookCommand:Me,hookTimeoutSec:de,hookStatusMessage:Ce,mcpPanelMode:Ee,mcpState:Y,mcpConfigPath:ue,mcpConfigError:ke,mcpConfigSuccess:we,mcpConfigBusy:De,mcpHttpName:Fe,mcpHttpUrl:Ae,mcpRawBlock:Oe,capabilities:V,shellControlState:ce,onToggleView:xe,onDismissPromptFocus:I,onSetOpenMenu:O,onToolboxItemClick:ae,onSetSlashPanelView:be,onViewGoals:je,onUpdateGoal:Te,onOpenForkTurns:fe,onForkLatest:Be,onForkTurn:_e,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:ft,onSetHookMatcher:Ve,onSetHookCommand:M,onSetHookTimeoutSec:X,onSetHookStatusMessage:ge,onSaveHook:Ne,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:gt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt,onPickPhoto:A,onPickFile:pe,onUpdateSettings:ze,onPasteShell:Ge,onCopyShell:Ue,onClearShell:mt,onShellControl:yt}){const Kt=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:b,busy:w,forkBusy:y,forkTurnOptionsState:T,skillsState:F,goalState:B,goalHistory:E,goalBusy:S,copiedSkillName:C,hooksPanelMode:W,hooksState:U,hostConfigFilesAvailable:V.hostConfigFiles,hookTrustAvailable:V.hookTrust,hookConfigBusy:ne,hookConfigError:K,hookConfigSuccess:ie,editingHookTarget:ee,hookScope:ve,hookEventName:oe,hookMatcher:ye,hookCommand:Me,hookTimeoutSec:de,hookStatusMessage:Ce,mcpPanelMode:Ee,mcpState:Y,mcpConfigEditing:V.mcpConfigEditing,mcpConfigPath:ue,mcpConfigError:ke,mcpConfigSuccess:we,mcpConfigBusy:De,mcpHttpName:Fe,mcpHttpUrl:Ae,mcpRawBlock:Oe,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>O(ot=>ot==="slash"?null:"slash"),onToolboxItemClick:ae,toolboxItemDisabled:ot=>tm(ot,{settingsBusy:x,compactBusy:j,busy:w,forkBusy:y}),toolboxItemClassName:ot=>rm(ot,{fastMode:v,goalComposeMode:k,goalStatus:N,menuItemClassName:d}),toolboxItemStatus:ot=>em(ot,{fastMode:v,compactBusy:j,goalComposeMode:k,goalStatus:N,busy:w}),onSetSlashPanelView:be,onViewGoals:je,onUpdateGoal:Te,onOpenForkTurns:fe,onForkLatest:Be,onForkTurn:_e,onCopySkillInvokeName:Qe,onResetHookForm:et,onSetHooksPanelMode:it,onClearHookConfigStatus:tt,onSetEditingHookTarget:Ke,onSetHookScope:dt,onSetHookEventName:ft,onSetHookMatcher:Ve,onSetHookCommand:M,onSetHookTimeoutSec:X,onSetHookStatusMessage:ge,onSaveHook:Ne,onStartEditingHook:Pe,onTrustHook:rt,onUntrustHook:nt,onSetMcpPanelMode:$e,onClearMcpConfigStatus:We,onSetMcpHttpName:ut,onSetMcpHttpUrl:st,onSetMcpRawBlock:ct,onPrepareRawMcpBlock:gt,onSaveHttpMcp:Rt,onSaveRawMcpBlock:wt},Xt=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>O(ot=>ot==="attachments"?null:"attachments"),onPickPhoto:A,onPickFile:pe},Mt=e?null:{openMenu:o,model:P,modelOptions:Q,modelContextTitle:D,contextUsage:Z,reasoningEffort:J,supportedEfforts:z,displayedCollaborationMode:te,sandboxMode:se,planModeAvailable:V.planMode,sandboxModeAvailable:V.sandboxMode,settingsBusy:x,goalComposeMode:k,goalBusy:S,activeView:L,disabled:R,fastMode:v,sendButtonLabel:$,sendButtonClassName:le,modelControlsDisabled:q,effortControlsDisabled:H,effortControlTitle:G,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:O,onUpdateSettings:ze};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Kt,attachmentMenuProps:Xt,settingsToolbarProps:Mt,shellToolsPanelProps:o==="shellTools"?{busy:w,shellControlState:ce,onPaste:Ge,onCopy:Ue,onClear:mt,onShellControl:yt}:null,shellControlState:ce,onToggleView:xe,onDismissPromptFocus:I,onSetOpenMenu:O}}function Un({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:b=null,hookCommandTemplates:w=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:v=!0,disabled:k=!1,disabledPlaceholder:S,shellControlState:N=null,draftPrompt:L,draftAttachments:R,onPickAttachment:P,skillsState:Q={status:"idle",data:null,error:null},mcpState:D={status:"idle",data:null,error:null},hooksState:Z={status:"idle",data:null,error:null},goalState:J={status:"idle",data:null,error:null},goalHistory:z=[],forkTurnOptionsState:te={status:"idle",data:null,error:null},onDraftChange:se,onSubmit:$,onInterrupt:le,onCompact:q,onOpenSkills:H,onOpenMcp:G,onOpenHooks:T,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ne,onOpenForkTurns:K,onForkLatest:ie,onForkTurn:ee,onReadProviderConfig:ve,onWriteProviderConfig:oe,onToggleFollow:ye,canJumpToPreviousTurn:Me,onJumpToPreviousTurn:de,canJumpToNextTurn:Ce,onJumpToNextTurn:Ee,subscriptionUsage:Y,onUpdateSettings:ue,onToggleView:ke,onShellCopy:we,onShellControl:De,canInterrupt:Fe=!1,pendingPrompts:Ae=[],onSteerPendingPrompt:Oe,onCancelPendingPrompt:V}){var ja;const[ce,xe]=c.useState(null),[I,O]=c.useState("root"),ae=c.useRef(!1),[be,je]=c.useState("list"),Te=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!ve&&!!oe,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,ve,oe]),fe=c.useMemo(()=>Ju(b,Te),[Te,b]),Be=c.useRef(null),_e=c.useRef(null),Qe=c.useRef(null),et=c.useRef(null),it=c.useRef(null),tt=c.useRef([]),Ke=c.useRef(null),dt=c.useRef(""),ft=c.useRef(0),Ve=e==="shell",M=v||Ve,X=!!(Ve&&(N!=null&&N.isMobileShell)),ge=(N==null?void 0:N.promptLabel)??null,[Ne,Pe]=c.useState(!1),[rt,nt]=c.useState(0),{prompt:$e,attachments:We,isDraftControlled:ut,updateDraft:st,flushControlledDraftToHost:ct}=Dm({isShellView:Ve,draftPrompt:L,draftAttachments:R,onDraftChange:se}),gt=_m({attachments:We,isShellView:Ve}),{displayedCollaborationMode:Rt,updateSettings:wt}=Qm({collaborationMode:h,onUpdateSettings:ue,closeMenu:()=>xe(null)}),{forkBusy:A,forkLatest:pe,forkTurn:ze}=Bm({slashPanelView:I,onForkLatest:ie,onForkTurn:ee,closeMenu:()=>xe(null)}),{hooksPanelMode:Ge,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Kt,hookTimeoutSec:Xt,hookStatusMessage:Mt,editingHookTarget:cr,hookConfigBusy:ot,hookConfigError:dn,hookConfigSuccess:cn,setHooksPanelMode:Il,setEditingHookTarget:zl,setHookScope:Pl,setHookEventName:Rl,setHookMatcher:Ml,setHookCommand:Al,setHookTimeoutSec:_l,setHookStatusMessage:$l,clearHookConfigStatus:pa,resetHookForm:Dl,startEditingHook:Bl,saveHook:Gl,trustHook:Fl,untrustHook:Hl}=Hm({slashPanelView:I,hookCommandTemplates:w,onCreateHook:F,onUpdateHook:B,onTrustHook:E,onUntrustHook:C}),{goalComposeMode:hr,goalTokenBudget:Ol,goalBusy:hn,goalLocalError:Wl,setGoalTokenBudget:Ul,submitGoal:Vl,enterGoalComposeMode:ql,exitGoalComposeMode:fa}=Gm({prompt:$e,goalTokenBudgetSource:J.data,promptRef:_e,onOpenGoal:W,onPrepareGoalSubmit:U,onUpdateGoal:ne,updateDraft:st,closeMenu:()=>xe(null),resetSlashPanel:()=>O("root")}),{mcpHttpName:Kl,mcpHttpUrl:Xl,mcpRawBlock:Yl,mcpConfigPath:Zl,mcpConfigBusy:Jl,mcpConfigError:Ql,mcpConfigSuccess:ei,setMcpHttpName:ti,setMcpHttpUrl:ri,setMcpRawBlock:ni,clearMcpConfigStatus:ga,prepareRawMcpBlock:ai,saveHttpMcp:si,saveRawMcpBlock:oi}=Wm({hostConfigFilesAvailable:Te.hostConfigFiles,onReadProviderConfig:ve,onWriteProviderConfig:oe,setMcpPanelMode:je,onOpenMcp:G}),{copiedSkillName:li,copySkillInvokeName:ii}=Um({openMenu:ce,setOpenMenu:xe,slashPanelView:I,setSlashPanelView:O,setMcpPanelMode:je,clearMcpConfigStatus:ga,clearHookConfigStatus:pa}),di=c.useCallback(re=>{st(Se=>{if(typeof re=="function"){const Re=re(Se.prompt,Se.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Se.attachments}}return{prompt:re,attachments:Se.attachments}})},[st]),un=c.useMemo(()=>f.find(re=>re.model===l)??null,[l,f]),ci=Pu(l,p),xa=(un==null?void 0:un.supportedReasoningEfforts)??[],hi=c.useMemo(()=>xu($e,We),[We,$e]),ui=c.useMemo(()=>Object.entries(gt).sort(([re],[Se])=>re.localeCompare(Se)).map(([re,Se])=>`${re}:${Se}`).join("|"),[gt]);function mi(re,Se){Se.stopPropagation();const Re=Qu(re,{fastMode:d,goalComposeMode:hr});switch(Re.type){case"toggleFast":wt({fastMode:Re.fastMode});break;case"runCompact":xe(null),q==null||q();break;case"enterGoalCompose":ql();break;case"exitGoalCompose":fa(),xe(null);break;case"openPanel":O(Re.panel),Re.panel==="skills"?H==null||H():Re.panel==="mcp"?G==null||G():Re.panel==="hooks"&&(T==null||T());break;case"insertPrompt":fn(Re.text),O("root"),xe(null);break}}function Yt(){const re=_e.current;return re?sm(re):null}const pi=c.useCallback(re=>{const Se=_e.current;!Se||!re||om(Se,re)},[]),mn=c.useCallback(()=>{const re=_e.current;return re?sl(re):$e},[$e]),{appendAttachments:pn,appendDroppedAttachments:ba}=Am({prompt:$e,attachments:We,updateDraft:st,getSelection:Yt,selectionSnapshotRef:Ke,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,onInserted:()=>xe(null)}),va=c.useCallback((re,Se)=>{var Re;if(At(),P){P({kind:re,appendAttachments:(Ze,lt=re)=>pn(Ze,lt),defaultPick:()=>{var Ze;return(Ze=Se.current)==null?void 0:Ze.click()}});return}(Re=Se.current)==null||Re.click()},[pn,At,P]);function fn(re){if(!re)return;const Se=Yt()??Ke.current,Re=(Se==null?void 0:Se.start)??$e.length,Ze=(Se==null?void 0:Se.end)??Re,lt=gu(re),Zt=`${$e.slice(0,Re)}${lt}${$e.slice(Ze)}`;st(Xi=>({prompt:Zt,attachments:Xi.attachments}));const _t=Re+lt.length;it.current={start:_t,end:_t},Ke.current={start:_t,end:_t}}Km({promptRef:_e,isShellView:Ve,prompt:$e,promptSegments:hi,attachmentPreviewUrls:gt,previewSignature:ui,editorSanitizeNonce:rt,pendingSelectionRef:it,pendingInsertedAttachmentIdsRef:tt,selectionSnapshotRef:Ke,renderedPreviewSignatureRef:dt,renderedSanitizeNonceRef:ft,serializeEditorPrompt:mn,restoreSelection:pi});function At(){var re;(re=_e.current)==null||re.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function fi(){var re;if(At(),xe(null),!!((re=navigator.clipboard)!=null&&re.readText))try{const Se=await navigator.clipboard.readText();fn(Se)}catch{return}}async function ka(){if(!ae.current){ae.current=!0;try{if(ut&&ct(),hr&&!Ve){await Vl();return}const re=yu({prompt:$e,attachments:We,isShellView:Ve});if(!re||await $(re)===!1)return;st(()=>({prompt:"",attachments:[]}))}finally{ae.current=!1}}}async function gi(re){re.preventDefault(),await ka()}function xi(){const re=mn(),Se=Yt();Ke.current=Se;const Re=_e.current;(Re?am(Re):!1)&&(it.current=Se,nt(lt=>lt+1)),st(lt=>({prompt:re,attachments:lt.attachments.filter(Zt=>re.includes(Zt.placeholder))}),"deferred")}function bi(re){var Ze,lt,Zt,_t;const Se=On((Ze=re.clipboardData)==null?void 0:Ze.items,(lt=re.clipboardData)==null?void 0:lt.files),Re=ju({files:Se,plainText:((Zt=re.clipboardData)==null?void 0:Zt.getData("text/plain"))??"",htmlText:((_t=re.clipboardData)==null?void 0:_t.getData("text/html"))??"",htmlToText:nm});Re.preventDefault&&re.preventDefault(),Re.type==="insert-text"?fn(Re.text):Re.type==="append-files"&&ba(Re.files)}function vi(re){var Re,Ze;const Se=es(ns((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Se.preventDefault&&re.preventDefault(),Se.activateDragTarget&&Pe(!0)}function ki(re){var Re,Ze;const Se=es(ns((Re=re.dataTransfer)==null?void 0:Re.items,(Ze=re.dataTransfer)==null?void 0:Ze.files));Se.preventDefault&&re.preventDefault(),Se.activateDragTarget&&re.dataTransfer&&(re.dataTransfer.dropEffect="copy"),Se.activateDragTarget&&Pe(!0)}function wi(re){re.currentTarget.contains(re.relatedTarget)||Pe(!1)}function yi(re){var Ze,lt;const Se=On((Ze=re.dataTransfer)==null?void 0:Ze.items,(lt=re.dataTransfer)==null?void 0:lt.files),Re=Nu(Se);Re.preventDefault&&re.preventDefault(),Re.type==="accept-files"&&(Pe(!1),ba(Re.files??[]))}function ji(re){if(re.key==="Enter"&&re.repeat){re.preventDefault();return}if(e==="chat"&&re.key==="/"&&!re.metaKey&&!re.ctrlKey&&!re.altKey&&!n&&!k&&fe.length>0&&mn().trim().length===0){re.preventDefault(),O("root"),xe("slash");return}const Se=Cu({key:re.key,metaKey:re.metaKey,ctrlKey:re.ctrlKey,busy:n,disabled:k});Se.preventDefault&&re.preventDefault(),Se.submit&&ka()}const{promptPlaceholder:Ni,interruptLabel:Ci,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:Si,effortControlsDisabled:Ti,effortControlTitle:Ei}=_u({goalComposeMode:hr,goalBusy:hn,threadConnected:y,busy:n,isShellView:Ve,disabledPlaceholder:S,settingsBusy:a,supportedEffortCount:xa.length,fastMode:d}),{composerLayerClassName:Li,formClassName:Ii,composerShellClassName:zi,composerToolbarClassName:Pi,composerIconButtonClassName:Ri,composerMenuClassName:Mi,composerMenuItemClassName:Ai,composerInlineToggleClassName:_i,composerPanelButtonClassName:$i,composerChipButtonClassName:Di,composerPlanToggleActiveClassName:Bi,composerSendButtonClassName:Gi,composerPromptRegionClassName:Fi,promptInputClassName:Hi,graphChatInputGroupClassName:Oi,graphChatInputClassName:Wi}=$u({isShellView:Ve,edgeToEdgeMobile:r,isMobileShell:X,openMenu:ce!==null,isDragTargetActive:Ne,busy:n}),Ui=ep({isShellView:Ve,canToggleShellView:M,isMobileShell:X,shellPromptLabel:ge,openMenu:ce,toolbarClassName:Pi,iconButtonClassName:Ri,menuClassName:Mi,menuItemClassName:Ai,panelButtonClassName:$i,chipButtonClassName:Di,inlineToggleClassName:_i,planToggleActiveClassName:Bi,sendButtonBaseClassName:Gi,slashPanelView:I,availableToolboxItems:fe,busy:n,settingsBusy:a,compactBusy:o,forkBusy:A,fastMode:d,goalComposeMode:hr,goalBusy:hn,goalStatus:(ja=J.data)==null?void 0:ja.status,activeView:e,disabled:k,model:l,modelOptions:f,modelContextTitle:ci,contextUsage:p,reasoningEffort:i,supportedEfforts:xa,displayedCollaborationMode:Rt,sandboxMode:u,sendButtonLabel:wa,sendButtonClassName:ya,modelControlsDisabled:Si,effortControlsDisabled:Ti,effortControlTitle:Ei,forkTurnOptionsState:te,skillsState:Q,goalState:J,goalHistory:z,copiedSkillName:li,hooksPanelMode:Ge,hooksState:Z,hookConfigBusy:ot,hookConfigError:dn,hookConfigSuccess:cn,editingHookTarget:cr,hookScope:Ue,hookEventName:mt,hookMatcher:yt,hookCommand:Kt,hookTimeoutSec:Xt,hookStatusMessage:Mt,mcpPanelMode:be,mcpState:D,mcpConfigPath:Zl,mcpConfigError:Ql,mcpConfigSuccess:ei,mcpConfigBusy:Jl,mcpHttpName:Kl,mcpHttpUrl:Xl,mcpRawBlock:Yl,capabilities:{hostConfigFiles:Te.hostConfigFiles,hookTrust:Te.hookTrust,mcpConfigEditing:Te.mcpConfigEditing,planMode:Te.planMode,sandboxMode:m?!1:Te.sandboxMode},shellControlState:N,onToggleView:ke,onDismissPromptFocus:At,onSetOpenMenu:xe,onToolboxItemClick:mi,onSetSlashPanelView:O,onViewGoals:W,onUpdateGoal:ne,onOpenForkTurns:()=>K==null?void 0:K(),onForkLatest:pe,onForkTurn:ze,onCopySkillInvokeName:ii,onResetHookForm:Dl,onSetHooksPanelMode:Il,onClearHookConfigStatus:pa,onSetEditingHookTarget:zl,onSetHookScope:Pl,onSetHookEventName:Rl,onSetHookMatcher:Ml,onSetHookCommand:Al,onSetHookTimeoutSec:_l,onSetHookStatusMessage:$l,onSaveHook:Gl,onStartEditingHook:Bl,onTrustHook:Fl,onUntrustHook:Hl,onSetMcpPanelMode:je,onClearMcpConfigStatus:ga,onSetMcpHttpName:ti,onSetMcpHttpUrl:ri,onSetMcpRawBlock:ni,onPrepareRawMcpBlock:ai,onSaveHttpMcp:si,onSaveRawMcpBlock:oi,onPickPhoto:()=>va("photo",Qe),onPickFile:()=>va("file",et),onUpdateSettings:re=>void wt(re),onPasteShell:()=>void fi(),onCopyShell:()=>{At(),xe(null),we==null||we()},onClearShell:()=>{At(),xe(null),$({prompt:"clear"})},onShellControl:re=>{At(),xe(null),De==null||De(re)}}),{promptSlot:Vi,goalSlot:qi,shellPromptSlot:Ki}=Jm({isShellView:Ve,promptRef:_e,prompt:$e,disabled:k,promptPlaceholder:Ni,canInterrupt:Fe,interruptLabel:Ci,composerPromptRegionClassName:Fi,graphChatInputClassName:Wi,promptInputClassName:Hi,goalComposeMode:hr,goalTokenBudget:Ol,goalLocalError:Wl,goalBusy:hn,busy:n,sendButtonLabel:wa,sendButtonClassName:ya,onInterrupt:le,onPromptInput:xi,onPromptPaste:bi,onPromptKeyDown:ji,onPromptKeyUp:()=>{Ke.current=Yt()},onPromptMouseUp:()=>{Ke.current=Yt()},onPromptBlur:()=>{Ke.current=Yt(),Pe(!1),ut&&ct()},onPromptDragEnter:vi,onPromptDragOver:ki,onPromptDragLeave:wi,onPromptDrop:yi,onGoalTokenBudgetChange:Ul,onCancelGoal:fa,onShellPromptChange:di});return t.jsx(xm,{activeView:e,layerClassName:Li,formClassName:Ii,shellClassName:zi,inputGroupClassName:Oi,error:s,followTail:j,photoInputRef:Qe,fileInputRef:et,onAppendAttachments:pn,onToggleFollow:ye,canJumpToPreviousTurn:Me,onJumpToPreviousTurn:de,canJumpToNextTurn:Ce,onJumpToNextTurn:Ee,subscriptionUsage:Y,onSubmit:gi,formRef:Be,promptSlot:Vi,pendingQueueSlot:!Ve&&Ae.length>0?t.jsx(bm,{prompts:Ae,onSteer:Oe,onCancel:V}):null,toolbarSlot:t.jsx(Pm,{...Ui}),goalSlot:qi,shellPromptSlot:Ki})}var tp=c.createContext(null);function ll(){return c.useContext(tp)}function vt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Wt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function rp(e){switch(e){case"idle":return"Idle";case"running":return"Running";case"interrupted":return"Interrupted";case"failed":return"Failed";case"not_loaded":return"Not Loaded";case"system_error":return"System Error"}}function np(e){switch(e){case"idle":return"ui-status-neutral";case"running":return"ui-status-info";case"interrupted":return"ui-status-warning";case"failed":case"system_error":return"ui-status-danger";case"not_loaded":return"ui-status-neutral"}}function il(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function ap({open:e,title:r,label:n,value:a,busy:o=!1,onChange:s,onCancel:l,onSubmit:i}){if(c.useEffect(()=>{if(!e)return;function h(u){u.key==="Escape"&&!o&&l()}return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h)}},[o,l,e]),!e)return null;function d(h){h.preventDefault(),i()}return Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close rename dialog",onClick:l,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("form",{role:"dialog","aria-modal":"true","aria-label":r,onSubmit:d,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-1 text-sm text-stone-500",children:"Changes are saved only after confirmation."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:l,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5",children:[t.jsx("label",{htmlFor:"rename-dialog-input",className:"text-sm font-medium text-stone-200",children:n}),t.jsx("input",{id:"rename-dialog-input","aria-label":n,autoFocus:!0,value:a,onChange:h=>s(h.target.value),className:"mt-2 w-full rounded-2xl border border-stone-700 bg-stone-950 px-4 py-3 text-stone-100 outline-none transition focus:border-amber-300"})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:l,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"submit",disabled:o||!a.trim(),className:"ui-action-success rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:"Save"})]})]})]}),document.body)}function sp({children:e,effectiveTheme:r,layoutMode:n,themeMode:a,viewportConstrained:o}){return t.jsx("div",{className:`thread-ui-shell ${r==="dark"?"thread-ui-theme-dark dark":""} ${o?"thread-ui-viewport-constrained":""} ${o?"h-[100svh] max-h-[100svh] min-h-0 overflow-hidden overscroll-none":"min-h-[100svh] overflow-hidden"} bg-[#f6f8fb] text-slate-900 transition-colors duration-200 sm:p-2`,"data-theme-effective":r,"data-theme-mode":a??r,"data-thread-layout":n,children:e})}function op({children:e,roomsRailCollapsed:r}){return t.jsx("div",{className:`thread-shell-frame relative h-full min-h-0 ${r?"is-rail-collapsed sm:grid-cols-[56px_minmax(0,1fr)]":"sm:grid-cols-[264px_minmax(0,1fr)]"}`,children:e})}function lp({onClose:e,open:r}){return r?t.jsx("button",{type:"button","aria-hidden":"true",tabIndex:-1,className:"thread-mobile-only-block thread-mobile-scrim fixed inset-0 z-40 bg-slate-950/35 backdrop-blur-[1px]",onClick:e}):null}function ip({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function dp({children:e}){return t.jsx("main",{className:"thread-shell-main h-full min-h-0 min-w-0 overflow-hidden",children:t.jsx("div",{className:"thread-main-panel thread-shell-card flex h-full min-h-0 flex-col overflow-hidden bg-white shadow-[0_10px_30px_rgba(15,23,42,0.04)] sm:rounded-[12px] sm:border sm:border-slate-200/80",children:e})})}function cp({children:e}){return t.jsx("div",{className:"thread-topbar-surface flex shrink-0 flex-col border-b border-slate-200 bg-white pt-[env(safe-area-inset-top)] sm:pt-0",children:e})}function hp({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}Lo();Pt();function cs({...e}){return t.jsx(td,{"data-slot":"dialog",...e})}function hs({...e}){return t.jsx(rd,{"data-slot":"dialog-trigger",...e})}function up({...e}){return t.jsx(ld,{"data-slot":"dialog-portal",...e})}function mp({className:e,...r}){return t.jsx(id,{"data-slot":"dialog-overlay",className:at("fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",e),...r})}function us({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(up,{"data-slot":"dialog-portal",children:[t.jsx(mp,{}),t.jsxs(nd,{"data-slot":"dialog-content",className:at("fixed left-[50%] top-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",r),...a,children:[e,n?t.jsxs(ad,{"data-slot":"dialog-close",className:"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(_.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function ms({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:at("flex flex-col gap-2 text-center sm:text-left",e),...r})}function ps({className:e,...r}){return t.jsx(sd,{"data-slot":"dialog-title",className:at("text-lg font-semibold leading-none",e),...r})}function fs({className:e,...r}){return t.jsx(od,{"data-slot":"dialog-description",className:at("text-sm text-muted-foreground",e),...r})}var pp=[{value:"system",label:"Follow system",icon:_.Monitor},{value:"dark",label:"Dark",icon:_.Moon},{value:"light",label:"Light",icon:_.Sun}];function fp({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),b=a[e.workspaceId],w=b&&!n?b:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const N=e.providerSessionId;if(N)try{await navigator.clipboard.writeText(N),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const y=()=>o(e.id),v=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,k=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(_.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),i(e)},"aria-label":`Rename thread ${e.title}`,title:"Rename thread",className:"thread-card-quiet-button inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(_.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:N=>{N.stopPropagation(),N.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:f==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[w?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:w,children:w}):t.jsx("span",{className:"min-w-0 flex-1","aria-hidden":"true"}),t.jsx("span",{className:`shrink-0 rounded-full border px-1.5 py-0.5 text-[9px] uppercase tracking-normal ${np(e.status)}`,children:rp(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:vt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),N.preventDefault(),d(e)},"aria-label":`Delete thread ${e.title}`,className:"thread-card-danger-button shrink-0 rounded-full p-1 transition",title:"Delete thread",children:t.jsx(_.Trash2,{className:"h-3.5 w-3.5"})}):null]}),S=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:k,className:v,onClick:y})}):S?t.jsx("a",{href:S,onClick:N=>{N.preventDefault(),y()},title:m?e.title:void 0,className:v,children:k}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),y())},title:m?e.title:void 0,className:v,children:k})}function gp({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(b=>t.jsx(fp,{thread:b,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},b.id))})})}function xp({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:b=null,currentWorkspaceLabel:w=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:v,metaContent:k,settingsContent:S,globalSettingsContent:N,workspaceLabels:L={},workspaceReturnHref:R,onWorkspaceReturn:P,getThreadHref:Q,onOpenThread:D,getNewThreadHref:Z,newThreadHref:J,newThreadLabel:z="New Chat",onNewThread:te,onNewThreadTitle:se,renderNewThreadDialogContent:$,renderThreadLink:le,onCloseAppNavigation:q,onRenameThread:H,onDeleteThread:G,workspaceContent:T,workspaceTitle:F="Workspace",workspaceActions:B,children:E}){const C=ll(),W=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[U,ne]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),K=i??(C==null?void 0:C.themeMode)??"system",ie=l??(C==null?void 0:C.effectiveTheme)??(K==="system"?U?"dark":"light":K),[ee,ve]=c.useState(!1),[oe,ye]=c.useState(!1),[Me,de]=c.useState(!W),[Ce,Ee]=c.useState(W),[Y,ue]=c.useState("chat"),[ke,we]=c.useState(null),[De,Fe]=c.useState(""),[Ae,Oe]=c.useState(null),[V,ce]=c.useState(!1),[xe,I]=c.useState(""),[O,ae]=c.useState(!1),[be,je]=c.useState(!1),[Te,fe]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(max-width: 639px)"),pe=()=>{Ee(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const A=window.matchMedia("(prefers-color-scheme: dark)"),pe=()=>{ne(A.matches)};return pe(),A.addEventListener("change",pe),()=>{A.removeEventListener("change",pe)}},[]);const Be=c.useMemo(()=>[...b?e.filter(pe=>pe.workspaceId===b):e].sort((pe,ze)=>{if(pe.id===p)return-1;if(ze.id===p)return 1;const Ge=Date.parse(pe.lastTurnStartedAt??pe.updatedAt);return Date.parse(ze.lastTurnStartedAt??ze.updatedAt)-Ge}),[p,b,e]),_e=J??(Z==null?void 0:Z(b)),Qe=w??b??"all",et=x??g??p??"default_session",it=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),tt=d??(C==null?void 0:C.setThemeMode),Ke=!!tt,dt=()=>{ve(!1),q==null||q()};async function ft(A){if(!H)return;const pe=De.trim();if(pe){Oe(A);try{await H(A,pe),we(null),Fe("")}finally{Oe(null)}}}function Ve(A){we(A.id),Fe(A.title)}function M(){we(null),Fe("")}function X(A){D==null||D(A),dt()}function ge(){ce(!1),I("")}function Ne(A){if(!_e||!A.trim())return _e;try{const pe=new URL(_e,window.location.origin);return pe.searchParams.set("title",A.trim()),`${pe.pathname}${pe.search}${pe.hash}`}catch{const pe=_e.includes("?")?"&":"?";return`${_e}${pe}title=${encodeURIComponent(A.trim())}`}}async function Pe(){const A=xe.trim();ae(!0);try{if(A&&se){await se(A),I(""),ce(!1),dt();return}if(_e){window.location.assign(Ne(A)??_e);return}await(te==null?void 0:te()),I(""),ce(!1),dt()}finally{ae(!1)}}function rt(A,pe=!1){const ze=pe?t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:z})]}):t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:z})]});return t.jsxs(cs,{open:V,onOpenChange:Ge=>{O||ce(Ge)},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":pe?z:void 0,title:z,className:A,children:ze})}),t.jsx(us,{"data-testid":"create-thread-dialog","data-theme-effective":ie,"data-theme-mode":K,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:$?$({close:ge,closeNavigation:dt,currentWorkspaceId:b}):t.jsxs(t.Fragment,{children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Create New Chat"}),t.jsx(fs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:xe,onChange:Ge=>I(Ge.target.value),onKeyDown:Ge=>{Ge.key==="Enter"&&(Ge.preventDefault(),Pe())},placeholder:"Chat name","aria-label":"Chat name",autoComplete:"off",className:"thread-graph-create-thread-input h-10 rounded-md border px-3 text-sm outline-none transition"}),t.jsx("button",{type:"button",onClick:()=>void Pe(),disabled:O,className:"thread-graph-create-thread-submit inline-flex h-10 items-center justify-center rounded-md px-4 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:O?"Creating...":"Create"})]})]})})]})}function nt(){if(!S&&!k&&!N&&!Ke)return null;const A=!!(S||k),pe=!!N,ze=A&&pe,Ge=Te==="global"&&pe||!A&&pe?"global":"session";return t.jsxs(cs,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(hs,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":"Open settings",title:"Settings",className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",children:t.jsx(_.Settings,{className:"h-4 w-4"})})}),t.jsxs(us,{"data-testid":"settings-dialog","data-theme-effective":ie,"data-theme-mode":K,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(ms,{children:[t.jsx(ps,{children:"Settings"}),t.jsx(fs,{children:"Manage this session and host-wide preferences."})]}),Ke?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:t.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"font-medium text-[var(--theme-fg)]",children:"Appearance"}),t.jsxs("p",{className:"mt-1 text-xs leading-5 text-[var(--theme-fg-muted)]",children:["Current theme: ",ie]})]}),t.jsx("div",{className:"thread-graph-theme-mode-group grid grid-cols-3 gap-1 rounded-lg border p-1",role:"group","aria-label":"Theme mode",children:pp.map(Ue=>{const mt=Ue.icon,yt=K===Ue.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ue.value}`,"aria-pressed":yt,disabled:!Ke,onClick:()=>tt==null?void 0:tt(Ue.value),className:`thread-graph-theme-mode-button inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-medium transition ${yt?"is-selected":""}`,children:[t.jsx(mt,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ue.label})]},Ue.value)})})]})}):null,ze?t.jsxs("div",{className:"thread-graph-settings-tabs grid grid-cols-2 gap-1 rounded-lg border p-1",children:[t.jsx("button",{type:"button","aria-pressed":Ge==="session",onClick:()=>fe("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ge==="global",onClick:()=>fe("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ge==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ge==="session"?t.jsxs("div",{className:"grid gap-4",children:[S?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:S}):null,k?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:k}):null,A?null:t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3 text-[var(--theme-fg-muted)]",children:"No session settings are available."})]}):t.jsx("div",{className:"thread-graph-settings-global-content",children:N})})]})]})}function $e(A=!1){return t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:t.jsxs("section",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:`mb-3 flex items-center gap-2 px-2 text-xs font-medium tracking-normal text-[var(--theme-fg-muted)] ${A?"justify-center":""}`,children:[t.jsx(_.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:A?"sr-only":"",children:"Rooms"}),!A&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&Be.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,Be.length>0?t.jsx(gp,{threads:Be,currentThreadId:p,currentWorkspaceId:b,workspaceLabels:L,onOpenThread:X,collapsed:A,...H?{onBeginRenameThread:Ve}:{},showDeleteButton:!!G,...Q?{getThreadHref:Q}:{},...le?{renderThreadLink:le}:{},...G?{onDeleteThread:G}:{}}):null]})]})})}function We(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>de(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})}),B?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:B})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:F}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:w??b??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[B,t.jsx("button",{type:"button",onClick:()=>de(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:w??b??"All threads"})]})]})})]})}const ut=!!T,st=s==="mobile"||s==="responsive"&&Ce,ct=st,gt=ct&&!ee,wt=!!(R||P)?t.jsx("a",{href:R??"#",onClick:A=>{P&&(A.preventDefault(),P())},className:"thread-icon-button inline-flex h-10 w-10 items-center justify-center rounded-full sm:h-9 sm:w-9",title:"Back to workspace","aria-label":"Back to workspace",children:t.jsx(_.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(sp,{effectiveTheme:ie,layoutMode:s,themeMode:K,viewportConstrained:o,children:t.jsxs(op,{roomsRailCollapsed:oe,children:[t.jsx(lp,{open:ee,onClose:()=>ve(!1)}),t.jsxs(ip,{collapsed:oe,mobileOpen:ee,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${oe?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${oe?"sm:justify-center":"justify-between"}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("button",{type:"button",onClick:()=>ye(A=>!A),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:oe?"Expand rooms":"Collapse rooms","aria-label":oe?"Expand rooms":"Collapse rooms",children:oe?t.jsx(_.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(_.PanelLeftClose,{className:"h-4 w-4"})}),t.jsx("div",{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[var(--theme-accent-solid)] text-sm font-semibold text-[var(--theme-accent-solid-fg)] ${oe?"thread-desktop-collapsed-hidden":""}`,children:(w??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${oe?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:w??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${oe?"thread-desktop-collapsed-hidden":""}`,children:[nt(),wt,t.jsx("button",{type:"button",onClick:()=>ve(!1),"aria-label":"Close rooms",title:"Close rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:t.jsx(_.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${oe?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:rt(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${oe?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,oe)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${oe?"w-full px-2 py-2":"px-3 py-3"}`,children:$e(oe)})]}),t.jsxs(dp,{children:[t.jsx(cp,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[gt?t.jsx("button",{type:"button",onClick:()=>ve(!0),"aria-label":"Open rooms",title:"Open rooms",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full",children:t.jsx(_.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"min-w-0 truncate text-sm font-semibold leading-tight text-[var(--theme-fg)] sm:text-base",title:g??"Shared Workspace",children:g??"Shared Workspace"}),t.jsxs("div",{className:"relative mt-0.5 flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{je(A=>!A)},"aria-expanded":be,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:Qe})]}),be?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var A;et&&((A=navigator.clipboard)==null||A.writeText(et))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-start gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"min-w-0 whitespace-normal break-words font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||v?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,v]}):null,ct&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,ct&&ut?t.jsx("button",{type:"button",onClick:()=>ue(A=>A==="workspace"?"chat":"workspace"),"aria-label":Y==="workspace"?"Show chat":"Show workspace",title:Y==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:Y==="workspace"?t.jsx(_.MessageSquare,{className:"h-4 w-4"}):t.jsx(_.Folder,{className:"h-4 w-4"})}):null,ct?f:null,ct&&h?rt("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(hp,{children:ut&&!Me?st?t.jsxs("div",{className:"thread-split-container thread-graph-shell-mobile-split h-full min-h-0 overflow-hidden",children:[t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Y==="chat"?"block":"thread-mobile-chat-hidden"}`,children:E}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${Y==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:We()})]}):t.jsxs(Mn,{direction:"horizontal",className:"thread-split-container thread-graph-shell-resizable thread-graph-shell-desktop-split h-full min-h-0 overflow-hidden",children:[t.jsx(sr,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:E}),t.jsx(An,{className:"thread-resize-handle w-2 bg-transparent after:w-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(sr,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:We()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ut&&Me?t.jsx("button",{type:"button",onClick:()=>de(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(_.ChevronsLeft,{className:"h-4 w-4"})}):null,E]})})]})]})}),t.jsx(ap,{open:ke!==null,title:"Rename Thread",label:"Thread Title",value:De,busy:Ae!==null,onChange:Fe,onCancel:M,onSubmit:()=>ke?ft(ke):void 0})]})}function bp({open:e,title:r,text:n,onClose:a}){return c.useEffect(()=>{if(!e)return;function o(s){s.key==="Escape"&&a()}return window.addEventListener("keydown",o),()=>{window.removeEventListener("keydown",o)}},[a,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[90] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close full text",onClick:a,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] flex max-h-[min(82vh,52rem)] w-full max-w-4xl flex-col overflow-hidden rounded-[1.8rem] border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-stone-800 px-4 py-3 sm:px-5",children:[t.jsx("p",{className:"truncate text-sm font-medium text-stone-100",children:r}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,className:"inline-flex h-9 w-9 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto px-4 py-4 sm:px-5",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words text-sm leading-6 text-stone-200",children:n})})]})]}),document.body):null}var vp=[/^(?: {0,3})#{1,6}\s+\S/m,/^(?: {0,3})>{1,}\s*\S/m,/^(?: {0,3})(?:[-+*]|\d{1,9}[.)])\s+(?:\[[ xX]\]\s+)?\S/m,/^(?: {0,3})(?:```|~~~)/m,/^(?: {0,3})(?:[-*_]\s*){3,}$/m],kp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,wp=/!?\[[^\]\n]+\]\([^)]+\)/,yp=/`[^`\n]+`/,jp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Np=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,Cp=/~~[^~\n]+~~/;function Sp(e){const r=e.trim();return r?vp.some(n=>n.test(r))||kp.test(r)?!0:/[`[\]*_~!]/.test(r)?wp.test(r)||yp.test(r)||jp.test(r)||Np.test(r)||Cp.test(r):!1:!1}rn();function Vn(e,r){const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{var l,i;return{...s.manifest,enabled:((l=n.get(s.manifest.id))==null?void 0:l.enabled)??!0,source:((i=n.get(s.manifest.id))==null?void 0:i.source)??"builtin"}}),o=new Set(e.map(s=>s.manifest.id));for(const s of r)o.has(s.id)||a.push(s);return a}function ia(e=[]){const r=Vn(e,[]),n=e;return{plugins:r,loading:!1,error:null,async refresh(){},async importPluginManifest(){},async setPluginEnabled(){},async uninstallPlugin(){},renderArtifact:s=>{var i;const l=n.find(d=>d.renderArtifact&&d.manifest.capabilities.artifactTypes.some(h=>h.type===s.artifact.type));return((i=l==null?void 0:l.renderArtifact)==null?void 0:i.call(l,s))??null},renderInlineCode:s=>{for(const l of n)for(const i of l.inlineCodeRenderers??[]){if(!i.languages.includes(s.language.trim().toLowerCase()))continue;const d=i.render(s);if(d)return d}return null},hasRendererForArtifact:s=>n.some(l=>!!l.renderArtifact&&l.manifest.capabilities.artifactTypes.some(i=>i.type===s.type)),getThreadPanels:()=>n.flatMap(s=>s.threadPanels??[])}}var da=c.createContext(ia());function ca(){return c.useContext(da)??ia()}Lr();function dl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function gs(e){return dl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function cl(e){return typeof e=="string"?t.jsxs("span",{className:"thread-graph-tool-string",children:['"',e,'"']}):typeof e=="number"?t.jsx("span",{className:"thread-graph-tool-number",children:e}):typeof e=="boolean"?t.jsx("span",{className:"thread-graph-tool-boolean",children:String(e)}):e===null?t.jsx("span",{className:"thread-graph-tool-null",children:"null"}):typeof e=="object"?t.jsx("span",{className:"thread-graph-tool-object",children:JSON.stringify(e)}):t.jsx("span",{children:String(e)})}function Tp(e,r){return typeof r=="string"&&(e==="stdout"||e==="stderr"||e==="result")?t.jsx("pre",{className:"thread-graph-tool-output",children:r||"(empty)"}):typeof r=="object"&&r!==null?t.jsx("pre",{className:"thread-graph-tool-output",children:JSON.stringify(r,null,2)}):cl(r)}function xs({callId:e,toolName:r,status:n,parameters:a,result:o}){const s=c.useMemo(()=>{switch(n){case"completed":return{className:"is-completed",icon:t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>gs(o),[o]),i=c.useMemo(()=>gs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:dl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsx(nn,{className:"thread-graph-tool-trigger px-4 py-3 hover:no-underline",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(_.Wrench,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:r}),t.jsxs("span",{className:`thread-graph-tool-badge ${s.className}`,title:s.label,"aria-label":`Status: ${s.label}`,children:[s.icon,t.jsx("span",{className:"thread-graph-status-label",children:s.label})]})]})}),t.jsxs(Er,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),cl(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Tp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var bs=null;function Ep(){return bs??(bs=Promise.all([Xe(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Xe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Xe(()=>import("./ayu-light-BA47KaF1.js"),[]),Xe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Xe(()=>import("./javascript-wDzz0qaB.js"),[]),Xe(()=>import("./typescript-BPQ3VLAy.js"),[]),Xe(()=>import("./tsx-COt5Ahok.js"),[]),Xe(()=>import("./jsx-g9-lgVsj.js"),[]),Xe(()=>import("./python-B6aJPvgy.js"),[]),Xe(()=>import("./json-Cp-IABpG.js"),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Xe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Xe(()=>import("./yaml-Buea-lGh.js"),[]),Xe(()=>import("./toml-vGWfd6FD.js"),[]),Xe(()=>import("./markdown-Cvjx9yec.js"),[]),Xe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Xe(()=>import("./css-CLj8gQPS.js"),[]),Xe(()=>import("./sql-CRqJ_cUM.js"),[]),Xe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,b,w,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,b.default,w.default,x.default,j.default]}))),bs}function an(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function qn(e){if(!e)return{};if(an(e)&&Object.prototype.hasOwnProperty.call(e,"0"))try{const r=Object.keys(e).map(Number).filter(n=>Number.isFinite(n)).sort((n,a)=>n-a).map(n=>String(e[String(n)]??"")).join("");return JSON.parse(r)}catch{return e}if(typeof e=="string")try{return JSON.parse(e)}catch{return e}return e}function Kn(){return{finalResult:null,stdout:"",stderr:""}}function Lp(e){return typeof e=="string"?{result:e}:e}function hl(e){const r=an(e.finalResult)?{...e.finalResult}:e.finalResult!=null?{result:e.finalResult}:{};return e.stdout&&(r.stdout=e.stdout),e.stderr&&(r.stderr=e.stderr),!("status"in r)&&(e.stdout||e.stderr)&&(r.status="pending"),r}function vs(e){if(!e)return"pending";if(!an(e))return"completed";const r=e.status;return r==="stream"||r==="pending"||r==="running"?"pending":r==="failed"||r==="error"||r==="timed_out"||typeof e.exit_code=="number"&&e.exit_code!==0?"failed":"completed"}function Ip(e){const r=new Map,n=/```tool-result\s*([\s\S]*?)\s*```/g,a=e.replace(n,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id;if(typeof h!="string")return l;const u=Lp(d.result),m=r.get(h)??Kn();return an(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=qn(d.args);if(typeof h=="string"&&r.has(h)){const f=hl(r.get(h)??Kn());return`\`\`\`tool-merged
3657
3690
  ${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
3658
- \`\`\``}return l}catch{return l}}),resultMap:r}}var Tp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function ks(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ws(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Ep(e){if(!e||typeof e!="object"||!("position"in e))return{startLine:void 0,endLine:void 0};const r=e.position;if(!r||typeof r!="object")return{startLine:void 0,endLine:void 0};const n=r.start,a=r.end,o=n&&typeof n=="object"?n.line:void 0,s=a&&typeof a=="object"?a.line:void 0;return{startLine:typeof o=="number"?o:void 0,endLine:typeof s=="number"?s:void 0}}function Lp(e){if(!e)return null;let r=e.trim();if(!r)return null;try{if(typeof window>"u")return null;const s=new URL(r,window.location.origin);if(s.origin!==window.location.origin&&s.protocol!=="file:")return null;r=(s.protocol==="file:",s.pathname)}catch{}try{r=decodeURIComponent(r)}catch{}if(!r.startsWith("/")||Tp.some(s=>r===s||r.startsWith(s)))return null;const n=r.match(/:(\d+)(?::\d+)?$/),a=n?Number.parseInt(n[1]??"",10):void 0,o=n?r.slice(0,-n[0].length):r;return!o||o==="/"?null:{path:o,...Number.isFinite(a)?{line:a}:{}}}function Ip({children:e,...r}){return zp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function zp(e){var n;if(!e||typeof e!="object"||!("props"in e))return!1;const r=(n=e.props)==null?void 0:n.className;return typeof r!="string"?!1:r.includes("language-tool-call")||r.includes("language-tool-merged")||r.includes("language-tool-result")}var Pp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const o=c.useRef(null),s=ca(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>Sp(n),[n]);c.useEffect(()=>{let k=!0;return Np().then(x=>{k&&i(x)}).catch(()=>{}),()=>{k=!1}},[]),c.useEffect(()=>{const k=o.current,x=k==null?void 0:k.closest(".thread-ui-shell"),j=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(j()),!x)return;const w=new MutationObserver(()=>m(j()));return w.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>w.disconnect()},[]);async function g(k,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[k]:"copied"})),window.setTimeout(()=>{h(j=>{const w={...j};return delete w[k],w})},1200)}catch{h(j=>({...j,[k]:"failed"}))}}const b=({children:k,className:x,inline:j,node:w,...y})=>{var $;const v=/language-(\w+(?:-\w+)*)/.exec(x||""),S=v?v[1]??"":"",N=ws(k).replace(/\n$/,""),{startLine:I,endLine:M}=Ep(w),R=j===!1||!!x||N.includes(`
3659
- `)||I!==M;if(S==="tool-merged"){let Y={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Y=JSON.parse(N)}catch{Y={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const Z=typeof Y.call.tool=="string"?Y.call.tool:"Unknown",P=typeof Y.call.call_id=="string"?Y.call.call_id:void 0;return t.jsx(xs,{callId:P,toolName:Z,status:vs(Y.result),parameters:Kn(Y.call.args),result:Y.result})}if(S==="tool-call"){let Y={tool:"Unknown",args:{},call_id:void 0};try{Y=JSON.parse(N)}catch{Y={tool:"Error",args:{raw:N}}}const Z=typeof Y.call_id=="string"?Y.call_id:void 0,P=Z&&p.has(Z)?hl(p.get(Z)??qn()):void 0;return t.jsx(xs,{callId:Z,toolName:typeof Y.tool=="string"?Y.tool:"Unknown",status:P?vs(P):"pending",parameters:Kn(Y.args),result:P})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const Y=s.renderInlineCode({code:N,isIncomplete:!1,language:S});if(c.isValidElement(Y))return Y}if(R){const Z=((($=l==null?void 0:l.getLoadedLanguages)==null?void 0:$.call(l))??[]).includes(S)?S:"text",P=u?"ayu-dark":"ayu-light",te=`${S||"text"}:${N.length}:${N.slice(0,32)}`;let oe="";if(l)try{oe=ks(l.codeToHtml(N,{lang:Z,theme:P}))}catch{oe=ks(l.codeToHtml(N,{lang:"text",theme:P}))}return t.jsxs("div",{className:"thread-graph-code-block not-prose relative my-3 overflow-auto rounded-xl border p-3 text-sm shadow-sm",children:[t.jsx(Nr,{type:"button",onClick:()=>void g(te,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[te]==="copied"?"Copied":d[te]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}),oe?t.jsx("div",{dangerouslySetInnerHTML:{__html:oe}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:N})})]})}const Q=ws(k).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${x||""}`,...y,children:Q})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(Cd,{remarkPlugins:[Td,Ed],rehypePlugins:[Sd],components:{a({href:k,children:x,...j}){const w=Lp(k);return w&&a?t.jsx("a",{...j,href:k,className:"thread-inline-link",onClick:y=>{y.preventDefault(),a(w)},children:x}):t.jsx("a",{...j,href:k,className:"thread-inline-link",children:x})},code:b,pre:Ip},children:f})})}),ys=2400,Rp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,Mp=/[),.;:!?]+$/;function Ap(e){return e.startsWith("www.")?`https://${e}`:e}function js(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function _p(e){var s;if(!e)return[];const r=/\[(PHOTO|FILE)\s+([^\]]+)\]/g,n=[];let a=0,o=0;for(const l of e.matchAll(r)){const i=l.index??0;i>a&&(n.push({type:"text",key:`text-${o}`,text:e.slice(a,i)}),o+=1);const d=l[1],h=((s=l[2])==null?void 0:s.trim())??"";d==="PHOTO"&&h?n.push({type:"photo",key:`photo-${o}`,path:h}):d==="FILE"&&h?n.push({type:"file",key:`file-${o}`,path:h}):n.push({type:"text",key:`text-${o}`,text:l[0]}),o+=1,a=i+l[0].length}return a<e.length&&n.push({type:"text",key:`text-${o}`,text:e.slice(a)}),n}function lr({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll(Rp)){const s=o[0],l=o.index??0,i=((a=s.match(Mp))==null?void 0:a[0])??"",d=i?s.slice(0,-i.length):s;d&&(l>n&&r.push(e.slice(n,l)),r.push(t.jsx("a",{href:Ap(d),target:"_blank",rel:"noreferrer",className:"thread-inline-link",children:d},`${l}-${d}`)),i&&r.push(i),n=l+s.length)}return n<e.length&&r.push(e.slice(n)),t.jsx(t.Fragment,{children:r.length>0?r:e})}var ul=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:o="",plainTextClassName:s="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),u=c.useRef(null),[m,f]=c.useState(!1),p=yp(r),g=!a&&r.length>ys,b=g&&!m?`${r.slice(0,ys).trimEnd()}
3691
+ \`\`\``}return l}catch{return l}}),resultMap:r}}var zp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function ks(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ws(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Pp(e){if(!e||typeof e!="object"||!("position"in e))return{startLine:void 0,endLine:void 0};const r=e.position;if(!r||typeof r!="object")return{startLine:void 0,endLine:void 0};const n=r.start,a=r.end,o=n&&typeof n=="object"?n.line:void 0,s=a&&typeof a=="object"?a.line:void 0;return{startLine:typeof o=="number"?o:void 0,endLine:typeof s=="number"?s:void 0}}function Rp(e){if(!e)return null;let r=e.trim();if(!r)return null;try{if(typeof window>"u")return null;const s=new URL(r,window.location.origin);if(s.origin!==window.location.origin&&s.protocol!=="file:")return null;r=(s.protocol==="file:",s.pathname)}catch{}try{r=decodeURIComponent(r)}catch{}if(!r.startsWith("/")||zp.some(s=>r===s||r.startsWith(s)))return null;const n=r.match(/:(\d+)(?::\d+)?$/),a=n?Number.parseInt(n[1]??"",10):void 0,o=n?r.slice(0,-n[0].length):r;return!o||o==="/"?null:{path:o,...Number.isFinite(a)?{line:a}:{}}}function Mp({children:e,...r}){return Ap(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function Ap(e){var n;if(!e||typeof e!="object"||!("props"in e))return!1;const r=(n=e.props)==null?void 0:n.className;return typeof r!="string"?!1:r.includes("language-tool-call")||r.includes("language-tool-merged")||r.includes("language-tool-result")}var _p=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const o=c.useRef(null),s=ca(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>Ip(n),[n]);c.useEffect(()=>{let w=!0;return Ep().then(x=>{w&&i(x)}).catch(()=>{}),()=>{w=!1}},[]),c.useEffect(()=>{const w=o.current,x=w==null?void 0:w.closest(".thread-ui-shell"),j=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(j()),!x)return;const y=new MutationObserver(()=>m(j()));return y.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function g(w,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[w]:"copied"})),window.setTimeout(()=>{h(j=>{const y={...j};return delete y[w],y})},1200)}catch{h(j=>({...j,[w]:"failed"}))}}const b=({children:w,className:x,inline:j,node:y,...v})=>{var D;const k=/language-(\w+(?:-\w+)*)/.exec(x||""),S=k?k[1]??"":"",N=ws(w).replace(/\n$/,""),{startLine:L,endLine:R}=Pp(y),P=j===!1||!!x||N.includes(`
3692
+ `)||L!==R;if(S==="tool-merged"){let Z={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Z=JSON.parse(N)}catch{Z={call:{tool:"Error",args:{raw:N}},result:{status:"failed"}}}const J=typeof Z.call.tool=="string"?Z.call.tool:"Unknown",z=typeof Z.call.call_id=="string"?Z.call.call_id:void 0;return t.jsx(xs,{callId:z,toolName:J,status:vs(Z.result),parameters:qn(Z.call.args),result:Z.result})}if(S==="tool-call"){let Z={tool:"Unknown",args:{},call_id:void 0};try{Z=JSON.parse(N)}catch{Z={tool:"Error",args:{raw:N}}}const J=typeof Z.call_id=="string"?Z.call_id:void 0,z=J&&p.has(J)?hl(p.get(J)??Kn()):void 0;return t.jsx(xs,{callId:J,toolName:typeof Z.tool=="string"?Z.tool:"Unknown",status:z?vs(z):"pending",parameters:qn(Z.args),result:z})}if(S==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(S)){const Z=s.renderInlineCode({code:N,isIncomplete:!1,language:S});if(c.isValidElement(Z))return Z}if(P){const J=(((D=l==null?void 0:l.getLoadedLanguages)==null?void 0:D.call(l))??[]).includes(S)?S:"text",z=u?"ayu-dark":"ayu-light",te=`${S||"text"}:${N.length}:${N.slice(0,32)}`;let se="";if(l)try{se=ks(l.codeToHtml(N,{lang:J,theme:z}))}catch{se=ks(l.codeToHtml(N,{lang:"text",theme:z}))}return t.jsxs("div",{className:"thread-graph-code-block not-prose relative my-3 overflow-auto rounded-xl border p-3 text-sm shadow-sm",children:[t.jsx(Nr,{type:"button",onClick:()=>void g(te,N),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[te]==="copied"?"Copied":d[te]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:d[te]==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}),se?t.jsx("div",{dangerouslySetInnerHTML:{__html:se}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:N})})]})}const Q=ws(w).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${x||""}`,...v,children:Q})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(Ed,{remarkPlugins:[Id,zd],rehypePlugins:[Ld],components:{a({href:w,children:x,...j}){const y=Rp(w);return y&&a?t.jsx("a",{...j,href:w,className:"thread-inline-link",onClick:v=>{v.preventDefault(),a(y)},children:x}):t.jsx("a",{...j,href:w,className:"thread-inline-link",children:x})},code:b,pre:Mp},children:f})})}),ys=2400,$p=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,Dp=/[),.;:!?]+$/;function Bp(e){return e.startsWith("www.")?`https://${e}`:e}function js(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Gp(e){var s;if(!e)return[];const r=/\[(PHOTO|FILE)\s+([^\]]+)\]/g,n=[];let a=0,o=0;for(const l of e.matchAll(r)){const i=l.index??0;i>a&&(n.push({type:"text",key:`text-${o}`,text:e.slice(a,i)}),o+=1);const d=l[1],h=((s=l[2])==null?void 0:s.trim())??"";d==="PHOTO"&&h?n.push({type:"photo",key:`photo-${o}`,path:h}):d==="FILE"&&h?n.push({type:"file",key:`file-${o}`,path:h}):n.push({type:"text",key:`text-${o}`,text:l[0]}),o+=1,a=i+l[0].length}return a<e.length&&n.push({type:"text",key:`text-${o}`,text:e.slice(a)}),n}function lr({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll($p)){const s=o[0],l=o.index??0,i=((a=s.match(Dp))==null?void 0:a[0])??"",d=i?s.slice(0,-i.length):s;d&&(l>n&&r.push(e.slice(n,l)),r.push(t.jsx("a",{href:Bp(d),target:"_blank",rel:"noreferrer",className:"thread-inline-link",children:d},`${l}-${d}`)),i&&r.push(i),n=l+s.length)}return n<e.length&&r.push(e.slice(n)),t.jsx(t.Fragment,{children:r.length>0?r:e})}var ul=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:o="",plainTextClassName:s="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),u=c.useRef(null),[m,f]=c.useState(!1),p=Sp(r),g=!a&&r.length>ys,b=g&&!m?`${r.slice(0,ys).trimEnd()}
3660
3693
 
3661
- ...`:r,[k,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const w=n.current,y=h.current,v=(y==null?void 0:y.getBoundingClientRect().top)??null;i==null||i(),u.current=w&&v!==null?{root:w,top:v}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const w=u.current,y=h.current;if(!w||!y)return;u.current=null;const v=()=>{const N=y.getBoundingClientRect().top;w.root.scrollTop+=N-w.top};v();const S=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(k||!h.current)return;const w=new IntersectionObserver(y=>{for(const v of y)if(v.isIntersecting){x(!0),w.disconnect();break}},{root:n.current,threshold:0});return w.observe(h.current),()=>{w.disconnect()}},[k,n,a]),t.jsxs("div",{ref:h,className:o,children:[k&&p?t.jsx(Pp,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:s,children:t.jsx(lr,{text:b})}),g?t.jsx("button",{type:"button",onClick:j,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),$p=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o,onOpenWorkspaceFile:s}){return t.jsx(ul,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{},...s?{onOpenWorkspaceFile:s}:{}})}),Dp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>_p(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:s.map(l=>{if(l.type==="text")return t.jsx("span",{children:l.text},l.key);if(l.type==="photo"){const d=(a==null?void 0:a[l.path])??(r?(o==null?void 0:o({threadId:r,path:l.path}))??null:null),h=js(l.path)||"Attached image";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-full flex-col rounded-[1rem] border border-sky-300/28 bg-sky-300/[0.08] p-1.5 shadow-sm shadow-stone-950/20",children:[d?t.jsx("img",{src:d,alt:h,className:"h-[4.5rem] w-[6rem] rounded-[0.75rem] bg-stone-950 object-contain",loading:"lazy"}):t.jsx("span",{className:"inline-flex h-[4.5rem] w-[6rem] items-center justify-center rounded-[0.75rem] bg-stone-950 text-[10px] text-sky-100",children:"PHOTO"}),t.jsx("span",{className:"mt-1 max-w-[7rem] truncate text-[10px] font-medium tracking-[0.08em] text-sky-50",title:l.path,children:h})]})},l.key)}const i=js(l.path)||"Attached file";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-[12rem] items-center gap-2 rounded-[0.95rem] border border-emerald-300/28 bg-emerald-300/[0.08] px-2.5 py-2 text-[10px] font-medium tracking-[0.08em] text-emerald-50 shadow-sm shadow-stone-950/20",title:l.path,children:[t.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/20 bg-emerald-300/12 text-[9px]",children:"FILE"}),t.jsx("span",{className:"min-w-0 truncate",children:i})]})},l.key)})})});function Bp(){return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(e=>t.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-sky-200/90",style:{animationDelay:`${e*180}ms`}},e))})}function Ns({status:e}){if(!e)return null;const r=e.toLowerCase(),n=r.includes("running")||r.includes("generating")||r.includes("steering"),a=r.includes("failed")||r.includes("error"),o=r.includes("accepted")||r.includes("complete"),s=n?"ui-status-warning":a?"ui-status-danger":o?"ui-status-success":"ui-status-neutral",l=n?t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}):o?t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(D.Circle,{className:"h-3.5 w-3.5"});return t.jsxs("span",{className:`thread-graph-message-status inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-normal ${s}`,title:e,"aria-label":`Status: ${e}`,children:[t.jsx("span",{className:"thread-graph-message-status-icon inline-flex shrink-0",children:n?t.jsx(Bp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Gp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:o,status:s,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{title:i??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:l}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":d?"user":"assistant",className:"thread-graph-message flex justify-start",children:t.jsxs("div",{className:`thread-graph-message-bubble min-w-0 w-full max-w-full ${d?"is-user":"is-assistant"}`,children:[d?null:t.jsxs("div",{className:"thread-graph-message-header mb-2 flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"thread-graph-message-sender rounded-full px-2.5 py-1 text-xs font-semibold tracking-[0.02em]",children:"Assistant"}),t.jsx(Ns,{status:s??"Complete"})]}),a?t.jsx("div",{className:"thread-graph-message-header-meta flex min-w-0 flex-1 justify-center",children:a}):null,r||h?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,h]}):null]}),o,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(s||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[s?t.jsx(Ns,{status:s}):null,h]}):null]})})}Lr();function Fp(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Hp({tone:e="amber"}){const r=e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}var It=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:o=!1,adapter:s,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],b=g.map(N=>N.text.trim()).filter(Boolean).join(`
3694
+ ...`:r,[w,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,v=h.current,k=(v==null?void 0:v.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&k!==null?{root:y,top:k}:null,f(S=>!S)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,v=h.current;if(!y||!v)return;u.current=null;const k=()=>{const N=v.getBoundingClientRect().top;y.root.scrollTop+=N-y.top};k();const S=window.requestAnimationFrame(k);return()=>{window.cancelAnimationFrame(S)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(w||!h.current)return;const y=new IntersectionObserver(v=>{for(const k of v)if(k.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[w,n,a]),t.jsxs("div",{ref:h,className:o,children:[w&&p?t.jsx(_p,{content:b,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:s,children:t.jsx(lr,{text:b})}),g?t.jsx("button",{type:"button",onClick:j,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),Fp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o,onOpenWorkspaceFile:s}){return t.jsx(ul,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{},...s?{onOpenWorkspaceFile:s}:{}})}),Hp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>Gp(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:s.map(l=>{if(l.type==="text")return t.jsx("span",{children:l.text},l.key);if(l.type==="photo"){const d=(a==null?void 0:a[l.path])??(r?(o==null?void 0:o({threadId:r,path:l.path}))??null:null),h=js(l.path)||"Attached image";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-full flex-col rounded-[1rem] border border-sky-300/28 bg-sky-300/[0.08] p-1.5 shadow-sm shadow-stone-950/20",children:[d?t.jsx("img",{src:d,alt:h,className:"h-[4.5rem] w-[6rem] rounded-[0.75rem] bg-stone-950 object-contain",loading:"lazy"}):t.jsx("span",{className:"inline-flex h-[4.5rem] w-[6rem] items-center justify-center rounded-[0.75rem] bg-stone-950 text-[10px] text-sky-100",children:"PHOTO"}),t.jsx("span",{className:"mt-1 max-w-[7rem] truncate text-[10px] font-medium tracking-[0.08em] text-sky-50",title:l.path,children:h})]})},l.key)}const i=js(l.path)||"Attached file";return t.jsx("span",{className:"mx-[0.14rem] inline-flex align-middle",children:t.jsxs("span",{className:"inline-flex max-w-[12rem] items-center gap-2 rounded-[0.95rem] border border-emerald-300/28 bg-emerald-300/[0.08] px-2.5 py-2 text-[10px] font-medium tracking-[0.08em] text-emerald-50 shadow-sm shadow-stone-950/20",title:l.path,children:[t.jsx("span",{className:"inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-emerald-200/20 bg-emerald-300/12 text-[9px]",children:"FILE"}),t.jsx("span",{className:"min-w-0 truncate",children:i})]})},l.key)})})});function Op(){return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(e=>t.jsx("span",{className:"h-1.5 w-1.5 animate-pulse rounded-full bg-sky-200/90",style:{animationDelay:`${e*180}ms`}},e))})}function Ns({status:e}){if(!e)return null;const r=e.toLowerCase(),n=r.includes("running")||r.includes("generating")||r.includes("steering"),a=r.includes("failed")||r.includes("error"),o=r.includes("accepted")||r.includes("complete"),s=n?"ui-status-warning":a?"ui-status-danger":o?"ui-status-success":"ui-status-neutral",l=n?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}):o?t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(_.Circle,{className:"h-3.5 w-3.5"});return t.jsxs("span",{className:`thread-graph-message-status inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs font-normal ${s}`,title:e,"aria-label":`Status: ${e}`,children:[t.jsx("span",{className:"thread-graph-message-status-icon inline-flex shrink-0",children:n?t.jsx(Op,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Wp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:o,status:s,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{title:i??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:l}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":d?"user":"assistant",className:"thread-graph-message flex justify-start",children:t.jsxs("div",{className:`thread-graph-message-bubble min-w-0 w-full max-w-full ${d?"is-user":"is-assistant"}`,children:[d?null:t.jsxs("div",{className:"thread-graph-message-header mb-2 flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"thread-graph-message-sender rounded-full px-2.5 py-1 text-xs font-semibold tracking-[0.02em]",children:"Assistant"}),t.jsx(Ns,{status:s??"Complete"})]}),a?t.jsx("div",{className:"thread-graph-message-header-meta flex min-w-0 flex-1 justify-center",children:a}):null,r||h?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,h]}):null]}),o,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(s||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[s?t.jsx(Ns,{status:s}):null,h]}):null]})})}Lr();function Up(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Vp({tone:e="amber"}){const r=e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}var It=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:o=!1,adapter:s,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],b=g.map(N=>N.text.trim()).filter(Boolean).join(`
3662
3695
 
3663
- `),k=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(N=>!N)}const w=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(D.Copy,{className:"h-3.5 w-3.5"})}):null,y=g.some(N=>Fp(N.status)),v=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(D.Brain,{className:`h-3.5 w-3.5 ${y?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),y?t.jsx(Hp,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Sr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Tr,{value:"thoughts",className:"border-b-0",children:t.jsx(Er,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(lr,{text:b})})})})})}):null;return t.jsx(Gp,{kind:n.kind,status:k||n.kind==="agentMessage"?n.status:null,copyButton:w,metaControl:v,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx($p,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Dp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function Cs(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ml(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Cs(r[1]):null,a=Cs(r[2]??"").trim(),o=(n==null?void 0:n.split(":")[0])??"hook",s=o==="stop"?"Stop":o,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${s} hook`,previewText:a||`${s} hook`,detailText:a||null,status:"Completed",hookEventName:o,hookEventLabel:s,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function Op(e){return e==="userMessage"||e==="agentMessage"}function Wp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Up(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Vp(e,r){if(!r)return e;const n=[...e],a=n.findIndex(s=>s.kind==="userMessage");if(a<0)return n;for(let s=a+1;s<n.length;s+=1){const l=n[s];if(!l||l.kind!=="userMessage")continue;let i=s+1;for(;i<n.length&&Wp(n[i].kind);)i+=1;if(i===s+1)continue;const[d]=n.splice(s,1);n.splice(i-1,0,d),s=i-1}let o=!1;return n.map((s,l)=>s.kind!=="userMessage"?s:o?n.slice(l+1).some(d=>Up(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Ar(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Ss(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Tt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Tt))return e;const o=a.map(u=>Ar(u)).filter(Number.isFinite),s=o.length>0?Math.max(...o):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(Tt(u)){l.push({item:u,index:i,order:Ar(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Tt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Tt),g=a.slice(i).find(Tt),b=p?Ar(p):null,k=g?Ar(g):null;f.forEach((x,j)=>{let w;if(b===null&&k!==null)w=k-(f.length-j)/(f.length+1);else if(b!==null&&k!==null&&k>b){const y=k-b;w=b+(j+1)/(f.length+1)*y}else w=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:w})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function Kp(e,r){if(!r||r.length===0)return Ss(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),o=[...n.values()];return o.length===0&&!a.some(Tt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:Ss(a)}function qp(e,r){if(!e)return"";const n=r.filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const o=n.join("");if(!o)return e;const s=Math.min(e.length,o.length);let l=0;for(;l<s&&e[l]===o[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function pl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vr(e){return e==="inProgress"||e==="sending"}function Xp(e){var a;const r=[];let n=0;for(;n<e.length;){const o=e[n];if(!o)break;if(o.kind!=="commandExecution"&&o.kind!=="fileChange"&&o.kind!=="webSearch"&&o.kind!=="fileRead"){r.push({kind:"item",key:o.id,item:o}),n+=1;continue}const s=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===o.kind;)s.push(e[n]),n+=1;if(s.length===1){r.push({kind:"item",key:s[0].id,item:s[0]});continue}const l=s.map(i=>i.id).join(":");if(o.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:s});continue}if(o.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:s});continue}if(o.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:s});continue}r.push({kind:"searchGroup",key:l,items:s})}return r}function fl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function kr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function gl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Yp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?kr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?kr(l,p.turnId,p):d.push(p);const h=fl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=gl(h,p.createdAt);if(!g){m.push(p);continue}kr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function Zp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=fl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?kr(i,m.anchorTurnId,m):s.push(m);continue}const f=gl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}kr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function xl({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(w=>w===u?(s[x.id]??"").trim():w.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function b(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean);if(j===u){const y=(s[x.id]??"").trim();return y?[y]:[]}const w=j.trim();return w?[w]:[]}function k(x,j){o(w=>{const y=w[x],v=Array.isArray(y)?y:[],S=v.includes(j)?v.filter(N=>N!==j):[...v,j];return{...w,[x]:S}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,w)=>{const y=f(j.label),v=y.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${w===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?v?"Starting...":"Saving...":y.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const w=f(j.label),y=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?k(x.id,j.label):o(v=>({...v,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(y)&&y.includes(j.label):y===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[w.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,w.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?k(x.id,u):o(w=>({...w,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:y=>l(v=>({...v,[x.id]:y.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>o(w=>({...w,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function bl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function vl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",o=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Wt(e.createdAt),className:"timeline-meta-text text-[10px]",children:xt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:o}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const s=e.linkedThreadId;s&&(n==null||n(s),r==null||r(s))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function pr({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(vl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Xn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(bl,{note:a.note},a.id):t.jsx(xl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Jp({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const o=[...e.map(s=>({kind:"note",id:s.id,createdAt:s.createdAt??"",note:s})),...r.map(s=>({kind:"request",id:s.id,createdAt:s.createdAt,request:s}))].sort((s,l)=>s.createdAt.localeCompare(l.createdAt));return t.jsx(Xn,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function Qp({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:o}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((s,l)=>s.createdAt.localeCompare(l.createdAt)).map(s=>s.kind==="activity"?t.jsx(vl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(bl,{note:s.note},s.id):t.jsx(xl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function ef({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:o,renderFileReadGroup:s,renderItem:l,renderSearchGroup:i}){return t.jsx(t.Fragment,{children:e.map(d=>{const h=r[d.key]??!1,u=()=>n(d.key);return d.kind==="commandGroup"?a(d,h,u):d.kind==="fileChangeGroup"?o(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?s(d,h,u):l(d)})})}function sn({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${o}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":s,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Lr();Pt();var tf=Cr("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function on({asChild:e=!1,className:r,variant:n,...a}){const o=e?Gs:"span";return t.jsx(o,{"data-slot":"badge",className:rt(tf({variant:n,className:r})),...a})}function ha(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function rf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.2 8h3.6"}),t.jsx("path",{d:"M6.2 10h1.7"})]})}function nf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.15 7.25h3.7"}),t.jsx("path",{d:"M6.15 9.25h2.8"}),t.jsx("path",{d:"m10.4 10.7 1.2 1.2"}),t.jsx("circle",{cx:"9.25",cy:"9.55",r:"1.45"})]})}function af(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2.75",y:"3",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"4.25",y:"6.5",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"5.75",y:"10",width:"7.5",height:"3",rx:"1.1"}),t.jsx("path",{d:"m6.25 4.5 1 1-1 1"}),t.jsx("path",{d:"M7.9 5.5h1.7"}),t.jsx("path",{d:"m7.75 8 1 1-1 1"}),t.jsx("path",{d:"M9.4 9h1.7"})]})}function sf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"6",cy:"6",r:"2.3"}),t.jsx("path",{d:"m8 8 1.6 1.6"}),t.jsx("circle",{cx:"9.3",cy:"8.8",r:"2"}),t.jsx("path",{d:"m10.75 10.25 1.65 1.65"}),t.jsx("circle",{cx:"11.2",cy:"4.75",r:"1.8"}),t.jsx("path",{d:"m12.45 6 1.1 1.1"})]})}function of(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",s=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!s.startsWith("/"))return`${s.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=s.indexOf(i);if(d>=0)return`${s.slice(d+1)}${a}`}return r}function kl(e,r=42){const n=of(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),o=(a==null?void 0:a[1])??"",s=o?n.slice(0,-o.length):n;if(s.length<=r)return`${s}${o}`;const i=s.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=o.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function lf(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(o=>o.trim()).filter(Boolean):[]}function Yn({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function df(e){var n;const r=e.replace(/\r\n/g,`
3696
+ `),w=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(N=>!N)}const y=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:h==="copied"?t.jsx(_.Check,{className:"h-3.5 w-3.5"}):t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}):null,v=g.some(N=>Up(N.status)),k=n.kind==="agentMessage"&&b?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(_.Brain,{className:`h-3.5 w-3.5 ${v?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),v?t.jsx(Vp,{tone:"sky"}):null]}):null,S=n.kind==="agentMessage"&&b?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(Sr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:N=>f(!!N),...m?{value:"thoughts"}:{},children:t.jsx(Tr,{value:"thoughts",className:"border-b-0",children:t.jsx(Er,{className:"thread-graph-thinking-content pb-0",children:t.jsx("pre",{className:"thread-graph-thinking-body my-1 max-h-56 overflow-auto whitespace-pre-wrap break-words rounded-xl border p-3 text-[12px] leading-5",children:t.jsx(lr,{text:b})})})})})}):null;return t.jsx(Wp,{kind:n.kind,status:w||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:k,reasoning:S,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Fp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Hp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function Cs(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function ml(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?Cs(r[1]):null,a=Cs(r[2]??"").trim(),o=(n==null?void 0:n.split(":")[0])??"hook",s=o==="stop"?"Stop":o,l=(n==null?void 0:n.split(":").slice(2).join(":"))||null;return{id:`live-hook-prompt:${n??"unknown"}`,kind:"hook",text:`${s} hook`,previewText:a||`${s} hook`,detailText:a||null,status:"Completed",hookEventName:o,hookEventLabel:s,hookHandlerType:"command",hookScope:"turn",hookSource:l?"project":null,hookSourcePath:l,hookStatusMessage:null,hookOutputEntries:a?[{kind:"warning",text:a}]:[]}}function qp(e){return e==="userMessage"||e==="agentMessage"}function Kp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function Xp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Yp(e,r){if(!r)return e;const n=[...e],a=n.findIndex(s=>s.kind==="userMessage");if(a<0)return n;for(let s=a+1;s<n.length;s+=1){const l=n[s];if(!l||l.kind!=="userMessage")continue;let i=s+1;for(;i<n.length&&Kp(n[i].kind);)i+=1;if(i===s+1)continue;const[d]=n.splice(s,1);n.splice(i-1,0,d),s=i-1}let o=!1;return n.map((s,l)=>s.kind!=="userMessage"?s:o?n.slice(l+1).some(d=>Xp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function Tt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Ar(e){return Tt(e)?e.sequence:Number.POSITIVE_INFINITY}function Ss(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!Tt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(Tt))return e;const o=a.map(u=>Ar(u)).filter(Number.isFinite),s=o.length>0?Math.max(...o):0,l=[];let i=0;for(;i<a.length;){const u=a[i];if(Tt(u)){l.push({item:u,index:i,order:Ar(u)}),i+=1;continue}const m=i;for(;i<a.length&&!Tt(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(Tt),g=a.slice(i).find(Tt),b=p?Ar(p):null,w=g?Ar(g):null;f.forEach((x,j)=>{let y;if(b===null&&w!==null)y=w-(f.length-j)/(f.length+1);else if(b!==null&&w!==null&&w>b){const v=w-b;y=b+(j+1)/(f.length+1)*v}else y=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:y})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function Zp(e,r){if(!r||r.length===0)return Ss(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),o=[...n.values()];return o.length===0&&!a.some(Tt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:Ss(a)}function Jp(e,r){if(!e)return"";const n=r.filter(d=>d.kind==="agentMessage").map(d=>d.text).filter(d=>d.length>0),a=n.at(-1)??"";if(a){const d=e.lastIndexOf(a);if(d>=0){const h=e.slice(d+a.length);return h.trim()?h:""}}const o=n.join("");if(!o)return e;const s=Math.min(e.length,o.length);let l=0;for(;l<s&&e[l]===o[l];)l+=1;if(l===0)return e;const i=e.slice(l);return i.trim()?i:""}function pl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function vr(e){return e==="inProgress"||e==="sending"}function Qp(e){var a;const r=[];let n=0;for(;n<e.length;){const o=e[n];if(!o)break;if(o.kind!=="commandExecution"&&o.kind!=="fileChange"&&o.kind!=="webSearch"&&o.kind!=="fileRead"){r.push({kind:"item",key:o.id,item:o}),n+=1;continue}const s=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===o.kind;)s.push(e[n]),n+=1;if(s.length===1){r.push({kind:"item",key:s[0].id,item:s[0]});continue}const l=s.map(i=>i.id).join(":");if(o.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:s});continue}if(o.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:s});continue}if(o.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:s});continue}r.push({kind:"searchGroup",key:l,items:s})}return r}function fl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function kr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function gl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function ef({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?kr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?kr(l,p.turnId,p):d.push(p);const h=fl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=gl(h,p.createdAt);if(!g){m.push(p);continue}kr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function tf({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=fl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?kr(i,m.anchorTurnId,m):s.push(m);continue}const f=gl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}kr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function xl({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function b(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(v=>v===u?(s[x.id]??"").trim():v.trim()).filter(Boolean);if(j===u){const v=(s[x.id]??"").trim();return v?[v]:[]}const y=j.trim();return y?[y]:[]}function w(x,j){o(y=>{const v=y[x],k=Array.isArray(v)?v:[],S=k.includes(j)?k.filter(N=>N!==j):[...k,j];return{...y,[x]:S}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,y)=>{const v=f(j.label),k=v.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[v.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?k?"Starting...":"Saving...":v.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const y=f(j.label),v=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,j.label):o(k=>({...k,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(v)&&v.includes(j.label):v===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?w(x.id,u):o(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:v=>l(k=>({...k,[x.id]:v.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>o(y=>({...y,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:b(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function bl({note:e}){return t.jsxs("div",{className:"timeline-note-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:e.title}),t.jsx("div",{className:"mt-1 space-y-1",children:e.summaryLines.map((r,n)=>t.jsxs("p",{className:"timeline-primary-text text-[13px] leading-5",children:["You selected ",r]},`${e.id}-${n}`))})]})}function vl({note:e,onOpenThread:r,onOpenLinkedThread:n}){const a=e.kind==="forkCreated"?"Fork":e.kind==="forkSource"?"Fork source":"System",o=e.kind==="forkCreated"?`Thread forked from Turn ${e.turnIndex??"?"}`:e.kind==="forkSource"?`Forked from ${e.linkedThreadTitle??"source thread"} at Turn ${e.turnIndex??"?"}`:e.text??"";return t.jsxs("div",{className:"timeline-activity-card w-full rounded-2xl border px-3 py-2.5",children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("p",{className:"timeline-meta-text text-[11px] uppercase tracking-[0.2em]",children:a}),t.jsx("time",{dateTime:e.createdAt,title:Wt(e.createdAt),className:"timeline-meta-text text-[10px]",children:vt(e.createdAt)})]}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5",children:o}),e.linkedThreadId?t.jsx("button",{type:"button",onClick:()=>{const s=e.linkedThreadId;s&&(n==null||n(s),r==null||r(s))},className:"relative z-10 mt-2 inline-flex cursor-pointer rounded-full border border-amber-300/30 px-3 py-1.5 text-xs text-amber-100 transition hover:bg-amber-300/10",children:e.kind==="forkCreated"?"Open fork":"Back to source"}):null]})}function pr({notes:e,onOpenThread:r,onOpenLinkedThread:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>t.jsx(vl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function Xn({entries:e,respondingRequestId:r,onRespondToRequest:n}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:e.map(a=>a.kind==="note"?t.jsx(bl,{note:a.note},a.id):t.jsx(xl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function rf({notes:e,requests:r,respondingRequestId:n,onRespondToRequest:a}){const o=[...e.map(s=>({kind:"note",id:s.id,createdAt:s.createdAt??"",note:s})),...r.map(s=>({kind:"request",id:s.id,createdAt:s.createdAt,request:s}))].sort((s,l)=>s.createdAt.localeCompare(l.createdAt));return t.jsx(Xn,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function nf({entries:e,respondingRequestId:r,onRespondToRequest:n,onOpenThread:a,onOpenLinkedThread:o}){return e.length===0?null:t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:[...e].sort((s,l)=>s.createdAt.localeCompare(l.createdAt)).map(s=>s.kind==="activity"?t.jsx(vl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(bl,{note:s.note},s.id):t.jsx(xl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function af({entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:a,renderFileChangeGroup:o,renderFileReadGroup:s,renderItem:l,renderSearchGroup:i}){return t.jsx(t.Fragment,{children:e.map(d=>{const h=r[d.key]??!1,u=()=>n(d.key);return d.kind==="commandGroup"?a(d,h,u):d.kind==="fileChangeGroup"?o(d,h,u):d.kind==="searchGroup"?i(d,h,u):d.kind==="fileReadGroup"?s(d,h,u):l(d)})})}function sn({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${o}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":s,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Lr();Pt();var sf=Cr("inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden whitespace-nowrap rounded-md border px-2 py-0.5 text-xs font-medium outline-none transition-[color,box-shadow] focus-visible:ring-[3px] [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-white",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function on({asChild:e=!1,className:r,variant:n,...a}){const o=e?Gs:"span";return t.jsx(o,{"data-slot":"badge",className:at(sf({variant:n,className:r})),...a})}function ha(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function of(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.2 8h3.6"}),t.jsx("path",{d:"M6.2 10h1.7"})]})}function lf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 2.75h4l2 2v6.5a1.5 1.5 0 0 1-1.5 1.5h-4A1.5 1.5 0 0 1 4 11.25v-7A1.5 1.5 0 0 1 5.5 2.75Z"}),t.jsx("path",{d:"M9 2.75v2h2"}),t.jsx("path",{d:"M6.15 7.25h3.7"}),t.jsx("path",{d:"M6.15 9.25h2.8"}),t.jsx("path",{d:"m10.4 10.7 1.2 1.2"}),t.jsx("circle",{cx:"9.25",cy:"9.55",r:"1.45"})]})}function df(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2.75",y:"3",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"4.25",y:"6.5",width:"8.5",height:"3",rx:"1.1"}),t.jsx("rect",{x:"5.75",y:"10",width:"7.5",height:"3",rx:"1.1"}),t.jsx("path",{d:"m6.25 4.5 1 1-1 1"}),t.jsx("path",{d:"M7.9 5.5h1.7"}),t.jsx("path",{d:"m7.75 8 1 1-1 1"}),t.jsx("path",{d:"M9.4 9h1.7"})]})}function cf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"6",cy:"6",r:"2.3"}),t.jsx("path",{d:"m8 8 1.6 1.6"}),t.jsx("circle",{cx:"9.3",cy:"8.8",r:"2"}),t.jsx("path",{d:"m10.75 10.25 1.65 1.65"}),t.jsx("circle",{cx:"11.2",cy:"4.75",r:"1.8"}),t.jsx("path",{d:"m12.45 6 1.1 1.1"})]})}function hf(e){const r=e.trim();if(!r)return"";const n=r.match(/(, \+\d+ more.*)$/),a=(n==null?void 0:n[1])??"",s=(a?r.slice(0,-a.length):r).replace(/\\/g,"/");if(!s.startsWith("/"))return`${s.replace(/^\.\//,"")}${a}`;const l=["/apps/","/packages/","/src/","/test/","/tests/","/docs/","/config/","/scripts/","/e2e/","/.agents/","/.codex/"];for(const i of l){const d=s.indexOf(i);if(d>=0)return`${s.slice(d+1)}${a}`}return r}function kl(e,r=42){const n=hf(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),o=(a==null?void 0:a[1])??"",s=o?n.slice(0,-o.length):n;if(s.length<=r)return`${s}${o}`;const i=s.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=o.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function uf(e){var a;const r=[];if(typeof e.changedFiles=="number"&&e.changedFiles>0&&r.push(`${e.changedFiles} ${e.changedFiles===1?"file":"files"}`),typeof e.addedLines=="number"&&e.addedLines>0&&r.push(`+${e.addedLines}`),typeof e.removedLines=="number"&&e.removedLines>0&&r.push(`-${e.removedLines}`),r.length>0)return r;const n=(a=e.previewText)==null?void 0:a.trim();return n?n.replace(/\bfiles changed\b/gi,"files").replace(/\bfile changed\b/gi,"file").split("·").map(o=>o.trim()).filter(Boolean):[]}function Yn({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 animate-pulse rounded-full ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function mf(e){var n;const r=e.replace(/\r\n/g,`
3664
3697
  `).split(`
3665
- `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function bt(e){const r=df(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function wl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:ha(e)?{className:"is-pending",icon:t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:(e==null?void 0:e.trim())||"Running"}:{className:"is-neutral",icon:null,label:(e==null?void 0:e.trim())||"Event"}}function cf(e){switch(e){case"command":return"is-command";case"tool":return"is-tool";case"agent":return"is-agent";case"skill":return"is-skill";case"search":return"is-search";case"fileRead":return"is-file-read"}}function hf(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function Kt({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=wl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${hf(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:o}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),s.status?t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function dr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=wl(l.status),[p,g]=c.useState(n?"item-1":void 0),b=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):b.current&&g(void 0),b.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${cf(m)} ${a??""}`,children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:k=>{g(k||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsxs(nn,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Er,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(lr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(D.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var uf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(Kt,{className:"thread-graph-event-plan",icon:t.jsx(D.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:o,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(ul,{text:r.text,scrollRootRef:n,plainTextClassName:"thread-graph-plain-text whitespace-pre-wrap break-words text-sm leading-6",markdownClassName:"thread-graph-markdown text-sm",...a?{onBeforeResize:a}:{}})})})}),mf=c.memo(function({item:r,timeMeta:n}){const a=ha(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(Kt,{className:"thread-graph-event-context",icon:t.jsx(D.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:o}),a?t.jsx(Yn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),pf=c.memo(function({item:r,timeMeta:n}){return t.jsx(Kt,{className:"thread-graph-event-generic",icon:t.jsx(D.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(lr,{text:r.text})})})}),ff=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.previewText??n.text);return t.jsx(dr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(D.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),gf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(D.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),xf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(D.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),bf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=bt(n.text);return t.jsx(dr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(D.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),vf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=bt(s);return t.jsx(dr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(D.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:o,title:"web_search",tone:"search"})}),kf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=bt(s);return t.jsx(dr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(D.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),wf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o,timeMeta:s}){const l=n.assetPath??n.detailText??null,i=r&&l?(o==null?void 0:o({threadId:r,path:l}))??null:null;return t.jsxs(Kt,{className:"thread-graph-event-image",icon:t.jsx(D.Image,{className:"h-4 w-4"}),item:n,timeMeta:s,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),yf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const o=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((f=r.detailText)==null?void 0:f.trim())||null,l=kl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=lf(r),d=!!(s||r.hasDeferredDetail),h=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:o??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",s??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:o??l,children:h}):h;return t.jsx(Kt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(D.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),jf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=ca(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Kt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!o.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(D.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(D.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:s?"Hide":"Open"})]}),s?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),Nf=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
3666
- `).trim())??"",o=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=bt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(Kt,{className:"thread-graph-event-hook",icon:t.jsx(D.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:o}),t.jsx(lr,{text:i.firstLine})]}):t.jsx(lr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),Cf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>ha(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(sn,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(af,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Yn,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Yn,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=bt(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>o(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),Sf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(sn,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(sf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=bt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>o(`Web Search ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Tf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(sn,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(nf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=bt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>o(`File Read ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Ef=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(sn,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx(rf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,b,k,x;const f=((g=u.detailText)==null?void 0:g.trim())||((b=u.previewText)==null?void 0:b.trim())||u.text,p=(k=u.previewText)!=null&&k.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>o(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:kl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function Lf(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in-progress"||r==="running"||r==="active"?"in_progress":r==="failed"||r==="error"||r==="cancelled"?"failed":r==="pending"||r==="todo"?"pending":"unknown"}function If({status:e}){const r=Lf(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(on,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(D.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(D.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(D.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(D.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function zf({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(on,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(If,{status:r.status})]},`${e.turnId}-${n}`))})]})}function Pf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(zf,{livePlan:o}):null,n??a??null,e]})}function Rf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function Mf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function Af(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13.25v-8"}),t.jsx("path",{d:"m11.25 8.5-3.25-3.25L4.75 8.5"})]})}function Ts(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3.25 5.25 8 2.75l4.75 2.5L8 7.75l-4.75-2.5Z"}),t.jsx("path",{d:"M3.25 8 8 10.5 12.75 8"}),t.jsx("path",{d:"M3.25 10.75 8 13.25l4.75-2.5"}),t.jsx("path",{d:"M3.25 5.25v5.5"}),t.jsx("path",{d:"M12.75 5.25v5.5"})]})}function _f(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function fr(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function yl(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function nr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function _r(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function jl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.cacheWriteInputTokens??0,0),s=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:fr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Mf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:fr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,o>0?{id:"cache-write",label:"Cache write",tokenCompactValue:fr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:fr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:_r((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(Af,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:fr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:_r((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(_f,{})}:null].filter(g=>g!==null)}function $f(e){return jl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Nl(e){return{label:e.priceEstimate?yl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${nr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Sn="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function Df({turn:e}){const r=jl(e),n=Nl(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,b=m.current;if(!g||!b)return;const k=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,w=12,y=k.left+k.width/2-x/2,v=w,S=Math.max(v,j-w-x),N=Math.min(Math.max(y,v),S);d(Math.round(N-y))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&o(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[s,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":s,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${Sn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),s&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${Sn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>o(p=>!p),className:`${Sn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Bf({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Es(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in progress"||r==="inprogress"||r==="running"||r==="active"?"in_progress":r==="pending"||r==="todo"||r==="not_started"||r==="not started"||r==="queued"?"pending":r==="failed"||r==="error"?"failed":"other"}function Gf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!pl(e.status);default:return!1}}function Ff(e,r,n){if(!e||!vr(n))return e;const a=e.plan.findIndex(i=>Es(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&Es(i.status)==="pending");if(o<0||!r.some(i=>Gf(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===o?{...i,status:"in_progress"}:i);return{...e,plan:l}}function Hf(e){var a;const r=(a=e.model)!=null&&a.trim()?e.model.trim():"--";let n="--";return e.reasoningEffortAvailable===null||e.reasoningEffortAvailable===void 0?n="--":e.reasoningEffortAvailable===!1?n="-":n=e.reasoningEffort??"--",[r,n].join(" · ")}function Ls({status:e}){const r=il(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(Bf,{tone:"emerald"})})}function Is({turn:e,variant:r="header"}){const n=il(e.status),a=Hf(e),o=$f(e),s=Nl(e),l=vr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ls,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Wt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:xt(e.startedAt)})]}),(s||o.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[s?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${s.className}`,title:s.title,children:s.label}):null,o.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(Ls,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function Of(e,r){return e.createdAt??r}var ua=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var b,k,x;if(Op(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(jf,{item:n,timeMeta:p,...d?{onSelect:(j,w)=>d({item:j,artifact:w})}:{}});if(n.kind==="commandExecution")return t.jsx(ff,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(gf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(xf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(bf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,w=((b=j.detailText)==null?void 0:b.trim())||j.text||"Web search";return t.jsx(vf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",w,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,w=((k=j.detailText)==null?void 0:k.trim())||j.text||"File read";return t.jsx(kf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",w,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(wf,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(uf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,w=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(yf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",w,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(mf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(Nf,{item:n,timeMeta:p}):t.jsx(pf,{item:n,timeMeta:p})});function zs(e){return e==="completed"||e==="failed"||e==="interrupted"}function Wf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Uf(e){let r=null;for(const n of e){const a=Wf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Vf(e,r){const n=Date.parse(e??""),a=Uf(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const o=Math.max(1,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`Worked for ${s}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function Kf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?xt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function wr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Wt(n),i=Kf(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function $r(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function qf(e){const r=e.filter(s=>s.kind==="item"),n=r.map(s=>s.item).filter(s=>s.kind==="userMessage"),a=r.map(s=>s.item).reverse().find(s=>s.kind==="agentMessage"&&s.text.trim().length>0),o=e.filter(s=>s.kind!=="item"?!0:s.item.kind!=="userMessage"&&s.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:o}}var Tn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:o,isCollapsed:s,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:k,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:w=!1}){const y=!!l||!!d||!!(i&&i.length>0),v=h||vr(a.status)||y||w,S=v&&!vr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>Kp(a.items,i),[i,a.items]),I=c.useMemo(()=>Ff(l,N,a.status),[l,N,a.status]),M=c.useMemo(()=>qp(d,N),[d,N]),R=c.useMemo(()=>Vp(N,v),[v,N]),Q=c.useMemo(()=>Xp(R),[R]),$=h||vr(a.status)||y,Y=xt(a.startedAt),Z=Wt(a.startedAt),P=c.useMemo(()=>ml(M),[M]),[te,oe]=c.useState({}),T=c.useCallback(V=>{oe(de=>({...de,[V]:!de[V]}))},[]),re=t.jsx(Xf,{entries:Q,expandedGroups:te,onToggleGroupedItem:T,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...k?{onBeforeMessageResize:k}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Y,fallbackTimeTitle:Z,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:$,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),B=P?t.jsx(ua,{threadId:r,item:P,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Y,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Y,timeTitle:Z,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,J=!P&&M?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:M},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Y,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Y,timeTitle:Z,streaming:!0,...k?{onBeforeMessageResize:k}:{}}):null,K=v?t.jsx(Is,{turn:S,variant:"footer"}):null,L=c.useMemo(()=>qf(Q),[Q]),q=c.useMemo(()=>Vf(a.startedAt,N),[N,a.startedAt]),G=L.hiddenEntries.length>0,E=s&&G,W=zs(a.status)&&G&&!E?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${q}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:q}),t.jsx(D.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,H=zs(a.status)&&G?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[L.users.map(V=>t.jsx(It,{threadId:r,item:V,scrollRootRef:x,timeLabel:V.createdAt?xt(V.createdAt):Y,timeTitle:V.createdAt?Wt(V.createdAt):Z,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}},V.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${q}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:q}),t.jsx(D.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),L.finalAgent?t.jsx(It,{threadId:r,item:L.finalAgent,scrollRootRef:x,timeLabel:L.finalAgent.createdAt?t.jsx(wr,{absoluteLabel:xt(L.finalAgent.createdAt),timestamp:L.finalAgent.createdAt,turnStartedAt:a.startedAt}):Y,timeTitle:L.finalAgent.createdAt?Wt(L.finalAgent.createdAt):Z,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}}):null]}):null,se=t.jsx(Pf,{footer:K,history:t.jsxs(t.Fragment,{children:[W,re]}),liveHookPrompt:B,liveOutput:J,livePlan:I});return t.jsx(Rf,{absoluteIndex:o,body:se,collapsed:E,collapsedBody:H,error:a.error,headerStatus:t.jsx(Is,{turn:a}),isActive:v,refCallback:j,startedAt:a.startedAt,timeLabel:Y,timeTitle:Z,tokenSummary:t.jsx(Df,{turn:a})})});function Xf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:b,autoOpenLatestToolDetails:k=!1}){var w;const x=((w=e.at(-1))==null?void 0:w.key)??null,j=c.useCallback(y=>y?t.jsx(wr,{absoluteLabel:xt(y),timestamp:y,turnStartedAt:b??f}):null,[f,b]);return t.jsx(ef,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(y,v,S)=>t.jsx(Cf,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:l,timeMeta:j($r(y))},y.key),renderFileChangeGroup:(y,v,S)=>t.jsx(Ef,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:s,timeMeta:j($r(y))},y.key),renderSearchGroup:(y,v,S)=>t.jsx(Sf,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:s,timeMeta:j($r(y))},y.key),renderFileReadGroup:(y,v,S)=>t.jsx(Tf,{items:y.items,expanded:v,onToggleExpanded:S,onOpen:s,timeMeta:j($r(y))},y.key),renderItem:y=>{const v=Of(y.item,f??null),N=y.item.kind==="userMessage"?y.item.createdAt?xt(v):p:y.item.createdAt?t.jsx(wr,{absoluteLabel:xt(v),timestamp:v,turnStartedAt:b??f}):p;return t.jsx(ua,{threadId:a,item:y.item,scrollRootRef:o,timeLabel:N,timeTitle:y.item.createdAt?Wt(v):g,timeMeta:j(v),autoOpenToolDetails:k&&y.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},y.key)}})}var Ps=3,Yf=3,Zn=80;function gr(e,r=Zn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Zf(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=Math.max(n.top,a.top),s=Math.min(n.bottom,a.bottom);return Math.max(0,s-o)>0}function Jf(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Qf(e,r){return{id:e,startedAt:Jf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Rs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function eg({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((p,g)=>{s({title:p,text:g})},[]),i=c.useCallback((p,g,b)=>{if(b&&r){r({item:p,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:b,loadingText:k,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Rs(p,g,b),j);return}const w=a.current.get(p.id);if(w){i(p,w,j);return}const y=n.current+1;n.current=y,j&&r||s({title:g,text:k});try{const v=await e(p.id);if(a.current.set(p.id,v),n.current!==y)return;i(p,v,j)}catch(v){if(n.current!==y)return;i(p,Rs(p,g,v instanceof Error?v.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,k,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:k,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function tg(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((s,l)=>!Object.is(s,a[l])))&&(n.current+=1,r.current=e),n.current}function rg({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:o,scrollRequestKey:s,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(s),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),b=c.useRef(0),k=c.useRef(null),x=c.useRef(null),j=c.useRef(null),w=c.useRef(!0),y=c.useRef(!0),v=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),I=c.useRef(!1),M=c.useRef(null),R=c.useRef(0),[Q,$]=c.useState(Ps),[Y,Z]=c.useState(0),[P,te]=c.useState(!0),oe=tg(d),T=typeof o=="function"||n!==void 0,re=n??r,B=T?0:Math.max(0,r-Q),K=(T?Math.max(0,re-r):0)+B,L=T?r:r-B,q=T?0:r-L,G=T?Math.max(0,re-r):0,E=T?G+q:q,C=!T&&E>0&&Y>=2,W=T&&G>0&&q===0&&typeof o=="function",H=c.useCallback(()=>{const X=h.current;if(!X){k.current=null;return}k.current={scrollHeight:X.scrollHeight,scrollTop:X.scrollTop}},[]),se=c.useCallback(()=>!W||a||N.current?!1:(H(),N.current=!0,I.current=!1,R.current=0,o==null||o(),!0),[W,a,o,H]),V=c.useCallback(()=>{const X=h.current,ue=x.current;if(!X)return;const ve=ue?Zf(X,ue):gr(X);w.current=ve,te(ke=>ke===ve?ke:ve)},[]),de=c.useCallback(()=>{const X=h.current;if(X){S.current=!0;const ue=X.scrollTop,ve=b.current,ke=ue-ve;b.current=ue,gr(X,1)?(v.current=!1,y.current=!0):ke<-1?(v.current=!0,y.current=!1):ke>1&&(y.current=!v.current&&gr(X,Zn)),ue<=0&&S.current?I.current=!0:ue>0&&(I.current=!1,R.current=0)}V()},[V]),ee=c.useCallback(()=>{const X=h.current;X&&(X.scrollTop=X.scrollHeight,b.current=X.scrollTop,g.current=X.scrollHeight,w.current=!0,te(ue=>ue||!0),v.current=!1,y.current=!0)},[]),be=c.useCallback(()=>{const X=h.current;X&&(b.current=X.scrollTop,g.current=X.scrollHeight,y.current=!1,v.current=!0)},[]),ie=c.useCallback(()=>{if(T&&q===0){se();return}$(X=>Math.min(r,X+Yf)),Z(X=>X+1)},[q,T,se,r]),ye=c.useCallback(X=>{const ue=h.current;if(!(!ue||X.deltaY>=-8||ue.scrollTop>0||!W)){if(!I.current){I.current=!0;return}se()}},[W,se]),Ae=c.useCallback(X=>{var ue;M.current=((ue=X.touches.item(0))==null?void 0:ue.clientY)??null,R.current=0},[]),ce=c.useCallback(X=>{var He;const ue=h.current,ve=((He=X.touches.item(0))==null?void 0:He.clientY)??null,ke=M.current;if(M.current=ve,!ue||ve===null||ke===null||ue.scrollTop>0||!W){R.current=0;return}const $e=ve-ke;if($e<=0){R.current=0;return}if(!I.current){I.current=!0,R.current=0;return}R.current+=$e,R.current>=28&&se()},[W,se]),Ce=c.useCallback(()=>{M.current=null,R.current=0},[]),Le=c.useCallback(()=>{$(r)},[r]);return c.useLayoutEffect(()=>{const X=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(X)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,I.current=!1,k.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const X=k.current,ue=h.current;if(!X||!ue||a)return;k.current=null;const ve=ue.scrollHeight-X.scrollHeight;if(ve<=0){g.current=ue.scrollHeight,b.current=ue.scrollTop;return}const ke=X.scrollTop+ve;ue.scrollTop=ke,b.current=ke,g.current=ue.scrollHeight,v.current=!0,y.current=!1,I.current=!1},[a,r]),c.useEffect(()=>{$(X=>X>=r-1?r:Math.max(X,Ps))},[r]),c.useEffect(()=>{const X=h.current;X&&(g.current=X.scrollHeight,b.current=X.scrollTop,gr(X,1)?(v.current=!1,y.current=!0):(v.current||!gr(X,Zn))&&(y.current=!1)),V()},[oe,V,Q]),c.useEffect(()=>{const X=s!==m.current,ue=f.current!==oe;if(f.current=oe,!(X||ue&&y.current&&!v.current))return;const ke=window.requestAnimationFrame(()=>{ee()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(ke)}},[oe,P,ee,s]),c.useEffect(()=>{const X=h.current,ue=u.current;if(!X||!ue||typeof ResizeObserver>"u")return;g.current=X.scrollHeight;const ve=new ResizeObserver(()=>{const ke=X.scrollHeight,$e=g.current;if(g.current=ke,ke<=$e)return;const He=$e>0&&$e-X.scrollTop-X.clientHeight<=1;v.current||!(y.current||He||w.current)||window.requestAnimationFrame(()=>{ee()})});return ve.observe(ue),()=>{ve.disconnect()}},[ee]),c.useEffect(()=>{if(!y.current||v.current){p.current=l;return}if(l===p.current)return;p.current=l;const X=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(X)}},[l,ee]),c.useEffect(()=>{i==null||i(P)},[P,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:P,handleScroll:de,handleWheel:ye,handleTouchStart:Ae,handleTouchMove:ce,handleTouchEnd:Ce,preserveScrollPositionForResize:be,serverManagedHistory:T,effectiveTotalTurnCount:re,startIndex:B,visibleTurnAbsoluteOffset:K,hiddenCount:E,loadedHiddenCount:q,unloadedHiddenCount:G,showLoadAll:C,handleLoadEarlierClick:ie,handleLoadAllClick:Le}}function ng(e){return e==="completed"||e==="failed"||e==="interrupted"}function ag(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(o=>o.id)),a=r.items.filter(o=>!n.has(o.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function sg({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:b=0,className:k="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:w,loadingEarlier:y=!1,onLoadEarlier:v,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:I=[],optimisticSteers:M=[],optimisticTurn:R=null,onLoadHistoryItemDetail:Q,onOpenThread:$,onSelectArtifact:Y,onSelectHistoryItemDetail:Z,adapter:P,autoCollapseCompletedTurns:te}){var vt,it,Nt,Rt,Ct;const oe=ll(),T=te??(oe==null?void 0:oe.autoCollapseCompletedTurns)??!1,[re,B]=c.useState({}),[J,K]=c.useState(()=>new Set),L=c.useRef(null),q=c.useRef(null),G=(P==null?void 0:P.onLoadHistoryItemDetail)??Q,E=P==null?void 0:P.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:H,openToolCallDetail:se,openDeferredHistoryItemDetail:V,closeExpandedText:de}=eg({loadHistoryItemDetail:G,onSelectHistoryItemDetail:Z}),{scrollContainerRef:ee,scrollContentRef:be,tailSentinelRef:ie,topSentinelRef:ye,handleScroll:Ae,handleWheel:ce,handleTouchStart:Ce,handleTouchMove:Le,handleTouchEnd:X,preserveScrollPositionForResize:ue,serverManagedHistory:ve,effectiveTotalTurnCount:ke,startIndex:$e,visibleTurnAbsoluteOffset:He,hiddenCount:_e,loadedHiddenCount:ze,unloadedHiddenCount:F,showLoadAll:le,handleLoadEarlierClick:we,handleLoadAllClick:z}=rg({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:y,onLoadEarlier:v,scrollRequestKey:f,bottomSpacer:b,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,M,m,i,d,R,N,I,S,b]}),O=c.useCallback((_,pe)=>{B(Re=>({...Re,[_]:!pe}))},[]),ne=c.useCallback((_,pe)=>{const Re=re[_.id];return Re!==void 0?Re:!!(T&&ng(_.status)&&!pe.forceActive&&!pe.hasLiveActivity)},[re,T]),ge=ve?r:r.slice($e),Te=ke+1,Ee=s&&(!o||!ge.some(_=>_.id===o)&&(R==null?void 0:R.id)!==o),fe=(R==null?void 0:R.id)??((vt=ge.at(-1))==null?void 0:vt.id)??null,De=Ee&&fe!==null,Be=!!d&&(ge.some(_=>_.id===d.turnId)||(R==null?void 0:R.id)===d.turnId),et=d&&Be?d.turnId:d&&De?fe:null,Ve=R&&et===R.id?(d==null?void 0:d.items)??null:null,pt=((d==null?void 0:d.items.length)??0)>0,nt=d&&et===null?d.items:null,We=c.useMemo(()=>d&&et===null&&d.items.length>0?Qf(d.turnId,d.items):null,[d,et]),ot=Math.max(1,ke+(R?1:0)),ht=!!m&&!!R&&R.status!=="failed"&&!Ve,ut=m&&ge.length>0?o&&ge.some(_=>_.id===o)?o:((it=ge.findLast(_=>pl(_.status)))==null?void 0:it.id)??(De?fe:null):null,A=!!ut,U=c.useMemo(()=>ml(m),[m]),xe=[...l.map(_=>({id:_.id,prompt:_.prompt,status:"Accepted",createdAt:_.createdAt,canCancel:!0})),...M.map(_=>({id:_.id,prompt:_.prompt,status:_.status==="steering"?"Steering":null,createdAt:_.createdAt,canCancel:!1}))].sort((_,pe)=>_.createdAt.localeCompare(pe.createdAt)),je=c.useMemo(()=>Yp({answeredRequestNotes:N,pendingRequests:a,visibleTurns:ge,optimisticTurn:R}),[N,R,a,ge]),Ne=c.useMemo(()=>Zp({activityNotes:I,visibleTurns:ge,optimisticTurn:R}),[I,R,ge]),Ye=c.useCallback(()=>{const _=ee.current;if(!_)return null;const pe=_.getBoundingClientRect().top;return Array.from(_.querySelectorAll("[data-timeline-turn]")).find(Re=>Re.getBoundingClientRect().top>pe+8)??null},[ee]),tt=c.useCallback(()=>{const _=ee.current;if(!_)return null;const pe=_.getBoundingClientRect().top;return Array.from(_.querySelectorAll("[data-timeline-turn]")).findLast(Re=>Re.getBoundingClientRect().top<pe-8)??null},[ee]),Fe=c.useCallback(()=>{j==null||j(!!tt())},[tt,j]),Ke=c.useCallback(()=>{w==null||w(!!Ye())},[Ye,w]),lt=c.useCallback(()=>{Ae(),Fe(),Ke()},[Ae,Ke,Fe]);return c.useEffect(()=>{Fe(),Ke()},[Ke,Fe,ge]),c.useEffect(()=>{if(p===0)return;const _=ee.current,pe=tt(),Re=_?Array.from(_.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?Re.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===L.current?Re[Ge-1]??null:pe;if(!_||!Ue)return;L.current=Ue.dataset.turnId??null;const ct=Ue.getBoundingClientRect().top-_.getBoundingClientRect().top;_.scrollTo({top:_.scrollTop+ct-8,behavior:"smooth"}),Re.indexOf(Ue)===0&&(j==null||j(!1))},[tt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const _=ee.current,pe=Ye(),Re=_?Array.from(_.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?Re.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===q.current?Re[Ge+1]??null:pe;if(!_||!Ue)return;q.current=Ue.dataset.turnId??null;const ct=Ue.getBoundingClientRect().top-_.getBoundingClientRect().top;_.scrollTo({top:_.scrollTop+ct-8,behavior:"smooth"}),Re.indexOf(Ue)===Re.length-1&&(w==null||w(!1))},[Ye,g,w,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${k}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:lt,onWheel:ce,onTouchStart:Ce,onTouchMove:Le,onTouchEnd:X,onTouchCancel:X,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:b>0?{paddingBottom:b}:void 0,children:t.jsxs("div",{ref:be,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ye,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[_e>0&&t.jsx("button",{type:"button",onClick:we,disabled:y,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:y?"Loading earlier...":"Load 3 earlier"}),le&&t.jsx("button",{type:"button",onClick:z,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",ge.length," of ",ke," turns",_e>0?` · ${_e} earlier hidden${ze>0&&F>0?` (${ze} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!R&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(ge.length>0||R||Ne.leading.length>0||Ne.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ne.leading.length>0?t.jsx(pr,{notes:Ne.leading,onOpenThread:$,onOpenLinkedThread:E}):null,ge.map((_,pe)=>{var Re,Ge,Ue,ct,kt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":_.id,children:[(((Re=Ne.beforeTurnId.get(_.id))==null?void 0:Re.length)??0)>0?t.jsx(pr,{notes:Ne.beforeTurnId.get(_.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null,(((Ge=je.beforeTurnId.get(_.id))==null?void 0:Ge.length)??0)>0?t.jsx(Xn,{entries:je.beforeTurnId.get(_.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const qt=ag(_,R),Xt=(i==null?void 0:i.turnId)===_.id?i:null,Mt=et===_.id?(d==null?void 0:d.items)??null:null,cr=ut===_.id?m:"",at=o===_.id||De&&fe===_.id,dn=!!Xt||!!cr||!!(Mt&&Mt.length>0),cn=ne(qt,{forceActive:at,hasLiveActivity:dn});return t.jsx(Tn,{threadId:e,...P?{adapter:P}:{},turn:qt,absoluteIndex:He+pe+1,isCollapsed:cn,livePlan:Xt,liveItems:Mt,liveOutput:cr,forceActive:at,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Ne.afterTurnId.get(_.id))==null?void 0:Ue.length)??0)>0?t.jsx(pr,{notes:Ne.afterTurnId.get(_.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null,(ct=je.notesByTurnId.get(_.id))!=null&&ct.length||(kt=je.pendingRequestsByTurnId.get(_.id))!=null&&kt.length?t.jsx(Jp,{notes:je.notesByTurnId.get(_.id)??[],requests:je.pendingRequestsByTurnId.get(_.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},_.id)}),R&&ge.every(_=>_.id!==R.id)&&t.jsxs(t.Fragment,{children:[(((Nt=Ne.beforeTurnId.get(R.id))==null?void 0:Nt.length)??0)>0?t.jsx(pr,{notes:Ne.beforeTurnId.get(R.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null,(((Rt=je.beforeTurnId.get(R.id))==null?void 0:Rt.length)??0)>0?t.jsx(Xn,{entries:je.beforeTurnId.get(R.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const _=ht?m:"",pe=o===R.id||De&&fe===R.id,Re=!!(Ve&&Ve.length>0)||!!_,Ge=ne(R,{forceActive:pe,hasLiveActivity:Re});return t.jsx(Tn,{threadId:e,...P?{adapter:P}:{},turn:R,absoluteIndex:Te,isCollapsed:Ge,livePlan:null,liveItems:Ve,liveOutput:_,forceActive:pe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:ee})})(),(((Ct=Ne.afterTurnId.get(R.id))==null?void 0:Ct.length)??0)>0?t.jsx(pr,{notes:Ne.afterTurnId.get(R.id)??[],onOpenThread:$,onOpenLinkedThread:E}):null]})]}),xe.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:xe.map(_=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:_.id,kind:"userMessage",text:_.prompt,status:_.status},scrollRootRef:ee,onBeforeMessageResize:ue,...P?{adapter:P}:{}}),e&&_.canCancel&&(P!=null&&P.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:J.has(_.id),onClick:()=>{var pe;K(Re=>new Set(Re).add(_.id)),Promise.resolve((pe=P.cancelPendingSteer)==null?void 0:pe.call(P,e,_.id)).catch(()=>{}).finally(()=>{K(Re=>{const Ge=new Set(Re);return Ge.delete(_.id),Ge})})},children:J.has(_.id)?"Canceling...":"Cancel"})}):null]},_.id))}),(je.trailing.length>0||Ne.trailing.length>0)&&t.jsx(Qp,{entries:[...Ne.trailing.map(_=>({kind:"activity",id:_.id,createdAt:_.createdAt,note:_})),...je.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:$,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:ue})}),We&&nt&&nt.length>0&&t.jsx(Tn,{threadId:e,...P?{adapter:P}:{},turn:We,absoluteIndex:ot,isCollapsed:re[We.id]??!1,livePlan:(i==null?void 0:i.turnId)===We.id?i:null,liveItems:nt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},scrollRootRef:ee}),m&&!A&&!ht&&!pt&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:U?t.jsx(ua,{threadId:e,item:U,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:H,onOpenToolCallDetail:se,onOpenDeferredHistoryItemDetail:V,onBeforeMessageResize:ue,...Y?{onSelectArtifact:Y}:{},...P?{adapter:P}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:ue,...P?{adapter:P}:{}})}),t.jsx("div",{ref:ie,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(pp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:de})]})}var Cl=c.memo(sg);function og(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Jn(e){return e.replace(/\r\n/g,`
3698
+ `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function kt(e){const r=mf(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function wl(e){const r=(e==null?void 0:e.trim().toLowerCase())??"";return r==="completed"||r==="complete"||r==="success"||r==="succeeded"?{className:"is-completed",icon:t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:ha(e)?{className:"is-pending",icon:t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:(e==null?void 0:e.trim())||"Running"}:{className:"is-neutral",icon:null,label:(e==null?void 0:e.trim())||"Event"}}function pf(e){switch(e){case"command":return"is-command";case"tool":return"is-tool";case"agent":return"is-agent";case"skill":return"is-skill";case"search":return"is-search";case"fileRead":return"is-file-read"}}function ff(e){switch(e){case"plan":return"is-plan";case"context":return"is-context";case"generic":return"is-generic";case"image":return"is-image";case"fileChange":return"is-file-change";case"artifact":return"is-artifact";case"hook":return"is-hook"}}function qt({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=wl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${ff(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:o}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),s.status?t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function dr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=wl(l.status),[p,g]=c.useState(n?"item-1":void 0),b=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):b.current&&g(void 0),b.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${pf(m)} ${a??""}`,children:t.jsx(Sr,{type:"single",collapsible:!0,onValueChange:w=>{g(w||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(Tr,{value:"item-1",className:"border-0",children:[t.jsxs(nn,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(on,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Er,{className:"thread-graph-tool-content thread-graph-history-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Summary"}),t.jsxs("div",{className:"thread-graph-history-tool-summary",children:[t.jsx(lr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(_.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var gf=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(qt,{className:"thread-graph-event-plan",icon:t.jsx(_.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:o,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(ul,{text:r.text,scrollRootRef:n,plainTextClassName:"thread-graph-plain-text whitespace-pre-wrap break-words text-sm leading-6",markdownClassName:"thread-graph-markdown text-sm",...a?{onBeforeResize:a}:{}})})})}),xf=c.memo(function({item:r,timeMeta:n}){const a=ha(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(qt,{className:"thread-graph-event-context",icon:t.jsx(_.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:o}),a?t.jsx(Yn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),bf=c.memo(function({item:r,timeMeta:n}){return t.jsx(qt,{className:"thread-graph-event-generic",icon:t.jsx(_.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(lr,{text:r.text})})})}),vf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.previewText??n.text);return t.jsx(dr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(_.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),kf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.text);return t.jsx(dr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(_.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),wf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.text);return t.jsx(dr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(_.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),yf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=kt(n.text);return t.jsx(dr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(_.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),jf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=kt(s);return t.jsx(dr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(_.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:o,title:"web_search",tone:"search"})}),Nf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=kt(s);return t.jsx(dr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(_.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),Cf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o,timeMeta:s}){const l=n.assetPath??n.detailText??null,i=r&&l?(o==null?void 0:o({threadId:r,path:l}))??null:null;return t.jsxs(qt,{className:"thread-graph-event-image",icon:t.jsx(_.Image,{className:"h-4 w-4"}),item:n,timeMeta:s,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),Sf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const o=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((f=r.detailText)==null?void 0:f.trim())||null,l=kl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=uf(r),d=!!(s||r.hasDeferredDetail),h=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:o??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",s??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:o??l,children:h}):h;return t.jsx(qt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(_.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),Tf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=ca(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(qt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!o.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(_.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(_.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:s?"Hide":"Open"})]}),s?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),Ef=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
3699
+ `).trim())??"",o=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=kt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(qt,{className:"thread-graph-event-hook",icon:t.jsx(_.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:o}),t.jsx(lr,{text:i.firstLine})]}):t.jsx(lr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),Lf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>ha(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(sn,{className:"thread-graph-history-group-command",count:r.length,countBadgeClassName:"border-amber-200/35 text-amber-100",desktopIconClassName:"border-amber-300/30 bg-amber-300/[0.14] text-amber-100",expanded:n,expandedListClassName:"border-amber-300/12",icon:t.jsx(df,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Yn,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Yn,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=kt(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>o(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),If=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(sn,{className:"thread-graph-history-group-search",count:r.length,countBadgeClassName:"border-sky-200/35 text-sky-100",desktopIconClassName:"border-sky-300/30 bg-sky-300/[0.14] text-sky-100",expanded:n,expandedListClassName:"border-sky-300/12",icon:t.jsx(cf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=kt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>o(`Web Search ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),zf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(sn,{className:"thread-graph-history-group-file-read",count:r.length,countBadgeClassName:"border-cyan-200/35 text-cyan-100",desktopIconClassName:"border-cyan-300/30 bg-cyan-300/[0.14] text-cyan-100",expanded:n,expandedListClassName:"border-cyan-300/12",icon:t.jsx(lf,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=kt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>o(`File Read ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Pf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(sn,{className:"thread-graph-history-group-file-change",count:r.length,countBadgeClassName:"border-lime-200/35 text-lime-100",desktopIconClassName:"border-lime-300/30 bg-lime-300/[0.14] text-lime-100",expanded:n,expandedListClassName:"border-lime-300/12",icon:t.jsx(of,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,b,w,x;const f=((g=u.detailText)==null?void 0:g.trim())||((b=u.previewText)==null?void 0:b.trim())||u.text,p=(w=u.previewText)!=null&&w.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>o(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:kl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function Rf(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in-progress"||r==="running"||r==="active"?"in_progress":r==="failed"||r==="error"||r==="cancelled"?"failed":r==="pending"||r==="todo"?"pending":"unknown"}function Mf({status:e}){const r=Rf(e),n=r==="completed"?"Plan step status: Completed":r==="in_progress"?"Plan step status: In progress":r==="pending"?"Plan step status: Pending":r==="failed"?"Plan step status: Failed":`Plan step status: ${e}`,a=r==="completed"?"thread-graph-plan-status is-completed":r==="in_progress"?"thread-graph-plan-status is-running":r==="pending"?"thread-graph-plan-status is-pending":r==="failed"?"thread-graph-plan-status is-failed":"thread-graph-plan-status is-unknown";return t.jsx(on,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(_.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(_.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(_.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function Af({livePlan:e}){return t.jsxs("div",{className:"thread-graph-plan-card rounded-xl border px-3 py-3",children:[t.jsxs("div",{className:"thread-graph-plan-header flex flex-wrap items-center justify-between gap-2",children:[t.jsx("p",{className:"text-sm font-semibold",children:"Plan update"}),t.jsx(on,{className:"thread-graph-plan-badge",children:"Live"})]}),e.explanation?t.jsx("p",{className:"thread-graph-plan-explanation mt-3 text-sm",children:e.explanation}):null,t.jsx("div",{className:"mt-3 space-y-2",children:e.plan.map((r,n)=>t.jsxs("div",{className:"thread-graph-plan-step flex items-center justify-between gap-3 rounded-lg border px-3 py-2 text-sm",children:[t.jsx("span",{className:"thread-graph-plan-step-text min-w-0 flex-1",children:r.step}),t.jsx(Mf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function _f({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(Af,{livePlan:o}):null,n??a??null,e]})}function $f({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function Df(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 2.75v8"}),t.jsx("path",{d:"m4.75 7.5 3.25 3.25L11.25 7.5"})]})}function Bf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13.25v-8"}),t.jsx("path",{d:"m11.25 8.5-3.25-3.25L4.75 8.5"})]})}function Ts(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M3.25 5.25 8 2.75l4.75 2.5L8 7.75l-4.75-2.5Z"}),t.jsx("path",{d:"M3.25 8 8 10.5 12.75 8"}),t.jsx("path",{d:"M3.25 10.75 8 13.25l4.75-2.5"}),t.jsx("path",{d:"M3.25 5.25v5.5"}),t.jsx("path",{d:"M12.75 5.25v5.5"})]})}function Gf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.45",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M6.2 3.2a2.3 2.3 0 0 0-2.95 3.5A2.4 2.4 0 0 0 4.5 11h.2c.25 1.1 1.1 1.8 2.3 1.8h1.8c1.2 0 2.05-.7 2.3-1.8h.2A2.4 2.4 0 0 0 12.75 6.7 2.3 2.3 0 0 0 9.8 3.2"}),t.jsx("path",{d:"M6.3 6.15c.45-.42 1.02-.65 1.7-.65s1.25.23 1.7.65"}),t.jsx("path",{d:"M8 5.5v4.75"}),t.jsx("path",{d:"M6.75 9.05 8 10.25l1.25-1.2"})]})}function fr(e){if(!Number.isFinite(e)||e<=0)return"0";if(e>=1e6){const r=e>=1e7?Math.round(e/1e6):e/1e6;return`${String(r.toFixed(1)).replace(/\.0$/,"")}m`}if(e>=1e3){const r=e>=1e4?Math.round(e/1e3):e/1e3;return`${String(r.toFixed(1)).replace(/\.0$/,"")}k`}return String(Math.round(e))}function yl(e){return!Number.isFinite(e)||e<=0?"$0":e>=100?`$${Math.round(e)}`:e>=10?`$${String(e.toFixed(1)).replace(/\.0$/,"")}`:e>=1?`$${String(e.toFixed(2)).replace(/0$/,"").replace(/\.$/,"")}`:e>=.1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:e>=.001?`$${e.toFixed(4)}`:"<$0.001"}function nr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function _r(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function jl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.cacheWriteInputTokens??0,0),s=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:fr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(Df,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:fr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,o>0?{id:"cache-write",label:"Cache write",tokenCompactValue:fr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?nr(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(Ts,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:fr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:_r((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(Bf,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:fr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?nr(_r(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:_r((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(Gf,{})}:null].filter(g=>g!==null)}function Ff(e){return jl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function Nl(e){return{label:e.priceEstimate?yl(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${nr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var Sn="inline-flex shrink-0 items-center gap-1 rounded-full border px-1.5 py-0.5 text-[10px] font-normal leading-none sm:text-[11px]";function Hf({turn:e}){const r=jl(e),n=Nl(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,b=m.current;if(!g||!b)return;const w=g.getBoundingClientRect(),x=b.offsetWidth||b.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,v=w.left+w.width/2-x/2,k=y,S=Math.max(k,j-y-x),N=Math.min(Math.max(v,k),S);d(Math.round(N-v))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&o(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[s,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":s,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${Sn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),s&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${Sn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>o(p=>!p),className:`${Sn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Of({tone:e="amber"}){const r=e==="emerald"?"bg-sky-200/90":e==="sky"?"bg-sky-300/90":"bg-amber-200/90";return t.jsx("span",{className:"ml-1.5 inline-flex items-center gap-1","aria-hidden":"true",children:[0,1,2].map(n=>t.jsx("span",{className:`h-1.5 w-1.5 rounded-full animate-pulse ${r}`,style:{animationDelay:`${n*180}ms`}},n))})}function Es(e){const r=e.trim().toLowerCase();return r==="completed"||r==="done"||r==="complete"?"completed":r==="in_progress"||r==="in progress"||r==="inprogress"||r==="running"||r==="active"?"in_progress":r==="pending"||r==="todo"||r==="not_started"||r==="not started"||r==="queued"?"pending":r==="failed"||r==="error"?"failed":"other"}function Wf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!pl(e.status);default:return!1}}function Uf(e,r,n){if(!e||!vr(n))return e;const a=e.plan.findIndex(i=>Es(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&Es(i.status)==="pending");if(o<0||!r.some(i=>Wf(i)))return e;const l=e.plan.map((i,d)=>d===a?{...i,status:"completed"}:d===o?{...i,status:"in_progress"}:i);return{...e,plan:l}}function Vf(e){var a;const r=(a=e.model)!=null&&a.trim()?e.model.trim():"--";let n="--";return e.reasoningEffortAvailable===null||e.reasoningEffortAvailable===void 0?n="--":e.reasoningEffortAvailable===!1?n="-":n=e.reasoningEffort??"--",[r,n].join(" · ")}function Ls({status:e}){const r=il(e);return e==="completed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-success inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m3.75 8.25 2.5 2.5 6-6"})})}):e==="failed"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-failed inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"m5 5 6 6M11 5l-6 6"})})}):e==="interrupted"?t.jsx("span",{"aria-label":r,title:r,className:"timeline-status-icon timeline-status-icon-warning inline-flex h-4 w-4 items-center justify-center",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M6 4.5v7M10 4.5v7"})})}):t.jsx("span",{"aria-label":r,title:r,className:"inline-flex min-w-[1.25rem] items-center justify-center text-sky-200",children:t.jsx(Of,{tone:"emerald"})})}function Is({turn:e,variant:r="header"}){const n=il(e.status),a=Vf(e),o=Ff(e),s=Nl(e),l=vr(e.status),i=e.status==="failed"?"border-rose-300/20 bg-rose-300/[0.06] text-rose-100":l?"border-sky-300/22 bg-sky-300/[0.08] text-sky-100":"border-stone-700/90 bg-stone-900/70 text-stone-200";if(r==="footer")return t.jsxs("div",{className:`flex w-full flex-col gap-1.5 rounded-[0.95rem] border px-3 py-2 text-xs ${i}`,children:[t.jsxs("div",{className:"flex w-full items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Ls,{status:e.status}),t.jsx("span",{className:"timeline-soft-text min-w-0 truncate",children:a})]}),e.startedAt&&t.jsx("time",{dateTime:e.startedAt,title:Wt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:vt(e.startedAt)})]}),(s||o.length>0)&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 pl-6",children:[s?t.jsx("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${s.className}`,title:s.title,children:s.label}):null,o.map(h=>t.jsxs("span",{className:`inline-flex items-center rounded-full border px-1.5 py-0.5 text-[10px] font-medium ${h.className}`,title:h.title,children:[h.icon?t.jsx("span",{className:"mr-1",children:h.icon}):null,h.label]},h.id))]})]});const d=`${n} · ${a}`;return t.jsxs("span",{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border px-2 py-1 text-[10px] sm:text-[11px] ${i}`,title:d,children:[t.jsx(Ls,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function qf(e,r){return e.createdAt??r}var ua=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var b,w,x;if(qp(n.kind))return t.jsx(It,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(It,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(Tf,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(vf,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(kf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(wf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(yf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((b=j.detailText)==null?void 0:b.trim())||j.text||"Web search";return t.jsx(jf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((w=j.detailText)==null?void 0:w.trim())||j.text||"File read";return t.jsx(Nf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Cf,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(gf,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(Sf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(xf,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(Ef,{item:n,timeMeta:p}):t.jsx(bf,{item:n,timeMeta:p})});function zs(e){return e==="completed"||e==="failed"||e==="interrupted"}function Kf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function Xf(e){let r=null;for(const n of e){const a=Kf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Yf(e,r){const n=Date.parse(e??""),a=Xf(r);if(!Number.isFinite(n)||a===null||a<n)return"Worked";const o=Math.max(1,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`Worked for ${s}h ${l}m`:l>0?`Worked for ${l}m ${i}s`:`Worked for ${i}s`}function Zf(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?vt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function wr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Wt(n),i=Zf(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function $r(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function Jf(e){const r=e.filter(s=>s.kind==="item"),n=r.map(s=>s.item).filter(s=>s.kind==="userMessage"),a=r.map(s=>s.item).reverse().find(s=>s.kind==="agentMessage"&&s.text.trim().length>0),o=e.filter(s=>s.kind!=="item"?!0:s.item.kind!=="userMessage"&&s.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:o}}var Tn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:o,isCollapsed:s,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:b,onBeforeMessageResize:w,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const v=!!l||!!d||!!(i&&i.length>0),k=h||vr(a.status)||v||y,S=k&&!vr(a.status)?{...a,status:"inProgress"}:a,N=c.useMemo(()=>Zp(a.items,i),[i,a.items]),L=c.useMemo(()=>Uf(l,N,a.status),[l,N,a.status]),R=c.useMemo(()=>Jp(d,N),[d,N]),P=c.useMemo(()=>Yp(N,k),[k,N]),Q=c.useMemo(()=>Qp(P),[P]),D=h||vr(a.status)||v,Z=vt(a.startedAt),J=Wt(a.startedAt),z=c.useMemo(()=>ml(R),[R]),[te,se]=c.useState({}),$=c.useCallback(K=>{se(ie=>({...ie,[K]:!ie[K]}))},[]),le=t.jsx(Qf,{entries:Q,expandedGroups:te,onToggleGroupedItem:$,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...w?{onBeforeMessageResize:w}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Z,fallbackTimeTitle:J,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:D,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}),q=z?t.jsx(ua,{threadId:r,item:z,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,timeMeta:null,...b?{onSelectArtifact:b}:{},...n?{adapter:n}:{}}):null,H=!z&&R?t.jsx(It,{item:{id:"live-agent-message",kind:"agentMessage",text:R},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(wr,{absoluteLabel:Z,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Z,timeTitle:J,streaming:!0,...w?{onBeforeMessageResize:w}:{}}):null,G=k?t.jsx(Is,{turn:S,variant:"footer"}):null,T=c.useMemo(()=>Jf(Q),[Q]),F=c.useMemo(()=>Yf(a.startedAt,N),[N,a.startedAt]),B=T.hiddenEntries.length>0,E=s&&B,W=zs(a.status)&&B&&!E?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${F}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx(_.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,U=zs(a.status)&&B?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(K=>t.jsx(It,{threadId:r,item:K,scrollRootRef:x,timeLabel:K.createdAt?vt(K.createdAt):Z,timeTitle:K.createdAt?Wt(K.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}},K.id)),t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!0),"aria-label":`${F}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:F}),t.jsx(_.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),T.finalAgent?t.jsx(It,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(wr,{absoluteLabel:vt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Z,timeTitle:T.finalAgent.createdAt?Wt(T.finalAgent.createdAt):J,...w?{onBeforeMessageResize:w}:{},...n?{adapter:n}:{}}):null]}):null,ne=t.jsx(_f,{footer:G,history:t.jsxs(t.Fragment,{children:[W,le]}),liveHookPrompt:q,liveOutput:H,livePlan:L});return t.jsx($f,{absoluteIndex:o,body:ne,collapsed:E,collapsedBody:U,error:a.error,headerStatus:t.jsx(Is,{turn:a}),isActive:k,refCallback:j,startedAt:a.startedAt,timeLabel:Z,timeTitle:J,tokenSummary:t.jsx(Hf,{turn:a})})});function Qf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:b,autoOpenLatestToolDetails:w=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(v=>v?t.jsx(wr,{absoluteLabel:vt(v),timestamp:v,turnStartedAt:b??f}):null,[f,b]);return t.jsx(af,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(v,k,S)=>t.jsx(Lf,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:l,timeMeta:j($r(v))},v.key),renderFileChangeGroup:(v,k,S)=>t.jsx(Pf,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j($r(v))},v.key),renderSearchGroup:(v,k,S)=>t.jsx(If,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j($r(v))},v.key),renderFileReadGroup:(v,k,S)=>t.jsx(zf,{items:v.items,expanded:k,onToggleExpanded:S,onOpen:s,timeMeta:j($r(v))},v.key),renderItem:v=>{const k=qf(v.item,f??null),N=v.item.kind==="userMessage"?v.item.createdAt?vt(k):p:v.item.createdAt?t.jsx(wr,{absoluteLabel:vt(k),timestamp:k,turnStartedAt:b??f}):p;return t.jsx(ua,{threadId:a,item:v.item,scrollRootRef:o,timeLabel:N,timeTitle:v.item.createdAt?Wt(k):g,timeMeta:j(k),autoOpenToolDetails:w&&v.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},v.key)}})}var Ps=3,eg=3,Zn=80;function gr(e,r=Zn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function tg(e,r){const n=e.getBoundingClientRect(),a=r.getBoundingClientRect(),o=Math.max(n.top,a.top),s=Math.min(n.bottom,a.bottom);return Math.max(0,s-o)>0}function rg(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function ng(e,r){return{id:e,startedAt:rg(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Rs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function ag({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((p,g)=>{s({title:p,text:g})},[]),i=c.useCallback((p,g,b)=>{if(b&&r){r({item:p,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:b,loadingText:w,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Rs(p,g,b),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const v=n.current+1;n.current=v,j&&r||s({title:g,text:w});try{const k=await e(p.id);if(a.current.set(p.id,k),n.current!==v)return;i(p,k,j)}catch(k){if(n.current!==v)return;i(p,Rs(p,g,k instanceof Error?k.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var b;await d({item:p,fallbackTitle:g,fallbackText:((b=p.detailText)==null?void 0:b.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,b,w,x)=>{await d({item:p,fallbackTitle:g,fallbackText:b,loadingText:w,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function sg(e){const r=c.useRef(null),n=c.useRef(0),a=r.current;return(a===null||a.length!==e.length||e.some((s,l)=>!Object.is(s,a[l])))&&(n.current+=1,r.current=e),n.current}function og({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:o,scrollRequestKey:s,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(s),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),b=c.useRef(0),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),v=c.useRef(!0),k=c.useRef(!1),S=c.useRef(!1),N=c.useRef(!1),L=c.useRef(!1),R=c.useRef(null),P=c.useRef(0),[Q,D]=c.useState(Ps),[Z,J]=c.useState(0),[z,te]=c.useState(!0),se=sg(d),$=typeof o=="function"||n!==void 0,le=n??r,q=$?0:Math.max(0,r-Q),G=($?Math.max(0,le-r):0)+q,T=$?r:r-q,F=$?0:r-T,B=$?Math.max(0,le-r):0,E=$?B+F:F,C=!$&&E>0&&Z>=2,W=$&&B>0&&F===0&&typeof o=="function",U=c.useCallback(()=>{const Y=h.current;if(!Y){w.current=null;return}w.current={scrollHeight:Y.scrollHeight,scrollTop:Y.scrollTop}},[]),ne=c.useCallback(()=>!W||a||N.current?!1:(U(),N.current=!0,L.current=!1,P.current=0,o==null||o(),!0),[W,a,o,U]),K=c.useCallback(()=>{const Y=h.current,ue=x.current;if(!Y)return;const ke=ue?tg(Y,ue):gr(Y);y.current=ke,te(we=>we===ke?we:ke)},[]),ie=c.useCallback(()=>{const Y=h.current;if(Y){S.current=!0;const ue=Y.scrollTop,ke=b.current,we=ue-ke;b.current=ue,gr(Y,1)?(k.current=!1,v.current=!0):we<-1?(k.current=!0,v.current=!1):we>1&&(v.current=!k.current&&gr(Y,Zn)),ue<=0&&S.current?L.current=!0:ue>0&&(L.current=!1,P.current=0)}K()},[K]),ee=c.useCallback(()=>{const Y=h.current;Y&&(Y.scrollTop=Y.scrollHeight,b.current=Y.scrollTop,g.current=Y.scrollHeight,y.current=!0,te(ue=>ue||!0),k.current=!1,v.current=!0)},[]),ve=c.useCallback(()=>{const Y=h.current;Y&&(b.current=Y.scrollTop,g.current=Y.scrollHeight,v.current=!1,k.current=!0)},[]),oe=c.useCallback(()=>{if($&&F===0){ne();return}D(Y=>Math.min(r,Y+eg)),J(Y=>Y+1)},[F,$,ne,r]),ye=c.useCallback(Y=>{const ue=h.current;if(!(!ue||Y.deltaY>=-8||ue.scrollTop>0||!W)){if(!L.current){L.current=!0;return}ne()}},[W,ne]),Me=c.useCallback(Y=>{var ue;R.current=((ue=Y.touches.item(0))==null?void 0:ue.clientY)??null,P.current=0},[]),de=c.useCallback(Y=>{var Fe;const ue=h.current,ke=((Fe=Y.touches.item(0))==null?void 0:Fe.clientY)??null,we=R.current;if(R.current=ke,!ue||ke===null||we===null||ue.scrollTop>0||!W){P.current=0;return}const De=ke-we;if(De<=0){P.current=0;return}if(!L.current){L.current=!0,P.current=0;return}P.current+=De,P.current>=28&&ne()},[W,ne]),Ce=c.useCallback(()=>{R.current=null,P.current=0},[]),Ee=c.useCallback(()=>{D(r)},[r]);return c.useLayoutEffect(()=>{const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[e,ee]),c.useEffect(()=>{N.current=!1,S.current=!1,L.current=!1,w.current=null},[e]),c.useEffect(()=>{a||(N.current=!1)},[a,r]),c.useLayoutEffect(()=>{const Y=w.current,ue=h.current;if(!Y||!ue||a)return;w.current=null;const ke=ue.scrollHeight-Y.scrollHeight;if(ke<=0){g.current=ue.scrollHeight,b.current=ue.scrollTop;return}const we=Y.scrollTop+ke;ue.scrollTop=we,b.current=we,g.current=ue.scrollHeight,k.current=!0,v.current=!1,L.current=!1},[a,r]),c.useEffect(()=>{D(Y=>Y>=r-1?r:Math.max(Y,Ps))},[r]),c.useEffect(()=>{const Y=h.current;Y&&(g.current=Y.scrollHeight,b.current=Y.scrollTop,gr(Y,1)?(k.current=!1,v.current=!0):(k.current||!gr(Y,Zn))&&(v.current=!1)),K()},[se,K,Q]),c.useEffect(()=>{const Y=s!==m.current,ue=f.current!==se;if(f.current=se,!(Y||ue&&v.current&&!k.current))return;const we=window.requestAnimationFrame(()=>{ee()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(we)}},[se,z,ee,s]),c.useEffect(()=>{const Y=h.current,ue=u.current;if(!Y||!ue||typeof ResizeObserver>"u")return;g.current=Y.scrollHeight;const ke=new ResizeObserver(()=>{const we=Y.scrollHeight,De=g.current;if(g.current=we,we<=De)return;const Fe=De>0&&De-Y.scrollTop-Y.clientHeight<=1;k.current||!(v.current||Fe||y.current)||window.requestAnimationFrame(()=>{ee()})});return ke.observe(ue),()=>{ke.disconnect()}},[ee]),c.useEffect(()=>{if(!v.current||k.current){p.current=l;return}if(l===p.current)return;p.current=l;const Y=window.requestAnimationFrame(()=>{ee()});return()=>{window.cancelAnimationFrame(Y)}},[l,ee]),c.useEffect(()=>{i==null||i(z)},[z,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:z,handleScroll:ie,handleWheel:ye,handleTouchStart:Me,handleTouchMove:de,handleTouchEnd:Ce,preserveScrollPositionForResize:ve,serverManagedHistory:$,effectiveTotalTurnCount:le,startIndex:q,visibleTurnAbsoluteOffset:G,hiddenCount:E,loadedHiddenCount:F,unloadedHiddenCount:B,showLoadAll:C,handleLoadEarlierClick:oe,handleLoadAllClick:Ee}}function lg(e){return e==="completed"||e==="failed"||e==="interrupted"}function ig(e,r){if(!r||r.id!==e.id||r.items.length===0)return e;const n=new Set(e.items.map(o=>o.id)),a=r.items.filter(o=>!n.has(o.id));return a.length===0?e:{...e,items:[...a,...e.items]}}function dg({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,previousTurnScrollRequestKey:p=0,nextTurnScrollRequestKey:g=0,bottomSpacer:b=0,className:w="",onTailVisibilityChange:x,onPreviousTurnAvailabilityChange:j,onNextTurnAvailabilityChange:y,loadingEarlier:v=!1,onLoadEarlier:k,ephemeralUserNote:S=null,answeredRequestNotes:N=[],activityNotes:L=[],optimisticSteers:R=[],optimisticTurn:P=null,onLoadHistoryItemDetail:Q,onOpenThread:D,onSelectArtifact:Z,onSelectHistoryItemDetail:J,adapter:z,autoCollapseCompletedTurns:te}){var st,ct,gt,Rt,wt;const se=ll(),$=te??(se==null?void 0:se.autoCollapseCompletedTurns)??!1,[le,q]=c.useState({}),[H,G]=c.useState(()=>new Set),T=c.useRef(null),F=c.useRef(null),B=(z==null?void 0:z.onLoadHistoryItemDetail)??Q,E=z==null?void 0:z.onOpenLinkedThread,{expandedText:C,openExpandedText:W,openCommandDetail:U,openToolCallDetail:ne,openDeferredHistoryItemDetail:K,closeExpandedText:ie}=ag({loadHistoryItemDetail:B,onSelectHistoryItemDetail:J}),{scrollContainerRef:ee,scrollContentRef:ve,tailSentinelRef:oe,topSentinelRef:ye,handleScroll:Me,handleWheel:de,handleTouchStart:Ce,handleTouchMove:Ee,handleTouchEnd:Y,preserveScrollPositionForResize:ue,serverManagedHistory:ke,effectiveTotalTurnCount:we,startIndex:De,visibleTurnAbsoluteOffset:Fe,hiddenCount:Ae,loadedHiddenCount:Oe,unloadedHiddenCount:V,showLoadAll:ce,handleLoadEarlierClick:xe,handleLoadAllClick:I}=og({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:v,onLoadEarlier:k,scrollRequestKey:f,bottomSpacer:b,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,R,m,i,d,P,N,L,S,b]}),O=c.useCallback((A,pe)=>{q(ze=>({...ze,[A]:!pe}))},[]),ae=c.useCallback((A,pe)=>{const ze=le[A.id];return ze!==void 0?ze:!!($&&lg(A.status)&&!pe.forceActive&&!pe.hasLiveActivity)},[le,$]),be=ke?r:r.slice(De),je=we+1,Te=s&&(!o||!be.some(A=>A.id===o)&&(P==null?void 0:P.id)!==o),fe=(P==null?void 0:P.id)??((st=be.at(-1))==null?void 0:st.id)??null,Be=Te&&fe!==null,_e=!!d&&(be.some(A=>A.id===d.turnId)||(P==null?void 0:P.id)===d.turnId),Qe=d&&_e?d.turnId:d&&Be?fe:null,et=P&&Qe===P.id?(d==null?void 0:d.items)??null:null,it=((d==null?void 0:d.items.length)??0)>0,tt=d&&Qe===null?d.items:null,Ke=c.useMemo(()=>d&&Qe===null&&d.items.length>0?ng(d.turnId,d.items):null,[d,Qe]),dt=Math.max(1,we+(P?1:0)),ft=!!m&&!!P&&P.status!=="failed"&&!et,Ve=m&&be.length>0?o&&be.some(A=>A.id===o)?o:((ct=be.findLast(A=>pl(A.status)))==null?void 0:ct.id)??(Be?fe:null):null,M=!!Ve,X=c.useMemo(()=>ml(m),[m]),ge=[...l.map(A=>({id:A.id,prompt:A.prompt,status:"Accepted",createdAt:A.createdAt,canCancel:!0})),...R.map(A=>({id:A.id,prompt:A.prompt,status:A.status==="steering"?"Steering":null,createdAt:A.createdAt,canCancel:!1}))].sort((A,pe)=>A.createdAt.localeCompare(pe.createdAt)),Ne=c.useMemo(()=>ef({answeredRequestNotes:N,pendingRequests:a,visibleTurns:be,optimisticTurn:P}),[N,P,a,be]),Pe=c.useMemo(()=>tf({activityNotes:L,visibleTurns:be,optimisticTurn:P}),[L,P,be]),rt=c.useCallback(()=>{const A=ee.current;if(!A)return null;const pe=A.getBoundingClientRect().top;return Array.from(A.querySelectorAll("[data-timeline-turn]")).find(ze=>ze.getBoundingClientRect().top>pe+8)??null},[ee]),nt=c.useCallback(()=>{const A=ee.current;if(!A)return null;const pe=A.getBoundingClientRect().top;return Array.from(A.querySelectorAll("[data-timeline-turn]")).findLast(ze=>ze.getBoundingClientRect().top<pe-8)??null},[ee]),$e=c.useCallback(()=>{j==null||j(!!nt())},[nt,j]),We=c.useCallback(()=>{y==null||y(!!rt())},[rt,y]),ut=c.useCallback(()=>{Me(),$e(),We()},[Me,We,$e]);return c.useEffect(()=>{$e(),We()},[We,$e,be]),c.useEffect(()=>{if(p===0)return;const A=ee.current,pe=nt(),ze=A?Array.from(A.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?ze.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===T.current?ze[Ge-1]??null:pe;if(!A||!Ue)return;T.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-A.getBoundingClientRect().top;A.scrollTo({top:A.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===0&&(j==null||j(!1))},[nt,j,p,ee]),c.useEffect(()=>{if(g===0)return;const A=ee.current,pe=rt(),ze=A?Array.from(A.querySelectorAll("[data-timeline-turn]")):[],Ge=pe?ze.indexOf(pe):-1,Ue=pe&&pe.dataset.turnId===F.current?ze[Ge+1]??null:pe;if(!A||!Ue)return;F.current=Ue.dataset.turnId??null;const mt=Ue.getBoundingClientRect().top-A.getBoundingClientRect().top;A.scrollTo({top:A.scrollTop+mt-8,behavior:"smooth"}),ze.indexOf(Ue)===ze.length-1&&(y==null||y(!1))},[rt,g,y,ee]),t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${w}`.trim(),children:t.jsx("div",{ref:ee,"data-testid":"thread-scroll-container",onScroll:ut,onWheel:de,onTouchStart:Ce,onTouchMove:Ee,onTouchEnd:Y,onTouchCancel:Y,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:b>0?{paddingBottom:b}:void 0,children:t.jsxs("div",{ref:ve,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:ye,"aria-hidden":"true",className:"h-px"}),r.length>0&&t.jsx("div",{className:"thread-graph-history-control px-3 pb-1 pt-2 sm:px-5 sm:pb-1.5 sm:pt-3",children:t.jsxs("div",{className:"flex flex-wrap items-center gap-2.5 text-xs sm:text-sm",children:[Ae>0&&t.jsx("button",{type:"button",onClick:xe,disabled:v,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:v?"Loading earlier...":"Load 3 earlier"}),ce&&t.jsx("button",{type:"button",onClick:I,className:"rounded-full border border-amber-300/40 px-2.5 py-1.5 text-amber-200 transition hover:bg-amber-300/10",children:"Load full history"}),t.jsxs("p",{className:"timeline-meta-text",children:["Showing ",be.length," of ",we," turns",Ae>0?` · ${Ae} earlier hidden${Oe>0&&V>0?` (${Oe} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!P&&t.jsx("div",{className:"thread-graph-empty-state px-3 py-8 text-sm sm:px-5",children:"Send the first prompt to start the thread."}),(be.length>0||P||Pe.leading.length>0||Pe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Pe.leading.length>0?t.jsx(pr,{notes:Pe.leading,onOpenThread:D,onOpenLinkedThread:E}):null,be.map((A,pe)=>{var ze,Ge,Ue,mt,yt;return t.jsxs("div",{"data-timeline-turn":!0,"data-turn-id":A.id,children:[(((ze=Pe.beforeTurnId.get(A.id))==null?void 0:ze.length)??0)>0?t.jsx(pr,{notes:Pe.beforeTurnId.get(A.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Ge=Ne.beforeTurnId.get(A.id))==null?void 0:Ge.length)??0)>0?t.jsx(Xn,{entries:Ne.beforeTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Kt=ig(A,P),Xt=(i==null?void 0:i.turnId)===A.id?i:null,Mt=Qe===A.id?(d==null?void 0:d.items)??null:null,cr=Ve===A.id?m:"",ot=o===A.id||Be&&fe===A.id,dn=!!Xt||!!cr||!!(Mt&&Mt.length>0),cn=ae(Kt,{forceActive:ot,hasLiveActivity:dn});return t.jsx(Tn,{threadId:e,...z?{adapter:z}:{},turn:Kt,absoluteIndex:Fe+pe+1,isCollapsed:cn,livePlan:Xt,liveItems:Mt,liveOutput:cr,forceActive:ot,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee,articleRef:void 0})})(),(((Ue=Pe.afterTurnId.get(A.id))==null?void 0:Ue.length)??0)>0?t.jsx(pr,{notes:Pe.afterTurnId.get(A.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(mt=Ne.notesByTurnId.get(A.id))!=null&&mt.length||(yt=Ne.pendingRequestsByTurnId.get(A.id))!=null&&yt.length?t.jsx(rf,{notes:Ne.notesByTurnId.get(A.id)??[],requests:Ne.pendingRequestsByTurnId.get(A.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},A.id)}),P&&be.every(A=>A.id!==P.id)&&t.jsxs(t.Fragment,{children:[(((gt=Pe.beforeTurnId.get(P.id))==null?void 0:gt.length)??0)>0?t.jsx(pr,{notes:Pe.beforeTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null,(((Rt=Ne.beforeTurnId.get(P.id))==null?void 0:Rt.length)??0)>0?t.jsx(Xn,{entries:Ne.beforeTurnId.get(P.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const A=ft?m:"",pe=o===P.id||Be&&fe===P.id,ze=!!(et&&et.length>0)||!!A,Ge=ae(P,{forceActive:pe,hasLiveActivity:ze});return t.jsx(Tn,{threadId:e,...z?{adapter:z}:{},turn:P,absoluteIndex:je,isCollapsed:Ge,livePlan:null,liveItems:et,liveOutput:A,forceActive:pe,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee})})(),(((wt=Pe.afterTurnId.get(P.id))==null?void 0:wt.length)??0)>0?t.jsx(pr,{notes:Pe.afterTurnId.get(P.id)??[],onOpenThread:D,onOpenLinkedThread:E}):null]})]}),ge.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:ge.map(A=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(It,{threadId:e,item:{id:A.id,kind:"userMessage",text:A.prompt,status:A.status},scrollRootRef:ee,onBeforeMessageResize:ue,...z?{adapter:z}:{}}),e&&A.canCancel&&(z!=null&&z.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:H.has(A.id),onClick:()=>{var pe;G(ze=>new Set(ze).add(A.id)),Promise.resolve((pe=z.cancelPendingSteer)==null?void 0:pe.call(z,e,A.id)).catch(()=>{}).finally(()=>{G(ze=>{const Ge=new Set(ze);return Ge.delete(A.id),Ge})})},children:H.has(A.id)?"Canceling...":"Cancel"})}):null]},A.id))}),(Ne.trailing.length>0||Pe.trailing.length>0)&&t.jsx(nf,{entries:[...Pe.trailing.map(A=>({kind:"activity",id:A.id,createdAt:A.createdAt,note:A})),...Ne.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:D,onOpenLinkedThread:E}),S&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(It,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:S},scrollRootRef:ee,onBeforeMessageResize:ue})}),Ke&&tt&&tt.length>0&&t.jsx(Tn,{threadId:e,...z?{adapter:z}:{},turn:Ke,absoluteIndex:dt,isCollapsed:le[Ke.id]??!1,livePlan:(i==null?void 0:i.turnId)===Ke.id?i:null,liveItems:tt,liveOutput:"",forceActive:!0,onToggleCollapse:O,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},scrollRootRef:ee}),m&&!M&&!ft&&!it&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:X?t.jsx(ua,{threadId:e,item:X,scrollRootRef:ee,onOpenExpandedText:W,onOpenCommandDetail:U,onOpenToolCallDetail:ne,onOpenDeferredHistoryItemDetail:K,onBeforeMessageResize:ue,...Z?{onSelectArtifact:Z}:{},...z?{adapter:z}:{}}):t.jsx(It,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:ee,streaming:!0,onBeforeMessageResize:ue,...z?{adapter:z}:{}})}),t.jsx("div",{ref:oe,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(bp,{open:C!==null,title:(C==null?void 0:C.title)??"Full text",text:(C==null?void 0:C.text)??"",onClose:ie})]})}var Cl=c.memo(dg);function cg(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Jn(e){return e.replace(/\r\n/g,`
3667
3700
  `)}function Ms(e){const r=Jn(e),n=r.split(`
3668
3701
  `);return r.endsWith(`
3669
- `)&&n.at(-1)===""&&n.pop(),n}function lg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function ig(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...o]=e;if(a===void 0)return e;const s=a.trim();return s===n||s.endsWith(` ${n}`)||s.endsWith(`$ ${n}`)||s.endsWith(`% ${n}`)||s.endsWith(`# ${n}`)||s.endsWith(`> ${n}`)?o:e}function dg(e,r,n){var d,h;const a=Ms(e),o=Ms(r);let s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s+=1;let l=0;for(;l<a.length-s&&l<o.length-s&&a[a.length-1-l]===o[o.length-1-l];)l+=1;let i=o.slice(s,o.length-l);for(i=ig(i,n);i.length>0&&((d=i[0])==null?void 0:d.trim())==="";)i.shift();for(;i.length>0&&(((h=i.at(-1))==null?void 0:h.trim())===""||lg(i.at(-1)??""));)i.pop();return i.join(`
3670
- `).trimEnd()}function cg(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function As(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function En(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function ln(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ma(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function Ln(e){return Math.min(75,Math.max(25,e))}function hg(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function ug({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function _s(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function In({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var mg=120,pg=800,fg=4e3,gg=4500,xg="Shell connection timed out. Reconnecting...";function bg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:xg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function vg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function kg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function wg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:kg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function yg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Sl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:o,hasTerminal:s,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||o===e||!s?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:yg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function jg({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:o}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:o?{type:"joinPending"}:{type:"startAttach"}}function Ng({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Cg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Sg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Tl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function Tg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Tl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Eg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=Tl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:o,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:s,shouldCloseSocket:!0,shouldClearSocketRef:l}}function Lg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:o}){return o?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function Ig(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:ma(n??ln(r),a),isCommandRunning:e.isCommandRunning===!0}}function zg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Jn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:dg(o.beforeSnapshot,s,o.command)}}function Pg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const o=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:o==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:o==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function El(e,r,n,a,o){const s=r.replace(/\r\n/g,`
3702
+ `)&&n.at(-1)===""&&n.pop(),n}function hg(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function ug(e,r){const n=r.trim();if(!n||e.length===0)return e;const[a,...o]=e;if(a===void 0)return e;const s=a.trim();return s===n||s.endsWith(` ${n}`)||s.endsWith(`$ ${n}`)||s.endsWith(`% ${n}`)||s.endsWith(`# ${n}`)||s.endsWith(`> ${n}`)?o:e}function mg(e,r,n){var d,h;const a=Ms(e),o=Ms(r);let s=0;for(;s<a.length&&s<o.length&&a[s]===o[s];)s+=1;let l=0;for(;l<a.length-s&&l<o.length-s&&a[a.length-1-l]===o[o.length-1-l];)l+=1;let i=o.slice(s,o.length-l);for(i=ug(i,n);i.length>0&&((d=i[0])==null?void 0:d.trim())==="";)i.shift();for(;i.length>0&&(((h=i.at(-1))==null?void 0:h.trim())===""||hg(i.at(-1)??""));)i.pop();return i.join(`
3703
+ `).trimEnd()}function pg(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function As(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function En(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function ln(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ma(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function Ln(e){return Math.min(75,Math.max(25,e))}function fg(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function gg({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function _s(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-3.5 w-3.5 fill-none stroke-current",strokeWidth:"1.35",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5.5 3.25h5"}),t.jsx("path",{d:"M6.4 2h3.2a.9.9 0 0 1 .9.9v.35h1.3a1.2 1.2 0 0 1 1.2 1.2v7.35a1.2 1.2 0 0 1-1.2 1.2H4.2A1.2 1.2 0 0 1 3 11.8V4.45a1.2 1.2 0 0 1 1.2-1.2h1.3V2.9a.9.9 0 0 1 .9-.9Z"})]})}function In({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var xg=120,bg=800,vg=4e3,kg=4500,wg="Shell connection timed out. Reconnecting...";function yg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:wg,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function jg({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function Ng({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function Cg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:Ng({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function Sg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function Sl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:o,hasTerminal:s,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||o===e||!s?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:Sg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function Tg({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:o}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:o?{type:"joinPending"}:{type:"startAttach"}}function Eg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function Lg({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function Ig({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function Tl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function zg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:Tl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function Pg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=Tl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:o,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:s,shouldCloseSocket:!0,shouldClearSocketRef:l}}function Rg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:o}){return o?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function Mg(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:ma(n??ln(r),a),isCommandRunning:e.isCommandRunning===!0}}function Ag({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Jn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:mg(o.beforeSnapshot,s,o.command)}}function _g({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const o=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:o==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:o==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function El(e,r,n,a,o){const s=r.replace(/\r\n/g,`
3671
3704
  `),l=s.split(`
3672
3705
  `);s.endsWith(`
3673
3706
  `)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
3674
3707
  `);if(n!==void 0&&a!==void 0){const u=(o!==void 0?Math.max(0,l.length-o):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function $s(e){return e?Array.from(e.querySelectorAll(".xterm-rows > div")).map(n=>n.textContent??"").filter((n,a,o)=>n.length>0||a<o.length-1).join(`
3675
- `).trimEnd():""}function Rg({clearTimeout:e}){let r=null;const n=o=>{(o==null?void 0:o.timer)!==null&&(o==null?void 0:o.timer)!==void 0&&e(o.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(o=>{r==null||r.waiters.push(o)}),start:({timeoutMs:o,setTimeout:s,onTimeout:l})=>new Promise(i=>{const d=s(()=>{r=null,l(),i(!1)},o);r={waiters:[i],timer:d}}),settle:o=>{const s=r;if(s){r=null,n(s);for(const l of s.waiters)l(o)}},clear:()=>{const o=r;r=null,n(o)}}}var Ds={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function gt(e){return e.status!=="exited"&&e.status!=="not_found"}function Mg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&gt(e))}function Ag(e,r){return e.status===r.status&&e.shellInputEnabled===r.shellInputEnabled&&e.isConnecting===r.isConnecting&&e.isCommandRunning===r.isCommandRunning&&e.promptLabel===r.promptLabel&&e.error===r.error&&e.hasShell===r.hasShell}function _g(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&gt(r)):null)??(e.shell&&gt(e.shell)?e.shell:null)??e.shells.find(gt)??null}function $g({activeRuntime:e,activeShell:r,busy:n,loading:a,status:o,workspacePathMissing:s}){const l=n||a||o==="creating"||s,i=e.shellInputEnabled?"Disconnect shell":r&&!gt(r)?"Restart shell":r?"Connect shell":"Create shell",d=e.shellInputEnabled?"border-emerald-300/45 bg-emerald-300/18 text-emerald-50 ring-1 ring-emerald-300/20 hover:bg-emerald-300/24":r&&!gt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":s?"border-rose-300/35 bg-rose-300/12 text-rose-100":"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800";return{disabled:l,label:i,className:d}}function Dg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:o,busy:s,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?ma(ln(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Ht(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Bg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=mg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Gg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=pg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Fg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=fg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=bg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(o(d.connectionError),s(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Hg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function Og({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Eg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:o.current!==null,isCurrentSocket:((i=s.current)==null?void 0:i.socket)===n.socket})}function Wg({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:o,setViewerId:s,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ht(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Hg,"detached"),u.shouldScheduleReconnect&&Gg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function Ug({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ht(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ht(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Vg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Kg(e){return Sl({...e,attachSize:void 0})}function qg({attachSize:e,...r}){return Sl({...r,attachSize:e})}function Xg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=vg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function Yg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function Zg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=Ig(e.payload,r),s=o.data?zg({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function Jg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=wg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o});return{closeAction:l,shouldClearAttachTimeout:!!(l&&s),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function Qg(e,r){return r.shellUpdate?{...e,status:r.shellUpdate.status==="attached"||r.shellUpdate.status==="detached"||r.shellUpdate.status==="exited"||r.shellUpdate.status==="not_found"?r.shellUpdate.status:e.status,attachedViewerId:r.shellUpdate.attachedViewerId===void 0?e.attachedViewerId:r.shellUpdate.attachedViewerId}:e}function ex(e){return e.current}function tx({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:k,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:w,setReconnectKey:y,setViewerId:v,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:I,setIsCommandRunning:M,settleAttachPromise:R,onShellUpdate:Q}){const $=e==null?void 0:e.id,Y=e==null?void 0:e.cwd;c.useEffect(()=>{const Z=s.current,P={shellId:$??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Z,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===$),hasReconnectTimer:h.current!==null};if(Kg(P).type==="skip")return;const oe=w.current(),T=qg({...P,attachSize:oe});if(T.type==="skip"||T.type==="measureSize")return;if(T.type==="scheduleRetry"){Bg({attachRetryTimerRef:m,setReconnectKey:y});return}if(T.shouldClearAttachRetry&&Ht(m),T.type==="reuseSocket"||(T.shouldClearReconnectTimer&&Ht(h),!$||!Z))return;const re=T.attachSize;d.current=$,Z.reset(),N(null),v(null),S(!0),p.current=!1;const B=r.connectSocket({onConnected:()=>{var q;const J=u.current,K=Xg({isCurrentSocket:((q=l.current)==null?void 0:q.socket)===B.socket,shellId:$,attachSize:re,hasAttachTimeout:J!==null}),L=K.openAction;L&&(B.send(L.message),K.shouldClearAttachTimeout&&J!==null&&Ht(u),L.shouldScheduleAttachTimeout&&Fg({shellSocket:B,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:R}))},onShellEvent:J=>{var q;if(!Vg({eventShellId:J.shellId,shellId:$,socketExists:!!B.socket,isCurrentSocket:((q=l.current)==null?void 0:q.socket)===B.socket}))return;if(J.type==="shell.connected"){Ht(u);const G=Yg(J);v(G.viewerId),S(!1),R(G.settleAttachPromise),Q($,G.nextShell,"attached");return}if(J.type==="shell.output"){const{output:G,snapshotUpdate:E}=Zg({event:J,shellCwd:Y,currentSnapshot:b.current,pendingCommand:k.current});j.current={cursorX:G.cursorX,cursorY:G.cursorY,paneHeight:G.paneHeight},I(G.promptLabel),M(G.isCommandRunning),E&&(b.current=E.nextSnapshot,k.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),G.replace?El(Z,G.data,G.cursorX,G.cursorY,G.paneHeight):Z.write(G.data));return}const L=Pg({event:J,currentViewerId:i.current});L&&(L.viewerId!==void 0&&v(L.viewerId),L.isConnecting!==void 0&&S(L.isConnecting),L.settleAttachPromise!==void 0&&R(L.settleAttachPromise),L.isCommandRunning!==void 0&&M(L.isCommandRunning),L.connectionError!==void 0&&N(L.connectionError),L.intentionalDisconnect!==void 0&&(p.current=L.intentionalDisconnect),L.shellUpdate&&Q($,G=>Qg(G,L),L.shellUpdate.status),L.closeSocket&&B.socket.close())}});return l.current=B,B.socket.addEventListener("close",()=>{var L;const J=u.current,K=Jg({isCurrentSocket:((L=l.current)==null?void 0:L.socket)===B.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:$,hasAttachTimeout:J!==null});Wg({closeApplication:K,shellId:$,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:v,setIsConnecting:S,settleAttachPromise:R,onShellUpdate:Q,setReconnectKey:y})}),()=>{const J=ex(i),K=Og({shellId:$,viewerId:J,shellSocket:B,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Ug({cleanupAction:K,shellSocket:B,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:v,setIsConnecting:S,settleAttachPromise:R})}},[m,u,n,p,f,x,Q,k,o,h,N,M,S,y,I,v,R,Y,$,r,d,b,j,l,w,a,s,g,i])}function zn(e){return e.current}var Bs=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),k=c.useRef(null),x=c.useRef(null),j=c.useRef(null),w=c.useRef(null),y=c.useRef(null),v=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),I=c.useRef(""),M=c.useRef(null),R=c.useRef(""),Q=c.useRef(null),$=c.useRef(null),Y=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Z=c.useRef(!1),P=c.useRef(null),te=c.useRef(o),oe=c.useRef(s),T=c.useRef(()=>!1),re=c.useRef(()=>null),B=c.useRef(()=>{}),J=c.useRef(Rg({clearTimeout:window.clearTimeout})),[K,L]=c.useState(null),[q,G]=c.useState(!1),[E,C]=c.useState(null),[W,H]=c.useState(!1),[se,V]=c.useState(null),[de,ee]=c.useState(null),[be,ie]=c.useState(!1),[ye,Ae]=c.useState(0),ce=(n==null?void 0:n.status)??"not_created",Ce=Mg({shell:n,workspacePathMissing:i}),Le=c.useMemo(()=>ma(ln(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),X=de??Le,ue=c.useCallback(F=>{x.current=F,C(F)},[]),ve=c.useCallback(F=>{J.current.settle(F)},[]);c.useEffect(()=>{te.current=o},[o]),c.useEffect(()=>{oe.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ke=c.useCallback(F=>{const le=k.current,we=j.current,z=x.current;return!le||!we||!z?!1:(le.send({type:"shell.input",shellId:we,viewerId:z,data:F}),!0)},[]);c.useEffect(()=>{T.current=ke},[ke]);const $e=c.useCallback(()=>{const F=k.current,le=j.current,we=x.current;return!F||!le||!we?!1:(F.send({type:"shell.clear",shellId:le,viewerId:we}),!0)},[]),He=c.useCallback(()=>{if(!o||!K)return!1;const F=K.getBoundingClientRect();return F.width>0&&F.height>0},[o,K]),_e=c.useCallback(F=>{const le=g.current,we=b.current;if(!le||!we||!He()||(we.fit(),le.cols<=0||le.rows<=0))return null;const z={cols:le.cols,rows:le.rows},O=Lg({size:z,previousSize:$.current,shellId:j.current,viewerId:x.current,syncBackendSize:(F==null?void 0:F.syncBackendSize)!==!1});return(F==null?void 0:F.syncBackendSize)===!1||($.current=O.nextLastSentSize,!O.message)||k.current&&k.current.send(O.message),z},[He]);c.useEffect(()=>{re.current=_e},[_e]);const ze=c.useCallback(F=>{const le=g.current;!le||!He()||(_e((F==null?void 0:F.syncBackendSize)===void 0?void 0:{syncBackendSize:F.syncBackendSize}),I.current&&!$s(K)?El(le,I.current,Y.current.cursorX,Y.current.cursorY,Y.current.paneHeight):le.scrollToBottom(),F!=null&&F.focus&&!s&&le.focus())},[s,He,_e,K]);return c.useEffect(()=>{B.current=()=>ze()},[ze]),c.useEffect(()=>{m({status:E?"attached":ce,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:be,promptLabel:X,error:se,hasShell:!!n})},[se,W,be,m,X,n,ce,E]),c.useEffect(()=>{if(!K||g.current||Z.current)return;let F=!1;return Z.current=!0,(async()=>{const[{Terminal:le},{FitAddon:we}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ne=>ne.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ne=>ne.a),__vite__mapDeps([6,2,7]))]);if(F||!K){Z.current=!1;return}const z=new le({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:As(l)}),O=new we;z.loadAddon(O),z.open(K),g.current=z,b.current=O,re.current(),z.attachCustomKeyEventHandler(ne=>{if(oe.current||ne.type!=="keydown")return!0;if(ne.ctrlKey&&!ne.altKey&&!ne.metaKey&&!ne.shiftKey){const ge=og(ne.key);if(!ge)return!0;if(T.current(ge))return ne.preventDefault(),!1}return!0}),G(!0),Z.current=!1,Q.current=new ResizeObserver(()=>{B.current()}),Q.current.observe(K),P.current=z.onData(ne=>{oe.current||T.current(ne)})})(),()=>{var le,we,z;F=!0,Z.current=!1,(le=P.current)==null||le.dispose(),P.current=null,(we=Q.current)==null||we.disconnect(),Q.current=null,G(!1),(z=g.current)==null||z.dispose(),g.current=null,b.current=null,$.current=null}},[l,K]),c.useEffect(()=>{var le;const F=Cg({hasShell:!!n});F&&(ue(F.viewerId),H(F.isConnecting),ve(F.settleAttachPromise),V(F.connectionError),ee(F.runtimePromptLabel),ie(F.isCommandRunning),I.current=F.shellSnapshot,R.current=F.lastCommandOutput,M.current=F.pendingCommand,F.shouldResetTerminal&&((le=g.current)==null||le.reset()))},[ue,ve,n]),c.useEffect(()=>{const F=g.current;F&&(F.options.theme=As(l))},[l]),c.useEffect(()=>{const F=g.current;F&&(F.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!q)return;const F=window.requestAnimationFrame(()=>{ze({focus:a,syncBackendSize:!1}),!k.current&&(n!=null&&n.id)&&N.current!==n.id&&Ae(le=>le+1)});return()=>{window.cancelAnimationFrame(F)}},[a,o,ze,n==null?void 0:n.id,q]),tx({shell:n,shellAdapter:d,canAttachShell:Ce,terminalReady:q,reconnectKey:ye,terminalRef:g,socketRef:k,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:w,attachTimeoutRef:y,attachRetryTimerRef:v,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:I,pendingCommandRef:M,lastCommandOutputRef:R,snapshotCursorRef:Y,syncTerminalSizeRef:re,setReconnectKey:Ae,setViewerId:ue,setIsConnecting:H,setConnectionError:V,setRuntimePromptLabel:ee,setIsCommandRunning:ie,settleAttachPromise:ve,onShellUpdate:u}),c.useEffect(()=>()=>{const F=zn(w),le=zn(y),we=zn(v),z=Sg({hasReconnectTimer:F!==null,hasAttachTimeout:le!==null,hasAttachRetry:we!==null});z.shouldClearReconnectTimer&&F!==null&&window.clearTimeout(F),z.shouldClearAttachTimeout&&le!==null&&window.clearTimeout(le),z.shouldClearAttachRetry&&we!==null&&window.clearTimeout(we),ve(z.settleAttachPromise)},[ve]),c.useImperativeHandle(p,()=>({disconnect(){const F=k.current,le=j.current,we=x.current,z=Tg({shellId:le,viewerId:we,hasSocket:!!F});N.current=z.userDisconnectedShellId,S.current=z.intentionalDisconnect,F&&z.detachMessage&&F.send(z.detachMessage),ue(null),H(!1),ve(!1),z.shouldCloseSocket&&(F==null||F.socket.close()),k.current=null,$.current=null,z.shouldDetachShell&&le&&u(le,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const F=jg({hasShellId:!!j.current,terminalReady:q,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:J.current.hasPending()});if(F.type==="reject")return Promise.resolve(!1);if(F.type==="alreadyConnected")return Promise.resolve(!0);if(F.type==="joinPending")return J.current.joinPending();const le=J.current.start({timeoutMs:gg,setTimeout:window.setTimeout,onTimeout:()=>{H(!1)}}),we=Ng({shellId:j.current,userDisconnectedShellId:N.current});return we.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=we.intentionalDisconnect,V(we.connectionError),H(we.isConnecting),Ae(z=>z+1),le},sendInput(F){return ke(F)},sendCommand(F){const le={command:F,beforeSnapshot:I.current};if(M.current=le,F.trim()==="clear"){const O=$e();return!O&&M.current===le&&(M.current=null),O}const we=F.endsWith(`
3676
- `)?F:`${F}
3677
- `,z=ke(we);return!z&&M.current===le&&(M.current=null),z},sendControl(F){return F==="clear"?$e():ke(cg(F))},async copyLastCommandOutput(){const F=R.current.trim()||$s(K);if(!F)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(F),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var F;(F=g.current)==null||F.focus()},refreshLayout(F){ze(F)}}),[f,u,ze,$e,ke,ue,ve,K,q,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:L,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var F;h(),(F=g.current)==null||F.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),rx=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:o=!0,showFloatingToolbox:s=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),b=c.useRef(null),k=c.useRef(!1),[x,j]=c.useState(null),[w,y]=c.useState(!0),[v,S]=c.useState(!1),[N,I]=c.useState(null),[M,R]=c.useState("primary"),[Q,$]=c.useState(null),[Y,Z]=c.useState(null),[P,te]=c.useState("single"),[oe,T]=c.useState(50),[re,B]=c.useState(null),[J,K]=c.useState(""),[L,q]=c.useState(!1),[G,E]=c.useState(!1),[C,W]=c.useState(!1),[H,se]=c.useState({primary:Ds,secondary:Ds}),[V,de]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",be=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),ie=c.useMemo(()=>be.filter(gt),[be]),ye=c.useMemo(()=>ie.find(A=>A.id===Q)??null,[ie,Q]),Ae=c.useMemo(()=>ie.find(A=>A.id===Y)??null,[ie,Y]),ce=M==="secondary"?Ae:ye,Ce=H[M],Le=(x==null?void 0:x.workspacePathStatus)==="missing",X=M==="secondary"?f:m,ue=$g({activeRuntime:Ce,activeShell:ce,busy:v,loading:w,status:ee,workspacePathMissing:Le}),ve=ue.disabled,ke=ue.label,$e=ue.className,He=(V==null?void 0:V.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(V==null?void 0:V.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",_e=c.useCallback((A,U)=>{de({tone:A,text:U}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{de(null),p.current=null},1800)},[]),ze=c.useCallback((A,U,xe)=>{j(je=>{var tt;if(!je)return je;const Ne=je.shells.map(Fe=>Fe.id===A?U(Fe):Fe),Ye=((tt=je.shell)==null?void 0:tt.id)===A?U(je.shell):Ne.find(Fe=>{var Ke;return Fe.id===((Ke=je.shell)==null?void 0:Ke.id)})??je.shell;return{...je,...xe?{state:xe}:{},shell:Ye,shells:Ne}})},[]),F=c.useCallback(async()=>{y(!0);try{const A=await n.fetchState(r);j(A),I(null)}catch(A){I(A instanceof Error?A.message:"Unable to load shell state.")}finally{y(!1)}},[n,r]);c.useEffect(()=>{F()},[F]),c.useEffect(()=>{const A=i==null?void 0:i(r);if(A==null){T(50);return}const U=typeof A=="number"?A:Number.parseFloat(String(A));T(Number.isFinite(U)?Ln(U):50)},[i,r]),c.useEffect(()=>{if(!x){$(null),Z(null);return}const A=_g(x);$(U=>U&&x.shells.some(xe=>xe.id===U&&gt(xe))?U:(A==null?void 0:A.id)??null),Z(U=>{if(P!=="columns")return null;if(U&&x.shells.some(je=>je.id===U&&gt(je)))return U;const xe=x.shells.find(je=>gt(je)&&je.id!==(A==null?void 0:A.id));return(xe==null?void 0:xe.id)??null})},[x,P]),c.useEffect(()=>{P!=="columns"&&(R("primary"),Z(null))},[P]),c.useEffect(()=>{if(P!=="columns"||Y||ie.length<2)return;const A=ie.find(U=>U.id!==(ye==null?void 0:ye.id))??null;A&&Z(A.id)},[ie,ye==null?void 0:ye.id,Y,P]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const A=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),U=()=>{q(A.matches),A.matches||(W(!1),E(!1))};return U(),A.addEventListener("change",U),()=>{A.removeEventListener("change",U)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const le=c.useCallback((A,U)=>{se(xe=>{const je=xe[A];return Ag(je,U)?xe:{...xe,[A]:U}})},[]),we=c.useCallback(A=>le("primary",A),[le]),z=c.useCallback(A=>le("secondary",A),[le]),O=c.useCallback(A=>{var xe;if((xe=A.label)!=null&&xe.trim())return A.label.trim();const U=be.findIndex(je=>je.id===A.id);return`Shell ${U>=0?U+1:""}`.trim()},[be]),ne=c.useCallback(A=>{var U;B(A.id),K(((U=A.label)==null?void 0:U.trim())||O(A))},[O]),ge=c.useCallback(()=>{B(null),K("")},[]),Te=c.useCallback(async()=>{if(re){S(!0);try{const A=J.trim(),U=await n.updateShell(re,{label:A.length>0?A:null});j(xe=>{var je;return xe&&{...xe,state:xe.activeShellId===U.id?U.status:xe.state,shell:((je=xe.shell)==null?void 0:je.id)===U.id?U:xe.shell,shells:xe.shells.map(Ne=>Ne.id===U.id?U:Ne)}}),B(null),K(""),I(null)}catch(A){I(A instanceof Error?A.message:"Unable to rename shell.")}finally{S(!1)}}},[J,re,n]),Ee=c.useCallback((A,U)=>{if(A==="primary"){$(U),Z(xe=>xe===U?null:xe);return}Z(U),$(xe=>xe===U?null:xe)},[]),fe=c.useCallback(A=>{var U,xe;if(A==="primary"){(U=m.current)==null||U.disconnect(),$(null),P==="columns"&&R("secondary");return}(xe=f.current)==null||xe.disconnect(),Z(null),R("primary"),te("single")},[P]),De=c.useCallback((A,U=M)=>{const xe=P==="columns"?U:"primary";Ee(xe,A.id),P!=="columns"&&Z(null),R(xe)},[M,Ee,P]),Be=c.useCallback(async(A=M)=>{var U;if(!k.current){k.current=!0,S(!0);try{const xe=await n.createShell(r);j(xe);const je=xe.activeShellId??((U=xe.shell)==null?void 0:U.id)??null;if(je){const Ne=P==="columns"?A:"primary";Ee(Ne,je),P!=="columns"&&Z(null),R(Ne)}I(null)}catch(xe){I(xe instanceof Error?xe.message:"Unable to create shell.")}finally{k.current=!1,S(!1)}}},[M,Ee,n,P,r]);c.useEffect(()=>{!a||!x||w||v||Le||ee==="creating"||ie.length>0||Be("primary")},[v,Be,a,ie.length,w,x,ee,Le]);const et=c.useCallback(async(A=(ce==null?void 0:ce.id)??"")=>{if(A){S(!0);try{await n.terminateShell(A),$(U=>U===A?null:U),Z(U=>U===A?null:U),await F(),I(null)}catch(U){I(U instanceof Error?U.message:"Unable to terminate shell.")}finally{S(!1)}}},[ce==null?void 0:ce.id,F,n]),Ve=c.useCallback(async()=>{var A,U;if(!ve){if(Ce.shellInputEnabled){(A=X.current)==null||A.disconnect();return}if(!ce||ce.status==="exited"||ce.status==="not_found"){await Be(M);return}await((U=X.current)==null?void 0:U.reconnect())}},[M,X,Ce.shellInputEnabled,ce,ve,Be]),pt=c.useCallback(A=>{typeof window>"u"||d==null||d(r,Ln(A))},[d,r]),nt=c.useCallback(()=>{var A,U;(A=m.current)==null||A.refreshLayout({syncBackendSize:!0}),(U=f.current)==null||U.refreshLayout({syncBackendSize:!0})},[]),We=c.useCallback(A=>{var Ye,tt;if(P!=="columns")return;const U=g.current;if(!U)return;A.preventDefault(),(tt=(Ye=A.currentTarget).setPointerCapture)==null||tt.call(Ye,A.pointerId);const xe=Fe=>{const Ke=U.getBoundingClientRect();if(Ke.width<=0)return;const lt=Ln((Fe-Ke.left)/Ke.width*100);T(lt),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,nt()})},je=Fe=>{xe(Fe.clientX)},Ne=Fe=>{xe(Fe.clientX);const Ke=U.getBoundingClientRect();Ke.width>0&&pt((Fe.clientX-Ke.left)/Ke.width*100),window.removeEventListener("pointermove",je),window.removeEventListener("pointerup",Ne)};window.addEventListener("pointermove",je),window.addEventListener("pointerup",Ne,{once:!0})},[pt,nt,P]),ot=c.useCallback((A,U)=>{Ee(U,A.id),R(U)},[Ee]),ht=c.useCallback(async()=>{var U;return await((U=X.current)==null?void 0:U.copyLastCommandOutput())?!0:(_e("failed","Nothing to copy"),!1)},[X,_e]);c.useEffect(()=>{h==null||h(Dg({activeRuntime:Ce,activeShell:ce,connectionButtonDisabled:ve,connectionButtonLabel:ke,isMobileShell:L,busy:v,loading:w,error:N}))},[Ce,ce,v,ve,ke,N,L,w,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await Ve()},sendInput(A){var U;return((U=X.current)==null?void 0:U.sendInput(A))??!1},sendCommand(A){var U;return((U=X.current)==null?void 0:U.sendCommand(A))??!1},sendControl(A){var U;return((U=X.current)==null?void 0:U.sendControl(A))??!1},async copyLastCommandOutput(){var A;return await((A=X.current)==null?void 0:A.copyLastCommandOutput())??!1},async terminate(){await et()},focus(){var A;(A=X.current)==null||A.focus()},refreshLayout(A){var U,xe;(U=m.current)==null||U.refreshLayout(A),P==="columns"&&((xe=f.current)==null||xe.refreshLayout(A))}}),[X,Ve,et,P]);const ut=A=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${A.id===(ce==null?void 0:ce.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[re===A.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:U=>{U.preventDefault(),Te()},children:t.jsx("input",{value:J,onChange:U=>K(U.currentTarget.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>De(A),onDoubleClick:()=>ne(A),className:"min-w-0 flex-1 text-left",title:A.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(A)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[En(A.status)," · ",ln(A.cwd)||A.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[re===A.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Te(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>ne(A),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),P==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>ot(A,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>ot(A,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:v,onClick:()=>void et(A.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},A.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[o&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:Ce.promptLabel??(ce==null?void 0:ce.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ke,title:`${ke} (${En(Ce.status)})`,disabled:ve,onClick:()=>void Ve(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${$e}`,children:t.jsx(ug,{connected:Ce.shellInputEnabled})}),ce&&t.jsx("button",{type:"button",disabled:v,onClick:()=>void et(ce.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||w||Le)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:ce?O(ce):"No live shell process"}),ce&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:En(Ce.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",ie.length]}),t.jsx("button",{type:"button","aria-expanded":G,"aria-label":G?"Hide shell processes":"Show shell processes",onClick:()=>E(A=>!A),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),G&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[ie.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ie.map(ut),ie.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:v||w||Le,onClick:()=>void Be(M),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),ee==="not_created"||Le?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Le&&t.jsx("button",{type:"button",disabled:v||w,onClick:()=>void Be("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!o&&(N||w||Le)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[w&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!w&&Le&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!w&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${P==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:P==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(Bs,{ref:m,paneId:"primary",shell:ye,isActive:M==="primary",isVisible:a,isMobileShell:L,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>R("primary"),onShellUpdate:ze,onRuntimeStateChange:we,onFeedback:_e}),P==="columns"&&t.jsx("button",{type:"button",onClick:()=>fe("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),P==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:We,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),P==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Bs,{ref:f,paneId:"secondary",shell:Ae,isActive:M==="secondary",isVisible:a,isMobileShell:L,effectiveTheme:l,workspacePathMissing:Le,shellAdapter:n,onActivate:()=>R("secondary"),onShellUpdate:ze,onRuntimeStateChange:z,onFeedback:_e}),t.jsx("button",{type:"button",onClick:()=>fe("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),s&&L&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[V&&t.jsx("div",{className:`pointer-events-auto rounded-full border px-3 py-1.5 text-[11px] shadow-lg shadow-stone-950/30 backdrop-blur ${He}`,children:V.text}),C&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{_e("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void ht(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var A;(A=X.current)!=null&&A.sendControl("clear")?_e("done","Cleared"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled||!Ce.isCommandRunning,onClick:()=>{var A;(A=X.current)!=null&&A.sendInput("")?_e("done","Sent Ctrl-C"):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(A=>t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var U;(U=X.current)!=null&&U.sendControl(A)?_e("done",`Sent ${A.toUpperCase().replace("_","-")}`):_e("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:A.toUpperCase().replace("_","-"),tone:"stone"})},A))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(A=>!A),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(hg,{})})]})]}),t.jsxs("aside",{className:"hidden min-h-0 overflow-hidden rounded-[1rem] border border-stone-800/80 bg-stone-950/30 p-2 sm:flex sm:flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[ie.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ie.map(ut),ie.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:v||w||Le,onClick:()=>void Be(M),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),nx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(uu(),rl))).ThreadGraphWorkspacePanel}));function ax(){return t.jsx("div",{className:"flex h-full min-h-0 flex-1 items-center justify-center px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading workspace..."})}function Ll(e){return t.jsx(c.Suspense,{fallback:t.jsx(ax,{}),children:t.jsx(nx,{...e})})}c.memo(Ll);function wx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:o=!1,onCancel:s,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!o&&s()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[o,s,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:s,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:s,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:s,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:o,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:o?"Deleting...":a})]})]})]}),document.body):null}function sx(e){if(!e)return"No time";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function ox(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function lx(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function ix(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function dx(e){return e==="read"?"View only":"Collaborator"}function cx(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function yx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var q,G,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(q=n.data)==null?void 0:q.turns]),[g,b]=c.useState(l),[k,x]=c.useState("latest-10"),[j,w]=c.useState(()=>new Set),[y,v]=c.useState(!0),[S,N]=c.useState(""),[I,M]=c.useState("read"),[R,Q]=c.useState("none"),[$,Y]=c.useState(""),[Z,P]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(b(l),x("latest-10"),v(!0),N(""),M("read"),Q("none"),Y(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&w(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(P(W()),!C)return;const H=new MutationObserver(()=>P(W()));return H.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>H.disconnect()},[e]),!e)return null;const te=ix(k),oe=te!==null?Math.min(te,((G=n.data)==null?void 0:G.totalTurnCount)??te):k==="all-loaded"?p.length:j.size,T=!r&&g!=="share"&&(te!==null||k==="all-loaded"||j.size>0),re=!r&&a&&!!u&&S.trim().length>0;function B(C){w(W=>{const H=new Set(W);return H.has(C)?H.delete(C):H.add(C),H})}function J(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:k==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:y}};h(C)}function K(C){C.preventDefault(),re&&(u==null||u({targetIdentifier:S.trim(),threadAccess:I,workspaceAccess:R,label:$.trim()||null}))}const L=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Yr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${Z} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":Z,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:L.map(C=>t.jsx("button",{type:"button",onClick:()=>b(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:K,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:I===C,disabled:!a||r,onChange:()=>M(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:R===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>Y(C.target.value),placeholder:"optional",value:$})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(s==null?void 0:s.shares.length)??0})]}),(s==null?void 0:s.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:s.error}):s!=null&&s.shares.length?t.jsx("div",{className:"divide-y",children:s.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",dx(C.threadAccess)," / ",cx(C.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(C.id),children:"Revoke"}):null]},C.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:k,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:lx(C)},C))})]}),k==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>w(new Set(p.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>w(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(C.turnId),onChange:()=>B(C.turnId),className:"thread-export-dialog-checkbox h-4 w-4"}),t.jsxs("span",{className:"thread-export-dialog-strong shrink-0 text-xs font-medium",children:["Turn ",C.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:sx(C.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:C.userPromptPreview}),t.jsx("span",{className:"thread-export-dialog-status-pill hidden shrink-0 rounded-full border px-2 py-0.5 text-[10px] sm:inline",children:ox(C.status)})]},C.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:y,onChange:C=>v(C.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${oe} ${oe===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!re,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:J,disabled:!T,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function hx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Cl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,b]=c.useState(0),[k,x]=c.useState(0),[j,w]=c.useState(0),[y,v]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,I=e.pendingRequests.length>0,M=c.useCallback(T=>{N==null||N(T)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const T=window.matchMedia("(max-width: 639px)"),re=()=>p(T.matches);return re(),T.addEventListener("change",re),()=>{T.removeEventListener("change",re)}},[]),c.useEffect(()=>{var re,B;if(typeof window>"u")return;const T=()=>{const J=window.visualViewport,K=J?Math.max(0,Math.round(window.innerHeight-J.height-J.offsetTop)):0,L=J?Math.max(0,Math.round(window.innerHeight-J.height)):K,q=Math.min(K,L),G=Math.max(0,Math.round(window.innerHeight*.52));w(Math.min(q,G))};return T(),(re=window.visualViewport)==null||re.addEventListener("resize",T),(B=window.visualViewport)==null||B.addEventListener("scroll",T),window.addEventListener("resize",T),()=>{var J,K;(J=window.visualViewport)==null||J.removeEventListener("resize",T),(K=window.visualViewport)==null||K.removeEventListener("scroll",T),window.removeEventListener("resize",T)}},[]),c.useLayoutEffect(()=>{const T=S.current;if(!T||!f){b(0);return}const re=()=>{b(Math.ceil(T.getBoundingClientRect().height))};if(re(),typeof ResizeObserver>"u")return;const B=new ResizeObserver(re);return B.observe(T),()=>{B.disconnect()}},[f,l,I]),c.useLayoutEffect(()=>{var J,K;const T=S.current;if(!T||!f){x(0);return}const re=()=>{const L=T.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-L.top)))};re(),window.addEventListener("resize",re),(J=window.visualViewport)==null||J.addEventListener("resize",re),(K=window.visualViewport)==null||K.addEventListener("scroll",re);let B=null;return typeof ResizeObserver<"u"&&(B=new ResizeObserver(re),B.observe(T)),()=>{var L,q;window.removeEventListener("resize",re),(L=window.visualViewport)==null||L.removeEventListener("resize",re),(q=window.visualViewport)==null||q.removeEventListener("scroll",re),B==null||B.disconnect()}},[f,j,y,l,I]),c.useEffect(()=>{if(!f){v(!1);return}const T=B=>{var K;const J=B.target;J instanceof HTMLElement&&((K=S.current)!=null&&K.contains(J))&&v(!0)},re=B=>{var K;const J=B.relatedTarget;J instanceof HTMLElement&&((K=S.current)!=null&&K.contains(J))||v(!1)};return document.addEventListener("focusin",T),document.addEventListener("focusout",re),()=>{document.removeEventListener("focusin",T),document.removeEventListener("focusout",re)}},[f]);const R=c.useCallback(T=>{S.current=T,m&&(m.current=T)},[m]),Q=f&&y?Math.max(0,j-u):0,$=Math.max(g,144),Y=Math.max(k,$+Q),Z=f?Y+12:0,P=Z>0?{"--thread-graph-chat-scroll-bottom-spacer":`${Z}px`}:void 0,te=h&&f?{bottom:`${u+Q}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,oe=c.useMemo(()=>{const T=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:T,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:M})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,M,o,n,i]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:P,children:[s,oe,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),l?h?t.jsx("div",{ref:R,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:te??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Un,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:R,className:"thread-graph-composer-host shrink-0",children:t.jsx(Un,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function ux(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Dr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function mx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Dr(e.input)} / out ${Dr(e.output)} / cache read ${Dr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Dr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${yl(e.priceUsd)}`:n}function jx({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:k,threadActionsButton:x,surfaceActions:j,floatingPanel:w,workspaceContent:y,workspaceTitle:v,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:I=null,onNewThreadTitle:M,beforeTimelineContent:R,errorContent:Q,workspaceMissingContent:$,dialogs:Y,currentThreadId:Z,currentWorkspaceId:P,currentWorkspaceLabel:te,onCloseAppNavigation:oe,className:T="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:re="chat",liveOutput:B="",timelineProps:J,composerProps:K,shellComposerProps:L,useFloatingMobileComposer:q=!1,floatingMobileComposerBottomOffset:G=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:H=W,onShellThemeModeChange:se,onShellStateChange:V,shellUnavailableContent:de,shellDisconnectedContent:ee,timelineComponent:be=Cl,shellPanelComponent:ie=rx,shellContent:ye,loadingContent:Ae,emptyContent:ce}){const Ce=ca(),Le=s??Ce??ia(),{getImageAssetUrl:X,loadHistoryItemDetail:ue,openWorkspaceFile:ve,openThread:ke,cancelPendingSteer:$e}=l,He=c.useMemo(()=>({...X?{getImageAssetUrl:ne=>X(ne.path)}:{},onOpenLinkedThread:ke,...ve?{onOpenWorkspaceFile:ve}:{},...ue?{onLoadHistoryItemDetail:ue}:{},...$e?{cancelPendingSteer:$e}:{}}),[$e,X,ue,ve,ke]),_e=Le.getThreadPanels().some(ne=>ne.kind==="terminal"),ze=c.useMemo(()=>r?ux(r):null,[r]),F=c.useMemo(()=>mx(ze),[ze]),le=c.useMemo(()=>{var ne;return r?r.turns.reduce((ge,Te)=>ge+Te.items.length,((ne=r.liveItems)==null?void 0:ne.items.length)??0):0},[r]),we=y??(r?t.jsx(Ll,{detail:r,status:o,plugins:Le,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:re,features:N,focusPathRequest:I}):null),z=n?Ae??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):r?t.jsxs("div",{className:T,children:[w?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:w}):null,a&&!n&&(Q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&($??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:r.workspace.absPath})]})),t.jsx("div",{className:re==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(hx,{detail:r,adapter:l,timelineAdapter:He,TimelineComponent:be,liveOutput:B,transcriptItemCount:le,useFloatingMobileComposer:q,floatingMobileComposerBottomOffset:G,...R?{beforeTimelineContent:R}:{},...K?{composerProps:K}:{},...J?{timelineProps:J}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:re==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ye??(r.thread.isLoaded&&_e&&l.shell?t.jsx(ie,{ref:C,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:re==="shell",showHeader:!1,showFloatingToolbox:!1,...V?{onStateChange:V}:{}}):r.thread.isLoaded&&!_e?de??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):ee??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),re==="shell"&&L&&!ye?t.jsx(Un,{...L,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Y]}):ce??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),O=t.jsx(mp,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:Z??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:P??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:te??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:F,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:H,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...k?{onWorkspaceReturn:k}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:we,workspaceTitle:v??"Workspace",workspaceActions:S,...M?{onNewThreadTitle:M}:{},...oe?{onCloseAppNavigation:oe}:{},...se?{onThemeModeChange:se}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:z});return s?t.jsx(da.Provider,{value:Le,children:O}):O}var px={},fx=[];function Nx({adapter:e=px,builtinPlugins:r=fx,children:n}){const[a,o]=c.useState(()=>Vn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const w=e.fetchPlugins?await e.fetchPlugins():[];o(Vn(r,w))}catch(w){d(w instanceof Error?w.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(w,y)=>{if(e.updatePlugin){const v=await e.updatePlugin(w,{enabled:y});o(S=>S.map(N=>N.id===v.id?v:N));return}o(v=>v.map(S=>S.id===w?{...S,enabled:y}:S))},[e]),m=c.useCallback(async w=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const y=await e.importPlugin(w);o(v=>[...v.filter(N=>N.id!==y.id),y])},[e]),f=c.useCallback(async w=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const y=await e.deletePlugin(w);o(v=>v.filter(S=>S.id!==y.id))},[e]),p=c.useMemo(()=>{const w=new Set(a.filter(y=>y.enabled).map(y=>y.id));return r.filter(y=>w.has(y.manifest.id))},[r,a]),g=c.useCallback(w=>{var v;const y=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===w.artifact.type));return((v=y==null?void 0:y.renderArtifact)==null?void 0:v.call(y,w))??null},[p]),b=c.useCallback(w=>{for(const y of p)for(const v of y.inlineCodeRenderers??[]){if(!v.languages.includes(w.language.trim().toLowerCase()))continue;const S=v.render(w);if(S)return S}return null},[p]),k=c.useCallback(w=>p.some(y=>!!y.renderArtifact&&y.manifest.capabilities.artifactTypes.some(v=>v.type===w.type)),[p]),x=c.useCallback(()=>p.flatMap(w=>w.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:k,getThreadPanels:x}),[i,x,k,m,s,a,h,g,b,u,f]);return t.jsx(da.Provider,{value:j,children:n})}export{Zm as A,wx as C,pp as L,Nx as P,yx as T,ca as a,jx as b,rx as c,Cl as d,mp as e,Wt as f,up as g,Jm as t,ll as u};
3708
+ `).trimEnd():""}function $g({clearTimeout:e}){let r=null;const n=o=>{(o==null?void 0:o.timer)!==null&&(o==null?void 0:o.timer)!==void 0&&e(o.timer)};return{hasPending:()=>!!r,joinPending:()=>new Promise(o=>{r==null||r.waiters.push(o)}),start:({timeoutMs:o,setTimeout:s,onTimeout:l})=>new Promise(i=>{const d=s(()=>{r=null,l(),i(!1)},o);r={waiters:[i],timer:d}}),settle:o=>{const s=r;if(s){r=null,n(s);for(const l of s.waiters)l(o)}},clear:()=>{const o=r;r=null,n(o)}}}var Ds={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function bt(e){return e.status!=="exited"&&e.status!=="not_found"}function Dg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&bt(e))}function Bg(e,r){return e.status===r.status&&e.shellInputEnabled===r.shellInputEnabled&&e.isConnecting===r.isConnecting&&e.isCommandRunning===r.isCommandRunning&&e.promptLabel===r.promptLabel&&e.error===r.error&&e.hasShell===r.hasShell}function Gg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&bt(r)):null)??(e.shell&&bt(e.shell)?e.shell:null)??e.shells.find(bt)??null}function Fg({activeRuntime:e,activeShell:r,busy:n,loading:a,status:o,workspacePathMissing:s}){const l=n||a||o==="creating"||s,i=e.shellInputEnabled?"Disconnect shell":r&&!bt(r)?"Restart shell":r?"Connect shell":"Create shell",d=e.shellInputEnabled?"border-emerald-300/45 bg-emerald-300/18 text-emerald-50 ring-1 ring-emerald-300/20 hover:bg-emerald-300/24":r&&!bt(r)?"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800":s?"border-rose-300/35 bg-rose-300/12 text-rose-100":"border-stone-600 bg-stone-800/90 text-stone-100 hover:border-stone-500 hover:bg-stone-800";return{disabled:l,label:i,className:d}}function Hg({activeRuntime:e,activeShell:r,connectionButtonDisabled:n,connectionButtonLabel:a,isMobileShell:o,busy:s,loading:l,error:i}){return{status:e.status,connectionButtonDisabled:n,connectionButtonLabel:a,shellInputEnabled:e.shellInputEnabled,isConnecting:e.isConnecting,isCommandRunning:e.isCommandRunning,promptLabel:e.promptLabel??(r?ma(ln(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Ht(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Og({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=xg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Wg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=bg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Ug({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=vg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=yg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(o(d.connectionError),s(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Vg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function qg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Pg({shellId:e,viewerId:r,socketReadyState:n.socket.readyState,openReadyState:l,hasAttachRetryTimer:a.current!==null,hasAttachTimeout:o.current!==null,isCurrentSocket:((i=s.current)==null?void 0:i.socket)===n.socket})}function Kg({closeApplication:e,shellId:r,attachTimeoutRef:n,socketRef:a,reconnectTimerRef:o,setViewerId:s,setIsConnecting:l,settleAttachPromise:i,onShellUpdate:d,setReconnectKey:h}){const u=e.closeAction;return u?(e.shouldClearAttachTimeout&&Ht(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Vg,"detached"),u.shouldScheduleReconnect&&Wg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function Xg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Ht(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Ht(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Yg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Zg(e){return Sl({...e,attachSize:void 0})}function Jg({attachSize:e,...r}){return Sl({...r,attachSize:e})}function Qg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=jg({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function ex(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function tx({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=Mg(e.payload,r),s=o.data?Ag({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function rx({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=Cg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o});return{closeAction:l,shouldClearAttachTimeout:!!(l&&s),shouldClearSocketRef:!!l,viewerId:null,isConnecting:!1,settleAttachPromise:!1}}function nx(e,r){return r.shellUpdate?{...e,status:r.shellUpdate.status==="attached"||r.shellUpdate.status==="detached"||r.shellUpdate.status==="exited"||r.shellUpdate.status==="not_found"?r.shellUpdate.status:e.status,attachedViewerId:r.shellUpdate.attachedViewerId===void 0?e.attachedViewerId:r.shellUpdate.attachedViewerId}:e}function ax(e){return e.current}function sx({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:b,pendingCommandRef:w,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:v,setViewerId:k,setIsConnecting:S,setConnectionError:N,setRuntimePromptLabel:L,setIsCommandRunning:R,settleAttachPromise:P,onShellUpdate:Q}){const D=e==null?void 0:e.id,Z=e==null?void 0:e.cwd;c.useEffect(()=>{const J=s.current,z={shellId:D??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!J,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===D),hasReconnectTimer:h.current!==null};if(Zg(z).type==="skip")return;const se=y.current(),$=Jg({...z,attachSize:se});if($.type==="skip"||$.type==="measureSize")return;if($.type==="scheduleRetry"){Og({attachRetryTimerRef:m,setReconnectKey:v});return}if($.shouldClearAttachRetry&&Ht(m),$.type==="reuseSocket"||($.shouldClearReconnectTimer&&Ht(h),!D||!J))return;const le=$.attachSize;d.current=D,J.reset(),N(null),k(null),S(!0),p.current=!1;const q=r.connectSocket({onConnected:()=>{var F;const H=u.current,G=Qg({isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket,shellId:D,attachSize:le,hasAttachTimeout:H!==null}),T=G.openAction;T&&(q.send(T.message),G.shouldClearAttachTimeout&&H!==null&&Ht(u),T.shouldScheduleAttachTimeout&&Ug({shellSocket:q,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:N,setIsConnecting:S,settleAttachPromise:P}))},onShellEvent:H=>{var F;if(!Yg({eventShellId:H.shellId,shellId:D,socketExists:!!q.socket,isCurrentSocket:((F=l.current)==null?void 0:F.socket)===q.socket}))return;if(H.type==="shell.connected"){Ht(u);const B=ex(H);k(B.viewerId),S(!1),P(B.settleAttachPromise),Q(D,B.nextShell,"attached");return}if(H.type==="shell.output"){const{output:B,snapshotUpdate:E}=tx({event:H,shellCwd:Z,currentSnapshot:b.current,pendingCommand:w.current});j.current={cursorX:B.cursorX,cursorY:B.cursorY,paneHeight:B.paneHeight},L(B.promptLabel),R(B.isCommandRunning),E&&(b.current=E.nextSnapshot,w.current=E.nextPendingCommand,E.lastCommandOutput!==null&&(x.current=E.lastCommandOutput),B.replace?El(J,B.data,B.cursorX,B.cursorY,B.paneHeight):J.write(B.data));return}const T=_g({event:H,currentViewerId:i.current});T&&(T.viewerId!==void 0&&k(T.viewerId),T.isConnecting!==void 0&&S(T.isConnecting),T.settleAttachPromise!==void 0&&P(T.settleAttachPromise),T.isCommandRunning!==void 0&&R(T.isCommandRunning),T.connectionError!==void 0&&N(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&Q(D,B=>nx(B,T),T.shellUpdate.status),T.closeSocket&&q.socket.close())}});return l.current=q,q.socket.addEventListener("close",()=>{var T;const H=u.current,G=rx({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===q.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:D,hasAttachTimeout:H!==null});Kg({closeApplication:G,shellId:D,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:k,setIsConnecting:S,settleAttachPromise:P,onShellUpdate:Q,setReconnectKey:v})}),()=>{const H=ax(i),G=qg({shellId:D,viewerId:H,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Xg({cleanupAction:G,shellSocket:q,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:k,setIsConnecting:S,settleAttachPromise:P})}},[m,u,n,p,f,x,Q,w,o,h,N,R,S,v,L,k,P,Z,D,r,d,b,j,l,y,a,s,g,i])}function zn(e){return e.current}var Bs=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),b=c.useRef(null),w=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),v=c.useRef(null),k=c.useRef(null),S=c.useRef(!1),N=c.useRef(null),L=c.useRef(""),R=c.useRef(null),P=c.useRef(""),Q=c.useRef(null),D=c.useRef(null),Z=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),J=c.useRef(!1),z=c.useRef(null),te=c.useRef(o),se=c.useRef(s),$=c.useRef(()=>!1),le=c.useRef(()=>null),q=c.useRef(()=>{}),H=c.useRef($g({clearTimeout:window.clearTimeout})),[G,T]=c.useState(null),[F,B]=c.useState(!1),[E,C]=c.useState(null),[W,U]=c.useState(!1),[ne,K]=c.useState(null),[ie,ee]=c.useState(null),[ve,oe]=c.useState(!1),[ye,Me]=c.useState(0),de=(n==null?void 0:n.status)??"not_created",Ce=Dg({shell:n,workspacePathMissing:i}),Ee=c.useMemo(()=>ma(ln(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),Y=ie??Ee,ue=c.useCallback(V=>{x.current=V,C(V)},[]),ke=c.useCallback(V=>{H.current.settle(V)},[]);c.useEffect(()=>{te.current=o},[o]),c.useEffect(()=>{se.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const we=c.useCallback(V=>{const ce=w.current,xe=j.current,I=x.current;return!ce||!xe||!I?!1:(ce.send({type:"shell.input",shellId:xe,viewerId:I,data:V}),!0)},[]);c.useEffect(()=>{$.current=we},[we]);const De=c.useCallback(()=>{const V=w.current,ce=j.current,xe=x.current;return!V||!ce||!xe?!1:(V.send({type:"shell.clear",shellId:ce,viewerId:xe}),!0)},[]),Fe=c.useCallback(()=>{if(!o||!G)return!1;const V=G.getBoundingClientRect();return V.width>0&&V.height>0},[o,G]),Ae=c.useCallback(V=>{const ce=g.current,xe=b.current;if(!ce||!xe||!Fe()||(xe.fit(),ce.cols<=0||ce.rows<=0))return null;const I={cols:ce.cols,rows:ce.rows},O=Rg({size:I,previousSize:D.current,shellId:j.current,viewerId:x.current,syncBackendSize:(V==null?void 0:V.syncBackendSize)!==!1});return(V==null?void 0:V.syncBackendSize)===!1||(D.current=O.nextLastSentSize,!O.message)||w.current&&w.current.send(O.message),I},[Fe]);c.useEffect(()=>{le.current=Ae},[Ae]);const Oe=c.useCallback(V=>{const ce=g.current;!ce||!Fe()||(Ae((V==null?void 0:V.syncBackendSize)===void 0?void 0:{syncBackendSize:V.syncBackendSize}),L.current&&!$s(G)?El(ce,L.current,Z.current.cursorX,Z.current.cursorY,Z.current.paneHeight):ce.scrollToBottom(),V!=null&&V.focus&&!s&&ce.focus())},[s,Fe,Ae,G]);return c.useEffect(()=>{q.current=()=>Oe()},[Oe]),c.useEffect(()=>{m({status:E?"attached":de,shellInputEnabled:!!(E&&n),isConnecting:W,isCommandRunning:ve,promptLabel:Y,error:ne,hasShell:!!n})},[ne,W,ve,m,Y,n,de,E]),c.useEffect(()=>{if(!G||g.current||J.current)return;let V=!1;return J.current=!0,(async()=>{const[{Terminal:ce},{FitAddon:xe}]=await Promise.all([Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ae=>ae.x),__vite__mapDeps([6,2,7])),Xe(()=>import("./terminal-vendor-C5bTa-Ka.js").then(ae=>ae.a),__vite__mapDeps([6,2,7]))]);if(V||!G){J.current=!1;return}const I=new ce({cursorBlink:!0,disableStdin:se.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:As(l)}),O=new xe;I.loadAddon(O),I.open(G),g.current=I,b.current=O,le.current(),I.attachCustomKeyEventHandler(ae=>{if(se.current||ae.type!=="keydown")return!0;if(ae.ctrlKey&&!ae.altKey&&!ae.metaKey&&!ae.shiftKey){const be=cg(ae.key);if(!be)return!0;if($.current(be))return ae.preventDefault(),!1}return!0}),B(!0),J.current=!1,Q.current=new ResizeObserver(()=>{q.current()}),Q.current.observe(G),z.current=I.onData(ae=>{se.current||$.current(ae)})})(),()=>{var ce,xe,I;V=!0,J.current=!1,(ce=z.current)==null||ce.dispose(),z.current=null,(xe=Q.current)==null||xe.disconnect(),Q.current=null,B(!1),(I=g.current)==null||I.dispose(),g.current=null,b.current=null,D.current=null}},[l,G]),c.useEffect(()=>{var ce;const V=Lg({hasShell:!!n});V&&(ue(V.viewerId),U(V.isConnecting),ke(V.settleAttachPromise),K(V.connectionError),ee(V.runtimePromptLabel),oe(V.isCommandRunning),L.current=V.shellSnapshot,P.current=V.lastCommandOutput,R.current=V.pendingCommand,V.shouldResetTerminal&&((ce=g.current)==null||ce.reset()))},[ue,ke,n]),c.useEffect(()=>{const V=g.current;V&&(V.options.theme=As(l))},[l]),c.useEffect(()=>{const V=g.current;V&&(V.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!F)return;const V=window.requestAnimationFrame(()=>{Oe({focus:a,syncBackendSize:!1}),!w.current&&(n!=null&&n.id)&&N.current!==n.id&&Me(ce=>ce+1)});return()=>{window.cancelAnimationFrame(V)}},[a,o,Oe,n==null?void 0:n.id,F]),sx({shell:n,shellAdapter:d,canAttachShell:Ce,terminalReady:F,reconnectKey:ye,terminalRef:g,socketRef:w,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:v,attachRetryTimerRef:k,isVisibleRef:te,intentionalDisconnectRef:S,userDisconnectedShellIdRef:N,shellSnapshotRef:L,pendingCommandRef:R,lastCommandOutputRef:P,snapshotCursorRef:Z,syncTerminalSizeRef:le,setReconnectKey:Me,setViewerId:ue,setIsConnecting:U,setConnectionError:K,setRuntimePromptLabel:ee,setIsCommandRunning:oe,settleAttachPromise:ke,onShellUpdate:u}),c.useEffect(()=>()=>{const V=zn(y),ce=zn(v),xe=zn(k),I=Ig({hasReconnectTimer:V!==null,hasAttachTimeout:ce!==null,hasAttachRetry:xe!==null});I.shouldClearReconnectTimer&&V!==null&&window.clearTimeout(V),I.shouldClearAttachTimeout&&ce!==null&&window.clearTimeout(ce),I.shouldClearAttachRetry&&xe!==null&&window.clearTimeout(xe),ke(I.settleAttachPromise)},[ke]),c.useImperativeHandle(p,()=>({disconnect(){const V=w.current,ce=j.current,xe=x.current,I=zg({shellId:ce,viewerId:xe,hasSocket:!!V});N.current=I.userDisconnectedShellId,S.current=I.intentionalDisconnect,V&&I.detachMessage&&V.send(I.detachMessage),ue(null),U(!1),ke(!1),I.shouldCloseSocket&&(V==null||V.socket.close()),w.current=null,D.current=null,I.shouldDetachShell&&ce&&u(ce,O=>({...O,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const V=Tg({hasShellId:!!j.current,terminalReady:F,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:H.current.hasPending()});if(V.type==="reject")return Promise.resolve(!1);if(V.type==="alreadyConnected")return Promise.resolve(!0);if(V.type==="joinPending")return H.current.joinPending();const ce=H.current.start({timeoutMs:kg,setTimeout:window.setTimeout,onTimeout:()=>{U(!1)}}),xe=Eg({shellId:j.current,userDisconnectedShellId:N.current});return xe.shouldClearUserDisconnectedShellId&&(N.current=null),S.current=xe.intentionalDisconnect,K(xe.connectionError),U(xe.isConnecting),Me(I=>I+1),ce},sendInput(V){return we(V)},sendCommand(V){const ce={command:V,beforeSnapshot:L.current};if(R.current=ce,V.trim()==="clear"){const O=De();return!O&&R.current===ce&&(R.current=null),O}const xe=V.endsWith(`
3709
+ `)?V:`${V}
3710
+ `,I=we(xe);return!I&&R.current===ce&&(R.current=null),I},sendControl(V){return V==="clear"?De():we(pg(V))},async copyLastCommandOutput(){const V=P.current.trim()||$s(G);if(!V)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(V),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var V;(V=g.current)==null||V.focus()},refreshLayout(V){Oe(V)}}),[f,u,Oe,De,we,ue,ke,G,F,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var V;h(),(V=g.current)==null||V.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),ox=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:o=!0,showFloatingToolbox:s=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),b=c.useRef(null),w=c.useRef(!1),[x,j]=c.useState(null),[y,v]=c.useState(!0),[k,S]=c.useState(!1),[N,L]=c.useState(null),[R,P]=c.useState("primary"),[Q,D]=c.useState(null),[Z,J]=c.useState(null),[z,te]=c.useState("single"),[se,$]=c.useState(50),[le,q]=c.useState(null),[H,G]=c.useState(""),[T,F]=c.useState(!1),[B,E]=c.useState(!1),[C,W]=c.useState(!1),[U,ne]=c.useState({primary:Ds,secondary:Ds}),[K,ie]=c.useState(null),ee=(x==null?void 0:x.state)??"not_created",ve=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),oe=c.useMemo(()=>ve.filter(bt),[ve]),ye=c.useMemo(()=>oe.find(M=>M.id===Q)??null,[oe,Q]),Me=c.useMemo(()=>oe.find(M=>M.id===Z)??null,[oe,Z]),de=R==="secondary"?Me:ye,Ce=U[R],Ee=(x==null?void 0:x.workspacePathStatus)==="missing",Y=R==="secondary"?f:m,ue=Fg({activeRuntime:Ce,activeShell:de,busy:k,loading:y,status:ee,workspacePathMissing:Ee}),ke=ue.disabled,we=ue.label,De=ue.className,Fe=(K==null?void 0:K.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(K==null?void 0:K.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",Ae=c.useCallback((M,X)=>{ie({tone:M,text:X}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{ie(null),p.current=null},1800)},[]),Oe=c.useCallback((M,X,ge)=>{j(Ne=>{var nt;if(!Ne)return Ne;const Pe=Ne.shells.map($e=>$e.id===M?X($e):$e),rt=((nt=Ne.shell)==null?void 0:nt.id)===M?X(Ne.shell):Pe.find($e=>{var We;return $e.id===((We=Ne.shell)==null?void 0:We.id)})??Ne.shell;return{...Ne,...ge?{state:ge}:{},shell:rt,shells:Pe}})},[]),V=c.useCallback(async()=>{v(!0);try{const M=await n.fetchState(r);j(M),L(null)}catch(M){L(M instanceof Error?M.message:"Unable to load shell state.")}finally{v(!1)}},[n,r]);c.useEffect(()=>{V()},[V]),c.useEffect(()=>{const M=i==null?void 0:i(r);if(M==null){$(50);return}const X=typeof M=="number"?M:Number.parseFloat(String(M));$(Number.isFinite(X)?Ln(X):50)},[i,r]),c.useEffect(()=>{if(!x){D(null),J(null);return}const M=Gg(x);D(X=>X&&x.shells.some(ge=>ge.id===X&&bt(ge))?X:(M==null?void 0:M.id)??null),J(X=>{if(z!=="columns")return null;if(X&&x.shells.some(Ne=>Ne.id===X&&bt(Ne)))return X;const ge=x.shells.find(Ne=>bt(Ne)&&Ne.id!==(M==null?void 0:M.id));return(ge==null?void 0:ge.id)??null})},[x,z]),c.useEffect(()=>{z!=="columns"&&(P("primary"),J(null))},[z]),c.useEffect(()=>{if(z!=="columns"||Z||oe.length<2)return;const M=oe.find(X=>X.id!==(ye==null?void 0:ye.id))??null;M&&J(M.id)},[oe,ye==null?void 0:ye.id,Z,z]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const M=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),X=()=>{F(M.matches),M.matches||(W(!1),E(!1))};return X(),M.addEventListener("change",X),()=>{M.removeEventListener("change",X)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),b.current!==null&&window.cancelAnimationFrame(b.current)},[]);const ce=c.useCallback((M,X)=>{ne(ge=>{const Ne=ge[M];return Bg(Ne,X)?ge:{...ge,[M]:X}})},[]),xe=c.useCallback(M=>ce("primary",M),[ce]),I=c.useCallback(M=>ce("secondary",M),[ce]),O=c.useCallback(M=>{var ge;if((ge=M.label)!=null&&ge.trim())return M.label.trim();const X=ve.findIndex(Ne=>Ne.id===M.id);return`Shell ${X>=0?X+1:""}`.trim()},[ve]),ae=c.useCallback(M=>{var X;q(M.id),G(((X=M.label)==null?void 0:X.trim())||O(M))},[O]),be=c.useCallback(()=>{q(null),G("")},[]),je=c.useCallback(async()=>{if(le){S(!0);try{const M=H.trim(),X=await n.updateShell(le,{label:M.length>0?M:null});j(ge=>{var Ne;return ge&&{...ge,state:ge.activeShellId===X.id?X.status:ge.state,shell:((Ne=ge.shell)==null?void 0:Ne.id)===X.id?X:ge.shell,shells:ge.shells.map(Pe=>Pe.id===X.id?X:Pe)}}),q(null),G(""),L(null)}catch(M){L(M instanceof Error?M.message:"Unable to rename shell.")}finally{S(!1)}}},[H,le,n]),Te=c.useCallback((M,X)=>{if(M==="primary"){D(X),J(ge=>ge===X?null:ge);return}J(X),D(ge=>ge===X?null:ge)},[]),fe=c.useCallback(M=>{var X,ge;if(M==="primary"){(X=m.current)==null||X.disconnect(),D(null),z==="columns"&&P("secondary");return}(ge=f.current)==null||ge.disconnect(),J(null),P("primary"),te("single")},[z]),Be=c.useCallback((M,X=R)=>{const ge=z==="columns"?X:"primary";Te(ge,M.id),z!=="columns"&&J(null),P(ge)},[R,Te,z]),_e=c.useCallback(async(M=R)=>{var X;if(!w.current){w.current=!0,S(!0);try{const ge=await n.createShell(r);j(ge);const Ne=ge.activeShellId??((X=ge.shell)==null?void 0:X.id)??null;if(Ne){const Pe=z==="columns"?M:"primary";Te(Pe,Ne),z!=="columns"&&J(null),P(Pe)}L(null)}catch(ge){L(ge instanceof Error?ge.message:"Unable to create shell.")}finally{w.current=!1,S(!1)}}},[R,Te,n,z,r]);c.useEffect(()=>{!a||!x||y||k||Ee||ee==="creating"||oe.length>0||_e("primary")},[k,_e,a,oe.length,y,x,ee,Ee]);const Qe=c.useCallback(async(M=(de==null?void 0:de.id)??"")=>{if(M){S(!0);try{await n.terminateShell(M),D(X=>X===M?null:X),J(X=>X===M?null:X),await V(),L(null)}catch(X){L(X instanceof Error?X.message:"Unable to terminate shell.")}finally{S(!1)}}},[de==null?void 0:de.id,V,n]),et=c.useCallback(async()=>{var M,X;if(!ke){if(Ce.shellInputEnabled){(M=Y.current)==null||M.disconnect();return}if(!de||de.status==="exited"||de.status==="not_found"){await _e(R);return}await((X=Y.current)==null?void 0:X.reconnect())}},[R,Y,Ce.shellInputEnabled,de,ke,_e]),it=c.useCallback(M=>{typeof window>"u"||d==null||d(r,Ln(M))},[d,r]),tt=c.useCallback(()=>{var M,X;(M=m.current)==null||M.refreshLayout({syncBackendSize:!0}),(X=f.current)==null||X.refreshLayout({syncBackendSize:!0})},[]),Ke=c.useCallback(M=>{var rt,nt;if(z!=="columns")return;const X=g.current;if(!X)return;M.preventDefault(),(nt=(rt=M.currentTarget).setPointerCapture)==null||nt.call(rt,M.pointerId);const ge=$e=>{const We=X.getBoundingClientRect();if(We.width<=0)return;const ut=Ln(($e-We.left)/We.width*100);$(ut),b.current!==null&&window.cancelAnimationFrame(b.current),b.current=window.requestAnimationFrame(()=>{b.current=null,tt()})},Ne=$e=>{ge($e.clientX)},Pe=$e=>{ge($e.clientX);const We=X.getBoundingClientRect();We.width>0&&it(($e.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Ne),window.removeEventListener("pointerup",Pe)};window.addEventListener("pointermove",Ne),window.addEventListener("pointerup",Pe,{once:!0})},[it,tt,z]),dt=c.useCallback((M,X)=>{Te(X,M.id),P(X)},[Te]),ft=c.useCallback(async()=>{var X;return await((X=Y.current)==null?void 0:X.copyLastCommandOutput())?!0:(Ae("failed","Nothing to copy"),!1)},[Y,Ae]);c.useEffect(()=>{h==null||h(Hg({activeRuntime:Ce,activeShell:de,connectionButtonDisabled:ke,connectionButtonLabel:we,isMobileShell:T,busy:k,loading:y,error:N}))},[Ce,de,k,ke,we,N,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(M){var X;return((X=Y.current)==null?void 0:X.sendInput(M))??!1},sendCommand(M){var X;return((X=Y.current)==null?void 0:X.sendCommand(M))??!1},sendControl(M){var X;return((X=Y.current)==null?void 0:X.sendControl(M))??!1},async copyLastCommandOutput(){var M;return await((M=Y.current)==null?void 0:M.copyLastCommandOutput())??!1},async terminate(){await Qe()},focus(){var M;(M=Y.current)==null||M.focus()},refreshLayout(M){var X,ge;(X=m.current)==null||X.refreshLayout(M),z==="columns"&&((ge=f.current)==null||ge.refreshLayout(M))}}),[Y,et,Qe,z]);const Ve=M=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${M.id===(de==null?void 0:de.id)?"border-sky-300/40 bg-sky-300/12 text-sky-50":"border-stone-800 bg-stone-900/40 text-stone-300"}`,children:t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[le===M.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:X=>{X.preventDefault(),je()},children:t.jsx("input",{value:H,onChange:X=>G(X.currentTarget.value),onKeyDown:X=>{X.key==="Escape"&&(X.preventDefault(),be())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>Be(M),onDoubleClick:()=>ae(M),className:"min-w-0 flex-1 text-left",title:M.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:O(M)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[En(M.status)," · ",ln(M.cwd)||M.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[le===M.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void je(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:be,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>ae(M),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Rename shell",children:"Rename"}),z==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>dt(M,"primary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in left pane",children:"L"}),t.jsx("button",{type:"button",onClick:()=>dt(M,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:k,onClick:()=>void Qe(M.id),className:"rounded border border-rose-300/35 bg-rose-300/12 px-1.5 py-1 text-[10px] text-rose-100 disabled:cursor-not-allowed disabled:opacity-50",title:"Kill shell process",children:"Kill"})]})]})},M.id);return t.jsxs("div",{className:"shell-panel flex min-h-0 flex-1 flex-col",children:[o&&t.jsxs("div",{className:"shell-header shrink-0 border-b px-3 py-3 sm:px-5",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Shell"}),t.jsx("p",{className:"mt-1 truncate text-sm text-[var(--theme-fg-soft)]",children:Ce.promptLabel??(de==null?void 0:de.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":we,title:`${we} (${En(Ce.status)})`,disabled:ke,onClick:()=>void et(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${De}`,children:t.jsx(gg,{connected:Ce.shellInputEnabled})}),de&&t.jsx("button",{type:"button",disabled:k,onClick:()=>void Qe(de.id),className:"rounded-full border border-rose-300/35 bg-rose-300/12 px-3 py-2 text-sm text-rose-600 transition hover:bg-rose-300/18 dark:text-rose-100 disabled:cursor-not-allowed disabled:opacity-60",children:"Terminate"})]})]}),(N||y||Ee)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Ee&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]})]}),t.jsx("div",{className:"min-h-0 flex-1",children:t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"shell-terminal-bar flex shrink-0 items-center gap-2 border-b px-2 py-2",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 px-1",children:[t.jsx("span",{className:"min-w-0 truncate text-xs text-[var(--theme-fg-soft)]",children:de?O(de):"No live shell process"}),de&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:En(Ce.status)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[t.jsxs("span",{className:"hidden text-xs text-[var(--theme-fg-muted)] sm:inline",children:["Live ",oe.length]}),t.jsx("button",{type:"button","aria-expanded":B,"aria-label":B?"Hide shell processes":"Show shell processes",onClick:()=>E(M=>!M),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),B&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[oe.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[oe.map(Ve),oe.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:k||y||Ee,onClick:()=>void _e(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]}),ee==="not_created"||Ee?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"shell-empty-state max-w-md rounded-[1.6rem] border px-6 py-8",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Durable thread shell"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"The shell runs under a supervisor-managed PTY and reconnects after browser disconnects. Create it explicitly when you want to inspect or take over the workspace."}),!Ee&&t.jsx("button",{type:"button",disabled:k||y,onClick:()=>void _e("primary"),className:"mt-5 rounded-md border border-sky-300/35 bg-sky-300/12 px-3 py-2 text-sm text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"New Shell"})]})}):t.jsxs("div",{className:"grid h-full min-h-0 grid-cols-1 gap-2 p-2 sm:grid-cols-[minmax(0,1fr)_16rem] sm:p-3",children:[t.jsxs("div",{className:"shell-terminal-frame relative min-h-0 overflow-hidden rounded-[1.4rem] border shadow-inner",children:[!o&&(N||y||Ee)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Ee&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&N&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:N})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${z==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:z==="columns"?{"--shell-left":`${se}fr`,"--shell-right":`${100-se}fr`}:void 0,"data-shell-split-ratio":se,children:[t.jsx(Bs,{ref:m,paneId:"primary",shell:ye,isActive:R==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Ee,shellAdapter:n,onActivate:()=>P("primary"),onShellUpdate:Oe,onRuntimeStateChange:xe,onFeedback:Ae}),z==="columns"&&t.jsx("button",{type:"button",onClick:()=>fe("primary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close left pane",children:"Close"}),z==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Ke,className:"hidden cursor-col-resize border-x border-stone-800/80 bg-stone-900/60 transition hover:border-sky-300/40 hover:bg-sky-300/10 sm:block"}),z==="columns"&&t.jsxs("div",{className:"relative min-h-0 border-t border-stone-800/80 sm:border-l sm:border-t-0",children:[t.jsx(Bs,{ref:f,paneId:"secondary",shell:Me,isActive:R==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Ee,shellAdapter:n,onActivate:()=>P("secondary"),onShellUpdate:Oe,onRuntimeStateChange:I,onFeedback:Ae}),t.jsx("button",{type:"button",onClick:()=>fe("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),s&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[K&&t.jsx("div",{className:`pointer-events-auto rounded-full border px-3 py-1.5 text-[11px] shadow-lg shadow-stone-950/30 backdrop-blur ${Fe}`,children:K.text}),C&&t.jsx("div",{className:"shell-toolbox pointer-events-auto rounded-[1.2rem] border p-2 shadow-2xl backdrop-blur",children:t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsx("button",{type:"button",onClick:()=>{Ae("idle","Use the prompt box tools to paste")},className:"inline-flex items-center justify-center rounded-full border border-sky-300/35 bg-sky-300/12 px-2.5 py-2 text-sky-600 dark:text-sky-50",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void ft(),className:"shell-toolbox-copy inline-flex items-center justify-center rounded-full border px-2.5 py-2",children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(_s,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var M;(M=Y.current)!=null&&M.sendControl("clear")?Ae("done","Cleared"):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled||!Ce.isCommandRunning,onClick:()=>{var M;(M=Y.current)!=null&&M.sendInput("")?Ae("done","Sent Ctrl-C"):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(M=>t.jsx("button",{type:"button",disabled:!Ce.shellInputEnabled,onClick:()=>{var X;(X=Y.current)!=null&&X.sendControl(M)?Ae("done",`Sent ${M.toUpperCase().replace("_","-")}`):Ae("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(In,{label:M.toUpperCase().replace("_","-"),tone:"stone"})},M))]})}),t.jsx("button",{type:"button","aria-expanded":C,"aria-label":C?"Close shell tools":"Open shell tools",onClick:()=>W(M=>!M),className:"shell-toolbox-trigger pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-2xl backdrop-blur transition",children:t.jsx(fg,{})})]})]}),t.jsxs("aside",{className:"hidden min-h-0 overflow-hidden rounded-[1rem] border border-stone-800/80 bg-stone-950/30 p-2 sm:flex sm:flex-col",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[oe.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[oe.map(Ve),oe.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:k||y||Ee,onClick:()=>void _e(R),className:"inline-flex h-8 w-8 items-center justify-center rounded-md border border-sky-300/35 bg-sky-300/12 text-base leading-none text-sky-50 disabled:cursor-not-allowed disabled:opacity-50",children:"+"})})]})]})]})})]})}),lx=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(fu(),rl))).ThreadGraphWorkspacePanel}));function ix(){return t.jsx("div",{className:"flex h-full min-h-0 flex-1 items-center justify-center px-4 text-sm text-[var(--theme-fg-muted)]",children:"Loading workspace..."})}function Ll(e){return t.jsx(c.Suspense,{fallback:t.jsx(ix,{}),children:t.jsx(lx,{...e})})}c.memo(Ll);function Cx({open:e,title:r,description:n,confirmLabel:a="Delete",busy:o=!1,onCancel:s,onConfirm:l}){return c.useEffect(()=>{if(!e)return;function i(d){d.key==="Escape"&&!o&&s()}return window.addEventListener("keydown",i),()=>{window.removeEventListener("keydown",i)}},[o,s,e]),e?Yr.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[95] flex items-center justify-center p-4 sm:p-6",children:[t.jsx("button",{type:"button","aria-label":"Close confirmation dialog",onClick:s,disabled:o,className:"absolute inset-0 bg-stone-950/78 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":r,className:"relative z-[1] w-full max-w-md rounded-[1.6rem] border border-stone-700 bg-stone-900 p-5 shadow-2xl shadow-stone-950/40 sm:p-6",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm font-medium text-stone-100",children:r}),t.jsx("p",{className:"mt-2 text-sm leading-6 text-stone-400",children:n})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:s,disabled:o,className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-stone-700 text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"mt-5 flex items-center justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:s,disabled:o,className:"rounded-full border border-stone-700 px-4 py-2 text-sm font-medium text-stone-300 transition hover:bg-stone-800 disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),t.jsx("button",{type:"button",onClick:()=>void l(),disabled:o,className:"ui-action-danger rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:o?"Deleting...":a})]})]})]}),document.body):null}function dx(e){if(!e)return"No time";const r=new Date(e);return Number.isNaN(r.getTime())?e:r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function cx(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function hx(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function ux(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function mx(e){return e==="read"?"View only":"Collaborator"}function px(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function Sx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var F,B,E;const p=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(F=n.data)==null?void 0:F.turns]),[g,b]=c.useState(l),[w,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[v,k]=c.useState(!0),[S,N]=c.useState(""),[L,R]=c.useState("read"),[P,Q]=c.useState("none"),[D,Z]=c.useState(""),[J,z]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(b(l),x("latest-10"),k(!0),N(""),R("read"),Q("none"),Z(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(C=>C.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function C(W){W.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,i,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),W=()=>C?C.getAttribute("data-theme-effective")==="dark"||C.classList.contains("dark")||C.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(z(W()),!C)return;const U=new MutationObserver(()=>z(W()));return U.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>U.disconnect()},[e]),!e)return null;const te=ux(w),se=te!==null?Math.min(te,((B=n.data)==null?void 0:B.totalTurnCount)??te):w==="all-loaded"?p.length:j.size,$=!r&&g!=="share"&&(te!==null||w==="all-loaded"||j.size>0),le=!r&&a&&!!u&&S.trim().length>0;function q(C){y(W=>{const U=new Set(W);return U.has(C)?U.delete(C):U.add(C),U})}function H(){if(g==="share")return;const C={format:g,...te!==null?{mode:"latest",limit:te}:w==="all-loaded"?{mode:"selected",turnIds:p.map(W=>W.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:v}};h(C)}function G(C){C.preventDefault(),le&&(u==null||u({targetIdentifier:S.trim(),threadAccess:L,workspaceAccess:P,label:D.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Yr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${J} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":J,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:T.map(C=>t.jsx("button",{type:"button",onClick:()=>b(C.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:C.label},C.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:G,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>N(C.target.value),placeholder:"username or email",value:S})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:L===C,disabled:!a||r,onChange:()=>R(C)}),W]},C))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([C,W])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:P===C,disabled:!a||r,onChange:()=>Q(C)}),W]},C))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:C=>Z(C.target.value),placeholder:"optional",value:D})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(s==null?void 0:s.shares.length)??0})]}),(s==null?void 0:s.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:s.error}):s!=null&&s.shares.length?t.jsx("div",{className:"divide-y",children:s.shares.map(C=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:C.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[C.label?`${C.label} · `:"",mx(C.threadAccess)," / ",px(C.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(C.id),children:"Revoke"}):null]},C.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:w,onChange:C=>x(C.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(C=>t.jsx("option",{value:C,children:hx(C)},C))})]}),w==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((E=n.data)==null?void 0:E.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(C=>C.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>y(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(C=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(C.turnId),onChange:()=>q(C.turnId),className:"thread-export-dialog-checkbox h-4 w-4"}),t.jsxs("span",{className:"thread-export-dialog-strong shrink-0 text-xs font-medium",children:["Turn ",C.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:dx(C.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:C.userPromptPreview}),t.jsx("span",{className:"thread-export-dialog-status-pill hidden shrink-0 rounded-full border px-2 py-0.5 text-[10px] sm:inline",children:cx(C.status)})]},C.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:v,onChange:C=>k(C.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${se} ${se===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!le,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:H,disabled:!$,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Exporting...":`Export ${g.toUpperCase()}`})]})]})]})]}),document.body)}function fx({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=Cl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,transcriptItemCount:d,useFloatingMobileComposer:h=!1,floatingMobileComposerBottomOffset:u=0,composerHostRef:m}){const[f,p]=c.useState(!1),[g,b]=c.useState(0),[w,x]=c.useState(0),[j,y]=c.useState(0),[v,k]=c.useState(!1),S=c.useRef(null),N=i==null?void 0:i.onTailVisibilityChange,L=e.pendingRequests.length>0,R=c.useMemo(()=>{const H=e.pendingSteers??[],G=new Set(H.map(T=>T.clientRequestId).filter(T=>!!T));return[...H.filter(T=>T.delivery==="continuation").map(T=>({id:T.id,prompt:T.prompt,...T.id.startsWith("optimistic-")?{optimistic:!0}:{}})),...((i==null?void 0:i.optimisticSteers)??[]).filter(T=>!G.has(T.clientRequestId)).map(T=>({id:T.id,prompt:T.prompt,optimistic:!0}))]},[e.pendingSteers,i==null?void 0:i.optimisticSteers]),P=c.useMemo(()=>(e.pendingSteers??[]).filter(H=>H.delivery==="steer"),[e.pendingSteers]),Q=c.useMemo(()=>{var H;return l?{...l,pendingPrompts:R,...r.steerPendingPrompt&&((H=l.capabilities)!=null&&H.turns.steer)?{onSteerPendingPrompt:G=>{var T;return(T=r.steerPendingPrompt)==null?void 0:T.call(r,e.thread.id,G)}}:{},...r.cancelPendingSteer?{onCancelPendingPrompt:G=>{var T;return(T=r.cancelPendingSteer)==null?void 0:T.call(r,e.thread.id,G)}}:{}}:null},[r.cancelPendingSteer,r.steerPendingPrompt,l,e.thread.id,R]),D=c.useCallback(H=>{N==null||N(H)},[N]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const H=window.matchMedia("(max-width: 639px)"),G=()=>p(H.matches);return G(),H.addEventListener("change",G),()=>{H.removeEventListener("change",G)}},[]),c.useEffect(()=>{var G,T;if(typeof window>"u")return;const H=()=>{const F=window.visualViewport,B=F?Math.max(0,Math.round(window.innerHeight-F.height-F.offsetTop)):0,E=F?Math.max(0,Math.round(window.innerHeight-F.height)):B,C=Math.min(B,E),W=Math.max(0,Math.round(window.innerHeight*.52));y(Math.min(C,W))};return H(),(G=window.visualViewport)==null||G.addEventListener("resize",H),(T=window.visualViewport)==null||T.addEventListener("scroll",H),window.addEventListener("resize",H),()=>{var F,B;(F=window.visualViewport)==null||F.removeEventListener("resize",H),(B=window.visualViewport)==null||B.removeEventListener("scroll",H),window.removeEventListener("resize",H)}},[]),c.useLayoutEffect(()=>{const H=S.current;if(!H||!f){b(0);return}const G=()=>{b(Math.ceil(H.getBoundingClientRect().height))};if(G(),typeof ResizeObserver>"u")return;const T=new ResizeObserver(G);return T.observe(H),()=>{T.disconnect()}},[f,l,L]),c.useLayoutEffect(()=>{var F,B;const H=S.current;if(!H||!f){x(0);return}const G=()=>{const E=H.getBoundingClientRect();x(Math.max(0,Math.ceil(window.innerHeight-E.top)))};G(),window.addEventListener("resize",G),(F=window.visualViewport)==null||F.addEventListener("resize",G),(B=window.visualViewport)==null||B.addEventListener("scroll",G);let T=null;return typeof ResizeObserver<"u"&&(T=new ResizeObserver(G),T.observe(H)),()=>{var E,C;window.removeEventListener("resize",G),(E=window.visualViewport)==null||E.removeEventListener("resize",G),(C=window.visualViewport)==null||C.removeEventListener("scroll",G),T==null||T.disconnect()}},[f,j,v,l,L]),c.useEffect(()=>{if(!f){k(!1);return}const H=T=>{var B;const F=T.target;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))&&k(!0)},G=T=>{var B;const F=T.relatedTarget;F instanceof HTMLElement&&((B=S.current)!=null&&B.contains(F))||k(!1)};return document.addEventListener("focusin",H),document.addEventListener("focusout",G),()=>{document.removeEventListener("focusin",H),document.removeEventListener("focusout",G)}},[f]);const Z=c.useCallback(H=>{S.current=H,m&&(m.current=H)},[m]),J=f&&v?Math.max(0,j-u):0,z=Math.max(g,144),te=Math.max(w,z+J),se=f?te+12:0,$=se>0?{"--thread-graph-chat-scroll-bottom-spacer":`${se}px`}:void 0,le=h&&f?{bottom:`${u+J}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,q=c.useMemo(()=>{const H=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:H,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,pendingSteers:P,optimisticSteers:[],adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:D})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,D,o,n,i,P]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:$,children:[s,q,t.jsx("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center px-4 py-1 text-[10px] leading-4 sm:flex",children:t.jsxs("span",{className:"min-w-0",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),d," item",d!==1?"s":""]})}),Q?h?t.jsx("div",{ref:Z,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:le??{bottom:`${u}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Un,{...Q,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:Z,className:"thread-graph-composer-host shrink-0",children:t.jsx(Un,{...Q,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function gx(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function Dr(e){return typeof e!="number"||!Number.isFinite(e)||e<=0?"0":e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:String(Math.round(e))}function xx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Dr(e.input)} / out ${Dr(e.output)} / cache read ${Dr(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Dr(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${yl(e.priceUsd)}`:n}function Tx({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,onWorkspaceReturn:w,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:v,workspaceTitle:k,workspaceActions:S,workspaceFeatures:N,workspaceFocusPathRequest:L=null,onNewThreadTitle:R,beforeTimelineContent:P,errorContent:Q,workspaceMissingContent:D,dialogs:Z,currentThreadId:J,currentWorkspaceId:z,currentWorkspaceLabel:te,onCloseAppNavigation:se,className:$="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:le="chat",liveOutput:q="",timelineProps:H,composerProps:G,shellComposerProps:T,useFloatingMobileComposer:F=!1,floatingMobileComposerBottomOffset:B=0,composerHostRef:E,shellPanelRef:C,shellEffectiveTheme:W="dark",shellThemeMode:U=W,onShellThemeModeChange:ne,onShellStateChange:K,shellUnavailableContent:ie,shellDisconnectedContent:ee,timelineComponent:ve=Cl,shellPanelComponent:oe=ox,shellContent:ye,loadingContent:Me,emptyContent:de}){const Ce=ca(),Ee=s??Ce??ia(),{getImageAssetUrl:Y,loadHistoryItemDetail:ue,openWorkspaceFile:ke,openThread:we,cancelPendingSteer:De}=l,Fe=c.useMemo(()=>({...Y?{getImageAssetUrl:ae=>Y(ae.path)}:{},onOpenLinkedThread:we,...ke?{onOpenWorkspaceFile:ke}:{},...ue?{onLoadHistoryItemDetail:ue}:{},...De?{cancelPendingSteer:De}:{}}),[De,Y,ue,ke,we]),Ae=Ee.getThreadPanels().some(ae=>ae.kind==="terminal"),Oe=c.useMemo(()=>r?gx(r):null,[r]),V=c.useMemo(()=>xx(Oe),[Oe]),ce=c.useMemo(()=>{var ae;return r?r.turns.reduce((be,je)=>be+je.items.length,((ae=r.liveItems)==null?void 0:ae.items.length)??0):0},[r]),xe=v??(r?t.jsx(Ll,{detail:r,status:o,plugins:Ee,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:le,features:N,focusPathRequest:L}):null),I=n?Me??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Loading thread detail..."}):r?t.jsxs("div",{className:$,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(Q??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&(D??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:r.workspace.absPath})]})),t.jsx("div",{className:le==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(fx,{detail:r,adapter:l,timelineAdapter:Fe,TimelineComponent:ve,liveOutput:q,transcriptItemCount:ce,useFloatingMobileComposer:F,floatingMobileComposerBottomOffset:B,...P?{beforeTimelineContent:P}:{},...G?{composerProps:G}:{},...H?{timelineProps:H}:{},...E?{composerHostRef:E}:{}})}),t.jsxs("div",{className:le==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ye??(r.thread.isLoaded&&Ae&&l.shell?t.jsx(oe,{ref:C,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:W,isVisible:le==="shell",showHeader:!1,showFloatingToolbox:!1,...K?{onStateChange:K}:{}}):r.thread.isLoaded&&!Ae?ie??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Terminal plugin disabled"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-muted)]",children:"Enable the Terminal plugin in Settings to use the shell panel."})]})}):ee??t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center p-4 sm:p-6",children:t.jsxs("div",{className:"thread-empty-surface max-w-md rounded-[1.6rem] border px-6 py-8 text-center",children:[t.jsx("p",{className:"text-base font-medium text-[var(--theme-fg)]",children:"Thread disconnected"}),t.jsx("p",{className:"mt-3 text-sm leading-6 text-[var(--theme-fg-soft)]",children:"Reconnect this thread before creating or attaching a shell."})]})})),le==="shell"&&T&&!ye?t.jsx(Un,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Z]}):de??t.jsx("div",{className:"flex flex-1 items-center justify-center px-6 py-12 text-center text-[var(--theme-fg-muted)]",children:"Select a thread to inspect."}),O=t.jsx(xp,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:J??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:z??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:te??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:V,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:W,themeMode:U,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:b,...w?{onWorkspaceReturn:w}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:xe,workspaceTitle:k??"Workspace",workspaceActions:S,...R?{onNewThreadTitle:R}:{},...se?{onCloseAppNavigation:se}:{},...ne?{onThemeModeChange:ne}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:I});return s?t.jsx(da.Provider,{value:Ee,children:O}):O}var bx={},vx=[];function Ex({adapter:e=bx,builtinPlugins:r=vx,children:n}){const[a,o]=c.useState(()=>Vn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];o(Vn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,v)=>{if(e.updatePlugin){const k=await e.updatePlugin(y,{enabled:v});o(S=>S.map(N=>N.id===k.id?k:N));return}o(k=>k.map(S=>S.id===y?{...S,enabled:v}:S))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const v=await e.importPlugin(y);o(k=>[...k.filter(N=>N.id!==v.id),v])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const v=await e.deletePlugin(y);o(k=>k.filter(S=>S.id!==v.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(v=>v.enabled).map(v=>v.id));return r.filter(v=>y.has(v.manifest.id))},[r,a]),g=c.useCallback(y=>{var k;const v=p.find(S=>S.renderArtifact&&S.manifest.capabilities.artifactTypes.some(N=>N.type===y.artifact.type));return((k=v==null?void 0:v.renderArtifact)==null?void 0:k.call(v,y))??null},[p]),b=c.useCallback(y=>{for(const v of p)for(const k of v.inlineCodeRenderers??[]){if(!k.languages.includes(y.language.trim().toLowerCase()))continue;const S=k.render(y);if(S)return S}return null},[p]),w=c.useCallback(y=>p.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(k=>k.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:b,hasRendererForArtifact:w,getThreadPanels:x}),[i,x,w,m,s,a,h,g,b,u,f]);return t.jsx(da.Provider,{value:j,children:n})}export{tp as A,Cx as C,bp as L,Ex as P,Sx as T,ca as a,Tx as b,ox as c,Cl as d,xp as e,Wt as f,gp as g,rp as t,ll as u};