remote-codex 0.11.18 → 0.11.19

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-oEok_Crl.js","assets/markdown-vendor-BQJfKm05.js","assets/react-vendor-CgLzZcV4.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-B365Go3Z.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
2
- import{l as _,R as Si,I as Ti,H as Ei,T as Li,C as Pi,S as js,a as Ii,b as zi,c as Ri,d as Ai,e as Mi,D as _i,P as $i,O as Di,f as Bi,g as Gi,h as Fi,i as Hi,j as Oi,k as Ui,m as Wi,n as Vi,A as qi,o as Ki,p as Xi}from"./ui-vendor-CeKGesq3.js";import{r as c,R as Yi,j as t,b as Mr}from"./react-vendor-CgLzZcV4.js";import{u as Zi,a as Ji,H as ca,P as Et,b as Qi,M as Ns,R as ed,i as td,C as rd,B as nd,c as ha,g as Cs}from"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import{M as ad,r as sd,a as od,b as ld}from"./markdown-vendor-BQJfKm05.js";const id="modulepreload",dd=function(e){return"/"+e},ua={},Oe=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(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};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=dd(h),h in ua)return;ua[h]=!0;const u=h.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":id,u||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),u)return new Promise((f,g)=>{m.addEventListener("load",f),m.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 Ss(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=Ss(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ts(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Ss(e))&&(a&&(a+=" "),a+=r);return a}const cd=(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},hd=(e,r)=>({classGroupId:e,validator:r}),Es=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Er="-",ma=[],ud="arbitrary..",md=e=>{const r=fd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return pd(l);const i=l.split(Er),d=i[0]===""&&i.length>1?1:0;return Ls(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?cd(h,d):d:h||ma}return n[l]||ma}}},Ls=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Ls(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Er):e.slice(r).join(Er),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},pd=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?ud+a:void 0})(),fd=e=>{const{theme:r,classGroups:n}=e;return gd(n,r)},gd=(e,r)=>{const n=Es();for(const a in e){const o=e[a];Dn(o,n,a,r)}return n},Dn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];xd(l,r,n,a)}},xd=(e,r,n,a)=>{if(typeof e=="string"){bd(e,r,n);return}if(typeof e=="function"){vd(e,r,n,a);return}kd(e,r,n,a)},bd=(e,r,n)=>{const a=e===""?r:Ps(r,e);a.classGroupId=n},vd=(e,r,n,a)=>{if(wd(e)){Dn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(hd(n,e))},kd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Dn(d,Ps(r,i),n,a)}},Ps=(e,r)=>{let n=e;const a=r.split(Er),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Es(),n.nextPart.set(l,i)),n=i}return n},wd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,yd=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)}}},wn="!",pa=":",jd=[],fa=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Nd=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 x=0;x<u;x++){const k=o[x];if(l===0&&i===0){if(k===pa){s.push(o.slice(d,x)),d=x+1;continue}if(k==="/"){h=x;continue}}k==="["?l++:k==="]"?l--:k==="("?i++:k===")"&&i--}const p=s.length===0?o:o.slice(d);let m=p,f=!1;p.endsWith(wn)?(m=p.slice(0,-1),f=!0):p.startsWith(wn)&&(m=p.slice(1),f=!0);const g=h&&h>d?h-d:void 0;return fa(s,f,m,g)};if(r){const o=r+pa,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):fa(jd,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Cd=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}},Sd=e=>({cache:yd(e.cacheSize),parseClassName:Nd(e),sortModifiers:Cd(e),postfixLookupClassGroupIds:Td(e),...md(e)}),Td=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},Ed=/\s+/,Ld=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Ed);let h="";for(let u=d.length-1;u>=0;u-=1){const p=d[u],{isExternal:m,modifiers:f,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:k}=n(p);if(m){h=p+(h.length>0?" "+h:h);continue}let b=!!k,y;if(b){const S=x.substring(0,k);y=a(S);const P=y&&l[y]?a(x):void 0;P&&P!==y&&(y=P,b=!1)}else y=a(x);if(!y){if(!b){h=p+(h.length>0?" "+h:h);continue}if(y=a(x),!y){h=p+(h.length>0?" "+h:h);continue}b=!1}const w=f.length===0?"":f.length===1?f[0]:s(f).join(":"),v=g?w+wn:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const j=o(y,b);for(let S=0;S<j.length;++S){const P=j[S];i.push(v+P)}h=p+(h.length>0?" "+h:h)}return h},Pd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Is(n))&&(o&&(o+=" "),o+=a);return o},Is=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Is(e[a]))&&(n&&(n+=" "),n+=r);return n},Id=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,p)=>p(u),e());return n=Sd(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=Ld(d,n);return o(d,u),u};return s=l,(...d)=>s(Pd(...d))},zd=[],qe=e=>{const r=n=>n[e]||zd;return r.isThemeGetter=!0,r},zs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Rs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Rd=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ad=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Md=/\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$/,_d=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$d=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Dd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,gt=e=>Rd.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),ht=e=>!!e&&Number.isInteger(Number(e)),tn=e=>e.endsWith("%")&&Se(e.slice(0,-1)),pt=e=>Ad.test(e),As=()=>!0,Bd=e=>Md.test(e)&&!_d.test(e),Bn=()=>!1,Gd=e=>$d.test(e),Fd=e=>Dd.test(e),Hd=e=>!se(e)&&!le(e),Od=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)),Ud=e=>wt(e,$s,Bn),se=e=>zs.test(e),Ct=e=>wt(e,Ds,Bd),ga=e=>wt(e,Jd,Se),Wd=e=>wt(e,Gs,As),Vd=e=>wt(e,Bs,Bn),xa=e=>wt(e,Ms,Bn),qd=e=>wt(e,_s,Fd),gr=e=>wt(e,Fs,Gd),le=e=>Rs.test(e),Jt=e=>Mt(e,Ds),Kd=e=>Mt(e,Bs),ba=e=>Mt(e,Ms),Xd=e=>Mt(e,$s),Yd=e=>Mt(e,_s),xr=e=>Mt(e,Fs,!0),Zd=e=>Mt(e,Gs,!0),wt=(e,r,n)=>{const a=zs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Mt=(e,r,n=!1)=>{const a=Rs.exec(e);return a?a[1]?r(a[1]):n:!1},Ms=e=>e==="position"||e==="percentage",_s=e=>e==="image"||e==="url",$s=e=>e==="length"||e==="size"||e==="bg-size",Ds=e=>e==="length",Jd=e=>e==="number",Bs=e=>e==="family-name",Gs=e=>e==="number"||e==="weight",Fs=e=>e==="shadow",Qd=()=>{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"),p=qe("inset-shadow"),m=qe("text-shadow"),f=qe("drop-shadow"),g=qe("blur"),x=qe("perspective"),k=qe("aspect"),b=qe("ease"),y=qe("animate"),w=()=>["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"],N=()=>[...v(),le,se],j=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],P=()=>[le,se,d],C=()=>[gt,"full","auto",...P()],F=()=>[ht,"none","subgrid",le,se],H=()=>["auto",{span:["full",ht,le,se]},ht,le,se],M=()=>[ht,"auto",le,se],Q=()=>["auto","min","max","fr",le,se],V=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],W=()=>["start","end","center","stretch","center-safe","end-safe"],Z=()=>["auto",...P()],de=()=>[gt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...P()],E=()=>[gt,"screen","full","dvw","lvw","svw","min","max","fit",...P()],J=()=>[gt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...P()],A=()=>[e,le,se],X=()=>[...v(),ba,xa,{position:[le,se]}],O=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",Xd,Ud,{size:[le,se]}],K=()=>[tn,Jt,Ct],B=()=>["","none","full",h,le,se],T=()=>["",Se,Jt,Ct],z=()=>["solid","dashed","dotted","double"],Y=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[Se,tn,ba,xa],q=()=>["","none",g,le,se],G=()=>["none",Se,le,se],ce=()=>["none",Se,le,se],ee=()=>[Se,le,se],ie=()=>[gt,"full",...P()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pt],breakpoint:[pt],color:[As],container:[pt],"drop-shadow":[pt],ease:["in","out","in-out"],font:[Hd],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pt],shadow:[pt],spacing:["px",Se],text:[pt],"text-shadow":[pt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",gt,se,le,k]}],container:["container"],"container-type":[{"@container":["","normal","size",le,se]}],"container-named":[Od],columns:[{columns:[Se,se,le,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:N()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{"inset-s":C(),start:C()}],end:[{"inset-e":C(),end:C()}],"inset-bs":[{"inset-bs":C()}],"inset-be":[{"inset-be":C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:["visible","invisible","collapse"],z:[{z:[ht,"auto",le,se]}],basis:[{basis:[gt,"full","auto",i,...P()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,gt,"auto","initial","none",se]}],grow:[{grow:["",Se,le,se]}],shrink:[{shrink:["",Se,le,se]}],order:[{order:[ht,"first","last","none",le,se]}],"grid-cols":[{"grid-cols":F()}],"col-start-end":[{col:H()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":F()}],"row-start-end":[{row:H()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:P()}],"gap-x":[{"gap-x":P()}],"gap-y":[{"gap-y":P()}],"justify-content":[{justify:[...V(),"normal"]}],"justify-items":[{"justify-items":[...W(),"normal"]}],"justify-self":[{"justify-self":["auto",...W()]}],"align-content":[{content:["normal",...V()]}],"align-items":[{items:[...W(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...W(),{baseline:["","last"]}]}],"place-content":[{"place-content":V()}],"place-items":[{"place-items":[...W(),"baseline"]}],"place-self":[{"place-self":["auto",...W()]}],p:[{p:P()}],px:[{px:P()}],py:[{py:P()}],ps:[{ps:P()}],pe:[{pe:P()}],pbs:[{pbs:P()}],pbe:[{pbe:P()}],pt:[{pt:P()}],pr:[{pr:P()}],pb:[{pb:P()}],pl:[{pl:P()}],m:[{m:Z()}],mx:[{mx:Z()}],my:[{my:Z()}],ms:[{ms:Z()}],me:[{me:Z()}],mbs:[{mbs:Z()}],mbe:[{mbe:Z()}],mt:[{mt:Z()}],mr:[{mr:Z()}],mb:[{mb:Z()}],ml:[{ml:Z()}],"space-x":[{"space-x":P()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":P()}],"space-y-reverse":["space-y-reverse"],size:[{size:de()}],"inline-size":[{inline:["auto",...E()]}],"min-inline-size":[{"min-inline":["auto",...E()]}],"max-inline-size":[{"max-inline":["none",...E()]}],"block-size":[{block:["auto",...J()]}],"min-block-size":[{"min-block":["auto",...J()]}],"max-block-size":[{"max-block":["none",...J()]}],w:[{w:[i,"screen",...de()]}],"min-w":[{"min-w":[i,"screen","none",...de()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...de()]}],h:[{h:["screen","lh",...de()]}],"min-h":[{"min-h":["screen","lh","none",...de()]}],"max-h":[{"max-h":["screen","lh",...de()]}],"font-size":[{text:["base",n,Jt,Ct]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Zd,Wd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",tn,se]}],"font-family":[{font:[Kd,Vd,r]}],"font-features":[{"font-features":[se]}],"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,le,se]}],"line-clamp":[{"line-clamp":[Se,"none",le,ga]}],leading:[{leading:[s,...P()]}],"list-image":[{"list-image":["none",le,se]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",le,se]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...z(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",le,Ct]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[Se,"auto",le,se]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:P()}],"tab-size":[{tab:[ht,le,se]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",le,se]}],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",le,se]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:X()}],"bg-repeat":[{bg:O()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ht,le,se],radial:["",le,se],conic:[ht,le,se]},Yd,qd]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],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:T()}],"border-w-x":[{"border-x":T()}],"border-w-y":[{"border-y":T()}],"border-w-s":[{"border-s":T()}],"border-w-e":[{"border-e":T()}],"border-w-bs":[{"border-bs":T()}],"border-w-be":[{"border-be":T()}],"border-w-t":[{"border-t":T()}],"border-w-r":[{"border-r":T()}],"border-w-b":[{"border-b":T()}],"border-w-l":[{"border-l":T()}],"divide-x":[{"divide-x":T()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":T()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...z(),"hidden","none"]}],"divide-style":[{divide:[...z(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,le,se]}],"outline-w":[{outline:["",Se,Jt,Ct]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",u,xr,gr]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",p,xr,gr]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:T()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[Se,Ct]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":T()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",m,xr,gr]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[Se,le,se]}],"mix-blend":[{"mix-blend":[...Y(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Y()}],"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":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[le,se]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"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":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:X()}],"mask-repeat":[{mask:O()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",le,se]}],filter:[{filter:["","none",le,se]}],blur:[{blur:q()}],brightness:[{brightness:[Se,le,se]}],contrast:[{contrast:[Se,le,se]}],"drop-shadow":[{"drop-shadow":["","none",f,xr,gr]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",Se,le,se]}],"hue-rotate":[{"hue-rotate":[Se,le,se]}],invert:[{invert:["",Se,le,se]}],saturate:[{saturate:[Se,le,se]}],sepia:[{sepia:["",Se,le,se]}],"backdrop-filter":[{"backdrop-filter":["","none",le,se]}],"backdrop-blur":[{"backdrop-blur":q()}],"backdrop-brightness":[{"backdrop-brightness":[Se,le,se]}],"backdrop-contrast":[{"backdrop-contrast":[Se,le,se]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,le,se]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,le,se]}],"backdrop-invert":[{"backdrop-invert":["",Se,le,se]}],"backdrop-opacity":[{"backdrop-opacity":[Se,le,se]}],"backdrop-saturate":[{"backdrop-saturate":[Se,le,se]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,le,se]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":P()}],"border-spacing-x":[{"border-spacing-x":P()}],"border-spacing-y":[{"border-spacing-y":P()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",le,se]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",le,se]}],ease:[{ease:["linear","initial",b,le,se]}],delay:[{delay:[Se,le,se]}],animate:[{animate:["none",y,le,se]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,le,se]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[le,se,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],zoom:[{zoom:[ht,le,se]}],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"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",le,se]}],"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":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":P()}],"scroll-mx":[{"scroll-mx":P()}],"scroll-my":[{"scroll-my":P()}],"scroll-ms":[{"scroll-ms":P()}],"scroll-me":[{"scroll-me":P()}],"scroll-mbs":[{"scroll-mbs":P()}],"scroll-mbe":[{"scroll-mbe":P()}],"scroll-mt":[{"scroll-mt":P()}],"scroll-mr":[{"scroll-mr":P()}],"scroll-mb":[{"scroll-mb":P()}],"scroll-ml":[{"scroll-ml":P()}],"scroll-p":[{"scroll-p":P()}],"scroll-px":[{"scroll-px":P()}],"scroll-py":[{"scroll-py":P()}],"scroll-ps":[{"scroll-ps":P()}],"scroll-pe":[{"scroll-pe":P()}],"scroll-pbs":[{"scroll-pbs":P()}],"scroll-pbe":[{"scroll-pbe":P()}],"scroll-pt":[{"scroll-pt":P()}],"scroll-pr":[{"scroll-pr":P()}],"scroll-pb":[{"scroll-pb":P()}],"scroll-pl":[{"scroll-pl":P()}],"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",le,se]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[Se,Jt,Ct,ga]}],stroke:[{stroke:["none",...A()]}],"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"]}},ec=Id(Qd),va=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ka=Ts,dr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return ka(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],p=s==null?void 0:s[h];if(u===null)return null;const m=va(u)||va(p);return o[h][m]}),i=n&&Object.entries(n).reduce((h,u)=>{let[p,m]=u;return m===void 0||(h[p]=m),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:p,className:m,...f}=u;return Object.entries(f).every(g=>{let[x,k]=g;return Array.isArray(k)?k.includes({...s,...i}[x]):{...s,...i}[x]===k})?[...h,p,m]:h},[]);return ka(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},_r=c.createContext(null);_r.displayName="PanelGroupContext";const Be={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"},Gn=10,It=c.useLayoutEffect,wa=Yi.useId,tc=typeof wa=="function"?wa:()=>null;let rc=0;function Fn(e=null){const r=tc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+rc++),e??n.current}function Hs({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:p,order:m,style:f,tagName:g="div",...x}){const k=c.useContext(_r);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:y,getPanelSize:w,getPanelStyle:v,groupId:N,isPanelCollapsed:j,reevaluatePanelConstraints:S,registerPanel:P,resizePanel:C,unregisterPanel:F}=k,H=Fn(l),M=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:p},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:H,idIsFromProps:l!==void 0,order:m});c.useRef({didLogMissingDefaultSizeWarning:!1}),It(()=>{const{callbacks:V,constraints:W}=M.current,Z={...W};M.current.id=H,M.current.idIsFromProps=l!==void 0,M.current.order=m,V.onCollapse=h,V.onExpand=u,V.onResize=p,W.collapsedSize=n,W.collapsible=a,W.defaultSize=o,W.maxSize=i,W.minSize=d,(Z.collapsedSize!==W.collapsedSize||Z.collapsible!==W.collapsible||Z.maxSize!==W.maxSize||Z.minSize!==W.minSize)&&S(M.current,Z)}),It(()=>{const V=M.current;return P(V),()=>{F(V)}},[m,H,P,F]),c.useImperativeHandle(s,()=>({collapse:()=>{b(M.current)},expand:V=>{y(M.current,V)},getId(){return H},getSize(){return w(M.current)},isCollapsed(){return j(M.current)},isExpanded(){return!j(M.current)},resize:V=>{C(M.current,V)}}),[b,y,w,j,H,C]);const Q=v(M.current,o);return c.createElement(g,{...x,children:e,className:r,id:H,style:{...Q,...f},[Be.groupId]:N,[Be.panel]:"",[Be.panelCollapsible]:a||void 0,[Be.panelId]:H,[Be.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const Os=c.forwardRef((e,r)=>c.createElement(Hs,{...e,forwardedRef:r}));Hs.displayName="Panel";Os.displayName="forwardRef(Panel)";let yn=null,jr=-1,bt=null;function nc(e,r,n){const a=(r&Ks)!==0,o=(r&Xs)!==0,s=(r&Ys)!==0,l=(r&Zs)!==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 ac(){bt!==null&&(document.head.removeChild(bt),yn=null,bt=null,jr=-1)}function rn(e,r,n){var a,o;const s=nc(e,r);if(yn!==s){if(yn=s,bt===null&&(bt=document.createElement("style"),document.head.appendChild(bt)),jr>=0){var l;(l=bt.sheet)===null||l===void 0||l.removeRule(jr)}jr=(a=(o=bt.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function Us(e){return e.type==="keydown"}function Ws(e){return e.type.startsWith("pointer")}function Vs(e){return e.type.startsWith("mouse")}function $r(e){if(Ws(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Vs(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 oc(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 lc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Na(e),b:Na(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ce(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:ja(ya(n.a)),b:ja(ya(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 ic=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dc(e){var r;const n=getComputedStyle((r=qs(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function cc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||dc(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"||ic.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function ya(e){let r=e.length;for(;r--;){const n=e[r];if(Ce(n,"Missing node"),cc(n))return n}return null}function ja(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Na(e){const r=[];for(;e;)r.push(e),e=qs(e);return r}function qs(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const Ks=1,Xs=2,Ys=4,Zs=8,hc=sc()==="coarse";let ct=[],Vt=!1,vt=new Map,Dr=new Map;const or=new Set;function uc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=vt.get(l))!==null&&s!==void 0?s:0;return vt.set(l,d+1),or.add(i),Lr(),function(){var u;Dr.delete(e),or.delete(i);const p=(u=vt.get(l))!==null&&u!==void 0?u:1;if(vt.set(l,p-1),Lr(),p===1&&vt.delete(l),ct.includes(i)){const m=ct.indexOf(i);m>=0&&ct.splice(m,1),Br(),o("up",!0,null)}}}function mc(e){const{target:r}=e,{x:n,y:a}=$r(e);Vt=!0,Hn({target:r,x:n,y:a}),Lr(),ct.length>0&&(Pr("down",e),Br(),e.preventDefault(),Js(r)||e.stopImmediatePropagation())}function nn(e){const{x:r,y:n}=$r(e);if(Vt&&e.type!=="pointerleave"&&e.buttons===0&&(Vt=!1,Pr("up",e)),!Vt){const{target:a}=e;Hn({target:a,x:r,y:n})}Pr("move",e),Br(),ct.length>0&&e.preventDefault()}function an(e){const{target:r}=e,{x:n,y:a}=$r(e);Dr.clear(),Vt=!1,ct.length>0&&(e.preventDefault(),Js(r)||e.stopImmediatePropagation()),Pr("up",e),Hn({target:r,x:n,y:a}),Br(),Lr()}function Js(e){let r=e;for(;r;){if(r.hasAttribute(Be.resizeHandle))return!0;r=r.parentElement}return!1}function Hn({target:e,x:r,y:n}){ct.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),or.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:p}=i,m=hc?l.coarse:l.fine;if(r>=h-m&&r<=u+m&&n>=p-m&&n<=d+m){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&lc(a,s)>0){let g=a,x=!1;for(;g&&!g.contains(s);){if(oc(g.getBoundingClientRect(),i)){x=!0;break}g=g.parentElement}if(x)return}ct.push(o)}})}function sn(e,r){Dr.set(e,r)}function Br(){let e=!1,r=!1;ct.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Dr.forEach(a=>{n|=a}),e&&r?rn("intersection",n):e?rn("horizontal",n):r?rn("vertical",n):ac()}let on;function Lr(){var e;(e=on)===null||e===void 0||e.abort(),on=new AbortController;const r={capture:!0,signal:on.signal};or.size&&(Vt?(ct.length>0&&vt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",an,r),o.addEventListener("pointerleave",nn,r),o.addEventListener("pointermove",nn,r))}),vt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",an,r),o.addEventListener("pointercancel",an,r)})):vt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",mc,r),o.addEventListener("pointermove",nn,r))}))}function Pr(e,r){or.forEach(n=>{const{setResizeHandlerState:a}=n,o=ct.includes(n);a(e,o,r)})}function pc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ce(e,r){if(!e)throw console.error(r),Error(r)}function At(e,r,n=Gn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function ft(e,r,n=Gn){return At(e,r,n)===0}function at(e,r,n){return At(e,r,n)===0}function fc(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(!at(o,s,n))return!1}return!0}function Wt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ce(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(At(n,i)<0)if(s){const d=(o+i)/2;At(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(Gn)),n}function rr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(at(e,0))return r;const l=[...r],[i,d]=a;Ce(i!=null,"Invalid first pivot index"),Ce(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const p=e<0?d:i,m=n[p];Ce(m,`Panel constraints not found for index ${p}`);const{collapsedSize:f=0,collapsible:g,minSize:x=0}=m;if(g){const k=r[p];if(Ce(k!=null,`Previous layout not found for panel index ${p}`),at(k,f)){const b=x-k;At(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?i:d,m=n[p];Ce(m,`No panel constraints found for index ${p}`);const{collapsedSize:f=0,collapsible:g,minSize:x=0}=m;if(g){const k=r[p];if(Ce(k!=null,`Previous layout not found for panel index ${p}`),at(k,x)){const b=k-f;At(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let m=e<0?d:i,f=0;for(;;){const x=r[m];Ce(x!=null,`Previous layout not found for panel index ${m}`);const b=Wt({panelConstraints:n,panelIndex:m,size:100})-x;if(f+=b,m+=p,m<0||m>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-g:g}{let m=e<0?i:d;for(;m>=0&&m<n.length;){const f=Math.abs(e)-Math.abs(h),g=r[m];Ce(g!=null,`Previous layout not found for panel index ${m}`);const x=g-f,k=Wt({panelConstraints:n,panelIndex:m,size:x});if(!at(g,k)&&(h+=g-k,l[m]=k,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(fc(o,l))return o;{const p=e<0?d:i,m=r[p];Ce(m!=null,`Previous layout not found for panel index ${p}`);const f=m+h,g=Wt({panelConstraints:n,panelIndex:p,size:f});if(l[p]=g,!at(g,f)){let x=f-g,b=e<0?d:i;for(;b>=0&&b<n.length;){const y=l[b];Ce(y!=null,`Previous layout not found for panel index ${b}`);const w=y+x,v=Wt({panelConstraints:n,panelIndex:b,size:w});if(at(y,v)||(x-=v-y,l[b]=v),at(x,0))break;e>0?b--:b++}}}const u=l.reduce((p,m)=>m+p,0);return at(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];Ce(i!=null,"No pivot index found"),r.forEach((p,m)=>{const{constraints:f}=p,{maxSize:g=100,minSize:x=0}=f;m===i?(a=x,o=g):(s+=x,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 lr(e,r=document){return Array.from(r.querySelectorAll(`[${Be.resizeHandleId}][data-panel-group-id="${e}"]`))}function Qs(e,r,n=document){const o=lr(e,n).findIndex(s=>s.getAttribute(Be.resizeHandleId)===r);return o??null}function eo(e,r,n){const a=Qs(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function xc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function to(e,r=document){if(xc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Gr(e,r=document){const n=r.querySelector(`[${Be.resizeHandleId}="${e}"]`);return n||null}function bc(e,r,n,a=document){var o,s,l,i;const d=Gr(r,a),h=lr(e,a),u=d?h.indexOf(d):-1,p=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,m=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[p,m]}function vc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),It(()=>{if(!s)return;const i=lr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:p}=gc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),m=i[d];if(m!=null){const f=o[d];Ce(f,`No panel data found for index "${d}"`),m.setAttribute("aria-controls",f.id),m.setAttribute("aria-valuemax",""+Math.round(h)),m.setAttribute("aria-valuemin",""+Math.round(u)),m.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}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;Ce(i,"Eager values not found");const{panelDataArray:d}=i,h=to(n,s);Ce(h!=null,`No group found for id "${n}"`);const u=lr(n,s);Ce(u,`No resize handles found for group id "${n}"`);const p=u.map(m=>{const f=m.getAttribute(Be.resizeHandleId);Ce(f,"Resize handle element has no handle id attribute");const[g,x]=bc(n,f,d,s);if(g==null||x==null)return()=>{};const k=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const y=d.findIndex(w=>w.id===g);if(y>=0){const w=d[y];Ce(w,`No panel data found for index ${y}`);const v=a[y],{collapsedSize:N=0,collapsible:j,minSize:S=0}=w.constraints;if(v!=null&&j){const P=rr({delta:at(v,N)?S-N:N-v,initialLayout:a,panelConstraints:d.map(C=>C.constraints),pivotIndices:eo(n,f,s),prevLayout:a,trigger:"keyboard"});a!==P&&l(P)}}break}}};return m.addEventListener("keydown",k),()=>{m.removeEventListener("keydown",k)}});return()=>{p.forEach(m=>m())}},[s,e,r,n,a,o,l])}function Ca(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 ro(e,r){const n=e==="horizontal",{x:a,y:o}=$r(r);return n?a:o}function kc(e,r,n,a,o){const s=n==="horizontal",l=Gr(r,o);Ce(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Be.groupId);Ce(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ro(n,e),u=to(i,o);Ce(u,`No group element found for id "${i}"`);const p=u.getBoundingClientRect(),m=s?p.width:p.height;return(h-d)/m*100}function wc(e,r,n,a,o,s){if(Us(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:kc(e,r,n,a,s)}function yc({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];Ce(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];Ce(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 Ft(e,r,n){r.forEach((a,o)=>{const s=e[o];Ce(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{collapsedSize:h=0,collapsible:u}=i,p=n[d];if(p==null||a!==p){n[d]=a;const{onCollapse:m,onExpand:f,onResize:g}=l;g&&g(a,p),u&&(m||f)&&(f&&(p==null||ft(p,h))&&!ft(a,h)&&f(),m&&(p==null||!ft(p,h))&&ft(a,h)&&m())}})}function br(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 jc({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 Nc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Sa(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 no(e){return`react-resizable-panels:${e}`}function ao(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 so(e,r){try{const n=no(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Cc(e,r,n){var a,o;const s=(a=so(e,n))!==null&&a!==void 0?a:{},l=ao(r);return(o=s[l])!==null&&o!==void 0?o:null}function Sc(e,r,n,a,o){var s;const l=no(e),i=ao(r),d=(s=so(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 Ta({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(!at(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Ce(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];Ce(l!=null,`No layout data found for index ${s}`);const i=Wt({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!at(o,0))for(let s=0;s<r.length;s++){const l=n[s];Ce(l!=null,`No layout data found for index ${s}`);const i=l+o,d=Wt({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,at(o,0)))break}return n}const Tc=100,nr={getItem:e=>(Sa(nr),nr.getItem(e)),setItem:(e,r)=>{Sa(nr),nr.setItem(e,r)}},Ea={};function oo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=nr,style:h,tagName:u="div",...p}){const m=Fn(s),f=c.useRef(null),[g,x]=c.useState(null),[k,b]=c.useState([]),y=pc(),w=c.useRef({}),v=c.useRef(new Map),N=c.useRef(0),j=c.useRef({autoSaveId:e,direction:a,dragState:g,id:m,keyboardResizeBy:i,onLayout:l,storage:d}),S=c.useRef({layout:k,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:I}=S.current;return I},setLayout:I=>{const{onLayout:K}=j.current,{layout:B,panelDataArray:T}=S.current,z=Ta({layout:I,panelConstraints:T.map(Y=>Y.constraints)});Ca(B,z)||(b(z),S.current.layout=z,K&&K(z),Ft(T,z,w.current))}}),[]),It(()=>{j.current.autoSaveId=e,j.current.direction=a,j.current.dragState=g,j.current.id=m,j.current.onLayout=l,j.current.storage=d}),vc({committedValuesRef:j,eagerValuesRef:S,groupId:m,layout:k,panelDataArray:S.current.panelDataArray,setLayout:b,panelGroupElement:f.current}),c.useEffect(()=>{const{panelDataArray:I}=S.current;if(e){if(k.length===0||k.length!==I.length)return;let K=Ea[e];K==null&&(K=Nc(Sc,Tc),Ea[e]=K);const B=[...I],T=new Map(v.current);K(e,B,T,k,d)}},[e,k,d]),c.useEffect(()=>{});const P=c.useCallback(I=>{const{onLayout:K}=j.current,{layout:B,panelDataArray:T}=S.current;if(I.constraints.collapsible){const z=T.map(G=>G.constraints),{collapsedSize:Y=0,panelSize:$,pivotIndices:q}=St(T,I,B);if(Ce($!=null,`Panel size not found for panel "${I.id}"`),!ft($,Y)){v.current.set(I.id,$);const ce=Ot(T,I)===T.length-1?$-Y:Y-$,ee=rr({delta:ce,initialLayout:B,panelConstraints:z,pivotIndices:q,prevLayout:B,trigger:"imperative-api"});br(B,ee)||(b(ee),S.current.layout=ee,K&&K(ee),Ft(T,ee,w.current))}}},[]),C=c.useCallback((I,K)=>{const{onLayout:B}=j.current,{layout:T,panelDataArray:z}=S.current;if(I.constraints.collapsible){const Y=z.map(ie=>ie.constraints),{collapsedSize:$=0,panelSize:q=0,minSize:G=0,pivotIndices:ce}=St(z,I,T),ee=K??G;if(ft(q,$)){const ie=v.current.get(I.id),ue=ie!=null&&ie>=ee?ie:ee,Le=Ot(z,I)===z.length-1?q-ue:ue-q,re=rr({delta:Le,initialLayout:T,panelConstraints:Y,pivotIndices:ce,prevLayout:T,trigger:"imperative-api"});br(T,re)||(b(re),S.current.layout=re,B&&B(re),Ft(z,re,w.current))}}},[]),F=c.useCallback(I=>{const{layout:K,panelDataArray:B}=S.current,{panelSize:T}=St(B,I,K);return Ce(T!=null,`Panel size not found for panel "${I.id}"`),T},[]),H=c.useCallback((I,K)=>{const{panelDataArray:B}=S.current,T=Ot(B,I);return jc({defaultSize:K,dragState:g,layout:k,panelData:B,panelIndex:T})},[g,k]),M=c.useCallback(I=>{const{layout:K,panelDataArray:B}=S.current,{collapsedSize:T=0,collapsible:z,panelSize:Y}=St(B,I,K);return Ce(Y!=null,`Panel size not found for panel "${I.id}"`),z===!0&&ft(Y,T)},[]),Q=c.useCallback(I=>{const{layout:K,panelDataArray:B}=S.current,{collapsedSize:T=0,collapsible:z,panelSize:Y}=St(B,I,K);return Ce(Y!=null,`Panel size not found for panel "${I.id}"`),!z||At(Y,T)>0},[]),V=c.useCallback(I=>{const{panelDataArray:K}=S.current;K.push(I),K.sort((B,T)=>{const z=B.order,Y=T.order;return z==null&&Y==null?0:z==null?-1:Y==null?1:z-Y}),S.current.panelDataArrayChanged=!0,y()},[y]);It(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:I,onLayout:K,storage:B}=j.current,{layout:T,panelDataArray:z}=S.current;let Y=null;if(I){const q=Cc(I,z,B);q&&(v.current=new Map(Object.entries(q.expandToSizes)),Y=q.layout)}Y==null&&(Y=yc({panelDataArray:z}));const $=Ta({layout:Y,panelConstraints:z.map(q=>q.constraints)});Ca(T,$)||(b($),S.current.layout=$,K&&K($),Ft(z,$,w.current))}}),It(()=>{const I=S.current;return()=>{I.layout=[]}},[]);const W=c.useCallback(I=>{let K=!1;const B=f.current;return B&&window.getComputedStyle(B,null).getPropertyValue("direction")==="rtl"&&(K=!0),function(z){z.preventDefault();const Y=f.current;if(!Y)return()=>null;const{direction:$,dragState:q,id:G,keyboardResizeBy:ce,onLayout:ee}=j.current,{layout:ie,panelDataArray:ue}=S.current,{initialLayout:ge}=q??{},Le=eo(G,I,Y);let re=wc(z,I,$,q,ce,Y);const be=$==="horizontal";be&&K&&(re=-re);const je=ue.map(R=>R.constraints),xe=rr({delta:re,initialLayout:ge??ie,panelConstraints:je,pivotIndices:Le,prevLayout:ie,trigger:Us(z)?"keyboard":"mouse-or-touch"}),ze=!br(ie,xe);(Ws(z)||Vs(z))&&N.current!=re&&(N.current=re,!ze&&re!==0?be?sn(I,re<0?Ks:Xs):sn(I,re<0?Ys:Zs):sn(I,0)),ze&&(b(xe),S.current.layout=xe,ee&&ee(xe),Ft(ue,xe,w.current))}},[]),Z=c.useCallback((I,K)=>{const{onLayout:B}=j.current,{layout:T,panelDataArray:z}=S.current,Y=z.map(ie=>ie.constraints),{panelSize:$,pivotIndices:q}=St(z,I,T);Ce($!=null,`Panel size not found for panel "${I.id}"`);const ce=Ot(z,I)===z.length-1?$-K:K-$,ee=rr({delta:ce,initialLayout:T,panelConstraints:Y,pivotIndices:q,prevLayout:T,trigger:"imperative-api"});br(T,ee)||(b(ee),S.current.layout=ee,B&&B(ee),Ft(z,ee,w.current))},[]),de=c.useCallback((I,K)=>{const{layout:B,panelDataArray:T}=S.current,{collapsedSize:z=0,collapsible:Y}=K,{collapsedSize:$=0,collapsible:q,maxSize:G=100,minSize:ce=0}=I.constraints,{panelSize:ee}=St(T,I,B);ee!=null&&(Y&&q&&ft(ee,z)?ft(z,$)||Z(I,$):ee<ce?Z(I,ce):ee>G&&Z(I,G))},[Z]),E=c.useCallback((I,K)=>{const{direction:B}=j.current,{layout:T}=S.current;if(!f.current)return;const z=Gr(I,f.current);Ce(z,`Drag handle element not found for id "${I}"`);const Y=ro(B,K);x({dragHandleId:I,dragHandleRect:z.getBoundingClientRect(),initialCursorPosition:Y,initialLayout:T})},[]),J=c.useCallback(()=>{x(null)},[]),A=c.useCallback(I=>{const{panelDataArray:K}=S.current,B=Ot(K,I);B>=0&&(K.splice(B,1),delete w.current[I.id],S.current.panelDataArrayChanged=!0,y())},[y]),X=c.useMemo(()=>({collapsePanel:P,direction:a,dragState:g,expandPanel:C,getPanelSize:F,getPanelStyle:H,groupId:m,isPanelCollapsed:M,isPanelExpanded:Q,reevaluatePanelConstraints:de,registerPanel:V,registerResizeHandle:W,resizePanel:Z,startDragging:E,stopDragging:J,unregisterPanel:A,panelGroupElement:f.current}),[P,g,a,C,F,H,m,M,Q,de,V,W,Z,E,J,A]),O={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(_r.Provider,{value:X},c.createElement(u,{...p,children:r,className:n,id:s,ref:f,style:{...O,...h},[Be.group]:"",[Be.groupDirection]:a,[Be.groupId]:m}))}const lo=c.forwardRef((e,r)=>c.createElement(oo,{...e,forwardedRef:r}));oo.displayName="PanelGroup";lo.displayName="forwardRef(PanelGroup)";function Ot(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function St(e,r,n){const a=Ot(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Ec({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=Gr(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(Be.groupId);Ce(i,`No group element found for id "${i}"`);const d=lr(i,a),h=Qs(i,r,a);Ce(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 io({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:p={},tabIndex:m=0,tagName:f="div",...g}){var x,k;const b=c.useRef(null),y=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{y.current.onClick=l,y.current.onDragging=i,y.current.onPointerDown=h,y.current.onPointerUp=u});const w=c.useContext(_r);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:N,registerResizeHandle:j,startDragging:S,stopDragging:P,panelGroupElement:C}=w,F=Fn(o),[H,M]=c.useState("inactive"),[Q,V]=c.useState(!1),[W,Z]=c.useState(null),de=c.useRef({state:H});It(()=>{de.current.state=H}),c.useEffect(()=>{if(n)Z(null);else{const X=j(F);Z(()=>X)}},[n,F,j]);const E=(x=a==null?void 0:a.coarse)!==null&&x!==void 0?x:15,J=(k=a==null?void 0:a.fine)!==null&&k!==void 0?k:5;c.useEffect(()=>{if(n||W==null)return;const X=b.current;Ce(X,"Element ref not attached");let O=!1;return uc(F,X,v,{coarse:E,fine:J},(K,B,T)=>{if(!B){M("inactive");return}switch(K){case"down":{M("drag"),O=!1,Ce(T,'Expected event to be defined for "down" action'),S(F,T);const{onDragging:z,onPointerDown:Y}=y.current;z==null||z(!0),Y==null||Y();break}case"move":{const{state:z}=de.current;O=!0,z!=="drag"&&M("hover"),Ce(T,'Expected event to be defined for "move" action'),W(T);break}case"up":{M("hover"),P();const{onClick:z,onDragging:Y,onPointerUp:$}=y.current;Y==null||Y(!1),$==null||$(),O||z==null||z();break}}})},[E,v,n,J,j,F,W,S,P]),Ec({disabled:n,handleId:F,resizeHandler:W,panelGroupElement:C});const A={touchAction:"none",userSelect:"none"};return c.createElement(f,{...g,children:e,className:r,id:o,onBlur:()=>{V(!1),s==null||s()},onFocus:()=>{V(!0),d==null||d()},ref:b,role:"separator",style:{...A,...p},tabIndex:m,[Be.groupDirection]:v,[Be.groupId]:N,[Be.resizeHandle]:"",[Be.resizeHandleActive]:H==="drag"?"pointer":Q?"keyboard":void 0,[Be.resizeHandleEnabled]:!n,[Be.resizeHandleId]:F,[Be.resizeHandleState]:H})}io.displayName="PanelResizeHandle";var Lc=Object.defineProperty,Pc=Object.getOwnPropertyNames,Me=(e,r)=>function(){return e&&(r=(0,e[Pc(e)[0]])(e=0)),r},Ic=(e,r)=>{for(var n in r)Lc(e,n,{get:r[n],enumerable:!0})};function Qe(...e){return ec(Ts(e))}var yt=Me({"src/components/graph-ui/utils.ts"(){}});function ir({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?js:"button";return t.jsx(s,{"data-slot":"button",className:Qe(co({variant:a,size:n,className:r})),...o})}var co,Fr=Me({"src/components/graph-ui/Button.tsx"(){yt(),co=dr("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 ho(...e){return e.filter(Boolean).join(" ")}function uo({className:e,...r}){return t.jsx(lo,{"data-slot":"resizable-panel-group",className:ho("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function Ir({...e}){return t.jsx(Os,{"data-slot":"resizable-panel",...e})}function mo({withHandle:e,className:r,...n}){return t.jsx(io,{"data-slot":"resizable-handle",className:ho("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 po=Me({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function On(...e){return e.filter(Boolean).join(" ")}function cr({...e}){return t.jsx(Si,{"data-slot":"accordion",...e})}function hr({className:e,...r}){return t.jsx(Ti,{"data-slot":"accordion-item",className:On("border-b last:border-b-0",e),...r})}function ur({className:e,children:r,...n}){return t.jsx(Ei,{className:"flex",children:t.jsxs(Li,{"data-slot":"accordion-trigger",className:On("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 mr({className:e,children:r,...n}){return t.jsx(Pi,{"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:On("pb-4 pt-0",e),children:r})})}var pr=Me({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function zc(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 Rc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function fr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Ac(e){return e.split("/").filter(Boolean).at(-1)??e}function jn(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(jn);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 fo(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=fo(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function go(e){if(e.kind==="file")return e;for(const r of e.children){const n=go(r);if(n)return n}return null}function Nn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Nn(n,r))}function Mc(e){if(!e)return null;const r=fr(e.path);return Un.has(r)?{content:[e.content.endsWith(`
2
+ import{l as $,R as Si,I as Ti,H as Ei,T as Li,C as Pi,S as js,a as Ii,b as zi,c as Ri,d as Ai,e as Mi,D as _i,P as $i,O as Di,f as Bi,g as Gi,h as Fi,i as Hi,j as Oi,k as Ui,m as Wi,n as Vi,A as qi,o as Ki,p as Xi}from"./ui-vendor-CeKGesq3.js";import{r as c,R as Yi,j as t,b as Mr}from"./react-vendor-CgLzZcV4.js";import{u as Zi,a as Ji,H as ca,P as Et,b as Qi,M as Ns,R as ed,i as td,C as rd,B as nd,c as ha,g as Cs}from"./graph-vendor-DVPtkh3h.js";import"./terminal-vendor-B365Go3Z.js";import{M as ad,r as sd,a as od,b as ld}from"./markdown-vendor-BQJfKm05.js";const id="modulepreload",dd=function(e){return"/"+e},ua={},Oe=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(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};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=dd(h),h in ua)return;ua[h]=!0;const u=h.endsWith(".css"),p=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=u?"stylesheet":id,u||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),u)return new Promise((f,g)=>{m.addEventListener("load",f),m.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 Ss(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=Ss(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ts(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Ss(e))&&(a&&(a+=" "),a+=r);return a}const cd=(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},hd=(e,r)=>({classGroupId:e,validator:r}),Es=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Er="-",ma=[],ud="arbitrary..",md=e=>{const r=fd(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return pd(l);const i=l.split(Er),d=i[0]===""&&i.length>1?1:0;return Ls(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?cd(h,d):d:h||ma}return n[l]||ma}}},Ls=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Ls(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Er):e.slice(r).join(Er),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},pd=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?ud+a:void 0})(),fd=e=>{const{theme:r,classGroups:n}=e;return gd(n,r)},gd=(e,r)=>{const n=Es();for(const a in e){const o=e[a];Dn(o,n,a,r)}return n},Dn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];xd(l,r,n,a)}},xd=(e,r,n,a)=>{if(typeof e=="string"){bd(e,r,n);return}if(typeof e=="function"){vd(e,r,n,a);return}kd(e,r,n,a)},bd=(e,r,n)=>{const a=e===""?r:Ps(r,e);a.classGroupId=n},vd=(e,r,n,a)=>{if(wd(e)){Dn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(hd(n,e))},kd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Dn(d,Ps(r,i),n,a)}},Ps=(e,r)=>{let n=e;const a=r.split(Er),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Es(),n.nextPart.set(l,i)),n=i}return n},wd=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,yd=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)}}},wn="!",pa=":",jd=[],fa=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Nd=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 x=0;x<u;x++){const k=o[x];if(l===0&&i===0){if(k===pa){s.push(o.slice(d,x)),d=x+1;continue}if(k==="/"){h=x;continue}}k==="["?l++:k==="]"?l--:k==="("?i++:k===")"&&i--}const p=s.length===0?o:o.slice(d);let m=p,f=!1;p.endsWith(wn)?(m=p.slice(0,-1),f=!0):p.startsWith(wn)&&(m=p.slice(1),f=!0);const g=h&&h>d?h-d:void 0;return fa(s,f,m,g)};if(r){const o=r+pa,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):fa(jd,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Cd=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}},Sd=e=>({cache:yd(e.cacheSize),parseClassName:Nd(e),sortModifiers:Cd(e),postfixLookupClassGroupIds:Td(e),...md(e)}),Td=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},Ed=/\s+/,Ld=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Ed);let h="";for(let u=d.length-1;u>=0;u-=1){const p=d[u],{isExternal:m,modifiers:f,hasImportantModifier:g,baseClassName:x,maybePostfixModifierPosition:k}=n(p);if(m){h=p+(h.length>0?" "+h:h);continue}let b=!!k,y;if(b){const S=x.substring(0,k);y=a(S);const L=y&&l[y]?a(x):void 0;L&&L!==y&&(y=L,b=!1)}else y=a(x);if(!y){if(!b){h=p+(h.length>0?" "+h:h);continue}if(y=a(x),!y){h=p+(h.length>0?" "+h:h);continue}b=!1}const w=f.length===0?"":f.length===1?f[0]:s(f).join(":"),v=g?w+wn:w,N=v+y;if(i.indexOf(N)>-1)continue;i.push(N);const j=o(y,b);for(let S=0;S<j.length;++S){const L=j[S];i.push(v+L)}h=p+(h.length>0?" "+h:h)}return h},Pd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Is(n))&&(o&&(o+=" "),o+=a);return o},Is=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Is(e[a]))&&(n&&(n+=" "),n+=r);return n},Id=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,p)=>p(u),e());return n=Sd(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=Ld(d,n);return o(d,u),u};return s=l,(...d)=>s(Pd(...d))},zd=[],qe=e=>{const r=n=>n[e]||zd;return r.isThemeGetter=!0,r},zs=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Rs=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Rd=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Ad=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Md=/\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$/,_d=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$d=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Dd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,gt=e=>Rd.test(e),Se=e=>!!e&&!Number.isNaN(Number(e)),ht=e=>!!e&&Number.isInteger(Number(e)),tn=e=>e.endsWith("%")&&Se(e.slice(0,-1)),pt=e=>Ad.test(e),As=()=>!0,Bd=e=>Md.test(e)&&!_d.test(e),Bn=()=>!1,Gd=e=>$d.test(e),Fd=e=>Dd.test(e),Hd=e=>!se(e)&&!le(e),Od=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)),Ud=e=>wt(e,$s,Bn),se=e=>zs.test(e),Ct=e=>wt(e,Ds,Bd),ga=e=>wt(e,Jd,Se),Wd=e=>wt(e,Gs,As),Vd=e=>wt(e,Bs,Bn),xa=e=>wt(e,Ms,Bn),qd=e=>wt(e,_s,Fd),gr=e=>wt(e,Fs,Gd),le=e=>Rs.test(e),Jt=e=>Mt(e,Ds),Kd=e=>Mt(e,Bs),ba=e=>Mt(e,Ms),Xd=e=>Mt(e,$s),Yd=e=>Mt(e,_s),xr=e=>Mt(e,Fs,!0),Zd=e=>Mt(e,Gs,!0),wt=(e,r,n)=>{const a=zs.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Mt=(e,r,n=!1)=>{const a=Rs.exec(e);return a?a[1]?r(a[1]):n:!1},Ms=e=>e==="position"||e==="percentage",_s=e=>e==="image"||e==="url",$s=e=>e==="length"||e==="size"||e==="bg-size",Ds=e=>e==="length",Jd=e=>e==="number",Bs=e=>e==="family-name",Gs=e=>e==="number"||e==="weight",Fs=e=>e==="shadow",Qd=()=>{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"),p=qe("inset-shadow"),m=qe("text-shadow"),f=qe("drop-shadow"),g=qe("blur"),x=qe("perspective"),k=qe("aspect"),b=qe("ease"),y=qe("animate"),w=()=>["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"],N=()=>[...v(),le,se],j=()=>["auto","hidden","clip","visible","scroll"],S=()=>["auto","contain","none"],L=()=>[le,se,d],C=()=>[gt,"full","auto",...L()],H=()=>[ht,"none","subgrid",le,se],O=()=>["auto",{span:["full",ht,le,se]},ht,le,se],M=()=>[ht,"auto",le,se],Q=()=>["auto","min","max","fr",le,se],V=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],W=()=>["start","end","center","stretch","center-safe","end-safe"],Z=()=>["auto",...L()],de=()=>[gt,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...L()],T=()=>[gt,"screen","full","dvw","lvw","svw","min","max","fit",...L()],J=()=>[gt,"screen","full","lh","dvh","lvh","svh","min","max","fit",...L()],A=()=>[e,le,se],Y=()=>[...v(),ba,xa,{position:[le,se]}],F=()=>["no-repeat",{repeat:["","x","y","space","round"]}],I=()=>["auto","cover","contain",Xd,Ud,{size:[le,se]}],K=()=>[tn,Jt,Ct],D=()=>["","none","full",h,le,se],P=()=>["",Se,Jt,Ct],z=()=>["solid","dashed","dotted","double"],X=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],_=()=>[Se,tn,ba,xa],q=()=>["","none",g,le,se],G=()=>["none",Se,le,se],ce=()=>["none",Se,le,se],ee=()=>[Se,le,se],ie=()=>[gt,"full",...L()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pt],breakpoint:[pt],color:[As],container:[pt],"drop-shadow":[pt],ease:["in","out","in-out"],font:[Hd],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pt],shadow:[pt],spacing:["px",Se],text:[pt],"text-shadow":[pt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",gt,se,le,k]}],container:["container"],"container-type":[{"@container":["","normal","size",le,se]}],"container-named":[Od],columns:[{columns:[Se,se,le,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:N()}],overflow:[{overflow:j()}],"overflow-x":[{"overflow-x":j()}],"overflow-y":[{"overflow-y":j()}],overscroll:[{overscroll:S()}],"overscroll-x":[{"overscroll-x":S()}],"overscroll-y":[{"overscroll-y":S()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:C()}],"inset-x":[{"inset-x":C()}],"inset-y":[{"inset-y":C()}],start:[{"inset-s":C(),start:C()}],end:[{"inset-e":C(),end:C()}],"inset-bs":[{"inset-bs":C()}],"inset-be":[{"inset-be":C()}],top:[{top:C()}],right:[{right:C()}],bottom:[{bottom:C()}],left:[{left:C()}],visibility:["visible","invisible","collapse"],z:[{z:[ht,"auto",le,se]}],basis:[{basis:[gt,"full","auto",i,...L()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Se,gt,"auto","initial","none",se]}],grow:[{grow:["",Se,le,se]}],shrink:[{shrink:["",Se,le,se]}],order:[{order:[ht,"first","last","none",le,se]}],"grid-cols":[{"grid-cols":H()}],"col-start-end":[{col:O()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":H()}],"row-start-end":[{row:O()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:L()}],"gap-x":[{"gap-x":L()}],"gap-y":[{"gap-y":L()}],"justify-content":[{justify:[...V(),"normal"]}],"justify-items":[{"justify-items":[...W(),"normal"]}],"justify-self":[{"justify-self":["auto",...W()]}],"align-content":[{content:["normal",...V()]}],"align-items":[{items:[...W(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...W(),{baseline:["","last"]}]}],"place-content":[{"place-content":V()}],"place-items":[{"place-items":[...W(),"baseline"]}],"place-self":[{"place-self":["auto",...W()]}],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:Z()}],mx:[{mx:Z()}],my:[{my:Z()}],ms:[{ms:Z()}],me:[{me:Z()}],mbs:[{mbs:Z()}],mbe:[{mbe:Z()}],mt:[{mt:Z()}],mr:[{mr:Z()}],mb:[{mb:Z()}],ml:[{ml:Z()}],"space-x":[{"space-x":L()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":L()}],"space-y-reverse":["space-y-reverse"],size:[{size:de()}],"inline-size":[{inline:["auto",...T()]}],"min-inline-size":[{"min-inline":["auto",...T()]}],"max-inline-size":[{"max-inline":["none",...T()]}],"block-size":[{block:["auto",...J()]}],"min-block-size":[{"min-block":["auto",...J()]}],"max-block-size":[{"max-block":["none",...J()]}],w:[{w:[i,"screen",...de()]}],"min-w":[{"min-w":[i,"screen","none",...de()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...de()]}],h:[{h:["screen","lh",...de()]}],"min-h":[{"min-h":["screen","lh","none",...de()]}],"max-h":[{"max-h":["screen","lh",...de()]}],"font-size":[{text:["base",n,Jt,Ct]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,Zd,Wd]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",tn,se]}],"font-family":[{font:[Kd,Vd,r]}],"font-features":[{"font-features":[se]}],"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,le,se]}],"line-clamp":[{"line-clamp":[Se,"none",le,ga]}],leading:[{leading:[s,...L()]}],"list-image":[{"list-image":["none",le,se]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",le,se]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:A()}],"text-color":[{text:A()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...z(),"wavy"]}],"text-decoration-thickness":[{decoration:[Se,"from-font","auto",le,Ct]}],"text-decoration-color":[{decoration:A()}],"underline-offset":[{"underline-offset":[Se,"auto",le,se]}],"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:[ht,le,se]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",le,se]}],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",le,se]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:Y()}],"bg-repeat":[{bg:F()}],"bg-size":[{bg:I()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},ht,le,se],radial:["",le,se],conic:[ht,le,se]},Yd,qd]}],"bg-color":[{bg:A()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:A()}],"gradient-via":[{via:A()}],"gradient-to":[{to:A()}],rounded:[{rounded:D()}],"rounded-s":[{"rounded-s":D()}],"rounded-e":[{"rounded-e":D()}],"rounded-t":[{"rounded-t":D()}],"rounded-r":[{"rounded-r":D()}],"rounded-b":[{"rounded-b":D()}],"rounded-l":[{"rounded-l":D()}],"rounded-ss":[{"rounded-ss":D()}],"rounded-se":[{"rounded-se":D()}],"rounded-ee":[{"rounded-ee":D()}],"rounded-es":[{"rounded-es":D()}],"rounded-tl":[{"rounded-tl":D()}],"rounded-tr":[{"rounded-tr":D()}],"rounded-br":[{"rounded-br":D()}],"rounded-bl":[{"rounded-bl":D()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":P()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...z(),"hidden","none"]}],"divide-style":[{divide:[...z(),"hidden","none"]}],"border-color":[{border:A()}],"border-color-x":[{"border-x":A()}],"border-color-y":[{"border-y":A()}],"border-color-s":[{"border-s":A()}],"border-color-e":[{"border-e":A()}],"border-color-bs":[{"border-bs":A()}],"border-color-be":[{"border-be":A()}],"border-color-t":[{"border-t":A()}],"border-color-r":[{"border-r":A()}],"border-color-b":[{"border-b":A()}],"border-color-l":[{"border-l":A()}],"divide-color":[{divide:A()}],"outline-style":[{outline:[...z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Se,le,se]}],"outline-w":[{outline:["",Se,Jt,Ct]}],"outline-color":[{outline:A()}],shadow:[{shadow:["","none",u,xr,gr]}],"shadow-color":[{shadow:A()}],"inset-shadow":[{"inset-shadow":["none",p,xr,gr]}],"inset-shadow-color":[{"inset-shadow":A()}],"ring-w":[{ring:P()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:A()}],"ring-offset-w":[{"ring-offset":[Se,Ct]}],"ring-offset-color":[{"ring-offset":A()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":A()}],"text-shadow":[{"text-shadow":["none",m,xr,gr]}],"text-shadow-color":[{"text-shadow":A()}],opacity:[{opacity:[Se,le,se]}],"mix-blend":[{"mix-blend":[...X(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":X()}],"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":[Se]}],"mask-image-linear-from-pos":[{"mask-linear-from":_()}],"mask-image-linear-to-pos":[{"mask-linear-to":_()}],"mask-image-linear-from-color":[{"mask-linear-from":A()}],"mask-image-linear-to-color":[{"mask-linear-to":A()}],"mask-image-t-from-pos":[{"mask-t-from":_()}],"mask-image-t-to-pos":[{"mask-t-to":_()}],"mask-image-t-from-color":[{"mask-t-from":A()}],"mask-image-t-to-color":[{"mask-t-to":A()}],"mask-image-r-from-pos":[{"mask-r-from":_()}],"mask-image-r-to-pos":[{"mask-r-to":_()}],"mask-image-r-from-color":[{"mask-r-from":A()}],"mask-image-r-to-color":[{"mask-r-to":A()}],"mask-image-b-from-pos":[{"mask-b-from":_()}],"mask-image-b-to-pos":[{"mask-b-to":_()}],"mask-image-b-from-color":[{"mask-b-from":A()}],"mask-image-b-to-color":[{"mask-b-to":A()}],"mask-image-l-from-pos":[{"mask-l-from":_()}],"mask-image-l-to-pos":[{"mask-l-to":_()}],"mask-image-l-from-color":[{"mask-l-from":A()}],"mask-image-l-to-color":[{"mask-l-to":A()}],"mask-image-x-from-pos":[{"mask-x-from":_()}],"mask-image-x-to-pos":[{"mask-x-to":_()}],"mask-image-x-from-color":[{"mask-x-from":A()}],"mask-image-x-to-color":[{"mask-x-to":A()}],"mask-image-y-from-pos":[{"mask-y-from":_()}],"mask-image-y-to-pos":[{"mask-y-to":_()}],"mask-image-y-from-color":[{"mask-y-from":A()}],"mask-image-y-to-color":[{"mask-y-to":A()}],"mask-image-radial":[{"mask-radial":[le,se]}],"mask-image-radial-from-pos":[{"mask-radial-from":_()}],"mask-image-radial-to-pos":[{"mask-radial-to":_()}],"mask-image-radial-from-color":[{"mask-radial-from":A()}],"mask-image-radial-to-color":[{"mask-radial-to":A()}],"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":[Se]}],"mask-image-conic-from-pos":[{"mask-conic-from":_()}],"mask-image-conic-to-pos":[{"mask-conic-to":_()}],"mask-image-conic-from-color":[{"mask-conic-from":A()}],"mask-image-conic-to-color":[{"mask-conic-to":A()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:F()}],"mask-size":[{mask:I()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",le,se]}],filter:[{filter:["","none",le,se]}],blur:[{blur:q()}],brightness:[{brightness:[Se,le,se]}],contrast:[{contrast:[Se,le,se]}],"drop-shadow":[{"drop-shadow":["","none",f,xr,gr]}],"drop-shadow-color":[{"drop-shadow":A()}],grayscale:[{grayscale:["",Se,le,se]}],"hue-rotate":[{"hue-rotate":[Se,le,se]}],invert:[{invert:["",Se,le,se]}],saturate:[{saturate:[Se,le,se]}],sepia:[{sepia:["",Se,le,se]}],"backdrop-filter":[{"backdrop-filter":["","none",le,se]}],"backdrop-blur":[{"backdrop-blur":q()}],"backdrop-brightness":[{"backdrop-brightness":[Se,le,se]}],"backdrop-contrast":[{"backdrop-contrast":[Se,le,se]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Se,le,se]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Se,le,se]}],"backdrop-invert":[{"backdrop-invert":["",Se,le,se]}],"backdrop-opacity":[{"backdrop-opacity":[Se,le,se]}],"backdrop-saturate":[{"backdrop-saturate":[Se,le,se]}],"backdrop-sepia":[{"backdrop-sepia":["",Se,le,se]}],"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",le,se]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Se,"initial",le,se]}],ease:[{ease:["linear","initial",b,le,se]}],delay:[{delay:[Se,le,se]}],animate:[{animate:["none",y,le,se]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[x,le,se]}],"perspective-origin":[{"perspective-origin":N()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:ee()}],"skew-x":[{"skew-x":ee()}],"skew-y":[{"skew-y":ee()}],transform:[{transform:[le,se,"","none","gpu","cpu"]}],"transform-origin":[{origin:N()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:ie()}],"translate-x":[{"translate-x":ie()}],"translate-y":[{"translate-y":ie()}],"translate-z":[{"translate-z":ie()}],"translate-none":["translate-none"],zoom:[{zoom:[ht,le,se]}],accent:[{accent:A()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:A()}],"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",le,se]}],"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":A()}],"scrollbar-track-color":[{"scrollbar-track":A()}],"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",le,se]}],fill:[{fill:["none",...A()]}],"stroke-w":[{stroke:[Se,Jt,Ct,ga]}],stroke:[{stroke:["none",...A()]}],"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"]}},ec=Id(Qd),va=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,ka=Ts,dr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return ka(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],p=s==null?void 0:s[h];if(u===null)return null;const m=va(u)||va(p);return o[h][m]}),i=n&&Object.entries(n).reduce((h,u)=>{let[p,m]=u;return m===void 0||(h[p]=m),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:p,className:m,...f}=u;return Object.entries(f).every(g=>{let[x,k]=g;return Array.isArray(k)?k.includes({...s,...i}[x]):{...s,...i}[x]===k})?[...h,p,m]:h},[]);return ka(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},_r=c.createContext(null);_r.displayName="PanelGroupContext";const Be={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"},Gn=10,It=c.useLayoutEffect,wa=Yi.useId,tc=typeof wa=="function"?wa:()=>null;let rc=0;function Fn(e=null){const r=tc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+rc++),e??n.current}function Hs({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:p,order:m,style:f,tagName:g="div",...x}){const k=c.useContext(_r);if(k===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:y,getPanelSize:w,getPanelStyle:v,groupId:N,isPanelCollapsed:j,reevaluatePanelConstraints:S,registerPanel:L,resizePanel:C,unregisterPanel:H}=k,O=Fn(l),M=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:p},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:O,idIsFromProps:l!==void 0,order:m});c.useRef({didLogMissingDefaultSizeWarning:!1}),It(()=>{const{callbacks:V,constraints:W}=M.current,Z={...W};M.current.id=O,M.current.idIsFromProps=l!==void 0,M.current.order=m,V.onCollapse=h,V.onExpand=u,V.onResize=p,W.collapsedSize=n,W.collapsible=a,W.defaultSize=o,W.maxSize=i,W.minSize=d,(Z.collapsedSize!==W.collapsedSize||Z.collapsible!==W.collapsible||Z.maxSize!==W.maxSize||Z.minSize!==W.minSize)&&S(M.current,Z)}),It(()=>{const V=M.current;return L(V),()=>{H(V)}},[m,O,L,H]),c.useImperativeHandle(s,()=>({collapse:()=>{b(M.current)},expand:V=>{y(M.current,V)},getId(){return O},getSize(){return w(M.current)},isCollapsed(){return j(M.current)},isExpanded(){return!j(M.current)},resize:V=>{C(M.current,V)}}),[b,y,w,j,O,C]);const Q=v(M.current,o);return c.createElement(g,{...x,children:e,className:r,id:O,style:{...Q,...f},[Be.groupId]:N,[Be.panel]:"",[Be.panelCollapsible]:a||void 0,[Be.panelId]:O,[Be.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const Os=c.forwardRef((e,r)=>c.createElement(Hs,{...e,forwardedRef:r}));Hs.displayName="Panel";Os.displayName="forwardRef(Panel)";let yn=null,jr=-1,bt=null;function nc(e,r,n){const a=(r&Ks)!==0,o=(r&Xs)!==0,s=(r&Ys)!==0,l=(r&Zs)!==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 ac(){bt!==null&&(document.head.removeChild(bt),yn=null,bt=null,jr=-1)}function rn(e,r,n){var a,o;const s=nc(e,r);if(yn!==s){if(yn=s,bt===null&&(bt=document.createElement("style"),document.head.appendChild(bt)),jr>=0){var l;(l=bt.sheet)===null||l===void 0||l.removeRule(jr)}jr=(a=(o=bt.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function Us(e){return e.type==="keydown"}function Ws(e){return e.type.startsWith("pointer")}function Vs(e){return e.type.startsWith("mouse")}function $r(e){if(Ws(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(Vs(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 oc(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 lc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Na(e),b:Na(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ce(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:ja(ya(n.a)),b:ja(ya(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 ic=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dc(e){var r;const n=getComputedStyle((r=qs(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function cc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||dc(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"||ic.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function ya(e){let r=e.length;for(;r--;){const n=e[r];if(Ce(n,"Missing node"),cc(n))return n}return null}function ja(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Na(e){const r=[];for(;e;)r.push(e),e=qs(e);return r}function qs(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const Ks=1,Xs=2,Ys=4,Zs=8,hc=sc()==="coarse";let ct=[],Vt=!1,vt=new Map,Dr=new Map;const or=new Set;function uc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=vt.get(l))!==null&&s!==void 0?s:0;return vt.set(l,d+1),or.add(i),Lr(),function(){var u;Dr.delete(e),or.delete(i);const p=(u=vt.get(l))!==null&&u!==void 0?u:1;if(vt.set(l,p-1),Lr(),p===1&&vt.delete(l),ct.includes(i)){const m=ct.indexOf(i);m>=0&&ct.splice(m,1),Br(),o("up",!0,null)}}}function mc(e){const{target:r}=e,{x:n,y:a}=$r(e);Vt=!0,Hn({target:r,x:n,y:a}),Lr(),ct.length>0&&(Pr("down",e),Br(),e.preventDefault(),Js(r)||e.stopImmediatePropagation())}function nn(e){const{x:r,y:n}=$r(e);if(Vt&&e.type!=="pointerleave"&&e.buttons===0&&(Vt=!1,Pr("up",e)),!Vt){const{target:a}=e;Hn({target:a,x:r,y:n})}Pr("move",e),Br(),ct.length>0&&e.preventDefault()}function an(e){const{target:r}=e,{x:n,y:a}=$r(e);Dr.clear(),Vt=!1,ct.length>0&&(e.preventDefault(),Js(r)||e.stopImmediatePropagation()),Pr("up",e),Hn({target:r,x:n,y:a}),Br(),Lr()}function Js(e){let r=e;for(;r;){if(r.hasAttribute(Be.resizeHandle))return!0;r=r.parentElement}return!1}function Hn({target:e,x:r,y:n}){ct.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),or.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:p}=i,m=hc?l.coarse:l.fine;if(r>=h-m&&r<=u+m&&n>=p-m&&n<=d+m){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&lc(a,s)>0){let g=a,x=!1;for(;g&&!g.contains(s);){if(oc(g.getBoundingClientRect(),i)){x=!0;break}g=g.parentElement}if(x)return}ct.push(o)}})}function sn(e,r){Dr.set(e,r)}function Br(){let e=!1,r=!1;ct.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Dr.forEach(a=>{n|=a}),e&&r?rn("intersection",n):e?rn("horizontal",n):r?rn("vertical",n):ac()}let on;function Lr(){var e;(e=on)===null||e===void 0||e.abort(),on=new AbortController;const r={capture:!0,signal:on.signal};or.size&&(Vt?(ct.length>0&&vt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",an,r),o.addEventListener("pointerleave",nn,r),o.addEventListener("pointermove",nn,r))}),vt.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",an,r),o.addEventListener("pointercancel",an,r)})):vt.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",mc,r),o.addEventListener("pointermove",nn,r))}))}function Pr(e,r){or.forEach(n=>{const{setResizeHandlerState:a}=n,o=ct.includes(n);a(e,o,r)})}function pc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ce(e,r){if(!e)throw console.error(r),Error(r)}function At(e,r,n=Gn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function ft(e,r,n=Gn){return At(e,r,n)===0}function at(e,r,n){return At(e,r,n)===0}function fc(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(!at(o,s,n))return!1}return!0}function Wt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ce(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(At(n,i)<0)if(s){const d=(o+i)/2;At(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(Gn)),n}function rr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(at(e,0))return r;const l=[...r],[i,d]=a;Ce(i!=null,"Invalid first pivot index"),Ce(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const p=e<0?d:i,m=n[p];Ce(m,`Panel constraints not found for index ${p}`);const{collapsedSize:f=0,collapsible:g,minSize:x=0}=m;if(g){const k=r[p];if(Ce(k!=null,`Previous layout not found for panel index ${p}`),at(k,f)){const b=x-k;At(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}{const p=e<0?i:d,m=n[p];Ce(m,`No panel constraints found for index ${p}`);const{collapsedSize:f=0,collapsible:g,minSize:x=0}=m;if(g){const k=r[p];if(Ce(k!=null,`Previous layout not found for panel index ${p}`),at(k,x)){const b=k-f;At(b,Math.abs(e))>0&&(e=e<0?0-b:b)}}}}{const p=e<0?1:-1;let m=e<0?d:i,f=0;for(;;){const x=r[m];Ce(x!=null,`Previous layout not found for panel index ${m}`);const b=Wt({panelConstraints:n,panelIndex:m,size:100})-x;if(f+=b,m+=p,m<0||m>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(f));e=e<0?0-g:g}{let m=e<0?i:d;for(;m>=0&&m<n.length;){const f=Math.abs(e)-Math.abs(h),g=r[m];Ce(g!=null,`Previous layout not found for panel index ${m}`);const x=g-f,k=Wt({panelConstraints:n,panelIndex:m,size:x});if(!at(g,k)&&(h+=g-k,l[m]=k,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(fc(o,l))return o;{const p=e<0?d:i,m=r[p];Ce(m!=null,`Previous layout not found for panel index ${p}`);const f=m+h,g=Wt({panelConstraints:n,panelIndex:p,size:f});if(l[p]=g,!at(g,f)){let x=f-g,b=e<0?d:i;for(;b>=0&&b<n.length;){const y=l[b];Ce(y!=null,`Previous layout not found for panel index ${b}`);const w=y+x,v=Wt({panelConstraints:n,panelIndex:b,size:w});if(at(y,v)||(x-=v-y,l[b]=v),at(x,0))break;e>0?b--:b++}}}const u=l.reduce((p,m)=>m+p,0);return at(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];Ce(i!=null,"No pivot index found"),r.forEach((p,m)=>{const{constraints:f}=p,{maxSize:g=100,minSize:x=0}=f;m===i?(a=x,o=g):(s+=x,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 lr(e,r=document){return Array.from(r.querySelectorAll(`[${Be.resizeHandleId}][data-panel-group-id="${e}"]`))}function Qs(e,r,n=document){const o=lr(e,n).findIndex(s=>s.getAttribute(Be.resizeHandleId)===r);return o??null}function eo(e,r,n){const a=Qs(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function xc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function to(e,r=document){if(xc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Gr(e,r=document){const n=r.querySelector(`[${Be.resizeHandleId}="${e}"]`);return n||null}function bc(e,r,n,a=document){var o,s,l,i;const d=Gr(r,a),h=lr(e,a),u=d?h.indexOf(d):-1,p=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,m=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[p,m]}function vc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),It(()=>{if(!s)return;const i=lr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:p}=gc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),m=i[d];if(m!=null){const f=o[d];Ce(f,`No panel data found for index "${d}"`),m.setAttribute("aria-controls",f.id),m.setAttribute("aria-valuemax",""+Math.round(h)),m.setAttribute("aria-valuemin",""+Math.round(u)),m.setAttribute("aria-valuenow",p!=null?""+Math.round(p):"")}}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;Ce(i,"Eager values not found");const{panelDataArray:d}=i,h=to(n,s);Ce(h!=null,`No group found for id "${n}"`);const u=lr(n,s);Ce(u,`No resize handles found for group id "${n}"`);const p=u.map(m=>{const f=m.getAttribute(Be.resizeHandleId);Ce(f,"Resize handle element has no handle id attribute");const[g,x]=bc(n,f,d,s);if(g==null||x==null)return()=>{};const k=b=>{if(!b.defaultPrevented)switch(b.key){case"Enter":{b.preventDefault();const y=d.findIndex(w=>w.id===g);if(y>=0){const w=d[y];Ce(w,`No panel data found for index ${y}`);const v=a[y],{collapsedSize:N=0,collapsible:j,minSize:S=0}=w.constraints;if(v!=null&&j){const L=rr({delta:at(v,N)?S-N:N-v,initialLayout:a,panelConstraints:d.map(C=>C.constraints),pivotIndices:eo(n,f,s),prevLayout:a,trigger:"keyboard"});a!==L&&l(L)}}break}}};return m.addEventListener("keydown",k),()=>{m.removeEventListener("keydown",k)}});return()=>{p.forEach(m=>m())}},[s,e,r,n,a,o,l])}function Ca(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 ro(e,r){const n=e==="horizontal",{x:a,y:o}=$r(r);return n?a:o}function kc(e,r,n,a,o){const s=n==="horizontal",l=Gr(r,o);Ce(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Be.groupId);Ce(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=ro(n,e),u=to(i,o);Ce(u,`No group element found for id "${i}"`);const p=u.getBoundingClientRect(),m=s?p.width:p.height;return(h-d)/m*100}function wc(e,r,n,a,o,s){if(Us(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:kc(e,r,n,a,s)}function yc({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];Ce(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];Ce(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 Ft(e,r,n){r.forEach((a,o)=>{const s=e[o];Ce(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{collapsedSize:h=0,collapsible:u}=i,p=n[d];if(p==null||a!==p){n[d]=a;const{onCollapse:m,onExpand:f,onResize:g}=l;g&&g(a,p),u&&(m||f)&&(f&&(p==null||ft(p,h))&&!ft(a,h)&&f(),m&&(p==null||!ft(p,h))&&ft(a,h)&&m())}})}function br(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 jc({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 Nc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function Sa(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 no(e){return`react-resizable-panels:${e}`}function ao(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 so(e,r){try{const n=no(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Cc(e,r,n){var a,o;const s=(a=so(e,n))!==null&&a!==void 0?a:{},l=ao(r);return(o=s[l])!==null&&o!==void 0?o:null}function Sc(e,r,n,a,o){var s;const l=no(e),i=ao(r),d=(s=so(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 Ta({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(!at(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Ce(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];Ce(l!=null,`No layout data found for index ${s}`);const i=Wt({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!at(o,0))for(let s=0;s<r.length;s++){const l=n[s];Ce(l!=null,`No layout data found for index ${s}`);const i=l+o,d=Wt({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,at(o,0)))break}return n}const Tc=100,nr={getItem:e=>(Sa(nr),nr.getItem(e)),setItem:(e,r)=>{Sa(nr),nr.setItem(e,r)}},Ea={};function oo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=nr,style:h,tagName:u="div",...p}){const m=Fn(s),f=c.useRef(null),[g,x]=c.useState(null),[k,b]=c.useState([]),y=pc(),w=c.useRef({}),v=c.useRef(new Map),N=c.useRef(0),j=c.useRef({autoSaveId:e,direction:a,dragState:g,id:m,keyboardResizeBy:i,onLayout:l,storage:d}),S=c.useRef({layout:k,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>j.current.id,getLayout:()=>{const{layout:I}=S.current;return I},setLayout:I=>{const{onLayout:K}=j.current,{layout:D,panelDataArray:P}=S.current,z=Ta({layout:I,panelConstraints:P.map(X=>X.constraints)});Ca(D,z)||(b(z),S.current.layout=z,K&&K(z),Ft(P,z,w.current))}}),[]),It(()=>{j.current.autoSaveId=e,j.current.direction=a,j.current.dragState=g,j.current.id=m,j.current.onLayout=l,j.current.storage=d}),vc({committedValuesRef:j,eagerValuesRef:S,groupId:m,layout:k,panelDataArray:S.current.panelDataArray,setLayout:b,panelGroupElement:f.current}),c.useEffect(()=>{const{panelDataArray:I}=S.current;if(e){if(k.length===0||k.length!==I.length)return;let K=Ea[e];K==null&&(K=Nc(Sc,Tc),Ea[e]=K);const D=[...I],P=new Map(v.current);K(e,D,P,k,d)}},[e,k,d]),c.useEffect(()=>{});const L=c.useCallback(I=>{const{onLayout:K}=j.current,{layout:D,panelDataArray:P}=S.current;if(I.constraints.collapsible){const z=P.map(G=>G.constraints),{collapsedSize:X=0,panelSize:_,pivotIndices:q}=St(P,I,D);if(Ce(_!=null,`Panel size not found for panel "${I.id}"`),!ft(_,X)){v.current.set(I.id,_);const ce=Ot(P,I)===P.length-1?_-X:X-_,ee=rr({delta:ce,initialLayout:D,panelConstraints:z,pivotIndices:q,prevLayout:D,trigger:"imperative-api"});br(D,ee)||(b(ee),S.current.layout=ee,K&&K(ee),Ft(P,ee,w.current))}}},[]),C=c.useCallback((I,K)=>{const{onLayout:D}=j.current,{layout:P,panelDataArray:z}=S.current;if(I.constraints.collapsible){const X=z.map(ie=>ie.constraints),{collapsedSize:_=0,panelSize:q=0,minSize:G=0,pivotIndices:ce}=St(z,I,P),ee=K??G;if(ft(q,_)){const ie=v.current.get(I.id),ue=ie!=null&&ie>=ee?ie:ee,Le=Ot(z,I)===z.length-1?q-ue:ue-q,re=rr({delta:Le,initialLayout:P,panelConstraints:X,pivotIndices:ce,prevLayout:P,trigger:"imperative-api"});br(P,re)||(b(re),S.current.layout=re,D&&D(re),Ft(z,re,w.current))}}},[]),H=c.useCallback(I=>{const{layout:K,panelDataArray:D}=S.current,{panelSize:P}=St(D,I,K);return Ce(P!=null,`Panel size not found for panel "${I.id}"`),P},[]),O=c.useCallback((I,K)=>{const{panelDataArray:D}=S.current,P=Ot(D,I);return jc({defaultSize:K,dragState:g,layout:k,panelData:D,panelIndex:P})},[g,k]),M=c.useCallback(I=>{const{layout:K,panelDataArray:D}=S.current,{collapsedSize:P=0,collapsible:z,panelSize:X}=St(D,I,K);return Ce(X!=null,`Panel size not found for panel "${I.id}"`),z===!0&&ft(X,P)},[]),Q=c.useCallback(I=>{const{layout:K,panelDataArray:D}=S.current,{collapsedSize:P=0,collapsible:z,panelSize:X}=St(D,I,K);return Ce(X!=null,`Panel size not found for panel "${I.id}"`),!z||At(X,P)>0},[]),V=c.useCallback(I=>{const{panelDataArray:K}=S.current;K.push(I),K.sort((D,P)=>{const z=D.order,X=P.order;return z==null&&X==null?0:z==null?-1:X==null?1:z-X}),S.current.panelDataArrayChanged=!0,y()},[y]);It(()=>{if(S.current.panelDataArrayChanged){S.current.panelDataArrayChanged=!1;const{autoSaveId:I,onLayout:K,storage:D}=j.current,{layout:P,panelDataArray:z}=S.current;let X=null;if(I){const q=Cc(I,z,D);q&&(v.current=new Map(Object.entries(q.expandToSizes)),X=q.layout)}X==null&&(X=yc({panelDataArray:z}));const _=Ta({layout:X,panelConstraints:z.map(q=>q.constraints)});Ca(P,_)||(b(_),S.current.layout=_,K&&K(_),Ft(z,_,w.current))}}),It(()=>{const I=S.current;return()=>{I.layout=[]}},[]);const W=c.useCallback(I=>{let K=!1;const D=f.current;return D&&window.getComputedStyle(D,null).getPropertyValue("direction")==="rtl"&&(K=!0),function(z){z.preventDefault();const X=f.current;if(!X)return()=>null;const{direction:_,dragState:q,id:G,keyboardResizeBy:ce,onLayout:ee}=j.current,{layout:ie,panelDataArray:ue}=S.current,{initialLayout:ge}=q??{},Le=eo(G,I,X);let re=wc(z,I,_,q,ce,X);const be=_==="horizontal";be&&K&&(re=-re);const je=ue.map(R=>R.constraints),xe=rr({delta:re,initialLayout:ge??ie,panelConstraints:je,pivotIndices:Le,prevLayout:ie,trigger:Us(z)?"keyboard":"mouse-or-touch"}),ze=!br(ie,xe);(Ws(z)||Vs(z))&&N.current!=re&&(N.current=re,!ze&&re!==0?be?sn(I,re<0?Ks:Xs):sn(I,re<0?Ys:Zs):sn(I,0)),ze&&(b(xe),S.current.layout=xe,ee&&ee(xe),Ft(ue,xe,w.current))}},[]),Z=c.useCallback((I,K)=>{const{onLayout:D}=j.current,{layout:P,panelDataArray:z}=S.current,X=z.map(ie=>ie.constraints),{panelSize:_,pivotIndices:q}=St(z,I,P);Ce(_!=null,`Panel size not found for panel "${I.id}"`);const ce=Ot(z,I)===z.length-1?_-K:K-_,ee=rr({delta:ce,initialLayout:P,panelConstraints:X,pivotIndices:q,prevLayout:P,trigger:"imperative-api"});br(P,ee)||(b(ee),S.current.layout=ee,D&&D(ee),Ft(z,ee,w.current))},[]),de=c.useCallback((I,K)=>{const{layout:D,panelDataArray:P}=S.current,{collapsedSize:z=0,collapsible:X}=K,{collapsedSize:_=0,collapsible:q,maxSize:G=100,minSize:ce=0}=I.constraints,{panelSize:ee}=St(P,I,D);ee!=null&&(X&&q&&ft(ee,z)?ft(z,_)||Z(I,_):ee<ce?Z(I,ce):ee>G&&Z(I,G))},[Z]),T=c.useCallback((I,K)=>{const{direction:D}=j.current,{layout:P}=S.current;if(!f.current)return;const z=Gr(I,f.current);Ce(z,`Drag handle element not found for id "${I}"`);const X=ro(D,K);x({dragHandleId:I,dragHandleRect:z.getBoundingClientRect(),initialCursorPosition:X,initialLayout:P})},[]),J=c.useCallback(()=>{x(null)},[]),A=c.useCallback(I=>{const{panelDataArray:K}=S.current,D=Ot(K,I);D>=0&&(K.splice(D,1),delete w.current[I.id],S.current.panelDataArrayChanged=!0,y())},[y]),Y=c.useMemo(()=>({collapsePanel:L,direction:a,dragState:g,expandPanel:C,getPanelSize:H,getPanelStyle:O,groupId:m,isPanelCollapsed:M,isPanelExpanded:Q,reevaluatePanelConstraints:de,registerPanel:V,registerResizeHandle:W,resizePanel:Z,startDragging:T,stopDragging:J,unregisterPanel:A,panelGroupElement:f.current}),[L,g,a,C,H,O,m,M,Q,de,V,W,Z,T,J,A]),F={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(_r.Provider,{value:Y},c.createElement(u,{...p,children:r,className:n,id:s,ref:f,style:{...F,...h},[Be.group]:"",[Be.groupDirection]:a,[Be.groupId]:m}))}const lo=c.forwardRef((e,r)=>c.createElement(oo,{...e,forwardedRef:r}));oo.displayName="PanelGroup";lo.displayName="forwardRef(PanelGroup)";function Ot(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function St(e,r,n){const a=Ot(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Ec({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=Gr(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(Be.groupId);Ce(i,`No group element found for id "${i}"`);const d=lr(i,a),h=Qs(i,r,a);Ce(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 io({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:p={},tabIndex:m=0,tagName:f="div",...g}){var x,k;const b=c.useRef(null),y=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{y.current.onClick=l,y.current.onDragging=i,y.current.onPointerDown=h,y.current.onPointerUp=u});const w=c.useContext(_r);if(w===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:v,groupId:N,registerResizeHandle:j,startDragging:S,stopDragging:L,panelGroupElement:C}=w,H=Fn(o),[O,M]=c.useState("inactive"),[Q,V]=c.useState(!1),[W,Z]=c.useState(null),de=c.useRef({state:O});It(()=>{de.current.state=O}),c.useEffect(()=>{if(n)Z(null);else{const Y=j(H);Z(()=>Y)}},[n,H,j]);const T=(x=a==null?void 0:a.coarse)!==null&&x!==void 0?x:15,J=(k=a==null?void 0:a.fine)!==null&&k!==void 0?k:5;c.useEffect(()=>{if(n||W==null)return;const Y=b.current;Ce(Y,"Element ref not attached");let F=!1;return uc(H,Y,v,{coarse:T,fine:J},(K,D,P)=>{if(!D){M("inactive");return}switch(K){case"down":{M("drag"),F=!1,Ce(P,'Expected event to be defined for "down" action'),S(H,P);const{onDragging:z,onPointerDown:X}=y.current;z==null||z(!0),X==null||X();break}case"move":{const{state:z}=de.current;F=!0,z!=="drag"&&M("hover"),Ce(P,'Expected event to be defined for "move" action'),W(P);break}case"up":{M("hover"),L();const{onClick:z,onDragging:X,onPointerUp:_}=y.current;X==null||X(!1),_==null||_(),F||z==null||z();break}}})},[T,v,n,J,j,H,W,S,L]),Ec({disabled:n,handleId:H,resizeHandler:W,panelGroupElement:C});const A={touchAction:"none",userSelect:"none"};return c.createElement(f,{...g,children:e,className:r,id:o,onBlur:()=>{V(!1),s==null||s()},onFocus:()=>{V(!0),d==null||d()},ref:b,role:"separator",style:{...A,...p},tabIndex:m,[Be.groupDirection]:v,[Be.groupId]:N,[Be.resizeHandle]:"",[Be.resizeHandleActive]:O==="drag"?"pointer":Q?"keyboard":void 0,[Be.resizeHandleEnabled]:!n,[Be.resizeHandleId]:H,[Be.resizeHandleState]:O})}io.displayName="PanelResizeHandle";var Lc=Object.defineProperty,Pc=Object.getOwnPropertyNames,Me=(e,r)=>function(){return e&&(r=(0,e[Pc(e)[0]])(e=0)),r},Ic=(e,r)=>{for(var n in r)Lc(e,n,{get:r[n],enumerable:!0})};function Qe(...e){return ec(Ts(e))}var yt=Me({"src/components/graph-ui/utils.ts"(){}});function ir({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?js:"button";return t.jsx(s,{"data-slot":"button",className:Qe(co({variant:a,size:n,className:r})),...o})}var co,Fr=Me({"src/components/graph-ui/Button.tsx"(){yt(),co=dr("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 ho(...e){return e.filter(Boolean).join(" ")}function uo({className:e,...r}){return t.jsx(lo,{"data-slot":"resizable-panel-group",className:ho("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function Ir({...e}){return t.jsx(Os,{"data-slot":"resizable-panel",...e})}function mo({withHandle:e,className:r,...n}){return t.jsx(io,{"data-slot":"resizable-handle",className:ho("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 po=Me({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function On(...e){return e.filter(Boolean).join(" ")}function cr({...e}){return t.jsx(Si,{"data-slot":"accordion",...e})}function hr({className:e,...r}){return t.jsx(Ti,{"data-slot":"accordion-item",className:On("border-b last:border-b-0",e),...r})}function ur({className:e,children:r,...n}){return t.jsx(Ei,{className:"flex",children:t.jsxs(Li,{"data-slot":"accordion-trigger",className:On("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 mr({className:e,children:r,...n}){return t.jsx(Pi,{"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:On("pb-4 pt-0",e),children:r})})}var pr=Me({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function zc(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 Rc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function fr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Ac(e){return e.split("/").filter(Boolean).at(-1)??e}function jn(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(jn);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 fo(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=fo(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function go(e){if(e.kind==="file")return e;for(const r of e.children){const n=go(r);if(n)return n}return null}function Nn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>Nn(n,r))}function Mc(e){if(!e)return null;const r=fr(e.path);return Un.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 _c(e){const r=fr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function $c(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 Dc(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;$c(e,a).children.push({...n,name:n.name||o,path:r})}function Bc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function xo(e){e.children.sort(Bc);for(const r of e.children)xo(r);return e}function La(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 p of r){const m=p.title||p.id,f=Rc(m)||p.id;s.children.push({id:`artifact:${p.id}`,name:`${f}.artifact`,path:`artifacts/${f}.artifact`,kind:"artifact",artifact:p,preview:p.summaryText??p.type,detail:JSON.stringify(p.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=(p,m,f=!1)=>{d+=1;const g=m.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),x=`${f?"live":`thread-events/${p}`}/${String(d).padStart(3,"0")}-${g}.json`,k="text"in m&&typeof m.text=="string"?m.text.slice(0,160):m.kind,b=m.kind==="artifact"&&m.artifact?m.artifact:null,y=b&&f?{id:`live-artifact:${b.id}`,name:b.title||b.id,path:x,kind:"live-artifact",artifact:b,item:m,preview:b.summaryText??b.type,detail:JSON.stringify(b.payload,null,2),children:[]}:{id:`event:${m.id}`,name:Ac(x),path:x,kind:"event",item:m,preview:k,detail:JSON.stringify(m,null,2),children:[]};if(f){i.children.push(y);return}Dc(l,x.replace(/^thread-events\//,""),y)};for(const p of e.turns)for(const m of p.items)(m.kind==="commandExecution"||m.kind==="webSearch"||m.kind==="fileRead"||m.kind==="fileChange"||m.kind==="agentToolCall"||m.kind==="skillToolCall"||m.kind==="toolCall"||m.kind==="hook"||m.kind==="plan"||m.kind==="reasoning")&&h(p.id,m);for(const p of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",p,!0);return o.children.push(s,l,i),xo(o)}function Gc(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 bo(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=bo(r);if(n)return n}return null}function Pa(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 Un,vo,ko,Wn=Me({"src/components/graph-workspace/workspaceTree.ts"(){Un=new Set(["xyz","extxyz","cif","pdb"]),vo=new Set(["png","jpg","jpeg","gif","webp","svg"]),ko=new Set(["pdf"])}});function Ut({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 wo=Me({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Fc({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(Ki,{"data-slot":"separator",decorative:r,orientation:n,className:Qe("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 Hc=Me({"src/components/graph-ui/Separator.tsx"(){yt()}});function Oc({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:Qe(yo({orientation:r}),e),...n})}function Uc({className:e,orientation:r="vertical",...n}){return t.jsx(Fc,{"data-slot":"button-group-separator",orientation:r,className:Qe("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var yo,jo=Me({"src/components/graph-ui/ButtonGroup.tsx"(){Hc(),yt(),yo=dr("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 Wc({delayDuration:e=0,...r}){return t.jsx(Xi,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function Vc({...e}){return t.jsx(Wc,{children:t.jsx(Oi,{"data-slot":"tooltip",...e})})}function qc({...e}){return t.jsx(Ui,{"data-slot":"tooltip-trigger",...e})}function Kc({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(Wi,{children:t.jsxs(Vi,{"data-slot":"tooltip-content",sideOffset:n,className:Qe("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(qi,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var Xc=Me({"src/components/graph-ui/Tooltip.tsx"(){yt()}});function Yc(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ia(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 Ue({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(Vc,{children:[t.jsx(qc,{asChild:!0,children:t.jsx(ir,{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(Kc,{children:t.jsx("p",{children:n})})]})}function Cn({children:e,className:r=""}){return t.jsx(Oc,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var No=Me({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Fr(),jo(),Xc()}});function Zc({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:p,unitCellVisible:m}){const f=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(Cn,{children:[t.jsx(Ue,{label:"Distance",children:t.jsx(_.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ue,{label:"Connectivity",children:t.jsx(_.Share2,{className:"size-4"})}),t.jsx(Ue,{label:"Angle",children:t.jsx(_.Waypoints,{className:"size-4"})}),t.jsx(Ue,{label:"Dihedral",children:t.jsx(_.Spline,{className:"size-4"})}),t.jsx(Ue,{label:"Add dummy atoms",children:t.jsx(_.Bubbles,{className:"size-4"})}),t.jsx(Ue,{label:"Delete atoms",children:t.jsx(_.CircleX,{className:"size-4"})}),t.jsx(Ue,{label:"Rotate",children:t.jsx(_.Rotate3d,{className:"size-4"})})]}),t.jsxs(Cn,{children:[t.jsx(Ue,{label:m?"Hide unit cell":"Show unit cell",disabled:!p,onClick:l,children:t.jsx(_.Boxes,{className:"size-4"})}),t.jsx(Ue,{label:"Clear selection",disabled:!f,onClick:r,children:t.jsx(_.Trash2,{className:"size-4"})}),t.jsx(Ue,{label:"Send selection",disabled:!f,onClick:a,children:t.jsx(_.Send,{className:"size-4"})}),t.jsx(Ue,{label:"Stage current selection",disabled:!f,onClick:s,children:t.jsx(_.Box,{className:"size-4"})}),t.jsx(Ue,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(_.Eraser,{className:"size-4"})}),t.jsx(Ue,{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(x=>`${i[x]??"Atom"}(${x})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Jc=Me({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){No()}});function Qc({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=Yc(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ia(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ia(r,`${i}_trajectory.${l||"xyz"}`)}function p(){o.current&&(o.current.zoom(1.2),o.current.render())}function m(){o.current&&(o.current.zoom(.8),o.current.render())}function f(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Cn,{className:"ml-auto justify-end",children:[t.jsx(Ue,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(_.Copy,{className:"size-3.5"})}),t.jsx(Ue,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(_.Download,{className:"size-3.5"})}),t.jsx(Ue,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(_.Box,{className:"size-3.5"})}),t.jsx(Ue,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(_.Camera,{className:"size-3.5"})}),t.jsx(Uc,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ue,{label:"Zoom in",onClick:p,disabled:!o.current||!s,children:t.jsx(_.ZoomIn,{className:"size-3.5"})}),t.jsx(Ue,{label:"Zoom out",onClick:m,disabled:!o.current||!s,children:t.jsx(_.ZoomOut,{className:"size-3.5"})}),t.jsx(Ue,{label:"Reset camera",onClick:f,disabled:!o.current||!s,children:t.jsx(_.RotateCcw,{className:"size-3.5"})})]})}var eh=Me({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){jo(),No()}});async function th(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Nr||(Nr=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)})),Nr)}var Nr,rh=Me({"src/components/graph-workspace/load3Dmol.ts"(){Nr=null}});function nh({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(Bi,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:Qe("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(Gi,{"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(Fi,{"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(Hi,{"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 ah=Me({"src/components/graph-ui/Slider.tsx"(){yt()}});function sh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function oh(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 _c(e){const r=fr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function $c(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 Dc(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;$c(e,a).children.push({...n,name:n.name||o,path:r})}function Bc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function xo(e){e.children.sort(Bc);for(const r of e.children)xo(r);return e}function La(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 p of r){const m=p.title||p.id,f=Rc(m)||p.id;s.children.push({id:`artifact:${p.id}`,name:`${f}.artifact`,path:`artifacts/${f}.artifact`,kind:"artifact",artifact:p,preview:p.summaryText??p.type,detail:JSON.stringify(p.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=(p,m,f=!1)=>{d+=1;const g=m.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),x=`${f?"live":`thread-events/${p}`}/${String(d).padStart(3,"0")}-${g}.json`,k="text"in m&&typeof m.text=="string"?m.text.slice(0,160):m.kind,b=m.kind==="artifact"&&m.artifact?m.artifact:null,y=b&&f?{id:`live-artifact:${b.id}`,name:b.title||b.id,path:x,kind:"live-artifact",artifact:b,item:m,preview:b.summaryText??b.type,detail:JSON.stringify(b.payload,null,2),children:[]}:{id:`event:${m.id}`,name:Ac(x),path:x,kind:"event",item:m,preview:k,detail:JSON.stringify(m,null,2),children:[]};if(f){i.children.push(y);return}Dc(l,x.replace(/^thread-events\//,""),y)};for(const p of e.turns)for(const m of p.items)(m.kind==="commandExecution"||m.kind==="webSearch"||m.kind==="fileRead"||m.kind==="fileChange"||m.kind==="agentToolCall"||m.kind==="skillToolCall"||m.kind==="toolCall"||m.kind==="hook"||m.kind==="plan"||m.kind==="reasoning")&&h(p.id,m);for(const p of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",p,!0);return o.children.push(s,l,i),xo(o)}function Gc(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 bo(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=bo(r);if(n)return n}return null}function Pa(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 Un,vo,ko,Wn=Me({"src/components/graph-workspace/workspaceTree.ts"(){Un=new Set(["xyz","extxyz","cif","pdb"]),vo=new Set(["png","jpg","jpeg","gif","webp","svg"]),ko=new Set(["pdf"])}});function Ut({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 wo=Me({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function Fc({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(Ki,{"data-slot":"separator",decorative:r,orientation:n,className:Qe("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 Hc=Me({"src/components/graph-ui/Separator.tsx"(){yt()}});function Oc({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:Qe(yo({orientation:r}),e),...n})}function Uc({className:e,orientation:r="vertical",...n}){return t.jsx(Fc,{"data-slot":"button-group-separator",orientation:r,className:Qe("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var yo,jo=Me({"src/components/graph-ui/ButtonGroup.tsx"(){Hc(),yt(),yo=dr("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 Wc({delayDuration:e=0,...r}){return t.jsx(Xi,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function Vc({...e}){return t.jsx(Wc,{children:t.jsx(Oi,{"data-slot":"tooltip",...e})})}function qc({...e}){return t.jsx(Ui,{"data-slot":"tooltip-trigger",...e})}function Kc({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(Wi,{children:t.jsxs(Vi,{"data-slot":"tooltip-content",sideOffset:n,className:Qe("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(qi,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var Xc=Me({"src/components/graph-ui/Tooltip.tsx"(){yt()}});function Yc(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ia(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 Ue({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(Vc,{children:[t.jsx(qc,{asChild:!0,children:t.jsx(ir,{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(Kc,{children:t.jsx("p",{children:n})})]})}function Cn({children:e,className:r=""}){return t.jsx(Oc,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var No=Me({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Fr(),jo(),Xc()}});function Zc({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:p,unitCellVisible:m}){const f=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(Cn,{children:[t.jsx(Ue,{label:"Distance",children:t.jsx($.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Ue,{label:"Connectivity",children:t.jsx($.Share2,{className:"size-4"})}),t.jsx(Ue,{label:"Angle",children:t.jsx($.Waypoints,{className:"size-4"})}),t.jsx(Ue,{label:"Dihedral",children:t.jsx($.Spline,{className:"size-4"})}),t.jsx(Ue,{label:"Add dummy atoms",children:t.jsx($.Bubbles,{className:"size-4"})}),t.jsx(Ue,{label:"Delete atoms",children:t.jsx($.CircleX,{className:"size-4"})}),t.jsx(Ue,{label:"Rotate",children:t.jsx($.Rotate3d,{className:"size-4"})})]}),t.jsxs(Cn,{children:[t.jsx(Ue,{label:m?"Hide unit cell":"Show unit cell",disabled:!p,onClick:l,children:t.jsx($.Boxes,{className:"size-4"})}),t.jsx(Ue,{label:"Clear selection",disabled:!f,onClick:r,children:t.jsx($.Trash2,{className:"size-4"})}),t.jsx(Ue,{label:"Send selection",disabled:!f,onClick:a,children:t.jsx($.Send,{className:"size-4"})}),t.jsx(Ue,{label:"Stage current selection",disabled:!f,onClick:s,children:t.jsx($.Box,{className:"size-4"})}),t.jsx(Ue,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx($.Eraser,{className:"size-4"})}),t.jsx(Ue,{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(x=>`${i[x]??"Atom"}(${x})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var Jc=Me({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){No()}});function Qc({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=Yc(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ia(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ia(r,`${i}_trajectory.${l||"xyz"}`)}function p(){o.current&&(o.current.zoom(1.2),o.current.render())}function m(){o.current&&(o.current.zoom(.8),o.current.render())}function f(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Cn,{className:"ml-auto justify-end",children:[t.jsx(Ue,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx($.Copy,{className:"size-3.5"})}),t.jsx(Ue,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx($.Download,{className:"size-3.5"})}),t.jsx(Ue,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx($.Box,{className:"size-3.5"})}),t.jsx(Ue,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx($.Camera,{className:"size-3.5"})}),t.jsx(Uc,{className:"thread-graph-molecule-button-divider"}),t.jsx(Ue,{label:"Zoom in",onClick:p,disabled:!o.current||!s,children:t.jsx($.ZoomIn,{className:"size-3.5"})}),t.jsx(Ue,{label:"Zoom out",onClick:m,disabled:!o.current||!s,children:t.jsx($.ZoomOut,{className:"size-3.5"})}),t.jsx(Ue,{label:"Reset camera",onClick:f,disabled:!o.current||!s,children:t.jsx($.RotateCcw,{className:"size-3.5"})})]})}var eh=Me({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){jo(),No()}});async function th(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(Nr||(Nr=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)})),Nr)}var Nr,rh=Me({"src/components/graph-workspace/load3Dmol.ts"(){Nr=null}});function nh({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(Bi,{"data-slot":"slider",...r!==void 0?{defaultValue:r}:{},...o!==void 0?{value:o}:{},min:a,max:n,className:Qe("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(Gi,{"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(Fi,{"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(Hi,{"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 ah=Me({"src/components/graph-ui/Slider.tsx"(){yt()}});function sh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function oh(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
9
  `),a+=i}return n.length>0?n:[e]}function za(e,r){return r!=="xyz"?e:e.flatMap(n=>oh(n))}function Ra(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=za([e],"xyz");return{frames:o,format:"xyz",exportContent:Ra(o)}}const r=sh(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:za(n,r),format:r,exportContent:Ra(n)}}var ih=Me({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function dh({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),[p,m]=c.useState(null),[f,g]=c.useState(0),[x,k]=c.useState(null),[b,y]=c.useState(!1),[w,v]=c.useState({}),[N,j]=c.useState([]),[S,P]=c.useState({}),[C,F]=c.useState(!1),[H,M]=c.useState(!1),[Q,V]=c.useState(null),W=c.useMemo(()=>lh(o),[o]),Z=W.frames,de=W.format,E=Z[f]??null,J=Z.length>0&&f===Z.length-1,A=r??"current",X=Object.values(S).reduce((T,z)=>T+z.length,0),O=Object.keys(S).length;c.useEffect(()=>{if(Z.length===0){g(0);return}g(Z.length-1)},[Z.length]),c.useEffect(()=>{if(!b||Z.length<=1)return;const T=window.setInterval(()=>{g(z=>z>=Z.length-1?(window.clearInterval(T),y(!1),z):z+1)},200);return()=>window.clearInterval(T)},[b,Z.length]),c.useEffect(()=>{const T=l.current;if(!T||i.current)return;let z=!1;try{const $=document.createElement("canvas");if(!($.getContext("webgl2")||$.getContext("webgl")||$.getContext("experimental-webgl"))){V("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{V("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const Y=()=>{var $,q;($=i.current)==null||$.resize(),(q=i.current)==null||q.render()};return th().then($=>{if(!(z||i.current))try{const q=$.createViewer(T,{});i.current=q,q.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",Y),window.setTimeout(Y,100)}catch(q){console.error("Failed to initialize 3Dmol viewer:",q),V("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch($=>{console.error("Failed to load 3Dmol viewer runtime:",$),V("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{z=!0,window.removeEventListener("resize",Y),i.current=null,d.current=null}},[]),c.useEffect(()=>{const T=i.current;if(!(!T||!E))try{T.removeAllModels(),T.removeAllShapes(),T.removeAllLabels();const z=T.addModel(E,de||"xyz");d.current=z,z.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const Y=z.getCrystData(),$=!!(Y&&typeof Y=="object"&&Object.keys(Y).length);F($),M($?u.current:!1),j([]),v({});const q=E.split(`
11
- `).slice(2).map(G=>G.trim()).filter(Boolean).map(G=>G.split(/\s+/)[0]??"Atom");h.current||(T.zoomTo(),h.current=!0),z.setClickable({},!0,(G,ce,ee)=>{const ie=G.serial??G.index;if(ie===void 0)return;const ue=G.atom||G.elem||q[ie]||"Atom";j(ge=>{const re=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ge.includes(ie)?ge.filter(be=>be!==ie):[...ge,ie]:ge.length===1&&ge[0]===ie?[]:[ie];return v(be=>{if(re.length===0)return{};const je={};return re.forEach(xe=>{je[xe]=be[xe]||q[xe]||ue}),je}),re})}),z.setHoverable({},!0,(G,ce,ee)=>{!ee||!G||k({x:ee.clientX,y:ee.clientY,label:`${G.atom||G.elem||"Atom"} (${G.serial??G.index??"?"})`,coords:{x:G.x.toFixed(2),y:G.y.toFixed(2),z:G.z.toFixed(2)}})},()=>k(null)),T.render()}catch(z){console.error("Failed to render molecule:",z),V("Unable to render this molecular structure.")}},[E,de]),c.useEffect(()=>{const T=i.current,z=d.current;if(!(!T||!z)){try{T.removeUnitCell(z)}catch{}if(H&&C)try{T.addUnitCell(z,{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{F(!1),M(!1)}T.render()}},[C,H,E,de]),c.useEffect(()=>{const T=i.current,z=d.current;!T||!z||!E||(z.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),N.length>0&&z.setStyle({serial:N},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),T.render(),a==null||a({moleculeId:r,atoms:N}))},[r,a,N,E]),c.useEffect(()=>{if(!E)return;let T=0;const z=()=>{var $,q;const Y=(q=($=i.current)==null?void 0:$.getView)==null?void 0:q.call($);if(Array.isArray(Y)&&Y.length>=8){const[G,ce,ee,ie,ue,ge,Le,re]=Y;if(typeof G=="number"&&typeof ce=="number"&&typeof ee=="number"&&typeof ie=="number"&&typeof ue=="number"&&typeof ge=="number"&&typeof Le=="number"&&typeof re=="number"){const be=Math.sqrt(ue*ue+ge*ge+Le*Le),je=be>0?{x:ue/be,y:ge/be,z:Le/be}:{x:0,y:0,z:0};m({position:{x:G,y:ce,z:ee,qx:ue,qy:ge,qz:Le,qw:re},lookAt:je,zoom:ie})}}T=window.requestAnimationFrame(z)};return T=window.requestAnimationFrame(z),()=>window.cancelAnimationFrame(T)},[E]);const I=c.useCallback(async()=>{const T=i.current;if(!(T!=null&&T.pngURI))return;T.render();const z=T.pngURI();if(z){try{const $=await(await fetch(z)).blob(),q=new ClipboardItem({[$.type||"image/png"]:$});await navigator.clipboard.write([q])}catch{}n==null||n({moleculeId:r,image:z})}},[r,n]);function K(){C&&M(T=>{const z=!T;return u.current=z,z})}function B(){N.length!==0&&P(T=>{const z=T[A]??[];return{...T,[A]:Array.from(new Set([...z,...N]))}})}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:[Q?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:Q}):null,!Q&&!E?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,x?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:x.x-20,top:x.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:x.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",x.coords.x]}),t.jsxs("span",{children:["y: ",x.coords.y]}),t.jsxs("span",{children:["z: ",x.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(Qc,{currentIndex:f,exportContent:W.exportContent,moleculeId:r,onScreenshot:()=>void I(),viewerRef:i,xyzContent:E,xyzFormat:de})]}),Z.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 ",f+1," / ",Z.length,t.jsx(ir,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{y(T=>{const z=!T;return z&&f===Z.length-1&&g(0),z})},"aria-label":b?"Pause trajectory":"Play trajectory",title:b?"Pause trajectory":"Play trajectory",children:b&&f!==Z.length-1?t.jsx(_.Pause,{className:"h-3 w-3"}):t.jsx(_.Play,{className:"h-3 w-3"})})]}),t.jsxs(ir,{type:"button",variant:"ghost",onClick:()=>g(Z.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${J?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(nh,{value:[f],max:Z.length-1,step:1,onValueChange:T=>g(T[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Zc,{cameraInfo:p,onClearSelection:()=>j([]),onClearStaged:()=>P({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:N}),onSendStaged:()=>{Object.entries(S).forEach(([T,z])=>{a==null||a({moleculeId:T==="current"?r:T,atoms:z})})},onStageSelection:B,onToggleUnitCell:K,selectedAtomLabels:w,selectedSerials:N,stagedAtoms:X,stagedMolecules:O,unitCellAvailable:C,unitCellVisible:H})]})]})]})}var ch=Me({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Jc(),eh(),rh(),Fr(),ah(),ih()}});function hh(e){return!e.truncated&&e.size<=Co&&e.content.split(`
12
- `).length<=So}function uh(e){return e&&(e.node.path||e.node.name)||null}function mh(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 ph({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[p,m]=c.useState(!1),[f,g]=c.useState(""),[x,k]=c.useState(null),[b,y]=c.useState(!1),w=(u==null?void 0:u.node)??null,v=w!=null&&w.artifact?h.renderArtifact({artifact:w.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,N=Mc(i??null),j=(i==null?void 0:i.language)||_c((i==null?void 0:i.path)??""),S=i?fr(i.path):"",P=uh(u),C=i!==null&&Un.has(S),F=!!(i&&a)&&!C&&hh(i),H=(u==null?void 0:u.kind)==="live-molecule",M=!!(w!=null&&w.artifact&&v),Q=!!N||M;c.useEffect(()=>{m(!1),g((i==null?void 0:i.content)??""),k(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function V(){if(!(!i||!a)){y(!0),k(null);try{await a({path:i.path,content:f}),m(!1)}catch(W){k(W instanceof Error?W.message:"Failed to save file.")}finally{y(!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"}),P?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:P}):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"&&N?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(dh,{source:N,moleculeId:N.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:[C?"molecule":j||S||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),F?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),m(!1),k(null)},disabled:b,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 V(),disabled:b||f===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),m(!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(_.Pencil,{className:"h-4 w-4"})})}):null]}),x?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:x}):null,p?t.jsx("textarea",{value:f,onChange:W=>g(W.currentTarget.value),spellCheck:!1,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(Cr,{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,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:Q||H?"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(Ut,{label:"Workspace Data",children:t.jsx(Cr,{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(Cr,{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 Co,So,Cr,fh=Me({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Wn(),wo(),ch(),Co=50*1024,So=1e3,Cr=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 gh({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 xh=Me({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function To(e){return`${Lo}${e.workspaceId??"workspace"}:${e.threadId}`}function bh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(To(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function vh(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(To(e),JSON.stringify([...r]))}catch{}}function Aa(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=fr(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 Eo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onDownload:o,onSelect:s,onToggle:l,selectedNodeId:i}){const d=a.kind==="directory",h=d&&(a.path===""||r.has(a.path)),u=d&&n.has(a.path),p=i===a.id,m=`${e*.75+.5}rem`;return d?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:()=>l(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:m},children:[h?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"}),Aa(a,h),t.jsx("span",{className:"truncate",children:a.name}),u?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o?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: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]}),h?t.jsxs("div",{children:[a.children.map(f=>t.jsx(Eo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:f,...o?{onDownload:o}:{},onSelect:s,onToggle:l,selectedNodeId:i},f.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:()=>s(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:[Aa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),o&&a.kind==="file"?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 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]})}function kh({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 wh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onEmptyGarbage:i,onRefresh:d,onSelect:h,onToggle:u,onUpload:p,selectedNodeId:m,tree:f,liveNodes:g}){const x=c.useMemo(()=>({...f,children:f.children.filter(k=>k.path!=="live")}),[f]);return t.jsxs("aside",{className:`${Po} flex flex-col`,children:[t.jsxs("div",{className:Io,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:zo,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:Ro,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:Tr,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:d,className:Tr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(_.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),i?t.jsx("button",{type:"button",onClick:i,disabled:!e,className:Tr,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",{className:"min-h-0 flex-1 overflow-y-auto py-2",children:[t.jsx(kh,{liveNodes:g??[],onSelect:h,selectedNodeId:m}),t.jsx("div",{className:Ao,children:"Workspace"}),s?t.jsx("p",{className:Mo,children:"Loading workspace..."}):null,t.jsx(Eo,{depth:0,expandedPaths:a,loadingPaths:o,node:x,...l?{onDownload:l}:{},onSelect:h,onToggle:u,selectedNodeId:m}),x.children.length===0?t.jsx("p",{className:_o,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function yh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,workspaceAdapter:s}){const[l,i]=c.useState(null),d=c.useMemo(()=>s&&l?null:La(r,n),[e,l,n,r,o,s]),h=l??d??La(r,n),u=c.useMemo(()=>Gc(h),[h]),p=c.useMemo(()=>{var R;return((R=h.children.find(te=>te.path==="live"))==null?void 0:R.children)??[]},[h]),m=bo(h),[f,g]=c.useState(()=>(m==null?void 0:m.id)??null),[x,k]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Pa((m==null?void 0:m.path)??"")])),[b,y]=c.useState(null),[w,v]=c.useState(null),[N,j]=c.useState(!1),[S,P]=c.useState(()=>new Set),[C,F]=c.useState(!1),[H,M]=c.useState(!1),[Q,V]=c.useState(!1),[W,Z]=c.useState([]),[de,E]=c.useState(null),[J,A]=c.useState(null),[X,O]=c.useState(null),[I,K]=c.useState(0),[B,T]=c.useState(!1),z=c.useRef(null),Y=c.useRef(null),$=(f?u.get(f):null)??m??null,q={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{k(new Set(["","artifacts","thread-events","live",...bh(q),...Pa((m==null?void 0:m.path)??"")]))},[q.threadId,q.workspaceId]),c.useEffect(()=>()=>{Y.current!==null&&window.clearTimeout(Y.current)},[]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const R=window.matchMedia("(max-width: 639px)"),te=()=>T(R.matches);return te(),typeof R.addEventListener=="function"?(R.addEventListener("change",te),()=>R.removeEventListener("change",te)):(R.addListener(te),()=>R.removeListener(te))},[]);async function G(R){if(s){j(!0),v(null);try{const te=jn(await s.listTree({...q,path:""}));i(te);const ve=go(te);g(fe=>{const pe=fe?u.get(fe):null;return R&&Nn(te,R)?`workspace:${R}`:pe!=null&&pe.path&&Nn(te,pe.path)?`workspace:${pe.path}`:(ve==null?void 0:ve.id)??fe}),K(fe=>fe+1)}catch(te){v(te instanceof Error?te.message:"Failed to load workspace"),i(null)}finally{j(!1)}}}async function ce(R){if(!(!s||!l)){P(te=>{if(te.has(R))return te;const ve=new Set(te);return ve.add(R),ve}),v(null);try{const te=jn(await s.listTree({...q,path:R}));i(ve=>ve&&fo(ve,R,te.children,{truncated:te.truncated})),K(ve=>ve+1)}catch(te){v(te instanceof Error?te.message:"Failed to load directory")}finally{P(te=>{if(!te.has(R))return te;const ve=new Set(te);return ve.delete(R),ve})}}}c.useEffect(()=>{if(!(!s||!l))for(const R of u.values())R.path&&R.kind==="directory"&&x.has(R.path)&&R.hasChildren&&!R.childrenLoaded&&!S.has(R.path)&&ce(R.path)},[l,x,u,s]),c.useEffect(()=>{i(null),P(new Set),E(null),A(null),O(null),v(null),G()},[s,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{if(!(s!=null&&s.subscribeWorkspaceChanged))return;const R=s.subscribeWorkspaceChanged(q,()=>{Y.current!==null&&window.clearTimeout(Y.current),Y.current=window.setTimeout(()=>{Y.current=null,G(($==null?void 0:$.path)??null)},240)});return()=>{Y.current!==null&&(window.clearTimeout(Y.current),Y.current=null),R==null||R()}},[s,q.threadId,q.workspaceId,$==null?void 0:$.path]),c.useEffect(()=>{const R=s&&($==null?void 0:$.kind)==="file"?$.path:null;if(!R){E(null),A(null),O(null);return}const te=R;let ve=!1;async function fe(){var pe;if(s){F(!0),v(null),E(null),A(null),O(null);try{const Ie=fr(te),D=(pe=s.getRawFileUrl)==null?void 0:pe.call(s,{...q,path:te});if(D&&vo.has(Ie)){ve||A(D);return}if(D&&ko.has(Ie)){ve||O(D);return}const ae=await s.readFile({...q,path:te,limit:Sr});ve||E(ae)}catch(Ie){ve||v(Ie instanceof Error?Ie.message:"Failed to read file")}finally{ve||F(!1)}}}return fe(),()=>{ve=!0}},[s,$==null?void 0:$.id,I]);async function ee(){if(!(!s||!(de!=null&&de.truncated))){M(!0);try{const R=await s.readFile({...q,path:de.path,offset:de.nextOffset,limit:Sr});E(te=>te&&{...te,content:te.content+R.content,truncated:R.truncated,nextOffset:R.nextOffset,size:R.size})}finally{M(!1)}}}async function ie(R){if(!(s!=null&&s.writeFile))return;v(null),await s.writeFile({...q,path:R.path,content:R.content}),await G(R.path);const te=await s.readFile({...q,path:R.path,limit:Sr});E(te)}async function ue(R){var ve;const te=(ve=R.target.files)==null?void 0:ve[0];if(R.target.value="",!(!(s!=null&&s.uploadFile)||!te)){j(!0),v(null);try{const fe=await s.uploadFile({...q,path:te.name,file:te}),pe=fe.kind==="archive"?fe.paths[0]??null:fe.file.path;await G(pe)}catch(fe){v(fe instanceof Error?fe.message:"Failed to upload file")}finally{j(!1)}}}function ge(R){var te;(te=s==null?void 0:s.downloadNode)==null||te.call(s,{...q,path:R.path,kind:R.kind==="directory"?"directory":"file"})}async function Le(){if(s!=null&&s.emptyGarbage){if(v(null),!s.listGarbage){Z([]),V(!0);return}try{const R=await s.listGarbage(q);Z(R.map(te=>`garbage/${te}`))}catch(R){Z([]),v(R instanceof Error?R.message:"Failed to list garbage files")}finally{V(!0)}}}async function re(){if(s!=null&&s.emptyGarbage){V(!1),v(null);try{await s.emptyGarbage(q),await G(($==null?void 0:$.path)??null)}catch(R){v(R instanceof Error?R.message:"Failed to empty garbage")}}}const be={...s!=null&&s.downloadNode?{onDownload:ge}:{},...s!=null&&s.emptyGarbage?{onEmptyGarbage:Le}:{},...s?{onRefresh:()=>void G(($==null?void 0:$.path)??null)}:{},...s!=null&&s.uploadFile?{onUpload:()=>{var R;return(R=z.current)==null?void 0:R.click()}}:{}};function je(R){if(!R)return;const te=u.get(`workspace:${R}`),ve=(te==null?void 0:te.kind)==="directory"&&te.hasChildren&&!te.childrenLoaded&&!S.has(R);k(fe=>{const pe=new Set(fe);return pe.has(R)?pe.delete(R):pe.add(R),vh(q,pe),pe}),!x.has(R)&&ve&&ce(R)}const xe=t.jsx(wh,{canEmptyGarbage:!!(s!=null&&s.emptyGarbage),canUpload:!!(s!=null&&s.uploadFile),...B?{}:{onCollapse:()=>y("explorer")},expandedPaths:x,loadingPaths:S,loading:N,...be,onSelect:R=>{g(R)},onToggle:je,selectedNodeId:($==null?void 0:$.id)??null,tree:h,liveNodes:p}),ze=t.jsx(ph,{error:w,imageUrl:J,loadingMore:H,onLoadMore:ee,...s!=null&&s.writeFile?{onSaveFile:ie}:{},...B?{}:{onCollapse:()=>y("viewer")},pdfUrl:X,previewFile:de,previewLoading:C,plugins:a,selectedTarget:mh($)});return b==="explorer"?t.jsxs("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:[t.jsx("button",{type:"button","data-testid":"expand-explorer",onClick:()=>y(null),className:"thread-graph-panel-expand-fab left-3",title:"Expand Explorer","aria-label":"Expand Explorer",children:t.jsx(_.ChevronsRight,{className:"h-4 w-4"})}),ze]}):b==="viewer"?t.jsxs("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:[xe,t.jsx("button",{type:"button","data-testid":"expand-viewer",onClick:()=>y(null),className:"thread-graph-panel-expand-fab right-3",title:"Expand Viewer","aria-label":"Expand Viewer",children:t.jsx(_.ChevronsLeft,{className:"h-4 w-4"})})]}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Q?t.jsx(gh,{files:W,onCancel:()=>V(!1),onConfirm:()=>void re()}):null,B?t.jsxs("div",{className:"thread-graph-workspace-mobile-stack flex h-full min-h-0 w-full flex-col",children:[t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-[34%] min-h-[11rem] shrink-0 overflow-hidden border-b",children:xe}),t.jsx("div",{className:"thread-graph-workspace-mobile-viewer min-h-0 flex-1 overflow-hidden",children:ze})]}):t.jsxs(uo,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(Ir,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:xe})}),t.jsx(mo,{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(Ir,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ze})})]}),t.jsx("input",{ref:z,type:"file",className:"hidden",onChange:R=>void ue(R)})]})}var Sr,Lo,Po,Io,zo,Tr,Ro,Ao,Mo,_o,jh=Me({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){Wn(),fh(),xh(),po(),Sr=24e3,Lo="remote-codex:graphchat:workspace:expanded:",Po="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Io="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",zo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Tr="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",Ro="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",Ao="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Mo="thread-graph-workspace-loading px-4 text-sm text-slate-400 dark:text-slate-500",_o="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 ln({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 Ht({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 Nh({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 Qt({value:e,title:r,icon:n,children:a}){return t.jsxs(hr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(ur,{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(Nh,{children:n}),r]})}),t.jsx(mr,{className:"space-y-3 pb-3",children:a})]})}function Ch(){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(cr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(Qt,{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(Ht,{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(Qt,{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(Ht,{items:[t.jsxs(t.Fragment,{children:[t.jsx(ln,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(ln,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(ln,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(Qt,{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(Ht,{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(Qt,{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(Ht,{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(Ht,{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(Qt,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(_.Code2,{className:"h-3 w-3"}),children:t.jsx(Ht,{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 Sh=Me({"src/components/graph-workspace/GraphGuidePanel.tsx"(){pr()}});function Th(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 Ma({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:Th(r)})]})}function Eh({event:e}){return t.jsxs(hr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(ur,{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(mr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ma,{label:"Input",value:e.preview}),t.jsx(Ma,{label:"Output",value:e.detail})]})})]})}function Lh({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(cr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Eh,{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 Ph=Me({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){pr()}});function _a(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,p=o.y+h,m=s.x+l/2,f=s.y+i/2,g=(m-u)/(2*d)-(f-p)/(2*h),x=(m-u)/(2*d)+(f-p)/(2*h),k=1/(Math.abs(g)+Math.abs(x)),b=k*g,y=k*x,w=d*(b+y)+u,v=h*(-b+y)+p;return{x:w,y:v}}function $a(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?Et.Left:s>=a+(e.measured.width??1)-1?Et.Right:l<=o+1?Et.Top:l>=n.y+(e.measured.height??1)-1?Et.Bottom:Et.Top}function $o(e,r){const n=_a(e,r),a=_a(r,e),o=$a(e,n),s=$a(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Ih(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,p)=>{const m=new Map,f=d.length;d.forEach((g,x)=>{const k=g.id.split("").reduce((b,y)=>{const w=(b<<5)-b+y.charCodeAt(0);return w&w},0);m.set(g.id,{x:Math.abs(k)%u+x*100%u,y:Math.abs(k>>16)%p+x*150%p,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let x=0;x<f;x+=1)for(let k=x+1;k<f;k+=1){const b=d[x],y=d[k];if(!b||!y)continue;const w=m.get(b.id),v=m.get(y.id);if(!w||!v)continue;const N=w.x-v.x,j=w.y-v.y,S=Math.sqrt(N*N+j*j)||1,C=(200-S)*.5,F=N/S*C,H=j/S*C;w.vx+=F,w.vy+=H,v.vx-=F,v.vy-=H}h.forEach(x=>{const k=m.get(x.source),b=m.get(x.target);if(!k||!b)return;const y=b.x-k.x,w=b.y-k.y,v=Math.sqrt(y*y+w*w)||1,j=(v-120)*.3,S=y/v*j,P=w/v*j;k.vx+=S,k.vy+=P,b.vx-=S,b.vy-=P}),m.forEach(x=>{x.x+=x.vx*.1,x.y+=x.vy*.1,x.vx*=.9,x.vy*=.9,x.x=Math.max(80,Math.min(u-80,x.x)),x.y=Math.max(80,Math.min(p-80,x.y))})}return m},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:Ns.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 Vn=Me({"src/components/graph-chat/FloatingHelper.tsx"(){}});function zh({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:p}=$o(o,s),[m]=Cs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:p||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:m}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Rh=Me({"src/components/graph-chat/FloatingConnectionLine.tsx"(){Vn()}});function Ah({id:e,source:r,target:n,markerEnd:a,style:o}){const s=ha(r),l=ha(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:p,targetPos:m}=$o(s,l),[f]=Cs({sourceX:i,sourceY:d,sourcePosition:p,targetPosition:m,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:f,markerEnd:a,style:o})}var Mh=Me({"src/components/graph-chat/FloatingEdge.tsx"(){Vn()}});function _h({nodes:e}){const[r,n,a]=Zi([]),[o,s,l]=Ji([]),i=c.useMemo(()=>Ih(e),[e]),d=c.useMemo(()=>({floating:Ah}),[]),h=c.useMemo(()=>({styledNode:({data:p,isConnectable:m})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[p.label,t.jsx(ca,{type:"target",position:Et.Top,isConnectable:m,style:{opacity:0,pointerEvents:"none"}}),t.jsx(ca,{type:"source",position:Et.Bottom,isConnectable:m,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(p=>s(m=>Qi({...p,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ns.Arrow}},m)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(ed,{children:t.jsxs(td,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:zh,children:[t.jsx(rd,{}),t.jsx(nd,{gap:16})]})})})}var $h=Me({"src/components/graph-chat/GraphVisualization.tsx"(){Rh(),Mh(),Vn()}});function Dh(e){return{...Bo,...e}}function Da(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 Bh(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 Gh(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:zr(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:zr(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 zr(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 Fh(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return zr(e.kind)}}function Hh(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function Oh(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:Fh(d),description:Hh(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 Do({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i}){const d=c.useMemo(()=>Dh(i),[i]),h=Da(d,i==null?void 0:i.defaultTab),[u,p]=c.useState(h),m=c.useMemo(()=>zc(e),[e]),f=c.useMemo(()=>Gh(e),[e]),g=c.useMemo(()=>{const v=new Map;for(const N of f)v.set(N.kind,(v.get(N.kind)??0)+1);return[...v.entries()].sort((N,j)=>j[1]-N[1])},[f]),x=n.getThreadPanels(),k=Math.max(...g.map(([,v])=>v),1),b=c.useMemo(()=>Oh(e,f),[e,f]),y=c.useMemo(()=>{const v=[];return d.workspace&&v.push({id:"workspace",label:"Workspace",icon:null}),d.toolUsage&&v.push({id:"tools",label:"Tool Usage",icon:_.BarChart2}),d.guide&&v.push({id:"guide",label:"Guide",icon:_.BookOpen}),v},[d.guide,d.toolUsage,d.workspace]),w=c.useMemo(()=>{const v=[];return d.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:_.GitBranch}),d.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:_.Wrench}),v},[d.extensions,d.threadGraph]);return c.useEffect(()=>{(!u||!Bh(d,u))&&p(Da(d,i==null?void 0:i.defaultTab))},[u,i==null?void 0:i.defaultTab,d]),u?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(v=>{const N=v.icon;return t.jsxs("button",{type:"button",onClick:()=>p(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 ${u===v.id?"is-active":""}`,children:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),w.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:w.map(v=>{const N=v.icon;return t.jsx("button",{type:"button",onClick:()=>p(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 ${u===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(N,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[u==="workspace"?t.jsx(yh,{activeView:l,detail:e,artifacts:m,plugins:n,status:r,workspaceAdapter:a??null}):null,u==="tools"?t.jsx(Lh,{formatToolKind:zr,toolCounts:g,toolEvents:f,maxToolCount:k}):null,u==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(_h,{nodes:b})}):null,u==="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(Ut,{label:"Plugin Panels",children:x.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:x.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(Ut,{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(Ut,{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(Ut,{label:"Thread Meta",children:o}):null,s?t.jsx(Ut,{label:"Settings",children:s}):null]})}):null,u==="guide"?t.jsx(Ch,{}):null]})]}):null}var Bo,Go,Uh=Me({"src/components/ThreadGraphWorkspacePanel.tsx"(){jh(),wo(),Sh(),Ph(),Wn(),$h(),Bo={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},Go=c.memo(Do)}}),Fo={};Ic(Fo,{MemoizedThreadGraphWorkspacePanel:()=>Go,ThreadGraphWorkspacePanel:()=>Do});var Wh=Me({"src/workspace-panel.ts"(){Uh()}});function Xt(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))}Xt(`.thread-ui-shell,
10
+ `).join("")}function lh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=za([e],"xyz");return{frames:o,format:"xyz",exportContent:Ra(o)}}const r=sh(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:za(n,r),format:r,exportContent:Ra(n)}}var ih=Me({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function dh({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),[p,m]=c.useState(null),[f,g]=c.useState(0),[x,k]=c.useState(null),[b,y]=c.useState(!1),[w,v]=c.useState({}),[N,j]=c.useState([]),[S,L]=c.useState({}),[C,H]=c.useState(!1),[O,M]=c.useState(!1),[Q,V]=c.useState(null),W=c.useMemo(()=>lh(o),[o]),Z=W.frames,de=W.format,T=Z[f]??null,J=Z.length>0&&f===Z.length-1,A=r??"current",Y=Object.values(S).reduce((P,z)=>P+z.length,0),F=Object.keys(S).length;c.useEffect(()=>{if(Z.length===0){g(0);return}g(Z.length-1)},[Z.length]),c.useEffect(()=>{if(!b||Z.length<=1)return;const P=window.setInterval(()=>{g(z=>z>=Z.length-1?(window.clearInterval(P),y(!1),z):z+1)},200);return()=>window.clearInterval(P)},[b,Z.length]),c.useEffect(()=>{const P=l.current;if(!P||i.current)return;let z=!1;try{const _=document.createElement("canvas");if(!(_.getContext("webgl2")||_.getContext("webgl")||_.getContext("experimental-webgl"))){V("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{V("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const X=()=>{var _,q;(_=i.current)==null||_.resize(),(q=i.current)==null||q.render()};return th().then(_=>{if(!(z||i.current))try{const q=_.createViewer(P,{});i.current=q,q.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",X),window.setTimeout(X,100)}catch(q){console.error("Failed to initialize 3Dmol viewer:",q),V("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(_=>{console.error("Failed to load 3Dmol viewer runtime:",_),V("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{z=!0,window.removeEventListener("resize",X),i.current=null,d.current=null}},[]),c.useEffect(()=>{const P=i.current;if(!(!P||!T))try{P.removeAllModels(),P.removeAllShapes(),P.removeAllLabels();const z=P.addModel(T,de||"xyz");d.current=z,z.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const X=z.getCrystData(),_=!!(X&&typeof X=="object"&&Object.keys(X).length);H(_),M(_?u.current:!1),j([]),v({});const q=T.split(`
11
+ `).slice(2).map(G=>G.trim()).filter(Boolean).map(G=>G.split(/\s+/)[0]??"Atom");h.current||(P.zoomTo(),h.current=!0),z.setClickable({},!0,(G,ce,ee)=>{const ie=G.serial??G.index;if(ie===void 0)return;const ue=G.atom||G.elem||q[ie]||"Atom";j(ge=>{const re=!!(ee!=null&&ee.shiftKey||ee!=null&&ee.metaKey||ee!=null&&ee.ctrlKey)?ge.includes(ie)?ge.filter(be=>be!==ie):[...ge,ie]:ge.length===1&&ge[0]===ie?[]:[ie];return v(be=>{if(re.length===0)return{};const je={};return re.forEach(xe=>{je[xe]=be[xe]||q[xe]||ue}),je}),re})}),z.setHoverable({},!0,(G,ce,ee)=>{!ee||!G||k({x:ee.clientX,y:ee.clientY,label:`${G.atom||G.elem||"Atom"} (${G.serial??G.index??"?"})`,coords:{x:G.x.toFixed(2),y:G.y.toFixed(2),z:G.z.toFixed(2)}})},()=>k(null)),P.render()}catch(z){console.error("Failed to render molecule:",z),V("Unable to render this molecular structure.")}},[T,de]),c.useEffect(()=>{const P=i.current,z=d.current;if(!(!P||!z)){try{P.removeUnitCell(z)}catch{}if(O&&C)try{P.addUnitCell(z,{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{H(!1),M(!1)}P.render()}},[C,O,T,de]),c.useEffect(()=>{const P=i.current,z=d.current;!P||!z||!T||(z.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),N.length>0&&z.setStyle({serial:N},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),P.render(),a==null||a({moleculeId:r,atoms:N}))},[r,a,N,T]),c.useEffect(()=>{if(!T)return;let P=0;const z=()=>{var _,q;const X=(q=(_=i.current)==null?void 0:_.getView)==null?void 0:q.call(_);if(Array.isArray(X)&&X.length>=8){const[G,ce,ee,ie,ue,ge,Le,re]=X;if(typeof G=="number"&&typeof ce=="number"&&typeof ee=="number"&&typeof ie=="number"&&typeof ue=="number"&&typeof ge=="number"&&typeof Le=="number"&&typeof re=="number"){const be=Math.sqrt(ue*ue+ge*ge+Le*Le),je=be>0?{x:ue/be,y:ge/be,z:Le/be}:{x:0,y:0,z:0};m({position:{x:G,y:ce,z:ee,qx:ue,qy:ge,qz:Le,qw:re},lookAt:je,zoom:ie})}}P=window.requestAnimationFrame(z)};return P=window.requestAnimationFrame(z),()=>window.cancelAnimationFrame(P)},[T]);const I=c.useCallback(async()=>{const P=i.current;if(!(P!=null&&P.pngURI))return;P.render();const z=P.pngURI();if(z){try{const _=await(await fetch(z)).blob(),q=new ClipboardItem({[_.type||"image/png"]:_});await navigator.clipboard.write([q])}catch{}n==null||n({moleculeId:r,image:z})}},[r,n]);function K(){C&&M(P=>{const z=!P;return u.current=z,z})}function D(){N.length!==0&&L(P=>{const z=P[A]??[];return{...P,[A]:Array.from(new Set([...z,...N]))}})}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:[Q?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:Q}):null,!Q&&!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,x?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:x.x-20,top:x.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:x.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",x.coords.x]}),t.jsxs("span",{children:["y: ",x.coords.y]}),t.jsxs("span",{children:["z: ",x.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(Qc,{currentIndex:f,exportContent:W.exportContent,moleculeId:r,onScreenshot:()=>void I(),viewerRef:i,xyzContent:T,xyzFormat:de})]}),Z.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 ",f+1," / ",Z.length,t.jsx(ir,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{y(P=>{const z=!P;return z&&f===Z.length-1&&g(0),z})},"aria-label":b?"Pause trajectory":"Play trajectory",title:b?"Pause trajectory":"Play trajectory",children:b&&f!==Z.length-1?t.jsx($.Pause,{className:"h-3 w-3"}):t.jsx($.Play,{className:"h-3 w-3"})})]}),t.jsxs(ir,{type:"button",variant:"ghost",onClick:()=>g(Z.length-1),className:"thread-graph-molecule-live-button",children:[t.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${J?"animate-pulse bg-red-600":"bg-gray-300"}`}),"Live"]})]}),t.jsx(nh,{value:[f],max:Z.length-1,step:1,onValueChange:P=>g(P[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(Zc,{cameraInfo:p,onClearSelection:()=>j([]),onClearStaged:()=>L({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:N}),onSendStaged:()=>{Object.entries(S).forEach(([P,z])=>{a==null||a({moleculeId:P==="current"?r:P,atoms:z})})},onStageSelection:D,onToggleUnitCell:K,selectedAtomLabels:w,selectedSerials:N,stagedAtoms:Y,stagedMolecules:F,unitCellAvailable:C,unitCellVisible:O})]})]})]})}var ch=Me({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){Jc(),eh(),rh(),Fr(),ah(),ih()}});function hh(e){return!e.truncated&&e.size<=Co&&e.content.split(`
12
+ `).length<=So}function uh(e){return e&&(e.node.path||e.node.name)||null}function mh(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 ph({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[p,m]=c.useState(!1),[f,g]=c.useState(""),[x,k]=c.useState(null),[b,y]=c.useState(!1),w=(u==null?void 0:u.node)??null,v=w!=null&&w.artifact?h.renderArtifact({artifact:w.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,N=Mc(i??null),j=(i==null?void 0:i.language)||_c((i==null?void 0:i.path)??""),S=i?fr(i.path):"",L=uh(u),C=i!==null&&Un.has(S),H=!!(i&&a)&&!C&&hh(i),O=(u==null?void 0:u.kind)==="live-molecule",M=!!(w!=null&&w.artifact&&v),Q=!!N||M;c.useEffect(()=>{m(!1),g((i==null?void 0:i.content)??""),k(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function V(){if(!(!i||!a)){y(!0),k(null);try{await a({path:i.path,content:f}),m(!1)}catch(W){k(W instanceof Error?W.message:"Failed to save file.")}finally{y(!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"&&N?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(dh,{source:N,moleculeId:N.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:[C?"molecule":j||S||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),H?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:p?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),m(!1),k(null)},disabled:b,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 V(),disabled:b||f===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),m(!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($.Pencil,{className:"h-4 w-4"})})}):null]}),x?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:x}):null,p?t.jsx("textarea",{value:f,onChange:W=>g(W.currentTarget.value),spellCheck:!1,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(Cr,{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,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:Q||O?"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(Ut,{label:"Workspace Data",children:t.jsx(Cr,{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(Cr,{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 Co,So,Cr,fh=Me({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){Wn(),wo(),ch(),Co=50*1024,So=1e3,Cr=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 gh({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 xh=Me({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function To(e){return`${Lo}${e.workspaceId??"workspace"}:${e.threadId}`}function bh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(To(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function vh(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(To(e),JSON.stringify([...r]))}catch{}}function Aa(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=fr(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 Eo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onDownload:o,onSelect:s,onToggle:l,selectedNodeId:i}){const d=a.kind==="directory",h=d&&(a.path===""||r.has(a.path)),u=d&&n.has(a.path),p=i===a.id,m=`${e*.75+.5}rem`;return d?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:()=>l(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:m},children:[h?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"}),Aa(a,h),t.jsx("span",{className:"truncate",children:a.name}),u?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),o?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: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]}),h?t.jsxs("div",{children:[a.children.map(f=>t.jsx(Eo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:f,...o?{onDownload:o}:{},onSelect:s,onToggle:l,selectedNodeId:i},f.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:()=>s(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:[Aa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),o&&a.kind==="file"?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 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]})}function kh({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 wh({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onEmptyGarbage:i,onRefresh:d,onSelect:h,onToggle:u,onUpload:p,selectedNodeId:m,tree:f,liveNodes:g}){const x=c.useMemo(()=>({...f,children:f.children.filter(k=>k.path!=="live")}),[f]);return t.jsxs("aside",{className:`${Po} flex flex-col`,children:[t.jsxs("div",{className:Io,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:zo,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:Ro,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:Tr,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:d,className:Tr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx($.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),i?t.jsx("button",{type:"button",onClick:i,disabled:!e,className:Tr,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",{className:"min-h-0 flex-1 overflow-y-auto py-2",children:[t.jsx(kh,{liveNodes:g??[],onSelect:h,selectedNodeId:m}),t.jsx("div",{className:Ao,children:"Workspace"}),s?t.jsx("p",{className:Mo,children:"Loading workspace..."}):null,t.jsx(Eo,{depth:0,expandedPaths:a,loadingPaths:o,node:x,...l?{onDownload:l}:{},onSelect:h,onToggle:u,selectedNodeId:m}),x.children.length===0?t.jsx("p",{className:_o,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function yh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,workspaceAdapter:s}){const[l,i]=c.useState(null),d=c.useMemo(()=>s&&l?null:La(r,n),[e,l,n,r,o,s]),h=l??d??La(r,n),u=c.useMemo(()=>Gc(h),[h]),p=c.useMemo(()=>{var R;return((R=h.children.find(te=>te.path==="live"))==null?void 0:R.children)??[]},[h]),m=bo(h),[f,g]=c.useState(()=>(m==null?void 0:m.id)??null),[x,k]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Pa((m==null?void 0:m.path)??"")])),[b,y]=c.useState(null),[w,v]=c.useState(null),[N,j]=c.useState(!1),[S,L]=c.useState(()=>new Set),[C,H]=c.useState(!1),[O,M]=c.useState(!1),[Q,V]=c.useState(!1),[W,Z]=c.useState([]),[de,T]=c.useState(null),[J,A]=c.useState(null),[Y,F]=c.useState(null),[I,K]=c.useState(0),[D,P]=c.useState(!1),z=c.useRef(null),X=c.useRef(null),_=(f?u.get(f):null)??m??null,q={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{k(new Set(["","artifacts","thread-events","live",...bh(q),...Pa((m==null?void 0:m.path)??"")]))},[q.threadId,q.workspaceId]),c.useEffect(()=>()=>{X.current!==null&&window.clearTimeout(X.current)},[]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const R=window.matchMedia("(max-width: 639px)"),te=()=>P(R.matches);return te(),typeof R.addEventListener=="function"?(R.addEventListener("change",te),()=>R.removeEventListener("change",te)):(R.addListener(te),()=>R.removeListener(te))},[]);async function G(R){if(s){j(!0),v(null);try{const te=jn(await s.listTree({...q,path:""}));i(te);const ve=go(te);g(fe=>{const pe=fe?u.get(fe):null;return R&&Nn(te,R)?`workspace:${R}`:pe!=null&&pe.path&&Nn(te,pe.path)?`workspace:${pe.path}`:(ve==null?void 0:ve.id)??fe}),K(fe=>fe+1)}catch(te){v(te instanceof Error?te.message:"Failed to load workspace"),i(null)}finally{j(!1)}}}async function ce(R){if(!(!s||!l)){L(te=>{if(te.has(R))return te;const ve=new Set(te);return ve.add(R),ve}),v(null);try{const te=jn(await s.listTree({...q,path:R}));i(ve=>ve&&fo(ve,R,te.children,{truncated:te.truncated})),K(ve=>ve+1)}catch(te){v(te instanceof Error?te.message:"Failed to load directory")}finally{L(te=>{if(!te.has(R))return te;const ve=new Set(te);return ve.delete(R),ve})}}}c.useEffect(()=>{if(!(!s||!l))for(const R of u.values())R.path&&R.kind==="directory"&&x.has(R.path)&&R.hasChildren&&!R.childrenLoaded&&!S.has(R.path)&&ce(R.path)},[l,x,u,s]),c.useEffect(()=>{i(null),L(new Set),T(null),A(null),F(null),v(null),G()},[s,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{if(!(s!=null&&s.subscribeWorkspaceChanged))return;const R=s.subscribeWorkspaceChanged(q,()=>{X.current!==null&&window.clearTimeout(X.current),X.current=window.setTimeout(()=>{X.current=null,G((_==null?void 0:_.path)??null)},240)});return()=>{X.current!==null&&(window.clearTimeout(X.current),X.current=null),R==null||R()}},[s,q.threadId,q.workspaceId,_==null?void 0:_.path]),c.useEffect(()=>{const R=s&&(_==null?void 0:_.kind)==="file"?_.path:null;if(!R){T(null),A(null),F(null);return}const te=R;let ve=!1;async function fe(){var pe;if(s){H(!0),v(null),T(null),A(null),F(null);try{const Ie=fr(te),B=(pe=s.getRawFileUrl)==null?void 0:pe.call(s,{...q,path:te});if(B&&vo.has(Ie)){ve||A(B);return}if(B&&ko.has(Ie)){ve||F(B);return}const ae=await s.readFile({...q,path:te,limit:Sr});ve||T(ae)}catch(Ie){ve||v(Ie instanceof Error?Ie.message:"Failed to read file")}finally{ve||H(!1)}}}return fe(),()=>{ve=!0}},[s,_==null?void 0:_.id,I]);async function ee(){if(!(!s||!(de!=null&&de.truncated))){M(!0);try{const R=await s.readFile({...q,path:de.path,offset:de.nextOffset,limit:Sr});T(te=>te&&{...te,content:te.content+R.content,truncated:R.truncated,nextOffset:R.nextOffset,size:R.size})}finally{M(!1)}}}async function ie(R){if(!(s!=null&&s.writeFile))return;v(null),await s.writeFile({...q,path:R.path,content:R.content}),await G(R.path);const te=await s.readFile({...q,path:R.path,limit:Sr});T(te)}async function ue(R){var ve;const te=(ve=R.target.files)==null?void 0:ve[0];if(R.target.value="",!(!(s!=null&&s.uploadFile)||!te)){j(!0),v(null);try{const fe=await s.uploadFile({...q,path:te.name,file:te}),pe=fe.kind==="archive"?fe.paths[0]??null:fe.file.path;await G(pe)}catch(fe){v(fe instanceof Error?fe.message:"Failed to upload file")}finally{j(!1)}}}function ge(R){var te;(te=s==null?void 0:s.downloadNode)==null||te.call(s,{...q,path:R.path,kind:R.kind==="directory"?"directory":"file"})}async function Le(){if(s!=null&&s.emptyGarbage){if(v(null),!s.listGarbage){Z([]),V(!0);return}try{const R=await s.listGarbage(q);Z(R.map(te=>`garbage/${te}`))}catch(R){Z([]),v(R instanceof Error?R.message:"Failed to list garbage files")}finally{V(!0)}}}async function re(){if(s!=null&&s.emptyGarbage){V(!1),v(null);try{await s.emptyGarbage(q),await G((_==null?void 0:_.path)??null)}catch(R){v(R instanceof Error?R.message:"Failed to empty garbage")}}}const be={...s!=null&&s.downloadNode?{onDownload:ge}:{},...s!=null&&s.emptyGarbage?{onEmptyGarbage:Le}:{},...s?{onRefresh:()=>void G((_==null?void 0:_.path)??null)}:{},...s!=null&&s.uploadFile?{onUpload:()=>{var R;return(R=z.current)==null?void 0:R.click()}}:{}};function je(R){if(!R)return;const te=u.get(`workspace:${R}`),ve=(te==null?void 0:te.kind)==="directory"&&te.hasChildren&&!te.childrenLoaded&&!S.has(R);k(fe=>{const pe=new Set(fe);return pe.has(R)?pe.delete(R):pe.add(R),vh(q,pe),pe}),!x.has(R)&&ve&&ce(R)}const xe=t.jsx(wh,{canEmptyGarbage:!!(s!=null&&s.emptyGarbage),canUpload:!!(s!=null&&s.uploadFile),...D?{}:{onCollapse:()=>y("explorer")},expandedPaths:x,loadingPaths:S,loading:N,...be,onSelect:R=>{g(R)},onToggle:je,selectedNodeId:(_==null?void 0:_.id)??null,tree:h,liveNodes:p}),ze=t.jsx(ph,{error:w,imageUrl:J,loadingMore:O,onLoadMore:ee,...s!=null&&s.writeFile?{onSaveFile:ie}:{},...D?{}:{onCollapse:()=>y("viewer")},pdfUrl:Y,previewFile:de,previewLoading:C,plugins:a,selectedTarget:mh(_)});return b==="explorer"?t.jsxs("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:[t.jsx("button",{type:"button","data-testid":"expand-explorer",onClick:()=>y(null),className:"thread-graph-panel-expand-fab left-3",title:"Expand Explorer","aria-label":"Expand Explorer",children:t.jsx($.ChevronsRight,{className:"h-4 w-4"})}),ze]}):b==="viewer"?t.jsxs("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:[xe,t.jsx("button",{type:"button","data-testid":"expand-viewer",onClick:()=>y(null),className:"thread-graph-panel-expand-fab right-3",title:"Expand Viewer","aria-label":"Expand Viewer",children:t.jsx($.ChevronsLeft,{className:"h-4 w-4"})})]}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Q?t.jsx(gh,{files:W,onCancel:()=>V(!1),onConfirm:()=>void re()}):null,D?t.jsxs("div",{className:"thread-graph-workspace-mobile-stack flex h-full min-h-0 w-full flex-col",children:[t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-[34%] min-h-[11rem] shrink-0 overflow-hidden border-b",children:xe}),t.jsx("div",{className:"thread-graph-workspace-mobile-viewer min-h-0 flex-1 overflow-hidden",children:ze})]}):t.jsxs(uo,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(Ir,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:xe})}),t.jsx(mo,{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(Ir,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:ze})})]}),t.jsx("input",{ref:z,type:"file",className:"hidden",onChange:R=>void ue(R)})]})}var Sr,Lo,Po,Io,zo,Tr,Ro,Ao,Mo,_o,jh=Me({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){Wn(),fh(),xh(),po(),Sr=24e3,Lo="remote-codex:graphchat:workspace:expanded:",Po="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Io="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",zo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Tr="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",Ro="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",Ao="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Mo="thread-graph-workspace-loading px-4 text-sm text-slate-400 dark:text-slate-500",_o="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 ln({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 Ht({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 Nh({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 Qt({value:e,title:r,icon:n,children:a}){return t.jsxs(hr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(ur,{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(Nh,{children:n}),r]})}),t.jsx(mr,{className:"space-y-3 pb-3",children:a})]})}function Ch(){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(cr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(Qt,{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(Ht,{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(Qt,{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(Ht,{items:[t.jsxs(t.Fragment,{children:[t.jsx(ln,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(ln,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(ln,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(Qt,{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(Ht,{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(Qt,{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(Ht,{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(Ht,{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(Qt,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx($.Code2,{className:"h-3 w-3"}),children:t.jsx(Ht,{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 Sh=Me({"src/components/graph-workspace/GraphGuidePanel.tsx"(){pr()}});function Th(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 Ma({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:Th(r)})]})}function Eh({event:e}){return t.jsxs(hr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(ur,{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(mr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ma,{label:"Input",value:e.preview}),t.jsx(Ma,{label:"Output",value:e.detail})]})})]})}function Lh({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(cr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Eh,{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 Ph=Me({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){pr()}});function _a(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,p=o.y+h,m=s.x+l/2,f=s.y+i/2,g=(m-u)/(2*d)-(f-p)/(2*h),x=(m-u)/(2*d)+(f-p)/(2*h),k=1/(Math.abs(g)+Math.abs(x)),b=k*g,y=k*x,w=d*(b+y)+u,v=h*(-b+y)+p;return{x:w,y:v}}function $a(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?Et.Left:s>=a+(e.measured.width??1)-1?Et.Right:l<=o+1?Et.Top:l>=n.y+(e.measured.height??1)-1?Et.Bottom:Et.Top}function $o(e,r){const n=_a(e,r),a=_a(r,e),o=$a(e,n),s=$a(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Ih(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,p)=>{const m=new Map,f=d.length;d.forEach((g,x)=>{const k=g.id.split("").reduce((b,y)=>{const w=(b<<5)-b+y.charCodeAt(0);return w&w},0);m.set(g.id,{x:Math.abs(k)%u+x*100%u,y:Math.abs(k>>16)%p+x*150%p,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let x=0;x<f;x+=1)for(let k=x+1;k<f;k+=1){const b=d[x],y=d[k];if(!b||!y)continue;const w=m.get(b.id),v=m.get(y.id);if(!w||!v)continue;const N=w.x-v.x,j=w.y-v.y,S=Math.sqrt(N*N+j*j)||1,C=(200-S)*.5,H=N/S*C,O=j/S*C;w.vx+=H,w.vy+=O,v.vx-=H,v.vy-=O}h.forEach(x=>{const k=m.get(x.source),b=m.get(x.target);if(!k||!b)return;const y=b.x-k.x,w=b.y-k.y,v=Math.sqrt(y*y+w*w)||1,j=(v-120)*.3,S=y/v*j,L=w/v*j;k.vx+=S,k.vy+=L,b.vx-=S,b.vy-=L}),m.forEach(x=>{x.x+=x.vx*.1,x.y+=x.vy*.1,x.vx*=.9,x.vy*=.9,x.x=Math.max(80,Math.min(u-80,x.x)),x.y=Math.max(80,Math.min(p-80,x.y))})}return m},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:Ns.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 Vn=Me({"src/components/graph-chat/FloatingHelper.tsx"(){}});function zh({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:p}=$o(o,s),[m]=Cs({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:p||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:m}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Rh=Me({"src/components/graph-chat/FloatingConnectionLine.tsx"(){Vn()}});function Ah({id:e,source:r,target:n,markerEnd:a,style:o}){const s=ha(r),l=ha(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:p,targetPos:m}=$o(s,l),[f]=Cs({sourceX:i,sourceY:d,sourcePosition:p,targetPosition:m,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:f,markerEnd:a,style:o})}var Mh=Me({"src/components/graph-chat/FloatingEdge.tsx"(){Vn()}});function _h({nodes:e}){const[r,n,a]=Zi([]),[o,s,l]=Ji([]),i=c.useMemo(()=>Ih(e),[e]),d=c.useMemo(()=>({floating:Ah}),[]),h=c.useMemo(()=>({styledNode:({data:p,isConnectable:m})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[p.label,t.jsx(ca,{type:"target",position:Et.Top,isConnectable:m,style:{opacity:0,pointerEvents:"none"}}),t.jsx(ca,{type:"source",position:Et.Bottom,isConnectable:m,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(p=>s(m=>Qi({...p,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ns.Arrow}},m)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(ed,{children:t.jsxs(td,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:zh,children:[t.jsx(rd,{}),t.jsx(nd,{gap:16})]})})})}var $h=Me({"src/components/graph-chat/GraphVisualization.tsx"(){Rh(),Mh(),Vn()}});function Dh(e){return{...Bo,...e}}function Da(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 Bh(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 Gh(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:zr(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:zr(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 zr(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 Fh(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return zr(e.kind)}}function Hh(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function Oh(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:Fh(d),description:Hh(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 Do({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i}){const d=c.useMemo(()=>Dh(i),[i]),h=Da(d,i==null?void 0:i.defaultTab),[u,p]=c.useState(h),m=c.useMemo(()=>zc(e),[e]),f=c.useMemo(()=>Gh(e),[e]),g=c.useMemo(()=>{const v=new Map;for(const N of f)v.set(N.kind,(v.get(N.kind)??0)+1);return[...v.entries()].sort((N,j)=>j[1]-N[1])},[f]),x=n.getThreadPanels(),k=Math.max(...g.map(([,v])=>v),1),b=c.useMemo(()=>Oh(e,f),[e,f]),y=c.useMemo(()=>{const v=[];return d.workspace&&v.push({id:"workspace",label:"Workspace",icon:null}),d.toolUsage&&v.push({id:"tools",label:"Tool Usage",icon:$.BarChart2}),d.guide&&v.push({id:"guide",label:"Guide",icon:$.BookOpen}),v},[d.guide,d.toolUsage,d.workspace]),w=c.useMemo(()=>{const v=[];return d.threadGraph&&v.push({id:"graph",label:"Thread graph",icon:$.GitBranch}),d.extensions&&v.push({id:"extensions",label:"Remote Codex extensions",icon:$.Wrench}),v},[d.extensions,d.threadGraph]);return c.useEffect(()=>{(!u||!Bh(d,u))&&p(Da(d,i==null?void 0:i.defaultTab))},[u,i==null?void 0:i.defaultTab,d]),u?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(v=>{const N=v.icon;return t.jsxs("button",{type:"button",onClick:()=>p(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 ${u===v.id?"is-active":""}`,children:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,v.label]},v.id)}),w.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:w.map(v=>{const N=v.icon;return t.jsx("button",{type:"button",onClick:()=>p(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 ${u===v.id?"is-active":""}`,title:v.label,"aria-label":v.label,children:t.jsx(N,{className:"h-3.5 w-3.5"})},v.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[u==="workspace"?t.jsx(yh,{activeView:l,detail:e,artifacts:m,plugins:n,status:r,workspaceAdapter:a??null}):null,u==="tools"?t.jsx(Lh,{formatToolKind:zr,toolCounts:g,toolEvents:f,maxToolCount:k}):null,u==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(_h,{nodes:b})}):null,u==="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(Ut,{label:"Plugin Panels",children:x.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:x.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(Ut,{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(Ut,{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(Ut,{label:"Thread Meta",children:o}):null,s?t.jsx(Ut,{label:"Settings",children:s}):null]})}):null,u==="guide"?t.jsx(Ch,{}):null]})]}):null}var Bo,Go,Uh=Me({"src/components/ThreadGraphWorkspacePanel.tsx"(){jh(),wo(),Sh(),Ph(),Wn(),$h(),Bo={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},Go=c.memo(Do)}}),Fo={};Ic(Fo,{MemoizedThreadGraphWorkspacePanel:()=>Go,ThreadGraphWorkspacePanel:()=>Do});var Wh=Me({"src/workspace-panel.ts"(){Uh()}});function Xt(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))}Xt(`.thread-ui-shell,
14
14
  .thread-graph-dialog {
15
15
  color-scheme: light;
16
16
  --radius: 0.625rem;
@@ -3587,20 +3587,20 @@ url = ${JSON.stringify(r.trim())}
3587
3587
  `).concat(`
3588
3588
  `)}const u=a.trimEnd();return u?`${u}
3589
3589
 
3590
- ${o}`:o}function Ho(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function dn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function iu(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,`${dn(n)} used / ${dn(a)}`,`${dn(o)} left`,`${Ho(r.remainingPercent)}% context left`].join(" · ")}function du(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 cu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Tn(e){return e.type.startsWith("image/")?"photo":"file"}function En(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 Ha(e,r){return En(e,r).length>0}function hu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Oa(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:hu(e.originalName)}var Rr=[{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 uu({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",p=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",m=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:p,modelControlsDisabled:m,effortControlsDisabled:m||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 pu(){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 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.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 xu(){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 Ln(){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 vu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function ku(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function wu(e){var r;return((r=Rr.find(n=>n.value===e))==null?void 0:r.label)??e}function yu(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 ju(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Nu(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 Cu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Oo(e){const r=Cu(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 Su(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Tu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Ho(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 Tt({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 Eu(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};default:return{type:"noop"}}}function Lu(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?Su(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";default:return""}}function Pu(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;default:return!1}}function Iu(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 zu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Ru(e){return!!e.querySelector("[style], font")}function Lt(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Uo(e){let r="";for(const n of Array.from(e.childNodes))r+=Lt(n);return r.replace(/\u00a0/g," ")}function Ua(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 p=d[u];p&&(h+=Lt(p).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 Uo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Lt(d).length;try{h.setEnd(r,n);const p=h.toString().length,m=((i=d.textContent)==null?void 0:i.length)??0;m===0?o=u:o=Math.round(Math.min(1,p/m)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Lt(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,Lt(d).length);l+=Lt(d).length}return l}function Au(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:Ua(e,n.startContainer,n.startOffset),end:Ua(e,n.endContainer,n.endOffset)}}function Wa(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Lt(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 Mu(e,r){const n=Wa(e,r.start),a=Wa(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 _u(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}Fr();yt();function $u({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:Qe("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 Du=dr("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 Bu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:Qe(Du({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 Gu=dr("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 kt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(ir,{type:r,"data-size":a,variant:n,className:Qe(Gu({size:a}),e),...o})}function Fu({className:e,...r}){return t.jsx("span",{className:Qe("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function Hu({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 Ou({activeView:e,followTail:r,onToggleFollow:n}){return e!=="chat"?null:t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest turn is in view":"Jump to the latest messages",onClick:()=>n==null?void 0:n(),className:"absolute left-1/2 top-3 z-40 inline-flex h-9 min-w-[5.75rem] -translate-x-1/2 -translate-y-[62%] items-start justify-center bg-transparent pt-1 touch-manipulation sm:top-4",children:t.jsx("span",{className:`thread-jump-latest-badge pointer-events-none inline-flex h-4 min-w-[3.75rem] items-center justify-center 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("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 6 4 4 4-4"})})})})}function Uu({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:p,formRef:m,promptSlot:f,toolbarSlot:g,goalSlot:x,shellPromptSlot:k}){return t.jsxs("div",{className:r,children:[t.jsx(Hu,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(Ou,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:m,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:p,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-hidden rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs($u,{className:o,children:[f,g]}),x,k]}),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 Wu({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{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(fu,{})}),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"})]})})]})}function Vu({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,planModeAvailable:d,settingsBusy:h,goalComposeMode:u,goalBusy:p,activeView:m,disabled:f,fastMode:g,sendButtonLabel:x,sendButtonClassName:k,modelControlsDisabled:b,effortControlsDisabled:y,effortControlTitle:w,inlineToggleClassName:v,menuItemClassName:N,planToggleActiveClassName:j,sendButtonBaseClassName:S,onSetOpenMenu:P,onUpdateSettings:C}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:b||n.length===0,onClick:()=>P(F=>F==="model"?null:"model"),title:g?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${v} 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(Tu,{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(F=>t.jsx("button",{type:"button",onClick:()=>C({model:F.model,reasoningEffort:F.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${F.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:F.model})},F.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>P(F=>F==="effort"?null:"effort"),title:w,className:`${v} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ga(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(F=>t.jsx("button",{type:"button",onClick:()=>C({reasoningEffort:F.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${F.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ga(F.reasoningEffort)})},F.reasoningEffort))})})]}),d&&t.jsx(kt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:h,onClick:()=>C({collaborationMode:i==="plan"?"default":"plan"}),className:`${v} rounded-full px-2.5 ${i==="plan"?j:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(kt,{type:"submit",variant:"default",size:"icon-xs","aria-label":u?"Set goal":"Send Prompt",title:x,disabled:p||(m==="chat"?f:!1),className:`${S} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${k}`,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 qu({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(Ln,{}),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(Ln,{}),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(Tt,{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(Tt,{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(Tt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"DOWN"})})]})})}function Ku({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 Xu({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 Yu({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:p,hookTimeoutSec:m,hookStatusMessage:f,composerChipButtonClassName:g,onResetHookForm:x,onSetHooksPanelMode:k,onClearHookConfigStatus:b,onSetEditingHookTarget:y,onSetHookScope:w,onSetHookEventName:v,onSetHookMatcher:N,onSetHookCommand:j,onSetHookTimeoutSec:S,onSetHookStatusMessage:P,onSaveHook:C,onStartEditingHook:F,onTrustHook:H,onUntrustHook:M}){var Q,V,W,Z,de;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:((Q=r.data)==null?void 0:Q.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:E=>{E.stopPropagation(),x(),k("add"),b()},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"," ",Nu((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:E=>w(E.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:E=>v(E.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:Rr.map(E=>t.jsx("option",{value:E.value,children:E.label},E.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:E=>N(E.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:p,onChange:E=>j(E.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:m,onChange:E=>S(E.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:f,onChange:E=>P(E.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"),y(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 C(),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"&&((V=r.data)!=null&&V.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(E=>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:E},E))}):null,e==="list"&&((W=r.data)!=null&&W.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(E=>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:E.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:E.path})]},`${E.path}:${E.message}`))}):null,e==="list"&&((Z=r.data)!=null&&Z.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(E=>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:[wu(E.eventName),E.matcher?` · ${E.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:E.command??E.handlerType}),E.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:E.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:[Oo(E)?t.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),F(E)},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&&E.trustStatus==="trusted"&&!E.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:J=>{J.stopPropagation(),M(E)},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,(E.trustStatus==="untrusted"||E.trustStatus==="modified")&&!E.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!E.currentHash,onClick:J=>{J.stopPropagation(),H(E)},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:ju(E.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:yu(E.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:E.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[E.timeoutSec,"s"]})]})]},E.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((de=r.data)==null?void 0:de.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 Zu({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:p,onSetMcpPanelMode:m,onClearMcpConfigStatus:f,onSetMcpHttpName:g,onSetMcpHttpUrl:x,onSetMcpRawBlock:k,onPrepareRawMcpBlock:b,onSaveHttpMcp:y,onSaveRawMcpBlock:w}){var v,N;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:j=>{j.stopPropagation(),m("add"),f()},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:j=>{j.stopPropagation(),m("http"),f()},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:j=>{j.stopPropagation(),b()},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:j=>g(j.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:j=>x(j.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:()=>m("add"),className:`${p} 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 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:j=>k(j.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:()=>m("add"),className:`${p} 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"&&((v=r.data)!=null&&v.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(j=>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:j.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[j.tools.length," tools · ",j.resourceCount," ","resources · ",j.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:vu(j.authStatus)})]}),j.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:j.tools.slice(0,4).map(S=>S.title??S.name).join(" · ")}):null]},j.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((N=r.data)==null?void 0:N.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 Ju({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:ku(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(Ln,{}),"$",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 Qu({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:p,hookConfigBusy:m,hookConfigError:f,hookConfigSuccess:g,editingHookTarget:x,hookScope:k,hookEventName:b,hookMatcher:y,hookCommand:w,hookTimeoutSec:v,hookStatusMessage:N,mcpPanelMode:j,mcpState:S,mcpConfigEditing:P,mcpConfigPath:C,mcpConfigError:F,mcpConfigSuccess:H,mcpConfigBusy:M,mcpHttpName:Q,mcpHttpUrl:V,mcpRawBlock:W,iconButtonClassName:Z,menuClassName:de,menuItemClassName:E,panelButtonClassName:J,chipButtonClassName:A,onToggle:X,onToolboxItemClick:O,toolboxItemDisabled:I,toolboxItemClassName:K,toolboxItemStatus:B,onSetSlashPanelView:T,onOpenForkTurns:z,onForkLatest:Y,onForkTurn:$,onCopySkillInvokeName:q,onResetHookForm:G,onSetHooksPanelMode:ce,onClearHookConfigStatus:ee,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:ge,onSetHookMatcher:Le,onSetHookCommand:re,onSetHookTimeoutSec:be,onSetHookStatusMessage:je,onSaveHook:xe,onStartEditingHook:ze,onTrustHook:R,onUntrustHook:te,onSetMcpPanelMode:ve,onClearMcpConfigStatus:fe,onSetMcpHttpName:pe,onSetMcpHttpUrl:Ie,onSetMcpRawBlock:D,onPrepareRawMcpBlock:ae,onSaveHttpMcp:ye,onSaveRawMcpBlock:ke}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:X,className:`${Z} 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:`${de} 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:we=>{we.stopPropagation()},onMouseDown:we=>{we.stopPropagation()},onPointerDown:we=>{we.stopPropagation()},onTouchStart:we=>{we.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((we,Te)=>t.jsx("button",{type:"button",disabled:I(we),onClick:De=>O(we,De),className:`${K(we)} ${Te===0?"mt-0":""}`,title:we.description??we.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:we.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:B(we)})]})},`${we.action}:${we.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==="fork"?t.jsx(Ku,{busy:a,forkBusy:o,composerMenuItemClassName:E,onForkLatest:Y,onSelectForkTurnPanel:()=>(T("forkTurns"),z())}):r==="forkTurns"?t.jsx(Xu,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:J,onForkTurn:$}):r==="skills"?t.jsx(Ju,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:A,onCopySkillInvokeName:q}):r==="hooks"?t.jsx(Yu,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:p,hookConfigBusy:m,hookConfigError:f,hookConfigSuccess:g,editingHookTarget:x,hookScope:k,hookEventName:b,hookMatcher:y,hookCommand:w,hookTimeoutSec:v,hookStatusMessage:N,composerChipButtonClassName:A,onResetHookForm:G,onSetHooksPanelMode:ce,onClearHookConfigStatus:ee,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:ge,onSetHookMatcher:Le,onSetHookCommand:re,onSetHookTimeoutSec:be,onSetHookStatusMessage:je,onSaveHook:xe,onStartEditingHook:ze,onTrustHook:R,onUntrustHook:te}):t.jsx(Zu,{mcpPanelMode:j,mcpState:S,mcpConfigEditing:P,mcpConfigPath:C,mcpConfigError:F,mcpConfigSuccess:H,mcpConfigBusy:M,mcpHttpName:Q,mcpHttpUrl:V,mcpRawBlock:W,composerPanelButtonClassName:J,composerChipButtonClassName:A,onSetMcpPanelMode:ve,onClearMcpConfigStatus:fe,onSetMcpHttpName:pe,onSetMcpHttpUrl:Ie,onSetMcpRawBlock:D,onPrepareRawMcpBlock:ae,onSaveHttpMcp:ye,onSaveRawMcpBlock:ke})})})]})}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:p,onDismissPromptFocus:m,onSetOpenMenu:f}){return t.jsxs(Bu,{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(Qu,{...i}):null,!e&&d?t.jsx(Wu,{...d}):null,r&&t.jsx(kt,{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:()=>p==null?void 0:p(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(xu,{}):t.jsx(pu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(Vu,{...h}):null,e&&a?t.jsx(Fu,{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:()=>{m(),f(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(qu,{...u}):null]})]})]})}function tm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function rm(e){return[...e.filter(r=>Tn(r)==="photo"),...e.filter(r=>Tn(r)==="file")]}function nm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=tm}){const h=c.useCallback((m,f)=>{if(m.length===0)return!1;const g=Zh({prompt:e,attachments:r,files:m,selection:a()??o.current,kindForFile:f,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((m,f)=>!m||m.length===0?!1:h(Array.from(m),()=>f),[h]),p=c.useCallback(m=>h(rm(m),Tn),[h]);return{appendAttachments:u,appendDroppedAttachments:p}}function Va(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function am({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){Va(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()=>{Va(s)}},[]),a}var sm=180;function cn(e,r){return{prompt:e??"",attachments:r??[]}}function om({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>cn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(vr(l)),p=!e&&r!==void 0&&n!==void 0&&typeof a=="function",m=p?vr(cn(r,n)):"",f=c.useRef(m);c.useLayoutEffect(()=>{if(!p){f.current="";return}const w=cn(r,n),v=vr(w);v!==f.current&&(f.current=v,u.current=v,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,p]);const g=c.useCallback(w=>{if(!p||!a)return;const v=vr(w);v!==u.current&&(u.current=v,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[p,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const x=c.useCallback((w,v)=>{if(p){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),v==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},sm)}},[p,g]),k=c.useCallback((w=h.current)=>{x(w,"immediate")},[x]),b=c.useCallback((w,v="immediate")=>{if(p){const N=w(h.current);h.current=N,i(N),x(N,v);return}s(N=>w(N))},[p,x]),y=p?l:o;return{prompt:y.prompt,attachments:y.attachments,isDraftControlled:p,updateDraft:b,flushControlledDraftToHost:k}}function lm({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 im({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onUpdateGoal:o,updateDraft:s,closeMenu:l,resetSlashPanel:i}){const[d,h]=c.useState(!1),[u,p]=c.useState(""),[m,f]=c.useState(!1),[g,x]=c.useState(null),k=c.useCallback(async()=>{const w=e.trim();if(!w)return x("Goal objective cannot be empty."),!1;const v=u.trim(),N=nu(v);if(v.length>0&&(N===null||!Number.isInteger(N)||N<=0))return x("Token budget must be a positive number in thousands."),!1;if(!o)return x("/goal is unavailable in this view."),!1;f(!0),x(null);try{return await o({objective:w,status:"active",tokenBudget:N}),p(""),h(!1),s(()=>({prompt:"",attachments:[]})),!0}catch(j){return x(j instanceof Error?j.message:"Unable to set goal."),!1}finally{f(!1)}},[u,o,e,s]),b=c.useCallback(()=>{l(),i(),h(!0),p(au(r==null?void 0:r.tokenBudget)),x(null),a==null||a(),requestAnimationFrame(()=>{var w;(w=n.current)==null||w.focus()})},[l,r==null?void 0:r.tokenBudget,a,n,i]),y=c.useCallback(()=>{h(!1),x(null)},[]);return{goalComposeMode:d,goalTokenBudget:u,goalBusy:m,goalLocalError:g,setGoalTokenBudget:p,submitGoal:k,enterGoalComposeMode:b,exitGoalComposeMode:y}}var hn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function dm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function cm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,p]=c.useState("preToolUse"),[m,f]=c.useState("Bash"),[g,x]=c.useState(hn),[k,b]=c.useState("30"),[y,w]=c.useState("Running hook"),[v,N]=c.useState(null),[j,S]=c.useState(!1),[P,C]=c.useState(null),[F,H]=c.useState(null),M=c.useMemo(()=>dm(r),[r]),Q=c.useCallback(X=>M.get(X)??M.get("preToolUse")??hn,[M]),V=c.useMemo(()=>new Set([hn,...M.values()]),[M]),W=c.useCallback(()=>{C(null),H(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),W())},[W,e]),c.useEffect(()=>{const X=Rr.find(O=>O.value===u);f(O=>{const I=O.trim(),K=new Set(Rr.map(B=>B.matcherHint).filter(Boolean));return I&&!K.has(I)?O:(X==null?void 0:X.matcherHint)??""}),x(O=>V.has(O.trim())?Q(u):O)},[Q,V,u]);const Z=c.useCallback(()=>{N(null),h("project"),p("preToolUse"),f("Bash"),x(Q("preToolUse")),b("30"),w("Running hook")},[Q]),de=c.useCallback(X=>{const O=Oo(X);if(!O){C("Only command hooks in global or project hooks.json can be edited here.");return}N(O),h(O.scope),p(O.eventName),f(O.matcher??""),x(O.command),b(O.timeoutSec?String(O.timeoutSec):""),w(O.statusMessage??""),C(null),H(null),i("edit")},[]),E=c.useCallback(async()=>{if(l==="edit"&&!a){C("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){C("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){C("Select a hook to edit first.");return}const X=g.trim();if(!X){C("Hook command cannot be empty.");return}const O=k.trim(),I=O?Number(O):null;if(O&&(I===null||!Number.isInteger(I)||I<=0)){C("Timeout must be a positive number of seconds.");return}S(!0),C(null),H(null);try{const K={scope:d,eventName:u,matcher:m.trim()||null,command:X,timeoutSec:I,statusMessage:y.trim()||null};l==="edit"?await(a==null?void 0:a({...K,target:v})):await(n==null?void 0:n(K)),H(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),N(null)}catch(K){C(K instanceof Error?K.message:"Unable to write hooks.json.")}finally{S(!1)}},[v,g,u,m,d,y,k,l,n,a]),J=c.useCallback(async X=>{if(!o||!X.currentHash){C("Hook trust is unavailable in this view.");return}S(!0),C(null),H(null);try{await o({key:X.key,currentHash:X.currentHash}),H("Hook trusted.")}catch(O){C(O instanceof Error?O.message:"Unable to trust hook.")}finally{S(!1)}},[o]),A=c.useCallback(async X=>{if(!s){C("Hook trust is unavailable in this view.");return}S(!0),C(null),H(null);try{await s({key:X.key}),H("Hook untrusted.")}catch(O){C(O instanceof Error?O.message:"Unable to untrust hook.")}finally{S(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:m,hookCommand:g,hookTimeoutSec:k,hookStatusMessage:y,editingHookTarget:v,hookConfigBusy:j,hookConfigError:P,hookConfigSuccess:F,setHooksPanelMode:i,setEditingHookTarget:N,setHookScope:h,setHookEventName:p,setHookMatcher:f,setHookCommand:x,setHookTimeoutSec:b,setHookStatusMessage:w,clearHookConfigStatus:W,resetHookForm:Z,startEditingHook:de,saveHook:E,trustHook:J,untrustHook:A}}var hm=`[mcp_servers.example_stdio]
3590
+ ${o}`:o}function Ho(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function dn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function iu(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,`${dn(n)} used / ${dn(a)}`,`${dn(o)} left`,`${Ho(r.remainingPercent)}% context left`].join(" · ")}function du(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 cu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Tn(e){return e.type.startsWith("image/")?"photo":"file"}function En(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 Ha(e,r){return En(e,r).length>0}function hu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Oa(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:hu(e.originalName)}var Rr=[{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 uu({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",p=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",m=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:p,modelControlsDisabled:m,effortControlsDisabled:m||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 pu(){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 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.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 xu(){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 Ln(){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 vu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function ku(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function wu(e){var r;return((r=Rr.find(n=>n.value===e))==null?void 0:r.label)??e}function yu(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 ju(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Nu(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 Cu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Oo(e){const r=Cu(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 Su(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Tu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Ho(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 Tt({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 Eu(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};default:return{type:"noop"}}}function Lu(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?Su(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";default:return""}}function Pu(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;default:return!1}}function Iu(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 zu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Ru(e){return!!e.querySelector("[style], font")}function Lt(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Uo(e){let r="";for(const n of Array.from(e.childNodes))r+=Lt(n);return r.replace(/\u00a0/g," ")}function Ua(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 p=d[u];p&&(h+=Lt(p).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 Uo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Lt(d).length;try{h.setEnd(r,n);const p=h.toString().length,m=((i=d.textContent)==null?void 0:i.length)??0;m===0?o=u:o=Math.round(Math.min(1,p/m)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Lt(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,Lt(d).length);l+=Lt(d).length}return l}function Au(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:Ua(e,n.startContainer,n.startOffset),end:Ua(e,n.endContainer,n.endOffset)}}function Wa(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Lt(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 Mu(e,r){const n=Wa(e,r.start),a=Wa(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 _u(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}Fr();yt();function $u({className:e,...r}){return t.jsx("div",{"data-slot":"input-group",role:"group",className:Qe("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 Du=dr("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 Bu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:Qe(Du({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 Gu=dr("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 kt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(ir,{type:r,"data-size":a,variant:n,className:Qe(Gu({size:a}),e),...o})}function Fu({className:e,...r}){return t.jsx("span",{className:Qe("flex items-center gap-2 text-sm [&_svg]:pointer-events-none [&_svg:not([class*=size-])]:size-4",e),...r})}function Hu({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 Ou({activeView:e,followTail:r,onToggleFollow:n}){return e!=="chat"?null:t.jsx("button",{type:"button","aria-label":"Jump to latest",title:r?"Latest turn is in view":"Jump to the latest messages",onClick:()=>n==null?void 0:n(),className:"absolute left-1/2 top-3 z-40 inline-flex h-9 min-w-[5.75rem] -translate-x-1/2 -translate-y-[62%] items-start justify-center bg-transparent pt-1 touch-manipulation sm:top-4",children:t.jsx("span",{className:`thread-jump-latest-badge pointer-events-none inline-flex h-4 min-w-[3.75rem] items-center justify-center 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("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 6 4 4 4-4"})})})})}function Uu({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:p,formRef:m,promptSlot:f,toolbarSlot:g,goalSlot:x,shellPromptSlot:k}){return t.jsxs("div",{className:r,children:[t.jsx(Hu,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(Ou,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:m,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:p,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-hidden rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs($u,{className:o,children:[f,g]}),x,k]}),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 Wu({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{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(fu,{})}),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"})]})})]})}function Vu({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,planModeAvailable:d,settingsBusy:h,goalComposeMode:u,goalBusy:p,activeView:m,disabled:f,fastMode:g,sendButtonLabel:x,sendButtonClassName:k,modelControlsDisabled:b,effortControlsDisabled:y,effortControlTitle:w,inlineToggleClassName:v,menuItemClassName:N,planToggleActiveClassName:j,sendButtonBaseClassName:S,onSetOpenMenu:L,onUpdateSettings:C}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:b||n.length===0,onClick:()=>L(H=>H==="model"?null:"model"),title:g?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${v} 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(Tu,{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(H=>t.jsx("button",{type:"button",onClick:()=>C({model:H.model,reasoningEffort:H.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${H.model===r?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:H.model})},H.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:y,onClick:()=>L(H=>H==="effort"?null:"effort"),title:w,className:`${v} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${y?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ga(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(H=>t.jsx("button",{type:"button",onClick:()=>C({reasoningEffort:H.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${H.reasoningEffort===s?"ui-status-warning":`${N} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ga(H.reasoningEffort)})},H.reasoningEffort))})})]}),d&&t.jsx(kt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:h,onClick:()=>C({collaborationMode:i==="plan"?"default":"plan"}),className:`${v} rounded-full px-2.5 ${i==="plan"?j:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(kt,{type:"submit",variant:"default",size:"icon-xs","aria-label":u?"Set goal":"Send Prompt",title:x,disabled:p||(m==="chat"?f:!1),className:`${S} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${k}`,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 qu({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(Ln,{}),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(Ln,{}),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(Tt,{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(Tt,{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(Tt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Tt,{label:"DOWN"})})]})})}function Ku({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 Xu({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 Yu({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:p,hookTimeoutSec:m,hookStatusMessage:f,composerChipButtonClassName:g,onResetHookForm:x,onSetHooksPanelMode:k,onClearHookConfigStatus:b,onSetEditingHookTarget:y,onSetHookScope:w,onSetHookEventName:v,onSetHookMatcher:N,onSetHookCommand:j,onSetHookTimeoutSec:S,onSetHookStatusMessage:L,onSaveHook:C,onStartEditingHook:H,onTrustHook:O,onUntrustHook:M}){var Q,V,W,Z,de;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:((Q=r.data)==null?void 0:Q.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),x(),k("add"),b()},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"," ",Nu((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=>v(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:Rr.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=>N(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:p,onChange:T=>j(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:m,onChange:T=>S(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:f,onChange:T=>L(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"),y(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 C(),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"&&((V=r.data)!=null&&V.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"&&((W=r.data)!=null&&W.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"&&((Z=r.data)!=null&&Z.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:[wu(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:[Oo(T)?t.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),H(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:J=>{J.stopPropagation(),M(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:J=>{J.stopPropagation(),O(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:ju(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:yu(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&&(((de=r.data)==null?void 0:de.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 Zu({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:p,onSetMcpPanelMode:m,onClearMcpConfigStatus:f,onSetMcpHttpName:g,onSetMcpHttpUrl:x,onSetMcpRawBlock:k,onPrepareRawMcpBlock:b,onSaveHttpMcp:y,onSaveRawMcpBlock:w}){var v,N;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:j=>{j.stopPropagation(),m("add"),f()},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:j=>{j.stopPropagation(),m("http"),f()},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:j=>{j.stopPropagation(),b()},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:j=>g(j.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:j=>x(j.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:()=>m("add"),className:`${p} 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 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:j=>k(j.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:()=>m("add"),className:`${p} 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"&&((v=r.data)!=null&&v.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(j=>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:j.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[j.tools.length," tools · ",j.resourceCount," ","resources · ",j.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:vu(j.authStatus)})]}),j.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:j.tools.slice(0,4).map(S=>S.title??S.name).join(" · ")}):null]},j.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((N=r.data)==null?void 0:N.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 Ju({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:ku(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(Ln,{}),"$",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 Qu({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:p,hookConfigBusy:m,hookConfigError:f,hookConfigSuccess:g,editingHookTarget:x,hookScope:k,hookEventName:b,hookMatcher:y,hookCommand:w,hookTimeoutSec:v,hookStatusMessage:N,mcpPanelMode:j,mcpState:S,mcpConfigEditing:L,mcpConfigPath:C,mcpConfigError:H,mcpConfigSuccess:O,mcpConfigBusy:M,mcpHttpName:Q,mcpHttpUrl:V,mcpRawBlock:W,iconButtonClassName:Z,menuClassName:de,menuItemClassName:T,panelButtonClassName:J,chipButtonClassName:A,onToggle:Y,onToolboxItemClick:F,toolboxItemDisabled:I,toolboxItemClassName:K,toolboxItemStatus:D,onSetSlashPanelView:P,onOpenForkTurns:z,onForkLatest:X,onForkTurn:_,onCopySkillInvokeName:q,onResetHookForm:G,onSetHooksPanelMode:ce,onClearHookConfigStatus:ee,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:ge,onSetHookMatcher:Le,onSetHookCommand:re,onSetHookTimeoutSec:be,onSetHookStatusMessage:je,onSaveHook:xe,onStartEditingHook:ze,onTrustHook:R,onUntrustHook:te,onSetMcpPanelMode:ve,onClearMcpConfigStatus:fe,onSetMcpHttpName:pe,onSetMcpHttpUrl:Ie,onSetMcpRawBlock:B,onPrepareRawMcpBlock:ae,onSaveHttpMcp:ye,onSaveRawMcpBlock:ke}){return t.jsxs("div",{className:"relative",children:[t.jsx(kt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:Y,className:`${Z} 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:`${de} 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:we=>{we.stopPropagation()},onMouseDown:we=>{we.stopPropagation()},onPointerDown:we=>{we.stopPropagation()},onTouchStart:we=>{we.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((we,Te)=>t.jsx("button",{type:"button",disabled:I(we),onClick:De=>F(we,De),className:`${K(we)} ${Te===0?"mt-0":""}`,title:we.description??we.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:we.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:D(we)})]})},`${we.action}:${we.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==="fork"?t.jsx(Ku,{busy:a,forkBusy:o,composerMenuItemClassName:T,onForkLatest:X,onSelectForkTurnPanel:()=>(P("forkTurns"),z())}):r==="forkTurns"?t.jsx(Xu,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:J,onForkTurn:_}):r==="skills"?t.jsx(Ju,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:A,onCopySkillInvokeName:q}):r==="hooks"?t.jsx(Yu,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:p,hookConfigBusy:m,hookConfigError:f,hookConfigSuccess:g,editingHookTarget:x,hookScope:k,hookEventName:b,hookMatcher:y,hookCommand:w,hookTimeoutSec:v,hookStatusMessage:N,composerChipButtonClassName:A,onResetHookForm:G,onSetHooksPanelMode:ce,onClearHookConfigStatus:ee,onSetEditingHookTarget:ie,onSetHookScope:ue,onSetHookEventName:ge,onSetHookMatcher:Le,onSetHookCommand:re,onSetHookTimeoutSec:be,onSetHookStatusMessage:je,onSaveHook:xe,onStartEditingHook:ze,onTrustHook:R,onUntrustHook:te}):t.jsx(Zu,{mcpPanelMode:j,mcpState:S,mcpConfigEditing:L,mcpConfigPath:C,mcpConfigError:H,mcpConfigSuccess:O,mcpConfigBusy:M,mcpHttpName:Q,mcpHttpUrl:V,mcpRawBlock:W,composerPanelButtonClassName:J,composerChipButtonClassName:A,onSetMcpPanelMode:ve,onClearMcpConfigStatus:fe,onSetMcpHttpName:pe,onSetMcpHttpUrl:Ie,onSetMcpRawBlock:B,onPrepareRawMcpBlock:ae,onSaveHttpMcp:ye,onSaveRawMcpBlock:ke})})})]})}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:p,onDismissPromptFocus:m,onSetOpenMenu:f}){return t.jsxs(Bu,{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(Qu,{...i}):null,!e&&d?t.jsx(Wu,{...d}):null,r&&t.jsx(kt,{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:()=>p==null?void 0:p(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(xu,{}):t.jsx(pu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(Vu,{...h}):null,e&&a?t.jsx(Fu,{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:()=>{m(),f(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(qu,{...u}):null]})]})]})}function tm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function rm(e){return[...e.filter(r=>Tn(r)==="photo"),...e.filter(r=>Tn(r)==="file")]}function nm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=tm}){const h=c.useCallback((m,f)=>{if(m.length===0)return!1;const g=Zh({prompt:e,attachments:r,files:m,selection:a()??o.current,kindForFile:f,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((m,f)=>!m||m.length===0?!1:h(Array.from(m),()=>f),[h]),p=c.useCallback(m=>h(rm(m),Tn),[h]);return{appendAttachments:u,appendDroppedAttachments:p}}function Va(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function am({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){Va(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()=>{Va(s)}},[]),a}var sm=180;function cn(e,r){return{prompt:e??"",attachments:r??[]}}function om({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>cn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(vr(l)),p=!e&&r!==void 0&&n!==void 0&&typeof a=="function",m=p?vr(cn(r,n)):"",f=c.useRef(m);c.useLayoutEffect(()=>{if(!p){f.current="";return}const w=cn(r,n),v=vr(w);v!==f.current&&(f.current=v,u.current=v,h.current=w,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(w))},[n,r,p]);const g=c.useCallback(w=>{if(!p||!a)return;const v=vr(w);v!==u.current&&(u.current=v,a(()=>({prompt:w.prompt,attachments:w.attachments})))},[p,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const x=c.useCallback((w,v)=>{if(p){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),v==="immediate"){g(w);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},sm)}},[p,g]),k=c.useCallback((w=h.current)=>{x(w,"immediate")},[x]),b=c.useCallback((w,v="immediate")=>{if(p){const N=w(h.current);h.current=N,i(N),x(N,v);return}s(N=>w(N))},[p,x]),y=p?l:o;return{prompt:y.prompt,attachments:y.attachments,isDraftControlled:p,updateDraft:b,flushControlledDraftToHost:k}}function lm({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 im({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onUpdateGoal:o,updateDraft:s,closeMenu:l,resetSlashPanel:i}){const[d,h]=c.useState(!1),[u,p]=c.useState(""),[m,f]=c.useState(!1),[g,x]=c.useState(null),k=c.useCallback(async()=>{const w=e.trim();if(!w)return x("Goal objective cannot be empty."),!1;const v=u.trim(),N=nu(v);if(v.length>0&&(N===null||!Number.isInteger(N)||N<=0))return x("Token budget must be a positive number in thousands."),!1;if(!o)return x("/goal is unavailable in this view."),!1;f(!0),x(null);try{return await o({objective:w,status:"active",tokenBudget:N}),p(""),h(!1),s(()=>({prompt:"",attachments:[]})),!0}catch(j){return x(j instanceof Error?j.message:"Unable to set goal."),!1}finally{f(!1)}},[u,o,e,s]),b=c.useCallback(()=>{l(),i(),h(!0),p(au(r==null?void 0:r.tokenBudget)),x(null),a==null||a(),requestAnimationFrame(()=>{var w;(w=n.current)==null||w.focus()})},[l,r==null?void 0:r.tokenBudget,a,n,i]),y=c.useCallback(()=>{h(!1),x(null)},[]);return{goalComposeMode:d,goalTokenBudget:u,goalBusy:m,goalLocalError:g,setGoalTokenBudget:p,submitGoal:k,enterGoalComposeMode:b,exitGoalComposeMode:y}}var hn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function dm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function cm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,p]=c.useState("preToolUse"),[m,f]=c.useState("Bash"),[g,x]=c.useState(hn),[k,b]=c.useState("30"),[y,w]=c.useState("Running hook"),[v,N]=c.useState(null),[j,S]=c.useState(!1),[L,C]=c.useState(null),[H,O]=c.useState(null),M=c.useMemo(()=>dm(r),[r]),Q=c.useCallback(Y=>M.get(Y)??M.get("preToolUse")??hn,[M]),V=c.useMemo(()=>new Set([hn,...M.values()]),[M]),W=c.useCallback(()=>{C(null),O(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),W())},[W,e]),c.useEffect(()=>{const Y=Rr.find(F=>F.value===u);f(F=>{const I=F.trim(),K=new Set(Rr.map(D=>D.matcherHint).filter(Boolean));return I&&!K.has(I)?F:(Y==null?void 0:Y.matcherHint)??""}),x(F=>V.has(F.trim())?Q(u):F)},[Q,V,u]);const Z=c.useCallback(()=>{N(null),h("project"),p("preToolUse"),f("Bash"),x(Q("preToolUse")),b("30"),w("Running hook")},[Q]),de=c.useCallback(Y=>{const F=Oo(Y);if(!F){C("Only command hooks in global or project hooks.json can be edited here.");return}N(F),h(F.scope),p(F.eventName),f(F.matcher??""),x(F.command),b(F.timeoutSec?String(F.timeoutSec):""),w(F.statusMessage??""),C(null),O(null),i("edit")},[]),T=c.useCallback(async()=>{if(l==="edit"&&!a){C("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){C("Hook editing is unavailable in this view.");return}if(l==="edit"&&!v){C("Select a hook to edit first.");return}const Y=g.trim();if(!Y){C("Hook command cannot be empty.");return}const F=k.trim(),I=F?Number(F):null;if(F&&(I===null||!Number.isInteger(I)||I<=0)){C("Timeout must be a positive number of seconds.");return}S(!0),C(null),O(null);try{const K={scope:d,eventName:u,matcher:m.trim()||null,command:Y,timeoutSec:I,statusMessage:y.trim()||null};l==="edit"?await(a==null?void 0:a({...K,target:v})):await(n==null?void 0:n(K)),O(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),N(null)}catch(K){C(K instanceof Error?K.message:"Unable to write hooks.json.")}finally{S(!1)}},[v,g,u,m,d,y,k,l,n,a]),J=c.useCallback(async Y=>{if(!o||!Y.currentHash){C("Hook trust is unavailable in this view.");return}S(!0),C(null),O(null);try{await o({key:Y.key,currentHash:Y.currentHash}),O("Hook trusted.")}catch(F){C(F instanceof Error?F.message:"Unable to trust hook.")}finally{S(!1)}},[o]),A=c.useCallback(async Y=>{if(!s){C("Hook trust is unavailable in this view.");return}S(!0),C(null),O(null);try{await s({key:Y.key}),O("Hook untrusted.")}catch(F){C(F instanceof Error?F.message:"Unable to untrust hook.")}finally{S(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:m,hookCommand:g,hookTimeoutSec:k,hookStatusMessage:y,editingHookTarget:v,hookConfigBusy:j,hookConfigError:L,hookConfigSuccess:H,setHooksPanelMode:i,setEditingHookTarget:N,setHookScope:h,setHookEventName:p,setHookMatcher:f,setHookCommand:x,setHookTimeoutSec:b,setHookStatusMessage:w,clearHookConfigStatus:W,resetHookForm:Z,startEditingHook:de,saveHook:T,trustHook:J,untrustHook:A}}var hm=`[mcp_servers.example_stdio]
3591
3591
  command = "npx"
3592
3592
  args = ["-y", "your-mcp-server"]
3593
- `,qa="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function um({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[p,m]=c.useState(null),[f,g]=c.useState(!1),[x,k]=c.useState(null),[b,y]=c.useState(null),w=c.useCallback(()=>{k(null),y(null)},[]),v=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const C=await r();return m(C.path),C},[e,r]),N=c.useCallback(async C=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const F=await n(C);return m(F.path),F},[e,n]),j=c.useCallback(async()=>{const C=su(s),F=i.trim();if(!C){k("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(F)){k("HTTP MCP URL must start with http:// or https://");return}g(!0),k(null),y(null);try{const H=await v(),M=Fa(H.content,C,lu(C,F));await N(M),y(qa),a("list"),l(""),d(""),o==null||o()}catch(H){k(H instanceof Error?H.message:"Unable to update provider config.")}finally{g(!1)}},[v,s,i,o,a,N]),S=c.useCallback(async()=>{g(!0),k(null),y(null);try{await v(),u(C=>C||hm),a("stdio")}catch(C){k(C instanceof Error?C.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),P=c.useCallback(async()=>{const C=ou(h);if(!C){k("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),k(null),y(null);try{const F=await v(),H=Fa(F.content,C,h);await N(H),y(qa),a("list"),o==null||o()}catch(F){k(F instanceof Error?F.message:"Unable to update provider config.")}finally{g(!1)}},[v,h,o,a,N]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:p,mcpConfigBusy:f,mcpConfigError:x,mcpConfigSuccess:b,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:w,prepareRawMcpBlock:S,saveHttpMcp:j,saveRawMcpBlock:P}}function mm({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(p=>p===i?null:p)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(p){(typeof p.composedPath=="function"?p.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 pm(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=Oa(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=Oa(n),a.append(o,s),a}function fm(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(pm(a,r))}return n}function gm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:p,serializeEditorPrompt:m,restoreSelection:f}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const x=i.current,k=m()!==n||u.current!==s||p.current!==l;k&&(g.replaceChildren(fm(a,o)),u.current=s,p.current=l),x!==null?(g.focus(),_u(g,d.current)||f(x),h.current=x):document.activeElement===g&&k&&f(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,p,f,h,m])}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 bm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:p,onKeyUp:m,onMouseUp:f,onBlur:g,onDragEnter:x,onDragOver:k,onDragLeave:b,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,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:p,onKeyUp:m,onMouseUp:f,onBlur:g,onDragEnter:x,onDragOver:k,onDragLeave:b,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(kt,{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 vm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:p}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:m=>h(m.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(p==null?void 0:p()),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:m=>{m.preventDefault()},onPointerDown:m=>{m.preventDefault()},onTouchStart:m=>{m.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 km({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:p,goalLocalError:m,goalBusy:f,busy:g,sendButtonLabel:x,sendButtonClassName:k,onInterrupt:b,onPromptInput:y,onPromptPaste:w,onPromptKeyDown:v,onPromptKeyUp:N,onPromptMouseUp:j,onPromptBlur:S,onPromptDragEnter:P,onPromptDragOver:C,onPromptDragLeave:F,onPromptDrop:H,onGoalTokenBudgetChange:M,onCancelGoal:Q,onShellPromptChange:V}){return{promptSlot:e?null:t.jsx(bm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:b,onInput:y,onPaste:w,onKeyDown:v,onKeyUp:N,onMouseUp:j,onBlur:S,onDragEnter:P,onDragOver:C,onDragLeave:F,onDrop:H}),goalSlot:u&&!e?t.jsx(xm,{tokenBudget:p,error:m,onTokenBudgetChange:M,onCancel:Q}):null,shellPromptSlot:e?t.jsx(vm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:x,sendButtonClassName:k,sendDisabled:f||g,onPromptChange:V,onPromptKeyDown:v,onInterrupt:b}):null}}function wm({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=ru({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:p,planToggleActiveClassName:m,sendButtonBaseClassName:f,slashPanelView:g,availableToolboxItems:x,busy:k,settingsBusy:b,compactBusy:y,forkBusy:w,fastMode:v,goalComposeMode:N,goalBusy:j,goalStatus:S,activeView:P,disabled:C,model:F,modelOptions:H,modelContextTitle:M,contextUsage:Q,reasoningEffort:V,supportedEfforts:W,displayedCollaborationMode:Z,sendButtonLabel:de,sendButtonClassName:E,modelControlsDisabled:J,effortControlsDisabled:A,effortControlTitle:X,forkTurnOptionsState:O,skillsState:I,copiedSkillName:K,hooksPanelMode:B,hooksState:T,hookConfigBusy:z,hookConfigError:Y,hookConfigSuccess:$,editingHookTarget:q,hookScope:G,hookEventName:ce,hookMatcher:ee,hookCommand:ie,hookTimeoutSec:ue,hookStatusMessage:ge,mcpPanelMode:Le,mcpState:re,mcpConfigPath:be,mcpConfigError:je,mcpConfigSuccess:xe,mcpConfigBusy:ze,mcpHttpName:R,mcpHttpUrl:te,mcpRawBlock:ve,capabilities:fe,shellControlState:pe,onToggleView:Ie,onDismissPromptFocus:D,onSetOpenMenu:ae,onToolboxItemClick:ye,onSetSlashPanelView:ke,onOpenForkTurns:we,onForkLatest:Te,onForkTurn:De,onCopySkillInvokeName:et,onResetHookForm:Ze,onSetHooksPanelMode:it,onClearHookConfigStatus:Ke,onSetEditingHookTarget:_e,onSetHookScope:Ae,onSetHookEventName:$e,onSetHookMatcher:tt,onSetHookCommand:st,onSetHookTimeoutSec:Je,onSetHookStatusMessage:ot,onSaveHook:oe,onStartEditingHook:Ge,onTrustHook:L,onUntrustHook:U,onSetMcpPanelMode:he,onClearMcpConfigStatus:Ee,onSetMcpHttpName:Fe,onSetMcpHttpUrl:Xe,onSetMcpRawBlock:rt,onPrepareRawMcpBlock:He,onSaveHttpMcp:We,onSaveRawMcpBlock:me,onPickPhoto:Pe,onPickFile:Ye,onUpdateSettings:Ve,onPasteShell:$t,onCopyShell:Dt,onClearShell:Kr,onShellControl:Xr}){const Yr=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:x,busy:k,forkBusy:w,forkTurnOptionsState:O,skillsState:I,copiedSkillName:K,hooksPanelMode:B,hooksState:T,hostConfigFilesAvailable:fe.hostConfigFiles,hookTrustAvailable:fe.hookTrust,hookConfigBusy:z,hookConfigError:Y,hookConfigSuccess:$,editingHookTarget:q,hookScope:G,hookEventName:ce,hookMatcher:ee,hookCommand:ie,hookTimeoutSec:ue,hookStatusMessage:ge,mcpPanelMode:Le,mcpState:re,mcpConfigEditing:fe.mcpConfigEditing,mcpConfigPath:be,mcpConfigError:je,mcpConfigSuccess:xe,mcpConfigBusy:ze,mcpHttpName:R,mcpHttpUrl:te,mcpRawBlock:ve,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>ae(dt=>dt==="slash"?null:"slash"),onToolboxItemClick:ye,toolboxItemDisabled:dt=>Pu(dt,{settingsBusy:b,compactBusy:y,busy:k,forkBusy:w}),toolboxItemClassName:dt=>Iu(dt,{fastMode:v,goalComposeMode:N,goalStatus:S,menuItemClassName:d}),toolboxItemStatus:dt=>Lu(dt,{fastMode:v,compactBusy:y,goalComposeMode:N,goalStatus:S,busy:k}),onSetSlashPanelView:ke,onOpenForkTurns:we,onForkLatest:Te,onForkTurn:De,onCopySkillInvokeName:et,onResetHookForm:Ze,onSetHooksPanelMode:it,onClearHookConfigStatus:Ke,onSetEditingHookTarget:_e,onSetHookScope:Ae,onSetHookEventName:$e,onSetHookMatcher:tt,onSetHookCommand:st,onSetHookTimeoutSec:Je,onSetHookStatusMessage:ot,onSaveHook:oe,onStartEditingHook:Ge,onTrustHook:L,onUntrustHook:U,onSetMcpPanelMode:he,onClearMcpConfigStatus:Ee,onSetMcpHttpName:Fe,onSetMcpHttpUrl:Xe,onSetMcpRawBlock:rt,onPrepareRawMcpBlock:He,onSaveHttpMcp:We,onSaveRawMcpBlock:me},Zr=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>ae(dt=>dt==="attachments"?null:"attachments"),onPickPhoto:Pe,onPickFile:Ye},Jr=e?null:{openMenu:o,model:F,modelOptions:H,modelContextTitle:M,contextUsage:Q,reasoningEffort:V,supportedEfforts:W,displayedCollaborationMode:Z,planModeAvailable:fe.planMode,settingsBusy:b,goalComposeMode:N,goalBusy:j,activeView:P,disabled:C,fastMode:v,sendButtonLabel:de,sendButtonClassName:E,modelControlsDisabled:J,effortControlsDisabled:A,effortControlTitle:X,inlineToggleClassName:p,menuItemClassName:d,planToggleActiveClassName:m,sendButtonBaseClassName:f,onSetOpenMenu:ae,onUpdateSettings:Ve};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Yr,attachmentMenuProps:Zr,settingsToolbarProps:Jr,shellToolsPanelProps:o==="shellTools"?{busy:k,shellControlState:pe,onPaste:$t,onCopy:Dt,onClear:Kr,onShellControl:Xr}:null,shellControlState:pe,onToggleView:Ie,onDismissPromptFocus:D,onSetOpenMenu:ae}}function Pn({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",modelOptions:u=[],contextUsage:p=null,capabilities:m=null,toolboxItems:f=null,hookCommandTemplates:g=null,mcpConfigFormat:x="none",followTail:k=!1,threadConnected:b=!0,shellAvailable:y=!0,disabled:w=!1,disabledPlaceholder:v,shellControlState:N=null,draftPrompt:j,draftAttachments:S,skillsState:P={status:"idle",data:null,error:null},mcpState:C={status:"idle",data:null,error:null},hooksState:F={status:"idle",data:null,error:null},goalState:H={status:"idle",data:null,error:null},forkTurnOptionsState:M={status:"idle",data:null,error:null},onDraftChange:Q,onSubmit:V,onInterrupt:W,onCompact:Z,onOpenSkills:de,onOpenMcp:E,onOpenHooks:J,onCreateHook:A,onUpdateHook:X,onTrustHook:O,onUntrustHook:I,onOpenGoal:K,onUpdateGoal:B,onOpenForkTurns:T,onForkLatest:z,onForkTurn:Y,onReadProviderConfig:$,onWriteProviderConfig:q,onToggleFollow:G,onUpdateSettings:ce,onToggleView:ee,onShellCopy:ie,onShellControl:ue,canInterrupt:ge=!1}){var da;const[Le,re]=c.useState(null),[be,je]=c.useState("root"),[xe,ze]=c.useState("list"),R=c.useMemo(()=>({fast:(m==null?void 0:m.controls.performanceMode)??!1,compact:(m==null?void 0:m.turns.compact)??!1,goal:(m==null?void 0:m.controls.goals)??!1,fork:(m==null?void 0:m.branching.fork)??!1,skills:(m==null?void 0:m.management.skills)??!1,mcp:(m==null?void 0:m.management.mcpStatus)??!1,hooks:(m==null?void 0:m.management.hooks)??!1,hostConfigFiles:(m==null?void 0:m.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(m!=null&&m.management.hostConfigFiles)&&!!$&&!!q,hookTrust:(m==null?void 0:m.management.hookTrust)??!1,planMode:(m==null?void 0:m.controls.planMode)??!1}),[m,x,$,q]),te=c.useMemo(()=>(f??[]).filter(ne=>{switch(ne.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;default:return!1}}),[R,f]),ve=c.useRef(null),fe=c.useRef(null),pe=c.useRef(null),Ie=c.useRef(null),D=c.useRef(null),ae=c.useRef([]),ye=c.useRef(null),ke=c.useRef(""),we=c.useRef(0),Te=e==="shell",De=y||Te,et=!!(Te&&(N!=null&&N.isMobileShell)),Ze=(N==null?void 0:N.promptLabel)??null,[it,Ke]=c.useState(!1),[_e,Ae]=c.useState(0),{prompt:$e,attachments:tt,isDraftControlled:st,updateDraft:Je,flushControlledDraftToHost:ot}=om({isShellView:Te,draftPrompt:j,draftAttachments:S,onDraftChange:Q}),oe=am({attachments:tt,isShellView:Te}),{displayedCollaborationMode:Ge,updateSettings:L}=wm({collaborationMode:h,onUpdateSettings:ce,closeMenu:()=>re(null)}),{forkBusy:U,forkLatest:he,forkTurn:Ee}=lm({slashPanelView:be,onForkLatest:z,onForkTurn:Y,closeMenu:()=>re(null)}),{hooksPanelMode:Fe,hookScope:Xe,hookEventName:rt,hookMatcher:He,hookCommand:We,hookTimeoutSec:me,hookStatusMessage:Pe,editingHookTarget:Ye,hookConfigBusy:Ve,hookConfigError:$t,hookConfigSuccess:Dt,setHooksPanelMode:Kr,setEditingHookTarget:Xr,setHookScope:Yr,setHookEventName:Zr,setHookMatcher:Jr,setHookCommand:Jn,setHookTimeoutSec:dt,setHookStatusMessage:ul,clearHookConfigStatus:Qn,resetHookForm:ml,startEditingHook:pl,saveHook:fl,trustHook:gl,untrustHook:xl}=cm({slashPanelView:be,hookCommandTemplates:g,onCreateHook:A,onUpdateHook:X,onTrustHook:O,onUntrustHook:I}),{goalComposeMode:Zt,goalTokenBudget:bl,goalBusy:Qr,goalLocalError:vl,setGoalTokenBudget:kl,submitGoal:wl,enterGoalComposeMode:yl,exitGoalComposeMode:ea}=im({prompt:$e,goalTokenBudgetSource:H.data,promptRef:fe,onOpenGoal:K,onUpdateGoal:B,updateDraft:Je,closeMenu:()=>re(null),resetSlashPanel:()=>je("root")}),{mcpHttpName:jl,mcpHttpUrl:Nl,mcpRawBlock:Cl,mcpConfigPath:Sl,mcpConfigBusy:Tl,mcpConfigError:El,mcpConfigSuccess:Ll,setMcpHttpName:Pl,setMcpHttpUrl:Il,setMcpRawBlock:zl,clearMcpConfigStatus:ta,prepareRawMcpBlock:Rl,saveHttpMcp:Al,saveRawMcpBlock:Ml}=um({hostConfigFilesAvailable:R.hostConfigFiles,onReadProviderConfig:$,onWriteProviderConfig:q,setMcpPanelMode:ze,onOpenMcp:E}),{copiedSkillName:_l,copySkillInvokeName:$l}=mm({openMenu:Le,setOpenMenu:re,slashPanelView:be,setSlashPanelView:je,setMcpPanelMode:ze,clearMcpConfigStatus:ta,clearHookConfigStatus:Qn}),Dl=c.useCallback(ne=>{Je(Ne=>{if(typeof ne=="function"){const Re=ne(Ne.prompt,Ne.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Ne.attachments}}return{prompt:ne,attachments:Ne.attachments}})},[Je]),en=c.useMemo(()=>u.find(ne=>ne.model===l)??null,[l,u]),Bl=iu(l,p),ra=(en==null?void 0:en.supportedReasoningEfforts)??[],Gl=c.useMemo(()=>qh($e,tt),[tt,$e]),Fl=c.useMemo(()=>Object.entries(oe).sort(([ne],[Ne])=>ne.localeCompare(Ne)).map(([ne,Ne])=>`${ne}:${Ne}`).join("|"),[oe]);function Hl(ne,Ne){Ne.stopPropagation();const Re=Eu(ne,{fastMode:d,goalComposeMode:Zt});switch(Re.type){case"toggleFast":L({fastMode:Re.fastMode});break;case"runCompact":re(null),Z==null||Z();break;case"enterGoalCompose":yl();break;case"exitGoalCompose":ea(),re(null);break;case"openPanel":je(Re.panel),Re.panel==="skills"?de==null||de():Re.panel==="mcp"?E==null||E():Re.panel==="hooks"&&(J==null||J());break}}function Bt(){const ne=fe.current;return ne?Au(ne):null}const Ol=c.useCallback(ne=>{const Ne=fe.current;!Ne||!ne||Mu(Ne,ne)},[]),na=c.useCallback(()=>{const ne=fe.current;return ne?Uo(ne):$e},[$e]),{appendAttachments:Ul,appendDroppedAttachments:aa}=nm({prompt:$e,attachments:tt,updateDraft:Je,getSelection:Bt,selectionSnapshotRef:ye,pendingSelectionRef:D,pendingInsertedAttachmentIdsRef:ae,onInserted:()=>re(null)});function sa(ne){if(!ne)return;const Ne=Bt()??ye.current,Re=(Ne==null?void 0:Ne.start)??$e.length,nt=(Ne==null?void 0:Ne.end)??Re,lt=Vh(ne),Gt=`${$e.slice(0,Re)}${lt}${$e.slice(nt)}`;Je(Ci=>({prompt:Gt,attachments:Ci.attachments}));const Nt=Re+lt.length;D.current={start:Nt,end:Nt},ye.current={start:Nt,end:Nt}}gm({promptRef:fe,isShellView:Te,prompt:$e,promptSegments:Gl,attachmentPreviewUrls:oe,previewSignature:Fl,editorSanitizeNonce:_e,pendingSelectionRef:D,pendingInsertedAttachmentIdsRef:ae,selectionSnapshotRef:ye,renderedPreviewSignatureRef:ke,renderedSanitizeNonceRef:we,serializeEditorPrompt:na,restoreSelection:Ol});function jt(){var ne;(ne=fe.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function Wl(){var ne;if(jt(),re(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const Ne=await navigator.clipboard.readText();sa(Ne)}catch{return}}async function oa(){if(st&&ot(),Zt&&!Te){await wl();return}const ne=Jh({prompt:$e,attachments:tt,isShellView:Te});!ne||await V(ne)===!1||Je(()=>({prompt:"",attachments:[]}))}async function Vl(ne){ne.preventDefault(),await oa()}function ql(){const ne=na(),Ne=Bt();ye.current=Ne;const Re=fe.current;(Re?Ru(Re):!1)&&(D.current=Ne,Ae(lt=>lt+1)),Je(lt=>({prompt:ne,attachments:lt.attachments.filter(Gt=>ne.includes(Gt.placeholder))}),"deferred")}function Kl(ne){var nt,lt,Gt,Nt;const Ne=En((nt=ne.clipboardData)==null?void 0:nt.items,(lt=ne.clipboardData)==null?void 0:lt.files),Re=Qh({files:Ne,plainText:((Gt=ne.clipboardData)==null?void 0:Gt.getData("text/plain"))??"",htmlText:((Nt=ne.clipboardData)==null?void 0:Nt.getData("text/html"))??"",htmlToText:zu});Re.preventDefault&&ne.preventDefault(),Re.type==="insert-text"?sa(Re.text):Re.type==="append-files"&&aa(Re.files)}function Xl(ne){var Re,nt;const Ne=Ba(Ha((Re=ne.dataTransfer)==null?void 0:Re.items,(nt=ne.dataTransfer)==null?void 0:nt.files));Ne.preventDefault&&ne.preventDefault(),Ne.activateDragTarget&&Ke(!0)}function Yl(ne){var Re,nt;const Ne=Ba(Ha((Re=ne.dataTransfer)==null?void 0:Re.items,(nt=ne.dataTransfer)==null?void 0:nt.files));Ne.preventDefault&&ne.preventDefault(),Ne.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),Ne.activateDragTarget&&Ke(!0)}function Zl(ne){ne.currentTarget.contains(ne.relatedTarget)||Ke(!1)}function Jl(ne){var nt,lt;const Ne=En((nt=ne.dataTransfer)==null?void 0:nt.items,(lt=ne.dataTransfer)==null?void 0:lt.files),Re=eu(Ne);Re.preventDefault&&ne.preventDefault(),Re.type==="accept-files"&&(Ke(!1),aa(Re.files??[]))}function Ql(ne){const Ne=tu({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:w});Ne.preventDefault&&ne.preventDefault(),Ne.submit&&oa()}const{promptPlaceholder:ei,interruptLabel:ti,sendButtonLabel:la,sendButtonClassName:ia,modelControlsDisabled:ri,effortControlsDisabled:ni,effortControlTitle:ai}=uu({goalComposeMode:Zt,goalBusy:Qr,threadConnected:b,busy:n,isShellView:Te,disabledPlaceholder:v,settingsBusy:a,supportedEffortCount:ra.length,fastMode:d}),{composerLayerClassName:si,formClassName:oi,composerShellClassName:li,composerToolbarClassName:ii,composerIconButtonClassName:di,composerMenuClassName:ci,composerMenuItemClassName:hi,composerInlineToggleClassName:ui,composerPanelButtonClassName:mi,composerChipButtonClassName:pi,composerPlanToggleActiveClassName:fi,composerSendButtonClassName:gi,composerPromptRegionClassName:xi,promptInputClassName:bi,graphChatInputGroupClassName:vi,graphChatInputClassName:ki}=mu({isShellView:Te,edgeToEdgeMobile:r,isMobileShell:et,openMenu:Le!==null,isDragTargetActive:it,busy:n}),wi=ym({isShellView:Te,canToggleShellView:De,isMobileShell:et,shellPromptLabel:Ze,openMenu:Le,toolbarClassName:ii,iconButtonClassName:di,menuClassName:ci,menuItemClassName:hi,panelButtonClassName:mi,chipButtonClassName:pi,inlineToggleClassName:ui,planToggleActiveClassName:fi,sendButtonBaseClassName:gi,slashPanelView:be,availableToolboxItems:te,busy:n,settingsBusy:a,compactBusy:o,forkBusy:U,fastMode:d,goalComposeMode:Zt,goalBusy:Qr,goalStatus:(da=H.data)==null?void 0:da.status,activeView:e,disabled:w,model:l,modelOptions:u,modelContextTitle:Bl,contextUsage:p,reasoningEffort:i,supportedEfforts:ra,displayedCollaborationMode:Ge,sendButtonLabel:la,sendButtonClassName:ia,modelControlsDisabled:ri,effortControlsDisabled:ni,effortControlTitle:ai,forkTurnOptionsState:M,skillsState:P,copiedSkillName:_l,hooksPanelMode:Fe,hooksState:F,hookConfigBusy:Ve,hookConfigError:$t,hookConfigSuccess:Dt,editingHookTarget:Ye,hookScope:Xe,hookEventName:rt,hookMatcher:He,hookCommand:We,hookTimeoutSec:me,hookStatusMessage:Pe,mcpPanelMode:xe,mcpState:C,mcpConfigPath:Sl,mcpConfigError:El,mcpConfigSuccess:Ll,mcpConfigBusy:Tl,mcpHttpName:jl,mcpHttpUrl:Nl,mcpRawBlock:Cl,capabilities:{hostConfigFiles:R.hostConfigFiles,hookTrust:R.hookTrust,mcpConfigEditing:R.mcpConfigEditing,planMode:R.planMode},shellControlState:N,onToggleView:ee,onDismissPromptFocus:jt,onSetOpenMenu:re,onToolboxItemClick:Hl,onSetSlashPanelView:je,onOpenForkTurns:()=>T==null?void 0:T(),onForkLatest:he,onForkTurn:Ee,onCopySkillInvokeName:$l,onResetHookForm:ml,onSetHooksPanelMode:Kr,onClearHookConfigStatus:Qn,onSetEditingHookTarget:Xr,onSetHookScope:Yr,onSetHookEventName:Zr,onSetHookMatcher:Jr,onSetHookCommand:Jn,onSetHookTimeoutSec:dt,onSetHookStatusMessage:ul,onSaveHook:fl,onStartEditingHook:pl,onTrustHook:gl,onUntrustHook:xl,onSetMcpPanelMode:ze,onClearMcpConfigStatus:ta,onSetMcpHttpName:Pl,onSetMcpHttpUrl:Il,onSetMcpRawBlock:zl,onPrepareRawMcpBlock:Rl,onSaveHttpMcp:Al,onSaveRawMcpBlock:Ml,onPickPhoto:()=>{var ne;jt(),(ne=pe.current)==null||ne.click()},onPickFile:()=>{var ne;jt(),(ne=Ie.current)==null||ne.click()},onUpdateSettings:ne=>void L(ne),onPasteShell:()=>void Wl(),onCopyShell:()=>{jt(),re(null),ie==null||ie()},onClearShell:()=>{jt(),re(null),V({prompt:"clear"})},onShellControl:ne=>{jt(),re(null),ue==null||ue(ne)}}),{promptSlot:yi,goalSlot:ji,shellPromptSlot:Ni}=km({isShellView:Te,promptRef:fe,prompt:$e,disabled:w,promptPlaceholder:ei,canInterrupt:ge,interruptLabel:ti,composerPromptRegionClassName:xi,graphChatInputClassName:ki,promptInputClassName:bi,goalComposeMode:Zt,goalTokenBudget:bl,goalLocalError:vl,goalBusy:Qr,busy:n,sendButtonLabel:la,sendButtonClassName:ia,onInterrupt:W,onPromptInput:ql,onPromptPaste:Kl,onPromptKeyDown:Ql,onPromptKeyUp:()=>{ye.current=Bt()},onPromptMouseUp:()=>{ye.current=Bt()},onPromptBlur:()=>{ye.current=Bt(),Ke(!1),st&&ot()},onPromptDragEnter:Xl,onPromptDragOver:Yl,onPromptDragLeave:Zl,onPromptDrop:Jl,onGoalTokenBudgetChange:kl,onCancelGoal:ea,onShellPromptChange:Dl});return t.jsx(Uu,{activeView:e,layerClassName:si,formClassName:oi,shellClassName:li,inputGroupClassName:vi,error:s,followTail:k,photoInputRef:pe,fileInputRef:Ie,onAppendAttachments:Ul,onToggleFollow:G,onSubmit:Vl,formRef:ve,promptSlot:yi,toolbarSlot:t.jsx(em,{...wi}),goalSlot:ji,shellPromptSlot:Ni})}var jm=c.createContext(null);function Hr(){return c.useContext(jm)}function zt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function qt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Nm(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 Cm(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 Wo(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Sm({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 Mr.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 Tm({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 Em({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 Lm({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 Pm({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":""}`,children:e})}function Im({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 zm({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 Rm({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}po();yt();function Ka({...e}){return t.jsx(Ii,{"data-slot":"dialog",...e})}function Xa({...e}){return t.jsx(zi,{"data-slot":"dialog-trigger",...e})}function Am({...e}){return t.jsx($i,{"data-slot":"dialog-portal",...e})}function Mm({className:e,...r}){return t.jsx(Di,{"data-slot":"dialog-overlay",className:Qe("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 Ya({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Am,{"data-slot":"dialog-portal",children:[t.jsx(Mm,{}),t.jsxs(Ri,{"data-slot":"dialog-content",className:Qe("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(Ai,{"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 Za({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:Qe("flex flex-col gap-2 text-center sm:text-left",e),...r})}function Ja({className:e,...r}){return t.jsx(Mi,{"data-slot":"dialog-title",className:Qe("text-lg font-semibold leading-none",e),...r})}function Qa({className:e,...r}){return t.jsx(_i,{"data-slot":"dialog-description",className:Qe("text-sm text-muted-foreground",e),...r})}var _m=[{value:"system",label:"Follow system",icon:_.Monitor},{value:"dark",label:"Dark",icon:_.Moon},{value:"light",label:"Light",icon:_.Sun}];function $m({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:p=!1}){const[m,f]=c.useState("idle"),g=c.useRef(null),x=a[e.workspaceId],k=x&&!n?x:null,b=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function y(){const S=e.providerSessionId;if(S)try{await navigator.clipboard.writeText(S),f("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1200)}catch{f("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1600)}}const w=()=>o(e.id),v=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${b?"is-active":""} ${p?"justify-center px-2 py-2":"px-3 py-2.5"}`,N=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 ${b?"is-active":""}`,children:t.jsx(_.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${p?"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&&!p?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.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:m==="copied"?"Copied":m==="failed"?"Copy failed":"Copy session ID",onClick:S=>{S.stopPropagation(),S.preventDefault(),y()},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(_.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 ${Cm(e.status)}`,children:Nm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:zt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!p?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.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]}),j=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:N,className:v,onClick:w})}):j?t.jsx("a",{href:j,onClick:S=>{S.preventDefault(),w()},title:p?e.title:void 0,className:v,children:N}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),w())},title:p?e.title:void 0,className:v,children:N})}function Dm({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:p=!1,showSessionCopyButton:m=!1,collapsed:f=!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(x=>t.jsx($m,{thread:x,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:p,showSessionCopyButton:m,collapsed:f,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},x.id))})})}function Bm({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,mobileHeaderAction:u,currentThreadId:p,currentThreadLabel:m=null,currentWorkspaceId:f=null,currentWorkspaceLabel:g=null,sessionLabel:x=null,usageLabel:k=null,topbarActions:b,metaContent:y,settingsContent:w,globalSettingsContent:v,workspaceLabels:N={},workspaceReturnHref:j,onWorkspaceReturn:S,getThreadHref:P,onOpenThread:C,getNewThreadHref:F,newThreadHref:H,newThreadLabel:M="New Chat",onNewThread:Q,onNewThreadTitle:V,renderThreadLink:W,onCloseAppNavigation:Z,onRenameThread:de,onDeleteThread:E,workspaceContent:J,workspaceTitle:A="Workspace",workspaceActions:X,children:O}){const I=Hr(),[K,B]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),T=i??(I==null?void 0:I.themeMode)??"system",z=l??(I==null?void 0:I.effectiveTheme)??(T==="system"?K?"dark":"light":T),[Y,$]=c.useState(!1),[q,G]=c.useState(!1),[ce,ee]=c.useState(!1),[ie,ue]=c.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile"),[ge,Le]=c.useState("chat"),[re,be]=c.useState(null),[je,xe]=c.useState(""),[ze,R]=c.useState(null),[te,ve]=c.useState(!1),[fe,pe]=c.useState(""),[Ie,D]=c.useState(!1),[ae,ye]=c.useState(!1),[ke,we]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const me=window.matchMedia("(max-width: 639px)"),Pe=()=>{ue(me.matches)};return Pe(),me.addEventListener("change",Pe),()=>{me.removeEventListener("change",Pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const me=window.matchMedia("(prefers-color-scheme: dark)"),Pe=()=>{B(me.matches)};return Pe(),me.addEventListener("change",Pe),()=>{me.removeEventListener("change",Pe)}},[]);const Te=c.useMemo(()=>[...f?e.filter(Pe=>Pe.workspaceId===f):e].sort((Pe,Ye)=>{if(Pe.id===p)return-1;if(Ye.id===p)return 1;const Ve=Date.parse(Pe.lastTurnStartedAt??Pe.updatedAt);return Date.parse(Ye.lastTurnStartedAt??Ye.updatedAt)-Ve}),[p,f,e]),De=H??(F==null?void 0:F(f)),et=g??f??"all",Ze=x??m??p??"default_session",it=k??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),Ke=d??(I==null?void 0:I.setThemeMode),_e=!!Ke,Ae=()=>{$(!1),Z==null||Z()};async function $e(me){if(!de)return;const Pe=je.trim();if(Pe){R(me);try{await de(me,Pe),be(null),xe("")}finally{R(null)}}}function tt(me){be(me.id),xe(me.title)}function st(){be(null),xe("")}function Je(me){C==null||C(me),Ae()}function ot(me){if(!De||!me.trim())return De;try{const Pe=new URL(De,window.location.origin);return Pe.searchParams.set("title",me.trim()),`${Pe.pathname}${Pe.search}${Pe.hash}`}catch{const Pe=De.includes("?")?"&":"?";return`${De}${Pe}title=${encodeURIComponent(me.trim())}`}}async function oe(){const me=fe.trim();D(!0);try{if(me&&V){await V(me),pe(""),ve(!1),Ae();return}if(De){window.location.assign(ot(me)??De);return}await(Q==null?void 0:Q()),pe(""),ve(!1),Ae()}finally{D(!1)}}function Ge(me,Pe=!1){const Ye=Pe?t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:M})]}):t.jsxs(t.Fragment,{children:[t.jsx(_.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:M})]});return t.jsxs(Ka,{open:te,onOpenChange:Ve=>{Ie||ve(Ve)},children:[t.jsx(Xa,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":Pe?M:void 0,title:M,className:me,children:Ye})}),t.jsxs(Ya,{"data-testid":"create-thread-dialog","data-theme-effective":z,"data-theme-mode":T,className:"thread-graph-create-thread-dialog thread-graph-dialog",children:[t.jsxs(Za,{children:[t.jsx(Ja,{children:"Create New Chat"}),t.jsx(Qa,{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:fe,onChange:Ve=>pe(Ve.target.value),onKeyDown:Ve=>{Ve.key==="Enter"&&(Ve.preventDefault(),oe())},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 oe(),disabled:Ie,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:Ie?"Creating...":"Create"})]})]})]})}function L(){if(!w&&!y&&!v&&!_e)return null;const me=!!(w||y),Pe=!!v,Ye=ke==="global"&&Pe||!me&&Pe?"global":"session";return t.jsxs(Ka,{children:[t.jsx(Xa,{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(Ya,{"data-testid":"settings-dialog","data-theme-effective":z,"data-theme-mode":T,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(Za,{children:[t.jsx(Ja,{children:"Settings"}),t.jsx(Qa,{children:"Manage this session and host-wide preferences."})]}),_e?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: ",z]})]}),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:_m.map(Ve=>{const $t=Ve.icon,Dt=T===Ve.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ve.value}`,"aria-pressed":Dt,disabled:!_e,onClick:()=>Ke==null?void 0:Ke(Ve.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 ${Dt?"is-selected":""}`,children:[t.jsx($t,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ve.label})]},Ve.value)})})]})}):null,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":Ye==="session",onClick:()=>we("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ye==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ye==="global",disabled:!Pe,onClick:()=>we("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ye==="global"?"is-active":""}`,children:"Global"})]}),t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ye==="session"?t.jsxs("div",{className:"grid gap-4",children:[w?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:w}):null,y?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:y}):null,me?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:v})})]})]})}function U(me=!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)] ${me?"justify-center":""}`,children:[t.jsx(_.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:me?"sr-only":"",children:"Rooms"}),!me&&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&&Te.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,Te.length>0?t.jsx(Dm,{threads:Te,currentThreadId:p,currentWorkspaceId:f,workspaceLabels:N,onOpenThread:Je,collapsed:me,...de?{onBeginRenameThread:tt}:{},showDeleteButton:!!E,...P?{getThreadHref:P}:{},...W?{renderThreadLink:W}:{},...E?{onDeleteThread:E}:{}}):null]})]})})}function he(){return J?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:()=>ee(!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"})}),X?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:X})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:J})]}):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:A}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:g??f??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[X,t.jsx("button",{type:"button",onClick:()=>ee(!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:J??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:g??f??"All threads"})]})]})})]})}const Ee=!!J,Fe=s==="mobile"||s==="responsive"&&ie,Xe=Fe,rt=Xe&&!Y,We=!!(j||S)?t.jsx("a",{href:j??"#",onClick:me=>{S&&(me.preventDefault(),S())},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(Tm,{effectiveTheme:z,layoutMode:s,themeMode:T,viewportConstrained:o,children:t.jsxs(Em,{roomsRailCollapsed:q,children:[t.jsx(Lm,{open:Y,onClose:()=>$(!1)}),t.jsxs(Pm,{collapsed:q,mobileOpen:Y,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3.75rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-3 sm:h-16 sm:items-center sm:pb-0 ${q?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${q?"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:()=>G(me=>!me),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:q?"Expand rooms":"Collapse rooms","aria-label":q?"Expand rooms":"Collapse rooms",children:q?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)] ${q?"thread-desktop-collapsed-hidden":""}`,children:(g??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${q?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:g??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:f??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${q?"thread-desktop-collapsed-hidden":""}`,children:[L(),We,t.jsx("button",{type:"button",onClick:()=>$(!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 ${q?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ge(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${q?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,q)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${q?"w-full px-2 py-2":"px-3 py-3"}`,children:U(q)})]}),t.jsxs(Im,{children:[t.jsxs(zm,{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 items-center gap-2 sm:gap-3",children:[rt?t.jsx("button",{type:"button",onClick:()=>$(!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:[Xe?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:m??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{ye(me=>!me)},"aria-expanded":ae,"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})]}),ae?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(26rem,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 me;et&&((me=navigator.clipboard)==null||me.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 room ID",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("button",{type:"button",onClick:()=>{var me;Ze&&((me=navigator.clipboard)==null||me.writeText(Ze))},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-12 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:Ze})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Room token usage",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[b?t.jsx("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:b}):null,Xe?u:null,Xe&&h?Ge("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]})]})}),Xe&&Ee?t.jsxs("div",{className:"thread-mobile-view-switch thread-mobile-only-grid grid-cols-2 gap-1 px-3 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>Le("chat"),className:`thread-mobile-segment h-10 rounded-lg text-sm font-medium transition ${ge==="chat"?"is-active":""}`,children:"Chat"}),t.jsx("button",{type:"button",onClick:()=>Le("workspace"),className:`thread-mobile-segment h-10 rounded-lg text-sm font-medium transition ${ge==="workspace"?"is-active":""}`,children:"Workspace"})]}):null]}),t.jsx(Rm,{children:Ee&&!ce?Fe?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 ${ge==="chat"?"block":"thread-mobile-chat-hidden"}`,children:O}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ge==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:he()})]}):t.jsxs(uo,{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(Ir,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:O}),t.jsx(mo,{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(Ir,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:he()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[Ee&&ce?t.jsx("button",{type:"button",onClick:()=>ee(!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,O]})})]})]})}),t.jsx(Sm,{open:re!==null,title:"Rename Thread",label:"Thread Title",value:je,busy:ze!==null,onChange:xe,onCancel:st,onSubmit:()=>re?$e(re):void 0})]})}function Gm({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?Mr.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 Fm=[/^(?: {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],Hm=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Om=/!?\[[^\]\n]+\]\([^)]+\)/,Um=/`[^`\n]+`/,Wm=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Vm=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,qm=/~~[^~\n]+~~/;function Km(e){const r=e.trim();return r?Fm.some(n=>n.test(r))||Hm.test(r)?!0:/[`[\]*_~!]/.test(r)?Om.test(r)||Um.test(r)||Wm.test(r)||Vm.test(r)||qm.test(r):!1:!1}Fr();function In(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 qn(e=[]){const r=In(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 Kn=c.createContext(qn());function Xn(){return c.useContext(Kn)??qn()}pr();function Vo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function es(e){return Vo(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function qo(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 Xm(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)}):qo(r)}function ts({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(()=>es(o),[o]),i=c.useMemo(()=>es(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:Vo(o)?["stdout","stderr","result"].some(m=>{const f=o[m];return typeof f=="string"&&f.length>0}):!1,[o]),h=n==="pending"||d,[u,p]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&p("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(cr,{type:"single",collapsible:!0,onValueChange:m=>p(m||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(hr,{value:"item-1",className:"border-0",children:[t.jsx(ur,{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(mr,{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(([m,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',m,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),qo(f),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},m)):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(([m,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',m,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Xm(m,f),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},m)),"}"]})]}):null]})]})})})}var rs=null;function Ym(){return rs??(rs=Promise.all([Oe(()=>import("./core-oEok_Crl.js"),__vite__mapDeps([0,1,2])),Oe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Oe(()=>import("./ayu-light-BA47KaF1.js"),[]),Oe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Oe(()=>import("./javascript-wDzz0qaB.js"),[]),Oe(()=>import("./typescript-BPQ3VLAy.js"),[]),Oe(()=>import("./tsx-COt5Ahok.js"),[]),Oe(()=>import("./jsx-g9-lgVsj.js"),[]),Oe(()=>import("./python-B6aJPvgy.js"),[]),Oe(()=>import("./json-Cp-IABpG.js"),[]),Oe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Oe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Oe(()=>import("./yaml-Buea-lGh.js"),[]),Oe(()=>import("./toml-vGWfd6FD.js"),[]),Oe(()=>import("./markdown-Cvjx9yec.js"),[]),Oe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Oe(()=>import("./css-CLj8gQPS.js"),[]),Oe(()=>import("./sql-CRqJ_cUM.js"),[]),Oe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,p,m,f,g,x,k,b,y])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,p.default,m.default,f.default,g.default,x.default,k.default,b.default,y.default]}))),rs}function Or(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zn(e){if(!e)return{};if(Or(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 Rn(){return{finalResult:null,stdout:"",stderr:""}}function Zm(e){return typeof e=="string"?{result:e}:e}function Ko(e){const r=Or(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 ns(e){if(!e)return"pending";if(!Or(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 Jm(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=Zm(d.result),p=r.get(h)??Rn();return Or(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?p.stderr+=u.chunk:p.stdout+=u.chunk:p.finalResult=u,r.set(h,p),""}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 p=zn(d.args);if(typeof h=="string"&&r.has(h)){const m=Ko(r.get(h)??Rn());return`\`\`\`tool-merged
3593
+ `,qa="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function um({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[p,m]=c.useState(null),[f,g]=c.useState(!1),[x,k]=c.useState(null),[b,y]=c.useState(null),w=c.useCallback(()=>{k(null),y(null)},[]),v=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const C=await r();return m(C.path),C},[e,r]),N=c.useCallback(async C=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const H=await n(C);return m(H.path),H},[e,n]),j=c.useCallback(async()=>{const C=su(s),H=i.trim();if(!C){k("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(H)){k("HTTP MCP URL must start with http:// or https://");return}g(!0),k(null),y(null);try{const O=await v(),M=Fa(O.content,C,lu(C,H));await N(M),y(qa),a("list"),l(""),d(""),o==null||o()}catch(O){k(O instanceof Error?O.message:"Unable to update provider config.")}finally{g(!1)}},[v,s,i,o,a,N]),S=c.useCallback(async()=>{g(!0),k(null),y(null);try{await v(),u(C=>C||hm),a("stdio")}catch(C){k(C instanceof Error?C.message:"Unable to load provider config.")}finally{g(!1)}},[v,a]),L=c.useCallback(async()=>{const C=ou(h);if(!C){k("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),k(null),y(null);try{const H=await v(),O=Fa(H.content,C,h);await N(O),y(qa),a("list"),o==null||o()}catch(H){k(H instanceof Error?H.message:"Unable to update provider config.")}finally{g(!1)}},[v,h,o,a,N]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:p,mcpConfigBusy:f,mcpConfigError:x,mcpConfigSuccess:b,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:w,prepareRawMcpBlock:S,saveHttpMcp:j,saveRawMcpBlock:L}}function mm({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(p=>p===i?null:p)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(p){(typeof p.composedPath=="function"?p.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 pm(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=Oa(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=Oa(n),a.append(o,s),a}function fm(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(pm(a,r))}return n}function gm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:p,serializeEditorPrompt:m,restoreSelection:f}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const x=i.current,k=m()!==n||u.current!==s||p.current!==l;k&&(g.replaceChildren(fm(a,o)),u.current=s,p.current=l),x!==null?(g.focus(),_u(g,d.current)||f(x),h.current=x):document.activeElement===g&&k&&f(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,p,f,h,m])}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 bm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:p,onKeyUp:m,onMouseUp:f,onBlur:g,onDragEnter:x,onDragOver:k,onDragLeave:b,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,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:p,onKeyUp:m,onMouseUp:f,onBlur:g,onDragEnter:x,onDragOver:k,onDragLeave:b,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(kt,{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 vm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:p}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:m=>h(m.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(p==null?void 0:p()),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:m=>{m.preventDefault()},onPointerDown:m=>{m.preventDefault()},onTouchStart:m=>{m.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 km({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:p,goalLocalError:m,goalBusy:f,busy:g,sendButtonLabel:x,sendButtonClassName:k,onInterrupt:b,onPromptInput:y,onPromptPaste:w,onPromptKeyDown:v,onPromptKeyUp:N,onPromptMouseUp:j,onPromptBlur:S,onPromptDragEnter:L,onPromptDragOver:C,onPromptDragLeave:H,onPromptDrop:O,onGoalTokenBudgetChange:M,onCancelGoal:Q,onShellPromptChange:V}){return{promptSlot:e?null:t.jsx(bm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:b,onInput:y,onPaste:w,onKeyDown:v,onKeyUp:N,onMouseUp:j,onBlur:S,onDragEnter:L,onDragOver:C,onDragLeave:H,onDrop:O}),goalSlot:u&&!e?t.jsx(xm,{tokenBudget:p,error:m,onTokenBudgetChange:M,onCancel:Q}):null,shellPromptSlot:e?t.jsx(vm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:x,sendButtonClassName:k,sendDisabled:f||g,onPromptChange:V,onPromptKeyDown:v,onInterrupt:b}):null}}function wm({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=ru({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:p,planToggleActiveClassName:m,sendButtonBaseClassName:f,slashPanelView:g,availableToolboxItems:x,busy:k,settingsBusy:b,compactBusy:y,forkBusy:w,fastMode:v,goalComposeMode:N,goalBusy:j,goalStatus:S,activeView:L,disabled:C,model:H,modelOptions:O,modelContextTitle:M,contextUsage:Q,reasoningEffort:V,supportedEfforts:W,displayedCollaborationMode:Z,sendButtonLabel:de,sendButtonClassName:T,modelControlsDisabled:J,effortControlsDisabled:A,effortControlTitle:Y,forkTurnOptionsState:F,skillsState:I,copiedSkillName:K,hooksPanelMode:D,hooksState:P,hookConfigBusy:z,hookConfigError:X,hookConfigSuccess:_,editingHookTarget:q,hookScope:G,hookEventName:ce,hookMatcher:ee,hookCommand:ie,hookTimeoutSec:ue,hookStatusMessage:ge,mcpPanelMode:Le,mcpState:re,mcpConfigPath:be,mcpConfigError:je,mcpConfigSuccess:xe,mcpConfigBusy:ze,mcpHttpName:R,mcpHttpUrl:te,mcpRawBlock:ve,capabilities:fe,shellControlState:pe,onToggleView:Ie,onDismissPromptFocus:B,onSetOpenMenu:ae,onToolboxItemClick:ye,onSetSlashPanelView:ke,onOpenForkTurns:we,onForkLatest:Te,onForkTurn:De,onCopySkillInvokeName:et,onResetHookForm:Ze,onSetHooksPanelMode:it,onClearHookConfigStatus:Ke,onSetEditingHookTarget:_e,onSetHookScope:Ae,onSetHookEventName:$e,onSetHookMatcher:tt,onSetHookCommand:st,onSetHookTimeoutSec:Je,onSetHookStatusMessage:ot,onSaveHook:oe,onStartEditingHook:Ge,onTrustHook:E,onUntrustHook:U,onSetMcpPanelMode:he,onClearMcpConfigStatus:Ee,onSetMcpHttpName:Fe,onSetMcpHttpUrl:Xe,onSetMcpRawBlock:rt,onPrepareRawMcpBlock:He,onSaveHttpMcp:We,onSaveRawMcpBlock:me,onPickPhoto:Pe,onPickFile:Ye,onUpdateSettings:Ve,onPasteShell:$t,onCopyShell:Dt,onClearShell:Kr,onShellControl:Xr}){const Yr=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:x,busy:k,forkBusy:w,forkTurnOptionsState:F,skillsState:I,copiedSkillName:K,hooksPanelMode:D,hooksState:P,hostConfigFilesAvailable:fe.hostConfigFiles,hookTrustAvailable:fe.hookTrust,hookConfigBusy:z,hookConfigError:X,hookConfigSuccess:_,editingHookTarget:q,hookScope:G,hookEventName:ce,hookMatcher:ee,hookCommand:ie,hookTimeoutSec:ue,hookStatusMessage:ge,mcpPanelMode:Le,mcpState:re,mcpConfigEditing:fe.mcpConfigEditing,mcpConfigPath:be,mcpConfigError:je,mcpConfigSuccess:xe,mcpConfigBusy:ze,mcpHttpName:R,mcpHttpUrl:te,mcpRawBlock:ve,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>ae(dt=>dt==="slash"?null:"slash"),onToolboxItemClick:ye,toolboxItemDisabled:dt=>Pu(dt,{settingsBusy:b,compactBusy:y,busy:k,forkBusy:w}),toolboxItemClassName:dt=>Iu(dt,{fastMode:v,goalComposeMode:N,goalStatus:S,menuItemClassName:d}),toolboxItemStatus:dt=>Lu(dt,{fastMode:v,compactBusy:y,goalComposeMode:N,goalStatus:S,busy:k}),onSetSlashPanelView:ke,onOpenForkTurns:we,onForkLatest:Te,onForkTurn:De,onCopySkillInvokeName:et,onResetHookForm:Ze,onSetHooksPanelMode:it,onClearHookConfigStatus:Ke,onSetEditingHookTarget:_e,onSetHookScope:Ae,onSetHookEventName:$e,onSetHookMatcher:tt,onSetHookCommand:st,onSetHookTimeoutSec:Je,onSetHookStatusMessage:ot,onSaveHook:oe,onStartEditingHook:Ge,onTrustHook:E,onUntrustHook:U,onSetMcpPanelMode:he,onClearMcpConfigStatus:Ee,onSetMcpHttpName:Fe,onSetMcpHttpUrl:Xe,onSetMcpRawBlock:rt,onPrepareRawMcpBlock:He,onSaveHttpMcp:We,onSaveRawMcpBlock:me},Zr=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>ae(dt=>dt==="attachments"?null:"attachments"),onPickPhoto:Pe,onPickFile:Ye},Jr=e?null:{openMenu:o,model:H,modelOptions:O,modelContextTitle:M,contextUsage:Q,reasoningEffort:V,supportedEfforts:W,displayedCollaborationMode:Z,planModeAvailable:fe.planMode,settingsBusy:b,goalComposeMode:N,goalBusy:j,activeView:L,disabled:C,fastMode:v,sendButtonLabel:de,sendButtonClassName:T,modelControlsDisabled:J,effortControlsDisabled:A,effortControlTitle:Y,inlineToggleClassName:p,menuItemClassName:d,planToggleActiveClassName:m,sendButtonBaseClassName:f,onSetOpenMenu:ae,onUpdateSettings:Ve};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Yr,attachmentMenuProps:Zr,settingsToolbarProps:Jr,shellToolsPanelProps:o==="shellTools"?{busy:k,shellControlState:pe,onPaste:$t,onCopy:Dt,onClear:Kr,onShellControl:Xr}:null,shellControlState:pe,onToggleView:Ie,onDismissPromptFocus:B,onSetOpenMenu:ae}}function Pn({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",modelOptions:u=[],contextUsage:p=null,capabilities:m=null,toolboxItems:f=null,hookCommandTemplates:g=null,mcpConfigFormat:x="none",followTail:k=!1,threadConnected:b=!0,shellAvailable:y=!0,disabled:w=!1,disabledPlaceholder:v,shellControlState:N=null,draftPrompt:j,draftAttachments:S,skillsState:L={status:"idle",data:null,error:null},mcpState:C={status:"idle",data:null,error:null},hooksState:H={status:"idle",data:null,error:null},goalState:O={status:"idle",data:null,error:null},forkTurnOptionsState:M={status:"idle",data:null,error:null},onDraftChange:Q,onSubmit:V,onInterrupt:W,onCompact:Z,onOpenSkills:de,onOpenMcp:T,onOpenHooks:J,onCreateHook:A,onUpdateHook:Y,onTrustHook:F,onUntrustHook:I,onOpenGoal:K,onUpdateGoal:D,onOpenForkTurns:P,onForkLatest:z,onForkTurn:X,onReadProviderConfig:_,onWriteProviderConfig:q,onToggleFollow:G,onUpdateSettings:ce,onToggleView:ee,onShellCopy:ie,onShellControl:ue,canInterrupt:ge=!1}){var da;const[Le,re]=c.useState(null),[be,je]=c.useState("root"),[xe,ze]=c.useState("list"),R=c.useMemo(()=>({fast:(m==null?void 0:m.controls.performanceMode)??!1,compact:(m==null?void 0:m.turns.compact)??!1,goal:(m==null?void 0:m.controls.goals)??!1,fork:(m==null?void 0:m.branching.fork)??!1,skills:(m==null?void 0:m.management.skills)??!1,mcp:(m==null?void 0:m.management.mcpStatus)??!1,hooks:(m==null?void 0:m.management.hooks)??!1,hostConfigFiles:(m==null?void 0:m.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(m!=null&&m.management.hostConfigFiles)&&!!_&&!!q,hookTrust:(m==null?void 0:m.management.hookTrust)??!1,planMode:(m==null?void 0:m.controls.planMode)??!1}),[m,x,_,q]),te=c.useMemo(()=>(f??[]).filter(ne=>{switch(ne.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;default:return!1}}),[R,f]),ve=c.useRef(null),fe=c.useRef(null),pe=c.useRef(null),Ie=c.useRef(null),B=c.useRef(null),ae=c.useRef([]),ye=c.useRef(null),ke=c.useRef(""),we=c.useRef(0),Te=e==="shell",De=y||Te,et=!!(Te&&(N!=null&&N.isMobileShell)),Ze=(N==null?void 0:N.promptLabel)??null,[it,Ke]=c.useState(!1),[_e,Ae]=c.useState(0),{prompt:$e,attachments:tt,isDraftControlled:st,updateDraft:Je,flushControlledDraftToHost:ot}=om({isShellView:Te,draftPrompt:j,draftAttachments:S,onDraftChange:Q}),oe=am({attachments:tt,isShellView:Te}),{displayedCollaborationMode:Ge,updateSettings:E}=wm({collaborationMode:h,onUpdateSettings:ce,closeMenu:()=>re(null)}),{forkBusy:U,forkLatest:he,forkTurn:Ee}=lm({slashPanelView:be,onForkLatest:z,onForkTurn:X,closeMenu:()=>re(null)}),{hooksPanelMode:Fe,hookScope:Xe,hookEventName:rt,hookMatcher:He,hookCommand:We,hookTimeoutSec:me,hookStatusMessage:Pe,editingHookTarget:Ye,hookConfigBusy:Ve,hookConfigError:$t,hookConfigSuccess:Dt,setHooksPanelMode:Kr,setEditingHookTarget:Xr,setHookScope:Yr,setHookEventName:Zr,setHookMatcher:Jr,setHookCommand:Jn,setHookTimeoutSec:dt,setHookStatusMessage:ul,clearHookConfigStatus:Qn,resetHookForm:ml,startEditingHook:pl,saveHook:fl,trustHook:gl,untrustHook:xl}=cm({slashPanelView:be,hookCommandTemplates:g,onCreateHook:A,onUpdateHook:Y,onTrustHook:F,onUntrustHook:I}),{goalComposeMode:Zt,goalTokenBudget:bl,goalBusy:Qr,goalLocalError:vl,setGoalTokenBudget:kl,submitGoal:wl,enterGoalComposeMode:yl,exitGoalComposeMode:ea}=im({prompt:$e,goalTokenBudgetSource:O.data,promptRef:fe,onOpenGoal:K,onUpdateGoal:D,updateDraft:Je,closeMenu:()=>re(null),resetSlashPanel:()=>je("root")}),{mcpHttpName:jl,mcpHttpUrl:Nl,mcpRawBlock:Cl,mcpConfigPath:Sl,mcpConfigBusy:Tl,mcpConfigError:El,mcpConfigSuccess:Ll,setMcpHttpName:Pl,setMcpHttpUrl:Il,setMcpRawBlock:zl,clearMcpConfigStatus:ta,prepareRawMcpBlock:Rl,saveHttpMcp:Al,saveRawMcpBlock:Ml}=um({hostConfigFilesAvailable:R.hostConfigFiles,onReadProviderConfig:_,onWriteProviderConfig:q,setMcpPanelMode:ze,onOpenMcp:T}),{copiedSkillName:_l,copySkillInvokeName:$l}=mm({openMenu:Le,setOpenMenu:re,slashPanelView:be,setSlashPanelView:je,setMcpPanelMode:ze,clearMcpConfigStatus:ta,clearHookConfigStatus:Qn}),Dl=c.useCallback(ne=>{Je(Ne=>{if(typeof ne=="function"){const Re=ne(Ne.prompt,Ne.attachments);return{prompt:Re.prompt,attachments:Re.attachments??Ne.attachments}}return{prompt:ne,attachments:Ne.attachments}})},[Je]),en=c.useMemo(()=>u.find(ne=>ne.model===l)??null,[l,u]),Bl=iu(l,p),ra=(en==null?void 0:en.supportedReasoningEfforts)??[],Gl=c.useMemo(()=>qh($e,tt),[tt,$e]),Fl=c.useMemo(()=>Object.entries(oe).sort(([ne],[Ne])=>ne.localeCompare(Ne)).map(([ne,Ne])=>`${ne}:${Ne}`).join("|"),[oe]);function Hl(ne,Ne){Ne.stopPropagation();const Re=Eu(ne,{fastMode:d,goalComposeMode:Zt});switch(Re.type){case"toggleFast":E({fastMode:Re.fastMode});break;case"runCompact":re(null),Z==null||Z();break;case"enterGoalCompose":yl();break;case"exitGoalCompose":ea(),re(null);break;case"openPanel":je(Re.panel),Re.panel==="skills"?de==null||de():Re.panel==="mcp"?T==null||T():Re.panel==="hooks"&&(J==null||J());break}}function Bt(){const ne=fe.current;return ne?Au(ne):null}const Ol=c.useCallback(ne=>{const Ne=fe.current;!Ne||!ne||Mu(Ne,ne)},[]),na=c.useCallback(()=>{const ne=fe.current;return ne?Uo(ne):$e},[$e]),{appendAttachments:Ul,appendDroppedAttachments:aa}=nm({prompt:$e,attachments:tt,updateDraft:Je,getSelection:Bt,selectionSnapshotRef:ye,pendingSelectionRef:B,pendingInsertedAttachmentIdsRef:ae,onInserted:()=>re(null)});function sa(ne){if(!ne)return;const Ne=Bt()??ye.current,Re=(Ne==null?void 0:Ne.start)??$e.length,nt=(Ne==null?void 0:Ne.end)??Re,lt=Vh(ne),Gt=`${$e.slice(0,Re)}${lt}${$e.slice(nt)}`;Je(Ci=>({prompt:Gt,attachments:Ci.attachments}));const Nt=Re+lt.length;B.current={start:Nt,end:Nt},ye.current={start:Nt,end:Nt}}gm({promptRef:fe,isShellView:Te,prompt:$e,promptSegments:Gl,attachmentPreviewUrls:oe,previewSignature:Fl,editorSanitizeNonce:_e,pendingSelectionRef:B,pendingInsertedAttachmentIdsRef:ae,selectionSnapshotRef:ye,renderedPreviewSignatureRef:ke,renderedSanitizeNonceRef:we,serializeEditorPrompt:na,restoreSelection:Ol});function jt(){var ne;(ne=fe.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function Wl(){var ne;if(jt(),re(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const Ne=await navigator.clipboard.readText();sa(Ne)}catch{return}}async function oa(){if(st&&ot(),Zt&&!Te){await wl();return}const ne=Jh({prompt:$e,attachments:tt,isShellView:Te});!ne||await V(ne)===!1||Je(()=>({prompt:"",attachments:[]}))}async function Vl(ne){ne.preventDefault(),await oa()}function ql(){const ne=na(),Ne=Bt();ye.current=Ne;const Re=fe.current;(Re?Ru(Re):!1)&&(B.current=Ne,Ae(lt=>lt+1)),Je(lt=>({prompt:ne,attachments:lt.attachments.filter(Gt=>ne.includes(Gt.placeholder))}),"deferred")}function Kl(ne){var nt,lt,Gt,Nt;const Ne=En((nt=ne.clipboardData)==null?void 0:nt.items,(lt=ne.clipboardData)==null?void 0:lt.files),Re=Qh({files:Ne,plainText:((Gt=ne.clipboardData)==null?void 0:Gt.getData("text/plain"))??"",htmlText:((Nt=ne.clipboardData)==null?void 0:Nt.getData("text/html"))??"",htmlToText:zu});Re.preventDefault&&ne.preventDefault(),Re.type==="insert-text"?sa(Re.text):Re.type==="append-files"&&aa(Re.files)}function Xl(ne){var Re,nt;const Ne=Ba(Ha((Re=ne.dataTransfer)==null?void 0:Re.items,(nt=ne.dataTransfer)==null?void 0:nt.files));Ne.preventDefault&&ne.preventDefault(),Ne.activateDragTarget&&Ke(!0)}function Yl(ne){var Re,nt;const Ne=Ba(Ha((Re=ne.dataTransfer)==null?void 0:Re.items,(nt=ne.dataTransfer)==null?void 0:nt.files));Ne.preventDefault&&ne.preventDefault(),Ne.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),Ne.activateDragTarget&&Ke(!0)}function Zl(ne){ne.currentTarget.contains(ne.relatedTarget)||Ke(!1)}function Jl(ne){var nt,lt;const Ne=En((nt=ne.dataTransfer)==null?void 0:nt.items,(lt=ne.dataTransfer)==null?void 0:lt.files),Re=eu(Ne);Re.preventDefault&&ne.preventDefault(),Re.type==="accept-files"&&(Ke(!1),aa(Re.files??[]))}function Ql(ne){const Ne=tu({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:w});Ne.preventDefault&&ne.preventDefault(),Ne.submit&&oa()}const{promptPlaceholder:ei,interruptLabel:ti,sendButtonLabel:la,sendButtonClassName:ia,modelControlsDisabled:ri,effortControlsDisabled:ni,effortControlTitle:ai}=uu({goalComposeMode:Zt,goalBusy:Qr,threadConnected:b,busy:n,isShellView:Te,disabledPlaceholder:v,settingsBusy:a,supportedEffortCount:ra.length,fastMode:d}),{composerLayerClassName:si,formClassName:oi,composerShellClassName:li,composerToolbarClassName:ii,composerIconButtonClassName:di,composerMenuClassName:ci,composerMenuItemClassName:hi,composerInlineToggleClassName:ui,composerPanelButtonClassName:mi,composerChipButtonClassName:pi,composerPlanToggleActiveClassName:fi,composerSendButtonClassName:gi,composerPromptRegionClassName:xi,promptInputClassName:bi,graphChatInputGroupClassName:vi,graphChatInputClassName:ki}=mu({isShellView:Te,edgeToEdgeMobile:r,isMobileShell:et,openMenu:Le!==null,isDragTargetActive:it,busy:n}),wi=ym({isShellView:Te,canToggleShellView:De,isMobileShell:et,shellPromptLabel:Ze,openMenu:Le,toolbarClassName:ii,iconButtonClassName:di,menuClassName:ci,menuItemClassName:hi,panelButtonClassName:mi,chipButtonClassName:pi,inlineToggleClassName:ui,planToggleActiveClassName:fi,sendButtonBaseClassName:gi,slashPanelView:be,availableToolboxItems:te,busy:n,settingsBusy:a,compactBusy:o,forkBusy:U,fastMode:d,goalComposeMode:Zt,goalBusy:Qr,goalStatus:(da=O.data)==null?void 0:da.status,activeView:e,disabled:w,model:l,modelOptions:u,modelContextTitle:Bl,contextUsage:p,reasoningEffort:i,supportedEfforts:ra,displayedCollaborationMode:Ge,sendButtonLabel:la,sendButtonClassName:ia,modelControlsDisabled:ri,effortControlsDisabled:ni,effortControlTitle:ai,forkTurnOptionsState:M,skillsState:L,copiedSkillName:_l,hooksPanelMode:Fe,hooksState:H,hookConfigBusy:Ve,hookConfigError:$t,hookConfigSuccess:Dt,editingHookTarget:Ye,hookScope:Xe,hookEventName:rt,hookMatcher:He,hookCommand:We,hookTimeoutSec:me,hookStatusMessage:Pe,mcpPanelMode:xe,mcpState:C,mcpConfigPath:Sl,mcpConfigError:El,mcpConfigSuccess:Ll,mcpConfigBusy:Tl,mcpHttpName:jl,mcpHttpUrl:Nl,mcpRawBlock:Cl,capabilities:{hostConfigFiles:R.hostConfigFiles,hookTrust:R.hookTrust,mcpConfigEditing:R.mcpConfigEditing,planMode:R.planMode},shellControlState:N,onToggleView:ee,onDismissPromptFocus:jt,onSetOpenMenu:re,onToolboxItemClick:Hl,onSetSlashPanelView:je,onOpenForkTurns:()=>P==null?void 0:P(),onForkLatest:he,onForkTurn:Ee,onCopySkillInvokeName:$l,onResetHookForm:ml,onSetHooksPanelMode:Kr,onClearHookConfigStatus:Qn,onSetEditingHookTarget:Xr,onSetHookScope:Yr,onSetHookEventName:Zr,onSetHookMatcher:Jr,onSetHookCommand:Jn,onSetHookTimeoutSec:dt,onSetHookStatusMessage:ul,onSaveHook:fl,onStartEditingHook:pl,onTrustHook:gl,onUntrustHook:xl,onSetMcpPanelMode:ze,onClearMcpConfigStatus:ta,onSetMcpHttpName:Pl,onSetMcpHttpUrl:Il,onSetMcpRawBlock:zl,onPrepareRawMcpBlock:Rl,onSaveHttpMcp:Al,onSaveRawMcpBlock:Ml,onPickPhoto:()=>{var ne;jt(),(ne=pe.current)==null||ne.click()},onPickFile:()=>{var ne;jt(),(ne=Ie.current)==null||ne.click()},onUpdateSettings:ne=>void E(ne),onPasteShell:()=>void Wl(),onCopyShell:()=>{jt(),re(null),ie==null||ie()},onClearShell:()=>{jt(),re(null),V({prompt:"clear"})},onShellControl:ne=>{jt(),re(null),ue==null||ue(ne)}}),{promptSlot:yi,goalSlot:ji,shellPromptSlot:Ni}=km({isShellView:Te,promptRef:fe,prompt:$e,disabled:w,promptPlaceholder:ei,canInterrupt:ge,interruptLabel:ti,composerPromptRegionClassName:xi,graphChatInputClassName:ki,promptInputClassName:bi,goalComposeMode:Zt,goalTokenBudget:bl,goalLocalError:vl,goalBusy:Qr,busy:n,sendButtonLabel:la,sendButtonClassName:ia,onInterrupt:W,onPromptInput:ql,onPromptPaste:Kl,onPromptKeyDown:Ql,onPromptKeyUp:()=>{ye.current=Bt()},onPromptMouseUp:()=>{ye.current=Bt()},onPromptBlur:()=>{ye.current=Bt(),Ke(!1),st&&ot()},onPromptDragEnter:Xl,onPromptDragOver:Yl,onPromptDragLeave:Zl,onPromptDrop:Jl,onGoalTokenBudgetChange:kl,onCancelGoal:ea,onShellPromptChange:Dl});return t.jsx(Uu,{activeView:e,layerClassName:si,formClassName:oi,shellClassName:li,inputGroupClassName:vi,error:s,followTail:k,photoInputRef:pe,fileInputRef:Ie,onAppendAttachments:Ul,onToggleFollow:G,onSubmit:Vl,formRef:ve,promptSlot:yi,toolbarSlot:t.jsx(em,{...wi}),goalSlot:ji,shellPromptSlot:Ni})}var jm=c.createContext(null);function Hr(){return c.useContext(jm)}function zt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function qt(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Nm(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 Cm(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 Wo(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Sm({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 Mr.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 Tm({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 Em({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 Lm({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 Pm({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":""}`,children:e})}function Im({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 zm({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 Rm({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}po();yt();function Ka({...e}){return t.jsx(Ii,{"data-slot":"dialog",...e})}function Xa({...e}){return t.jsx(zi,{"data-slot":"dialog-trigger",...e})}function Am({...e}){return t.jsx($i,{"data-slot":"dialog-portal",...e})}function Mm({className:e,...r}){return t.jsx(Di,{"data-slot":"dialog-overlay",className:Qe("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 Ya({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Am,{"data-slot":"dialog-portal",children:[t.jsx(Mm,{}),t.jsxs(Ri,{"data-slot":"dialog-content",className:Qe("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(Ai,{"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 Za({className:e,...r}){return t.jsx("div",{"data-slot":"dialog-header",className:Qe("flex flex-col gap-2 text-center sm:text-left",e),...r})}function Ja({className:e,...r}){return t.jsx(Mi,{"data-slot":"dialog-title",className:Qe("text-lg font-semibold leading-none",e),...r})}function Qa({className:e,...r}){return t.jsx(_i,{"data-slot":"dialog-description",className:Qe("text-sm text-muted-foreground",e),...r})}var _m=[{value:"system",label:"Follow system",icon:$.Monitor},{value:"dark",label:"Dark",icon:$.Moon},{value:"light",label:"Light",icon:$.Sun}];function $m({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:p=!1}){const[m,f]=c.useState("idle"),g=c.useRef(null),x=a[e.workspaceId],k=x&&!n?x:null,b=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function y(){const S=e.providerSessionId;if(S)try{await navigator.clipboard.writeText(S),f("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1200)}catch{f("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>f("idle"),1600)}}const w=()=>o(e.id),v=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${b?"is-active":""} ${p?"justify-center px-2 py-2":"px-3 py-2.5"}`,N=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 ${b?"is-active":""}`,children:t.jsx($.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${p?"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&&!p?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.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:m==="copied"?"Copied":m==="failed"?"Copy failed":"Copy session ID",onClick:S=>{S.stopPropagation(),S.preventDefault(),y()},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($.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 ${Cm(e.status)}`,children:Nm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:zt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!p?t.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),S.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]}),j=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:N,className:v,onClick:w})}):j?t.jsx("a",{href:j,onClick:S=>{S.preventDefault(),w()},title:p?e.title:void 0,className:v,children:N}):t.jsx("div",{role:"link",tabIndex:0,onClick:w,onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),w())},title:p?e.title:void 0,className:v,children:N})}function Dm({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:p=!1,showSessionCopyButton:m=!1,collapsed:f=!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(x=>t.jsx($m,{thread:x,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:p,showSessionCopyButton:m,collapsed:f,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},x.id))})})}function Bm({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,mobileHeaderAction:u,currentThreadId:p,currentThreadLabel:m=null,currentWorkspaceId:f=null,currentWorkspaceLabel:g=null,sessionLabel:x=null,usageLabel:k=null,topbarActions:b,metaContent:y,settingsContent:w,globalSettingsContent:v,workspaceLabels:N={},workspaceReturnHref:j,onWorkspaceReturn:S,getThreadHref:L,onOpenThread:C,getNewThreadHref:H,newThreadHref:O,newThreadLabel:M="New Chat",onNewThread:Q,onNewThreadTitle:V,renderThreadLink:W,onCloseAppNavigation:Z,onRenameThread:de,onDeleteThread:T,workspaceContent:J,workspaceTitle:A="Workspace",workspaceActions:Y,children:F}){const I=Hr(),[K,D]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),P=i??(I==null?void 0:I.themeMode)??"system",z=l??(I==null?void 0:I.effectiveTheme)??(P==="system"?K?"dark":"light":P),[X,_]=c.useState(!1),[q,G]=c.useState(!1),[ce,ee]=c.useState(!1),[ie,ue]=c.useState(()=>typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile"),[ge,Le]=c.useState("chat"),[re,be]=c.useState(null),[je,xe]=c.useState(""),[ze,R]=c.useState(null),[te,ve]=c.useState(!1),[fe,pe]=c.useState(""),[Ie,B]=c.useState(!1),[ae,ye]=c.useState(!1),[ke,we]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const me=window.matchMedia("(max-width: 639px)"),Pe=()=>{ue(me.matches)};return Pe(),me.addEventListener("change",Pe),()=>{me.removeEventListener("change",Pe)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const me=window.matchMedia("(prefers-color-scheme: dark)"),Pe=()=>{D(me.matches)};return Pe(),me.addEventListener("change",Pe),()=>{me.removeEventListener("change",Pe)}},[]);const Te=c.useMemo(()=>[...f?e.filter(Pe=>Pe.workspaceId===f):e].sort((Pe,Ye)=>{if(Pe.id===p)return-1;if(Ye.id===p)return 1;const Ve=Date.parse(Pe.lastTurnStartedAt??Pe.updatedAt);return Date.parse(Ye.lastTurnStartedAt??Ye.updatedAt)-Ve}),[p,f,e]),De=O??(H==null?void 0:H(f)),et=g??f??"all",Ze=x??m??p??"default_session",it=k??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),Ke=d??(I==null?void 0:I.setThemeMode),_e=!!Ke,Ae=()=>{_(!1),Z==null||Z()};async function $e(me){if(!de)return;const Pe=je.trim();if(Pe){R(me);try{await de(me,Pe),be(null),xe("")}finally{R(null)}}}function tt(me){be(me.id),xe(me.title)}function st(){be(null),xe("")}function Je(me){C==null||C(me),Ae()}function ot(me){if(!De||!me.trim())return De;try{const Pe=new URL(De,window.location.origin);return Pe.searchParams.set("title",me.trim()),`${Pe.pathname}${Pe.search}${Pe.hash}`}catch{const Pe=De.includes("?")?"&":"?";return`${De}${Pe}title=${encodeURIComponent(me.trim())}`}}async function oe(){const me=fe.trim();B(!0);try{if(me&&V){await V(me),pe(""),ve(!1),Ae();return}if(De){window.location.assign(ot(me)??De);return}await(Q==null?void 0:Q()),pe(""),ve(!1),Ae()}finally{B(!1)}}function Ge(me,Pe=!1){const Ye=Pe?t.jsxs(t.Fragment,{children:[t.jsx($.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:M})]}):t.jsxs(t.Fragment,{children:[t.jsx($.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:M})]});return t.jsxs(Ka,{open:te,onOpenChange:Ve=>{Ie||ve(Ve)},children:[t.jsx(Xa,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":Pe?M:void 0,title:M,className:me,children:Ye})}),t.jsxs(Ya,{"data-testid":"create-thread-dialog","data-theme-effective":z,"data-theme-mode":P,className:"thread-graph-create-thread-dialog thread-graph-dialog",children:[t.jsxs(Za,{children:[t.jsx(Ja,{children:"Create New Chat"}),t.jsx(Qa,{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:fe,onChange:Ve=>pe(Ve.target.value),onKeyDown:Ve=>{Ve.key==="Enter"&&(Ve.preventDefault(),oe())},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 oe(),disabled:Ie,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:Ie?"Creating...":"Create"})]})]})]})}function E(){if(!w&&!y&&!v&&!_e)return null;const me=!!(w||y),Pe=!!v,Ye=ke==="global"&&Pe||!me&&Pe?"global":"session";return t.jsxs(Ka,{children:[t.jsx(Xa,{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(Ya,{"data-testid":"settings-dialog","data-theme-effective":z,"data-theme-mode":P,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(Za,{children:[t.jsx(Ja,{children:"Settings"}),t.jsx(Qa,{children:"Manage this session and host-wide preferences."})]}),_e?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: ",z]})]}),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:_m.map(Ve=>{const $t=Ve.icon,Dt=P===Ve.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${Ve.value}`,"aria-pressed":Dt,disabled:!_e,onClick:()=>Ke==null?void 0:Ke(Ve.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 ${Dt?"is-selected":""}`,children:[t.jsx($t,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:Ve.label})]},Ve.value)})})]})}):null,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":Ye==="session",onClick:()=>we("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ye==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Ye==="global",disabled:!Pe,onClick:()=>we("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Ye==="global"?"is-active":""}`,children:"Global"})]}),t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Ye==="session"?t.jsxs("div",{className:"grid gap-4",children:[w?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:w}):null,y?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:y}):null,me?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:v})})]})]})}function U(me=!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)] ${me?"justify-center":""}`,children:[t.jsx($.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:me?"sr-only":"",children:"Rooms"}),!me&&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&&Te.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,Te.length>0?t.jsx(Dm,{threads:Te,currentThreadId:p,currentWorkspaceId:f,workspaceLabels:N,onOpenThread:Je,collapsed:me,...de?{onBeginRenameThread:tt}:{},showDeleteButton:!!T,...L?{getThreadHref:L}:{},...W?{renderThreadLink:W}:{},...T?{onDeleteThread:T}:{}}):null]})]})})}function he(){return J?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:()=>ee(!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"})}),Y?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:Y})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:J})]}):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:A}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:g??f??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Y,t.jsx("button",{type:"button",onClick:()=>ee(!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:J??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:g??f??"All threads"})]})]})})]})}const Ee=!!J,Fe=s==="mobile"||s==="responsive"&&ie,Xe=Fe,rt=Xe&&!X,We=!!(j||S)?t.jsx("a",{href:j??"#",onClick:me=>{S&&(me.preventDefault(),S())},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(Tm,{effectiveTheme:z,layoutMode:s,themeMode:P,viewportConstrained:o,children:t.jsxs(Em,{roomsRailCollapsed:q,children:[t.jsx(Lm,{open:X,onClose:()=>_(!1)}),t.jsxs(Pm,{collapsed:q,mobileOpen:X,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3.75rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-3 sm:h-16 sm:items-center sm:pb-0 ${q?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${q?"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:()=>G(me=>!me),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:q?"Expand rooms":"Collapse rooms","aria-label":q?"Expand rooms":"Collapse rooms",children:q?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)] ${q?"thread-desktop-collapsed-hidden":""}`,children:(g??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${q?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:g??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:f??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${q?"thread-desktop-collapsed-hidden":""}`,children:[E(),We,t.jsx("button",{type:"button",onClick:()=>_(!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 ${q?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:Ge(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${q?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,q)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${q?"w-full px-2 py-2":"px-3 py-3"}`,children:U(q)})]}),t.jsxs(Im,{children:[t.jsxs(zm,{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 items-center gap-2 sm:gap-3",children:[rt?t.jsx("button",{type:"button",onClick:()=>_(!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:[Xe?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:m??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{ye(me=>!me)},"aria-expanded":ae,"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})]}),ae?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(26rem,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 me;et&&((me=navigator.clipboard)==null||me.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 room ID",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("button",{type:"button",onClick:()=>{var me;Ze&&((me=navigator.clipboard)==null||me.writeText(Ze))},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-12 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:Ze})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Room token usage",children:[t.jsx("span",{className:"w-12 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:it})]})]}):null]})]})]}),t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[b?t.jsx("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:b}):null,Xe?u:null,Xe&&h?Ge("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]})]})}),Xe&&Ee?t.jsxs("div",{className:"thread-mobile-view-switch thread-mobile-only-grid grid-cols-2 gap-1 px-3 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>Le("chat"),className:`thread-mobile-segment h-10 rounded-lg text-sm font-medium transition ${ge==="chat"?"is-active":""}`,children:"Chat"}),t.jsx("button",{type:"button",onClick:()=>Le("workspace"),className:`thread-mobile-segment h-10 rounded-lg text-sm font-medium transition ${ge==="workspace"?"is-active":""}`,children:"Workspace"})]}):null]}),t.jsx(Rm,{children:Ee&&!ce?Fe?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 ${ge==="chat"?"block":"thread-mobile-chat-hidden"}`,children:F}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${ge==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:he()})]}):t.jsxs(uo,{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(Ir,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:F}),t.jsx(mo,{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(Ir,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:he()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[Ee&&ce?t.jsx("button",{type:"button",onClick:()=>ee(!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,F]})})]})]})}),t.jsx(Sm,{open:re!==null,title:"Rename Thread",label:"Thread Title",value:je,busy:ze!==null,onChange:xe,onCancel:st,onSubmit:()=>re?$e(re):void 0})]})}function Gm({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?Mr.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 Fm=[/^(?: {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],Hm=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,Om=/!?\[[^\]\n]+\]\([^)]+\)/,Um=/`[^`\n]+`/,Wm=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,Vm=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,qm=/~~[^~\n]+~~/;function Km(e){const r=e.trim();return r?Fm.some(n=>n.test(r))||Hm.test(r)?!0:/[`[\]*_~!]/.test(r)?Om.test(r)||Um.test(r)||Wm.test(r)||Vm.test(r)||qm.test(r):!1:!1}Fr();function In(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 qn(e=[]){const r=In(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 Kn=c.createContext(qn());function Xn(){return c.useContext(Kn)??qn()}pr();function Vo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function es(e){return Vo(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function qo(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 Xm(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)}):qo(r)}function ts({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(()=>es(o),[o]),i=c.useMemo(()=>es(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:Vo(o)?["stdout","stderr","result"].some(m=>{const f=o[m];return typeof f=="string"&&f.length>0}):!1,[o]),h=n==="pending"||d,[u,p]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&p("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(cr,{type:"single",collapsible:!0,onValueChange:m=>p(m||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(hr,{value:"item-1",className:"border-0",children:[t.jsx(ur,{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(mr,{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(([m,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',m,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),qo(f),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},m)):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(([m,f],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',m,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),Xm(m,f),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},m)),"}"]})]}):null]})]})})})}var rs=null;function Ym(){return rs??(rs=Promise.all([Oe(()=>import("./core-oEok_Crl.js"),__vite__mapDeps([0,1,2])),Oe(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Oe(()=>import("./ayu-light-BA47KaF1.js"),[]),Oe(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Oe(()=>import("./javascript-wDzz0qaB.js"),[]),Oe(()=>import("./typescript-BPQ3VLAy.js"),[]),Oe(()=>import("./tsx-COt5Ahok.js"),[]),Oe(()=>import("./jsx-g9-lgVsj.js"),[]),Oe(()=>import("./python-B6aJPvgy.js"),[]),Oe(()=>import("./json-Cp-IABpG.js"),[]),Oe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Oe(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Oe(()=>import("./yaml-Buea-lGh.js"),[]),Oe(()=>import("./toml-vGWfd6FD.js"),[]),Oe(()=>import("./markdown-Cvjx9yec.js"),[]),Oe(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Oe(()=>import("./css-CLj8gQPS.js"),[]),Oe(()=>import("./sql-CRqJ_cUM.js"),[]),Oe(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,p,m,f,g,x,k,b,y])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,p.default,m.default,f.default,g.default,x.default,k.default,b.default,y.default]}))),rs}function Or(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function zn(e){if(!e)return{};if(Or(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 Rn(){return{finalResult:null,stdout:"",stderr:""}}function Zm(e){return typeof e=="string"?{result:e}:e}function Ko(e){const r=Or(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 ns(e){if(!e)return"pending";if(!Or(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 Jm(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=Zm(d.result),p=r.get(h)??Rn();return Or(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?p.stderr+=u.chunk:p.stdout+=u.chunk:p.finalResult=u,r.set(h,p),""}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 p=zn(d.args);if(typeof h=="string"&&r.has(h)){const m=Ko(r.get(h)??Rn());return`\`\`\`tool-merged
3594
3594
  ${JSON.stringify({call:{tool:u,args:p,call_id:h},result:m},null,2)}
3595
- \`\`\``}return l}catch{return l}}),resultMap:r}}function as(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ss(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Qm(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 ep({children:e,...r}){return tp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function tp(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 rp=c.memo(function({className:r="thread-graph-markdown",content:n}){const a=c.useRef(null),o=Xn(),[s,l]=c.useState(null),[i,d]=c.useState({}),[h,u]=c.useState(!1),{processedContent:p,resultMap:m}=c.useMemo(()=>Jm(n),[n]);c.useEffect(()=>{let x=!0;return Ym().then(k=>{x&&l(k)}).catch(()=>{}),()=>{x=!1}},[]),c.useEffect(()=>{const x=a.current,k=x==null?void 0:x.closest(".thread-ui-shell"),b=()=>k?k.getAttribute("data-theme-effective")==="dark"||k.classList.contains("dark")||k.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(u(b()),!k)return;const y=new MutationObserver(()=>u(b()));return y.observe(k,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function f(x,k){try{await navigator.clipboard.writeText(k),d(b=>({...b,[x]:"copied"})),window.setTimeout(()=>{d(b=>{const y={...b};return delete y[x],y})},1200)}catch{d(b=>({...b,[x]:"failed"}))}}const g=({children:x,className:k,inline:b,node:y,...w})=>{var H;const v=/language-(\w+(?:-\w+)*)/.exec(k||""),N=v?v[1]??"":"",j=ss(x).replace(/\n$/,""),{startLine:S,endLine:P}=Qm(y),C=b===!1||!!k||j.includes(`
3596
- `)||S!==P;if(N==="tool-merged"){let M={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{M=JSON.parse(j)}catch{M={call:{tool:"Error",args:{raw:j}},result:{status:"failed"}}}const Q=typeof M.call.tool=="string"?M.call.tool:"Unknown",V=typeof M.call.call_id=="string"?M.call.call_id:void 0;return t.jsx(ts,{callId:V,toolName:Q,status:ns(M.result),parameters:zn(M.call.args),result:M.result})}if(N==="tool-call"){let M={tool:"Unknown",args:{},call_id:void 0};try{M=JSON.parse(j)}catch{M={tool:"Error",args:{raw:j}}}const Q=typeof M.call_id=="string"?M.call_id:void 0,V=Q&&m.has(Q)?Ko(m.get(Q)??Rn()):void 0;return t.jsx(ts,{callId:Q,toolName:typeof M.tool=="string"?M.tool:"Unknown",status:V?ns(V):"pending",parameters:zn(M.args),result:V})}if(N==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(N)){const M=o.renderInlineCode({code:j,isIncomplete:!1,language:N});if(c.isValidElement(M))return M}if(C){const Q=(((H=s==null?void 0:s.getLoadedLanguages)==null?void 0:H.call(s))??[]).includes(N)?N:"text",V=h?"ayu-dark":"ayu-light",W=`${N||"text"}:${j.length}:${j.slice(0,32)}`;let Z="";if(s)try{Z=as(s.codeToHtml(j,{lang:Q,theme:V}))}catch{Z=as(s.codeToHtml(j,{lang:"text",theme:V}))}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(ir,{type:"button",onClick:()=>void f(W,j),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:i[W]==="copied"?"Copied":i[W]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:t.jsx(_.Copy,{className:"h-3.5 w-3.5"})}),Z?t.jsx("div",{dangerouslySetInnerHTML:{__html:Z}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:j})})]})}const F=ss(x).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${k||""}`,...w,children:F})};return t.jsx("div",{ref:a,className:`thread-graph-message-markdown ${r}`,children:t.jsx(ad,{remarkPlugins:[od,ld],rehypePlugins:[sd],components:{code:g,pre:ep},children:p})})}),os=4e3,np=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,ap=/[),.;:!?]+$/;function sp(e){return e.startsWith("www.")?`https://${e}`:e}function ls(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function op(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 Kt({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll(np)){const s=o[0],l=o.index??0,i=((a=s.match(ap))==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:sp(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 Xo=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}){const d=c.useRef(null),h=c.useRef(null),[u,p]=c.useState(!1),m=Km(r),f=!a&&r.length>os,g=f&&!u?`${r.slice(0,os).trimEnd()}
3595
+ \`\`\``}return l}catch{return l}}),resultMap:r}}function as(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function ss(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function Qm(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 ep({children:e,...r}){return tp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function tp(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 rp=c.memo(function({className:r="thread-graph-markdown",content:n}){const a=c.useRef(null),o=Xn(),[s,l]=c.useState(null),[i,d]=c.useState({}),[h,u]=c.useState(!1),{processedContent:p,resultMap:m}=c.useMemo(()=>Jm(n),[n]);c.useEffect(()=>{let x=!0;return Ym().then(k=>{x&&l(k)}).catch(()=>{}),()=>{x=!1}},[]),c.useEffect(()=>{const x=a.current,k=x==null?void 0:x.closest(".thread-ui-shell"),b=()=>k?k.getAttribute("data-theme-effective")==="dark"||k.classList.contains("dark")||k.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(u(b()),!k)return;const y=new MutationObserver(()=>u(b()));return y.observe(k,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function f(x,k){try{await navigator.clipboard.writeText(k),d(b=>({...b,[x]:"copied"})),window.setTimeout(()=>{d(b=>{const y={...b};return delete y[x],y})},1200)}catch{d(b=>({...b,[x]:"failed"}))}}const g=({children:x,className:k,inline:b,node:y,...w})=>{var O;const v=/language-(\w+(?:-\w+)*)/.exec(k||""),N=v?v[1]??"":"",j=ss(x).replace(/\n$/,""),{startLine:S,endLine:L}=Qm(y),C=b===!1||!!k||j.includes(`
3596
+ `)||S!==L;if(N==="tool-merged"){let M={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{M=JSON.parse(j)}catch{M={call:{tool:"Error",args:{raw:j}},result:{status:"failed"}}}const Q=typeof M.call.tool=="string"?M.call.tool:"Unknown",V=typeof M.call.call_id=="string"?M.call.call_id:void 0;return t.jsx(ts,{callId:V,toolName:Q,status:ns(M.result),parameters:zn(M.call.args),result:M.result})}if(N==="tool-call"){let M={tool:"Unknown",args:{},call_id:void 0};try{M=JSON.parse(j)}catch{M={tool:"Error",args:{raw:j}}}const Q=typeof M.call_id=="string"?M.call_id:void 0,V=Q&&m.has(Q)?Ko(m.get(Q)??Rn()):void 0;return t.jsx(ts,{callId:Q,toolName:typeof M.tool=="string"?M.tool:"Unknown",status:V?ns(V):"pending",parameters:zn(M.args),result:V})}if(N==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(N)){const M=o.renderInlineCode({code:j,isIncomplete:!1,language:N});if(c.isValidElement(M))return M}if(C){const Q=(((O=s==null?void 0:s.getLoadedLanguages)==null?void 0:O.call(s))??[]).includes(N)?N:"text",V=h?"ayu-dark":"ayu-light",W=`${N||"text"}:${j.length}:${j.slice(0,32)}`;let Z="";if(s)try{Z=as(s.codeToHtml(j,{lang:Q,theme:V}))}catch{Z=as(s.codeToHtml(j,{lang:"text",theme:V}))}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(ir,{type:"button",onClick:()=>void f(W,j),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:i[W]==="copied"?"Copied":i[W]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:t.jsx($.Copy,{className:"h-3.5 w-3.5"})}),Z?t.jsx("div",{dangerouslySetInnerHTML:{__html:Z}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:j})})]})}const H=ss(x).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${k||""}`,...w,children:H})};return t.jsx("div",{ref:a,className:`thread-graph-message-markdown ${r}`,children:t.jsx(ad,{remarkPlugins:[od,ld],rehypePlugins:[sd],components:{code:g,pre:ep},children:p})})}),os=4e3,np=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,ap=/[),.;:!?]+$/;function sp(e){return e.startsWith("www.")?`https://${e}`:e}function ls(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function op(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 Kt({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll(np)){const s=o[0],l=o.index??0,i=((a=s.match(ap))==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:sp(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 Xo=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}){const d=c.useRef(null),h=c.useRef(null),[u,p]=c.useState(!1),m=Km(r),f=!a&&r.length>os,g=f&&!u?`${r.slice(0,os).trimEnd()}
3597
3597
 
3598
- ...`:r,[x,k]=c.useState(a||typeof IntersectionObserver>"u"),b=c.useCallback(()=>{const y=n.current,w=d.current,v=(w==null?void 0:w.getBoundingClientRect().top)??null;i==null||i(),h.current=y&&v!==null?{root:y,top:v}:null,p(N=>!N)},[i,n]);return c.useLayoutEffect(()=>{const y=h.current,w=d.current;if(!y||!w)return;h.current=null;const v=()=>{const j=w.getBoundingClientRect().top;y.root.scrollTop+=j-y.top};v();const N=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(N)}},[u]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){k(!0);return}if(x||!d.current)return;const y=new IntersectionObserver(w=>{for(const v of w)if(v.isIntersecting){k(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(d.current),()=>{y.disconnect()}},[x,n,a]),t.jsxs("div",{ref:d,className:o,children:[x&&m?t.jsx(rp,{content:g,className:l}):t.jsx("p",{className:s,children:t.jsx(Kt,{text:g})}),f?t.jsx("button",{type:"button",onClick:b,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:u?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),lp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o}){return t.jsx(Xo,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{}})}),ip=c.memo(function({threadId:r,text:n,getImageAssetUrl:a}){const o=c.useMemo(()=>op(n),[n]);return t.jsx("div",{className:"thread-graph-message-prose whitespace-pre-wrap break-words text-[15px] leading-6",children:o.map(s=>{if(s.type==="text")return t.jsx("span",{children:s.text},s.key);if(s.type==="photo"){const i=r?(a==null?void 0:a({threadId:r,path:s.path}))??null:null,d=ls(s.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:[i?t.jsx("img",{src:i,alt:d,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:s.path,children:d})]})},s.key)}const l=ls(s.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:s.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:l})]})},s.key)})})});function dp(){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 is({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(dp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function cp({children:e,copyButton:r,kind:n,reasoning:a,status:o,timeLabel:s,timeTitle:l}){const i=n==="userMessage",d=s?t.jsx("time",{dateTime:l??void 0,title:l??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:s}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":i?"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 ${i?"is-user":"is-assistant"}`,children:[i?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(is,{status:o??"Complete"})]}),r||d?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,d]}):null]}),a,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${i?"is-user":"is-assistant"}`,children:e}),i&&(o||d)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[o?t.jsx(is,{status:o}):null,d]}):null]})})}pr();function un(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 Rt=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"),[p,m]=c.useState(!1),f=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],x=g.map(v=>v.text.trim()).filter(Boolean).join(`
3598
+ ...`:r,[x,k]=c.useState(a||typeof IntersectionObserver>"u"),b=c.useCallback(()=>{const y=n.current,w=d.current,v=(w==null?void 0:w.getBoundingClientRect().top)??null;i==null||i(),h.current=y&&v!==null?{root:y,top:v}:null,p(N=>!N)},[i,n]);return c.useLayoutEffect(()=>{const y=h.current,w=d.current;if(!y||!w)return;h.current=null;const v=()=>{const j=w.getBoundingClientRect().top;y.root.scrollTop+=j-y.top};v();const N=window.requestAnimationFrame(v);return()=>{window.cancelAnimationFrame(N)}},[u]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){k(!0);return}if(x||!d.current)return;const y=new IntersectionObserver(w=>{for(const v of w)if(v.isIntersecting){k(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(d.current),()=>{y.disconnect()}},[x,n,a]),t.jsxs("div",{ref:d,className:o,children:[x&&m?t.jsx(rp,{content:g,className:l}):t.jsx("p",{className:s,children:t.jsx(Kt,{text:g})}),f?t.jsx("button",{type:"button",onClick:b,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:u?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),lp=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o}){return t.jsx(Xo,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{}})}),ip=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>op(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=ls(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=ls(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 dp(){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 is({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(dp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function cp({children:e,copyButton:r,kind:n,reasoning:a,status:o,timeLabel:s,timeTitle:l}){const i=n==="userMessage",d=s?t.jsx("time",{dateTime:l??void 0,title:l??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:s}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":i?"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 ${i?"is-user":"is-assistant"}`,children:[i?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(is,{status:o??"Complete"})]}),r||d?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,d]}):null]}),a,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${i?"is-user":"is-assistant"}`,children:e}),i&&(o||d)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[o?t.jsx(is,{status:o}):null,d]}):null]})})}pr();function un(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 Rt=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"),[p,m]=c.useState(!1),f=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],x=g.map(v=>v.text.trim()).filter(Boolean).join(`
3599
3599
 
3600
- `),k=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);async function b(){try{await navigator.clipboard.writeText(n.text),u("copied"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>u("idle"),1600)}}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 b(),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(_.Copy,{className:"h-3.5 w-3.5"})}):null,w=n.kind==="agentMessage"&&x?t.jsx("div",{className:"thread-graph-message-thinking mb-3 mt-2",children:t.jsx(cr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:v=>m(!!v),...p?{value:"thoughts"}:{},children:t.jsxs(hr,{value:"thoughts",className:"border-b-0",children:[t.jsx(ur,{className:"thread-graph-thinking-trigger py-2 hover:no-underline",children:t.jsxs("div",{className:"thread-graph-thinking-label flex items-center gap-2 text-sm font-medium transition-colors",children:[t.jsx(_.Brain,{className:`h-4 w-4 ${g.some(v=>un(v.status))?"animate-pulse":""}`}),t.jsx("span",{children:g.some(v=>un(v.status))?"Thinking...":"Thought Process"}),g.some(v=>un(v.status))?t.jsx(hp,{tone:"sky"}):null]})}),t.jsx(mr,{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(Kt,{text:x})})})]})})}):null;return t.jsx(cp,{kind:n.kind,status:k||n.kind==="agentMessage"?n.status:null,copyButton:y,reasoning:w,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(lp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{}}):t.jsx(ip,{threadId:r,text:n.text,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function ds(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Yo(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?ds(r[1]):null,a=ds(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 up(e){return e==="userMessage"||e==="agentMessage"}function mp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function pp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function fp(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&&mp(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=>pp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function xt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function kr(e){return xt(e)?e.sequence:Number.POSITIVE_INFINITY}function cs(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!xt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(xt))return e;const o=a.map(u=>kr(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(xt(u)){l.push({item:u,index:i,order:kr(u)}),i+=1;continue}const p=i;for(;i<a.length&&!xt(a[i]);)i+=1;const m=a.slice(p,i),f=[...a.slice(0,p)].reverse().find(xt),g=a.slice(i).find(xt),x=f?kr(f):null,k=g?kr(g):null;m.forEach((b,y)=>{let w;if(x===null&&k!==null)w=k-(m.length-y)/(m.length+1);else if(x!==null&&k!==null&&k>x){const v=k-x;w=x+(y+1)/(m.length+1)*v}else w=s+1+y/(m.length+1);l.push({item:b,index:p+y,order:w})})}const d=l.sort((u,p)=>{const m=u.order-p.order;return m===0?u.index-p.index:m}).map(u=>u.item);return[...r,...d]}function gp(e,r){if(!r||r.length===0)return cs(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,p=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),p!==void 0&&(i.sequence=p),i}),o=[...n.values()];return o.length===0&&!a.some(xt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:cs(a)}function xp(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 Zo(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Ar(e){return e==="inProgress"||e==="sending"}function bp(e){var d,h;const r=[];let n=0;const a=new Set,o=[];function s(){const u=r.at(-1);return(u==null?void 0:u.kind)!=="item"||u.item.kind!=="agentMessage"?null:u}function l(u,p){if(p.length!==0){u.item={...u.item,reasoningItems:[...u.item.reasoningItems??[],...p]};for(const m of p)a.add(m.id)}}function i(){const u=o.splice(0);for(const p of u)r.push({kind:"item",key:p.id,item:p})}for(;n<e.length;){const u=e[n];if(!u)break;if(a.has(u.id)){n+=1;continue}if(u.kind==="reasoning"){let f=n;const g=[];for(;f<e.length&&((d=e[f])==null?void 0:d.kind)==="reasoning";)g.push(e[f]),f+=1;const x=s();x?l(x,g):o.push(...g),n=f;continue}if(u.kind==="agentMessage"){const f=o.splice(0),g={kind:"item",key:u.id,item:u};l(g,f),r.push(g),n+=1;continue}if(u.kind!=="commandExecution"&&u.kind!=="fileChange"&&u.kind!=="webSearch"&&u.kind!=="fileRead"){r.push({kind:"item",key:u.id,item:u}),n+=1;continue}const p=[];for(;n<e.length&&((h=e[n])==null?void 0:h.kind)===u.kind;)p.push(e[n]),n+=1;if(p.length===1){r.push({kind:"item",key:p[0].id,item:p[0]});continue}const m=p.map(f=>f.id).join(":");if(u.kind==="commandExecution"){r.push({kind:"commandGroup",key:m,items:p});continue}if(u.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:m,items:p});continue}if(u.kind==="fileRead"){r.push({kind:"fileReadGroup",key:m,items:p});continue}r.push({kind:"searchGroup",key:m,items:p})}return i(),r}function Jo(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function sr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function Qo(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function vp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(f=>f.id)),s=new Map,l=new Map,i=[],d=[];for(const f of e)f.turnId&&o.has(f.turnId)?sr(s,f.turnId,f):i.push(f);for(const f of r)f.turnId&&o.has(f.turnId)?sr(l,f.turnId,f):d.push(f);const h=Jo(n,a),u=new Map,p=[],m=[...i.map(f=>({kind:"note",id:f.id,createdAt:f.createdAt??"",note:f})),...d.map(f=>({kind:"request",id:f.id,createdAt:f.createdAt,request:f}))].sort((f,g)=>f.createdAt.localeCompare(g.createdAt));for(const f of m){const g=Qo(h,f.createdAt);if(!g){p.push(f);continue}sr(u,g.id,f)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:p}}function kp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((p,m)=>p.createdAt.localeCompare(m.createdAt)),o=Jo(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(p=>p.startedAt).filter(p=>!!p).sort().at(-1)??null;for(const p of a){if(p.anchorTurnId==="__leading__"){s.push(p);continue}if(p.anchorTurnId){o.some(f=>f.id===p.anchorTurnId)?sr(i,p.anchorTurnId,p):s.push(p);continue}const m=Qo(o,p.createdAt);if(!m){!u||p.createdAt.localeCompare(u)<=0?s.push(p):d.push(p);continue}sr(l,m.id,p)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function el({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__",p=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function m(b){const y=/\s*\(recommended\)\s*$/i.test(b);return{rawLabel:b,displayLabel:b.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:y}}function f(b){h&&(d(b),n==null||n(e.id,{answers:{[h.id]:{answers:[b]}}}))}function g(b){const y=a[b.id]??"";return Array.isArray(y)?y.map(w=>w===u?(s[b.id]??"").trim():w.trim()).filter(Boolean).join(", "):y===u?(s[b.id]??"").trim():y.trim()}function x(b){const y=a[b.id]??"";if(Array.isArray(y))return y.map(v=>v===u?(s[b.id]??"").trim():v.trim()).filter(Boolean);if(y===u){const v=(s[b.id]??"").trim();return v?[v]:[]}const w=y.trim();return w?[w]:[]}function k(b,y){o(w=>{const v=w[b],N=Array.isArray(v)?v:[],j=N.includes(y)?N.filter(S=>S!==y):[...N,y];return{...w,[b]:j}})}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:p}),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(b=>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:b.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:b.question}),e.kind==="planDecision"&&b.options&&b.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:b.options.map((y,w)=>{const v=m(y.label),N=v.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>f(y.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:y.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===y.label?N?"Starting...":"Saving...":v.displayLabel]},y.label)})}):b.options&&b.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[b.options.map(y=>{const w=m(y.label),v=a[b.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?k(b.id,y.label):o(N=>({...N,[b.id]:y.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(b.multiSelect?Array.isArray(v)&&v.includes(y.label):v===y.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.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]},y.label)}),b.isOther&&(()=>{const y=a[b.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?k(b.id,u):o(w=>({...w,[b.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(b.multiSelect?Array.isArray(y)&&y.includes(u):y===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"})})()]}),b.isOther&&(()=>{const y=a[b.id];return(b.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?t.jsx("input",{"aria-label":`${b.header} custom answer`,value:s[b.id]??"",onChange:v=>l(N=>({...N,[b.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":b.header,value:a[b.id]??"",onChange:y=>o(w=>({...w,[b.id]:y.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"})]},b.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(b=>!g(b)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(b=>[b.id,{answers:x(b)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function tl({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 rl({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:qt(e.createdAt),className:"timeline-meta-text text-[10px]",children:zt(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 er({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(rl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function An({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(tl,{note:a.note},a.id):t.jsx(el,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function wp({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(An,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function yp({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(rl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(tl,{note:s.note},s.id):t.jsx(el,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function jp({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 Ur({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,toggleAriaLabel:p,trailingSummary:m}){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":p,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}),m]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}pr();yt();var Np=dr("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 Wr({asChild:e=!1,className:r,variant:n,...a}){const o=e?js:"span";return t.jsx(o,{"data-slot":"badge",className:Qe(Np({variant:n,className:r})),...a})}function Vr(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Cp(){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 Sp(){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 Tp(){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 Ep(){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 Lp(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 nl(e,r=42){const n=Lp(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 p=i[u],m=h+p.length+(d.length>0?1:0);if(d.length>0&&m>r)break;d.unshift(p),h=m}if(d.length>0)return`.../${d.join("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function Pp(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 Mn({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 Ip(e){var n;const r=e.replace(/\r\n/g,`
3600
+ `),k=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current)},[]);async function b(){try{await navigator.clipboard.writeText(n.text),u("copied"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>u("idle"),1600)}}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 b(),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($.Copy,{className:"h-3.5 w-3.5"})}):null,w=n.kind==="agentMessage"&&x?t.jsx("div",{className:"thread-graph-message-thinking mb-3 mt-2",children:t.jsx(cr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:v=>m(!!v),...p?{value:"thoughts"}:{},children:t.jsxs(hr,{value:"thoughts",className:"border-b-0",children:[t.jsx(ur,{className:"thread-graph-thinking-trigger py-2 hover:no-underline",children:t.jsxs("div",{className:"thread-graph-thinking-label flex items-center gap-2 text-sm font-medium transition-colors",children:[t.jsx($.Brain,{className:`h-4 w-4 ${g.some(v=>un(v.status))?"animate-pulse":""}`}),t.jsx("span",{children:g.some(v=>un(v.status))?"Thinking...":"Thought Process"}),g.some(v=>un(v.status))?t.jsx(hp,{tone:"sky"}):null]})}),t.jsx(mr,{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(Kt,{text:x})})})]})})}):null;return t.jsx(cp,{kind:n.kind,status:k||n.kind==="agentMessage"?n.status:null,copyButton:y,reasoning:w,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(lp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{}}):t.jsx(ip,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function ds(e){return e.replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Yo(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?ds(r[1]):null,a=ds(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 up(e){return e==="userMessage"||e==="agentMessage"}function mp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function pp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function fp(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&&mp(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=>pp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function xt(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function kr(e){return xt(e)?e.sequence:Number.POSITIVE_INFINITY}function cs(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!xt(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(xt))return e;const o=a.map(u=>kr(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(xt(u)){l.push({item:u,index:i,order:kr(u)}),i+=1;continue}const p=i;for(;i<a.length&&!xt(a[i]);)i+=1;const m=a.slice(p,i),f=[...a.slice(0,p)].reverse().find(xt),g=a.slice(i).find(xt),x=f?kr(f):null,k=g?kr(g):null;m.forEach((b,y)=>{let w;if(x===null&&k!==null)w=k-(m.length-y)/(m.length+1);else if(x!==null&&k!==null&&k>x){const v=k-x;w=x+(y+1)/(m.length+1)*v}else w=s+1+y/(m.length+1);l.push({item:b,index:p+y,order:w})})}const d=l.sort((u,p)=>{const m=u.order-p.order;return m===0?u.index-p.index:m}).map(u=>u.item);return[...r,...d]}function gp(e,r){if(!r||r.length===0)return cs(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,p=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),p!==void 0&&(i.sequence=p),i}),o=[...n.values()];return o.length===0&&!a.some(xt)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:cs(a)}function xp(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 Zo(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Ar(e){return e==="inProgress"||e==="sending"}function bp(e){var d,h;const r=[];let n=0;const a=new Set,o=[];function s(){const u=r.at(-1);return(u==null?void 0:u.kind)!=="item"||u.item.kind!=="agentMessage"?null:u}function l(u,p){if(p.length!==0){u.item={...u.item,reasoningItems:[...u.item.reasoningItems??[],...p]};for(const m of p)a.add(m.id)}}function i(){const u=o.splice(0);for(const p of u)r.push({kind:"item",key:p.id,item:p})}for(;n<e.length;){const u=e[n];if(!u)break;if(a.has(u.id)){n+=1;continue}if(u.kind==="reasoning"){let f=n;const g=[];for(;f<e.length&&((d=e[f])==null?void 0:d.kind)==="reasoning";)g.push(e[f]),f+=1;const x=s();x?l(x,g):o.push(...g),n=f;continue}if(u.kind==="agentMessage"){const f=o.splice(0),g={kind:"item",key:u.id,item:u};l(g,f),r.push(g),n+=1;continue}if(u.kind!=="commandExecution"&&u.kind!=="fileChange"&&u.kind!=="webSearch"&&u.kind!=="fileRead"){r.push({kind:"item",key:u.id,item:u}),n+=1;continue}const p=[];for(;n<e.length&&((h=e[n])==null?void 0:h.kind)===u.kind;)p.push(e[n]),n+=1;if(p.length===1){r.push({kind:"item",key:p[0].id,item:p[0]});continue}const m=p.map(f=>f.id).join(":");if(u.kind==="commandExecution"){r.push({kind:"commandGroup",key:m,items:p});continue}if(u.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:m,items:p});continue}if(u.kind==="fileRead"){r.push({kind:"fileReadGroup",key:m,items:p});continue}r.push({kind:"searchGroup",key:m,items:p})}return i(),r}function Jo(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function sr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function Qo(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function vp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(f=>f.id)),s=new Map,l=new Map,i=[],d=[];for(const f of e)f.turnId&&o.has(f.turnId)?sr(s,f.turnId,f):i.push(f);for(const f of r)f.turnId&&o.has(f.turnId)?sr(l,f.turnId,f):d.push(f);const h=Jo(n,a),u=new Map,p=[],m=[...i.map(f=>({kind:"note",id:f.id,createdAt:f.createdAt??"",note:f})),...d.map(f=>({kind:"request",id:f.id,createdAt:f.createdAt,request:f}))].sort((f,g)=>f.createdAt.localeCompare(g.createdAt));for(const f of m){const g=Qo(h,f.createdAt);if(!g){p.push(f);continue}sr(u,g.id,f)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:p}}function kp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((p,m)=>p.createdAt.localeCompare(m.createdAt)),o=Jo(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(p=>p.startedAt).filter(p=>!!p).sort().at(-1)??null;for(const p of a){if(p.anchorTurnId==="__leading__"){s.push(p);continue}if(p.anchorTurnId){o.some(f=>f.id===p.anchorTurnId)?sr(i,p.anchorTurnId,p):s.push(p);continue}const m=Qo(o,p.createdAt);if(!m){!u||p.createdAt.localeCompare(u)<=0?s.push(p):d.push(p);continue}sr(l,m.id,p)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function el({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__",p=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function m(b){const y=/\s*\(recommended\)\s*$/i.test(b);return{rawLabel:b,displayLabel:b.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:y}}function f(b){h&&(d(b),n==null||n(e.id,{answers:{[h.id]:{answers:[b]}}}))}function g(b){const y=a[b.id]??"";return Array.isArray(y)?y.map(w=>w===u?(s[b.id]??"").trim():w.trim()).filter(Boolean).join(", "):y===u?(s[b.id]??"").trim():y.trim()}function x(b){const y=a[b.id]??"";if(Array.isArray(y))return y.map(v=>v===u?(s[b.id]??"").trim():v.trim()).filter(Boolean);if(y===u){const v=(s[b.id]??"").trim();return v?[v]:[]}const w=y.trim();return w?[w]:[]}function k(b,y){o(w=>{const v=w[b],N=Array.isArray(v)?v:[],j=N.includes(y)?N.filter(S=>S!==y):[...N,y];return{...w,[b]:j}})}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:p}),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(b=>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:b.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:b.question}),e.kind==="planDecision"&&b.options&&b.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:b.options.map((y,w)=>{const v=m(y.label),N=v.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>f(y.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:y.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===y.label?N?"Starting...":"Saving...":v.displayLabel]},y.label)})}):b.options&&b.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[b.options.map(y=>{const w=m(y.label),v=a[b.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?k(b.id,y.label):o(N=>({...N,[b.id]:y.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(b.multiSelect?Array.isArray(v)&&v.includes(y.label):v===y.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:y.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]},y.label)}),b.isOther&&(()=>{const y=a[b.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>b.multiSelect?k(b.id,u):o(w=>({...w,[b.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(b.multiSelect?Array.isArray(y)&&y.includes(u):y===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"})})()]}),b.isOther&&(()=>{const y=a[b.id];return(b.multiSelect?Array.isArray(y)&&y.includes(u):y===u)?t.jsx("input",{"aria-label":`${b.header} custom answer`,value:s[b.id]??"",onChange:v=>l(N=>({...N,[b.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":b.header,value:a[b.id]??"",onChange:y=>o(w=>({...w,[b.id]:y.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"})]},b.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(b=>!g(b)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(b=>[b.id,{answers:x(b)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function tl({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 rl({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:qt(e.createdAt),className:"timeline-meta-text text-[10px]",children:zt(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 er({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(rl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function An({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(tl,{note:a.note},a.id):t.jsx(el,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function wp({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(An,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function yp({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(rl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(tl,{note:s.note},s.id):t.jsx(el,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function jp({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 Ur({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,toggleAriaLabel:p,trailingSummary:m}){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":p,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}),m]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}pr();yt();var Np=dr("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 Wr({asChild:e=!1,className:r,variant:n,...a}){const o=e?js:"span";return t.jsx(o,{"data-slot":"badge",className:Qe(Np({variant:n,className:r})),...a})}function Vr(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Cp(){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 Sp(){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 Tp(){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 Ep(){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 Lp(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 nl(e,r=42){const n=Lp(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 p=i[u],m=h+p.length+(d.length>0?1:0);if(d.length>0&&m>r)break;d.unshift(p),h=m}if(d.length>0)return`.../${d.join("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function Pp(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 Mn({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 Ip(e){var n;const r=e.replace(/\r\n/g,`
3601
3601
  `).split(`
3602
- `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function mt(e){const r=Ip(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function al(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"}:Vr(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 zp(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 Rp(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 _t({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,title:l,tone:i}){const d=al(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Rp(i)} ${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:l}),s.status?t.jsxs(Wr,{variant:"outline",className:`thread-graph-tool-badge ${d.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:d.label,"aria-label":`Status: ${d.label}`,children:[d.icon,t.jsx("span",{className:"thread-graph-status-label",children:d.label})]}):null,a]}),e?t.jsx("div",{className:"thread-graph-history-event-actions",children:e}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function Yt({actionLabel:e="Open details",actionTitle:r,className:n,details:a,icon:o,item:s,onOpen:l,preview:i,title:d,tone:h}){const u=al(s.status),[p,m]=c.useState(Vr(s.status)?"item-1":void 0);return t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${zp(h)} ${n??""}`,children:t.jsx(cr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",...p!==void 0?{value:p}:{},children:t.jsxs(hr,{value:"item-1",className:"border-0",children:[t.jsx(ur,{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:o}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:d}),t.jsxs(Wr,{variant:"outline",className:`thread-graph-tool-badge ${u.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:u.label,"aria-label":`Status: ${u.label}`,children:[u.icon,t.jsx("span",{className:"thread-graph-status-label",children:u.label})]})]})}),t.jsxs(mr,{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(Kt,{text:i.firstLine}),i.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),a?t.jsx("section",{children:a}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:l,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 Ap=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a}){return t.jsx(_t,{className:"thread-graph-event-plan",icon:t.jsx(_.ClipboardList,{className:"h-4 w-4"}),item:r,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(Xo,{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}:{}})})})}),Mp=c.memo(function({item:r}){const n=Vr(r.status)||r.text==="Compacting context",a=n?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==a?r.detailText:null;return t.jsxs(_t,{className:"thread-graph-event-context",icon:t.jsx(_.Archive,{className:"h-4 w-4"}),item:r,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:a}),n?t.jsx(Mn,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),_p=c.memo(function({item:r}){return t.jsx(_t,{className:"thread-graph-event-generic",icon:t.jsx(_.Info,{className:"h-4 w-4"}),item:r,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(Kt,{text:r.text})})})}),$p=c.memo(function({item:r,onOpen:n}){const a=mt(r.previewText??r.text);return t.jsx(Yt,{actionLabel:"Open full command",actionTitle:"Command Output",className:"thread-graph-event-command",icon:t.jsx(_.Terminal,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Command Output"),preview:a,title:"command",tone:"command"})}),Dp=c.memo(function({item:r,onOpen:n}){const a=mt(r.text);return t.jsx(Yt,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",className:"thread-graph-event-tool",icon:t.jsx(_.Wrench,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Tool Call Details"),preview:a,title:"tool_call",tone:"tool"})}),Bp=c.memo(function({item:r,onOpen:n}){const a=mt(r.text);return t.jsx(Yt,{actionLabel:"Open agent details",actionTitle:"Agent Details",className:"thread-graph-event-agent-tool",icon:t.jsx(_.Bot,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Agent Details"),preview:a,title:"agent",tone:"agent"})}),Gp=c.memo(function({item:r,onOpen:n}){const a=mt(r.text);return t.jsx(Yt,{actionLabel:"Open skill details",actionTitle:"Skill Details",className:"thread-graph-event-skill-tool",icon:t.jsx(_.Sparkles,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Skill Details"),preview:a,title:"skill",tone:"skill"})}),Fp=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"Web search",o=((i=r.detailText)==null?void 0:i.trim())||r.text||"Web search",s=mt(a);return t.jsx(Yt,{actionLabel:"Open full web search",actionTitle:"Web Search Details",className:"thread-graph-event-search",icon:t.jsx(_.Search,{className:"h-4 w-4"}),item:r,onOpen:()=>n("Web Search Details",o),preview:s,title:"web_search",tone:"search"})}),Hp=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"File read",o=((i=r.detailText)==null?void 0:i.trim())||r.text||"File read",s=mt(a);return t.jsx(Yt,{actionLabel:"Open full file read",actionTitle:"File Read Details",className:"thread-graph-event-file-read",icon:t.jsx(_.FileText,{className:"h-4 w-4"}),item:r,onOpen:()=>n("File Read Details",o),preview:s,title:"file_read",tone:"fileRead"})}),Op=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o}){const s=n.assetPath??n.detailText??null,l=r&&s?(o==null?void 0:o({threadId:r,path:s}))??null:null;return t.jsxs(_t,{className:"thread-graph-event-image",icon:t.jsx(_.Image,{className:"h-4 w-4"}),item:n,title:"image",tone:"image",children:[l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",s??n.text),className:"block w-full text-left",children:t.jsx("img",{src:l,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}),s?t.jsx("button",{type:"button",onClick:()=>a("Image Path",s),className:"thread-graph-history-event-path",title:s,children:s}):null]})}),Up=c.memo(function({item:r,onOpen:n}){var u,p,m;const a=(u=r.previewText)!=null&&u.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((p=r.detailText)==null?void 0:p.trim())||null,s=nl(a??((m=r.previewText)==null?void 0:m.trim())??r.text,48),l=Pp(r),i=!!(o||r.hasDeferredDetail),d=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:a??s,children:s}),l.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:l.map(f=>t.jsx("span",{className:`thread-graph-history-delta-badge ${f.startsWith("+")?"is-add":f.startsWith("-")?"is-remove":"is-neutral"}`,children:f},f))})]}),h=i?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",o??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:a??s,children:d}):d;return t.jsx(_t,{className:"thread-graph-event-file-change",headerMeta:h,icon:t.jsx(_.FilePenLine,{className:"h-4 w-4"}),item:r,title:"file_change",tone:"fileChange"})}),Wp=c.memo(function({item:r,onSelect:n}){const a=Xn(),[o,s]=c.useState(!1),l=r.artifact,i=l?a.renderArtifact({artifact:l,expanded:o,onToggleExpanded:()=>s(d=>!d)}):null;return t.jsx(_t,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[l&&!a.hasRendererForArtifact(l)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,l&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${l.title}`,onClick:()=>n(r,l),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,title:(l==null?void 0:l.type)??"artifact",tone:"artifact",children:i??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>s(d=>!d),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:(l==null?void 0:l.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(l==null?void 0:l.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:o?"Hide":"Open"})]}),o?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((l==null?void 0:l.payload)??r,null,2)}):null]})})}),Vp=c.memo(function({item:r}){var d,h;const n=((d=r.hookOutputEntries)==null?void 0:d.map(u=>u.text.trim()).filter(Boolean).join(`
3603
- `).trim())??"",a=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((h=r.hookStatusMessage)==null?void 0:h.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),l=mt(n||(o&&o!==a?o:a)),i=!!(n&&l.showGap);return t.jsx(_t,{className:"thread-graph-event-hook",icon:t.jsx(_.Webhook,{className:"h-4 w-4"}),item:r,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:n?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:a}),t.jsx(Kt,{text:l.firstLine})]}):t.jsx(Kt,{text:l.firstLine&&l.firstLine!==a?`${a} · ${l.firstLine}`:a})}),i?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),qp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.filter(i=>Vr(i.status)).length,l=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Ur,{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(Tp,{}),onToggleExpanded:a,runningIndicator:s>0?t.jsx(Mn,{}):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:l}),s>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Mn,{})}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((i,d)=>{const h=mt(i.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${d+1}`,onClick:()=>o(i,`Command Output ${d+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 ",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:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Kp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.length===1?"1 search":`${r.length} searches`;return t.jsx(Ur,{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(Ep,{}),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:s})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((l,i)=>{var p,m;const d=((p=l.previewText)==null?void 0:p.trim())||l.text||"Web search",h=mt(d),u=((m=l.detailText)==null?void 0:m.trim())||l.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${i+1}`,onClick:()=>o(`Web Search ${i+1}`,u),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 ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.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:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),Xp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(Ur,{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(Sp,{}),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:s})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((l,i)=>{var p,m;const d=((p=l.previewText)==null?void 0:p.trim())||l.text||"File read",h=mt(d),u=((m=l.detailText)==null?void 0:m.trim())||l.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${i+1}`,onClick:()=>o(`File Read ${i+1}`,u),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 ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.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:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),Yp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.reduce((h,u)=>h+(u.changedFiles??0),0),l=r.reduce((h,u)=>h+(u.addedLines??0),0),i=r.reduce((h,u)=>h+(u.removedLines??0),0),d=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(Ur,{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(Cp,{}),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:d}),s>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[s," files"]}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[l>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",l]}):null,i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",i]}):null]}),children:r.map((h,u)=>{var f,g,x,k;const p=((f=h.detailText)==null?void 0:f.trim())||((g=h.previewText)==null?void 0:g.trim())||h.text,m=(x=h.previewText)!=null&&x.trim()&&h.text.trim()!==h.previewText.trim()?h.text.trim():((k=h.previewText)==null?void 0:k.trim())||h.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${u+1}`,onClick:()=>o(`File Change ${u+1}`,p),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:m,children:nl(m,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(h.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",h.addedLines]}):null,(h.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",h.removedLines]}):null]})]})},h.id)})})});function Zp(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 Jp({status:e}){const r=Zp(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(Wr,{"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 Qp({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(Wr,{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(Jp,{status:r.status})]},`${e.turnId}-${n}`))})]})}function ef({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(Qp,{livePlan:o}):null,n??a??null,e]})}function tf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,onToggleCollapse:d,refCallback:h,startedAt:u,timeLabel:p,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:h,"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.jsxs("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:u??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:p}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]}),t.jsx("button",{type:"button","aria-label":`${n?"Expand":"Collapse"} turn ${e}`,title:n?"Expand turn":"Collapse turn",onClick:d,className:"thread-graph-turn-collapse inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md transition",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.6",strokeLinecap:"round",strokeLinejoin:"round",children:n?t.jsx("path",{d:"m4.5 10 3.5-3.5L11.5 10"}):t.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6"})})})]}),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 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.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 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.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 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.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 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.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 wr(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 of(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 ar(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function yr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function sl(e){var i,d,h,u,p;const r=(i=e.tokenUsage)==null?void 0:i.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens,0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.reasoningOutputTokens,0),s=Math.max(r.outputTokens-o,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:wr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(rf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:wr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(af,{})}:null,s>0?{id:"out",label:"Output",tokenCompactValue:wr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ar(yr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:yr((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-out",icon:t.jsx(nf,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:wr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ar(yr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:yr((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(sf,{})}:null].filter(m=>m!==null)}function lf(e){return sl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function ol(e){return{label:e.priceEstimate?of(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ar(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var mn="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=sl(e),n=ol(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),p=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const f=()=>{const g=h.current,x=p.current;if(!g||!x)return;const k=g.getBoundingClientRect(),b=x.offsetWidth||x.getBoundingClientRect().width;if(b<=0)return;const y=window.innerWidth||document.documentElement.clientWidth,w=12,v=k.left+k.width/2-b/2,N=w,j=Math.max(N,y-w-b),S=Math.min(Math.max(v,N),j);d(Math.round(S-v))};return f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const f=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",f),()=>{document.removeEventListener("pointerdown",f)}},[s,a]),!n&&r.length===0)return null;const m=()=>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(f=>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:`${f.label}: ${f.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:f.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:f.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:f.tokenCompactValue})]},f.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:`${mn} 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:m()}):null]}):null,r.map(f=>t.jsxs("span",{className:`${mn} ${f.className}`,title:`${f.label}: ${f.usdCompactValue}, ${f.tokenRawValue} tokens`,children:[f.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:f.tokenCompactValue})]},f.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(f=>!f),className:`${mn} 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:p,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:m()}):null]})]})}function cf({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 hs(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 hf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!Zo(e.status);default:return!1}}function uf(e,r,n){if(!e||!Ar(n))return e;const a=e.plan.findIndex(i=>hs(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&hs(i.status)==="pending");if(o<0||!r.some(i=>hf(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 mf(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 us({status:e}){const r=Wo(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(cf,{tone:"emerald"})})}function ms({turn:e,variant:r="header"}){const n=Wo(e.status),a=mf(e),o=lf(e),s=ol(e),l=Ar(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(us,{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:qt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:zt(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(us,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function pf(e,r){return e.createdAt??r}var Yn=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:p,timeTitle:m}){var f,g,x;if(up(n.kind))return t.jsx(Rt,{threadId:r,item:n,scrollRootRef:a,timeLabel:p,timeTitle:m,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="artifact")return t.jsx(Wp,{item:n,...d?{onSelect:(k,b)=>d({item:k,artifact:b})}:{}});if(n.kind==="commandExecution")return t.jsx($p,{item:n,onOpen:s});if(n.kind==="toolCall")return t.jsx(Dp,{item:n,onOpen:l});if(n.kind==="agentToolCall")return t.jsx(Bp,{item:n,onOpen:l});if(n.kind==="skillToolCall")return t.jsx(Gp,{item:n,onOpen:l});if(n.kind==="webSearch"){const k=n,b=((f=k.detailText)==null?void 0:f.trim())||k.text||"Web search";return t.jsx(Fp,{item:k,onOpen:()=>i(k,"Web Search Details",b,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const k=n,b=((g=k.detailText)==null?void 0:g.trim())||k.text||"File read";return t.jsx(Hp,{item:k,onOpen:()=>i(k,"File Read Details",b,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Op,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl});if(n.kind==="plan")return t.jsx(Ap,{item:n,scrollRootRef:a,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const k=n,b=((x=k.detailText)==null?void 0:x.trim())||k.text||"File change";return t.jsx(Up,{item:k,onOpen:()=>i(k,"File Change Details",b,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Mp,{item:n}):n.kind==="hook"?t.jsx(Vp,{item:n}):t.jsx(_p,{item:n})});function ff(e){return e==="completed"||e==="failed"||e==="interrupted"}function gf(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=gf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function bf(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 vf(e){const r=e.filter(a=>a.kind==="userMessage"),n=[...e].reverse().find(a=>a.kind==="agentMessage"&&a.text.trim().length>0);return{users:r,finalAgent:n}}var pn=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:p,onOpenCommandDetail:m,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:x,onBeforeMessageResize:k,scrollRootRef:b,articleRef:y,isLatestVisibleTurn:w=!1}){const v=!!l||!!d||!!(i&&i.length>0),N=h||Ar(a.status)||v||w,j=N&&!Ar(a.status)?{...a,status:"inProgress"}:a,S=c.useMemo(()=>gp(a.items,i),[i,a.items]),P=c.useMemo(()=>uf(l,S,a.status),[l,S,a.status]),C=c.useMemo(()=>xp(d,S),[d,S]),F=c.useMemo(()=>fp(S,N),[N,S]),H=c.useMemo(()=>bp(F),[F]),M=zt(a.startedAt),Q=qt(a.startedAt),V=c.useMemo(()=>Yo(C),[C]),[W,Z]=c.useState({}),de=c.useCallback(T=>{Z(z=>({...z,[T]:!z[T]}))},[]),E=t.jsx(kf,{entries:H,expandedGroups:W,onToggleGroupedItem:de,threadId:r,scrollRootRef:b,onOpenExpandedText:p,onOpenCommandDetail:m,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,...k?{onBeforeMessageResize:k}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:M,fallbackTimeTitle:Q,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}),J=V?t.jsx(Yn,{threadId:r,item:V,scrollRootRef:b,onOpenExpandedText:p,onOpenCommandDetail:m,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,timeLabel:M,timeTitle:Q,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}):null,A=!V&&C?t.jsx(Rt,{item:{id:"live-agent-message",kind:"agentMessage",text:C},scrollRootRef:b,timeLabel:M,timeTitle:Q,streaming:!0,...k?{onBeforeMessageResize:k}:{}}):null,X=N?t.jsx(ms,{turn:j,variant:"footer"}):null,O=c.useMemo(()=>vf(S),[S]),I=c.useMemo(()=>bf(a.startedAt,S),[S,a.startedAt]),K=ff(a.status)?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[O.users.map(T=>t.jsx(Rt,{threadId:r,item:T,scrollRootRef:b,timeLabel:T.createdAt?zt(T.createdAt):M,timeTitle:T.createdAt?qt(T.createdAt):Q,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}},T.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":`${I}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:I}),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"})]}),O.finalAgent?t.jsx(Rt,{threadId:r,item:O.finalAgent,scrollRootRef:b,timeLabel:O.finalAgent.createdAt?zt(O.finalAgent.createdAt):M,timeTitle:O.finalAgent.createdAt?qt(O.finalAgent.createdAt):Q,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}}):null]}):null,B=t.jsx(ef,{footer:X,history:E,liveHookPrompt:J,liveOutput:A,livePlan:P});return t.jsx(tf,{absoluteIndex:o,body:B,collapsed:s,collapsedBody:K,error:a.error,headerStatus:t.jsx(ms,{turn:a}),isActive:N,onToggleCollapse:()=>u(a.id,s),refCallback:y,startedAt:a.startedAt,timeLabel:M,timeTitle:Q,tokenSummary:t.jsx(df,{turn:a})})});function kf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:p,fallbackTimestamp:m,fallbackTimeLabel:f,fallbackTimeTitle:g}){return t.jsx(jp,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(x,k,b)=>t.jsx(qp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:l},x.key),renderFileChangeGroup:(x,k,b)=>t.jsx(Yp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:s},x.key),renderSearchGroup:(x,k,b)=>t.jsx(Kp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:s},x.key),renderFileReadGroup:(x,k,b)=>t.jsx(Xp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:s},x.key),renderItem:x=>{const k=pf(x.item,m??null);return t.jsx(Yn,{threadId:a,item:x.item,scrollRootRef:o,timeLabel:x.item.createdAt?zt(k):f,timeTitle:x.item.createdAt?qt(k):g,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...p?{adapter:p}:{}},x.key)}})}var ps=10,wf=10,_n=80;function tr(e,r=_n){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function yf(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 Nf(e,r){return{id:e,startedAt:jf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function fs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Cf({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((f,g)=>{s({title:f,text:g})},[]),i=c.useCallback((f,g,x)=>{if(x&&r){r({item:f,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:f,fallbackTitle:g,fallbackText:x,loadingText:k,errorText:b,useSelectionCallback:y})=>{if(!f.hasDeferredDetail||!e){i(f,fs(f,g,x),y);return}const w=a.current.get(f.id);if(w){i(f,w,y);return}const v=n.current+1;n.current=v,y&&r||s({title:g,text:k});try{const N=await e(f.id);if(a.current.set(f.id,N),n.current!==v)return;i(f,N,y)}catch(N){if(n.current!==v)return;i(f,fs(f,g,N instanceof Error?N.message:b),y)}},[e,r,i]),h=c.useCallback(async(f,g)=>{var x;await d({item:f,fallbackTitle:g,fallbackText:((x=f.detailText)==null?void 0:x.trim())||f.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(f,g)=>{var x;await d({item:f,fallbackTitle:g,fallbackText:((x=f.detailText)==null?void 0:x.trim())||f.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),p=c.useCallback(async(f,g,x,k,b)=>{await d({item:f,fallbackTitle:g,fallbackText:x,loadingText:k,errorText:b,useSelectionCallback:!1})},[d]),m=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:p,closeExpandedText:m}}function Sf(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 Tf({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),p=c.useRef(s),m=c.useRef(null),f=c.useRef(l),g=c.useRef(0),x=c.useRef(0),k=c.useRef(null),b=c.useRef(null),y=c.useRef(!0),w=c.useRef(!0),v=c.useRef(!1),N=c.useRef(!1),j=c.useRef(!1),[S,P]=c.useState(ps),[C,F]=c.useState(0),[H,M]=c.useState(!0),Q=Sf(d),V=typeof o=="function"||n!==void 0,W=n??r,Z=V?0:Math.max(0,r-S),E=(V?Math.max(0,W-r):0)+Z,J=V?r:r-Z,A=V?0:r-J,X=V?Math.max(0,W-r):0,O=V?X+A:A,I=!V&&O>0&&C>=2,K=V&&X>0&&A===0&&typeof o=="function",B=c.useCallback(()=>{const G=h.current,ce=k.current;if(!G)return;const ee=ce?yf(G,ce):tr(G);y.current=ee,M(ie=>ie===ee?ie:ee)},[]),T=c.useCallback(()=>{const G=h.current;if(G){N.current=!0;const ce=G.scrollTop,ee=x.current,ie=ce-ee;x.current=ce,tr(G,1)?(v.current=!1,w.current=!0):ie<-1?(v.current=!0,w.current=!1):ie>1&&(w.current=!v.current&&tr(G,_n))}B()},[B]),z=c.useCallback(()=>{const G=h.current;G&&(G.scrollTop=G.scrollHeight,x.current=G.scrollTop,g.current=G.scrollHeight,y.current=!0,M(ce=>ce||!0),v.current=!1,w.current=!0)},[]),Y=c.useCallback(()=>{const G=h.current;G&&(x.current=G.scrollTop,g.current=G.scrollHeight,w.current=!1,v.current=!0)},[]),$=c.useCallback(()=>{if(V&&A===0){o==null||o();return}P(G=>Math.min(r,G+wf)),F(G=>G+1)},[A,o,V,r]),q=c.useCallback(()=>{P(r)},[r]);return c.useLayoutEffect(()=>{const G=window.requestAnimationFrame(()=>{z()});return()=>{window.cancelAnimationFrame(G)}},[e,z]),c.useEffect(()=>{j.current=!1,N.current=!1},[e]),c.useEffect(()=>{P(G=>G>=r-1?r:Math.max(G,ps))},[r]),c.useEffect(()=>{const G=h.current;G&&(g.current=G.scrollHeight,x.current=G.scrollTop,tr(G,1)?(v.current=!1,w.current=!0):(v.current||!tr(G,_n))&&(w.current=!1)),B()},[Q,B,S]),c.useEffect(()=>{const G=s!==p.current,ce=m.current!==Q;if(m.current=Q,!(G||ce&&w.current&&!v.current))return;const ie=window.requestAnimationFrame(()=>{z()});return s!==p.current&&(p.current=s),()=>{window.cancelAnimationFrame(ie)}},[Q,H,z,s]),c.useEffect(()=>{const G=h.current,ce=u.current;if(!G||!ce||typeof ResizeObserver>"u")return;g.current=G.scrollHeight;const ee=new ResizeObserver(()=>{const ie=G.scrollHeight,ue=g.current;if(g.current=ie,ie<=ue)return;const ge=ue>0&&ue-G.scrollTop-G.clientHeight<=1;v.current||!(w.current||ge||y.current)||window.requestAnimationFrame(()=>{z()})});return ee.observe(ce),()=>{ee.disconnect()}},[z]),c.useEffect(()=>{if(!w.current||v.current){f.current=l;return}if(l===f.current)return;f.current=l;const G=window.requestAnimationFrame(()=>{z()});return()=>{window.cancelAnimationFrame(G)}},[l,z]),c.useEffect(()=>{i==null||i(H)},[H,i]),c.useEffect(()=>{const G=h.current,ce=b.current;if(!G||!ce||!K||a||j.current||typeof IntersectionObserver>"u")return;const ee=new IntersectionObserver(ie=>{!N.current||a||j.current||!ie.some(ue=>ue.isIntersecting)||(j.current=!0,o==null||o())},{root:G,threshold:.01});return ee.observe(ce),()=>{ee.disconnect()}},[K,a,o]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:k,topSentinelRef:b,isTailVisible:H,handleScroll:T,preserveScrollPositionForResize:Y,serverManagedHistory:V,effectiveTotalTurnCount:W,startIndex:Z,visibleTurnAbsoluteOffset:E,hiddenCount:O,loadedHiddenCount:A,unloadedHiddenCount:X,showLoadAll:I,handleLoadEarlierClick:$,handleLoadAllClick:q}}function Ef(e){return e==="completed"||e==="failed"||e==="interrupted"}function Lf(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 Pf({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:p,scrollRequestKey:m=0,bottomSpacer:f=0,className:g="",onTailVisibilityChange:x,loadingEarlier:k=!1,onLoadEarlier:b,ephemeralUserNote:y=null,answeredRequestNotes:w=[],activityNotes:v=[],optimisticSteers:N=[],optimisticTurn:j=null,onLoadHistoryItemDetail:S,onOpenThread:P,onSelectArtifact:C,onSelectHistoryItemDetail:F,adapter:H,autoCollapseCompletedTurns:M}){var $e,tt,st,Je,ot;const Q=Hr(),V=M??(Q==null?void 0:Q.autoCollapseCompletedTurns)??!1,[W,Z]=c.useState({}),de=(H==null?void 0:H.onLoadHistoryItemDetail)??S,E=H==null?void 0:H.onOpenLinkedThread,{expandedText:J,openExpandedText:A,openCommandDetail:X,openToolCallDetail:O,openDeferredHistoryItemDetail:I,closeExpandedText:K}=Cf({loadHistoryItemDetail:de,onSelectHistoryItemDetail:F}),{scrollContainerRef:B,scrollContentRef:T,tailSentinelRef:z,topSentinelRef:Y,handleScroll:$,preserveScrollPositionForResize:q,serverManagedHistory:G,effectiveTotalTurnCount:ce,startIndex:ee,visibleTurnAbsoluteOffset:ie,hiddenCount:ue,loadedHiddenCount:ge,unloadedHiddenCount:Le,showLoadAll:re,handleLoadEarlierClick:be,handleLoadAllClick:je}=Tf({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:k,onLoadEarlier:b,scrollRequestKey:m,bottomSpacer:f,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,N,p,i,d,j,w,v,y,f]}),xe=c.useCallback((oe,Ge)=>{Z(L=>({...L,[oe]:!Ge}))},[]),ze=c.useCallback((oe,Ge)=>{const L=W[oe.id];return L!==void 0?L:!!(V&&Ef(oe.status)&&!Ge.forceActive&&!Ge.hasLiveActivity)},[W,V]),R=G?r:r.slice(ee),te=ce+1,ve=s&&(!o||!R.some(oe=>oe.id===o)&&(j==null?void 0:j.id)!==o),fe=(j==null?void 0:j.id)??(($e=R.at(-1))==null?void 0:$e.id)??null,pe=ve&&fe!==null,Ie=!!d&&(R.some(oe=>oe.id===d.turnId)||(j==null?void 0:j.id)===d.turnId),D=d&&Ie?d.turnId:d&&pe?fe:null,ae=j&&D===j.id?(d==null?void 0:d.items)??null:null,ye=((d==null?void 0:d.items.length)??0)>0,ke=d&&D===null?d.items:null,we=c.useMemo(()=>d&&D===null&&d.items.length>0?Nf(d.turnId,d.items):null,[d,D]),Te=Math.max(1,ce+(j?1:0)),De=!!p&&!!j&&j.status!=="failed"&&!ae,et=p&&R.length>0?o&&R.some(oe=>oe.id===o)?o:((tt=R.findLast(oe=>Zo(oe.status)))==null?void 0:tt.id)??(pe?fe:null):null,Ze=!!et,it=c.useMemo(()=>Yo(p),[p]),Ke=[...l.map(oe=>({id:oe.id,prompt:oe.prompt,status:"Accepted",createdAt:oe.createdAt})),...N.map(oe=>({id:oe.id,prompt:oe.prompt,status:oe.status==="steering"?"Steering":null,createdAt:oe.createdAt}))].sort((oe,Ge)=>oe.createdAt.localeCompare(Ge.createdAt)),_e=c.useMemo(()=>vp({answeredRequestNotes:w,pendingRequests:a,visibleTurns:R,optimisticTurn:j}),[w,j,a,R]),Ae=c.useMemo(()=>kp({activityNotes:v,visibleTurns:R,optimisticTurn:j}),[v,j,R]);return t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${g}`.trim(),children:t.jsx("div",{ref:B,"data-testid":"thread-scroll-container",onScroll:$,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:f>0?{paddingBottom:f}:void 0,children:t.jsxs("div",{ref:T,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:Y,"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:[ue>0&&t.jsx("button",{type:"button",onClick:be,disabled:k,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:k?"Loading earlier...":"Load 10 earlier"}),re&&t.jsx("button",{type:"button",onClick:je,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 ",R.length," of ",ce," turns",ue>0?` · ${ue} earlier hidden${ge>0&&Le>0?` (${ge} loaded)`:""}`:""]})]})}),r.length===0&&!p&&!j&&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."}),(R.length>0||j||Ae.leading.length>0||Ae.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ae.leading.length>0?t.jsx(er,{notes:Ae.leading,onOpenThread:P,onOpenLinkedThread:E}):null,R.map((oe,Ge)=>{var L,U,he,Ee,Fe;return t.jsxs("div",{children:[(((L=Ae.beforeTurnId.get(oe.id))==null?void 0:L.length)??0)>0?t.jsx(er,{notes:Ae.beforeTurnId.get(oe.id)??[],onOpenThread:P,onOpenLinkedThread:E}):null,(((U=_e.beforeTurnId.get(oe.id))==null?void 0:U.length)??0)>0?t.jsx(An,{entries:_e.beforeTurnId.get(oe.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Xe=Lf(oe,j),rt=(i==null?void 0:i.turnId)===oe.id?i:null,He=D===oe.id?(d==null?void 0:d.items)??null:null,We=et===oe.id?p:"",me=o===oe.id||pe&&fe===oe.id,Pe=!!rt||!!We||!!(He&&He.length>0),Ye=ze(Xe,{forceActive:me,hasLiveActivity:Pe});return t.jsx(pn,{threadId:e,...H?{adapter:H}:{},turn:Xe,absoluteIndex:ie+Ge+1,isCollapsed:Ye,livePlan:rt,liveItems:He,liveOutput:We,forceActive:me,onToggleCollapse:xe,onOpenExpandedText:A,onOpenCommandDetail:X,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},scrollRootRef:B,articleRef:void 0})})(),(((he=Ae.afterTurnId.get(oe.id))==null?void 0:he.length)??0)>0?t.jsx(er,{notes:Ae.afterTurnId.get(oe.id)??[],onOpenThread:P,onOpenLinkedThread:E}):null,(Ee=_e.notesByTurnId.get(oe.id))!=null&&Ee.length||(Fe=_e.pendingRequestsByTurnId.get(oe.id))!=null&&Fe.length?t.jsx(wp,{notes:_e.notesByTurnId.get(oe.id)??[],requests:_e.pendingRequestsByTurnId.get(oe.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},oe.id)}),j&&R.every(oe=>oe.id!==j.id)&&t.jsxs(t.Fragment,{children:[(((st=Ae.beforeTurnId.get(j.id))==null?void 0:st.length)??0)>0?t.jsx(er,{notes:Ae.beforeTurnId.get(j.id)??[],onOpenThread:P,onOpenLinkedThread:E}):null,(((Je=_e.beforeTurnId.get(j.id))==null?void 0:Je.length)??0)>0?t.jsx(An,{entries:_e.beforeTurnId.get(j.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const oe=De?p:"",Ge=o===j.id||pe&&fe===j.id,L=!!(ae&&ae.length>0)||!!oe,U=ze(j,{forceActive:Ge,hasLiveActivity:L});return t.jsx(pn,{threadId:e,...H?{adapter:H}:{},turn:j,absoluteIndex:te,isCollapsed:U,livePlan:null,liveItems:ae,liveOutput:oe,forceActive:Ge,onToggleCollapse:xe,onOpenExpandedText:A,onOpenCommandDetail:X,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},scrollRootRef:B})})(),(((ot=Ae.afterTurnId.get(j.id))==null?void 0:ot.length)??0)>0?t.jsx(er,{notes:Ae.afterTurnId.get(j.id)??[],onOpenThread:P,onOpenLinkedThread:E}):null]})]}),Ke.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Ke.map(oe=>t.jsx(Rt,{threadId:e,item:{id:oe.id,kind:"userMessage",text:oe.prompt,status:oe.status},scrollRootRef:B,onBeforeMessageResize:q,...H?{adapter:H}:{}},oe.id))}),(_e.trailing.length>0||Ae.trailing.length>0)&&t.jsx(yp,{entries:[...Ae.trailing.map(oe=>({kind:"activity",id:oe.id,createdAt:oe.createdAt,note:oe})),..._e.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:P,onOpenLinkedThread:E}),y&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Rt,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:y},scrollRootRef:B,onBeforeMessageResize:q})}),we&&ke&&ke.length>0&&t.jsx(pn,{threadId:e,...H?{adapter:H}:{},turn:we,absoluteIndex:Te,isCollapsed:W[we.id]??!1,livePlan:(i==null?void 0:i.turnId)===we.id?i:null,liveItems:ke,liveOutput:"",forceActive:!0,onToggleCollapse:xe,onOpenExpandedText:A,onOpenCommandDetail:X,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},scrollRootRef:B}),p&&!Ze&&!De&&!ye&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:it?t.jsx(Yn,{threadId:e,item:it,scrollRootRef:B,onOpenExpandedText:A,onOpenCommandDetail:X,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},...H?{adapter:H}:{}}):t.jsx(Rt,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:p},scrollRootRef:B,streaming:!0,onBeforeMessageResize:q,...H?{adapter:H}:{}})}),t.jsx("div",{ref:z,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Gm,{open:J!==null,title:(J==null?void 0:J.title)??"Full text",text:(J==null?void 0:J.text)??"",onClose:K})]})}var ll=c.memo(Pf);function If(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function $n(e){return e.replace(/\r\n/g,`
3602
+ `);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function mt(e){const r=Ip(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function al(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"}:Vr(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 zp(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 Rp(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 _t({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,title:l,tone:i}){const d=al(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Rp(i)} ${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:l}),s.status?t.jsxs(Wr,{variant:"outline",className:`thread-graph-tool-badge ${d.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:d.label,"aria-label":`Status: ${d.label}`,children:[d.icon,t.jsx("span",{className:"thread-graph-status-label",children:d.label})]}):null,a]}),e?t.jsx("div",{className:"thread-graph-history-event-actions",children:e}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function Yt({actionLabel:e="Open details",actionTitle:r,className:n,details:a,icon:o,item:s,onOpen:l,preview:i,title:d,tone:h}){const u=al(s.status),[p,m]=c.useState(Vr(s.status)?"item-1":void 0);return t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${zp(h)} ${n??""}`,children:t.jsx(cr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",...p!==void 0?{value:p}:{},children:t.jsxs(hr,{value:"item-1",className:"border-0",children:[t.jsx(ur,{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:o}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:d}),t.jsxs(Wr,{variant:"outline",className:`thread-graph-tool-badge ${u.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:u.label,"aria-label":`Status: ${u.label}`,children:[u.icon,t.jsx("span",{className:"thread-graph-status-label",children:u.label})]})]})}),t.jsxs(mr,{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(Kt,{text:i.firstLine}),i.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),a?t.jsx("section",{children:a}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:l,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 Ap=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a}){return t.jsx(_t,{className:"thread-graph-event-plan",icon:t.jsx($.ClipboardList,{className:"h-4 w-4"}),item:r,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(Xo,{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}:{}})})})}),Mp=c.memo(function({item:r}){const n=Vr(r.status)||r.text==="Compacting context",a=n?"Compacting context":"Context compacted",o=r.detailText&&r.detailText!==a?r.detailText:null;return t.jsxs(_t,{className:"thread-graph-event-context",icon:t.jsx($.Archive,{className:"h-4 w-4"}),item:r,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:a}),n?t.jsx(Mn,{tone:"emerald"}):null]}),o?t.jsx("p",{className:"thread-graph-history-event-secondary",title:o,children:o}):null]})}),_p=c.memo(function({item:r}){return t.jsx(_t,{className:"thread-graph-event-generic",icon:t.jsx($.Info,{className:"h-4 w-4"}),item:r,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(Kt,{text:r.text})})})}),$p=c.memo(function({item:r,onOpen:n}){const a=mt(r.previewText??r.text);return t.jsx(Yt,{actionLabel:"Open full command",actionTitle:"Command Output",className:"thread-graph-event-command",icon:t.jsx($.Terminal,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Command Output"),preview:a,title:"command",tone:"command"})}),Dp=c.memo(function({item:r,onOpen:n}){const a=mt(r.text);return t.jsx(Yt,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",className:"thread-graph-event-tool",icon:t.jsx($.Wrench,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Tool Call Details"),preview:a,title:"tool_call",tone:"tool"})}),Bp=c.memo(function({item:r,onOpen:n}){const a=mt(r.text);return t.jsx(Yt,{actionLabel:"Open agent details",actionTitle:"Agent Details",className:"thread-graph-event-agent-tool",icon:t.jsx($.Bot,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Agent Details"),preview:a,title:"agent",tone:"agent"})}),Gp=c.memo(function({item:r,onOpen:n}){const a=mt(r.text);return t.jsx(Yt,{actionLabel:"Open skill details",actionTitle:"Skill Details",className:"thread-graph-event-skill-tool",icon:t.jsx($.Sparkles,{className:"h-4 w-4"}),item:r,onOpen:()=>n(r,"Skill Details"),preview:a,title:"skill",tone:"skill"})}),Fp=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"Web search",o=((i=r.detailText)==null?void 0:i.trim())||r.text||"Web search",s=mt(a);return t.jsx(Yt,{actionLabel:"Open full web search",actionTitle:"Web Search Details",className:"thread-graph-event-search",icon:t.jsx($.Search,{className:"h-4 w-4"}),item:r,onOpen:()=>n("Web Search Details",o),preview:s,title:"web_search",tone:"search"})}),Hp=c.memo(function({item:r,onOpen:n}){var l,i;const a=((l=r.previewText)==null?void 0:l.trim())||r.text||"File read",o=((i=r.detailText)==null?void 0:i.trim())||r.text||"File read",s=mt(a);return t.jsx(Yt,{actionLabel:"Open full file read",actionTitle:"File Read Details",className:"thread-graph-event-file-read",icon:t.jsx($.FileText,{className:"h-4 w-4"}),item:r,onOpen:()=>n("File Read Details",o),preview:s,title:"file_read",tone:"fileRead"})}),Op=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o}){const s=n.assetPath??n.detailText??null,l=r&&s?(o==null?void 0:o({threadId:r,path:s}))??null:null;return t.jsxs(_t,{className:"thread-graph-event-image",icon:t.jsx($.Image,{className:"h-4 w-4"}),item:n,title:"image",tone:"image",children:[l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",s??n.text),className:"block w-full text-left",children:t.jsx("img",{src:l,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}),s?t.jsx("button",{type:"button",onClick:()=>a("Image Path",s),className:"thread-graph-history-event-path",title:s,children:s}):null]})}),Up=c.memo(function({item:r,onOpen:n}){var u,p,m;const a=(u=r.previewText)!=null&&u.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,o=((p=r.detailText)==null?void 0:p.trim())||null,s=nl(a??((m=r.previewText)==null?void 0:m.trim())??r.text,48),l=Pp(r),i=!!(o||r.hasDeferredDetail),d=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:a??s,children:s}),l.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:l.map(f=>t.jsx("span",{className:`thread-graph-history-delta-badge ${f.startsWith("+")?"is-add":f.startsWith("-")?"is-remove":"is-neutral"}`,children:f},f))})]}),h=i?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",o??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:a??s,children:d}):d;return t.jsx(_t,{className:"thread-graph-event-file-change",headerMeta:h,icon:t.jsx($.FilePenLine,{className:"h-4 w-4"}),item:r,title:"file_change",tone:"fileChange"})}),Wp=c.memo(function({item:r,onSelect:n}){const a=Xn(),[o,s]=c.useState(!1),l=r.artifact,i=l?a.renderArtifact({artifact:l,expanded:o,onToggleExpanded:()=>s(d=>!d)}):null;return t.jsx(_t,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[l&&!a.hasRendererForArtifact(l)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,l&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${l.title}`,onClick:()=>n(r,l),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,title:(l==null?void 0:l.type)??"artifact",tone:"artifact",children:i??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>s(d=>!d),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:(l==null?void 0:l.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(l==null?void 0:l.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:o?"Hide":"Open"})]}),o?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((l==null?void 0:l.payload)??r,null,2)}):null]})})}),Vp=c.memo(function({item:r}){var d,h;const n=((d=r.hookOutputEntries)==null?void 0:d.map(u=>u.text.trim()).filter(Boolean).join(`
3603
+ `).trim())??"",a=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,o=((h=r.hookStatusMessage)==null?void 0:h.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),l=mt(n||(o&&o!==a?o:a)),i=!!(n&&l.showGap);return t.jsx(_t,{className:"thread-graph-event-hook",icon:t.jsx($.Webhook,{className:"h-4 w-4"}),item:r,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:n?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:a}),t.jsx(Kt,{text:l.firstLine})]}):t.jsx(Kt,{text:l.firstLine&&l.firstLine!==a?`${a} · ${l.firstLine}`:a})}),i?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),qp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.filter(i=>Vr(i.status)).length,l=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Ur,{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(Tp,{}),onToggleExpanded:a,runningIndicator:s>0?t.jsx(Mn,{}):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:l}),s>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Mn,{})}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((i,d)=>{const h=mt(i.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${d+1}`,onClick:()=>o(i,`Command Output ${d+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 ",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:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),Kp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.length===1?"1 search":`${r.length} searches`;return t.jsx(Ur,{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(Ep,{}),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:s})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((l,i)=>{var p,m;const d=((p=l.previewText)==null?void 0:p.trim())||l.text||"Web search",h=mt(d),u=((m=l.detailText)==null?void 0:m.trim())||l.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${i+1}`,onClick:()=>o(`Web Search ${i+1}`,u),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 ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.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:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),Xp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(Ur,{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(Sp,{}),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:s})]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((l,i)=>{var p,m;const d=((p=l.previewText)==null?void 0:p.trim())||l.text||"File read",h=mt(d),u=((m=l.detailText)==null?void 0:m.trim())||l.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${i+1}`,onClick:()=>o(`File Read ${i+1}`,u),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 ",i+1]}),l.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:l.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:h.firstLine}),h.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},l.id)})})}),Yp=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o}){const s=r.reduce((h,u)=>h+(u.changedFiles??0),0),l=r.reduce((h,u)=>h+(u.addedLines??0),0),i=r.reduce((h,u)=>h+(u.removedLines??0),0),d=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(Ur,{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(Cp,{}),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:d}),s>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[s," files"]}):null]}),toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[l>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",l]}):null,i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",i]}):null]}),children:r.map((h,u)=>{var f,g,x,k;const p=((f=h.detailText)==null?void 0:f.trim())||((g=h.previewText)==null?void 0:g.trim())||h.text,m=(x=h.previewText)!=null&&x.trim()&&h.text.trim()!==h.previewText.trim()?h.text.trim():((k=h.previewText)==null?void 0:k.trim())||h.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${u+1}`,onClick:()=>o(`File Change ${u+1}`,p),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:m,children:nl(m,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(h.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",h.addedLines]}):null,(h.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",h.removedLines]}):null]})]})},h.id)})})});function Zp(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 Jp({status:e}){const r=Zp(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(Wr,{"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 Qp({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(Wr,{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(Jp,{status:r.status})]},`${e.turnId}-${n}`))})]})}function ef({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(Qp,{livePlan:o}):null,n??a??null,e]})}function tf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,onToggleCollapse:d,refCallback:h,startedAt:u,timeLabel:p,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:h,"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.jsxs("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:u??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:p}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]}),t.jsx("button",{type:"button","aria-label":`${n?"Expand":"Collapse"} turn ${e}`,title:n?"Expand turn":"Collapse turn",onClick:d,className:"thread-graph-turn-collapse inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-md transition",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.6",strokeLinecap:"round",strokeLinejoin:"round",children:n?t.jsx("path",{d:"m4.5 10 3.5-3.5L11.5 10"}):t.jsx("path",{d:"m4.5 6 3.5 3.5L11.5 6"})})})]}),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 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.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 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.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 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.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 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.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 wr(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 of(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 ar(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function yr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function sl(e){var i,d,h,u,p;const r=(i=e.tokenUsage)==null?void 0:i.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens,0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.reasoningOutputTokens,0),s=Math.max(r.outputTokens-o,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:wr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(rf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:wr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?ar(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(af,{})}:null,s>0?{id:"out",label:"Output",tokenCompactValue:wr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?ar(yr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:yr((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-out",icon:t.jsx(nf,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:wr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?ar(yr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:yr((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(sf,{})}:null].filter(m=>m!==null)}function lf(e){return sl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function ol(e){return{label:e.priceEstimate?of(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${ar(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var mn="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=sl(e),n=ol(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),p=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const f=()=>{const g=h.current,x=p.current;if(!g||!x)return;const k=g.getBoundingClientRect(),b=x.offsetWidth||x.getBoundingClientRect().width;if(b<=0)return;const y=window.innerWidth||document.documentElement.clientWidth,w=12,v=k.left+k.width/2-b/2,N=w,j=Math.max(N,y-w-b),S=Math.min(Math.max(v,N),j);d(Math.round(S-v))};return f(),window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const f=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",f),()=>{document.removeEventListener("pointerdown",f)}},[s,a]),!n&&r.length===0)return null;const m=()=>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(f=>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:`${f.label}: ${f.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:f.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:f.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:f.tokenCompactValue})]},f.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:`${mn} 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:m()}):null]}):null,r.map(f=>t.jsxs("span",{className:`${mn} ${f.className}`,title:`${f.label}: ${f.usdCompactValue}, ${f.tokenRawValue} tokens`,children:[f.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:f.tokenCompactValue})]},f.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(f=>!f),className:`${mn} 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:p,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:m()}):null]})]})}function cf({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 hs(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 hf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!Zo(e.status);default:return!1}}function uf(e,r,n){if(!e||!Ar(n))return e;const a=e.plan.findIndex(i=>hs(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&hs(i.status)==="pending");if(o<0||!r.some(i=>hf(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 mf(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 us({status:e}){const r=Wo(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(cf,{tone:"emerald"})})}function ms({turn:e,variant:r="header"}){const n=Wo(e.status),a=mf(e),o=lf(e),s=ol(e),l=Ar(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(us,{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:qt(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:zt(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(us,{status:e.status}),t.jsx("span",{className:"timeline-meta-text min-w-0 truncate",children:a})]})}function pf(e,r){return e.createdAt??r}var Yn=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:p,timeTitle:m}){var f,g,x;if(up(n.kind))return t.jsx(Rt,{threadId:r,item:n,scrollRootRef:a,timeLabel:p,timeTitle:m,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="artifact")return t.jsx(Wp,{item:n,...d?{onSelect:(k,b)=>d({item:k,artifact:b})}:{}});if(n.kind==="commandExecution")return t.jsx($p,{item:n,onOpen:s});if(n.kind==="toolCall")return t.jsx(Dp,{item:n,onOpen:l});if(n.kind==="agentToolCall")return t.jsx(Bp,{item:n,onOpen:l});if(n.kind==="skillToolCall")return t.jsx(Gp,{item:n,onOpen:l});if(n.kind==="webSearch"){const k=n,b=((f=k.detailText)==null?void 0:f.trim())||k.text||"Web search";return t.jsx(Fp,{item:k,onOpen:()=>i(k,"Web Search Details",b,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const k=n,b=((g=k.detailText)==null?void 0:g.trim())||k.text||"File read";return t.jsx(Hp,{item:k,onOpen:()=>i(k,"File Read Details",b,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(Op,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl});if(n.kind==="plan")return t.jsx(Ap,{item:n,scrollRootRef:a,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const k=n,b=((x=k.detailText)==null?void 0:x.trim())||k.text||"File change";return t.jsx(Up,{item:k,onOpen:()=>i(k,"File Change Details",b,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Mp,{item:n}):n.kind==="hook"?t.jsx(Vp,{item:n}):t.jsx(_p,{item:n})});function ff(e){return e==="completed"||e==="failed"||e==="interrupted"}function gf(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=gf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function bf(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 vf(e){const r=e.filter(a=>a.kind==="userMessage"),n=[...e].reverse().find(a=>a.kind==="agentMessage"&&a.text.trim().length>0);return{users:r,finalAgent:n,hiddenItems:e.filter(a=>a.kind!=="userMessage"&&a.id!==(n==null?void 0:n.id))}}var pn=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:p,onOpenCommandDetail:m,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:x,onBeforeMessageResize:k,scrollRootRef:b,articleRef:y,isLatestVisibleTurn:w=!1}){const v=!!l||!!d||!!(i&&i.length>0),N=h||Ar(a.status)||v||w,j=N&&!Ar(a.status)?{...a,status:"inProgress"}:a,S=c.useMemo(()=>gp(a.items,i),[i,a.items]),L=c.useMemo(()=>uf(l,S,a.status),[l,S,a.status]),C=c.useMemo(()=>xp(d,S),[d,S]),H=c.useMemo(()=>fp(S,N),[N,S]),O=c.useMemo(()=>bp(H),[H]),M=zt(a.startedAt),Q=qt(a.startedAt),V=c.useMemo(()=>Yo(C),[C]),[W,Z]=c.useState({}),de=c.useCallback(X=>{Z(_=>({..._,[X]:!_[X]}))},[]),T=t.jsx(kf,{entries:O,expandedGroups:W,onToggleGroupedItem:de,threadId:r,scrollRootRef:b,onOpenExpandedText:p,onOpenCommandDetail:m,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,...k?{onBeforeMessageResize:k}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:M,fallbackTimeTitle:Q,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}),J=V?t.jsx(Yn,{threadId:r,item:V,scrollRootRef:b,onOpenExpandedText:p,onOpenCommandDetail:m,onOpenToolCallDetail:f,onOpenDeferredHistoryItemDetail:g,timeLabel:M,timeTitle:Q,...x?{onSelectArtifact:x}:{},...n?{adapter:n}:{}}):null,A=!V&&C?t.jsx(Rt,{item:{id:"live-agent-message",kind:"agentMessage",text:C},scrollRootRef:b,timeLabel:M,timeTitle:Q,streaming:!0,...k?{onBeforeMessageResize:k}:{}}):null,Y=N?t.jsx(ms,{turn:j,variant:"footer"}):null,F=c.useMemo(()=>vf(S),[S]),I=c.useMemo(()=>bf(a.startedAt,S),[S,a.startedAt]),K=F.hiddenItems.length>0,D=s&&K,P=ff(a.status)&&K?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[F.users.map(X=>t.jsx(Rt,{threadId:r,item:X,scrollRootRef:b,timeLabel:X.createdAt?zt(X.createdAt):M,timeTitle:X.createdAt?qt(X.createdAt):Q,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}},X.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":`${I}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:I}),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"})]}),F.finalAgent?t.jsx(Rt,{threadId:r,item:F.finalAgent,scrollRootRef:b,timeLabel:F.finalAgent.createdAt?zt(F.finalAgent.createdAt):M,timeTitle:F.finalAgent.createdAt?qt(F.finalAgent.createdAt):Q,...k?{onBeforeMessageResize:k}:{},...n?{adapter:n}:{}}):null]}):null,z=t.jsx(ef,{footer:Y,history:T,liveHookPrompt:J,liveOutput:A,livePlan:L});return t.jsx(tf,{absoluteIndex:o,body:z,collapsed:D,collapsedBody:P,error:a.error,headerStatus:t.jsx(ms,{turn:a}),isActive:N,onToggleCollapse:()=>u(a.id,D),refCallback:y,startedAt:a.startedAt,timeLabel:M,timeTitle:Q,tokenSummary:t.jsx(df,{turn:a})})});function kf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:p,fallbackTimestamp:m,fallbackTimeLabel:f,fallbackTimeTitle:g}){return t.jsx(jp,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(x,k,b)=>t.jsx(qp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:l},x.key),renderFileChangeGroup:(x,k,b)=>t.jsx(Yp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:s},x.key),renderSearchGroup:(x,k,b)=>t.jsx(Kp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:s},x.key),renderFileReadGroup:(x,k,b)=>t.jsx(Xp,{items:x.items,expanded:k,onToggleExpanded:b,onOpen:s},x.key),renderItem:x=>{const k=pf(x.item,m??null);return t.jsx(Yn,{threadId:a,item:x.item,scrollRootRef:o,timeLabel:x.item.createdAt?zt(k):f,timeTitle:x.item.createdAt?qt(k):g,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...p?{adapter:p}:{}},x.key)}})}var ps=10,wf=10,_n=80;function tr(e,r=_n){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function yf(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 Nf(e,r){return{id:e,startedAt:jf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function fs(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Cf({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((f,g)=>{s({title:f,text:g})},[]),i=c.useCallback((f,g,x)=>{if(x&&r){r({item:f,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:f,fallbackTitle:g,fallbackText:x,loadingText:k,errorText:b,useSelectionCallback:y})=>{if(!f.hasDeferredDetail||!e){i(f,fs(f,g,x),y);return}const w=a.current.get(f.id);if(w){i(f,w,y);return}const v=n.current+1;n.current=v,y&&r||s({title:g,text:k});try{const N=await e(f.id);if(a.current.set(f.id,N),n.current!==v)return;i(f,N,y)}catch(N){if(n.current!==v)return;i(f,fs(f,g,N instanceof Error?N.message:b),y)}},[e,r,i]),h=c.useCallback(async(f,g)=>{var x;await d({item:f,fallbackTitle:g,fallbackText:((x=f.detailText)==null?void 0:x.trim())||f.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(f,g)=>{var x;await d({item:f,fallbackTitle:g,fallbackText:((x=f.detailText)==null?void 0:x.trim())||f.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),p=c.useCallback(async(f,g,x,k,b)=>{await d({item:f,fallbackTitle:g,fallbackText:x,loadingText:k,errorText:b,useSelectionCallback:!1})},[d]),m=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:p,closeExpandedText:m}}function Sf(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 Tf({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),p=c.useRef(s),m=c.useRef(null),f=c.useRef(l),g=c.useRef(0),x=c.useRef(0),k=c.useRef(null),b=c.useRef(null),y=c.useRef(!0),w=c.useRef(!0),v=c.useRef(!1),N=c.useRef(!1),j=c.useRef(!1),[S,L]=c.useState(ps),[C,H]=c.useState(0),[O,M]=c.useState(!0),Q=Sf(d),V=typeof o=="function"||n!==void 0,W=n??r,Z=V?0:Math.max(0,r-S),T=(V?Math.max(0,W-r):0)+Z,J=V?r:r-Z,A=V?0:r-J,Y=V?Math.max(0,W-r):0,F=V?Y+A:A,I=!V&&F>0&&C>=2,K=V&&Y>0&&A===0&&typeof o=="function",D=c.useCallback(()=>{const G=h.current,ce=k.current;if(!G)return;const ee=ce?yf(G,ce):tr(G);y.current=ee,M(ie=>ie===ee?ie:ee)},[]),P=c.useCallback(()=>{const G=h.current;if(G){N.current=!0;const ce=G.scrollTop,ee=x.current,ie=ce-ee;x.current=ce,tr(G,1)?(v.current=!1,w.current=!0):ie<-1?(v.current=!0,w.current=!1):ie>1&&(w.current=!v.current&&tr(G,_n))}D()},[D]),z=c.useCallback(()=>{const G=h.current;G&&(G.scrollTop=G.scrollHeight,x.current=G.scrollTop,g.current=G.scrollHeight,y.current=!0,M(ce=>ce||!0),v.current=!1,w.current=!0)},[]),X=c.useCallback(()=>{const G=h.current;G&&(x.current=G.scrollTop,g.current=G.scrollHeight,w.current=!1,v.current=!0)},[]),_=c.useCallback(()=>{if(V&&A===0){o==null||o();return}L(G=>Math.min(r,G+wf)),H(G=>G+1)},[A,o,V,r]),q=c.useCallback(()=>{L(r)},[r]);return c.useLayoutEffect(()=>{const G=window.requestAnimationFrame(()=>{z()});return()=>{window.cancelAnimationFrame(G)}},[e,z]),c.useEffect(()=>{j.current=!1,N.current=!1},[e]),c.useEffect(()=>{L(G=>G>=r-1?r:Math.max(G,ps))},[r]),c.useEffect(()=>{const G=h.current;G&&(g.current=G.scrollHeight,x.current=G.scrollTop,tr(G,1)?(v.current=!1,w.current=!0):(v.current||!tr(G,_n))&&(w.current=!1)),D()},[Q,D,S]),c.useEffect(()=>{const G=s!==p.current,ce=m.current!==Q;if(m.current=Q,!(G||ce&&w.current&&!v.current))return;const ie=window.requestAnimationFrame(()=>{z()});return s!==p.current&&(p.current=s),()=>{window.cancelAnimationFrame(ie)}},[Q,O,z,s]),c.useEffect(()=>{const G=h.current,ce=u.current;if(!G||!ce||typeof ResizeObserver>"u")return;g.current=G.scrollHeight;const ee=new ResizeObserver(()=>{const ie=G.scrollHeight,ue=g.current;if(g.current=ie,ie<=ue)return;const ge=ue>0&&ue-G.scrollTop-G.clientHeight<=1;v.current||!(w.current||ge||y.current)||window.requestAnimationFrame(()=>{z()})});return ee.observe(ce),()=>{ee.disconnect()}},[z]),c.useEffect(()=>{if(!w.current||v.current){f.current=l;return}if(l===f.current)return;f.current=l;const G=window.requestAnimationFrame(()=>{z()});return()=>{window.cancelAnimationFrame(G)}},[l,z]),c.useEffect(()=>{i==null||i(O)},[O,i]),c.useEffect(()=>{const G=h.current,ce=b.current;if(!G||!ce||!K||a||j.current||typeof IntersectionObserver>"u")return;const ee=new IntersectionObserver(ie=>{!N.current||a||j.current||!ie.some(ue=>ue.isIntersecting)||(j.current=!0,o==null||o())},{root:G,threshold:.01});return ee.observe(ce),()=>{ee.disconnect()}},[K,a,o]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:k,topSentinelRef:b,isTailVisible:O,handleScroll:P,preserveScrollPositionForResize:X,serverManagedHistory:V,effectiveTotalTurnCount:W,startIndex:Z,visibleTurnAbsoluteOffset:T,hiddenCount:F,loadedHiddenCount:A,unloadedHiddenCount:Y,showLoadAll:I,handleLoadEarlierClick:_,handleLoadAllClick:q}}function Ef(e){return e==="completed"||e==="failed"||e==="interrupted"}function Lf(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 Pf({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:p,scrollRequestKey:m=0,bottomSpacer:f=0,className:g="",onTailVisibilityChange:x,loadingEarlier:k=!1,onLoadEarlier:b,ephemeralUserNote:y=null,answeredRequestNotes:w=[],activityNotes:v=[],optimisticSteers:N=[],optimisticTurn:j=null,onLoadHistoryItemDetail:S,onOpenThread:L,onSelectArtifact:C,onSelectHistoryItemDetail:H,adapter:O,autoCollapseCompletedTurns:M}){var $e,tt,st,Je,ot;const Q=Hr(),V=M??(Q==null?void 0:Q.autoCollapseCompletedTurns)??!1,[W,Z]=c.useState({}),de=(O==null?void 0:O.onLoadHistoryItemDetail)??S,T=O==null?void 0:O.onOpenLinkedThread,{expandedText:J,openExpandedText:A,openCommandDetail:Y,openToolCallDetail:F,openDeferredHistoryItemDetail:I,closeExpandedText:K}=Cf({loadHistoryItemDetail:de,onSelectHistoryItemDetail:H}),{scrollContainerRef:D,scrollContentRef:P,tailSentinelRef:z,topSentinelRef:X,handleScroll:_,preserveScrollPositionForResize:q,serverManagedHistory:G,effectiveTotalTurnCount:ce,startIndex:ee,visibleTurnAbsoluteOffset:ie,hiddenCount:ue,loadedHiddenCount:ge,unloadedHiddenCount:Le,showLoadAll:re,handleLoadEarlierClick:be,handleLoadAllClick:je}=Tf({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:k,onLoadEarlier:b,scrollRequestKey:m,bottomSpacer:f,onTailVisibilityChange:x,contentRevisionInputs:[r,a,l,N,p,i,d,j,w,v,y,f]}),xe=c.useCallback((oe,Ge)=>{Z(E=>({...E,[oe]:!Ge}))},[]),ze=c.useCallback((oe,Ge)=>{const E=W[oe.id];return E!==void 0?E:!!(V&&Ef(oe.status)&&!Ge.forceActive&&!Ge.hasLiveActivity)},[W,V]),R=G?r:r.slice(ee),te=ce+1,ve=s&&(!o||!R.some(oe=>oe.id===o)&&(j==null?void 0:j.id)!==o),fe=(j==null?void 0:j.id)??(($e=R.at(-1))==null?void 0:$e.id)??null,pe=ve&&fe!==null,Ie=!!d&&(R.some(oe=>oe.id===d.turnId)||(j==null?void 0:j.id)===d.turnId),B=d&&Ie?d.turnId:d&&pe?fe:null,ae=j&&B===j.id?(d==null?void 0:d.items)??null:null,ye=((d==null?void 0:d.items.length)??0)>0,ke=d&&B===null?d.items:null,we=c.useMemo(()=>d&&B===null&&d.items.length>0?Nf(d.turnId,d.items):null,[d,B]),Te=Math.max(1,ce+(j?1:0)),De=!!p&&!!j&&j.status!=="failed"&&!ae,et=p&&R.length>0?o&&R.some(oe=>oe.id===o)?o:((tt=R.findLast(oe=>Zo(oe.status)))==null?void 0:tt.id)??(pe?fe:null):null,Ze=!!et,it=c.useMemo(()=>Yo(p),[p]),Ke=[...l.map(oe=>({id:oe.id,prompt:oe.prompt,status:"Accepted",createdAt:oe.createdAt})),...N.map(oe=>({id:oe.id,prompt:oe.prompt,status:oe.status==="steering"?"Steering":null,createdAt:oe.createdAt}))].sort((oe,Ge)=>oe.createdAt.localeCompare(Ge.createdAt)),_e=c.useMemo(()=>vp({answeredRequestNotes:w,pendingRequests:a,visibleTurns:R,optimisticTurn:j}),[w,j,a,R]),Ae=c.useMemo(()=>kp({activityNotes:v,visibleTurns:R,optimisticTurn:j}),[v,j,R]);return t.jsxs(t.Fragment,{children:[t.jsx("section",{className:`flex min-h-0 flex-1 flex-col ${g}`.trim(),children:t.jsx("div",{ref:D,"data-testid":"thread-scroll-container",onScroll:_,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:f>0?{paddingBottom:f}:void 0,children:t.jsxs("div",{ref:P,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:X,"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:[ue>0&&t.jsx("button",{type:"button",onClick:be,disabled:k,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:k?"Loading earlier...":"Load 10 earlier"}),re&&t.jsx("button",{type:"button",onClick:je,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 ",R.length," of ",ce," turns",ue>0?` · ${ue} earlier hidden${ge>0&&Le>0?` (${ge} loaded)`:""}`:""]})]})}),r.length===0&&!p&&!j&&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."}),(R.length>0||j||Ae.leading.length>0||Ae.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Ae.leading.length>0?t.jsx(er,{notes:Ae.leading,onOpenThread:L,onOpenLinkedThread:T}):null,R.map((oe,Ge)=>{var E,U,he,Ee,Fe;return t.jsxs("div",{children:[(((E=Ae.beforeTurnId.get(oe.id))==null?void 0:E.length)??0)>0?t.jsx(er,{notes:Ae.beforeTurnId.get(oe.id)??[],onOpenThread:L,onOpenLinkedThread:T}):null,(((U=_e.beforeTurnId.get(oe.id))==null?void 0:U.length)??0)>0?t.jsx(An,{entries:_e.beforeTurnId.get(oe.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const Xe=Lf(oe,j),rt=(i==null?void 0:i.turnId)===oe.id?i:null,He=B===oe.id?(d==null?void 0:d.items)??null:null,We=et===oe.id?p:"",me=o===oe.id||pe&&fe===oe.id,Pe=!!rt||!!We||!!(He&&He.length>0),Ye=ze(Xe,{forceActive:me,hasLiveActivity:Pe});return t.jsx(pn,{threadId:e,...O?{adapter:O}:{},turn:Xe,absoluteIndex:ie+Ge+1,isCollapsed:Ye,livePlan:rt,liveItems:He,liveOutput:We,forceActive:me,onToggleCollapse:xe,onOpenExpandedText:A,onOpenCommandDetail:Y,onOpenToolCallDetail:F,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},scrollRootRef:D,articleRef:void 0})})(),(((he=Ae.afterTurnId.get(oe.id))==null?void 0:he.length)??0)>0?t.jsx(er,{notes:Ae.afterTurnId.get(oe.id)??[],onOpenThread:L,onOpenLinkedThread:T}):null,(Ee=_e.notesByTurnId.get(oe.id))!=null&&Ee.length||(Fe=_e.pendingRequestsByTurnId.get(oe.id))!=null&&Fe.length?t.jsx(wp,{notes:_e.notesByTurnId.get(oe.id)??[],requests:_e.pendingRequestsByTurnId.get(oe.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},oe.id)}),j&&R.every(oe=>oe.id!==j.id)&&t.jsxs(t.Fragment,{children:[(((st=Ae.beforeTurnId.get(j.id))==null?void 0:st.length)??0)>0?t.jsx(er,{notes:Ae.beforeTurnId.get(j.id)??[],onOpenThread:L,onOpenLinkedThread:T}):null,(((Je=_e.beforeTurnId.get(j.id))==null?void 0:Je.length)??0)>0?t.jsx(An,{entries:_e.beforeTurnId.get(j.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const oe=De?p:"",Ge=o===j.id||pe&&fe===j.id,E=!!(ae&&ae.length>0)||!!oe,U=ze(j,{forceActive:Ge,hasLiveActivity:E});return t.jsx(pn,{threadId:e,...O?{adapter:O}:{},turn:j,absoluteIndex:te,isCollapsed:U,livePlan:null,liveItems:ae,liveOutput:oe,forceActive:Ge,onToggleCollapse:xe,onOpenExpandedText:A,onOpenCommandDetail:Y,onOpenToolCallDetail:F,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},scrollRootRef:D})})(),(((ot=Ae.afterTurnId.get(j.id))==null?void 0:ot.length)??0)>0?t.jsx(er,{notes:Ae.afterTurnId.get(j.id)??[],onOpenThread:L,onOpenLinkedThread:T}):null]})]}),Ke.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:Ke.map(oe=>t.jsx(Rt,{threadId:e,item:{id:oe.id,kind:"userMessage",text:oe.prompt,status:oe.status},scrollRootRef:D,onBeforeMessageResize:q,...O?{adapter:O}:{}},oe.id))}),(_e.trailing.length>0||Ae.trailing.length>0)&&t.jsx(yp,{entries:[...Ae.trailing.map(oe=>({kind:"activity",id:oe.id,createdAt:oe.createdAt,note:oe})),..._e.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:L,onOpenLinkedThread:T}),y&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Rt,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:y},scrollRootRef:D,onBeforeMessageResize:q})}),we&&ke&&ke.length>0&&t.jsx(pn,{threadId:e,...O?{adapter:O}:{},turn:we,absoluteIndex:Te,isCollapsed:W[we.id]??!1,livePlan:(i==null?void 0:i.turnId)===we.id?i:null,liveItems:ke,liveOutput:"",forceActive:!0,onToggleCollapse:xe,onOpenExpandedText:A,onOpenCommandDetail:Y,onOpenToolCallDetail:F,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},scrollRootRef:D}),p&&!Ze&&!De&&!ye&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:it?t.jsx(Yn,{threadId:e,item:it,scrollRootRef:D,onOpenExpandedText:A,onOpenCommandDetail:Y,onOpenToolCallDetail:F,onOpenDeferredHistoryItemDetail:I,onBeforeMessageResize:q,...C?{onSelectArtifact:C}:{},...O?{adapter:O}:{}}):t.jsx(Rt,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:p},scrollRootRef:D,streaming:!0,onBeforeMessageResize:q,...O?{adapter:O}:{}})}),t.jsx("div",{ref:z,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(Gm,{open:J!==null,title:(J==null?void 0:J.title)??"Full text",text:(J==null?void 0:J.text)??"",onClose:K})]})}var ll=c.memo(Pf);function If(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function $n(e){return e.replace(/\r\n/g,`
3604
3604
  `)}function gs(e){const r=$n(e),n=r.split(`
3605
3605
  `);return r.endsWith(`
3606
3606
  `)&&n.at(-1)===""&&n.pop(),n}function zf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Rf(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 Af(e,r,n){var d,h;const a=gs(e),o=gs(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=Rf(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())===""||zf(i.at(-1)??""));)i.pop();return i.join(`
@@ -3609,6 +3609,6 @@ ${JSON.stringify({call:{tool:u,args:p,call_id:h},result:m},null,2)}
3609
3609
  `);s.endsWith(`
3610
3610
  `)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
3611
3611
  `);if(n!==void 0&&a!==void 0){const u=(o!==void 0?Math.max(0,l.length-o):0)+a,p=Math.max(0,l.length-u-1);p>0&&(d+=`\x1B[${p}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function vs(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(`
3612
- `).trimEnd():""}function ag({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 ks={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function ut(e){return e.status!=="exited"&&e.status!=="not_found"}function sg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&ut(e))}function og(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 lg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&ut(r)):null)??(e.shell&&ut(e.shell)?e.shell:null)??e.shells.find(ut)??null}function ig({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&&!ut(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&&!ut(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?Zn(qr(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Pt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function cg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Df}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function hg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Bf}){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=Gf}){a.current=window.setTimeout(()=>{var h,u,p;a.current=null;const d=Of({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),(p=e.socket)==null||p.close()))},i)}function mg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function pg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Qf({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 fg({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&&Pt(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,mg,"detached"),u.shouldScheduleReconnect&&hg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function gg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Pt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Pt(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function xg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function bg(e){return il({...e,attachSize:void 0})}function vg({attachSize:e,...r}){return il({...r,attachSize:e})}function kg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=Uf({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function wg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function yg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=tg(e.payload,r),s=o.data?rg({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=Vf({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 Ng(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 Cg(e){return e.current}function Sg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:p,isVisibleRef:m,intentionalDisconnectRef:f,userDisconnectedShellIdRef:g,shellSnapshotRef:x,pendingCommandRef:k,lastCommandOutputRef:b,snapshotCursorRef:y,syncTerminalSizeRef:w,setReconnectKey:v,setViewerId:N,setIsConnecting:j,setConnectionError:S,setRuntimePromptLabel:P,setIsCommandRunning:C,settleAttachPromise:F,onShellUpdate:H}){const M=e==null?void 0:e.id,Q=e==null?void 0:e.cwd;c.useEffect(()=>{const V=s.current,W={shellId:M??null,terminalReady:a,isVisible:m.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!V,hasPendingAttachRetry:p.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===M),hasReconnectTimer:h.current!==null};if(bg(W).type==="skip")return;const de=w.current(),E=vg({...W,attachSize:de});if(E.type==="skip"||E.type==="measureSize")return;if(E.type==="scheduleRetry"){cg({attachRetryTimerRef:p,setReconnectKey:v});return}if(E.shouldClearAttachRetry&&Pt(p),E.type==="reuseSocket"||(E.shouldClearReconnectTimer&&Pt(h),!M||!V))return;const J=E.attachSize;d.current=M,V.reset(),S(null),N(null),j(!0),f.current=!1;const A=r.connectSocket({onConnected:()=>{var K;const X=u.current,O=kg({isCurrentSocket:((K=l.current)==null?void 0:K.socket)===A.socket,shellId:M,attachSize:J,hasAttachTimeout:X!==null}),I=O.openAction;I&&(A.send(I.message),O.shouldClearAttachTimeout&&X!==null&&Pt(u),I.shouldScheduleAttachTimeout&&ug({shellSocket:A,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:S,setIsConnecting:j,settleAttachPromise:F}))},onShellEvent:X=>{var K;if(!xg({eventShellId:X.shellId,shellId:M,socketExists:!!A.socket,isCurrentSocket:((K=l.current)==null?void 0:K.socket)===A.socket}))return;if(X.type==="shell.connected"){Pt(u);const B=wg(X);N(B.viewerId),j(!1),F(B.settleAttachPromise),H(M,B.nextShell,"attached");return}if(X.type==="shell.output"){const{output:B,snapshotUpdate:T}=yg({event:X,shellCwd:Q,currentSnapshot:x.current,pendingCommand:k.current});y.current={cursorX:B.cursorX,cursorY:B.cursorY,paneHeight:B.paneHeight},P(B.promptLabel),C(B.isCommandRunning),T&&(x.current=T.nextSnapshot,k.current=T.nextPendingCommand,T.lastCommandOutput!==null&&(b.current=T.lastCommandOutput),B.replace?cl(V,B.data,B.cursorX,B.cursorY,B.paneHeight):V.write(B.data));return}const I=ng({event:X,currentViewerId:i.current});I&&(I.viewerId!==void 0&&N(I.viewerId),I.isConnecting!==void 0&&j(I.isConnecting),I.settleAttachPromise!==void 0&&F(I.settleAttachPromise),I.isCommandRunning!==void 0&&C(I.isCommandRunning),I.connectionError!==void 0&&S(I.connectionError),I.intentionalDisconnect!==void 0&&(f.current=I.intentionalDisconnect),I.shellUpdate&&H(M,B=>Ng(B,I),I.shellUpdate.status),I.closeSocket&&A.socket.close())}});return l.current=A,A.socket.addEventListener("close",()=>{var I;const X=u.current,O=jg({isCurrentSocket:((I=l.current)==null?void 0:I.socket)===A.socket,hadViewer:!!i.current,intentionalDisconnect:f.current,userDisconnectedShellId:g.current,shellId:M,hasAttachTimeout:X!==null});fg({closeApplication:O,shellId:M,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:N,setIsConnecting:j,settleAttachPromise:F,onShellUpdate:H,setReconnectKey:v})}),()=>{const X=Cg(i),O=pg({shellId:M,viewerId:X,shellSocket:A,attachRetryTimerRef:p,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});gg({cleanupAction:O,shellSocket:A,attachRetryTimerRef:p,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:f,setViewerId:N,setIsConnecting:j,settleAttachPromise:F})}},[p,u,n,f,m,b,H,k,o,h,S,C,j,v,P,N,F,Q,M,r,d,x,y,l,w,a,s,g,i])}function bn(e){return e.current}var ws=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:p,onFeedback:m},f){const g=c.useRef(null),x=c.useRef(null),k=c.useRef(null),b=c.useRef(null),y=c.useRef(null),w=c.useRef(null),v=c.useRef(null),N=c.useRef(null),j=c.useRef(!1),S=c.useRef(null),P=c.useRef(""),C=c.useRef(null),F=c.useRef(""),H=c.useRef(null),M=c.useRef(null),Q=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),V=c.useRef(!1),W=c.useRef(null),Z=c.useRef(o),de=c.useRef(s),E=c.useRef(()=>!1),J=c.useRef(()=>null),A=c.useRef(()=>{}),X=c.useRef(ag({clearTimeout:window.clearTimeout})),[O,I]=c.useState(null),[K,B]=c.useState(!1),[T,z]=c.useState(null),[Y,$]=c.useState(!1),[q,G]=c.useState(null),[ce,ee]=c.useState(null),[ie,ue]=c.useState(!1),[ge,Le]=c.useState(0),re=(n==null?void 0:n.status)??"not_created",be=sg({shell:n,workspacePathMissing:i}),je=c.useMemo(()=>Zn(qr(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),xe=ce??je,ze=c.useCallback(D=>{b.current=D,z(D)},[]),R=c.useCallback(D=>{X.current.settle(D)},[]);c.useEffect(()=>{Z.current=o},[o]),c.useEffect(()=>{de.current=s},[s]),c.useEffect(()=>{y.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const te=c.useCallback(D=>{const ae=k.current,ye=y.current,ke=b.current;return!ae||!ye||!ke?!1:(ae.send({type:"shell.input",shellId:ye,viewerId:ke,data:D}),!0)},[]);c.useEffect(()=>{E.current=te},[te]);const ve=c.useCallback(()=>{const D=k.current,ae=y.current,ye=b.current;return!D||!ae||!ye?!1:(D.send({type:"shell.clear",shellId:ae,viewerId:ye}),!0)},[]),fe=c.useCallback(()=>{if(!o||!O)return!1;const D=O.getBoundingClientRect();return D.width>0&&D.height>0},[o,O]),pe=c.useCallback(D=>{const ae=g.current,ye=x.current;if(!ae||!ye||!fe()||(ye.fit(),ae.cols<=0||ae.rows<=0))return null;const ke={cols:ae.cols,rows:ae.rows},we=eg({size:ke,previousSize:M.current,shellId:y.current,viewerId:b.current,syncBackendSize:(D==null?void 0:D.syncBackendSize)!==!1});return(D==null?void 0:D.syncBackendSize)===!1||(M.current=we.nextLastSentSize,!we.message)||k.current&&k.current.send(we.message),ke},[fe]);c.useEffect(()=>{J.current=pe},[pe]);const Ie=c.useCallback(D=>{const ae=g.current;!ae||!fe()||(pe((D==null?void 0:D.syncBackendSize)===void 0?void 0:{syncBackendSize:D.syncBackendSize}),P.current&&!vs(O)?cl(ae,P.current,Q.current.cursorX,Q.current.cursorY,Q.current.paneHeight):ae.scrollToBottom(),D!=null&&D.focus&&!s&&ae.focus())},[s,fe,pe,O]);return c.useEffect(()=>{A.current=()=>Ie()},[Ie]),c.useEffect(()=>{p({status:T?"attached":re,shellInputEnabled:!!(T&&n),isConnecting:Y,isCommandRunning:ie,promptLabel:xe,error:q,hasShell:!!n})},[q,Y,ie,p,xe,n,re,T]),c.useEffect(()=>{if(!O||g.current||V.current)return;let D=!1;return V.current=!0,(async()=>{const[{Terminal:ae},{FitAddon:ye}]=await Promise.all([Oe(()=>import("./terminal-vendor-B365Go3Z.js").then(Te=>Te.x),__vite__mapDeps([6,2,7])),Oe(()=>import("./terminal-vendor-B365Go3Z.js").then(Te=>Te.a),__vite__mapDeps([6,2,7]))]);if(D||!O){V.current=!1;return}const ke=new ae({cursorBlink:!0,disableStdin:de.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:xs(l)}),we=new ye;ke.loadAddon(we),ke.open(O),g.current=ke,x.current=we,J.current(),ke.attachCustomKeyEventHandler(Te=>{if(de.current||Te.type!=="keydown")return!0;if(Te.ctrlKey&&!Te.altKey&&!Te.metaKey&&!Te.shiftKey){const De=If(Te.key);if(!De)return!0;if(E.current(De))return Te.preventDefault(),!1}return!0}),B(!0),V.current=!1,H.current=new ResizeObserver(()=>{A.current()}),H.current.observe(O),W.current=ke.onData(Te=>{de.current||E.current(Te)})})(),()=>{var ae,ye,ke;D=!0,V.current=!1,(ae=W.current)==null||ae.dispose(),W.current=null,(ye=H.current)==null||ye.disconnect(),H.current=null,B(!1),(ke=g.current)==null||ke.dispose(),g.current=null,x.current=null,M.current=null}},[l,O]),c.useEffect(()=>{var ae;const D=Yf({hasShell:!!n});D&&(ze(D.viewerId),$(D.isConnecting),R(D.settleAttachPromise),G(D.connectionError),ee(D.runtimePromptLabel),ue(D.isCommandRunning),P.current=D.shellSnapshot,F.current=D.lastCommandOutput,C.current=D.pendingCommand,D.shouldResetTerminal&&((ae=g.current)==null||ae.reset()))},[ze,R,n]),c.useEffect(()=>{const D=g.current;D&&(D.options.theme=xs(l))},[l]),c.useEffect(()=>{const D=g.current;D&&(D.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!K)return;const D=window.requestAnimationFrame(()=>{Ie({focus:a,syncBackendSize:!1}),!k.current&&(n!=null&&n.id)&&S.current!==n.id&&Le(ae=>ae+1)});return()=>{window.cancelAnimationFrame(D)}},[a,o,Ie,n==null?void 0:n.id,K]),Sg({shell:n,shellAdapter:d,canAttachShell:be,terminalReady:K,reconnectKey:ge,terminalRef:g,socketRef:k,viewerIdRef:b,shellIdRef:y,reconnectTimerRef:w,attachTimeoutRef:v,attachRetryTimerRef:N,isVisibleRef:Z,intentionalDisconnectRef:j,userDisconnectedShellIdRef:S,shellSnapshotRef:P,pendingCommandRef:C,lastCommandOutputRef:F,snapshotCursorRef:Q,syncTerminalSizeRef:J,setReconnectKey:Le,setViewerId:ze,setIsConnecting:$,setConnectionError:G,setRuntimePromptLabel:ee,setIsCommandRunning:ue,settleAttachPromise:R,onShellUpdate:u}),c.useEffect(()=>()=>{const D=bn(w),ae=bn(v),ye=bn(N),ke=Zf({hasReconnectTimer:D!==null,hasAttachTimeout:ae!==null,hasAttachRetry:ye!==null});ke.shouldClearReconnectTimer&&D!==null&&window.clearTimeout(D),ke.shouldClearAttachTimeout&&ae!==null&&window.clearTimeout(ae),ke.shouldClearAttachRetry&&ye!==null&&window.clearTimeout(ye),R(ke.settleAttachPromise)},[R]),c.useImperativeHandle(f,()=>({disconnect(){const D=k.current,ae=y.current,ye=b.current,ke=Jf({shellId:ae,viewerId:ye,hasSocket:!!D});S.current=ke.userDisconnectedShellId,j.current=ke.intentionalDisconnect,D&&ke.detachMessage&&D.send(ke.detachMessage),ze(null),$(!1),R(!1),ke.shouldCloseSocket&&(D==null||D.socket.close()),k.current=null,M.current=null,ke.shouldDetachShell&&ae&&u(ae,we=>({...we,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const D=Kf({hasShellId:!!y.current,terminalReady:K,workspacePathMissing:i,hasViewer:!!b.current,hasPendingAttach:X.current.hasPending()});if(D.type==="reject")return Promise.resolve(!1);if(D.type==="alreadyConnected")return Promise.resolve(!0);if(D.type==="joinPending")return X.current.joinPending();const ae=X.current.start({timeoutMs:Ff,setTimeout:window.setTimeout,onTimeout:()=>{$(!1)}}),ye=Xf({shellId:y.current,userDisconnectedShellId:S.current});return ye.shouldClearUserDisconnectedShellId&&(S.current=null),j.current=ye.intentionalDisconnect,G(ye.connectionError),$(ye.isConnecting),Le(ke=>ke+1),ae},sendInput(D){return te(D)},sendCommand(D){const ae={command:D,beforeSnapshot:P.current};if(C.current=ae,D.trim()==="clear"){const we=ve();return!we&&C.current===ae&&(C.current=null),we}const ye=D.endsWith(`
3613
- `)?D:`${D}
3614
- `,ke=te(ye);return!ke&&C.current===ae&&(C.current=null),ke},sendControl(D){return D==="clear"?ve():te(Mf(D))},async copyLastCommandOutput(){const D=F.current.trim()||vs(O);if(!D)return m==null||m("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(D),m==null||m("done","Copied"),!0}catch{return m==null||m("failed","Copy failed"),!1}},focus(){var D;(D=g.current)==null||D.focus()},refreshLayout(D){Ie(D)}}),[m,u,Ie,ve,te,ze,R,O,K,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:I,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var D;h(),(D=g.current)==null||D.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"})]})}),Tg=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 p=c.useRef(null),m=c.useRef(null),f=c.useRef(null),g=c.useRef(null),x=c.useRef(null),k=c.useRef(!1),[b,y]=c.useState(null),[w,v]=c.useState(!0),[N,j]=c.useState(!1),[S,P]=c.useState(null),[C,F]=c.useState("primary"),[H,M]=c.useState(null),[Q,V]=c.useState(null),[W,Z]=c.useState("single"),[de,E]=c.useState(50),[J,A]=c.useState(null),[X,O]=c.useState(""),[I,K]=c.useState(!1),[B,T]=c.useState(!1),[z,Y]=c.useState(!1),[$,q]=c.useState({primary:ks,secondary:ks}),[G,ce]=c.useState(null),ee=(b==null?void 0:b.state)??"not_created",ie=c.useMemo(()=>(b==null?void 0:b.shells)??[],[b==null?void 0:b.shells]),ue=c.useMemo(()=>ie.filter(ut),[ie]),ge=c.useMemo(()=>ue.find(L=>L.id===H)??null,[ue,H]),Le=c.useMemo(()=>ue.find(L=>L.id===Q)??null,[ue,Q]),re=C==="secondary"?Le:ge,be=$[C],je=(b==null?void 0:b.workspacePathStatus)==="missing",xe=C==="secondary"?m:p,ze=ig({activeRuntime:be,activeShell:re,busy:N,loading:w,status:ee,workspacePathMissing:je}),R=ze.disabled,te=ze.label,ve=ze.className,fe=(G==null?void 0:G.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(G==null?void 0:G.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",pe=c.useCallback((L,U)=>{ce({tone:L,text:U}),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{ce(null),f.current=null},1800)},[]),Ie=c.useCallback((L,U,he)=>{y(Ee=>{var rt;if(!Ee)return Ee;const Fe=Ee.shells.map(He=>He.id===L?U(He):He),Xe=((rt=Ee.shell)==null?void 0:rt.id)===L?U(Ee.shell):Fe.find(He=>{var We;return He.id===((We=Ee.shell)==null?void 0:We.id)})??Ee.shell;return{...Ee,...he?{state:he}:{},shell:Xe,shells:Fe}})},[]),D=c.useCallback(async()=>{v(!0);try{const L=await n.fetchState(r);y(L),P(null)}catch(L){P(L instanceof Error?L.message:"Unable to load shell state.")}finally{v(!1)}},[n,r]);c.useEffect(()=>{D()},[D]),c.useEffect(()=>{const L=i==null?void 0:i(r);if(L==null){E(50);return}const U=typeof L=="number"?L:Number.parseFloat(String(L));E(Number.isFinite(U)?gn(U):50)},[i,r]),c.useEffect(()=>{if(!b){M(null),V(null);return}const L=lg(b);M(U=>U&&b.shells.some(he=>he.id===U&&ut(he))?U:(L==null?void 0:L.id)??null),V(U=>{if(W!=="columns")return null;if(U&&b.shells.some(Ee=>Ee.id===U&&ut(Ee)))return U;const he=b.shells.find(Ee=>ut(Ee)&&Ee.id!==(L==null?void 0:L.id));return(he==null?void 0:he.id)??null})},[b,W]),c.useEffect(()=>{W!=="columns"&&(F("primary"),V(null))},[W]),c.useEffect(()=>{if(W!=="columns"||Q||ue.length<2)return;const L=ue.find(U=>U.id!==(ge==null?void 0:ge.id))??null;L&&V(L.id)},[ue,ge==null?void 0:ge.id,Q,W]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const L=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),U=()=>{K(L.matches),L.matches||(Y(!1),T(!1))};return U(),L.addEventListener("change",U),()=>{L.removeEventListener("change",U)}},[]),c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current),x.current!==null&&window.cancelAnimationFrame(x.current)},[]);const ae=c.useCallback((L,U)=>{q(he=>{const Ee=he[L];return og(Ee,U)?he:{...he,[L]:U}})},[]),ye=c.useCallback(L=>ae("primary",L),[ae]),ke=c.useCallback(L=>ae("secondary",L),[ae]),we=c.useCallback(L=>{var he;if((he=L.label)!=null&&he.trim())return L.label.trim();const U=ie.findIndex(Ee=>Ee.id===L.id);return`Shell ${U>=0?U+1:""}`.trim()},[ie]),Te=c.useCallback(L=>{var U;A(L.id),O(((U=L.label)==null?void 0:U.trim())||we(L))},[we]),De=c.useCallback(()=>{A(null),O("")},[]),et=c.useCallback(async()=>{if(J){j(!0);try{const L=X.trim(),U=await n.updateShell(J,{label:L.length>0?L:null});y(he=>{var Ee;return he&&{...he,state:he.activeShellId===U.id?U.status:he.state,shell:((Ee=he.shell)==null?void 0:Ee.id)===U.id?U:he.shell,shells:he.shells.map(Fe=>Fe.id===U.id?U:Fe)}}),A(null),O(""),P(null)}catch(L){P(L instanceof Error?L.message:"Unable to rename shell.")}finally{j(!1)}}},[X,J,n]),Ze=c.useCallback((L,U)=>{if(L==="primary"){M(U),V(he=>he===U?null:he);return}V(U),M(he=>he===U?null:he)},[]),it=c.useCallback(L=>{var U,he;if(L==="primary"){(U=p.current)==null||U.disconnect(),M(null),W==="columns"&&F("secondary");return}(he=m.current)==null||he.disconnect(),V(null),F("primary"),Z("single")},[W]),Ke=c.useCallback((L,U=C)=>{const he=W==="columns"?U:"primary";Ze(he,L.id),W!=="columns"&&V(null),F(he)},[C,Ze,W]),_e=c.useCallback(async(L=C)=>{var U;if(!k.current){k.current=!0,j(!0);try{const he=await n.createShell(r);y(he);const Ee=he.activeShellId??((U=he.shell)==null?void 0:U.id)??null;if(Ee){const Fe=W==="columns"?L:"primary";Ze(Fe,Ee),W!=="columns"&&V(null),F(Fe)}P(null)}catch(he){P(he instanceof Error?he.message:"Unable to create shell.")}finally{k.current=!1,j(!1)}}},[C,Ze,n,W,r]);c.useEffect(()=>{!a||!b||w||N||je||ee==="creating"||ue.length>0||_e("primary")},[N,_e,a,ue.length,w,b,ee,je]);const Ae=c.useCallback(async(L=(re==null?void 0:re.id)??"")=>{if(L){j(!0);try{await n.terminateShell(L),M(U=>U===L?null:U),V(U=>U===L?null:U),await D(),P(null)}catch(U){P(U instanceof Error?U.message:"Unable to terminate shell.")}finally{j(!1)}}},[re==null?void 0:re.id,D,n]),$e=c.useCallback(async()=>{var L,U;if(!R){if(be.shellInputEnabled){(L=xe.current)==null||L.disconnect();return}if(!re||re.status==="exited"||re.status==="not_found"){await _e(C);return}await((U=xe.current)==null?void 0:U.reconnect())}},[C,xe,be.shellInputEnabled,re,R,_e]),tt=c.useCallback(L=>{typeof window>"u"||d==null||d(r,gn(L))},[d,r]),st=c.useCallback(()=>{var L,U;(L=p.current)==null||L.refreshLayout({syncBackendSize:!0}),(U=m.current)==null||U.refreshLayout({syncBackendSize:!0})},[]),Je=c.useCallback(L=>{var Xe,rt;if(W!=="columns")return;const U=g.current;if(!U)return;L.preventDefault(),(rt=(Xe=L.currentTarget).setPointerCapture)==null||rt.call(Xe,L.pointerId);const he=He=>{const We=U.getBoundingClientRect();if(We.width<=0)return;const me=gn((He-We.left)/We.width*100);E(me),x.current!==null&&window.cancelAnimationFrame(x.current),x.current=window.requestAnimationFrame(()=>{x.current=null,st()})},Ee=He=>{he(He.clientX)},Fe=He=>{he(He.clientX);const We=U.getBoundingClientRect();We.width>0&&tt((He.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Ee),window.removeEventListener("pointerup",Fe)};window.addEventListener("pointermove",Ee),window.addEventListener("pointerup",Fe,{once:!0})},[tt,st,W]),ot=c.useCallback((L,U)=>{Ze(U,L.id),F(U)},[Ze]),oe=c.useCallback(async()=>{var U;return await((U=xe.current)==null?void 0:U.copyLastCommandOutput())?!0:(pe("failed","Nothing to copy"),!1)},[xe,pe]);c.useEffect(()=>{h==null||h(dg({activeRuntime:be,activeShell:re,connectionButtonDisabled:R,connectionButtonLabel:te,isMobileShell:I,busy:N,loading:w,error:S}))},[be,re,N,R,te,S,I,w,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await $e()},sendInput(L){var U;return((U=xe.current)==null?void 0:U.sendInput(L))??!1},sendCommand(L){var U;return((U=xe.current)==null?void 0:U.sendCommand(L))??!1},sendControl(L){var U;return((U=xe.current)==null?void 0:U.sendControl(L))??!1},async copyLastCommandOutput(){var L;return await((L=xe.current)==null?void 0:L.copyLastCommandOutput())??!1},async terminate(){await Ae()},focus(){var L;(L=xe.current)==null||L.focus()},refreshLayout(L){var U,he;(U=p.current)==null||U.refreshLayout(L),W==="columns"&&((he=m.current)==null||he.refreshLayout(L))}}),[xe,$e,Ae,W]);const Ge=L=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${L.id===(re==null?void 0:re.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:[J===L.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:U=>{U.preventDefault(),et()},children:t.jsx("input",{value:X,onChange:U=>O(U.currentTarget.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),De())},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:()=>Ke(L),onDoubleClick:()=>Te(L),className:"min-w-0 flex-1 text-left",title:L.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:we(L)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[fn(L.status)," · ",qr(L.cwd)||L.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[J===L.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void et(),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:De,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:()=>Te(L),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"}),W==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>ot(L,"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(L,"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:N,onClick:()=>void Ae(L.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"})]})]})},L.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:be.promptLabel??(re==null?void 0:re.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":te,title:`${te} (${fn(be.status)})`,disabled:R,onClick:()=>void $e(),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 ${ve}`,children:t.jsx($f,{connected:be.shellInputEnabled})}),re&&t.jsx("button",{type:"button",disabled:N,onClick:()=>void Ae(re.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"})]})]}),(S||w||je)&&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&&je&&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&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]})]}),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:re?we(re):"No live shell process"}),re&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:fn(be.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 ",ue.length]}),t.jsx("button",{type:"button","aria-expanded":B,"aria-label":B?"Hide shell processes":"Show shell processes",onClick:()=>T(L=>!L),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:[ue.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ue.map(Ge),ue.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:N||w||je,onClick:()=>void _e(C),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"||je?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."}),!je&&t.jsx("button",{type:"button",disabled:N||w,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&&(S||w||je)&&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&&je&&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&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${W==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:W==="columns"?{"--shell-left":`${de}fr`,"--shell-right":`${100-de}fr`}:void 0,"data-shell-split-ratio":de,children:[t.jsx(ws,{ref:p,paneId:"primary",shell:ge,isActive:C==="primary",isVisible:a,isMobileShell:I,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>F("primary"),onShellUpdate:Ie,onRuntimeStateChange:ye,onFeedback:pe}),W==="columns"&&t.jsx("button",{type:"button",onClick:()=>it("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"}),W==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Je,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"}),W==="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(ws,{ref:m,paneId:"secondary",shell:Le,isActive:C==="secondary",isVisible:a,isMobileShell:I,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>F("secondary"),onShellUpdate:Ie,onRuntimeStateChange:ke,onFeedback:pe}),t.jsx("button",{type:"button",onClick:()=>it("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&&I&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[G&&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:G.text}),z&&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:()=>{pe("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(bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void oe(),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(bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!be.shellInputEnabled,onClick:()=>{var L;(L=xe.current)!=null&&L.sendControl("clear")?pe("done","Cleared"):pe("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(xn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!be.shellInputEnabled||!be.isCommandRunning,onClick:()=>{var L;(L=xe.current)!=null&&L.sendInput("")?pe("done","Sent Ctrl-C"):pe("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(xn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(L=>t.jsx("button",{type:"button",disabled:!be.shellInputEnabled,onClick:()=>{var U;(U=xe.current)!=null&&U.sendControl(L)?pe("done",`Sent ${L.toUpperCase().replace("_","-")}`):pe("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(xn,{label:L.toUpperCase().replace("_","-"),tone:"stone"})},L))]})}),t.jsx("button",{type:"button","aria-expanded":z,"aria-label":z?"Close shell tools":"Open shell tools",onClick:()=>Y(L=>!L),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(_f,{})})]})]}),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:[ue.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ue.map(Ge),ue.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:N||w||je,onClick:()=>void _e(C),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:"+"})})]})]})]})})]})}),Eg=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(Wh(),Fo))).ThreadGraphWorkspacePanel}));function Lg(){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 hl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Lg,{}),children:t.jsx(Eg,{...e})})}c.memo(hl);function Wg({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?Mr.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 Pg(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 Ig(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function Vg({open:e,busy:r=!1,turnsState:n,onCancel:a,onLoadTurns:o,onExport:s}){var j,S,P;const l=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(j=n.data)==null?void 0:j.turns]),i=c.useMemo(()=>l.slice(0,10).map(C=>C.turnId),[l]),[d,h]=c.useState("latest"),[u,p]=c.useState(()=>new Set),[m,f]=c.useState(!0),[g,x]=c.useState("pdf"),[k,b]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(h("latest"),x("pdf"),f(!0),o())},[o,e]),c.useEffect(()=>{e&&l.length>0&&p(new Set(i))},[i,e,l.length]),c.useEffect(()=>{if(!e)return;function C(F){F.key==="Escape"&&!r&&a()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,a,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),F=()=>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(b(F()),!C)return;const H=new MutationObserver(()=>b(F()));return H.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>H.disconnect()},[e]),!e)return null;const y=d==="latest"?Math.min(10,((S=n.data)==null?void 0:S.totalTurnCount)??10):u.size,w=!r&&(d==="latest"||u.size>0);function v(C){p(F=>{const H=new Set(F);return H.has(C)?H.delete(C):H.add(C),H})}function N(){const C={format:g,mode:d,...d==="latest"?{limit:10}:{turnIds:[...u]},profile:"review",options:{includeTokenAndPrice:m}};s(C)}return Mr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${k} fixed inset-0 z-[96] flex items-center justify-center p-3 sm:p-6`,"data-theme-effective":k,children:[t.jsx("button",{type:"button","aria-label":"Close export dialog",onClick:a,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":"Export transcript",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(46rem,calc(100vh-2rem))] w-full max-w-2xl flex-col rounded-[1.6rem] border shadow-2xl",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:"Export transcript"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Default review copy summarizes command batches and file changes."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,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:[["latest","Latest 10"],["selected","Custom selection"]].map(([C,F])=>t.jsx("button",{type:"button",onClick:()=>h(C),className:`rounded-full px-3 py-1.5 text-sm transition ${d===C?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:F},C))}),t.jsx("div",{className:"thread-export-dialog-segment mt-4 inline-flex rounded-full border p-1",children:[["pdf","PDF"],["html","HTML"]].map(([C,F])=>t.jsx("button",{type:"button",onClick:()=>x(C),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:F},C))}),d==="selected"?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 ",u.size," of ",((P=n.data)==null?void 0:P.totalTurnCount)??l.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>p(new Set(l.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:()=>p(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:l.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:u.has(C.turnId),onChange:()=>v(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:Pg(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:Ig(C.status)})]},C.turnId))})]}):t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-body-text mt-4 rounded-2xl border px-3 py-3 text-sm",children:"Exports the latest 10 turns in chronological order."}),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:m,onChange:C=>f(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.jsxs("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:[y," ",y===1?"turn":"turns"," will be exported."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:a,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"}),t.jsx("button",{type:"button",onClick:N,disabled:!w,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 vn(e){if(e===void 0)return"-";if(Math.abs(e)>1e4){const r=Math.abs(e)>=1e5?0:1;return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:r})}k`}return e.toLocaleString()}function zg(e){return`in ${vn(e.input)} / out ${vn(e.output)} / cache ${vn(e.cache)}`}function Rg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=ll,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:p=0,composerHostRef:m}){const[f,g]=c.useState(!1),[x,k]=c.useState(0),[b,y]=c.useState(0),[w,v]=c.useState(0),[N,j]=c.useState(!1),S=c.useRef(null),P=i==null?void 0:i.onTailVisibilityChange,C=e.pendingRequests.length>0,F=c.useCallback(E=>{P==null||P(E)},[P]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const E=window.matchMedia("(max-width: 639px)"),J=()=>g(E.matches);return J(),E.addEventListener("change",J),()=>{E.removeEventListener("change",J)}},[]),c.useEffect(()=>{var J,A;if(typeof window>"u")return;const E=()=>{const X=window.visualViewport,O=X?Math.max(0,Math.round(window.innerHeight-X.height-X.offsetTop)):0,I=X?Math.max(0,Math.round(window.innerHeight-X.height)):O,K=Math.min(O,I),B=Math.max(0,Math.round(window.innerHeight*.52));v(Math.min(K,B))};return E(),(J=window.visualViewport)==null||J.addEventListener("resize",E),(A=window.visualViewport)==null||A.addEventListener("scroll",E),window.addEventListener("resize",E),()=>{var X,O;(X=window.visualViewport)==null||X.removeEventListener("resize",E),(O=window.visualViewport)==null||O.removeEventListener("scroll",E),window.removeEventListener("resize",E)}},[]),c.useLayoutEffect(()=>{const E=S.current;if(!E||!f){k(0);return}const J=()=>{k(Math.ceil(E.getBoundingClientRect().height))};if(J(),typeof ResizeObserver>"u")return;const A=new ResizeObserver(J);return A.observe(E),()=>{A.disconnect()}},[f,l,C]),c.useLayoutEffect(()=>{var X,O;const E=S.current;if(!E||!f){y(0);return}const J=()=>{const I=E.getBoundingClientRect();y(Math.max(0,Math.ceil(window.innerHeight-I.top)))};J(),window.addEventListener("resize",J),(X=window.visualViewport)==null||X.addEventListener("resize",J),(O=window.visualViewport)==null||O.addEventListener("scroll",J);let A=null;return typeof ResizeObserver<"u"&&(A=new ResizeObserver(J),A.observe(E)),()=>{var I,K;window.removeEventListener("resize",J),(I=window.visualViewport)==null||I.removeEventListener("resize",J),(K=window.visualViewport)==null||K.removeEventListener("scroll",J),A==null||A.disconnect()}},[f,w,N,l,C]),c.useEffect(()=>{if(!f){j(!1);return}const E=A=>{var O;const X=A.target;X instanceof HTMLElement&&((O=S.current)!=null&&O.contains(X))&&j(!0)},J=A=>{var O;const X=A.relatedTarget;X instanceof HTMLElement&&((O=S.current)!=null&&O.contains(X))||j(!1)};return document.addEventListener("focusin",E),document.addEventListener("focusout",J),()=>{document.removeEventListener("focusin",E),document.removeEventListener("focusout",J)}},[f]);const H=c.useCallback(E=>{S.current=E,m&&(m.current=E)},[m]),M=f&&N?Math.max(0,w-p):0,Q=Math.max(x,144),V=Math.max(b,Q+M),W=f?V+12:0,Z=W>0?{"--thread-graph-chat-scroll-bottom-spacer":`${W}px`}:void 0,de=u&&f?{bottom:`${p+M}px`,paddingBottom:"env(safe-area-inset-bottom)"}:void 0;return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:Z,children:[s,t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:e.thread.status==="running"||e.thread.activeTurnId!==null,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:F}),t.jsxs("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center justify-between gap-3 px-4 py-1 text-[10px] leading-4 sm:flex",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),h," item",h!==1?"s":""]}),t.jsxs("span",{className:"shrink-0",children:["Usage"," ",d&&d.turns>0?zg(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:H,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:de??{bottom:`${p}px`,paddingBottom:"env(safe-area-inset-bottom)"},children:t.jsx(Pn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:H,className:"thread-graph-composer-host shrink-0",children:t.jsx(Pn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Ag(e){return e.turns.reduce((r,n)=>{var o;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,turns:r.turns+1}:r},{input:0,output:0,cache:0,turns:0})}function kn(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 Mg(e){return!e||e.turns<=0?"waiting for agent usage":`in ${kn(e.input)} / out ${kn(e.output)} / cache ${kn(e.cache)}`}function qg({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,mobileHeaderAction:u,appMenuButton:p,appNavigationMenu:m,workspaceReturnHref:f,onWorkspaceReturn:g,surfaceActions:x,floatingPanel:k,workspaceContent:b,workspaceTitle:y,workspaceActions:w,workspaceFeatures:v,onNewThreadTitle:N,beforeTimelineContent:j,errorContent:S,workspaceMissingContent:P,dialogs:C,currentThreadId:F,currentWorkspaceId:H,currentWorkspaceLabel:M,onCloseAppNavigation:Q,className:V="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:W="chat",liveOutput:Z="",timelineProps:de,composerProps:E,shellComposerProps:J,useFloatingMobileComposer:A=!1,floatingMobileComposerBottomOffset:X=0,composerHostRef:O,shellPanelRef:I,shellEffectiveTheme:K="dark",shellThemeMode:B=K,onShellThemeModeChange:T,onShellStateChange:z,shellUnavailableContent:Y,shellDisconnectedContent:$,timelineComponent:q=ll,shellPanelComponent:G=Tg,shellContent:ce,loadingContent:ee,emptyContent:ie}){const ue=Xn(),ge=s??ue??qn(),{getImageAssetUrl:Le,loadHistoryItemDetail:re,openThread:be}=l,je=c.useMemo(()=>({...Le?{getImageAssetUrl:Ie=>Le(Ie.path)}:{},onOpenLinkedThread:be,...re?{onLoadHistoryItemDetail:re}:{}}),[Le,re,be]),xe=ge.getThreadPanels().some(Ie=>Ie.kind==="terminal"),ze=c.useMemo(()=>r?Ag(r):null,[r]),R=c.useMemo(()=>Mg(ze),[ze]),te=c.useMemo(()=>{var Ie;return r?r.turns.reduce((D,ae)=>D+ae.items.length,((Ie=r.liveItems)==null?void 0:Ie.items.length)??0):0},[r]),ve=b??(r?t.jsx(hl,{detail:r,status:o,plugins:ge,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:W,features:v}):null),fe=n?ee??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:V,children:[k?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:k}):null,a&&!n&&(S??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"&&(P??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:W==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Rg,{detail:r,adapter:l,timelineAdapter:je,TimelineComponent:q,liveOutput:Z,threadUsageSummary:ze,transcriptItemCount:te,useFloatingMobileComposer:A,floatingMobileComposerBottomOffset:X,...j?{beforeTimelineContent:j}:{},...E?{composerProps:E}:{},...de?{timelineProps:de}:{},...O?{composerHostRef:O}:{}})}),t.jsxs("div",{className:W==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ce??(r.thread.isLoaded&&xe&&l.shell?t.jsx(G,{ref:I,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:K,isVisible:W==="shell",showHeader:!1,showFloatingToolbox:!1,...z?{onStateChange:z}:{}}):r.thread.isLoaded&&!xe?Y??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."})]})}):$??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."})]})})),W==="shell"&&J&&!ce?t.jsx(Pn,{...J,activeView:"shell",onSubmit:l.sendPrompt}):null]}),C]}):ie??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."}),pe=t.jsx(Bm,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:F??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:H??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:M??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:R,topbarActions:x,metaContent:i,settingsContent:d,globalSettingsContent:h,mobileHeaderAction:u,effectiveTheme:K,themeMode:B,appMenuButton:p,appNavigationMenu:m,workspaceReturnHref:f,...g?{onWorkspaceReturn:g}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:ve,workspaceTitle:y??"Workspace",workspaceActions:w,...N?{onNewThreadTitle:N}:{},...Q?{onCloseAppNavigation:Q}:{},...T?{onThemeModeChange:T}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:fe});return s?t.jsx(Kn.Provider,{value:ge,children:pe}):pe}var _g={},$g=[];function Kg({adapter:e=_g,builtinPlugins:r=$g,children:n}){const[a,o]=c.useState(()=>In(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(In(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,v)=>{if(e.updatePlugin){const N=await e.updatePlugin(w,{enabled:v});o(j=>j.map(S=>S.id===N.id?N:S));return}o(N=>N.map(j=>j.id===w?{...j,enabled:v}:j))},[e]),p=c.useCallback(async w=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const v=await e.importPlugin(w);o(N=>[...N.filter(S=>S.id!==v.id),v])},[e]),m=c.useCallback(async w=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const v=await e.deletePlugin(w);o(N=>N.filter(j=>j.id!==v.id))},[e]),f=c.useMemo(()=>{const w=new Set(a.filter(v=>v.enabled).map(v=>v.id));return r.filter(v=>w.has(v.manifest.id))},[r,a]),g=c.useCallback(w=>{var N;const v=f.find(j=>j.renderArtifact&&j.manifest.capabilities.artifactTypes.some(S=>S.type===w.artifact.type));return((N=v==null?void 0:v.renderArtifact)==null?void 0:N.call(v,w))??null},[f]),x=c.useCallback(w=>{for(const v of f)for(const N of v.inlineCodeRenderers??[]){if(!N.languages.includes(w.language.trim().toLowerCase()))continue;const j=N.render(w);if(j)return j}return null},[f]),k=c.useCallback(w=>f.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(N=>N.type===w.type)),[f]),b=c.useCallback(()=>f.flatMap(w=>w.threadPanels??[]),[f]),y=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:p,setPluginEnabled:u,uninstallPlugin:m,renderArtifact:g,renderInlineCode:x,hasRendererForArtifact:k,getThreadPanels:b}),[i,b,k,p,s,a,h,g,x,u,m]);return t.jsx(Kn.Provider,{value:y,children:n})}function Dg(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M2 3.25h12v1.5H2Zm0 4h12v1.5H2Zm0 4h12v1.5H2Z"})})}function Bg(){return 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"})})}function ys(e=!1){return`flex w-full items-center rounded-[0.95rem] px-3 py-2 text-left text-sm transition ${e?"cursor-not-allowed bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]":"text-[var(--theme-fg)] hover:bg-[var(--theme-hover)]"}`}function Xg({className:e=""}){const r=Hr();return r?t.jsx("button",{type:"button","aria-label":r.navOpen?"Close Navigation":"Open Navigation","aria-expanded":r.navOpen,"aria-controls":"app-shell-navigation-menu",onClick:r.toggleNav,className:`inline-flex h-10 w-10 shrink-0 items-center justify-center text-[var(--theme-fg)] transition hover:text-[var(--theme-fg-soft)] ${e}`.trim(),children:r.navOpen?t.jsx(Bg,{}):t.jsx(Dg,{})}):null}function Yg({className:e="",currentPath:r="",items:n=[{label:"Workspaces",href:"/workspaces"}],onNavigate:a}){const o=Hr(),s=c.useRef(null);return c.useEffect(()=>{if(!(o!=null&&o.navOpen))return;const l=o;function i(d){const h=d.target;if(!h)return;const u=s.current;u!=null&&u.contains(h)||h instanceof Element&&h.closest('[aria-controls="app-shell-navigation-menu"]')||l.closeNav()}return document.addEventListener("pointerdown",i),()=>{document.removeEventListener("pointerdown",i)}},[o]),o!=null&&o.navOpen?t.jsxs("div",{ref:s,id:"app-shell-navigation-menu",onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),className:`rounded-[1.8rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 shadow-2xl shadow-black/15 backdrop-blur ${e}`.trim(),children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-base font-semibold tracking-wide text-[var(--theme-accent-strong)]",children:"Remote Codex"}),t.jsx("p",{className:"mt-1 text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Navigation"})]}),t.jsxs("nav",{className:"mt-4 flex flex-col gap-1.5 text-sm",children:[n.map(l=>{const i=r===l.href;return t.jsx("button",{type:"button",disabled:i,onClick:()=>{i||(o.closeNav(),a==null||a(l.href))},className:ys(i),children:l.label},l.href)}),t.jsx("button",{type:"button",onClick:o.openSettings,className:ys(),children:"Settings"})]})]}):null}export{Yg as A,Wg as C,Vg as E,Gm as L,Kg as P,qg as T,Xn as a,Xg as b,Tg as c,ll as d,Bm as e,qt as f,Dm as g,jm as h,Nm as t,Hr as u};
3612
+ `).trimEnd():""}function ag({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 ks={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function ut(e){return e.status!=="exited"&&e.status!=="not_found"}function sg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&ut(e))}function og(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 lg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&ut(r)):null)??(e.shell&&ut(e.shell)?e.shell:null)??e.shells.find(ut)??null}function ig({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&&!ut(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&&!ut(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?Zn(qr(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Pt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function cg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=Df}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function hg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=Bf}){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=Gf}){a.current=window.setTimeout(()=>{var h,u,p;a.current=null;const d=Of({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),(p=e.socket)==null||p.close()))},i)}function mg(e){return{...e,status:e.status==="attached"?"detached":e.status,attachedViewerId:null}}function pg({shellId:e,viewerId:r,shellSocket:n,attachRetryTimerRef:a,attachTimeoutRef:o,socketRef:s,openReadyState:l}){var i;return Qf({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 fg({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&&Pt(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,mg,"detached"),u.shouldScheduleReconnect&&hg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function gg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Pt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Pt(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function xg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function bg(e){return il({...e,attachSize:void 0})}function vg({attachSize:e,...r}){return il({...r,attachSize:e})}function kg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=Uf({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function wg(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function yg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=tg(e.payload,r),s=o.data?rg({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=Vf({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 Ng(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 Cg(e){return e.current}function Sg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:p,isVisibleRef:m,intentionalDisconnectRef:f,userDisconnectedShellIdRef:g,shellSnapshotRef:x,pendingCommandRef:k,lastCommandOutputRef:b,snapshotCursorRef:y,syncTerminalSizeRef:w,setReconnectKey:v,setViewerId:N,setIsConnecting:j,setConnectionError:S,setRuntimePromptLabel:L,setIsCommandRunning:C,settleAttachPromise:H,onShellUpdate:O}){const M=e==null?void 0:e.id,Q=e==null?void 0:e.cwd;c.useEffect(()=>{const V=s.current,W={shellId:M??null,terminalReady:a,isVisible:m.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!V,hasPendingAttachRetry:p.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===M),hasReconnectTimer:h.current!==null};if(bg(W).type==="skip")return;const de=w.current(),T=vg({...W,attachSize:de});if(T.type==="skip"||T.type==="measureSize")return;if(T.type==="scheduleRetry"){cg({attachRetryTimerRef:p,setReconnectKey:v});return}if(T.shouldClearAttachRetry&&Pt(p),T.type==="reuseSocket"||(T.shouldClearReconnectTimer&&Pt(h),!M||!V))return;const J=T.attachSize;d.current=M,V.reset(),S(null),N(null),j(!0),f.current=!1;const A=r.connectSocket({onConnected:()=>{var K;const Y=u.current,F=kg({isCurrentSocket:((K=l.current)==null?void 0:K.socket)===A.socket,shellId:M,attachSize:J,hasAttachTimeout:Y!==null}),I=F.openAction;I&&(A.send(I.message),F.shouldClearAttachTimeout&&Y!==null&&Pt(u),I.shouldScheduleAttachTimeout&&ug({shellSocket:A,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:S,setIsConnecting:j,settleAttachPromise:H}))},onShellEvent:Y=>{var K;if(!xg({eventShellId:Y.shellId,shellId:M,socketExists:!!A.socket,isCurrentSocket:((K=l.current)==null?void 0:K.socket)===A.socket}))return;if(Y.type==="shell.connected"){Pt(u);const D=wg(Y);N(D.viewerId),j(!1),H(D.settleAttachPromise),O(M,D.nextShell,"attached");return}if(Y.type==="shell.output"){const{output:D,snapshotUpdate:P}=yg({event:Y,shellCwd:Q,currentSnapshot:x.current,pendingCommand:k.current});y.current={cursorX:D.cursorX,cursorY:D.cursorY,paneHeight:D.paneHeight},L(D.promptLabel),C(D.isCommandRunning),P&&(x.current=P.nextSnapshot,k.current=P.nextPendingCommand,P.lastCommandOutput!==null&&(b.current=P.lastCommandOutput),D.replace?cl(V,D.data,D.cursorX,D.cursorY,D.paneHeight):V.write(D.data));return}const I=ng({event:Y,currentViewerId:i.current});I&&(I.viewerId!==void 0&&N(I.viewerId),I.isConnecting!==void 0&&j(I.isConnecting),I.settleAttachPromise!==void 0&&H(I.settleAttachPromise),I.isCommandRunning!==void 0&&C(I.isCommandRunning),I.connectionError!==void 0&&S(I.connectionError),I.intentionalDisconnect!==void 0&&(f.current=I.intentionalDisconnect),I.shellUpdate&&O(M,D=>Ng(D,I),I.shellUpdate.status),I.closeSocket&&A.socket.close())}});return l.current=A,A.socket.addEventListener("close",()=>{var I;const Y=u.current,F=jg({isCurrentSocket:((I=l.current)==null?void 0:I.socket)===A.socket,hadViewer:!!i.current,intentionalDisconnect:f.current,userDisconnectedShellId:g.current,shellId:M,hasAttachTimeout:Y!==null});fg({closeApplication:F,shellId:M,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:N,setIsConnecting:j,settleAttachPromise:H,onShellUpdate:O,setReconnectKey:v})}),()=>{const Y=Cg(i),F=pg({shellId:M,viewerId:Y,shellSocket:A,attachRetryTimerRef:p,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});gg({cleanupAction:F,shellSocket:A,attachRetryTimerRef:p,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:f,setViewerId:N,setIsConnecting:j,settleAttachPromise:H})}},[p,u,n,f,m,b,O,k,o,h,S,C,j,v,L,N,H,Q,M,r,d,x,y,l,w,a,s,g,i])}function bn(e){return e.current}var ws=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:p,onFeedback:m},f){const g=c.useRef(null),x=c.useRef(null),k=c.useRef(null),b=c.useRef(null),y=c.useRef(null),w=c.useRef(null),v=c.useRef(null),N=c.useRef(null),j=c.useRef(!1),S=c.useRef(null),L=c.useRef(""),C=c.useRef(null),H=c.useRef(""),O=c.useRef(null),M=c.useRef(null),Q=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),V=c.useRef(!1),W=c.useRef(null),Z=c.useRef(o),de=c.useRef(s),T=c.useRef(()=>!1),J=c.useRef(()=>null),A=c.useRef(()=>{}),Y=c.useRef(ag({clearTimeout:window.clearTimeout})),[F,I]=c.useState(null),[K,D]=c.useState(!1),[P,z]=c.useState(null),[X,_]=c.useState(!1),[q,G]=c.useState(null),[ce,ee]=c.useState(null),[ie,ue]=c.useState(!1),[ge,Le]=c.useState(0),re=(n==null?void 0:n.status)??"not_created",be=sg({shell:n,workspacePathMissing:i}),je=c.useMemo(()=>Zn(qr(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),xe=ce??je,ze=c.useCallback(B=>{b.current=B,z(B)},[]),R=c.useCallback(B=>{Y.current.settle(B)},[]);c.useEffect(()=>{Z.current=o},[o]),c.useEffect(()=>{de.current=s},[s]),c.useEffect(()=>{y.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const te=c.useCallback(B=>{const ae=k.current,ye=y.current,ke=b.current;return!ae||!ye||!ke?!1:(ae.send({type:"shell.input",shellId:ye,viewerId:ke,data:B}),!0)},[]);c.useEffect(()=>{T.current=te},[te]);const ve=c.useCallback(()=>{const B=k.current,ae=y.current,ye=b.current;return!B||!ae||!ye?!1:(B.send({type:"shell.clear",shellId:ae,viewerId:ye}),!0)},[]),fe=c.useCallback(()=>{if(!o||!F)return!1;const B=F.getBoundingClientRect();return B.width>0&&B.height>0},[o,F]),pe=c.useCallback(B=>{const ae=g.current,ye=x.current;if(!ae||!ye||!fe()||(ye.fit(),ae.cols<=0||ae.rows<=0))return null;const ke={cols:ae.cols,rows:ae.rows},we=eg({size:ke,previousSize:M.current,shellId:y.current,viewerId:b.current,syncBackendSize:(B==null?void 0:B.syncBackendSize)!==!1});return(B==null?void 0:B.syncBackendSize)===!1||(M.current=we.nextLastSentSize,!we.message)||k.current&&k.current.send(we.message),ke},[fe]);c.useEffect(()=>{J.current=pe},[pe]);const Ie=c.useCallback(B=>{const ae=g.current;!ae||!fe()||(pe((B==null?void 0:B.syncBackendSize)===void 0?void 0:{syncBackendSize:B.syncBackendSize}),L.current&&!vs(F)?cl(ae,L.current,Q.current.cursorX,Q.current.cursorY,Q.current.paneHeight):ae.scrollToBottom(),B!=null&&B.focus&&!s&&ae.focus())},[s,fe,pe,F]);return c.useEffect(()=>{A.current=()=>Ie()},[Ie]),c.useEffect(()=>{p({status:P?"attached":re,shellInputEnabled:!!(P&&n),isConnecting:X,isCommandRunning:ie,promptLabel:xe,error:q,hasShell:!!n})},[q,X,ie,p,xe,n,re,P]),c.useEffect(()=>{if(!F||g.current||V.current)return;let B=!1;return V.current=!0,(async()=>{const[{Terminal:ae},{FitAddon:ye}]=await Promise.all([Oe(()=>import("./terminal-vendor-B365Go3Z.js").then(Te=>Te.x),__vite__mapDeps([6,2,7])),Oe(()=>import("./terminal-vendor-B365Go3Z.js").then(Te=>Te.a),__vite__mapDeps([6,2,7]))]);if(B||!F){V.current=!1;return}const ke=new ae({cursorBlink:!0,disableStdin:de.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:xs(l)}),we=new ye;ke.loadAddon(we),ke.open(F),g.current=ke,x.current=we,J.current(),ke.attachCustomKeyEventHandler(Te=>{if(de.current||Te.type!=="keydown")return!0;if(Te.ctrlKey&&!Te.altKey&&!Te.metaKey&&!Te.shiftKey){const De=If(Te.key);if(!De)return!0;if(T.current(De))return Te.preventDefault(),!1}return!0}),D(!0),V.current=!1,O.current=new ResizeObserver(()=>{A.current()}),O.current.observe(F),W.current=ke.onData(Te=>{de.current||T.current(Te)})})(),()=>{var ae,ye,ke;B=!0,V.current=!1,(ae=W.current)==null||ae.dispose(),W.current=null,(ye=O.current)==null||ye.disconnect(),O.current=null,D(!1),(ke=g.current)==null||ke.dispose(),g.current=null,x.current=null,M.current=null}},[l,F]),c.useEffect(()=>{var ae;const B=Yf({hasShell:!!n});B&&(ze(B.viewerId),_(B.isConnecting),R(B.settleAttachPromise),G(B.connectionError),ee(B.runtimePromptLabel),ue(B.isCommandRunning),L.current=B.shellSnapshot,H.current=B.lastCommandOutput,C.current=B.pendingCommand,B.shouldResetTerminal&&((ae=g.current)==null||ae.reset()))},[ze,R,n]),c.useEffect(()=>{const B=g.current;B&&(B.options.theme=xs(l))},[l]),c.useEffect(()=>{const B=g.current;B&&(B.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!K)return;const B=window.requestAnimationFrame(()=>{Ie({focus:a,syncBackendSize:!1}),!k.current&&(n!=null&&n.id)&&S.current!==n.id&&Le(ae=>ae+1)});return()=>{window.cancelAnimationFrame(B)}},[a,o,Ie,n==null?void 0:n.id,K]),Sg({shell:n,shellAdapter:d,canAttachShell:be,terminalReady:K,reconnectKey:ge,terminalRef:g,socketRef:k,viewerIdRef:b,shellIdRef:y,reconnectTimerRef:w,attachTimeoutRef:v,attachRetryTimerRef:N,isVisibleRef:Z,intentionalDisconnectRef:j,userDisconnectedShellIdRef:S,shellSnapshotRef:L,pendingCommandRef:C,lastCommandOutputRef:H,snapshotCursorRef:Q,syncTerminalSizeRef:J,setReconnectKey:Le,setViewerId:ze,setIsConnecting:_,setConnectionError:G,setRuntimePromptLabel:ee,setIsCommandRunning:ue,settleAttachPromise:R,onShellUpdate:u}),c.useEffect(()=>()=>{const B=bn(w),ae=bn(v),ye=bn(N),ke=Zf({hasReconnectTimer:B!==null,hasAttachTimeout:ae!==null,hasAttachRetry:ye!==null});ke.shouldClearReconnectTimer&&B!==null&&window.clearTimeout(B),ke.shouldClearAttachTimeout&&ae!==null&&window.clearTimeout(ae),ke.shouldClearAttachRetry&&ye!==null&&window.clearTimeout(ye),R(ke.settleAttachPromise)},[R]),c.useImperativeHandle(f,()=>({disconnect(){const B=k.current,ae=y.current,ye=b.current,ke=Jf({shellId:ae,viewerId:ye,hasSocket:!!B});S.current=ke.userDisconnectedShellId,j.current=ke.intentionalDisconnect,B&&ke.detachMessage&&B.send(ke.detachMessage),ze(null),_(!1),R(!1),ke.shouldCloseSocket&&(B==null||B.socket.close()),k.current=null,M.current=null,ke.shouldDetachShell&&ae&&u(ae,we=>({...we,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const B=Kf({hasShellId:!!y.current,terminalReady:K,workspacePathMissing:i,hasViewer:!!b.current,hasPendingAttach:Y.current.hasPending()});if(B.type==="reject")return Promise.resolve(!1);if(B.type==="alreadyConnected")return Promise.resolve(!0);if(B.type==="joinPending")return Y.current.joinPending();const ae=Y.current.start({timeoutMs:Ff,setTimeout:window.setTimeout,onTimeout:()=>{_(!1)}}),ye=Xf({shellId:y.current,userDisconnectedShellId:S.current});return ye.shouldClearUserDisconnectedShellId&&(S.current=null),j.current=ye.intentionalDisconnect,G(ye.connectionError),_(ye.isConnecting),Le(ke=>ke+1),ae},sendInput(B){return te(B)},sendCommand(B){const ae={command:B,beforeSnapshot:L.current};if(C.current=ae,B.trim()==="clear"){const we=ve();return!we&&C.current===ae&&(C.current=null),we}const ye=B.endsWith(`
3613
+ `)?B:`${B}
3614
+ `,ke=te(ye);return!ke&&C.current===ae&&(C.current=null),ke},sendControl(B){return B==="clear"?ve():te(Mf(B))},async copyLastCommandOutput(){const B=H.current.trim()||vs(F);if(!B)return m==null||m("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(B),m==null||m("done","Copied"),!0}catch{return m==null||m("failed","Copy failed"),!1}},focus(){var B;(B=g.current)==null||B.focus()},refreshLayout(B){Ie(B)}}),[m,u,Ie,ve,te,ze,R,F,K,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:I,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var B;h(),(B=g.current)==null||B.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"})]})}),Tg=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 p=c.useRef(null),m=c.useRef(null),f=c.useRef(null),g=c.useRef(null),x=c.useRef(null),k=c.useRef(!1),[b,y]=c.useState(null),[w,v]=c.useState(!0),[N,j]=c.useState(!1),[S,L]=c.useState(null),[C,H]=c.useState("primary"),[O,M]=c.useState(null),[Q,V]=c.useState(null),[W,Z]=c.useState("single"),[de,T]=c.useState(50),[J,A]=c.useState(null),[Y,F]=c.useState(""),[I,K]=c.useState(!1),[D,P]=c.useState(!1),[z,X]=c.useState(!1),[_,q]=c.useState({primary:ks,secondary:ks}),[G,ce]=c.useState(null),ee=(b==null?void 0:b.state)??"not_created",ie=c.useMemo(()=>(b==null?void 0:b.shells)??[],[b==null?void 0:b.shells]),ue=c.useMemo(()=>ie.filter(ut),[ie]),ge=c.useMemo(()=>ue.find(E=>E.id===O)??null,[ue,O]),Le=c.useMemo(()=>ue.find(E=>E.id===Q)??null,[ue,Q]),re=C==="secondary"?Le:ge,be=_[C],je=(b==null?void 0:b.workspacePathStatus)==="missing",xe=C==="secondary"?m:p,ze=ig({activeRuntime:be,activeShell:re,busy:N,loading:w,status:ee,workspacePathMissing:je}),R=ze.disabled,te=ze.label,ve=ze.className,fe=(G==null?void 0:G.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(G==null?void 0:G.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",pe=c.useCallback((E,U)=>{ce({tone:E,text:U}),f.current!==null&&window.clearTimeout(f.current),f.current=window.setTimeout(()=>{ce(null),f.current=null},1800)},[]),Ie=c.useCallback((E,U,he)=>{y(Ee=>{var rt;if(!Ee)return Ee;const Fe=Ee.shells.map(He=>He.id===E?U(He):He),Xe=((rt=Ee.shell)==null?void 0:rt.id)===E?U(Ee.shell):Fe.find(He=>{var We;return He.id===((We=Ee.shell)==null?void 0:We.id)})??Ee.shell;return{...Ee,...he?{state:he}:{},shell:Xe,shells:Fe}})},[]),B=c.useCallback(async()=>{v(!0);try{const E=await n.fetchState(r);y(E),L(null)}catch(E){L(E instanceof Error?E.message:"Unable to load shell state.")}finally{v(!1)}},[n,r]);c.useEffect(()=>{B()},[B]),c.useEffect(()=>{const E=i==null?void 0:i(r);if(E==null){T(50);return}const U=typeof E=="number"?E:Number.parseFloat(String(E));T(Number.isFinite(U)?gn(U):50)},[i,r]),c.useEffect(()=>{if(!b){M(null),V(null);return}const E=lg(b);M(U=>U&&b.shells.some(he=>he.id===U&&ut(he))?U:(E==null?void 0:E.id)??null),V(U=>{if(W!=="columns")return null;if(U&&b.shells.some(Ee=>Ee.id===U&&ut(Ee)))return U;const he=b.shells.find(Ee=>ut(Ee)&&Ee.id!==(E==null?void 0:E.id));return(he==null?void 0:he.id)??null})},[b,W]),c.useEffect(()=>{W!=="columns"&&(H("primary"),V(null))},[W]),c.useEffect(()=>{if(W!=="columns"||Q||ue.length<2)return;const E=ue.find(U=>U.id!==(ge==null?void 0:ge.id))??null;E&&V(E.id)},[ue,ge==null?void 0:ge.id,Q,W]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const E=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),U=()=>{K(E.matches),E.matches||(X(!1),P(!1))};return U(),E.addEventListener("change",U),()=>{E.removeEventListener("change",U)}},[]),c.useEffect(()=>()=>{f.current!==null&&window.clearTimeout(f.current),x.current!==null&&window.cancelAnimationFrame(x.current)},[]);const ae=c.useCallback((E,U)=>{q(he=>{const Ee=he[E];return og(Ee,U)?he:{...he,[E]:U}})},[]),ye=c.useCallback(E=>ae("primary",E),[ae]),ke=c.useCallback(E=>ae("secondary",E),[ae]),we=c.useCallback(E=>{var he;if((he=E.label)!=null&&he.trim())return E.label.trim();const U=ie.findIndex(Ee=>Ee.id===E.id);return`Shell ${U>=0?U+1:""}`.trim()},[ie]),Te=c.useCallback(E=>{var U;A(E.id),F(((U=E.label)==null?void 0:U.trim())||we(E))},[we]),De=c.useCallback(()=>{A(null),F("")},[]),et=c.useCallback(async()=>{if(J){j(!0);try{const E=Y.trim(),U=await n.updateShell(J,{label:E.length>0?E:null});y(he=>{var Ee;return he&&{...he,state:he.activeShellId===U.id?U.status:he.state,shell:((Ee=he.shell)==null?void 0:Ee.id)===U.id?U:he.shell,shells:he.shells.map(Fe=>Fe.id===U.id?U:Fe)}}),A(null),F(""),L(null)}catch(E){L(E instanceof Error?E.message:"Unable to rename shell.")}finally{j(!1)}}},[Y,J,n]),Ze=c.useCallback((E,U)=>{if(E==="primary"){M(U),V(he=>he===U?null:he);return}V(U),M(he=>he===U?null:he)},[]),it=c.useCallback(E=>{var U,he;if(E==="primary"){(U=p.current)==null||U.disconnect(),M(null),W==="columns"&&H("secondary");return}(he=m.current)==null||he.disconnect(),V(null),H("primary"),Z("single")},[W]),Ke=c.useCallback((E,U=C)=>{const he=W==="columns"?U:"primary";Ze(he,E.id),W!=="columns"&&V(null),H(he)},[C,Ze,W]),_e=c.useCallback(async(E=C)=>{var U;if(!k.current){k.current=!0,j(!0);try{const he=await n.createShell(r);y(he);const Ee=he.activeShellId??((U=he.shell)==null?void 0:U.id)??null;if(Ee){const Fe=W==="columns"?E:"primary";Ze(Fe,Ee),W!=="columns"&&V(null),H(Fe)}L(null)}catch(he){L(he instanceof Error?he.message:"Unable to create shell.")}finally{k.current=!1,j(!1)}}},[C,Ze,n,W,r]);c.useEffect(()=>{!a||!b||w||N||je||ee==="creating"||ue.length>0||_e("primary")},[N,_e,a,ue.length,w,b,ee,je]);const Ae=c.useCallback(async(E=(re==null?void 0:re.id)??"")=>{if(E){j(!0);try{await n.terminateShell(E),M(U=>U===E?null:U),V(U=>U===E?null:U),await B(),L(null)}catch(U){L(U instanceof Error?U.message:"Unable to terminate shell.")}finally{j(!1)}}},[re==null?void 0:re.id,B,n]),$e=c.useCallback(async()=>{var E,U;if(!R){if(be.shellInputEnabled){(E=xe.current)==null||E.disconnect();return}if(!re||re.status==="exited"||re.status==="not_found"){await _e(C);return}await((U=xe.current)==null?void 0:U.reconnect())}},[C,xe,be.shellInputEnabled,re,R,_e]),tt=c.useCallback(E=>{typeof window>"u"||d==null||d(r,gn(E))},[d,r]),st=c.useCallback(()=>{var E,U;(E=p.current)==null||E.refreshLayout({syncBackendSize:!0}),(U=m.current)==null||U.refreshLayout({syncBackendSize:!0})},[]),Je=c.useCallback(E=>{var Xe,rt;if(W!=="columns")return;const U=g.current;if(!U)return;E.preventDefault(),(rt=(Xe=E.currentTarget).setPointerCapture)==null||rt.call(Xe,E.pointerId);const he=He=>{const We=U.getBoundingClientRect();if(We.width<=0)return;const me=gn((He-We.left)/We.width*100);T(me),x.current!==null&&window.cancelAnimationFrame(x.current),x.current=window.requestAnimationFrame(()=>{x.current=null,st()})},Ee=He=>{he(He.clientX)},Fe=He=>{he(He.clientX);const We=U.getBoundingClientRect();We.width>0&&tt((He.clientX-We.left)/We.width*100),window.removeEventListener("pointermove",Ee),window.removeEventListener("pointerup",Fe)};window.addEventListener("pointermove",Ee),window.addEventListener("pointerup",Fe,{once:!0})},[tt,st,W]),ot=c.useCallback((E,U)=>{Ze(U,E.id),H(U)},[Ze]),oe=c.useCallback(async()=>{var U;return await((U=xe.current)==null?void 0:U.copyLastCommandOutput())?!0:(pe("failed","Nothing to copy"),!1)},[xe,pe]);c.useEffect(()=>{h==null||h(dg({activeRuntime:be,activeShell:re,connectionButtonDisabled:R,connectionButtonLabel:te,isMobileShell:I,busy:N,loading:w,error:S}))},[be,re,N,R,te,S,I,w,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await $e()},sendInput(E){var U;return((U=xe.current)==null?void 0:U.sendInput(E))??!1},sendCommand(E){var U;return((U=xe.current)==null?void 0:U.sendCommand(E))??!1},sendControl(E){var U;return((U=xe.current)==null?void 0:U.sendControl(E))??!1},async copyLastCommandOutput(){var E;return await((E=xe.current)==null?void 0:E.copyLastCommandOutput())??!1},async terminate(){await Ae()},focus(){var E;(E=xe.current)==null||E.focus()},refreshLayout(E){var U,he;(U=p.current)==null||U.refreshLayout(E),W==="columns"&&((he=m.current)==null||he.refreshLayout(E))}}),[xe,$e,Ae,W]);const Ge=E=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${E.id===(re==null?void 0:re.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:[J===E.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:U=>{U.preventDefault(),et()},children:t.jsx("input",{value:Y,onChange:U=>F(U.currentTarget.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),De())},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:()=>Ke(E),onDoubleClick:()=>Te(E),className:"min-w-0 flex-1 text-left",title:E.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:we(E)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[fn(E.status)," · ",qr(E.cwd)||E.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[J===E.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void et(),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:De,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:()=>Te(E),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"}),W==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>ot(E,"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(E,"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:N,onClick:()=>void Ae(E.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"})]})]})},E.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:be.promptLabel??(re==null?void 0:re.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":te,title:`${te} (${fn(be.status)})`,disabled:R,onClick:()=>void $e(),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 ${ve}`,children:t.jsx($f,{connected:be.shellInputEnabled})}),re&&t.jsx("button",{type:"button",disabled:N,onClick:()=>void Ae(re.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"})]})]}),(S||w||je)&&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&&je&&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&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]})]}),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:re?we(re):"No live shell process"}),re&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:fn(be.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 ",ue.length]}),t.jsx("button",{type:"button","aria-expanded":D,"aria-label":D?"Hide shell processes":"Show shell processes",onClick:()=>P(E=>!E),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"})]})]}),D&&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:[ue.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[ue.map(Ge),ue.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:N||w||je,onClick:()=>void _e(C),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"||je?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."}),!je&&t.jsx("button",{type:"button",disabled:N||w,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&&(S||w||je)&&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&&je&&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&&S&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:S})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${W==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:W==="columns"?{"--shell-left":`${de}fr`,"--shell-right":`${100-de}fr`}:void 0,"data-shell-split-ratio":de,children:[t.jsx(ws,{ref:p,paneId:"primary",shell:ge,isActive:C==="primary",isVisible:a,isMobileShell:I,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>H("primary"),onShellUpdate:Ie,onRuntimeStateChange:ye,onFeedback:pe}),W==="columns"&&t.jsx("button",{type:"button",onClick:()=>it("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"}),W==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:Je,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"}),W==="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(ws,{ref:m,paneId:"secondary",shell:Le,isActive:C==="secondary",isVisible:a,isMobileShell:I,effectiveTheme:l,workspacePathMissing:je,shellAdapter:n,onActivate:()=>H("secondary"),onShellUpdate:Ie,onRuntimeStateChange:ke,onFeedback:pe}),t.jsx("button",{type:"button",onClick:()=>it("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&&I&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[G&&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:G.text}),z&&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:()=>{pe("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(bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void oe(),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(bs,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!be.shellInputEnabled,onClick:()=>{var E;(E=xe.current)!=null&&E.sendControl("clear")?pe("done","Cleared"):pe("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(xn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!be.shellInputEnabled||!be.isCommandRunning,onClick:()=>{var E;(E=xe.current)!=null&&E.sendInput("")?pe("done","Sent Ctrl-C"):pe("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(xn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(E=>t.jsx("button",{type:"button",disabled:!be.shellInputEnabled,onClick:()=>{var U;(U=xe.current)!=null&&U.sendControl(E)?pe("done",`Sent ${E.toUpperCase().replace("_","-")}`):pe("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(xn,{label:E.toUpperCase().replace("_","-"),tone:"stone"})},E))]})}),t.jsx("button",{type:"button","aria-expanded":z,"aria-label":z?"Close shell tools":"Open shell tools",onClick:()=>X(E=>!E),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(_f,{})})]})]}),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:[ue.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[ue.map(Ge),ue.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:N||w||je,onClick:()=>void _e(C),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:"+"})})]})]})]})})]})}),Eg=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(Wh(),Fo))).ThreadGraphWorkspacePanel}));function Lg(){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 hl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Lg,{}),children:t.jsx(Eg,{...e})})}c.memo(hl);function Wg({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?Mr.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 Pg(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 Ig(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function Vg({open:e,busy:r=!1,turnsState:n,onCancel:a,onLoadTurns:o,onExport:s}){var j,S,L;const l=c.useMemo(()=>{var C;return((C=n.data)==null?void 0:C.turns)??[]},[(j=n.data)==null?void 0:j.turns]),i=c.useMemo(()=>l.slice(0,10).map(C=>C.turnId),[l]),[d,h]=c.useState("latest"),[u,p]=c.useState(()=>new Set),[m,f]=c.useState(!0),[g,x]=c.useState("pdf"),[k,b]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(h("latest"),x("pdf"),f(!0),o())},[o,e]),c.useEffect(()=>{e&&l.length>0&&p(new Set(i))},[i,e,l.length]),c.useEffect(()=>{if(!e)return;function C(H){H.key==="Escape"&&!r&&a()}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[r,a,e]),c.useEffect(()=>{if(!e)return;const C=document.querySelector(".thread-ui-shell"),H=()=>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(b(H()),!C)return;const O=new MutationObserver(()=>b(H()));return O.observe(C,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>O.disconnect()},[e]),!e)return null;const y=d==="latest"?Math.min(10,((S=n.data)==null?void 0:S.totalTurnCount)??10):u.size,w=!r&&(d==="latest"||u.size>0);function v(C){p(H=>{const O=new Set(H);return O.has(C)?O.delete(C):O.add(C),O})}function N(){const C={format:g,mode:d,...d==="latest"?{limit:10}:{turnIds:[...u]},profile:"review",options:{includeTokenAndPrice:m}};s(C)}return Mr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${k} fixed inset-0 z-[96] flex items-center justify-center p-3 sm:p-6`,"data-theme-effective":k,children:[t.jsx("button",{type:"button","aria-label":"Close export dialog",onClick:a,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":"Export transcript",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(46rem,calc(100vh-2rem))] w-full max-w-2xl flex-col rounded-[1.6rem] border shadow-2xl",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:"Export transcript"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Default review copy summarizes command batches and file changes."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:a,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:[["latest","Latest 10"],["selected","Custom selection"]].map(([C,H])=>t.jsx("button",{type:"button",onClick:()=>h(C),className:`rounded-full px-3 py-1.5 text-sm transition ${d===C?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:H},C))}),t.jsx("div",{className:"thread-export-dialog-segment mt-4 inline-flex rounded-full border p-1",children:[["pdf","PDF"],["html","HTML"]].map(([C,H])=>t.jsx("button",{type:"button",onClick:()=>x(C),className:`rounded-full px-3 py-1.5 text-sm transition ${g===C?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:H},C))}),d==="selected"?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 ",u.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??l.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>p(new Set(l.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:()=>p(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:l.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:u.has(C.turnId),onChange:()=>v(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:Pg(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:Ig(C.status)})]},C.turnId))})]}):t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-body-text mt-4 rounded-2xl border px-3 py-3 text-sm",children:"Exports the latest 10 turns in chronological order."}),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:m,onChange:C=>f(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.jsxs("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:[y," ",y===1?"turn":"turns"," will be exported."]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:a,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"}),t.jsx("button",{type:"button",onClick:N,disabled:!w,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 vn(e){if(e===void 0)return"-";if(Math.abs(e)>1e4){const r=Math.abs(e)>=1e5?0:1;return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:r})}k`}return e.toLocaleString()}function zg(e){return`in ${vn(e.input)} / out ${vn(e.output)} / cache ${vn(e.cache)}`}function Rg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=ll,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:p=0,composerHostRef:m}){const[f,g]=c.useState(!1),[x,k]=c.useState(0),[b,y]=c.useState(0),[w,v]=c.useState(0),[N,j]=c.useState(!1),S=c.useRef(null),L=i==null?void 0:i.onTailVisibilityChange,C=e.pendingRequests.length>0,H=c.useCallback(T=>{L==null||L(T)},[L]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const T=window.matchMedia("(max-width: 639px)"),J=()=>g(T.matches);return J(),T.addEventListener("change",J),()=>{T.removeEventListener("change",J)}},[]),c.useEffect(()=>{var J,A;if(typeof window>"u")return;const T=()=>{const Y=window.visualViewport,F=Y?Math.max(0,Math.round(window.innerHeight-Y.height-Y.offsetTop)):0,I=Y?Math.max(0,Math.round(window.innerHeight-Y.height)):F,K=Math.min(F,I),D=Math.max(0,Math.round(window.innerHeight*.52));v(Math.min(K,D))};return T(),(J=window.visualViewport)==null||J.addEventListener("resize",T),(A=window.visualViewport)==null||A.addEventListener("scroll",T),window.addEventListener("resize",T),()=>{var Y,F;(Y=window.visualViewport)==null||Y.removeEventListener("resize",T),(F=window.visualViewport)==null||F.removeEventListener("scroll",T),window.removeEventListener("resize",T)}},[]),c.useLayoutEffect(()=>{const T=S.current;if(!T||!f){k(0);return}const J=()=>{k(Math.ceil(T.getBoundingClientRect().height))};if(J(),typeof ResizeObserver>"u")return;const A=new ResizeObserver(J);return A.observe(T),()=>{A.disconnect()}},[f,l,C]),c.useLayoutEffect(()=>{var Y,F;const T=S.current;if(!T||!f){y(0);return}const J=()=>{const I=T.getBoundingClientRect();y(Math.max(0,Math.ceil(window.innerHeight-I.top)))};J(),window.addEventListener("resize",J),(Y=window.visualViewport)==null||Y.addEventListener("resize",J),(F=window.visualViewport)==null||F.addEventListener("scroll",J);let A=null;return typeof ResizeObserver<"u"&&(A=new ResizeObserver(J),A.observe(T)),()=>{var I,K;window.removeEventListener("resize",J),(I=window.visualViewport)==null||I.removeEventListener("resize",J),(K=window.visualViewport)==null||K.removeEventListener("scroll",J),A==null||A.disconnect()}},[f,w,N,l,C]),c.useEffect(()=>{if(!f){j(!1);return}const T=A=>{var F;const Y=A.target;Y instanceof HTMLElement&&((F=S.current)!=null&&F.contains(Y))&&j(!0)},J=A=>{var F;const Y=A.relatedTarget;Y instanceof HTMLElement&&((F=S.current)!=null&&F.contains(Y))||j(!1)};return document.addEventListener("focusin",T),document.addEventListener("focusout",J),()=>{document.removeEventListener("focusin",T),document.removeEventListener("focusout",J)}},[f]);const O=c.useCallback(T=>{S.current=T,m&&(m.current=T)},[m]),M=f&&N?Math.max(0,w-p):0,Q=Math.max(x,144),V=Math.max(b,Q+M),W=f?V+12:0,Z=W>0?{"--thread-graph-chat-scroll-bottom-spacer":`${W}px`}:void 0,de=u&&f?{bottom:`${p+M}px`,paddingBottom:"env(safe-area-inset-bottom)"}:void 0;return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:Z,children:[s,t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:e.thread.status==="running"||e.thread.activeTurnId!==null,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:H}),t.jsxs("div",{className:"thread-chat-usage-footer hidden shrink-0 items-center justify-between gap-3 px-4 py-1 text-[10px] leading-4 sm:flex",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[e.turns.length," turn",e.turns.length!==1?"s":"",t.jsx("span",{className:"mx-1 text-[var(--theme-border-contrast)]",children:"|"}),h," item",h!==1?"s":""]}),t.jsxs("span",{className:"shrink-0",children:["Usage"," ",d&&d.turns>0?zg(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:O,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:de??{bottom:`${p}px`,paddingBottom:"env(safe-area-inset-bottom)"},children:t.jsx(Pn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:O,className:"thread-graph-composer-host shrink-0",children:t.jsx(Pn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function Ag(e){return e.turns.reduce((r,n)=>{var o;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,turns:r.turns+1}:r},{input:0,output:0,cache:0,turns:0})}function kn(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 Mg(e){return!e||e.turns<=0?"waiting for agent usage":`in ${kn(e.input)} / out ${kn(e.output)} / cache ${kn(e.cache)}`}function qg({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,mobileHeaderAction:u,appMenuButton:p,appNavigationMenu:m,workspaceReturnHref:f,onWorkspaceReturn:g,surfaceActions:x,floatingPanel:k,workspaceContent:b,workspaceTitle:y,workspaceActions:w,workspaceFeatures:v,onNewThreadTitle:N,beforeTimelineContent:j,errorContent:S,workspaceMissingContent:L,dialogs:C,currentThreadId:H,currentWorkspaceId:O,currentWorkspaceLabel:M,onCloseAppNavigation:Q,className:V="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:W="chat",liveOutput:Z="",timelineProps:de,composerProps:T,shellComposerProps:J,useFloatingMobileComposer:A=!1,floatingMobileComposerBottomOffset:Y=0,composerHostRef:F,shellPanelRef:I,shellEffectiveTheme:K="dark",shellThemeMode:D=K,onShellThemeModeChange:P,onShellStateChange:z,shellUnavailableContent:X,shellDisconnectedContent:_,timelineComponent:q=ll,shellPanelComponent:G=Tg,shellContent:ce,loadingContent:ee,emptyContent:ie}){const ue=Xn(),ge=s??ue??qn(),{getImageAssetUrl:Le,loadHistoryItemDetail:re,openThread:be}=l,je=c.useMemo(()=>({...Le?{getImageAssetUrl:Ie=>Le(Ie.path)}:{},onOpenLinkedThread:be,...re?{onLoadHistoryItemDetail:re}:{}}),[Le,re,be]),xe=ge.getThreadPanels().some(Ie=>Ie.kind==="terminal"),ze=c.useMemo(()=>r?Ag(r):null,[r]),R=c.useMemo(()=>Mg(ze),[ze]),te=c.useMemo(()=>{var Ie;return r?r.turns.reduce((B,ae)=>B+ae.items.length,((Ie=r.liveItems)==null?void 0:Ie.items.length)??0):0},[r]),ve=b??(r?t.jsx(hl,{detail:r,status:o,plugins:ge,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:W,features:v}):null),fe=n?ee??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:V,children:[k?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:k}):null,a&&!n&&(S??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"&&(L??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:W==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Rg,{detail:r,adapter:l,timelineAdapter:je,TimelineComponent:q,liveOutput:Z,threadUsageSummary:ze,transcriptItemCount:te,useFloatingMobileComposer:A,floatingMobileComposerBottomOffset:Y,...j?{beforeTimelineContent:j}:{},...T?{composerProps:T}:{},...de?{timelineProps:de}:{},...F?{composerHostRef:F}:{}})}),t.jsxs("div",{className:W==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ce??(r.thread.isLoaded&&xe&&l.shell?t.jsx(G,{ref:I,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:K,isVisible:W==="shell",showHeader:!1,showFloatingToolbox:!1,...z?{onStateChange:z}:{}}):r.thread.isLoaded&&!xe?X??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."})]})}):_??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."})]})})),W==="shell"&&J&&!ce?t.jsx(Pn,{...J,activeView:"shell",onSubmit:l.sendPrompt}):null]}),C]}):ie??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."}),pe=t.jsx(Bm,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:H??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:O??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:M??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:R,topbarActions:x,metaContent:i,settingsContent:d,globalSettingsContent:h,mobileHeaderAction:u,effectiveTheme:K,themeMode:D,appMenuButton:p,appNavigationMenu:m,workspaceReturnHref:f,...g?{onWorkspaceReturn:g}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:ve,workspaceTitle:y??"Workspace",workspaceActions:w,...N?{onNewThreadTitle:N}:{},...Q?{onCloseAppNavigation:Q}:{},...P?{onThemeModeChange:P}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:fe});return s?t.jsx(Kn.Provider,{value:ge,children:pe}):pe}var _g={},$g=[];function Kg({adapter:e=_g,builtinPlugins:r=$g,children:n}){const[a,o]=c.useState(()=>In(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(In(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,v)=>{if(e.updatePlugin){const N=await e.updatePlugin(w,{enabled:v});o(j=>j.map(S=>S.id===N.id?N:S));return}o(N=>N.map(j=>j.id===w?{...j,enabled:v}:j))},[e]),p=c.useCallback(async w=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const v=await e.importPlugin(w);o(N=>[...N.filter(S=>S.id!==v.id),v])},[e]),m=c.useCallback(async w=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const v=await e.deletePlugin(w);o(N=>N.filter(j=>j.id!==v.id))},[e]),f=c.useMemo(()=>{const w=new Set(a.filter(v=>v.enabled).map(v=>v.id));return r.filter(v=>w.has(v.manifest.id))},[r,a]),g=c.useCallback(w=>{var N;const v=f.find(j=>j.renderArtifact&&j.manifest.capabilities.artifactTypes.some(S=>S.type===w.artifact.type));return((N=v==null?void 0:v.renderArtifact)==null?void 0:N.call(v,w))??null},[f]),x=c.useCallback(w=>{for(const v of f)for(const N of v.inlineCodeRenderers??[]){if(!N.languages.includes(w.language.trim().toLowerCase()))continue;const j=N.render(w);if(j)return j}return null},[f]),k=c.useCallback(w=>f.some(v=>!!v.renderArtifact&&v.manifest.capabilities.artifactTypes.some(N=>N.type===w.type)),[f]),b=c.useCallback(()=>f.flatMap(w=>w.threadPanels??[]),[f]),y=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:p,setPluginEnabled:u,uninstallPlugin:m,renderArtifact:g,renderInlineCode:x,hasRendererForArtifact:k,getThreadPanels:b}),[i,b,k,p,s,a,h,g,x,u,m]);return t.jsx(Kn.Provider,{value:y,children:n})}function Dg(){return t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M2 3.25h12v1.5H2Zm0 4h12v1.5H2Zm0 4h12v1.5H2Z"})})}function Bg(){return 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"})})}function ys(e=!1){return`flex w-full items-center rounded-[0.95rem] px-3 py-2 text-left text-sm transition ${e?"cursor-not-allowed bg-[var(--theme-muted)] text-[var(--theme-fg-muted)]":"text-[var(--theme-fg)] hover:bg-[var(--theme-hover)]"}`}function Xg({className:e=""}){const r=Hr();return r?t.jsx("button",{type:"button","aria-label":r.navOpen?"Close Navigation":"Open Navigation","aria-expanded":r.navOpen,"aria-controls":"app-shell-navigation-menu",onClick:r.toggleNav,className:`inline-flex h-10 w-10 shrink-0 items-center justify-center text-[var(--theme-fg)] transition hover:text-[var(--theme-fg-soft)] ${e}`.trim(),children:r.navOpen?t.jsx(Bg,{}):t.jsx(Dg,{})}):null}function Yg({className:e="",currentPath:r="",items:n=[{label:"Workspaces",href:"/workspaces"}],onNavigate:a}){const o=Hr(),s=c.useRef(null);return c.useEffect(()=>{if(!(o!=null&&o.navOpen))return;const l=o;function i(d){const h=d.target;if(!h)return;const u=s.current;u!=null&&u.contains(h)||h instanceof Element&&h.closest('[aria-controls="app-shell-navigation-menu"]')||l.closeNav()}return document.addEventListener("pointerdown",i),()=>{document.removeEventListener("pointerdown",i)}},[o]),o!=null&&o.navOpen?t.jsxs("div",{ref:s,id:"app-shell-navigation-menu",onPointerDown:l=>l.stopPropagation(),onMouseDown:l=>l.stopPropagation(),onTouchStart:l=>l.stopPropagation(),className:`rounded-[1.8rem] border border-[var(--theme-border)] bg-[var(--theme-panel)] p-4 shadow-2xl shadow-black/15 backdrop-blur ${e}`.trim(),children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-base font-semibold tracking-wide text-[var(--theme-accent-strong)]",children:"Remote Codex"}),t.jsx("p",{className:"mt-1 text-xs uppercase tracking-[0.24em] text-[var(--theme-fg-muted)]",children:"Navigation"})]}),t.jsxs("nav",{className:"mt-4 flex flex-col gap-1.5 text-sm",children:[n.map(l=>{const i=r===l.href;return t.jsx("button",{type:"button",disabled:i,onClick:()=>{i||(o.closeNav(),a==null||a(l.href))},className:ys(i),children:l.label},l.href)}),t.jsx("button",{type:"button",onClick:o.openSettings,className:ys(),children:"Settings"})]})]}):null}export{Yg as A,Wg as C,Vg as E,Gm as L,Kg as P,qg as T,Xn as a,Xg as b,Tg as c,ll as d,Bm as e,qt as f,Dm as g,jm as h,Nm as t,Hr as u};