remote-codex 0.11.30 → 0.11.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/supervisor-api/dist/index.js +64 -10
- package/apps/supervisor-web/dist/apple-touch-icon.png +0 -0
- package/apps/supervisor-web/dist/assets/index-BkwJP0KB.js +6 -0
- package/apps/supervisor-web/dist/assets/{thread-ui-C0VPL4Uk.js → thread-ui-BOqbjoiB.js} +28 -28
- package/apps/supervisor-web/dist/favicon-16x16.png +0 -0
- package/apps/supervisor-web/dist/favicon-32x32.png +0 -0
- package/apps/supervisor-web/dist/favicon-48x48.png +0 -0
- package/apps/supervisor-web/dist/icon-192.png +0 -0
- package/apps/supervisor-web/dist/icon-512.png +0 -0
- package/apps/supervisor-web/dist/index.html +9 -3
- package/apps/supervisor-web/dist/remote-codex-icon.png +0 -0
- package/apps/supervisor-web/dist/site.webmanifest +19 -0
- package/config/codex-model-pricing.json +44 -0
- package/package.json +1 -1
- package/packages/agent-runtime/src/model-pricing.ts +66 -6
- package/packages/claude/src/runtimeAdapter.ts +4 -0
- package/packages/codex/src/modelPricing.test.ts +84 -0
- package/packages/codex/src/types.ts +3 -1
- package/packages/opencode/src/runtimeAdapter.ts +15 -0
- package/packages/shared/src/index.ts +4 -1
- package/apps/supervisor-web/dist/assets/index-BnpZn_3_.js +0 -6
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-DODVy7wn.js","assets/markdown-vendor-RZk8L7-L.js","assets/react-vendor-Dfg_6BLf.js","assets/html-pp8916En.js","assets/javascript-wDzz0qaB.js","assets/css-CLj8gQPS.js","assets/terminal-vendor-C5bTa-Ka.js","assets/terminal-vendor-Beg8tuEN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c as Vi,d as Ki,e as qi,D as Xi,P as Yi,O as Zi,f as Ji,g as Qi,h as ed,i as td,j as rd,k as nd,m as ad,n as sd,A as od,o as ld,p as id}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as dd,j as t,b as Ur}from"./react-vendor-Dfg_6BLf.js";import{u as cd,a as hd,H as va,P as $t,b as ud,M as _s,R as md,i as pd,C as fd,B as gd,c as ka,g as Ms}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as xd,r as bd,a as vd,b as kd}from"./markdown-vendor-RZk8L7-L.js";const wd="modulepreload",yd=function(e){return"/"+e},wa={},Ke=function(r,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=l(n.map(h=>{if(h=yd(h),h in wa)return;wa[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":wd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return o.then(l=>{for(const i of l||[])i.status==="rejected"&&s(i.reason);return r().catch(s)})};function $s(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=$s(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Ds(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=$s(e))&&(a&&(a+=" "),a+=r);return a}const jd=(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},Nd=(e,r)=>({classGroupId:e,validator:r}),Bs=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Br="-",ya=[],Cd="arbitrary..",Sd=e=>{const r=Ed(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Td(l);const i=l.split(Br),d=i[0]===""&&i.length>1?1:0;return Gs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?jd(h,d):d:h||ya}return n[l]||ya}}},Gs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Gs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Br):e.slice(r).join(Br),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Td=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?Cd+a:void 0})(),Ed=e=>{const{theme:r,classGroups:n}=e;return Ld(n,r)},Ld=(e,r)=>{const n=Bs();for(const a in e){const o=e[a];Kn(o,n,a,r)}return n},Kn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Pd(l,r,n,a)}},Pd=(e,r,n,a)=>{if(typeof e=="string"){zd(e,r,n);return}if(typeof e=="function"){Id(e,r,n,a);return}Rd(e,r,n,a)},zd=(e,r,n)=>{const a=e===""?r:Fs(r,e);a.classGroupId=n},Id=(e,r,n,a)=>{if(Ad(e)){Kn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Nd(n,e))},Rd=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Kn(d,Fs(r,i),n,a)}},Fs=(e,r)=>{let n=e;const a=r.split(Br),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Bs(),n.nextPart.set(l,i)),n=i}return n},Ad=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,_d=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)}}},Sn="!",ja=":",Md=[],Na=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),$d=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 v=0;v<u;v++){const b=o[v];if(l===0&&i===0){if(b===ja){s.push(o.slice(d,v)),d=v+1;continue}if(b==="/"){h=v;continue}}b==="["?l++:b==="]"?l--:b==="("?i++:b===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Sn)?(f=m.slice(0,-1),p=!0):m.startsWith(Sn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return Na(s,p,f,g)};if(r){const o=r+ja,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):Na(Md,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Dd=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}},Bd=e=>({cache:_d(e.cacheSize),parseClassName:$d(e),sortModifiers:Dd(e),postfixLookupClassGroupIds:Gd(e),...Sd(e)}),Gd=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},Fd=/\s+/,Hd=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Fd);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:b}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!b,j;if(x){const C=v.substring(0,b);j=a(C);const E=j&&l[j]?a(v):void 0;E&&E!==j&&(j=E,x=!1)}else j=a(v);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(v),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:s(p).join(":"),w=g?y+Sn:y,k=w+j;if(i.indexOf(k)>-1)continue;i.push(k);const N=o(j,x);for(let C=0;C<N.length;++C){const E=N[C];i.push(w+E)}h=m+(h.length>0?" "+h:h)}return h},Od=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Hs(n))&&(o&&(o+=" "),o+=a);return o},Hs=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Hs(e[a]))&&(n&&(n+=" "),n+=r);return n},Ud=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Bd(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=Hd(d,n);return o(d,u),u};return s=l,(...d)=>s(Od(...d))},Wd=[],Ze=e=>{const r=n=>n[e]||Wd;return r.isThemeGetter=!0,r},Os=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Us=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Vd=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Kd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,qd=/\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$/,Xd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Yd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Zd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ct=e=>Vd.test(e),Le=e=>!!e&&!Number.isNaN(Number(e)),pt=e=>!!e&&Number.isInteger(Number(e)),ln=e=>e.endsWith("%")&&Le(e.slice(0,-1)),vt=e=>Kd.test(e),Ws=()=>!0,Jd=e=>qd.test(e)&&!Xd.test(e),qn=()=>!1,Qd=e=>Yd.test(e),ec=e=>Zd.test(e),tc=e=>!ue(e)&&!me(e),rc=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)),nc=e=>Pt(e,qs,qn),ue=e=>Os.test(e),At=e=>Pt(e,Xs,Jd),Ca=e=>Pt(e,hc,Le),ac=e=>Pt(e,Zs,Ws),sc=e=>Pt(e,Ys,qn),Sa=e=>Pt(e,Vs,qn),oc=e=>Pt(e,Ks,ec),Sr=e=>Pt(e,Js,Qd),me=e=>Us.test(e),lr=e=>Ot(e,Xs),lc=e=>Ot(e,Ys),Ta=e=>Ot(e,Vs),ic=e=>Ot(e,qs),dc=e=>Ot(e,Ks),Tr=e=>Ot(e,Js,!0),cc=e=>Ot(e,Zs,!0),Pt=(e,r,n)=>{const a=Os.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Ot=(e,r,n=!1)=>{const a=Us.exec(e);return a?a[1]?r(a[1]):n:!1},Vs=e=>e==="position"||e==="percentage",Ks=e=>e==="image"||e==="url",qs=e=>e==="length"||e==="size"||e==="bg-size",Xs=e=>e==="length",hc=e=>e==="number",Ys=e=>e==="family-name",Zs=e=>e==="number"||e==="weight",Js=e=>e==="shadow",uc=()=>{const e=Ze("color"),r=Ze("font"),n=Ze("text"),a=Ze("font-weight"),o=Ze("tracking"),s=Ze("leading"),l=Ze("breakpoint"),i=Ze("container"),d=Ze("spacing"),h=Ze("radius"),u=Ze("shadow"),m=Ze("inset-shadow"),f=Ze("text-shadow"),p=Ze("drop-shadow"),g=Ze("blur"),v=Ze("perspective"),b=Ze("aspect"),x=Ze("ease"),j=Ze("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...w(),me,ue],N=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],E=()=>[me,ue,d],I=()=>[Ct,"full","auto",...E()],q=()=>[pt,"none","subgrid",me,ue],D=()=>["auto",{span:["full",pt,me,ue]},pt,me,ue],$=()=>[pt,"auto",me,ue],Q=()=>["auto","min","max","fr",me,ue],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],ee=()=>["auto",...E()],oe=()=>[Ct,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],A=()=>[Ct,"screen","full","dvw","lvw","svw","min","max","fit",...E()],J=()=>[Ct,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],R=()=>[e,me,ue],Y=()=>[...w(),Ta,Sa,{position:[me,ue]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",ic,nc,{size:[me,ue]}],O=()=>[ln,lr,At],G=()=>["","none","full",h,me,ue],L=()=>["",Le,lr,At],S=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[Le,ln,Ta,Sa],le=()=>["","none",g,me,ue],X=()=>["none",Le,me,ue],ce=()=>["none",Le,me,ue],re=()=>[Le,me,ue],fe=()=>[Ct,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vt],breakpoint:[vt],color:[Ws],container:[vt],"drop-shadow":[vt],ease:["in","out","in-out"],font:[tc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vt],shadow:[vt],spacing:["px",Le],text:[vt],"text-shadow":[vt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ct,ue,me,b]}],container:["container"],"container-type":[{"@container":["","normal","size",me,ue]}],"container-named":[rc],columns:[{columns:[Le,ue,me,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:I()}],"inset-x":[{"inset-x":I()}],"inset-y":[{"inset-y":I()}],start:[{"inset-s":I(),start:I()}],end:[{"inset-e":I(),end:I()}],"inset-bs":[{"inset-bs":I()}],"inset-be":[{"inset-be":I()}],top:[{top:I()}],right:[{right:I()}],bottom:[{bottom:I()}],left:[{left:I()}],visibility:["visible","invisible","collapse"],z:[{z:[pt,"auto",me,ue]}],basis:[{basis:[Ct,"full","auto",i,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Le,Ct,"auto","initial","none",ue]}],grow:[{grow:["",Le,me,ue]}],shrink:[{shrink:["",Le,me,ue]}],order:[{order:[pt,"first","last","none",me,ue]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mbs:[{mbs:ee()}],mbe:[{mbe:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:oe()}],"inline-size":[{inline:["auto",...A()]}],"min-inline-size":[{"min-inline":["auto",...A()]}],"max-inline-size":[{"max-inline":["none",...A()]}],"block-size":[{block:["auto",...J()]}],"min-block-size":[{"min-block":["auto",...J()]}],"max-block-size":[{"max-block":["none",...J()]}],w:[{w:[i,"screen",...oe()]}],"min-w":[{"min-w":[i,"screen","none",...oe()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...oe()]}],h:[{h:["screen","lh",...oe()]}],"min-h":[{"min-h":["screen","lh","none",...oe()]}],"max-h":[{"max-h":["screen","lh",...oe()]}],"font-size":[{text:["base",n,lr,At]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,cc,ac]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ln,ue]}],"font-family":[{font:[lc,sc,r]}],"font-features":[{"font-features":[ue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,me,ue]}],"line-clamp":[{"line-clamp":[Le,"none",me,Ca]}],leading:[{leading:[s,...E()]}],"list-image":[{"list-image":["none",me,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:R()}],"text-color":[{text:R()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...S(),"wavy"]}],"text-decoration-thickness":[{decoration:[Le,"from-font","auto",me,At]}],"text-decoration-color":[{decoration:R()}],"underline-offset":[{"underline-offset":[Le,"auto",me,ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"tab-size":[{tab:[pt,me,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",me,ue]}],"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:H()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},pt,me,ue],radial:["",me,ue],conic:[pt,me,ue]},dc,oc]}],"bg-color":[{bg:R()}],"gradient-from-pos":[{from:O()}],"gradient-via-pos":[{via:O()}],"gradient-to-pos":[{to:O()}],"gradient-from":[{from:R()}],"gradient-via":[{via:R()}],"gradient-to":[{to:R()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":L()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...S(),"hidden","none"]}],"divide-style":[{divide:[...S(),"hidden","none"]}],"border-color":[{border:R()}],"border-color-x":[{"border-x":R()}],"border-color-y":[{"border-y":R()}],"border-color-s":[{"border-s":R()}],"border-color-e":[{"border-e":R()}],"border-color-bs":[{"border-bs":R()}],"border-color-be":[{"border-be":R()}],"border-color-t":[{"border-t":R()}],"border-color-r":[{"border-r":R()}],"border-color-b":[{"border-b":R()}],"border-color-l":[{"border-l":R()}],"divide-color":[{divide:R()}],"outline-style":[{outline:[...S(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Le,me,ue]}],"outline-w":[{outline:["",Le,lr,At]}],"outline-color":[{outline:R()}],shadow:[{shadow:["","none",u,Tr,Sr]}],"shadow-color":[{shadow:R()}],"inset-shadow":[{"inset-shadow":["none",m,Tr,Sr]}],"inset-shadow-color":[{"inset-shadow":R()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:R()}],"ring-offset-w":[{"ring-offset":[Le,At]}],"ring-offset-color":[{"ring-offset":R()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":R()}],"text-shadow":[{"text-shadow":["none",f,Tr,Sr]}],"text-shadow-color":[{"text-shadow":R()}],opacity:[{opacity:[Le,me,ue]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"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":[Le]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":R()}],"mask-image-linear-to-color":[{"mask-linear-to":R()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":R()}],"mask-image-t-to-color":[{"mask-t-to":R()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":R()}],"mask-image-r-to-color":[{"mask-r-to":R()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":R()}],"mask-image-b-to-color":[{"mask-b-to":R()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":R()}],"mask-image-l-to-color":[{"mask-l-to":R()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":R()}],"mask-image-x-to-color":[{"mask-x-to":R()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":R()}],"mask-image-y-to-color":[{"mask-y-to":R()}],"mask-image-radial":[{"mask-radial":[me,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":R()}],"mask-image-radial-to-color":[{"mask-radial-to":R()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[Le]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":R()}],"mask-image-conic-to-color":[{"mask-conic-to":R()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,ue]}],filter:[{filter:["","none",me,ue]}],blur:[{blur:le()}],brightness:[{brightness:[Le,me,ue]}],contrast:[{contrast:[Le,me,ue]}],"drop-shadow":[{"drop-shadow":["","none",p,Tr,Sr]}],"drop-shadow-color":[{"drop-shadow":R()}],grayscale:[{grayscale:["",Le,me,ue]}],"hue-rotate":[{"hue-rotate":[Le,me,ue]}],invert:[{invert:["",Le,me,ue]}],saturate:[{saturate:[Le,me,ue]}],sepia:[{sepia:["",Le,me,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",me,ue]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Le,me,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Le,me,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Le,me,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Le,me,ue]}],"backdrop-invert":[{"backdrop-invert":["",Le,me,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Le,me,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Le,me,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Le,me,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Le,"initial",me,ue]}],ease:[{ease:["linear","initial",x,me,ue]}],delay:[{delay:[Le,me,ue]}],animate:[{animate:["none",j,me,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,me,ue]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[me,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:fe()}],"translate-x":[{"translate-x":fe()}],"translate-y":[{"translate-y":fe()}],"translate-z":[{"translate-z":fe()}],"translate-none":["translate-none"],zoom:[{zoom:[pt,me,ue]}],accent:[{accent:R()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:R()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",me,ue]}],"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":R()}],"scrollbar-track-color":[{"scrollbar-track":R()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",me,ue]}],fill:[{fill:["none",...R()]}],"stroke-w":[{stroke:[Le,lr,At,Ca]}],stroke:[{stroke:["none",...R()]}],"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"]}},mc=Ud(uc),Ea=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,La=Ds,kr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return La(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=r,l=Object.keys(o).map(h=>{const u=n==null?void 0:n[h],m=s==null?void 0:s[h];if(u===null)return null;const f=Ea(u)||Ea(m);return o[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[v,b]=g;return Array.isArray(b)?b.includes({...s,...i}[v]):{...s,...i}[v]===b})?[...h,m,f]:h},[]);return La(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Wr=c.createContext(null);Wr.displayName="PanelGroupContext";const Ve={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"},Xn=10,Gt=c.useLayoutEffect,Pa=dd.useId,pc=typeof Pa=="function"?Pa:()=>null;let fc=0;function Yn(e=null){const r=pc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+fc++),e??n.current}function Qs({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...v}){const b=c.useContext(Wr);if(b===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:w,groupId:k,isPanelCollapsed:N,reevaluatePanelConstraints:C,registerPanel:E,resizePanel:I,unregisterPanel:q}=b,D=Yn(l),$=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:D,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Gt(()=>{const{callbacks:Z,constraints:B}=$.current,ee={...B};$.current.id=D,$.current.idIsFromProps=l!==void 0,$.current.order=f,Z.onCollapse=h,Z.onExpand=u,Z.onResize=m,B.collapsedSize=n,B.collapsible=a,B.defaultSize=o,B.maxSize=i,B.minSize=d,(ee.collapsedSize!==B.collapsedSize||ee.collapsible!==B.collapsible||ee.maxSize!==B.maxSize||ee.minSize!==B.minSize)&&C($.current,ee)}),Gt(()=>{const Z=$.current;return E(Z),()=>{q(Z)}},[f,D,E,q]),c.useImperativeHandle(s,()=>({collapse:()=>{x($.current)},expand:Z=>{j($.current,Z)},getId(){return D},getSize(){return y($.current)},isCollapsed(){return N($.current)},isExpanded(){return!N($.current)},resize:Z=>{I($.current,Z)}}),[x,j,y,N,D,I]);const Q=w($.current,o);return c.createElement(g,{...v,children:e,className:r,id:D,style:{...Q,...p},[Ve.groupId]:k,[Ve.panel]:"",[Ve.panelCollapsible]:a||void 0,[Ve.panelId]:D,[Ve.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const eo=c.forwardRef((e,r)=>c.createElement(Qs,{...e,forwardedRef:r}));Qs.displayName="Panel";eo.displayName="forwardRef(Panel)";let Tn=null,Ar=-1,Tt=null;function gc(e,r,n){const a=(r&so)!==0,o=(r&oo)!==0,s=(r&lo)!==0,l=(r&io)!==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 xc(){Tt!==null&&(document.head.removeChild(Tt),Tn=null,Tt=null,Ar=-1)}function dn(e,r,n){var a,o;const s=gc(e,r);if(Tn!==s){if(Tn=s,Tt===null&&(Tt=document.createElement("style"),document.head.appendChild(Tt)),Ar>=0){var l;(l=Tt.sheet)===null||l===void 0||l.removeRule(Ar)}Ar=(a=(o=Tt.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function to(e){return e.type==="keydown"}function ro(e){return e.type.startsWith("pointer")}function no(e){return e.type.startsWith("mouse")}function Vr(e){if(ro(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(no(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function bc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function vc(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 kc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ra(e),b:Ra(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ee(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:Ia(za(n.a)),b:Ia(za(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 wc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function yc(e){var r;const n=getComputedStyle((r=ao(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function jc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||yc(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"||wc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function za(e){let r=e.length;for(;r--;){const n=e[r];if(Ee(n,"Missing node"),jc(n))return n}return null}function Ia(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ra(e){const r=[];for(;e;)r.push(e),e=ao(e);return r}function ao(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const so=1,oo=2,lo=4,io=8,Nc=bc()==="coarse";let mt=[],er=!1,Et=new Map,Kr=new Map;const xr=new Set;function Cc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Et.get(l))!==null&&s!==void 0?s:0;return Et.set(l,d+1),xr.add(i),Gr(),function(){var u;Kr.delete(e),xr.delete(i);const m=(u=Et.get(l))!==null&&u!==void 0?u:1;if(Et.set(l,m-1),Gr(),m===1&&Et.delete(l),mt.includes(i)){const f=mt.indexOf(i);f>=0&&mt.splice(f,1),qr(),o("up",!0,null)}}}function Sc(e){const{target:r}=e,{x:n,y:a}=Vr(e);er=!0,Zn({target:r,x:n,y:a}),Gr(),mt.length>0&&(Fr("down",e),qr(),e.preventDefault(),co(r)||e.stopImmediatePropagation())}function cn(e){const{x:r,y:n}=Vr(e);if(er&&e.type!=="pointerleave"&&e.buttons===0&&(er=!1,Fr("up",e)),!er){const{target:a}=e;Zn({target:a,x:r,y:n})}Fr("move",e),qr(),mt.length>0&&e.preventDefault()}function hn(e){const{target:r}=e,{x:n,y:a}=Vr(e);Kr.clear(),er=!1,mt.length>0&&(e.preventDefault(),co(r)||e.stopImmediatePropagation()),Fr("up",e),Zn({target:r,x:n,y:a}),qr(),Gr()}function co(e){let r=e;for(;r;){if(r.hasAttribute(Ve.resizeHandle))return!0;r=r.parentElement}return!1}function Zn({target:e,x:r,y:n}){mt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),xr.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Nc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&kc(a,s)>0){let g=a,v=!1;for(;g&&!g.contains(s);){if(vc(g.getBoundingClientRect(),i)){v=!0;break}g=g.parentElement}if(v)return}mt.push(o)}})}function un(e,r){Kr.set(e,r)}function qr(){let e=!1,r=!1;mt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Kr.forEach(a=>{n|=a}),e&&r?dn("intersection",n):e?dn("horizontal",n):r?dn("vertical",n):xc()}let mn;function Gr(){var e;(e=mn)===null||e===void 0||e.abort(),mn=new AbortController;const r={capture:!0,signal:mn.signal};xr.size&&(er?(mt.length>0&&Et.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",hn,r),o.addEventListener("pointerleave",cn,r),o.addEventListener("pointermove",cn,r))}),Et.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",hn,r),o.addEventListener("pointercancel",hn,r)})):Et.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",Sc,r),o.addEventListener("pointermove",cn,r))}))}function Fr(e,r){xr.forEach(n=>{const{setResizeHandlerState:a}=n,o=mt.includes(n);a(e,o,r)})}function Tc(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ee(e,r){if(!e)throw console.error(r),Error(r)}function Ht(e,r,n=Xn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function kt(e,r,n=Xn){return Ht(e,r,n)===0}function lt(e,r,n){return Ht(e,r,n)===0}function Ec(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(!lt(o,s,n))return!1}return!0}function Jt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ee(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ht(n,i)<0)if(s){const d=(o+i)/2;Ht(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(Xn)),n}function hr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(lt(e,0))return r;const l=[...r],[i,d]=a;Ee(i!=null,"Invalid first pivot index"),Ee(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Ee(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:v=0}=f;if(g){const b=r[m];if(Ee(b!=null,`Previous layout not found for panel index ${m}`),lt(b,p)){const x=v-b;Ht(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ee(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:v=0}=f;if(g){const b=r[m];if(Ee(b!=null,`Previous layout not found for panel index ${m}`),lt(b,v)){const x=b-p;Ht(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const v=r[f];Ee(v!=null,`Previous layout not found for panel index ${f}`);const x=Jt({panelConstraints:n,panelIndex:f,size:100})-v;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ee(g!=null,`Previous layout not found for panel index ${f}`);const v=g-p,b=Jt({panelConstraints:n,panelIndex:f,size:v});if(!lt(g,b)&&(h+=g-b,l[f]=b,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Ec(o,l))return o;{const m=e<0?d:i,f=r[m];Ee(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=Jt({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!lt(g,p)){let v=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ee(j!=null,`Previous layout not found for panel index ${x}`);const y=j+v,w=Jt({panelConstraints:n,panelIndex:x,size:y});if(lt(j,w)||(v-=w-j,l[x]=w),lt(v,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return lt(u,100)?l:o}function Lc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Ee(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:v=0}=p;f===i?(a=v,o=g):(s+=v,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 br(e,r=document){return Array.from(r.querySelectorAll(`[${Ve.resizeHandleId}][data-panel-group-id="${e}"]`))}function ho(e,r,n=document){const o=br(e,n).findIndex(s=>s.getAttribute(Ve.resizeHandleId)===r);return o??null}function uo(e,r,n){const a=ho(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Pc(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function mo(e,r=document){if(Pc(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Xr(e,r=document){const n=r.querySelector(`[${Ve.resizeHandleId}="${e}"]`);return n||null}function zc(e,r,n,a=document){var o,s,l,i;const d=Xr(r,a),h=br(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Ic({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Gt(()=>{if(!s)return;const i=br(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Lc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Ee(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,o,s]),c.useEffect(()=>{if(!s)return;const i=r.current;Ee(i,"Eager values not found");const{panelDataArray:d}=i,h=mo(n,s);Ee(h!=null,`No group found for id "${n}"`);const u=br(n,s);Ee(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(Ve.resizeHandleId);Ee(p,"Resize handle element has no handle id attribute");const[g,v]=zc(n,p,d,s);if(g==null||v==null)return()=>{};const b=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Ee(y,`No panel data found for index ${j}`);const w=a[j],{collapsedSize:k=0,collapsible:N,minSize:C=0}=y.constraints;if(w!=null&&N){const E=hr({delta:lt(w,k)?C-k:k-w,initialLayout:a,panelConstraints:d.map(I=>I.constraints),pivotIndices:uo(n,p,s),prevLayout:a,trigger:"keyboard"});a!==E&&l(E)}}break}}};return f.addEventListener("keydown",b),()=>{f.removeEventListener("keydown",b)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Aa(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 po(e,r){const n=e==="horizontal",{x:a,y:o}=Vr(r);return n?a:o}function Rc(e,r,n,a,o){const s=n==="horizontal",l=Xr(r,o);Ee(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Ve.groupId);Ee(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=po(n,e),u=mo(i,o);Ee(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function Ac(e,r,n,a,o,s){if(to(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:Rc(e,r,n,a,s)}function _c({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];Ee(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];Ee(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 Kt(e,r,n){r.forEach((a,o)=>{const s=e[o];Ee(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||kt(m,h))&&!kt(a,h)&&p(),f&&(m==null||!kt(m,h))&&kt(a,h)&&f())}})}function Er(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 Mc({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 $c(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function _a(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 fo(e){return`react-resizable-panels:${e}`}function go(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 xo(e,r){try{const n=fo(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Dc(e,r,n){var a,o;const s=(a=xo(e,n))!==null&&a!==void 0?a:{},l=go(r);return(o=s[l])!==null&&o!==void 0?o:null}function Bc(e,r,n,a,o){var s;const l=fo(e),i=go(r),d=(s=xo(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 Ma({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(!lt(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Ee(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];Ee(l!=null,`No layout data found for index ${s}`);const i=Jt({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!lt(o,0))for(let s=0;s<r.length;s++){const l=n[s];Ee(l!=null,`No layout data found for index ${s}`);const i=l+o,d=Jt({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,lt(o,0)))break}return n}const Gc=100,ur={getItem:e=>(_a(ur),ur.getItem(e)),setItem:(e,r)=>{_a(ur),ur.setItem(e,r)}},$a={};function bo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=ur,style:h,tagName:u="div",...m}){const f=Yn(s),p=c.useRef(null),[g,v]=c.useState(null),[b,x]=c.useState([]),j=Tc(),y=c.useRef({}),w=c.useRef(new Map),k=c.useRef(0),N=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),C=c.useRef({layout:b,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:T}=C.current;return T},setLayout:T=>{const{onLayout:O}=N.current,{layout:G,panelDataArray:L}=C.current,S=Ma({layout:T,panelConstraints:L.map(V=>V.constraints)});Aa(G,S)||(x(S),C.current.layout=S,O&&O(S),Kt(L,S,y.current))}}),[]),Gt(()=>{N.current.autoSaveId=e,N.current.direction=a,N.current.dragState=g,N.current.id=f,N.current.onLayout=l,N.current.storage=d}),Ic({committedValuesRef:N,eagerValuesRef:C,groupId:f,layout:b,panelDataArray:C.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=C.current;if(e){if(b.length===0||b.length!==T.length)return;let O=$a[e];O==null&&(O=$c(Bc,Gc),$a[e]=O);const G=[...T],L=new Map(w.current);O(e,G,L,b,d)}},[e,b,d]),c.useEffect(()=>{});const E=c.useCallback(T=>{const{onLayout:O}=N.current,{layout:G,panelDataArray:L}=C.current;if(T.constraints.collapsible){const S=L.map(X=>X.constraints),{collapsedSize:V=0,panelSize:K,pivotIndices:le}=_t(L,T,G);if(Ee(K!=null,`Panel size not found for panel "${T.id}"`),!kt(K,V)){w.current.set(T.id,K);const ce=Xt(L,T)===L.length-1?K-V:V-K,re=hr({delta:ce,initialLayout:G,panelConstraints:S,pivotIndices:le,prevLayout:G,trigger:"imperative-api"});Er(G,re)||(x(re),C.current.layout=re,O&&O(re),Kt(L,re,y.current))}}},[]),I=c.useCallback((T,O)=>{const{onLayout:G}=N.current,{layout:L,panelDataArray:S}=C.current;if(T.constraints.collapsible){const V=S.map(fe=>fe.constraints),{collapsedSize:K=0,panelSize:le=0,minSize:X=0,pivotIndices:ce}=_t(S,T,L),re=O??X;if(kt(le,K)){const fe=w.current.get(T.id),he=fe!=null&&fe>=re?fe:re,Re=Xt(S,T)===S.length-1?le-he:he-le,ie=hr({delta:Re,initialLayout:L,panelConstraints:V,pivotIndices:ce,prevLayout:L,trigger:"imperative-api"});Er(L,ie)||(x(ie),C.current.layout=ie,G&&G(ie),Kt(S,ie,y.current))}}},[]),q=c.useCallback(T=>{const{layout:O,panelDataArray:G}=C.current,{panelSize:L}=_t(G,T,O);return Ee(L!=null,`Panel size not found for panel "${T.id}"`),L},[]),D=c.useCallback((T,O)=>{const{panelDataArray:G}=C.current,L=Xt(G,T);return Mc({defaultSize:O,dragState:g,layout:b,panelData:G,panelIndex:L})},[g,b]),$=c.useCallback(T=>{const{layout:O,panelDataArray:G}=C.current,{collapsedSize:L=0,collapsible:S,panelSize:V}=_t(G,T,O);return Ee(V!=null,`Panel size not found for panel "${T.id}"`),S===!0&&kt(V,L)},[]),Q=c.useCallback(T=>{const{layout:O,panelDataArray:G}=C.current,{collapsedSize:L=0,collapsible:S,panelSize:V}=_t(G,T,O);return Ee(V!=null,`Panel size not found for panel "${T.id}"`),!S||Ht(V,L)>0},[]),Z=c.useCallback(T=>{const{panelDataArray:O}=C.current;O.push(T),O.sort((G,L)=>{const S=G.order,V=L.order;return S==null&&V==null?0:S==null?-1:V==null?1:S-V}),C.current.panelDataArrayChanged=!0,j()},[j]);Gt(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:O,storage:G}=N.current,{layout:L,panelDataArray:S}=C.current;let V=null;if(T){const le=Dc(T,S,G);le&&(w.current=new Map(Object.entries(le.expandToSizes)),V=le.layout)}V==null&&(V=_c({panelDataArray:S}));const K=Ma({layout:V,panelConstraints:S.map(le=>le.constraints)});Aa(L,K)||(x(K),C.current.layout=K,O&&O(K),Kt(S,K,y.current))}}),Gt(()=>{const T=C.current;return()=>{T.layout=[]}},[]);const B=c.useCallback(T=>{let O=!1;const G=p.current;return G&&window.getComputedStyle(G,null).getPropertyValue("direction")==="rtl"&&(O=!0),function(S){S.preventDefault();const V=p.current;if(!V)return()=>null;const{direction:K,dragState:le,id:X,keyboardResizeBy:ce,onLayout:re}=N.current,{layout:fe,panelDataArray:he}=C.current,{initialLayout:ve}=le??{},Re=uo(X,T,V);let ie=Ac(S,T,K,le,ce,V);const ye=K==="horizontal";ye&&O&&(ie=-ie);const Te=he.map(xe=>xe.constraints),U=hr({delta:ie,initialLayout:ve??fe,panelConstraints:Te,pivotIndices:Re,prevLayout:fe,trigger:to(S)?"keyboard":"mouse-or-touch"}),ae=!Er(fe,U);(ro(S)||no(S))&&k.current!=ie&&(k.current=ie,!ae&&ie!==0?ye?un(T,ie<0?so:oo):un(T,ie<0?lo:io):un(T,0)),ae&&(x(U),C.current.layout=U,re&&re(U),Kt(he,U,y.current))}},[]),ee=c.useCallback((T,O)=>{const{onLayout:G}=N.current,{layout:L,panelDataArray:S}=C.current,V=S.map(fe=>fe.constraints),{panelSize:K,pivotIndices:le}=_t(S,T,L);Ee(K!=null,`Panel size not found for panel "${T.id}"`);const ce=Xt(S,T)===S.length-1?K-O:O-K,re=hr({delta:ce,initialLayout:L,panelConstraints:V,pivotIndices:le,prevLayout:L,trigger:"imperative-api"});Er(L,re)||(x(re),C.current.layout=re,G&&G(re),Kt(S,re,y.current))},[]),oe=c.useCallback((T,O)=>{const{layout:G,panelDataArray:L}=C.current,{collapsedSize:S=0,collapsible:V}=O,{collapsedSize:K=0,collapsible:le,maxSize:X=100,minSize:ce=0}=T.constraints,{panelSize:re}=_t(L,T,G);re!=null&&(V&&le&&kt(re,S)?kt(S,K)||ee(T,K):re<ce?ee(T,ce):re>X&&ee(T,X))},[ee]),A=c.useCallback((T,O)=>{const{direction:G}=N.current,{layout:L}=C.current;if(!p.current)return;const S=Xr(T,p.current);Ee(S,`Drag handle element not found for id "${T}"`);const V=po(G,O);v({dragHandleId:T,dragHandleRect:S.getBoundingClientRect(),initialCursorPosition:V,initialLayout:L})},[]),J=c.useCallback(()=>{v(null)},[]),R=c.useCallback(T=>{const{panelDataArray:O}=C.current,G=Xt(O,T);G>=0&&(O.splice(G,1),delete y.current[T.id],C.current.panelDataArrayChanged=!0,j())},[j]),Y=c.useMemo(()=>({collapsePanel:E,direction:a,dragState:g,expandPanel:I,getPanelSize:q,getPanelStyle:D,groupId:f,isPanelCollapsed:$,isPanelExpanded:Q,reevaluatePanelConstraints:oe,registerPanel:Z,registerResizeHandle:B,resizePanel:ee,startDragging:A,stopDragging:J,unregisterPanel:R,panelGroupElement:p.current}),[E,g,a,I,q,D,f,$,Q,oe,Z,B,ee,A,J,R]),H={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Wr.Provider,{value:Y},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...H,...h},[Ve.group]:"",[Ve.groupDirection]:a,[Ve.groupId]:f}))}const vo=c.forwardRef((e,r)=>c.createElement(bo,{...e,forwardedRef:r}));bo.displayName="PanelGroup";vo.displayName="forwardRef(PanelGroup)";function Xt(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function _t(e,r,n){const a=Xt(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Fc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=Xr(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(Ve.groupId);Ee(i,`No group element found for id "${i}"`);const d=br(i,a),h=ho(i,r,a);Ee(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 ko({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:o,onBlur:s,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var v,b;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(Wr);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:w,groupId:k,registerResizeHandle:N,startDragging:C,stopDragging:E,panelGroupElement:I}=y,q=Yn(o),[D,$]=c.useState("inactive"),[Q,Z]=c.useState(!1),[B,ee]=c.useState(null),oe=c.useRef({state:D});Gt(()=>{oe.current.state=D}),c.useEffect(()=>{if(n)ee(null);else{const Y=N(q);ee(()=>Y)}},[n,q,N]);const A=(v=a==null?void 0:a.coarse)!==null&&v!==void 0?v:15,J=(b=a==null?void 0:a.fine)!==null&&b!==void 0?b:5;c.useEffect(()=>{if(n||B==null)return;const Y=x.current;Ee(Y,"Element ref not attached");let H=!1;return Cc(q,Y,w,{coarse:A,fine:J},(O,G,L)=>{if(!G){$("inactive");return}switch(O){case"down":{$("drag"),H=!1,Ee(L,'Expected event to be defined for "down" action'),C(q,L);const{onDragging:S,onPointerDown:V}=j.current;S==null||S(!0),V==null||V();break}case"move":{const{state:S}=oe.current;H=!0,S!=="drag"&&$("hover"),Ee(L,'Expected event to be defined for "move" action'),B(L);break}case"up":{$("hover"),E();const{onClick:S,onDragging:V,onPointerUp:K}=j.current;V==null||V(!1),K==null||K(),H||S==null||S();break}}})},[A,w,n,J,N,q,B,C,E]),Fc({disabled:n,handleId:q,resizeHandler:B,panelGroupElement:I});const R={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),d==null||d()},ref:x,role:"separator",style:{...R,...m},tabIndex:f,[Ve.groupDirection]:w,[Ve.groupId]:k,[Ve.resizeHandle]:"",[Ve.resizeHandleActive]:D==="drag"?"pointer":Q?"keyboard":void 0,[Ve.resizeHandleEnabled]:!n,[Ve.resizeHandleId]:q,[Ve.resizeHandleState]:D})}ko.displayName="PanelResizeHandle";var Hc=Object.defineProperty,Oc=Object.getOwnPropertyNames,Ge=(e,r)=>function(){return e&&(r=(0,e[Oc(e)[0]])(e=0)),r},Uc=(e,r)=>{for(var n in r)Hc(e,n,{get:r[n],enumerable:!0})};function Qe(...e){return mc(Ds(e))}var zt=Ge({"src/components/graph-ui/utils.ts"(){}});function vr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?As:"button";return t.jsx(s,{"data-slot":"button",className:Qe(wo({variant:a,size:n,className:r})),...o})}var wo,Yr=Ge({"src/components/graph-ui/Button.tsx"(){zt(),wo=kr("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 yo(...e){return e.filter(Boolean).join(" ")}function En({className:e,...r}){return t.jsx(vo,{"data-slot":"resizable-panel-group",className:yo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function Qt({...e}){return t.jsx(eo,{"data-slot":"resizable-panel",...e})}function Ln({withHandle:e,className:r,...n}){return t.jsx(ko,{"data-slot":"resizable-handle",className:yo("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(M.GripVerticalIcon,{className:"size-2.5"})}):null})}var jo=Ge({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function Jn(...e){return e.filter(Boolean).join(" ")}function wr({...e}){return t.jsx(Bi,{"data-slot":"accordion",...e})}function yr({className:e,...r}){return t.jsx(Gi,{"data-slot":"accordion-item",className:Jn("border-b last:border-b-0",e),...r})}function Zr({className:e,children:r,...n}){return t.jsx(Hi,{className:"flex",children:t.jsxs(Oi,{"data-slot":"accordion-trigger",className:Jn("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(M.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function jr({className:e,children:r,...n}){return t.jsx(Fi,{"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:Jn("pb-4 pt-0",e),children:r})})}var Nr=Ge({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Wc(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 Vc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Cr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function Kc(e){return e.split("/").filter(Boolean).at(-1)??e}function Yt(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(Yt);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 No(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=No(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function Co(e){if(e.kind==="file")return e;for(const r of e.children){const n=Co(r);if(n)return n}return null}function Pn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Pn(n,r);if(a)return a}return null}function So(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function qc(e){const n=So(e).split("/").filter(Boolean);n.pop();const a=[];let o="";for(const s of n)o=o?`${o}/${s}`:s,a.push(o);return a}function zn(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const o=e.children.map(s=>{const l=zn(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function In(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>In(n,r))}function Xc(e){if(!e)return null;const r=Cr(e.path);return Qn.has(r)?{content:[e.content.endsWith(`
|
|
2
|
+
import{l as M,R as Gi,I as Fi,C as Hi,S as _s,H as Oi,T as Wi,a as Ui,b as Vi,c as Ki,d as qi,e as Xi,D as Yi,P as Zi,O as Ji,f as Qi,g as ed,h as td,i as rd,j as nd,k as ad,m as sd,n as od,A as ld,o as id,p as dd}from"./ui-vendor-CuR8GHb0.js";import{r as c,R as cd,j as t,b as Vr}from"./react-vendor-Dfg_6BLf.js";import{u as hd,a as ud,H as va,P as $t,b as md,M as Ms,R as pd,i as fd,C as gd,B as xd,c as ka,g as $s}from"./graph-vendor-DVQUpZ8C.js";import"./terminal-vendor-C5bTa-Ka.js";import{M as bd,r as vd,a as kd,b as wd}from"./markdown-vendor-RZk8L7-L.js";const yd="modulepreload",jd=function(e){return"/"+e},wa={},Ke=function(r,n,a){let o=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),d=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=l(n.map(h=>{if(h=jd(h),h in wa)return;wa[h]=!0;const u=h.endsWith(".css"),m=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":yd,u||(f.as="script"),f.crossOrigin="",f.href=h,d&&f.setAttribute("nonce",d),document.head.appendChild(f),u)return new Promise((p,g)=>{f.addEventListener("load",p),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function s(l){const i=new Event("vite:preloadError",{cancelable:!0});if(i.payload=l,window.dispatchEvent(i),!i.defaultPrevented)throw l}return o.then(l=>{for(const i of l||[])i.status==="rejected"&&s(i.reason);return r().catch(s)})};function Ds(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=Ds(e[r]))&&(a&&(a+=" "),a+=n)}else for(n in e)e[n]&&(a&&(a+=" "),a+=n);return a}function Bs(){for(var e,r,n=0,a="",o=arguments.length;n<o;n++)(e=arguments[n])&&(r=Ds(e))&&(a&&(a+=" "),a+=r);return a}const Nd=(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},Cd=(e,r)=>({classGroupId:e,validator:r}),Gs=(e=new Map,r=null,n)=>({nextPart:e,validators:r,classGroupId:n}),Fr="-",ya=[],Sd="arbitrary..",Td=e=>{const r=Ld(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:a}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return Ed(l);const i=l.split(Fr),d=i[0]===""&&i.length>1?1:0;return Fs(i,d,r)},getConflictingClassGroupIds:(l,i)=>{if(i){const d=a[l],h=n[l];return d?h?Nd(h,d):d:h||ya}return n[l]||ya}}},Fs=(e,r,n)=>{if(e.length-r===0)return n.classGroupId;const o=e[r],s=n.nextPart.get(o);if(s){const h=Fs(e,r+1,s);if(h)return h}const l=n.validators;if(l===null)return;const i=r===0?e.join(Fr):e.slice(r).join(Fr),d=l.length;for(let h=0;h<d;h++){const u=l[h];if(u.validator(i))return u.classGroupId}},Ed=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?Sd+a:void 0})(),Ld=e=>{const{theme:r,classGroups:n}=e;return Pd(n,r)},Pd=(e,r)=>{const n=Gs();for(const a in e){const o=e[a];Kn(o,n,a,r)}return n},Kn=(e,r,n,a)=>{const o=e.length;for(let s=0;s<o;s++){const l=e[s];Id(l,r,n,a)}},Id=(e,r,n,a)=>{if(typeof e=="string"){zd(e,r,n);return}if(typeof e=="function"){Rd(e,r,n,a);return}Ad(e,r,n,a)},zd=(e,r,n)=>{const a=e===""?r:Hs(r,e);a.classGroupId=n},Rd=(e,r,n,a)=>{if(_d(e)){Kn(e(a),r,n,a);return}r.validators===null&&(r.validators=[]),r.validators.push(Cd(n,e))},Ad=(e,r,n,a)=>{const o=Object.entries(e),s=o.length;for(let l=0;l<s;l++){const[i,d]=o[l];Kn(d,Hs(r,i),n,a)}},Hs=(e,r)=>{let n=e;const a=r.split(Fr),o=a.length;for(let s=0;s<o;s++){const l=a[s];let i=n.nextPart.get(l);i||(i=Gs(),n.nextPart.set(l,i)),n=i}return n},_d=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,Md=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)}}},Sn="!",ja=":",$d=[],Na=(e,r,n,a,o)=>({modifiers:e,hasImportantModifier:r,baseClassName:n,maybePostfixModifierPosition:a,isExternal:o}),Dd=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 v=0;v<u;v++){const b=o[v];if(l===0&&i===0){if(b===ja){s.push(o.slice(d,v)),d=v+1;continue}if(b==="/"){h=v;continue}}b==="["?l++:b==="]"?l--:b==="("?i++:b===")"&&i--}const m=s.length===0?o:o.slice(d);let f=m,p=!1;m.endsWith(Sn)?(f=m.slice(0,-1),p=!0):m.startsWith(Sn)&&(f=m.slice(1),p=!0);const g=h&&h>d?h-d:void 0;return Na(s,p,f,g)};if(r){const o=r+ja,s=a;a=l=>l.startsWith(o)?s(l.slice(o.length)):Na($d,!1,l,void 0,!0)}if(n){const o=a;a=s=>n({className:s,parseClassName:o})}return a},Bd=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}},Gd=e=>({cache:Md(e.cacheSize),parseClassName:Dd(e),sortModifiers:Bd(e),postfixLookupClassGroupIds:Fd(e),...Td(e)}),Fd=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},Hd=/\s+/,Od=(e,r)=>{const{parseClassName:n,getClassGroupId:a,getConflictingClassGroupIds:o,sortModifiers:s,postfixLookupClassGroupIds:l}=r,i=[],d=e.trim().split(Hd);let h="";for(let u=d.length-1;u>=0;u-=1){const m=d[u],{isExternal:f,modifiers:p,hasImportantModifier:g,baseClassName:v,maybePostfixModifierPosition:b}=n(m);if(f){h=m+(h.length>0?" "+h:h);continue}let x=!!b,j;if(x){const C=v.substring(0,b);j=a(C);const E=j&&l[j]?a(v):void 0;E&&E!==j&&(j=E,x=!1)}else j=a(v);if(!j){if(!x){h=m+(h.length>0?" "+h:h);continue}if(j=a(v),!j){h=m+(h.length>0?" "+h:h);continue}x=!1}const y=p.length===0?"":p.length===1?p[0]:s(p).join(":"),w=g?y+Sn:y,k=w+j;if(i.indexOf(k)>-1)continue;i.push(k);const N=o(j,x);for(let C=0;C<N.length;++C){const E=N[C];i.push(w+E)}h=m+(h.length>0?" "+h:h)}return h},Wd=(...e)=>{let r=0,n,a,o="";for(;r<e.length;)(n=e[r++])&&(a=Os(n))&&(o&&(o+=" "),o+=a);return o},Os=e=>{if(typeof e=="string")return e;let r,n="";for(let a=0;a<e.length;a++)e[a]&&(r=Os(e[a]))&&(n&&(n+=" "),n+=r);return n},Ud=(e,...r)=>{let n,a,o,s;const l=d=>{const h=r.reduce((u,m)=>m(u),e());return n=Gd(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=Od(d,n);return o(d,u),u};return s=l,(...d)=>s(Wd(...d))},Vd=[],Ze=e=>{const r=n=>n[e]||Vd;return r.isThemeGetter=!0,r},Ws=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Us=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Kd=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,qd=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Xd=/\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$/,Yd=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Zd=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Jd=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ct=e=>Kd.test(e),Le=e=>!!e&&!Number.isNaN(Number(e)),pt=e=>!!e&&Number.isInteger(Number(e)),cn=e=>e.endsWith("%")&&Le(e.slice(0,-1)),vt=e=>qd.test(e),Vs=()=>!0,Qd=e=>Xd.test(e)&&!Yd.test(e),qn=()=>!1,ec=e=>Zd.test(e),tc=e=>Jd.test(e),rc=e=>!ue(e)&&!me(e),nc=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)),ac=e=>Pt(e,Xs,qn),ue=e=>Ws.test(e),At=e=>Pt(e,Ys,Qd),Ca=e=>Pt(e,uc,Le),sc=e=>Pt(e,Js,Vs),oc=e=>Pt(e,Zs,qn),Sa=e=>Pt(e,Ks,qn),lc=e=>Pt(e,qs,tc),Tr=e=>Pt(e,Qs,ec),me=e=>Us.test(e),ir=e=>Ot(e,Ys),ic=e=>Ot(e,Zs),Ta=e=>Ot(e,Ks),dc=e=>Ot(e,Xs),cc=e=>Ot(e,qs),Er=e=>Ot(e,Qs,!0),hc=e=>Ot(e,Js,!0),Pt=(e,r,n)=>{const a=Ws.exec(e);return a?a[1]?r(a[1]):n(a[2]):!1},Ot=(e,r,n=!1)=>{const a=Us.exec(e);return a?a[1]?r(a[1]):n:!1},Ks=e=>e==="position"||e==="percentage",qs=e=>e==="image"||e==="url",Xs=e=>e==="length"||e==="size"||e==="bg-size",Ys=e=>e==="length",uc=e=>e==="number",Zs=e=>e==="family-name",Js=e=>e==="number"||e==="weight",Qs=e=>e==="shadow",mc=()=>{const e=Ze("color"),r=Ze("font"),n=Ze("text"),a=Ze("font-weight"),o=Ze("tracking"),s=Ze("leading"),l=Ze("breakpoint"),i=Ze("container"),d=Ze("spacing"),h=Ze("radius"),u=Ze("shadow"),m=Ze("inset-shadow"),f=Ze("text-shadow"),p=Ze("drop-shadow"),g=Ze("blur"),v=Ze("perspective"),b=Ze("aspect"),x=Ze("ease"),j=Ze("animate"),y=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],k=()=>[...w(),me,ue],N=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],E=()=>[me,ue,d],z=()=>[Ct,"full","auto",...E()],q=()=>[pt,"none","subgrid",me,ue],D=()=>["auto",{span:["full",pt,me,ue]},pt,me,ue],$=()=>[pt,"auto",me,ue],Q=()=>["auto","min","max","fr",me,ue],Z=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],B=()=>["start","end","center","stretch","center-safe","end-safe"],ee=()=>["auto",...E()],oe=()=>[Ct,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...E()],A=()=>[Ct,"screen","full","dvw","lvw","svw","min","max","fit",...E()],J=()=>[Ct,"screen","full","lh","dvh","lvh","svh","min","max","fit",...E()],R=()=>[e,me,ue],Y=()=>[...w(),Ta,Sa,{position:[me,ue]}],H=()=>["no-repeat",{repeat:["","x","y","space","round"]}],T=()=>["auto","cover","contain",dc,ac,{size:[me,ue]}],O=()=>[cn,ir,At],G=()=>["","none","full",h,me,ue],L=()=>["",Le,ir,At],S=()=>["solid","dashed","dotted","double"],V=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],K=()=>[Le,cn,Ta,Sa],le=()=>["","none",g,me,ue],X=()=>["none",Le,me,ue],ce=()=>["none",Le,me,ue],re=()=>[Le,me,ue],fe=()=>[Ct,"full",...E()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[vt],breakpoint:[vt],color:[Vs],container:[vt],"drop-shadow":[vt],ease:["in","out","in-out"],font:[rc],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[vt],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[vt],shadow:[vt],spacing:["px",Le],text:[vt],"text-shadow":[vt],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Ct,ue,me,b]}],container:["container"],"container-type":[{"@container":["","normal","size",me,ue]}],"container-named":[nc],columns:[{columns:[Le,ue,me,i]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:k()}],overflow:[{overflow:N()}],"overflow-x":[{"overflow-x":N()}],"overflow-y":[{"overflow-y":N()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:z()}],"inset-x":[{"inset-x":z()}],"inset-y":[{"inset-y":z()}],start:[{"inset-s":z(),start:z()}],end:[{"inset-e":z(),end:z()}],"inset-bs":[{"inset-bs":z()}],"inset-be":[{"inset-be":z()}],top:[{top:z()}],right:[{right:z()}],bottom:[{bottom:z()}],left:[{left:z()}],visibility:["visible","invisible","collapse"],z:[{z:[pt,"auto",me,ue]}],basis:[{basis:[Ct,"full","auto",i,...E()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Le,Ct,"auto","initial","none",ue]}],grow:[{grow:["",Le,me,ue]}],shrink:[{shrink:["",Le,me,ue]}],order:[{order:[pt,"first","last","none",me,ue]}],"grid-cols":[{"grid-cols":q()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":$()}],"col-end":[{"col-end":$()}],"grid-rows":[{"grid-rows":q()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":$()}],"row-end":[{"row-end":$()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":Q()}],"auto-rows":[{"auto-rows":Q()}],gap:[{gap:E()}],"gap-x":[{"gap-x":E()}],"gap-y":[{"gap-y":E()}],"justify-content":[{justify:[...Z(),"normal"]}],"justify-items":[{"justify-items":[...B(),"normal"]}],"justify-self":[{"justify-self":["auto",...B()]}],"align-content":[{content:["normal",...Z()]}],"align-items":[{items:[...B(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...B(),{baseline:["","last"]}]}],"place-content":[{"place-content":Z()}],"place-items":[{"place-items":[...B(),"baseline"]}],"place-self":[{"place-self":["auto",...B()]}],p:[{p:E()}],px:[{px:E()}],py:[{py:E()}],ps:[{ps:E()}],pe:[{pe:E()}],pbs:[{pbs:E()}],pbe:[{pbe:E()}],pt:[{pt:E()}],pr:[{pr:E()}],pb:[{pb:E()}],pl:[{pl:E()}],m:[{m:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mbs:[{mbs:ee()}],mbe:[{mbe:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":E()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":E()}],"space-y-reverse":["space-y-reverse"],size:[{size:oe()}],"inline-size":[{inline:["auto",...A()]}],"min-inline-size":[{"min-inline":["auto",...A()]}],"max-inline-size":[{"max-inline":["none",...A()]}],"block-size":[{block:["auto",...J()]}],"min-block-size":[{"min-block":["auto",...J()]}],"max-block-size":[{"max-block":["none",...J()]}],w:[{w:[i,"screen",...oe()]}],"min-w":[{"min-w":[i,"screen","none",...oe()]}],"max-w":[{"max-w":[i,"screen","none","prose",{screen:[l]},...oe()]}],h:[{h:["screen","lh",...oe()]}],"min-h":[{"min-h":["screen","lh","none",...oe()]}],"max-h":[{"max-h":["screen","lh",...oe()]}],"font-size":[{text:["base",n,ir,At]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[a,hc,sc]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",cn,ue]}],"font-family":[{font:[ic,oc,r]}],"font-features":[{"font-features":[ue]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[o,me,ue]}],"line-clamp":[{"line-clamp":[Le,"none",me,Ca]}],leading:[{leading:[s,...E()]}],"list-image":[{"list-image":["none",me,ue]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",me,ue]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:R()}],"text-color":[{text:R()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...S(),"wavy"]}],"text-decoration-thickness":[{decoration:[Le,"from-font","auto",me,At]}],"text-decoration-color":[{decoration:R()}],"underline-offset":[{"underline-offset":[Le,"auto",me,ue]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:E()}],"tab-size":[{tab:[pt,me,ue]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",me,ue]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",me,ue]}],"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:H()}],"bg-size":[{bg:T()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},pt,me,ue],radial:["",me,ue],conic:[pt,me,ue]},cc,lc]}],"bg-color":[{bg:R()}],"gradient-from-pos":[{from:O()}],"gradient-via-pos":[{via:O()}],"gradient-to-pos":[{to:O()}],"gradient-from":[{from:R()}],"gradient-via":[{via:R()}],"gradient-to":[{to:R()}],rounded:[{rounded:G()}],"rounded-s":[{"rounded-s":G()}],"rounded-e":[{"rounded-e":G()}],"rounded-t":[{"rounded-t":G()}],"rounded-r":[{"rounded-r":G()}],"rounded-b":[{"rounded-b":G()}],"rounded-l":[{"rounded-l":G()}],"rounded-ss":[{"rounded-ss":G()}],"rounded-se":[{"rounded-se":G()}],"rounded-ee":[{"rounded-ee":G()}],"rounded-es":[{"rounded-es":G()}],"rounded-tl":[{"rounded-tl":G()}],"rounded-tr":[{"rounded-tr":G()}],"rounded-br":[{"rounded-br":G()}],"rounded-bl":[{"rounded-bl":G()}],"border-w":[{border:L()}],"border-w-x":[{"border-x":L()}],"border-w-y":[{"border-y":L()}],"border-w-s":[{"border-s":L()}],"border-w-e":[{"border-e":L()}],"border-w-bs":[{"border-bs":L()}],"border-w-be":[{"border-be":L()}],"border-w-t":[{"border-t":L()}],"border-w-r":[{"border-r":L()}],"border-w-b":[{"border-b":L()}],"border-w-l":[{"border-l":L()}],"divide-x":[{"divide-x":L()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":L()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...S(),"hidden","none"]}],"divide-style":[{divide:[...S(),"hidden","none"]}],"border-color":[{border:R()}],"border-color-x":[{"border-x":R()}],"border-color-y":[{"border-y":R()}],"border-color-s":[{"border-s":R()}],"border-color-e":[{"border-e":R()}],"border-color-bs":[{"border-bs":R()}],"border-color-be":[{"border-be":R()}],"border-color-t":[{"border-t":R()}],"border-color-r":[{"border-r":R()}],"border-color-b":[{"border-b":R()}],"border-color-l":[{"border-l":R()}],"divide-color":[{divide:R()}],"outline-style":[{outline:[...S(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Le,me,ue]}],"outline-w":[{outline:["",Le,ir,At]}],"outline-color":[{outline:R()}],shadow:[{shadow:["","none",u,Er,Tr]}],"shadow-color":[{shadow:R()}],"inset-shadow":[{"inset-shadow":["none",m,Er,Tr]}],"inset-shadow-color":[{"inset-shadow":R()}],"ring-w":[{ring:L()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:R()}],"ring-offset-w":[{"ring-offset":[Le,At]}],"ring-offset-color":[{"ring-offset":R()}],"inset-ring-w":[{"inset-ring":L()}],"inset-ring-color":[{"inset-ring":R()}],"text-shadow":[{"text-shadow":["none",f,Er,Tr]}],"text-shadow-color":[{"text-shadow":R()}],opacity:[{opacity:[Le,me,ue]}],"mix-blend":[{"mix-blend":[...V(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":V()}],"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":[Le]}],"mask-image-linear-from-pos":[{"mask-linear-from":K()}],"mask-image-linear-to-pos":[{"mask-linear-to":K()}],"mask-image-linear-from-color":[{"mask-linear-from":R()}],"mask-image-linear-to-color":[{"mask-linear-to":R()}],"mask-image-t-from-pos":[{"mask-t-from":K()}],"mask-image-t-to-pos":[{"mask-t-to":K()}],"mask-image-t-from-color":[{"mask-t-from":R()}],"mask-image-t-to-color":[{"mask-t-to":R()}],"mask-image-r-from-pos":[{"mask-r-from":K()}],"mask-image-r-to-pos":[{"mask-r-to":K()}],"mask-image-r-from-color":[{"mask-r-from":R()}],"mask-image-r-to-color":[{"mask-r-to":R()}],"mask-image-b-from-pos":[{"mask-b-from":K()}],"mask-image-b-to-pos":[{"mask-b-to":K()}],"mask-image-b-from-color":[{"mask-b-from":R()}],"mask-image-b-to-color":[{"mask-b-to":R()}],"mask-image-l-from-pos":[{"mask-l-from":K()}],"mask-image-l-to-pos":[{"mask-l-to":K()}],"mask-image-l-from-color":[{"mask-l-from":R()}],"mask-image-l-to-color":[{"mask-l-to":R()}],"mask-image-x-from-pos":[{"mask-x-from":K()}],"mask-image-x-to-pos":[{"mask-x-to":K()}],"mask-image-x-from-color":[{"mask-x-from":R()}],"mask-image-x-to-color":[{"mask-x-to":R()}],"mask-image-y-from-pos":[{"mask-y-from":K()}],"mask-image-y-to-pos":[{"mask-y-to":K()}],"mask-image-y-from-color":[{"mask-y-from":R()}],"mask-image-y-to-color":[{"mask-y-to":R()}],"mask-image-radial":[{"mask-radial":[me,ue]}],"mask-image-radial-from-pos":[{"mask-radial-from":K()}],"mask-image-radial-to-pos":[{"mask-radial-to":K()}],"mask-image-radial-from-color":[{"mask-radial-from":R()}],"mask-image-radial-to-color":[{"mask-radial-to":R()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[Le]}],"mask-image-conic-from-pos":[{"mask-conic-from":K()}],"mask-image-conic-to-pos":[{"mask-conic-to":K()}],"mask-image-conic-from-color":[{"mask-conic-from":R()}],"mask-image-conic-to-color":[{"mask-conic-to":R()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:Y()}],"mask-repeat":[{mask:H()}],"mask-size":[{mask:T()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",me,ue]}],filter:[{filter:["","none",me,ue]}],blur:[{blur:le()}],brightness:[{brightness:[Le,me,ue]}],contrast:[{contrast:[Le,me,ue]}],"drop-shadow":[{"drop-shadow":["","none",p,Er,Tr]}],"drop-shadow-color":[{"drop-shadow":R()}],grayscale:[{grayscale:["",Le,me,ue]}],"hue-rotate":[{"hue-rotate":[Le,me,ue]}],invert:[{invert:["",Le,me,ue]}],saturate:[{saturate:[Le,me,ue]}],sepia:[{sepia:["",Le,me,ue]}],"backdrop-filter":[{"backdrop-filter":["","none",me,ue]}],"backdrop-blur":[{"backdrop-blur":le()}],"backdrop-brightness":[{"backdrop-brightness":[Le,me,ue]}],"backdrop-contrast":[{"backdrop-contrast":[Le,me,ue]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Le,me,ue]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Le,me,ue]}],"backdrop-invert":[{"backdrop-invert":["",Le,me,ue]}],"backdrop-opacity":[{"backdrop-opacity":[Le,me,ue]}],"backdrop-saturate":[{"backdrop-saturate":[Le,me,ue]}],"backdrop-sepia":[{"backdrop-sepia":["",Le,me,ue]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":E()}],"border-spacing-x":[{"border-spacing-x":E()}],"border-spacing-y":[{"border-spacing-y":E()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",me,ue]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Le,"initial",me,ue]}],ease:[{ease:["linear","initial",x,me,ue]}],delay:[{delay:[Le,me,ue]}],animate:[{animate:["none",j,me,ue]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,me,ue]}],"perspective-origin":[{"perspective-origin":k()}],rotate:[{rotate:X()}],"rotate-x":[{"rotate-x":X()}],"rotate-y":[{"rotate-y":X()}],"rotate-z":[{"rotate-z":X()}],scale:[{scale:ce()}],"scale-x":[{"scale-x":ce()}],"scale-y":[{"scale-y":ce()}],"scale-z":[{"scale-z":ce()}],"scale-3d":["scale-3d"],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[me,ue,"","none","gpu","cpu"]}],"transform-origin":[{origin:k()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:fe()}],"translate-x":[{"translate-x":fe()}],"translate-y":[{"translate-y":fe()}],"translate-z":[{"translate-z":fe()}],"translate-none":["translate-none"],zoom:[{zoom:[pt,me,ue]}],accent:[{accent:R()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:R()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",me,ue]}],"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":R()}],"scrollbar-track-color":[{"scrollbar-track":R()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":E()}],"scroll-mx":[{"scroll-mx":E()}],"scroll-my":[{"scroll-my":E()}],"scroll-ms":[{"scroll-ms":E()}],"scroll-me":[{"scroll-me":E()}],"scroll-mbs":[{"scroll-mbs":E()}],"scroll-mbe":[{"scroll-mbe":E()}],"scroll-mt":[{"scroll-mt":E()}],"scroll-mr":[{"scroll-mr":E()}],"scroll-mb":[{"scroll-mb":E()}],"scroll-ml":[{"scroll-ml":E()}],"scroll-p":[{"scroll-p":E()}],"scroll-px":[{"scroll-px":E()}],"scroll-py":[{"scroll-py":E()}],"scroll-ps":[{"scroll-ps":E()}],"scroll-pe":[{"scroll-pe":E()}],"scroll-pbs":[{"scroll-pbs":E()}],"scroll-pbe":[{"scroll-pbe":E()}],"scroll-pt":[{"scroll-pt":E()}],"scroll-pr":[{"scroll-pr":E()}],"scroll-pb":[{"scroll-pb":E()}],"scroll-pl":[{"scroll-pl":E()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",me,ue]}],fill:[{fill:["none",...R()]}],"stroke-w":[{stroke:[Le,ir,At,Ca]}],stroke:[{stroke:["none",...R()]}],"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"]}},pc=Ud(mc),Ea=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,La=Bs,wr=(e,r)=>n=>{var a;if((r==null?void 0:r.variants)==null)return La(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:o,defaultVariants:s}=r,l=Object.keys(o).map(h=>{const u=n==null?void 0:n[h],m=s==null?void 0:s[h];if(u===null)return null;const f=Ea(u)||Ea(m);return o[h][f]}),i=n&&Object.entries(n).reduce((h,u)=>{let[m,f]=u;return f===void 0||(h[m]=f),h},{}),d=r==null||(a=r.compoundVariants)===null||a===void 0?void 0:a.reduce((h,u)=>{let{class:m,className:f,...p}=u;return Object.entries(p).every(g=>{let[v,b]=g;return Array.isArray(b)?b.includes({...s,...i}[v]):{...s,...i}[v]===b})?[...h,m,f]:h},[]);return La(e,l,d,n==null?void 0:n.class,n==null?void 0:n.className)},Kr=c.createContext(null);Kr.displayName="PanelGroupContext";const Ve={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"},Xn=10,Gt=c.useLayoutEffect,Pa=cd.useId,fc=typeof Pa=="function"?Pa:()=>null;let gc=0;function Yn(e=null){const r=fc(),n=c.useRef(e||r||null);return n.current===null&&(n.current=""+gc++),e??n.current}function eo({children:e,className:r="",collapsedSize:n,collapsible:a,defaultSize:o,forwardedRef:s,id:l,maxSize:i,minSize:d,onCollapse:h,onExpand:u,onResize:m,order:f,style:p,tagName:g="div",...v}){const b=c.useContext(Kr);if(b===null)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:x,expandPanel:j,getPanelSize:y,getPanelStyle:w,groupId:k,isPanelCollapsed:N,reevaluatePanelConstraints:C,registerPanel:E,resizePanel:z,unregisterPanel:q}=b,D=Yn(l),$=c.useRef({callbacks:{onCollapse:h,onExpand:u,onResize:m},constraints:{collapsedSize:n,collapsible:a,defaultSize:o,maxSize:i,minSize:d},id:D,idIsFromProps:l!==void 0,order:f});c.useRef({didLogMissingDefaultSizeWarning:!1}),Gt(()=>{const{callbacks:Z,constraints:B}=$.current,ee={...B};$.current.id=D,$.current.idIsFromProps=l!==void 0,$.current.order=f,Z.onCollapse=h,Z.onExpand=u,Z.onResize=m,B.collapsedSize=n,B.collapsible=a,B.defaultSize=o,B.maxSize=i,B.minSize=d,(ee.collapsedSize!==B.collapsedSize||ee.collapsible!==B.collapsible||ee.maxSize!==B.maxSize||ee.minSize!==B.minSize)&&C($.current,ee)}),Gt(()=>{const Z=$.current;return E(Z),()=>{q(Z)}},[f,D,E,q]),c.useImperativeHandle(s,()=>({collapse:()=>{x($.current)},expand:Z=>{j($.current,Z)},getId(){return D},getSize(){return y($.current)},isCollapsed(){return N($.current)},isExpanded(){return!N($.current)},resize:Z=>{z($.current,Z)}}),[x,j,y,N,D,z]);const Q=w($.current,o);return c.createElement(g,{...v,children:e,className:r,id:D,style:{...Q,...p},[Ve.groupId]:k,[Ve.panel]:"",[Ve.panelCollapsible]:a||void 0,[Ve.panelId]:D,[Ve.panelSize]:parseFloat(""+Q.flexGrow).toFixed(1)})}const to=c.forwardRef((e,r)=>c.createElement(eo,{...e,forwardedRef:r}));eo.displayName="Panel";to.displayName="forwardRef(Panel)";let Tn=null,Mr=-1,Tt=null;function xc(e,r,n){const a=(r&oo)!==0,o=(r&lo)!==0,s=(r&io)!==0,l=(r&co)!==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 bc(){Tt!==null&&(document.head.removeChild(Tt),Tn=null,Tt=null,Mr=-1)}function hn(e,r,n){var a,o;const s=xc(e,r);if(Tn!==s){if(Tn=s,Tt===null&&(Tt=document.createElement("style"),document.head.appendChild(Tt)),Mr>=0){var l;(l=Tt.sheet)===null||l===void 0||l.removeRule(Mr)}Mr=(a=(o=Tt.sheet)===null||o===void 0?void 0:o.insertRule(`*{cursor: ${s} !important;}`))!==null&&a!==void 0?a:-1}}function ro(e){return e.type==="keydown"}function no(e){return e.type.startsWith("pointer")}function ao(e){return e.type.startsWith("mouse")}function qr(e){if(no(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ao(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}function vc(){if(typeof matchMedia=="function")return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}function kc(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 wc(e,r){if(e===r)throw new Error("Cannot compare node with itself");const n={a:Ra(e),b:Ra(r)};let a;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),r=n.b.pop(),a=e;Ee(a,"Stacking order can only be calculated for elements with a common ancestor");const o={a:za(Ia(n.a)),b:za(Ia(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 yc=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function jc(e){var r;const n=getComputedStyle((r=so(e))!==null&&r!==void 0?r:e).display;return n==="flex"||n==="inline-flex"}function Nc(e){const r=getComputedStyle(e);return!!(r.position==="fixed"||r.zIndex!=="auto"&&(r.position!=="static"||jc(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"||yc.test(r.willChange)||r.webkitOverflowScrolling==="touch")}function Ia(e){let r=e.length;for(;r--;){const n=e[r];if(Ee(n,"Missing node"),Nc(n))return n}return null}function za(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Ra(e){const r=[];for(;e;)r.push(e),e=so(e);return r}function so(e){const{parentNode:r}=e;return r&&r instanceof ShadowRoot?r.host:r}const oo=1,lo=2,io=4,co=8,Cc=vc()==="coarse";let mt=[],tr=!1,Et=new Map,Xr=new Map;const br=new Set;function Sc(e,r,n,a,o){var s;const{ownerDocument:l}=r,i={direction:n,element:r,hitAreaMargins:a,setResizeHandlerState:o},d=(s=Et.get(l))!==null&&s!==void 0?s:0;return Et.set(l,d+1),br.add(i),Hr(),function(){var u;Xr.delete(e),br.delete(i);const m=(u=Et.get(l))!==null&&u!==void 0?u:1;if(Et.set(l,m-1),Hr(),m===1&&Et.delete(l),mt.includes(i)){const f=mt.indexOf(i);f>=0&&mt.splice(f,1),Yr(),o("up",!0,null)}}}function Tc(e){const{target:r}=e,{x:n,y:a}=qr(e);tr=!0,Zn({target:r,x:n,y:a}),Hr(),mt.length>0&&(Or("down",e),Yr(),e.preventDefault(),ho(r)||e.stopImmediatePropagation())}function un(e){const{x:r,y:n}=qr(e);if(tr&&e.type!=="pointerleave"&&e.buttons===0&&(tr=!1,Or("up",e)),!tr){const{target:a}=e;Zn({target:a,x:r,y:n})}Or("move",e),Yr(),mt.length>0&&e.preventDefault()}function mn(e){const{target:r}=e,{x:n,y:a}=qr(e);Xr.clear(),tr=!1,mt.length>0&&(e.preventDefault(),ho(r)||e.stopImmediatePropagation()),Or("up",e),Zn({target:r,x:n,y:a}),Yr(),Hr()}function ho(e){let r=e;for(;r;){if(r.hasAttribute(Ve.resizeHandle))return!0;r=r.parentElement}return!1}function Zn({target:e,x:r,y:n}){mt.splice(0);let a=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(a=e),br.forEach(o=>{const{element:s,hitAreaMargins:l}=o,i=s.getBoundingClientRect(),{bottom:d,left:h,right:u,top:m}=i,f=Cc?l.coarse:l.fine;if(r>=h-f&&r<=u+f&&n>=m-f&&n<=d+f){if(a!==null&&document.contains(a)&&s!==a&&!s.contains(a)&&!a.contains(s)&&wc(a,s)>0){let g=a,v=!1;for(;g&&!g.contains(s);){if(kc(g.getBoundingClientRect(),i)){v=!0;break}g=g.parentElement}if(v)return}mt.push(o)}})}function pn(e,r){Xr.set(e,r)}function Yr(){let e=!1,r=!1;mt.forEach(a=>{const{direction:o}=a;o==="horizontal"?e=!0:r=!0});let n=0;Xr.forEach(a=>{n|=a}),e&&r?hn("intersection",n):e?hn("horizontal",n):r?hn("vertical",n):bc()}let fn;function Hr(){var e;(e=fn)===null||e===void 0||e.abort(),fn=new AbortController;const r={capture:!0,signal:fn.signal};br.size&&(tr?(mt.length>0&&Et.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("contextmenu",mn,r),o.addEventListener("pointerleave",un,r),o.addEventListener("pointermove",un,r))}),Et.forEach((n,a)=>{const{body:o}=a;o.addEventListener("pointerup",mn,r),o.addEventListener("pointercancel",mn,r)})):Et.forEach((n,a)=>{const{body:o}=a;n>0&&(o.addEventListener("pointerdown",Tc,r),o.addEventListener("pointermove",un,r))}))}function Or(e,r){br.forEach(n=>{const{setResizeHandlerState:a}=n,o=mt.includes(n);a(e,o,r)})}function Ec(){const[e,r]=c.useState(0);return c.useCallback(()=>r(n=>n+1),[])}function Ee(e,r){if(!e)throw console.error(r),Error(r)}function Ht(e,r,n=Xn){return e.toFixed(n)===r.toFixed(n)?0:e>r?1:-1}function kt(e,r,n=Xn){return Ht(e,r,n)===0}function lt(e,r,n){return Ht(e,r,n)===0}function Lc(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(!lt(o,s,n))return!1}return!0}function Qt({panelConstraints:e,panelIndex:r,size:n}){const a=e[r];Ee(a!=null,`Panel constraints not found for index ${r}`);let{collapsedSize:o=0,collapsible:s,maxSize:l=100,minSize:i=0}=a;if(Ht(n,i)<0)if(s){const d=(o+i)/2;Ht(n,d)<0?n=o:n=i}else n=i;return n=Math.min(l,n),n=parseFloat(n.toFixed(Xn)),n}function mr({delta:e,initialLayout:r,panelConstraints:n,pivotIndices:a,prevLayout:o,trigger:s}){if(lt(e,0))return r;const l=[...r],[i,d]=a;Ee(i!=null,"Invalid first pivot index"),Ee(d!=null,"Invalid second pivot index");let h=0;if(s==="keyboard"){{const m=e<0?d:i,f=n[m];Ee(f,`Panel constraints not found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:v=0}=f;if(g){const b=r[m];if(Ee(b!=null,`Previous layout not found for panel index ${m}`),lt(b,p)){const x=v-b;Ht(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}{const m=e<0?i:d,f=n[m];Ee(f,`No panel constraints found for index ${m}`);const{collapsedSize:p=0,collapsible:g,minSize:v=0}=f;if(g){const b=r[m];if(Ee(b!=null,`Previous layout not found for panel index ${m}`),lt(b,v)){const x=b-p;Ht(x,Math.abs(e))>0&&(e=e<0?0-x:x)}}}}{const m=e<0?1:-1;let f=e<0?d:i,p=0;for(;;){const v=r[f];Ee(v!=null,`Previous layout not found for panel index ${f}`);const x=Qt({panelConstraints:n,panelIndex:f,size:100})-v;if(p+=x,f+=m,f<0||f>=n.length)break}const g=Math.min(Math.abs(e),Math.abs(p));e=e<0?0-g:g}{let f=e<0?i:d;for(;f>=0&&f<n.length;){const p=Math.abs(e)-Math.abs(h),g=r[f];Ee(g!=null,`Previous layout not found for panel index ${f}`);const v=g-p,b=Qt({panelConstraints:n,panelIndex:f,size:v});if(!lt(g,b)&&(h+=g-b,l[f]=b,h.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?f--:f++}}if(Lc(o,l))return o;{const m=e<0?d:i,f=r[m];Ee(f!=null,`Previous layout not found for panel index ${m}`);const p=f+h,g=Qt({panelConstraints:n,panelIndex:m,size:p});if(l[m]=g,!lt(g,p)){let v=p-g,x=e<0?d:i;for(;x>=0&&x<n.length;){const j=l[x];Ee(j!=null,`Previous layout not found for panel index ${x}`);const y=j+v,w=Qt({panelConstraints:n,panelIndex:x,size:y});if(lt(j,w)||(v-=w-j,l[x]=w),lt(v,0))break;e>0?x--:x++}}}const u=l.reduce((m,f)=>f+m,0);return lt(u,100)?l:o}function Pc({layout:e,panelsArray:r,pivotIndices:n}){let a=0,o=100,s=0,l=0;const i=n[0];Ee(i!=null,"No pivot index found"),r.forEach((m,f)=>{const{constraints:p}=m,{maxSize:g=100,minSize:v=0}=p;f===i?(a=v,o=g):(s+=v,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 vr(e,r=document){return Array.from(r.querySelectorAll(`[${Ve.resizeHandleId}][data-panel-group-id="${e}"]`))}function uo(e,r,n=document){const o=vr(e,n).findIndex(s=>s.getAttribute(Ve.resizeHandleId)===r);return o??null}function mo(e,r,n){const a=uo(e,r,n);return a!=null?[a,a+1]:[-1,-1]}function Ic(e){return e instanceof HTMLElement?!0:typeof e=="object"&&e!==null&&"tagName"in e&&"getAttribute"in e}function po(e,r=document){if(Ic(r)&&r.dataset.panelGroupId==e)return r;const n=r.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return n||null}function Zr(e,r=document){const n=r.querySelector(`[${Ve.resizeHandleId}="${e}"]`);return n||null}function zc(e,r,n,a=document){var o,s,l,i;const d=Zr(r,a),h=vr(e,a),u=d?h.indexOf(d):-1,m=(o=(s=n[u])===null||s===void 0?void 0:s.id)!==null&&o!==void 0?o:null,f=(l=(i=n[u+1])===null||i===void 0?void 0:i.id)!==null&&l!==void 0?l:null;return[m,f]}function Rc({committedValuesRef:e,eagerValuesRef:r,groupId:n,layout:a,panelDataArray:o,panelGroupElement:s,setLayout:l}){c.useRef({didWarnAboutMissingResizeHandle:!1}),Gt(()=>{if(!s)return;const i=vr(n,s);for(let d=0;d<o.length-1;d++){const{valueMax:h,valueMin:u,valueNow:m}=Pc({layout:a,panelsArray:o,pivotIndices:[d,d+1]}),f=i[d];if(f!=null){const p=o[d];Ee(p,`No panel data found for index "${d}"`),f.setAttribute("aria-controls",p.id),f.setAttribute("aria-valuemax",""+Math.round(h)),f.setAttribute("aria-valuemin",""+Math.round(u)),f.setAttribute("aria-valuenow",m!=null?""+Math.round(m):"")}}return()=>{i.forEach((d,h)=>{d.removeAttribute("aria-controls"),d.removeAttribute("aria-valuemax"),d.removeAttribute("aria-valuemin"),d.removeAttribute("aria-valuenow")})}},[n,a,o,s]),c.useEffect(()=>{if(!s)return;const i=r.current;Ee(i,"Eager values not found");const{panelDataArray:d}=i,h=po(n,s);Ee(h!=null,`No group found for id "${n}"`);const u=vr(n,s);Ee(u,`No resize handles found for group id "${n}"`);const m=u.map(f=>{const p=f.getAttribute(Ve.resizeHandleId);Ee(p,"Resize handle element has no handle id attribute");const[g,v]=zc(n,p,d,s);if(g==null||v==null)return()=>{};const b=x=>{if(!x.defaultPrevented)switch(x.key){case"Enter":{x.preventDefault();const j=d.findIndex(y=>y.id===g);if(j>=0){const y=d[j];Ee(y,`No panel data found for index ${j}`);const w=a[j],{collapsedSize:k=0,collapsible:N,minSize:C=0}=y.constraints;if(w!=null&&N){const E=mr({delta:lt(w,k)?C-k:k-w,initialLayout:a,panelConstraints:d.map(z=>z.constraints),pivotIndices:mo(n,p,s),prevLayout:a,trigger:"keyboard"});a!==E&&l(E)}}break}}};return f.addEventListener("keydown",b),()=>{f.removeEventListener("keydown",b)}});return()=>{m.forEach(f=>f())}},[s,e,r,n,a,o,l])}function Aa(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 fo(e,r){const n=e==="horizontal",{x:a,y:o}=qr(r);return n?a:o}function Ac(e,r,n,a,o){const s=n==="horizontal",l=Zr(r,o);Ee(l,`No resize handle element found for id "${r}"`);const i=l.getAttribute(Ve.groupId);Ee(i,"Resize handle element has no group id attribute");let{initialCursorPosition:d}=a;const h=fo(n,e),u=po(i,o);Ee(u,`No group element found for id "${i}"`);const m=u.getBoundingClientRect(),f=s?m.width:m.height;return(h-d)/f*100}function _c(e,r,n,a,o,s){if(ro(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:Ac(e,r,n,a,s)}function Mc({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];Ee(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];Ee(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 Kt(e,r,n){r.forEach((a,o)=>{const s=e[o];Ee(s,`Panel data not found for index ${o}`);const{callbacks:l,constraints:i,id:d}=s,{collapsedSize:h=0,collapsible:u}=i,m=n[d];if(m==null||a!==m){n[d]=a;const{onCollapse:f,onExpand:p,onResize:g}=l;g&&g(a,m),u&&(f||p)&&(p&&(m==null||kt(m,h))&&!kt(a,h)&&p(),f&&(m==null||!kt(m,h))&&kt(a,h)&&f())}})}function Lr(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 $c({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 Dc(e,r=10){let n=null;return(...o)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{e(...o)},r)}}function _a(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 go(e){return`react-resizable-panels:${e}`}function xo(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 bo(e,r){try{const n=go(e),a=r.getItem(n);if(a){const o=JSON.parse(a);if(typeof o=="object"&&o!=null)return o}}catch{}return null}function Bc(e,r,n){var a,o;const s=(a=bo(e,n))!==null&&a!==void 0?a:{},l=xo(r);return(o=s[l])!==null&&o!==void 0?o:null}function Gc(e,r,n,a,o){var s;const l=go(e),i=xo(r),d=(s=bo(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 Ma({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(!lt(a,100)&&n.length>0)for(let s=0;s<r.length;s++){const l=n[s];Ee(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];Ee(l!=null,`No layout data found for index ${s}`);const i=Qt({panelConstraints:r,panelIndex:s,size:l});l!=i&&(o+=l-i,n[s]=i)}if(!lt(o,0))for(let s=0;s<r.length;s++){const l=n[s];Ee(l!=null,`No layout data found for index ${s}`);const i=l+o,d=Qt({panelConstraints:r,panelIndex:s,size:i});if(l!==d&&(o-=d-l,n[s]=d,lt(o,0)))break}return n}const Fc=100,pr={getItem:e=>(_a(pr),pr.getItem(e)),setItem:(e,r)=>{_a(pr),pr.setItem(e,r)}},$a={};function vo({autoSaveId:e=null,children:r,className:n="",direction:a,forwardedRef:o,id:s=null,onLayout:l=null,keyboardResizeBy:i=null,storage:d=pr,style:h,tagName:u="div",...m}){const f=Yn(s),p=c.useRef(null),[g,v]=c.useState(null),[b,x]=c.useState([]),j=Ec(),y=c.useRef({}),w=c.useRef(new Map),k=c.useRef(0),N=c.useRef({autoSaveId:e,direction:a,dragState:g,id:f,keyboardResizeBy:i,onLayout:l,storage:d}),C=c.useRef({layout:b,panelDataArray:[],panelDataArrayChanged:!1});c.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),c.useImperativeHandle(o,()=>({getId:()=>N.current.id,getLayout:()=>{const{layout:T}=C.current;return T},setLayout:T=>{const{onLayout:O}=N.current,{layout:G,panelDataArray:L}=C.current,S=Ma({layout:T,panelConstraints:L.map(V=>V.constraints)});Aa(G,S)||(x(S),C.current.layout=S,O&&O(S),Kt(L,S,y.current))}}),[]),Gt(()=>{N.current.autoSaveId=e,N.current.direction=a,N.current.dragState=g,N.current.id=f,N.current.onLayout=l,N.current.storage=d}),Rc({committedValuesRef:N,eagerValuesRef:C,groupId:f,layout:b,panelDataArray:C.current.panelDataArray,setLayout:x,panelGroupElement:p.current}),c.useEffect(()=>{const{panelDataArray:T}=C.current;if(e){if(b.length===0||b.length!==T.length)return;let O=$a[e];O==null&&(O=Dc(Gc,Fc),$a[e]=O);const G=[...T],L=new Map(w.current);O(e,G,L,b,d)}},[e,b,d]),c.useEffect(()=>{});const E=c.useCallback(T=>{const{onLayout:O}=N.current,{layout:G,panelDataArray:L}=C.current;if(T.constraints.collapsible){const S=L.map(X=>X.constraints),{collapsedSize:V=0,panelSize:K,pivotIndices:le}=_t(L,T,G);if(Ee(K!=null,`Panel size not found for panel "${T.id}"`),!kt(K,V)){w.current.set(T.id,K);const ce=Xt(L,T)===L.length-1?K-V:V-K,re=mr({delta:ce,initialLayout:G,panelConstraints:S,pivotIndices:le,prevLayout:G,trigger:"imperative-api"});Lr(G,re)||(x(re),C.current.layout=re,O&&O(re),Kt(L,re,y.current))}}},[]),z=c.useCallback((T,O)=>{const{onLayout:G}=N.current,{layout:L,panelDataArray:S}=C.current;if(T.constraints.collapsible){const V=S.map(fe=>fe.constraints),{collapsedSize:K=0,panelSize:le=0,minSize:X=0,pivotIndices:ce}=_t(S,T,L),re=O??X;if(kt(le,K)){const fe=w.current.get(T.id),he=fe!=null&&fe>=re?fe:re,Re=Xt(S,T)===S.length-1?le-he:he-le,ie=mr({delta:Re,initialLayout:L,panelConstraints:V,pivotIndices:ce,prevLayout:L,trigger:"imperative-api"});Lr(L,ie)||(x(ie),C.current.layout=ie,G&&G(ie),Kt(S,ie,y.current))}}},[]),q=c.useCallback(T=>{const{layout:O,panelDataArray:G}=C.current,{panelSize:L}=_t(G,T,O);return Ee(L!=null,`Panel size not found for panel "${T.id}"`),L},[]),D=c.useCallback((T,O)=>{const{panelDataArray:G}=C.current,L=Xt(G,T);return $c({defaultSize:O,dragState:g,layout:b,panelData:G,panelIndex:L})},[g,b]),$=c.useCallback(T=>{const{layout:O,panelDataArray:G}=C.current,{collapsedSize:L=0,collapsible:S,panelSize:V}=_t(G,T,O);return Ee(V!=null,`Panel size not found for panel "${T.id}"`),S===!0&&kt(V,L)},[]),Q=c.useCallback(T=>{const{layout:O,panelDataArray:G}=C.current,{collapsedSize:L=0,collapsible:S,panelSize:V}=_t(G,T,O);return Ee(V!=null,`Panel size not found for panel "${T.id}"`),!S||Ht(V,L)>0},[]),Z=c.useCallback(T=>{const{panelDataArray:O}=C.current;O.push(T),O.sort((G,L)=>{const S=G.order,V=L.order;return S==null&&V==null?0:S==null?-1:V==null?1:S-V}),C.current.panelDataArrayChanged=!0,j()},[j]);Gt(()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:T,onLayout:O,storage:G}=N.current,{layout:L,panelDataArray:S}=C.current;let V=null;if(T){const le=Bc(T,S,G);le&&(w.current=new Map(Object.entries(le.expandToSizes)),V=le.layout)}V==null&&(V=Mc({panelDataArray:S}));const K=Ma({layout:V,panelConstraints:S.map(le=>le.constraints)});Aa(L,K)||(x(K),C.current.layout=K,O&&O(K),Kt(S,K,y.current))}}),Gt(()=>{const T=C.current;return()=>{T.layout=[]}},[]);const B=c.useCallback(T=>{let O=!1;const G=p.current;return G&&window.getComputedStyle(G,null).getPropertyValue("direction")==="rtl"&&(O=!0),function(S){S.preventDefault();const V=p.current;if(!V)return()=>null;const{direction:K,dragState:le,id:X,keyboardResizeBy:ce,onLayout:re}=N.current,{layout:fe,panelDataArray:he}=C.current,{initialLayout:ve}=le??{},Re=mo(X,T,V);let ie=_c(S,T,K,le,ce,V);const ye=K==="horizontal";ye&&O&&(ie=-ie);const Te=he.map(xe=>xe.constraints),W=mr({delta:ie,initialLayout:ve??fe,panelConstraints:Te,pivotIndices:Re,prevLayout:fe,trigger:ro(S)?"keyboard":"mouse-or-touch"}),ae=!Lr(fe,W);(no(S)||ao(S))&&k.current!=ie&&(k.current=ie,!ae&&ie!==0?ye?pn(T,ie<0?oo:lo):pn(T,ie<0?io:co):pn(T,0)),ae&&(x(W),C.current.layout=W,re&&re(W),Kt(he,W,y.current))}},[]),ee=c.useCallback((T,O)=>{const{onLayout:G}=N.current,{layout:L,panelDataArray:S}=C.current,V=S.map(fe=>fe.constraints),{panelSize:K,pivotIndices:le}=_t(S,T,L);Ee(K!=null,`Panel size not found for panel "${T.id}"`);const ce=Xt(S,T)===S.length-1?K-O:O-K,re=mr({delta:ce,initialLayout:L,panelConstraints:V,pivotIndices:le,prevLayout:L,trigger:"imperative-api"});Lr(L,re)||(x(re),C.current.layout=re,G&&G(re),Kt(S,re,y.current))},[]),oe=c.useCallback((T,O)=>{const{layout:G,panelDataArray:L}=C.current,{collapsedSize:S=0,collapsible:V}=O,{collapsedSize:K=0,collapsible:le,maxSize:X=100,minSize:ce=0}=T.constraints,{panelSize:re}=_t(L,T,G);re!=null&&(V&&le&&kt(re,S)?kt(S,K)||ee(T,K):re<ce?ee(T,ce):re>X&&ee(T,X))},[ee]),A=c.useCallback((T,O)=>{const{direction:G}=N.current,{layout:L}=C.current;if(!p.current)return;const S=Zr(T,p.current);Ee(S,`Drag handle element not found for id "${T}"`);const V=fo(G,O);v({dragHandleId:T,dragHandleRect:S.getBoundingClientRect(),initialCursorPosition:V,initialLayout:L})},[]),J=c.useCallback(()=>{v(null)},[]),R=c.useCallback(T=>{const{panelDataArray:O}=C.current,G=Xt(O,T);G>=0&&(O.splice(G,1),delete y.current[T.id],C.current.panelDataArrayChanged=!0,j())},[j]),Y=c.useMemo(()=>({collapsePanel:E,direction:a,dragState:g,expandPanel:z,getPanelSize:q,getPanelStyle:D,groupId:f,isPanelCollapsed:$,isPanelExpanded:Q,reevaluatePanelConstraints:oe,registerPanel:Z,registerResizeHandle:B,resizePanel:ee,startDragging:A,stopDragging:J,unregisterPanel:R,panelGroupElement:p.current}),[E,g,a,z,q,D,f,$,Q,oe,Z,B,ee,A,J,R]),H={display:"flex",flexDirection:a==="horizontal"?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return c.createElement(Kr.Provider,{value:Y},c.createElement(u,{...m,children:r,className:n,id:s,ref:p,style:{...H,...h},[Ve.group]:"",[Ve.groupDirection]:a,[Ve.groupId]:f}))}const ko=c.forwardRef((e,r)=>c.createElement(vo,{...e,forwardedRef:r}));vo.displayName="PanelGroup";ko.displayName="forwardRef(PanelGroup)";function Xt(e,r){return e.findIndex(n=>n===r||n.id===r.id)}function _t(e,r,n){const a=Xt(e,r),s=a===e.length-1?[a-1,a]:[a,a+1],l=n[a];return{...r.constraints,panelSize:l,pivotIndices:s}}function Hc({disabled:e,handleId:r,resizeHandler:n,panelGroupElement:a}){c.useEffect(()=>{if(e||n==null||a==null)return;const o=Zr(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(Ve.groupId);Ee(i,`No group element found for id "${i}"`);const d=vr(i,a),h=uo(i,r,a);Ee(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 wo({children:e=null,className:r="",disabled:n=!1,hitAreaMargins:a,id:o,onBlur:s,onClick:l,onDragging:i,onFocus:d,onPointerDown:h,onPointerUp:u,style:m={},tabIndex:f=0,tagName:p="div",...g}){var v,b;const x=c.useRef(null),j=c.useRef({onClick:l,onDragging:i,onPointerDown:h,onPointerUp:u});c.useEffect(()=>{j.current.onClick=l,j.current.onDragging=i,j.current.onPointerDown=h,j.current.onPointerUp=u});const y=c.useContext(Kr);if(y===null)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:w,groupId:k,registerResizeHandle:N,startDragging:C,stopDragging:E,panelGroupElement:z}=y,q=Yn(o),[D,$]=c.useState("inactive"),[Q,Z]=c.useState(!1),[B,ee]=c.useState(null),oe=c.useRef({state:D});Gt(()=>{oe.current.state=D}),c.useEffect(()=>{if(n)ee(null);else{const Y=N(q);ee(()=>Y)}},[n,q,N]);const A=(v=a==null?void 0:a.coarse)!==null&&v!==void 0?v:15,J=(b=a==null?void 0:a.fine)!==null&&b!==void 0?b:5;c.useEffect(()=>{if(n||B==null)return;const Y=x.current;Ee(Y,"Element ref not attached");let H=!1;return Sc(q,Y,w,{coarse:A,fine:J},(O,G,L)=>{if(!G){$("inactive");return}switch(O){case"down":{$("drag"),H=!1,Ee(L,'Expected event to be defined for "down" action'),C(q,L);const{onDragging:S,onPointerDown:V}=j.current;S==null||S(!0),V==null||V();break}case"move":{const{state:S}=oe.current;H=!0,S!=="drag"&&$("hover"),Ee(L,'Expected event to be defined for "move" action'),B(L);break}case"up":{$("hover"),E();const{onClick:S,onDragging:V,onPointerUp:K}=j.current;V==null||V(!1),K==null||K(),H||S==null||S();break}}})},[A,w,n,J,N,q,B,C,E]),Hc({disabled:n,handleId:q,resizeHandler:B,panelGroupElement:z});const R={touchAction:"none",userSelect:"none"};return c.createElement(p,{...g,children:e,className:r,id:o,onBlur:()=>{Z(!1),s==null||s()},onFocus:()=>{Z(!0),d==null||d()},ref:x,role:"separator",style:{...R,...m},tabIndex:f,[Ve.groupDirection]:w,[Ve.groupId]:k,[Ve.resizeHandle]:"",[Ve.resizeHandleActive]:D==="drag"?"pointer":Q?"keyboard":void 0,[Ve.resizeHandleEnabled]:!n,[Ve.resizeHandleId]:q,[Ve.resizeHandleState]:D})}wo.displayName="PanelResizeHandle";var Oc=Object.defineProperty,Wc=Object.getOwnPropertyNames,Ge=(e,r)=>function(){return e&&(r=(0,e[Wc(e)[0]])(e=0)),r},Uc=(e,r)=>{for(var n in r)Oc(e,n,{get:r[n],enumerable:!0})};function Qe(...e){return pc(Bs(e))}var It=Ge({"src/components/graph-ui/utils.ts"(){}});function kr({asChild:e=!1,className:r,size:n,variant:a,...o}){const s=e?_s:"button";return t.jsx(s,{"data-slot":"button",className:Qe(yo({variant:a,size:n,className:r})),...o})}var yo,Jr=Ge({"src/components/graph-ui/Button.tsx"(){It(),yo=wr("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 jo(...e){return e.filter(Boolean).join(" ")}function En({className:e,...r}){return t.jsx(ko,{"data-slot":"resizable-panel-group",className:jo("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",e),...r})}function er({...e}){return t.jsx(to,{"data-slot":"resizable-panel",...e})}function Ln({withHandle:e,className:r,...n}){return t.jsx(wo,{"data-slot":"resizable-handle",className:jo("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(M.GripVerticalIcon,{className:"size-2.5"})}):null})}var No=Ge({"src/components/graph-workspace/GraphResizablePanels.tsx"(){}});function Jn(...e){return e.filter(Boolean).join(" ")}function yr({...e}){return t.jsx(Gi,{"data-slot":"accordion",...e})}function jr({className:e,...r}){return t.jsx(Fi,{"data-slot":"accordion-item",className:Jn("border-b last:border-b-0",e),...r})}function Qr({className:e,children:r,...n}){return t.jsx(Oi,{className:"flex",children:t.jsxs(Wi,{"data-slot":"accordion-trigger",className:Jn("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(M.ChevronDownIcon,{className:"pointer-events-none size-4 shrink-0 translate-y-0.5 text-[var(--theme-fg-muted)] transition-transform duration-200"})]})})}function Nr({className:e,children:r,...n}){return t.jsx(Hi,{"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:Jn("pb-4 pt-0",e),children:r})})}var Cr=Ge({"src/components/graph-workspace/GraphAccordion.tsx"(){}});function Vc(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 Kc(e){return e.trim().replace(/^\/+|\/+$/g,"").replace(/[^\w.-]+/g,"-").replace(/^-+|-+$/g,"").toLowerCase()}function Sr(e){var r;return((r=e.split(".").pop())==null?void 0:r.toLowerCase())||""}function qc(e){return e.split("/").filter(Boolean).at(-1)??e}function Yt(e){const r=e.kind==="directory"?"directory":"file",n=(e.children??[]).map(Yt);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 Co(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=Co(l,r,n,a);return i!==l&&(o=!0),i});return o?{...e,children:s}:e}function So(e){if(e.kind==="file")return e;for(const r of e.children){const n=So(r);if(n)return n}return null}function Pn(e,r){if(!e||r===null)return null;if(e.path===r)return e;for(const n of e.children){const a=Pn(n,r);if(a)return a}return null}function To(e){return e.trim().replace(/\\/g,"/").replace(/^\.\/+/,"").replace(/^\/+/,"")}function Xc(e){const n=To(e).split("/").filter(Boolean);n.pop();const a=[];let o="";for(const s of n)o=o?`${o}/${s}`:s,a.push(o);return a}function In(e,r,n){if(e.path===r)return n;if(e.children.length===0)return e;let a=!1;const o=e.children.map(s=>{const l=In(s,r,n);return l!==s&&(a=!0),l});return a?{...e,children:o}:e}function zn(e,r){return!e||!r?!1:e.path===r?!0:e.children.some(n=>zn(n,r))}function Yc(e){if(!e)return null;const r=Sr(e.path);return Qn.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 Yc(e){const r=Cr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Zc(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 Jc(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;Zc(e,a).children.push({...n,name:n.name||o,path:r})}function Qc(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function To(e){e.children.sort(Qc);for(const r of e.children)To(r);return e}function Da(e,r,n,a){var u;const o={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},s={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=Vc(f)||m.id;s.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),v=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,b="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:v,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:Kc(v),path:v,kind:"event",item:f,preview:b,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}Jc(l,v.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),To(o)}function eh(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 Eo(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=Eo(r);if(n)return n}return null}function Ba(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 Qn,Lo,Po,ea=Ge({"src/components/graph-workspace/workspaceTree.ts"(){Qn=new Set(["xyz","extxyz","cif","pdb"]),Lo=new Set(["png","jpg","jpeg","gif","webp","svg"]),Po=new Set(["pdf"])}});function Zt({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 zo=Ge({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function th({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(ld,{"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 rh=Ge({"src/components/graph-ui/Separator.tsx"(){zt()}});function nh({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:Qe(Io({orientation:r}),e),...n})}function ah({className:e,orientation:r="vertical",...n}){return t.jsx(th,{"data-slot":"button-group-separator",orientation:r,className:Qe("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Io,Ro=Ge({"src/components/graph-ui/ButtonGroup.tsx"(){rh(),zt(),Io=kr("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 sh({delayDuration:e=0,...r}){return t.jsx(id,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function oh({...e}){return t.jsx(sh,{children:t.jsx(rd,{"data-slot":"tooltip",...e})})}function lh({...e}){return t.jsx(nd,{"data-slot":"tooltip-trigger",...e})}function ih({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(ad,{children:t.jsxs(sd,{"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(od,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var dh=Ge({"src/components/graph-ui/Tooltip.tsx"(){zt()}});function ch(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ga(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 Xe({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(oh,{children:[t.jsx(lh,{asChild:!0,children:t.jsx(vr,{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(ih,{children:t.jsx("p",{children:n})})]})}function Rn({children:e,className:r=""}){return t.jsx(nh,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var Ao=Ge({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Yr(),Ro(),dh()}});function hh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Rn,{children:[t.jsx(Xe,{label:"Distance",children:t.jsx(M.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Xe,{label:"Connectivity",children:t.jsx(M.Share2,{className:"size-4"})}),t.jsx(Xe,{label:"Angle",children:t.jsx(M.Waypoints,{className:"size-4"})}),t.jsx(Xe,{label:"Dihedral",children:t.jsx(M.Spline,{className:"size-4"})}),t.jsx(Xe,{label:"Add dummy atoms",children:t.jsx(M.Bubbles,{className:"size-4"})}),t.jsx(Xe,{label:"Delete atoms",children:t.jsx(M.CircleX,{className:"size-4"})}),t.jsx(Xe,{label:"Rotate",children:t.jsx(M.Rotate3d,{className:"size-4"})})]}),t.jsxs(Rn,{children:[t.jsx(Xe,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(M.Boxes,{className:"size-4"})}),t.jsx(Xe,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(M.Trash2,{className:"size-4"})}),t.jsx(Xe,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(M.Send,{className:"size-4"})}),t.jsx(Xe,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(M.Box,{className:"size-4"})}),t.jsx(Xe,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(M.Eraser,{className:"size-4"})}),t.jsx(Xe,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(M.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(v=>`${i[v]??"Atom"}(${v})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var uh=Ge({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){Ao()}});function mh({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=ch(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ga(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ga(r,`${i}_trajectory.${l||"xyz"}`)}function m(){o.current&&(o.current.zoom(1.2),o.current.render())}function f(){o.current&&(o.current.zoom(.8),o.current.render())}function p(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Rn,{className:"ml-auto justify-end",children:[t.jsx(Xe,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(M.Copy,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(M.Download,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(M.Box,{className:"size-3.5"})}),t.jsx(Xe,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(M.Camera,{className:"size-3.5"})}),t.jsx(ah,{className:"thread-graph-molecule-button-divider"}),t.jsx(Xe,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(M.ZoomIn,{className:"size-3.5"})}),t.jsx(Xe,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(M.ZoomOut,{className:"size-3.5"})}),t.jsx(Xe,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(M.RotateCcw,{className:"size-3.5"})})]})}var ph=Ge({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Ro(),Ao()}});async function fh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:(_r||(_r=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)})),_r)}var _r,gh=Ge({"src/components/graph-workspace/load3Dmol.ts"(){_r=null}});function xh({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(Ji,{"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(Qi,{"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(ed,{"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(td,{"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 bh=Ge({"src/components/graph-ui/Slider.tsx"(){zt()}});function vh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function kh(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 Zc(e){const r=Sr(e);return r==="tsx"||r==="jsx"?"tsx":r==="yml"?"yaml":r||"text"}function Jc(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 Qc(e,r,n){const a=r.split("/").filter(Boolean),o=a.pop()??n.name;Jc(e,a).children.push({...n,name:n.name||o,path:r})}function eh(e,r){return e.kind==="directory"&&r.kind!=="directory"?-1:e.kind!=="directory"&&r.kind==="directory"?1:e.name.localeCompare(r.name)}function Eo(e){e.children.sort(eh);for(const r of e.children)Eo(r);return e}function Da(e,r,n,a){var u;const o={id:"root",name:e.workspace.label??"Workspace",path:"",kind:"directory",children:[]},s={id:"artifacts",name:"artifacts",path:"artifacts",kind:"directory",children:[]};for(const m of r){const f=m.title||m.id,p=Kc(f)||m.id;s.children.push({id:`artifact:${m.id}`,name:`${p}.artifact`,path:`artifacts/${p}.artifact`,kind:"artifact",artifact:m,preview:m.summaryText??m.type,detail:JSON.stringify(m.payload,null,2),children:[]})}const l={id:"thread-events",name:"thread-events",path:"thread-events",kind:"directory",children:[]},i={id:"live",name:"live",path:"live",kind:"directory",children:[]};let d=0;const h=(m,f,p=!1)=>{d+=1;const g=f.kind.replace(/([A-Z])/g,"-$1").toLowerCase(),v=`${p?"live":`thread-events/${m}`}/${String(d).padStart(3,"0")}-${g}.json`,b="text"in f&&typeof f.text=="string"?f.text.slice(0,160):f.kind,x=f.kind==="artifact"&&f.artifact?f.artifact:null,j=x&&p?{id:`live-artifact:${x.id}`,name:x.title||x.id,path:v,kind:"live-artifact",artifact:x,item:f,preview:x.summaryText??x.type,detail:JSON.stringify(x.payload,null,2),children:[]}:{id:`event:${f.id}`,name:qc(v),path:v,kind:"event",item:f,preview:b,detail:JSON.stringify(f,null,2),children:[]};if(p){i.children.push(j);return}Qc(l,v.replace(/^thread-events\//,""),j)};for(const m of e.turns)for(const f of m.items)(f.kind==="commandExecution"||f.kind==="webSearch"||f.kind==="fileRead"||f.kind==="fileChange"||f.kind==="agentToolCall"||f.kind==="skillToolCall"||f.kind==="toolCall"||f.kind==="hook"||f.kind==="plan"||f.kind==="reasoning")&&h(m.id,f);for(const m of((u=e.liveItems)==null?void 0:u.items)??[])h(e.thread.activeTurnId??"live",m,!0);return o.children.push(s,l,i),Eo(o)}function th(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 Lo(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=Lo(r);if(n)return n}return null}function Ba(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 Qn,Po,Io,ea=Ge({"src/components/graph-workspace/workspaceTree.ts"(){Qn=new Set(["xyz","extxyz","cif","pdb"]),Po=new Set(["png","jpg","jpeg","gif","webp","svg"]),Io=new Set(["pdf"])}});function Zt({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 zo=Ge({"src/components/graph-workspace/GraphWorkspaceCards.tsx"(){}});function rh({className:e,decorative:r=!0,orientation:n="horizontal",...a}){return t.jsx(id,{"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 nh=Ge({"src/components/graph-ui/Separator.tsx"(){It()}});function ah({className:e,orientation:r,...n}){return t.jsx("div",{role:"group","data-slot":"button-group","data-orientation":r,className:Qe(Ro({orientation:r}),e),...n})}function sh({className:e,orientation:r="vertical",...n}){return t.jsx(rh,{"data-slot":"button-group-separator",orientation:r,className:Qe("relative !m-0 self-stretch bg-input data-[orientation=vertical]:h-auto",e),...n})}var Ro,Ao=Ge({"src/components/graph-ui/ButtonGroup.tsx"(){nh(),It(),Ro=wr("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 oh({delayDuration:e=0,...r}){return t.jsx(dd,{"data-slot":"tooltip-provider",delayDuration:e,...r})}function lh({...e}){return t.jsx(oh,{children:t.jsx(nd,{"data-slot":"tooltip",...e})})}function ih({...e}){return t.jsx(ad,{"data-slot":"tooltip-trigger",...e})}function dh({children:e,className:r,sideOffset:n=0,...a}){return t.jsx(sd,{children:t.jsxs(od,{"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(ld,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}var ch=Ge({"src/components/graph-ui/Tooltip.tsx"(){It()}});function hh(e){return(e==null?void 0:e.trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,""))||"molecule"}function Ga(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 Xe({children:e,disabled:r,label:n,onClick:a}){return t.jsxs(lh,{children:[t.jsx(ih,{asChild:!0,children:t.jsx(kr,{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(dh,{children:t.jsx("p",{children:n})})]})}function Rn({children:e,className:r=""}){return t.jsx(ah,{className:`thread-graph-molecule-button-group ${r}`,children:e})}var _o=Ge({"src/components/graph-workspace/GraphMoleculeViewerControls.tsx"(){Jr(),Ao(),ch()}});function uh({cameraInfo:e,onClearSelection:r,onClearStaged:n,onSendSelection:a,onSendStaged:o,onStageSelection:s,onToggleUnitCell:l,selectedAtomLabels:i,selectedSerials:d,stagedAtoms:h,stagedMolecules:u,unitCellAvailable:m,unitCellVisible:f}){const p=d.length>0,g=h>0;return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex w-full justify-between gap-2 overflow-x-auto",children:[t.jsxs(Rn,{children:[t.jsx(Xe,{label:"Distance",children:t.jsx(M.AlignVerticalDistributeCenter,{className:"size-4"})}),t.jsx(Xe,{label:"Connectivity",children:t.jsx(M.Share2,{className:"size-4"})}),t.jsx(Xe,{label:"Angle",children:t.jsx(M.Waypoints,{className:"size-4"})}),t.jsx(Xe,{label:"Dihedral",children:t.jsx(M.Spline,{className:"size-4"})}),t.jsx(Xe,{label:"Add dummy atoms",children:t.jsx(M.Bubbles,{className:"size-4"})}),t.jsx(Xe,{label:"Delete atoms",children:t.jsx(M.CircleX,{className:"size-4"})}),t.jsx(Xe,{label:"Rotate",children:t.jsx(M.Rotate3d,{className:"size-4"})})]}),t.jsxs(Rn,{children:[t.jsx(Xe,{label:f?"Hide unit cell":"Show unit cell",disabled:!m,onClick:l,children:t.jsx(M.Boxes,{className:"size-4"})}),t.jsx(Xe,{label:"Clear selection",disabled:!p,onClick:r,children:t.jsx(M.Trash2,{className:"size-4"})}),t.jsx(Xe,{label:"Send selection",disabled:!p,onClick:a,children:t.jsx(M.Send,{className:"size-4"})}),t.jsx(Xe,{label:"Stage current selection",disabled:!p,onClick:s,children:t.jsx(M.Box,{className:"size-4"})}),t.jsx(Xe,{label:"Clear staged selections",disabled:!g,onClick:n,children:t.jsx(M.Eraser,{className:"size-4"})}),t.jsx(Xe,{label:"Send staged selections",disabled:!g,onClick:o,children:t.jsx(M.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(v=>`${i[v]??"Atom"}(${v})`).join(", "):"None"]}),t.jsxs("div",{children:["Staged: ",u," molecule(s), ",h," atom(s)"]})]})]}):null]})}var mh=Ge({"src/components/graph-workspace/GraphMoleculeViewerLowerButtonGroup.tsx"(){_o()}});function ph({currentIndex:e,exportContent:r,moleculeId:n,onScreenshot:a,viewerRef:o,xyzContent:s,xyzFormat:l}){const i=hh(n);async function d(){s&&await navigator.clipboard.writeText(s)}function h(){s&&Ga(s,`${i}_step_${e+1}.${l||"xyz"}`)}function u(){r&&Ga(r,`${i}_trajectory.${l||"xyz"}`)}function m(){o.current&&(o.current.zoom(1.2),o.current.render())}function f(){o.current&&(o.current.zoom(.8),o.current.render())}function p(){o.current&&(o.current.zoomTo(),o.current.setCameraParameters({}),o.current.render())}return t.jsxs(Rn,{className:"ml-auto justify-end",children:[t.jsx(Xe,{label:"Copy current structure",onClick:()=>void d(),disabled:!s,children:t.jsx(M.Copy,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download current structure",onClick:h,disabled:!s,children:t.jsx(M.Download,{className:"size-3.5"})}),t.jsx(Xe,{label:"Download full trajectory",onClick:u,disabled:!r,children:t.jsx(M.Box,{className:"size-3.5"})}),t.jsx(Xe,{label:"Copy screenshot",onClick:a,disabled:!o.current||!s,children:t.jsx(M.Camera,{className:"size-3.5"})}),t.jsx(sh,{className:"thread-graph-molecule-button-divider"}),t.jsx(Xe,{label:"Zoom in",onClick:m,disabled:!o.current||!s,children:t.jsx(M.ZoomIn,{className:"size-3.5"})}),t.jsx(Xe,{label:"Zoom out",onClick:f,disabled:!o.current||!s,children:t.jsx(M.ZoomOut,{className:"size-3.5"})}),t.jsx(Xe,{label:"Reset camera",onClick:p,disabled:!o.current||!s,children:t.jsx(M.RotateCcw,{className:"size-3.5"})})]})}var fh=Ge({"src/components/graph-workspace/GraphMoleculeViewerUpperButtonGroup.tsx"(){Ao(),_o()}});async function gh(){if(typeof window>"u")throw new Error("3Dmol is only available in a browser environment.");return window["3Dmol"]?window["3Dmol"]:($r||($r=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)})),$r)}var $r,xh=Ge({"src/components/graph-workspace/load3Dmol.ts"(){$r=null}});function bh({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(Qi,{"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(ed,{"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(td,{"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(rd,{"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 vh=Ge({"src/components/graph-ui/Slider.tsx"(){It()}});function kh(e){const r=e==null?void 0:e.trim().toLowerCase();return!r||r==="extxyz"?"xyz":r}function wh(e){var o,s;const r=e.replace(/\r\n/g,`
|
|
5
5
|
`).replace(/\r/g,`
|
|
6
6
|
`).split(`
|
|
7
7
|
`),n=[];let a=0;for(;a<r.length;){for(;a<r.length&&((o=r[a])==null?void 0:o.trim())==="";)a+=1;if(a>=r.length)break;const l=Number.parseInt(((s=r[a])==null?void 0:s.trim())??"",10);if(!Number.isFinite(l)||l<0)return[e];const i=l+2;if(a+i>r.length)return[e];n.push(`${r.slice(a,a+i).join(`
|
|
8
8
|
`)}
|
|
9
|
-
`),a+=i}return n.length>0?n:[e]}function Fa(e,r){return r!=="xyz"?e:e.flatMap(n=>
|
|
10
|
-
`).join("")}function
|
|
11
|
-
`).slice(2).map(X=>X.trim()).filter(Boolean).map(X=>X.split(/\s+/)[0]??"Atom");h.current||(L.zoomTo(),h.current=!0),S.setClickable({},!0,(X,ce,re)=>{const fe=X.serial??X.index;if(fe===void 0)return;const he=X.atom||X.elem||le[fe]||"Atom";N(ve=>{const ie=!!(re!=null&&re.shiftKey||re!=null&&re.metaKey||re!=null&&re.ctrlKey)?ve.includes(fe)?ve.filter(ye=>ye!==fe):[...ve,fe]:ve.length===1&&ve[0]===fe?[]:[fe];return w(ye=>{if(ie.length===0)return{};const Te={};return ie.forEach(
|
|
12
|
-
`).length<=Mo}function Sh(e){return e&&(e.node.path||e.node.name)||null}function Th(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 Eh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[v,b]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,w=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,k=Xc(i??null),N=(i==null?void 0:i.language)||Yc((i==null?void 0:i.path)??""),C=i?Cr(i.path):"",E=Sh(u),I=i!==null&&Qn.has(C),q=!!(i&&a)&&!I&&Ch(i),D=(u==null?void 0:u.kind)==="live-molecule",$=!!(y!=null&&y.artifact&&w),Q=!!k||$;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),b(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function Z(){if(!(!i||!a)){j(!0),b(null);try{await a({path:i.path,content:p}),f(!1)}catch(B){b(B instanceof Error?B.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),E?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:E}):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(M.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&k?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(jh,{source:k,moleculeId:k.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[I?"molecule":N||C||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),q?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),b(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(M.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void Z(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(M.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),b(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(M.Pencil,{className:"h-4 w-4"})})}):null]}),v?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:v}):null,m?t.jsx("textarea",{value:p,onChange:B=>g(B.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Mr,{content:i.content}),i.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:Q||D?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:w}):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(Zt,{label:"Workspace Data",children:t.jsx(Mr,{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(Mr,{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 _o,Mo,Mr,Lh=Ge({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){ea(),zo(),Nh(),_o=50*1024,Mo=1e3,Mr=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 Ph({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 zh=Ge({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function $o(e){return`${Bo}${e.workspaceId??"workspace"}:${e.threadId}`}function Ih(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem($o(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Oa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem($o(e),JSON.stringify([...r]))}catch{}}function An(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>An(s,n.get(s.path)??null)),o=e.childrenLoaded&&e.children.length>0;return{...e,children:o||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Ua(e,r){if(e.kind==="directory")return r?t.jsx(M.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(M.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Cr(e.name);return n==="zip"?t.jsx(M.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(M.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(M.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(M.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Do({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(M.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(M.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Ua(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(M.Download,{className:"h-3.5 w-3.5"})}):null,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(v=>t.jsx(Do,{depth:e+1,expandedPaths:r,loadingPaths:n,node:v,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},v.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Ua(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(M.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(M.Download,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Rh({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(M.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 Ah({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:v,selectedNodeId:b,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(w=>w.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const w=v.current;w&&(w.scrollTop=g.current)},[v,g]),t.jsxs("aside",{className:`${Go} flex flex-col`,children:[t.jsxs("div",{className:Fo,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Ho,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:Oo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(M.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:Dr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(M.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Dr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(M.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Dr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(M.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:v,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:w=>{g.current=w.currentTarget.scrollTop},children:[t.jsx(Rh,{liveNodes:j??[],onSelect:m,selectedNodeId:b}),t.jsx("div",{className:Uo,children:"Workspace"}),t.jsx(Do,{depth:0,expandedPaths:a,loadingPaths:o,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:b}),y.children.length===0?t.jsx("p",{className:Wo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function _h({activeView:e,detail:r,artifacts:n,plugins:a,status:o,focusPathRequest:s,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Da(r,n),[e,i,n,r,o,l]),u=i??h??Da(r,n),m=c.useMemo(()=>eh(u),[u]),f=c.useMemo(()=>{var P;return((P=u.children.find(_=>_.path==="live"))==null?void 0:P.children)??[]},[u]),p=Eo(u),[g,v]=c.useState(()=>(p==null?void 0:p.id)??null),[b,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Ba((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[w,k]=c.useState(null),[N,C]=c.useState(!1),[E,I]=c.useState(()=>new Set),[q,D]=c.useState(!1),[$,Q]=c.useState(!1),[Z,B]=c.useState(!1),[ee,oe]=c.useState([]),[A,J]=c.useState(null),[R,Y]=c.useState(null),[H,T]=c.useState(null),[O,G]=c.useState(!1),L=c.useRef(null),S=c.useRef(null),V=c.useRef(0),K=c.useRef(null),le=!!l,X=(g?m.get(g):null)??p??null,ce={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{V.current=0,K.current=null,x(new Set(["","artifacts","thread-events","live",...Ih(ce),...Ba((p==null?void 0:p.path)??"")]))},[ce.threadId,ce.workspaceId]);function re(){var _;const P=((_=S.current)==null?void 0:_.scrollTop)??V.current;V.current=P,K.current=P}function fe(){const P=K.current??V.current;if(!S.current)return;let se=0;const ge=()=>{const Ne=S.current;Ne&&(Ne.scrollTop=Math.min(P,Math.max(0,Ne.scrollHeight-Ne.clientHeight)),V.current=Ne.scrollTop,se+=1,se<8?window.requestAnimationFrame(ge):K.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&fe()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const P=window.matchMedia("(max-width: 639px)"),_=()=>G(P.matches);return _(),typeof P.addEventListener=="function"?(P.addEventListener("change",_),()=>P.removeEventListener("change",_)):(P.addListener(_),()=>P.removeListener(_))},[]);async function he(P){if(!l)return;const _=P??(X==null?void 0:X.path)??null;C(!0),k(null);try{const se=Yt(await l.listTree({...ce,path:""}));let ge=i?An(se,i):se;if(i){const Ae=[...b].filter(Se=>Se).sort((Se,Be)=>Se.split("/").length-Be.split("/").length);for(const Se of Ae){const Be=Pn(i,Se);if((Be==null?void 0:Be.kind)!=="directory"||!Be.childrenLoaded)continue;const We=Yt(await l.listTree({...ce,path:Se}));ge=zn(ge,Se,An(We,Be))}}d(ge);const Ne=Co(ge);v(Ae=>{var Be;const Se=_??(Ae?(Be=m.get(Ae))==null?void 0:Be.path:null);return Se&&In(ge,Se)?`workspace:${Se}`:(Ne==null?void 0:Ne.id)??Ae})}catch(se){k(se instanceof Error?se.message:"Failed to load workspace"),d(null)}finally{C(!1)}}async function ve(P){if(!(!l||!i)){I(_=>{if(_.has(P))return _;const se=new Set(_);return se.add(P),se}),k(null);try{const _=Yt(await l.listTree({...ce,path:P}));d(se=>se&&No(se,P,_.children,{truncated:_.truncated}))}catch(_){k(_ instanceof Error?_.message:"Failed to load directory")}finally{I(_=>{if(!_.has(P))return _;const se=new Set(_);return se.delete(P),se})}}}async function Re(P){const _=So(P);if(!_)return;const se=qc(_);if(y(null),x(ge=>{const Ne=new Set(ge);Ne.add("");for(const Ae of se)Ne.add(Ae);return Oa(ce,Ne),Ne}),!l){In(u,_)&&v(`workspace:${_}`);return}C(!0),k(null);try{let ge=i??Yt(await l.listTree({...ce,path:""}));for(const Ne of se){const Ae=Pn(ge,Ne);if((Ae==null?void 0:Ae.kind)==="directory"&&Ae.childrenLoaded)continue;const Se=Yt(await l.listTree({...ce,path:Ne}));ge=zn(ge,Ne,Se)}d(ge),v(`workspace:${_}`)}catch(ge){k(ge instanceof Error?ge.message:`Failed to open ${_}`)}finally{C(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const P of m.values())P.path&&P.kind==="directory"&&b.has(P.path)&&P.hasChildren&&!P.childrenLoaded&&!E.has(P.path)&&ve(P.path)},[i,b,m,l]),c.useEffect(()=>{d(null),I(new Set),J(null),Y(null),T(null),k(null),he()},[le,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Re(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,ce.threadId,ce.workspaceId]),c.useEffect(()=>{const P=l&&(X==null?void 0:X.kind)==="file"?X.path:null;if(!P){J(null),Y(null),T(null);return}const _=P;let se=!1;async function ge(){var Ne;if(l){D(!0),k(null),J(null),Y(null),T(null);try{const Ae=Cr(_),Se=(Ne=l.getRawFileUrl)==null?void 0:Ne.call(l,{...ce,path:_});if(Se&&Lo.has(Ae)){se||Y(Se);return}if(Se&&Po.has(Ae)){se||T(Se);return}const Be=await l.readFile({...ce,path:_,limit:$r});se||J(Be)}catch(Ae){se||k(Ae instanceof Error?Ae.message:"Failed to read file")}finally{se||D(!1)}}}return ge(),()=>{se=!0}},[l,X==null?void 0:X.id]);async function ie(){if(!(!l||!(A!=null&&A.truncated))){Q(!0);try{const P=await l.readFile({...ce,path:A.path,offset:A.nextOffset,limit:$r});J(_=>_&&{..._,content:_.content+P.content,truncated:P.truncated,nextOffset:P.nextOffset,size:P.size})}finally{Q(!1)}}}async function ye(P){if(!(l!=null&&l.writeFile))return;k(null),await l.writeFile({...ce,path:P.path,content:P.content}),await he(P.path);const _=await l.readFile({...ce,path:P.path,limit:$r});J(_)}async function Te(P){if(!(!(l!=null&&l.uploadFile)||!P)){C(!0),k(null);try{const _=await l.uploadFile({...ce,path:P.name,file:P}),se=_.kind==="archive"?_.paths[0]??null:_.file.path;await he(se)}catch(_){k(_ instanceof Error?_.message:"Failed to upload file")}finally{C(!1)}}}async function U(P){var se;const _=(se=P.target.files)==null?void 0:se[0];P.target.value="",_&&await Te(_)}function ae(){if(!(l!=null&&l.uploadFile))return;const P=()=>{var _;return(_=L.current)==null?void 0:_.click()};if(l.pickUploadFile){l.pickUploadFile({...ce,defaultPick:P,upload:Te});return}P()}function xe(P){var _;(_=l==null?void 0:l.downloadNode)==null||_.call(l,{...ce,path:P.path,kind:P.kind==="directory"?"directory":"file"})}function ke(P){if(!P.path||typeof navigator>"u"||!navigator.clipboard)return;const _=r.workspace.absPath.replace(/\/+$/,""),se=P.path.startsWith("/")?P.path:_?`${_}/${P.path.replace(/^\/+/,"")}`:P.path;navigator.clipboard.writeText(se).catch(ge=>{k(ge instanceof Error?ge.message:"Failed to copy file path")})}function $e(P){P.kind==="file"&&(re(),v(P.id),y("explorer"))}async function Me(){if(l!=null&&l.emptyGarbage){if(k(null),!l.listGarbage){oe([]),B(!0);return}try{const P=await l.listGarbage(ce);oe(P.map(_=>`garbage/${_}`))}catch(P){oe([]),k(P instanceof Error?P.message:"Failed to list garbage files")}finally{B(!0)}}}async function je(){if(l!=null&&l.emptyGarbage){B(!1),k(null);try{await l.emptyGarbage(ce),await he((X==null?void 0:X.path)??null)}catch(P){k(P instanceof Error?P.message:"Failed to empty garbage")}}}const De={onCopyPath:ke,...l!=null&&l.downloadNode?{onDownload:xe}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Me}:{},...l?{onRefresh:()=>void he((X==null?void 0:X.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ae}:{}};function F(P){if(!P)return;const _=m.get(`workspace:${P}`),se=(_==null?void 0:_.kind)==="directory"&&_.hasChildren&&!_.childrenLoaded&&!E.has(P);x(ge=>{const Ne=new Set(ge);return Ne.has(P)?Ne.delete(P):Ne.add(P),Oa(ce,Ne),Ne}),!b.has(P)&&se&&ve(P)}const de=t.jsx(Ah,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{re(),y("explorer")},expandedPaths:b,loadingPaths:E,loading:N,explorerScrollTopRef:V,explorerScrollerRef:S,...De,onPreview:$e,onSelect:P=>{v(P)},onToggle:F,selectedNodeId:(X==null?void 0:X.id)??null,tree:u,liveNodes:f}),we=t.jsx(Eh,{error:w,imageUrl:R,loadingMore:$,onLoadMore:ie,...l!=null&&l.writeFile?{onSaveFile:ye}:{},onCollapse:()=>{re(),y("viewer")},pdfUrl:H,previewFile:A,previewLoading:q,plugins:a,selectedTarget:Th(X)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:we}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:de}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Z?t.jsx(Ph,{files:ee,onCancel:()=>B(!1),onConfirm:()=>void je()}):null,O?t.jsxs(En,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(Qt,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:de})}),t.jsx(Ln,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(Qt,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:we})})]}):t.jsxs(En,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(Qt,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:de})}),t.jsx(Ln,{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(Qt,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:we})})]}),t.jsx("input",{ref:L,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:P=>void U(P)})]})}var $r,Bo,Go,Fo,Ho,Dr,Oo,Uo,Wo,Mh=Ge({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ea(),Lh(),zh(),jo(),$r=24e3,Bo="remote-codex:graphchat:workspace:expanded:",Go="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Fo="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Ho="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Dr="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",Oo="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",Uo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Wo="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 pn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function qt({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function $h({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 ir({value:e,title:r,icon:n,children:a}){return t.jsxs(yr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(Zr,{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($h,{children:n}),r]})}),t.jsx(jr,{className:"space-y-3 pb-3",children:a})]})}function Dh(){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(wr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(ir,{value:"start",title:"Getting Started",icon:t.jsx(M.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(qt,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(ir,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(M.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M.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(M.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(M.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(M.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(M.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(pn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(pn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(pn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(ir,{value:"viewer",title:"Viewer",icon:t.jsx(M.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(qt,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(ir,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(M.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(qt,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(qt,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(ir,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(M.Code2,{className:"h-3 w-3"}),children:t.jsx(qt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var Bh=Ge({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Nr()}});function Gh(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 Wa({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:Gh(r)})]})}function Fh({event:e}){return t.jsxs(yr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(Zr,{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(jr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Wa,{label:"Input",value:e.preview}),t.jsx(Wa,{label:"Output",value:e.detail})]})})]})}function Hh({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(M.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(wr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Fh,{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(M.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Oh=Ge({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Nr()}});function Va(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),o=e.internals.positionAbsolute,s=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=o.x+d,m=o.y+h,f=s.x+l/2,p=s.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),v=(f-u)/(2*d)+(p-m)/(2*h),b=1/(Math.abs(g)+Math.abs(v)),x=b*g,j=b*v,y=d*(x+j)+u,w=h*(-x+j)+m;return{x:y,y:w}}function Ka(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?$t.Left:s>=a+(e.measured.width??1)-1?$t.Right:l<=o+1?$t.Top:l>=n.y+(e.measured.height??1)-1?$t.Bottom:$t.Top}function Vo(e,r){const n=Va(e,r),a=Va(r,e),o=Ka(e,n),s=Ka(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Uh(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,v)=>{const b=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(b)%u+v*100%u,y:Math.abs(b>>16)%m+v*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let v=0;v<p;v+=1)for(let b=v+1;b<p;b+=1){const x=d[v],j=d[b];if(!x||!j)continue;const y=f.get(x.id),w=f.get(j.id);if(!y||!w)continue;const k=y.x-w.x,N=y.y-w.y,C=Math.sqrt(k*k+N*N)||1,I=(200-C)*.5,q=k/C*I,D=N/C*I;y.vx+=q,y.vy+=D,w.vx-=q,w.vy-=D}h.forEach(v=>{const b=f.get(v.source),x=f.get(v.target);if(!b||!x)return;const j=x.x-b.x,y=x.y-b.y,w=Math.sqrt(j*j+y*y)||1,N=(w-120)*.3,C=j/w*N,E=y/w*N;b.vx+=C,b.vy+=E,x.vx-=C,x.vy-=E}),f.forEach(v=>{v.x+=v.vx*.1,v.y+=v.vy*.1,v.vx*=.9,v.vy*=.9,v.x=Math.max(80,Math.min(u-80,v.x)),v.y=Math.max(80,Math.min(m-80,v.y))})}return f},o=new Set(e.map(d=>d.id)),s=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:_s.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 ta=Ge({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Wh({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:o}){if(!o)return null;const s={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Vo(o,s),[f]=Ms({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Vh=Ge({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ta()}});function Kh({id:e,source:r,target:n,markerEnd:a,style:o}){const s=ka(r),l=ka(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Vo(s,l),[p]=Ms({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:o})}var qh=Ge({"src/components/graph-chat/FloatingEdge.tsx"(){ta()}});function Xh({nodes:e}){const[r,n,a]=cd([]),[o,s,l]=hd([]),i=c.useMemo(()=>Uh(e),[e]),d=c.useMemo(()=>({floating:Kh}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(va,{type:"target",position:$t.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(va,{type:"source",position:$t.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>ud({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:_s.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(md,{children:t.jsxs(pd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Wh,children:[t.jsx(fd,{}),t.jsx(gd,{gap:16})]})})})}var Yh=Ge({"src/components/graph-chat/GraphVisualization.tsx"(){Vh(),qh(),ta()}});function Zh(e){return{...qo,...e}}function qa(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function Jh(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 Qh(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:Hr(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:Hr(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 Hr(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 eu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Hr(e.kind)}}function tu(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function ru(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:eu(d),description:tu(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 Ko({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Zh(i),[i]),u=qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Wc(e),[e]),g=c.useMemo(()=>Qh(e),[e]),v=c.useMemo(()=>{const k=new Map;for(const N of g)k.set(N.kind,(k.get(N.kind)??0)+1);return[...k.entries()].sort((N,C)=>C[1]-N[1])},[g]),b=n.getThreadPanels(),x=Math.max(...v.map(([,k])=>k),1),j=c.useMemo(()=>ru(e,g),[e,g]),y=c.useMemo(()=>{const k=[];return h.workspace&&k.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&k.push({id:"tools",label:"Tool Usage",icon:M.BarChart2}),h.guide&&k.push({id:"guide",label:"Guide",icon:M.BookOpen}),k},[h.guide,h.toolUsage,h.workspace]),w=c.useMemo(()=>{const k=[];return h.threadGraph&&k.push({id:"graph",label:"Thread graph",icon:M.GitBranch}),h.extensions&&k.push({id:"extensions",label:"Remote Codex extensions",icon:M.Wrench}),k},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!Jh(h,m))&&f(qa(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[y.map(k=>{const N=k.icon;return t.jsxs("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===k.id?"is-active":""}`,children:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,k.label]},k.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(k=>{const N=k.icon;return t.jsx("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===k.id?"is-active":""}`,title:k.label,"aria-label":k.label,children:t.jsx(N,{className:"h-3.5 w-3.5"})},k.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(_h,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Hh,{formatToolKind:Hr,toolCounts:v,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(Xh,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(Zt,{label:"Plugin Panels",children:b.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.label},k.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(Zt,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(k=>k.enabled).map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.name},k.id))})}),t.jsx(Zt,{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(M.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(M.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(M.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(Zt,{label:"Thread Meta",children:o}):null,s?t.jsx(Zt,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Dh,{}):null]})]}):null}var qo,Xo,nu=Ge({"src/components/ThreadGraphWorkspacePanel.tsx"(){Mh(),zo(),Bh(),Oh(),ea(),Yh(),qo={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},Xo=c.memo(Ko)}}),Yo={};Uc(Yo,{MemoizedThreadGraphWorkspacePanel:()=>Xo,ThreadGraphWorkspacePanel:()=>Ko});var au=Ge({"src/workspace-panel.ts"(){nu()}});function rr(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))}rr(`.thread-ui-shell,
|
|
9
|
+
`),a+=i}return n.length>0?n:[e]}function Fa(e,r){return r!=="xyz"?e:e.flatMap(n=>wh(n))}function Ha(e){return e.map(r=>`${r.replace(/\s+$/g,"")}
|
|
10
|
+
`).join("")}function yh(e){if(!e)return{format:"xyz",frames:[],exportContent:""};if(typeof e=="string"){const o=Fa([e],"xyz");return{frames:o,format:"xyz",exportContent:Ha(o)}}const r=kh(e.format),n=e.content.filter(o=>o.trim().length>0);return{frames:Fa(n,r),format:r,exportContent:Ha(n)}}var jh=Ge({"src/components/graph-workspace/GraphMoleculeViewerData.ts"(){}});function Nh({className:e="",moleculeId:r=null,onScreenshot:n,onSelectionChange:a,source:o,title:s="PyMOL-style (PDB/CIF)"}){const l=c.useRef(null),i=c.useRef(null),d=c.useRef(null),h=c.useRef(!1),u=c.useRef(!0),[m,f]=c.useState(null),[p,g]=c.useState(0),[v,b]=c.useState(null),[x,j]=c.useState(!1),[y,w]=c.useState({}),[k,N]=c.useState([]),[C,E]=c.useState({}),[z,q]=c.useState(!1),[D,$]=c.useState(!1),[Q,Z]=c.useState(null),B=c.useMemo(()=>yh(o),[o]),ee=B.frames,oe=B.format,A=ee[p]??null,J=ee.length>0&&p===ee.length-1,R=r??"current",Y=Object.values(C).reduce((L,S)=>L+S.length,0),H=Object.keys(C).length;c.useEffect(()=>{if(ee.length===0){g(0);return}g(ee.length-1)},[ee.length]),c.useEffect(()=>{if(!x||ee.length<=1)return;const L=window.setInterval(()=>{g(S=>S>=ee.length-1?(window.clearInterval(L),j(!1),S):S+1)},200);return()=>window.clearInterval(L)},[x,ee.length]),c.useEffect(()=>{const L=l.current;if(!L||i.current)return;let S=!1;try{const K=document.createElement("canvas");if(!(K.getContext("webgl2")||K.getContext("webgl")||K.getContext("experimental-webgl"))){Z("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}}catch{Z("WebGL is unavailable in this browser environment. Unable to render 3D viewer.");return}const V=()=>{var K,le;(K=i.current)==null||K.resize(),(le=i.current)==null||le.render()};return gh().then(K=>{if(!(S||i.current))try{const le=K.createViewer(L,{});i.current=le,le.setBackgroundColor("#f8fafc",.8),window.addEventListener("resize",V),window.setTimeout(V,100)}catch(le){console.error("Failed to initialize 3Dmol viewer:",le),Z("Failed to initialize 3D viewer. Please refresh or try another browser.")}}).catch(K=>{console.error("Failed to load 3Dmol viewer runtime:",K),Z("Failed to load 3D viewer runtime. Please refresh or try another browser.")}),()=>{S=!0,window.removeEventListener("resize",V),i.current=null,d.current=null}},[]),c.useEffect(()=>{const L=i.current;if(!(!L||!A))try{L.removeAllModels(),L.removeAllShapes(),L.removeAllLabels();const S=L.addModel(A,oe||"xyz");d.current=S,S.setStyle({},{stick:{radius:.2},sphere:{scale:.3}});const V=S.getCrystData(),K=!!(V&&typeof V=="object"&&Object.keys(V).length);q(K),$(K?u.current:!1),N([]),w({});const le=A.split(`
|
|
11
|
+
`).slice(2).map(X=>X.trim()).filter(Boolean).map(X=>X.split(/\s+/)[0]??"Atom");h.current||(L.zoomTo(),h.current=!0),S.setClickable({},!0,(X,ce,re)=>{const fe=X.serial??X.index;if(fe===void 0)return;const he=X.atom||X.elem||le[fe]||"Atom";N(ve=>{const ie=!!(re!=null&&re.shiftKey||re!=null&&re.metaKey||re!=null&&re.ctrlKey)?ve.includes(fe)?ve.filter(ye=>ye!==fe):[...ve,fe]:ve.length===1&&ve[0]===fe?[]:[fe];return w(ye=>{if(ie.length===0)return{};const Te={};return ie.forEach(W=>{Te[W]=ye[W]||le[W]||he}),Te}),ie})}),S.setHoverable({},!0,(X,ce,re)=>{!re||!X||b({x:re.clientX,y:re.clientY,label:`${X.atom||X.elem||"Atom"} (${X.serial??X.index??"?"})`,coords:{x:X.x.toFixed(2),y:X.y.toFixed(2),z:X.z.toFixed(2)}})},()=>b(null)),L.render()}catch(S){console.error("Failed to render molecule:",S),Z("Unable to render this molecular structure.")}},[A,oe]),c.useEffect(()=>{const L=i.current,S=d.current;if(!(!L||!S)){try{L.removeUnitCell(S)}catch{}if(D&&z)try{L.addUnitCell(S,{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{q(!1),$(!1)}L.render()}},[z,D,A,oe]),c.useEffect(()=>{const L=i.current,S=d.current;!L||!S||!A||(S.setStyle({},{stick:{radius:.2},sphere:{scale:.3}}),k.length>0&&S.setStyle({serial:k},{stick:{radius:.3,color:"yellow"},sphere:{scale:.4,color:"yellow"}}),L.render(),a==null||a({moleculeId:r,atoms:k}))},[r,a,k,A]),c.useEffect(()=>{if(!A)return;let L=0;const S=()=>{var K,le;const V=(le=(K=i.current)==null?void 0:K.getView)==null?void 0:le.call(K);if(Array.isArray(V)&&V.length>=8){const[X,ce,re,fe,he,ve,Re,ie]=V;if(typeof X=="number"&&typeof ce=="number"&&typeof re=="number"&&typeof fe=="number"&&typeof he=="number"&&typeof ve=="number"&&typeof Re=="number"&&typeof ie=="number"){const ye=Math.sqrt(he*he+ve*ve+Re*Re),Te=ye>0?{x:he/ye,y:ve/ye,z:Re/ye}:{x:0,y:0,z:0};f({position:{x:X,y:ce,z:re,qx:he,qy:ve,qz:Re,qw:ie},lookAt:Te,zoom:fe})}}L=window.requestAnimationFrame(S)};return L=window.requestAnimationFrame(S),()=>window.cancelAnimationFrame(L)},[A]);const T=c.useCallback(async()=>{const L=i.current;if(!(L!=null&&L.pngURI))return;L.render();const S=L.pngURI();if(S){try{const K=await(await fetch(S)).blob(),le=new ClipboardItem({[K.type||"image/png"]:K});await navigator.clipboard.write([le])}catch{}n==null||n({moleculeId:r,image:S})}},[r,n]);function O(){z&&$(L=>{const S=!L;return u.current=S,S})}function G(){k.length!==0&&E(L=>{const S=L[R]??[];return{...L,[R]:Array.from(new Set([...S,...k]))}})}return t.jsxs("div",{className:`thread-graph-molecule-viewer flex h-full min-h-0 flex-col bg-white ${e}`,children:[t.jsxs("div",{className:"thread-graph-molecule-header flex shrink-0 items-center justify-between gap-3 border-b border-slate-200 px-3 py-2 sm:px-4 sm:py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("h2",{className:"truncate text-sm font-semibold text-slate-900",children:s}),t.jsx("p",{className:"mt-1 hidden text-[11px] text-slate-400 sm:block",children:"cartoon + surface"})]}),t.jsx("span",{className:"shrink-0 text-[11px] text-slate-400",children:"workspace preview"})]}),t.jsxs("div",{className:"thread-graph-molecule-body min-h-0 flex-1",children:[t.jsxs("div",{ref:l,"data-testid":"molecule-viewer",className:"thread-graph-molecule-stage relative min-h-0 flex-1 overflow-hidden",children:[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&&!A?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,v?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:v.x-20,top:v.y-50},children:[t.jsx("div",{className:"mb-0.5 font-semibold text-gray-900",children:v.label}),t.jsxs("div",{className:"space-x-2 text-gray-600",children:[t.jsxs("span",{children:["x: ",v.coords.x]}),t.jsxs("span",{children:["y: ",v.coords.y]}),t.jsxs("span",{children:["z: ",v.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(ph,{currentIndex:p,exportContent:B.exportContent,moleculeId:r,onScreenshot:()=>void T(),viewerRef:i,xyzContent:A,xyzFormat:oe})]}),ee.length>1?t.jsxs("div",{className:"thread-graph-molecule-trajectory",children:[t.jsxs("div",{className:"mb-2 flex justify-between gap-3 text-xs",children:[t.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:["Trajectory ",p+1," / ",ee.length,t.jsx(kr,{type:"button",variant:"ghost",size:"icon",className:"thread-graph-molecule-button h-5 w-5",onClick:()=>{j(L=>{const S=!L;return S&&p===ee.length-1&&g(0),S})},"aria-label":x?"Pause trajectory":"Play trajectory",title:x?"Pause trajectory":"Play trajectory",children:x&&p!==ee.length-1?t.jsx(M.Pause,{className:"h-3 w-3"}):t.jsx(M.Play,{className:"h-3 w-3"})})]}),t.jsxs(kr,{type:"button",variant:"ghost",onClick:()=>g(ee.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(bh,{value:[p],max:ee.length-1,step:1,onValueChange:L=>g(L[0]??0),"aria-label":"Trajectory frame"})]}):null,t.jsx(uh,{cameraInfo:m,onClearSelection:()=>N([]),onClearStaged:()=>E({}),onSendSelection:()=>a==null?void 0:a({moleculeId:r,atoms:k}),onSendStaged:()=>{Object.entries(C).forEach(([L,S])=>{a==null||a({moleculeId:L==="current"?r:L,atoms:S})})},onStageSelection:G,onToggleUnitCell:O,selectedAtomLabels:y,selectedSerials:k,stagedAtoms:Y,stagedMolecules:H,unitCellAvailable:z,unitCellVisible:D})]})]})]})}var Ch=Ge({"src/components/graph-workspace/GraphMoleculeViewer.tsx"(){mh(),fh(),xh(),Jr(),vh(),jh()}});function Sh(e){return!e.truncated&&e.size<=Mo&&e.content.split(`
|
|
12
|
+
`).length<=$o}function Th(e){return e&&(e.node.path||e.node.name)||null}function Eh(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 Lh({error:e,imageUrl:r,loadingMore:n,onSaveFile:a,onLoadMore:o,onCollapse:s,pdfUrl:l,previewFile:i,previewLoading:d,plugins:h,selectedTarget:u}){const[m,f]=c.useState(!1),[p,g]=c.useState(""),[v,b]=c.useState(null),[x,j]=c.useState(!1),y=(u==null?void 0:u.node)??null,w=y!=null&&y.artifact?h.renderArtifact({artifact:y.artifact,expanded:!0,onToggleExpanded:()=>{}}):null,k=Yc(i??null),N=(i==null?void 0:i.language)||Zc((i==null?void 0:i.path)??""),C=i?Sr(i.path):"",E=Th(u),z=i!==null&&Qn.has(C),q=!!(i&&a)&&!z&&Sh(i),D=(u==null?void 0:u.kind)==="live-molecule",$=!!(y!=null&&y.artifact&&w),Q=!!k||$;c.useEffect(()=>{f(!1),g((i==null?void 0:i.content)??""),b(null)},[i==null?void 0:i.path,i==null?void 0:i.content]);async function Z(){if(!(!i||!a)){j(!0),b(null);try{await a({path:i.path,content:p}),f(!1)}catch(B){b(B instanceof Error?B.message:"Failed to save file.")}finally{j(!1)}}}return t.jsxs("section",{className:"thread-graph-viewer flex h-full min-h-0 flex-col overflow-hidden rounded-[12px]","data-preview-target-kind":(u==null?void 0:u.kind)??"none",children:[t.jsxs("div",{className:"thread-graph-viewer-header flex h-12 shrink-0 items-center justify-between gap-3 border-b px-3 sm:h-[60px] sm:px-5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[t.jsx("h2",{className:"text-base font-semibold text-slate-900 sm:text-[18px] dark:text-slate-100",children:"Viewer"}),E?t.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-slate-500 dark:text-slate-400",children:E}):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(M.ChevronsRight,{className:"h-4 w-4"})}):null]}),t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:[e?t.jsx("div",{className:"border-b border-rose-200 bg-rose-50 px-5 py-3 text-sm text-rose-700 dark:border-rose-400/25 dark:bg-rose-400/10 dark:text-rose-200",children:e}):null,u?u.kind==="workspace-file"&&d?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center px-5 text-center text-sm text-slate-400 dark:text-slate-500",children:"Loading file preview..."}):u.kind==="workspace-file"&&k?t.jsx("div",{className:"thread-graph-molecule-preview min-h-0 flex-1 overflow-hidden",children:t.jsx(Nh,{source:k,moleculeId:k.uuid??u.node.path,title:"PyMOL-style (PDB/CIF)"})}):u.kind==="workspace-file"&&r?t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto p-5",children:t.jsx("img",{src:r,alt:u.node.path||u.node.name,className:"max-h-full max-w-full object-contain"})}):u.kind==="workspace-file"&&l?t.jsx("div",{className:"thread-graph-file-preview-frame min-h-0 flex-1 overflow-hidden",children:t.jsx("iframe",{src:l,title:`PDF preview: ${u.node.path||u.node.name}`,className:"h-full w-full border-0"})}):u.kind==="workspace-file"&&i?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs("div",{className:"thread-graph-file-preview-header flex min-h-12 items-center justify-between gap-3 border-b px-4 py-2",children:[t.jsxs("div",{className:"min-w-0 text-xs uppercase tracking-[0.12em]",children:[z?"molecule":N||C||"text"," |"," ",i.size.toLocaleString()," bytes",i.truncated?t.jsxs("span",{className:"ml-2 text-amber-500",children:["showing ",i.nextOffset.toLocaleString()," bytes"]}):null]}),q?t.jsx("div",{className:"flex shrink-0 items-center gap-1",children:m?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!1),b(null)},disabled:x,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Cancel edits","aria-label":"Cancel edits",children:t.jsx(M.X,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:()=>void Z(),disabled:x||p===i.content,className:"thread-graph-explorer-icon-button flex h-8 w-8 items-center justify-center rounded-lg border shadow-none transition disabled:cursor-not-allowed disabled:opacity-50",title:"Save file","aria-label":"Save file",children:t.jsx(M.Save,{className:"h-4 w-4"})})]}):t.jsx("button",{type:"button",onClick:()=>{g(i.content),f(!0),b(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(M.Pencil,{className:"h-4 w-4"})})}):null]}),v?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:v}):null,m?t.jsx("textarea",{value:p,onChange:B=>g(B.currentTarget.value),spellCheck:!1,"aria-label":"Workspace file editor",className:"thread-graph-file-editor min-h-0 flex-1 resize-none border-0 bg-transparent p-4 font-mono text-[12px] leading-5 text-slate-900 outline-none dark:text-slate-100"}):t.jsx(Dr,{content:i.content}),i.truncated&&o?t.jsx("div",{className:"thread-graph-file-preview-footer flex justify-center border-t px-4 py-3",children:t.jsx("button",{type:"button",onClick:o,disabled:n,title:"Load more workspace preview","aria-label":"Load more workspace preview",className:"thread-graph-load-more-button rounded-md px-4 py-1.5 text-xs disabled:opacity-50",children:n?"Loading...":`Load more (${(i.size-i.nextOffset).toLocaleString()} bytes remaining)`})}):null]}):(u.kind==="live-molecule"||u.kind==="artifact")&&u.node.artifact?t.jsx("div",{className:Q||D?"min-h-0 flex-1 overflow-hidden":"min-h-0 flex-1 overflow-auto p-3",children:w}):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(Zt,{label:"Workspace Data",children:t.jsx(Dr,{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(Dr,{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 Mo,$o,Dr,Ph=Ge({"src/components/graph-workspace/GraphWorkspacePreviewPane.tsx"(){ea(),zo(),Ch(),Mo=50*1024,$o=1e3,Dr=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 Ih({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 zh=Ge({"src/components/graph-workspace/GraphEmptyGarbageDialog.tsx"(){}});function Do(e){return`${Go}${e.workspaceId??"workspace"}:${e.threadId}`}function Rh(e){if(typeof window>"u")return[];try{const r=window.localStorage.getItem(Do(e));if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Oa(e,r){if(!(typeof window>"u"))try{window.localStorage.setItem(Do(e),JSON.stringify([...r]))}catch{}}function An(e,r){if(!r||e.path!==r.path||e.kind!=="directory")return e;const n=new Map(r.children.map(s=>[s.path,s])),a=e.children.map(s=>An(s,n.get(s.path)??null)),o=e.childrenLoaded&&e.children.length>0;return{...e,children:o||!r.childrenLoaded?a:r.children,childrenLoaded:e.childrenLoaded||r.childrenLoaded,truncated:e.truncated??r.truncated}}function Wa(e,r){if(e.kind==="directory")return r?t.jsx(M.FolderOpen,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"}):t.jsx(M.Folder,{className:"h-4 w-4 text-slate-500 dark:text-slate-400"});const n=Sr(e.name);return n==="zip"?t.jsx(M.FileArchive,{className:"h-4 w-4 text-amber-600"}):e.kind==="file"&&["png","jpg","jpeg","gif","webp","svg"].includes(n)?t.jsx(M.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(M.FileCode2,{className:"h-4 w-4 text-emerald-600"}):t.jsx(M.File,{className:"h-4 w-4 text-slate-400 dark:text-slate-500"})}function Bo({depth:e,expandedPaths:r,loadingPaths:n,node:a,onCopyPath:o,onDownload:s,onPreview:l,onSelect:i,onToggle:d,selectedNodeId:h}){const u=a.kind==="directory",m=u&&(a.path===""||r.has(a.path)),f=u&&n.has(a.path),p=h===a.id,g=`${e*.75+.5}rem`;return u?t.jsxs("div",{children:[t.jsxs("div",{className:"thread-graph-tree-row group flex items-center text-sm text-slate-600 transition hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100",children:[t.jsxs("button",{type:"button",onClick:()=>d(a.path),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:g},children:[m?t.jsx(M.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}):t.jsx(M.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-slate-400 dark:text-slate-500"}),Wa(a,m),t.jsx("span",{className:"truncate",children:a.name}),f?t.jsx("span",{className:"ml-auto shrink-0 text-xs text-slate-400 dark:text-slate-500",children:"Loading"}):null]}),s?t.jsx("button",{type:"button",onClick:()=>s(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:a.path?`Download ${a.name}`:"Download workspace","aria-label":a.path?`Download ${a.name}`:"Download workspace",children:t.jsx(M.Download,{className:"h-3.5 w-3.5"})}):null,o&&a.path?t.jsx("button",{type:"button",onClick:()=>o(a),className:"thread-graph-tree-action mr-1 flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-slate-400 transition hover:bg-white hover:text-slate-900 sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100",title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null]}),m?t.jsxs("div",{children:[a.children.map(v=>t.jsx(Bo,{depth:e+1,expandedPaths:r,loadingPaths:n,node:v,...o?{onCopyPath:o}:{},...s?{onDownload:s}:{},...l?{onPreview:l}:{},onSelect:i,onToggle:d,selectedNodeId:h},v.id)),a.truncated?t.jsx("div",{className:"px-2 py-1 text-xs text-slate-400 dark:text-slate-500",style:{paddingLeft:`${(e+1)*.75+.5}rem`},children:"More items not shown"}):null]}):null]}):t.jsxs("div",{className:`thread-graph-tree-row group flex items-center text-sm transition ${p?"is-selected":"text-slate-600 hover:bg-slate-100 hover:text-slate-900 dark:text-slate-300 dark:hover:bg-[#222733] dark:hover:text-slate-100"}`,children:[t.jsxs("button",{type:"button",onClick:()=>i(a.id),className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 px-2 py-2 text-left sm:min-h-0 sm:py-1.5",style:{paddingLeft:`${e*.75+2.2}rem`},children:[Wa(a,!1),t.jsx("span",{className:"truncate",children:a.name})]}),a.kind==="file"&&(l||s||o)?t.jsxs("div",{className:"mr-1 flex shrink-0 items-center gap-0.5",children:[l?t.jsx("button",{type:"button",onClick:()=>l(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Preview ${a.name}`,"aria-label":`Preview ${a.name}`,children:t.jsx(M.Eye,{className:"h-3.5 w-3.5"})}):null,s?t.jsx("button",{type:"button",onClick:()=>s(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Download ${a.name}`,"aria-label":`Download ${a.name}`,children:t.jsx(M.Download,{className:"h-3.5 w-3.5"})}):null,o?t.jsx("button",{type:"button",onClick:()=>o(a),className:`thread-graph-tree-action flex h-9 w-9 shrink-0 items-center justify-center rounded-md transition sm:h-7 sm:w-7 sm:opacity-0 sm:group-hover:opacity-100 sm:focus:opacity-100 ${p?"is-selected":"text-slate-400 hover:bg-white hover:text-slate-900 dark:text-slate-500 dark:hover:bg-[#1d222c] dark:hover:text-slate-100"}`,title:`Copy path for ${a.name}`,"aria-label":`Copy path for ${a.name}`,children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null]}):null]})}function Ah({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(M.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 _h({canEmptyGarbage:e,canUpload:r,onCollapse:n,expandedPaths:a,loadingPaths:o,loading:s,onDownload:l,onCopyPath:i,onEmptyGarbage:d,onPreview:h,onRefresh:u,onSelect:m,onToggle:f,onUpload:p,explorerScrollTopRef:g,explorerScrollerRef:v,selectedNodeId:b,tree:x,liveNodes:j}){const y=c.useMemo(()=>({...x,children:x.children.filter(w=>w.path!=="live")}),[x]);return c.useLayoutEffect(()=>{const w=v.current;w&&(w.scrollTop=g.current)},[v,g]),t.jsxs("aside",{className:`${Fo} flex flex-col`,children:[t.jsxs("div",{className:Ho,children:[t.jsx("div",{className:"min-w-0",children:t.jsx("h2",{className:Oo,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:Wo,title:"Collapse Explorer","aria-label":"Collapse Explorer",children:[t.jsx(M.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:Gr,title:r?"Upload file":"Upload is unavailable for this workspace","aria-label":"Upload file",children:t.jsx(M.Upload,{className:"h-4 w-4"})}),t.jsx("button",{type:"button",onClick:u,className:Gr,title:"Refresh workspace","aria-label":"Refresh workspace",children:t.jsx(M.RefreshCw,{className:`h-4 w-4 ${s?"animate-spin":""}`})}),d?t.jsx("button",{type:"button",onClick:d,disabled:!e,className:Gr,title:e?"Empty garbage":"Garbage controls are unavailable","aria-label":"Empty garbage",children:t.jsx(M.Trash2,{className:"h-4 w-4"})}):null]})]}),t.jsxs("div",{ref:v,className:"thread-graph-workspace-tree-scroll min-h-0 flex-1 overflow-y-auto py-2",onScroll:w=>{g.current=w.currentTarget.scrollTop},children:[t.jsx(Ah,{liveNodes:j??[],onSelect:m,selectedNodeId:b}),t.jsx("div",{className:Uo,children:"Workspace"}),t.jsx(Bo,{depth:0,expandedPaths:a,loadingPaths:o,node:y,...i?{onCopyPath:i}:{},...l?{onDownload:l}:{},...h?{onPreview:h}:{},onSelect:m,onToggle:f,selectedNodeId:b}),y.children.length===0?t.jsx("p",{className:Vo,children:"This workspace is empty. Agent tool runs execute inside the thread workspace, so files should appear here as the session works."}):null]})]})}function Mh({activeView:e,detail:r,artifacts:n,plugins:a,status:o,focusPathRequest:s,workspaceAdapter:l}){const[i,d]=c.useState(null),h=c.useMemo(()=>l&&i?null:Da(r,n),[e,i,n,r,o,l]),u=i??h??Da(r,n),m=c.useMemo(()=>th(u),[u]),f=c.useMemo(()=>{var P;return((P=u.children.find(_=>_.path==="live"))==null?void 0:P.children)??[]},[u]),p=Lo(u),[g,v]=c.useState(()=>(p==null?void 0:p.id)??null),[b,x]=c.useState(()=>new Set(["","artifacts","thread-events","live",...Ba((p==null?void 0:p.path)??"")])),[j,y]=c.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(max-width: 639px)").matches?"viewer":null),[w,k]=c.useState(null),[N,C]=c.useState(!1),[E,z]=c.useState(()=>new Set),[q,D]=c.useState(!1),[$,Q]=c.useState(!1),[Z,B]=c.useState(!1),[ee,oe]=c.useState([]),[A,J]=c.useState(null),[R,Y]=c.useState(null),[H,T]=c.useState(null),[O,G]=c.useState(!1),L=c.useRef(null),S=c.useRef(null),V=c.useRef(0),K=c.useRef(null),le=!!l,X=(g?m.get(g):null)??p??null,ce={threadId:r.thread.id,workspaceId:r.workspace.id??r.thread.workspaceId??null};c.useEffect(()=>{V.current=0,K.current=null,x(new Set(["","artifacts","thread-events","live",...Rh(ce),...Ba((p==null?void 0:p.path)??"")]))},[ce.threadId,ce.workspaceId]);function re(){var _;const P=((_=S.current)==null?void 0:_.scrollTop)??V.current;V.current=P,K.current=P}function fe(){const P=K.current??V.current;if(!S.current)return;let se=0;const ge=()=>{const Ne=S.current;Ne&&(Ne.scrollTop=Math.min(P,Math.max(0,Ne.scrollHeight-Ne.clientHeight)),V.current=Ne.scrollTop,se+=1,se<8?window.requestAnimationFrame(ge):K.current=null)};window.requestAnimationFrame(ge)}c.useLayoutEffect(()=>{j!=="explorer"&&fe()},[j,u]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const P=window.matchMedia("(max-width: 639px)"),_=()=>G(P.matches);return _(),typeof P.addEventListener=="function"?(P.addEventListener("change",_),()=>P.removeEventListener("change",_)):(P.addListener(_),()=>P.removeListener(_))},[]);async function he(P){if(!l)return;const _=P??(X==null?void 0:X.path)??null;C(!0),k(null);try{const se=Yt(await l.listTree({...ce,path:""}));let ge=i?An(se,i):se;if(i){const Ae=[...b].filter(Se=>Se).sort((Se,Be)=>Se.split("/").length-Be.split("/").length);for(const Se of Ae){const Be=Pn(i,Se);if((Be==null?void 0:Be.kind)!=="directory"||!Be.childrenLoaded)continue;const Ue=Yt(await l.listTree({...ce,path:Se}));ge=In(ge,Se,An(Ue,Be))}}d(ge);const Ne=So(ge);v(Ae=>{var Be;const Se=_??(Ae?(Be=m.get(Ae))==null?void 0:Be.path:null);return Se&&zn(ge,Se)?`workspace:${Se}`:(Ne==null?void 0:Ne.id)??Ae})}catch(se){k(se instanceof Error?se.message:"Failed to load workspace"),d(null)}finally{C(!1)}}async function ve(P){if(!(!l||!i)){z(_=>{if(_.has(P))return _;const se=new Set(_);return se.add(P),se}),k(null);try{const _=Yt(await l.listTree({...ce,path:P}));d(se=>se&&Co(se,P,_.children,{truncated:_.truncated}))}catch(_){k(_ instanceof Error?_.message:"Failed to load directory")}finally{z(_=>{if(!_.has(P))return _;const se=new Set(_);return se.delete(P),se})}}}async function Re(P){const _=To(P);if(!_)return;const se=Xc(_);if(y(null),x(ge=>{const Ne=new Set(ge);Ne.add("");for(const Ae of se)Ne.add(Ae);return Oa(ce,Ne),Ne}),!l){zn(u,_)&&v(`workspace:${_}`);return}C(!0),k(null);try{let ge=i??Yt(await l.listTree({...ce,path:""}));for(const Ne of se){const Ae=Pn(ge,Ne);if((Ae==null?void 0:Ae.kind)==="directory"&&Ae.childrenLoaded)continue;const Se=Yt(await l.listTree({...ce,path:Ne}));ge=In(ge,Ne,Se)}d(ge),v(`workspace:${_}`)}catch(ge){k(ge instanceof Error?ge.message:`Failed to open ${_}`)}finally{C(!1)}}c.useEffect(()=>{if(!(!l||!i))for(const P of m.values())P.path&&P.kind==="directory"&&b.has(P.path)&&P.hasChildren&&!P.childrenLoaded&&!E.has(P.path)&&ve(P.path)},[i,b,m,l]),c.useEffect(()=>{d(null),z(new Set),J(null),Y(null),T(null),k(null),he()},[le,r.thread.id,r.workspace.id,r.thread.workspaceId]),c.useEffect(()=>{s&&Re(s.path)},[s==null?void 0:s.requestId]),c.useEffect(()=>{l!=null&&l.subscribeWorkspaceChanged},[l,ce.threadId,ce.workspaceId]),c.useEffect(()=>{const P=l&&(X==null?void 0:X.kind)==="file"?X.path:null;if(!P){J(null),Y(null),T(null);return}const _=P;let se=!1;async function ge(){var Ne;if(l){D(!0),k(null),J(null),Y(null),T(null);try{const Ae=Sr(_),Se=(Ne=l.getRawFileUrl)==null?void 0:Ne.call(l,{...ce,path:_});if(Se&&Po.has(Ae)){se||Y(Se);return}if(Se&&Io.has(Ae)){se||T(Se);return}const Be=await l.readFile({...ce,path:_,limit:Br});se||J(Be)}catch(Ae){se||k(Ae instanceof Error?Ae.message:"Failed to read file")}finally{se||D(!1)}}}return ge(),()=>{se=!0}},[l,X==null?void 0:X.id]);async function ie(){if(!(!l||!(A!=null&&A.truncated))){Q(!0);try{const P=await l.readFile({...ce,path:A.path,offset:A.nextOffset,limit:Br});J(_=>_&&{..._,content:_.content+P.content,truncated:P.truncated,nextOffset:P.nextOffset,size:P.size})}finally{Q(!1)}}}async function ye(P){if(!(l!=null&&l.writeFile))return;k(null),await l.writeFile({...ce,path:P.path,content:P.content}),await he(P.path);const _=await l.readFile({...ce,path:P.path,limit:Br});J(_)}async function Te(P){if(!(!(l!=null&&l.uploadFile)||!P)){C(!0),k(null);try{const _=await l.uploadFile({...ce,path:P.name,file:P}),se=_.kind==="archive"?_.paths[0]??null:_.file.path;await he(se)}catch(_){k(_ instanceof Error?_.message:"Failed to upload file")}finally{C(!1)}}}async function W(P){var se;const _=(se=P.target.files)==null?void 0:se[0];P.target.value="",_&&await Te(_)}function ae(){if(!(l!=null&&l.uploadFile))return;const P=()=>{var _;return(_=L.current)==null?void 0:_.click()};if(l.pickUploadFile){l.pickUploadFile({...ce,defaultPick:P,upload:Te});return}P()}function xe(P){var _;(_=l==null?void 0:l.downloadNode)==null||_.call(l,{...ce,path:P.path,kind:P.kind==="directory"?"directory":"file"})}function ke(P){if(!P.path||typeof navigator>"u"||!navigator.clipboard)return;const _=r.workspace.absPath.replace(/\/+$/,""),se=P.path.startsWith("/")?P.path:_?`${_}/${P.path.replace(/^\/+/,"")}`:P.path;navigator.clipboard.writeText(se).catch(ge=>{k(ge instanceof Error?ge.message:"Failed to copy file path")})}function $e(P){P.kind==="file"&&(re(),v(P.id),y("explorer"))}async function Me(){if(l!=null&&l.emptyGarbage){if(k(null),!l.listGarbage){oe([]),B(!0);return}try{const P=await l.listGarbage(ce);oe(P.map(_=>`garbage/${_}`))}catch(P){oe([]),k(P instanceof Error?P.message:"Failed to list garbage files")}finally{B(!0)}}}async function je(){if(l!=null&&l.emptyGarbage){B(!1),k(null);try{await l.emptyGarbage(ce),await he((X==null?void 0:X.path)??null)}catch(P){k(P instanceof Error?P.message:"Failed to empty garbage")}}}const De={onCopyPath:ke,...l!=null&&l.downloadNode?{onDownload:xe}:{},...l!=null&&l.emptyGarbage?{onEmptyGarbage:Me}:{},...l?{onRefresh:()=>void he((X==null?void 0:X.path)??null)}:{},...l!=null&&l.uploadFile?{onUpload:ae}:{}};function F(P){if(!P)return;const _=m.get(`workspace:${P}`),se=(_==null?void 0:_.kind)==="directory"&&_.hasChildren&&!_.childrenLoaded&&!E.has(P);x(ge=>{const Ne=new Set(ge);return Ne.has(P)?Ne.delete(P):Ne.add(P),Oa(ce,Ne),Ne}),!b.has(P)&&se&&ve(P)}const de=t.jsx(_h,{canEmptyGarbage:!!(l!=null&&l.emptyGarbage),canUpload:!!(l!=null&&l.uploadFile),onCollapse:()=>{re(),y("explorer")},expandedPaths:b,loadingPaths:E,loading:N,explorerScrollTopRef:V,explorerScrollerRef:S,...De,onPreview:$e,onSelect:P=>{v(P)},onToggle:F,selectedNodeId:(X==null?void 0:X.id)??null,tree:u,liveNodes:f}),we=t.jsx(Lh,{error:w,imageUrl:R,loadingMore:$,onLoadMore:ie,...l!=null&&l.writeFile?{onSaveFile:ye}:{},onCollapse:()=>{re(),y("viewer")},pdfUrl:H,previewFile:A,previewLoading:q,plugins:a,selectedTarget:Eh(X)});return j==="explorer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:we}):j==="viewer"?t.jsx("div",{"data-testid":"workspace-panel",className:"relative h-full min-h-0 w-full overflow-hidden p-2",children:de}):t.jsxs("div",{"data-testid":"workspace-panel",className:"flex h-full min-h-0 w-full overflow-hidden bg-transparent p-2",children:[Z?t.jsx(Ih,{files:ee,onCancel:()=>B(!1),onConfirm:()=>void je()}):null,O?t.jsxs(En,{direction:"vertical",className:"thread-graph-workspace-mobile-stack",children:[t.jsx(er,{defaultSize:42,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-explorer h-full min-h-0 overflow-hidden",children:de})}),t.jsx(Ln,{className:"thread-graph-workspace-resize-handle h-2 bg-transparent after:h-px after:bg-slate-200/80 after:transition-colors hover:after:bg-slate-300 dark:after:bg-[#303642] dark:hover:after:bg-[#475063]"}),t.jsx(er,{defaultSize:58,minSize:18,children:t.jsx("div",{className:"thread-graph-workspace-mobile-viewer h-full min-h-0 overflow-hidden",children:we})})]}):t.jsxs(En,{direction:"horizontal",className:"thread-graph-workspace-resizable",children:[t.jsx(er,{defaultSize:33,minSize:20,children:t.jsx("div",{className:"thread-graph-workspace-explorer-pane h-full min-h-0 overflow-hidden",children:de})}),t.jsx(Ln,{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(er,{defaultSize:67,minSize:30,children:t.jsx("div",{className:"thread-graph-workspace-viewer-pane h-full min-h-0 overflow-hidden",children:we})})]}),t.jsx("input",{ref:L,type:"file","aria-label":"Workspace upload file input","data-testid":"workspace-upload-file-input",className:"hidden",onChange:P=>void W(P)})]})}var Br,Go,Fo,Ho,Oo,Gr,Wo,Uo,Vo,$h=Ge({"src/components/graph-workspace/GraphWorkspaceExplorer.tsx"(){ea(),Ph(),zh(),No(),Br=24e3,Go="remote-codex:graphchat:workspace:expanded:",Fo="thread-graph-explorer h-full min-h-0 overflow-hidden rounded-[12px]",Ho="thread-graph-explorer-header flex h-[60px] shrink-0 items-center justify-between border-b px-4",Oo="text-[18px] font-semibold text-slate-900 dark:text-slate-100",Gr="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",Wo="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",Uo="thread-graph-workspace-label px-3 pb-1 pt-2 text-[11px] font-semibold tracking-normal text-slate-500 dark:text-slate-400",Vo="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 gn({children:e}){return t.jsx("span",{className:"thread-guide-tag inline-flex items-center rounded px-1.5 py-0.5 font-mono text-[10px]",children:e})}function qt({items:e}){return t.jsx("ul",{className:"space-y-1 text-[12px] text-[var(--theme-fg-muted)]",children:e.map((r,n)=>t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"mt-[6px] h-1 w-1 shrink-0 rounded-full bg-[var(--theme-border-contrast)]"}),t.jsx("span",{children:r})]},n))})}function Dh({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 dr({value:e,title:r,icon:n,children:a}){return t.jsxs(jr,{value:e,className:"thread-guide-section border-b border-[var(--theme-border)] last:border-b-0",children:[t.jsx(Qr,{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(Dh,{children:n}),r]})}),t.jsx(Nr,{className:"space-y-3 pb-3",children:a})]})}function Bh(){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(yr,{type:"multiple",defaultValue:["start","workspace","remote-codex"],className:"space-y-0",children:[t.jsxs(dr,{value:"start",title:"Getting Started",icon:t.jsx(M.Zap,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"graphchat connects a language model to your files and a set of tools. Each Remote Codex thread has its own isolated workspace."}),t.jsx(qt,{items:["Upload data files via the Workspace panel","Type a question or task in plain language","The agent calls tools, writes results to the workspace, and explains what it found","Agent-produced files appear in the workspace automatically when the host reports changes"]})]}),t.jsxs(dr,{value:"workspace",title:"Workspace Explorer",icon:t.jsx(M.FolderOpen,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M.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(M.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(M.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(M.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(M.RefreshCw,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Refresh"}),t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Resync the file tree manually after shell commands, external changes, or agent tool runs."})]})]}),t.jsxs("div",{className:"rounded-lg border border-[var(--theme-border)] p-2.5",children:[t.jsx("p",{className:"mb-1.5 text-[10px] font-semibold uppercase tracking-wide text-[var(--theme-fg-muted)]",children:"Preview surfaces"}),t.jsx(qt,{items:[t.jsxs(t.Fragment,{children:[t.jsx(gn,{children:".xyz .extxyz .cif"})," use the 3D molecule plugin."]}),t.jsxs(t.Fragment,{children:[t.jsx(gn,{children:".png .jpg .gif .svg .webp"})," use inline image preview."]}),t.jsxs(t.Fragment,{children:[t.jsx(gn,{children:".py .json .ts .md .csv"})," use text/code preview."]}),"Large files load in chunks when the workspace adapter supports it."]})]})]}),t.jsxs(dr,{value:"viewer",title:"Viewer",icon:t.jsx(M.FileImage,{className:"h-3 w-3"}),children:[t.jsx("p",{className:"text-[11px] leading-5 text-[var(--theme-fg-muted)]",children:"Viewer is the GraphChat-style artifact surface. It opens Remote Codex artifacts through the same frontend plugin renderers used in rich message bubbles, and previews workspace files from Explorer."}),t.jsx(qt,{items:["Expand one artifact at a time for inspection","Fallback JSON preview is available for unknown artifact types","3D molecule artifacts remain interactive when the XYZ plugin is enabled"]})]}),t.jsxs(dr,{value:"usage",title:"Tool Usage & Chat",icon:t.jsx(M.BarChart2,{className:"h-3 w-3"}),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M.BarChart2,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Usage tab"}),t.jsx(qt,{items:["Bar chart of tool and command counts for this thread","Expandable call log: inspect every input and output","Recent live events appear with persisted history"]})]})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(M.MessageSquare,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--theme-fg-muted)]"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-[11px] font-medium text-[var(--theme-fg)]",children:"Chat controls"}),t.jsx(qt,{items:["New Chat creates a fresh Remote Codex thread with its own workspace","Interrupt, compact, goal controls, and model controls remain in the composer","Shell view stays available when a shell adapter is attached"]})]})]})]}),t.jsx(dr,{value:"remote-codex",title:"Remote Codex Extras",icon:t.jsx(M.Code2,{className:"h-3 w-3"}),children:t.jsx(qt,{items:["Slash toolbox: skills, MCP, hooks, goals, forks, model controls, provider settings","Rich message bubbles: reasoning, commands, searches, file reads, file changes, plans, action requests, artifacts","Plugin surfaces: terminal, XYZ molecule viewer, inline code renderers, and imported plugin panels","Thread metadata stays in the left rail and Workspace tab instead of replacing chat"]})})]})})]})}var Gh=Ge({"src/components/graph-workspace/GraphGuidePanel.tsx"(){Cr()}});function Fh(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 Ua({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:Fh(r)})]})}function Hh({event:e}){return t.jsxs(jr,{value:e.id,className:"thread-tool-call mb-2 overflow-hidden rounded-lg border border-[var(--theme-border)] last:mb-0",children:[t.jsxs(Qr,{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(Nr,{className:"px-3 pb-3",children:t.jsxs("div",{className:"space-y-2 px-3 pb-3 pt-1",children:[t.jsx(Ua,{label:"Input",value:e.preview}),t.jsx(Ua,{label:"Output",value:e.detail})]})})]})}function Oh({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(M.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(yr,{type:"single",collapsible:!0,value:o??"",onValueChange:i=>s(i||null),className:"space-y-0",children:n.slice(-50).map(i=>t.jsx(Hh,{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(M.RefreshCw,{className:"h-3 w-3"}),"Reload from workspace"]})]})}var Wh=Ge({"src/components/graph-workspace/GraphToolUsagePanel.tsx"(){Cr()}});function Va(e,r){const n=Math.max(e.measured.width??1,1),a=Math.max(e.measured.height??1,1),o=e.internals.positionAbsolute,s=r.internals.positionAbsolute,l=Math.max(r.measured.width??1,1),i=Math.max(r.measured.height??1,1),d=n/2,h=a/2,u=o.x+d,m=o.y+h,f=s.x+l/2,p=s.y+i/2,g=(f-u)/(2*d)-(p-m)/(2*h),v=(f-u)/(2*d)+(p-m)/(2*h),b=1/(Math.abs(g)+Math.abs(v)),x=b*g,j=b*v,y=d*(x+j)+u,w=h*(-x+j)+m;return{x:y,y:w}}function Ka(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?$t.Left:s>=a+(e.measured.width??1)-1?$t.Right:l<=o+1?$t.Top:l>=n.y+(e.measured.height??1)-1?$t.Bottom:$t.Top}function Ko(e,r){const n=Va(e,r),a=Va(r,e),o=Ka(e,n),s=Ka(r,a);return{sx:n.x,sy:n.y,tx:a.x,ty:a.y,sourcePos:o,targetPos:s}}function Uh(e,r=900,n=620){if(!e||!Array.isArray(e))return{nodes:[],edges:[]};const a=(d,h,u,m)=>{const f=new Map,p=d.length;d.forEach((g,v)=>{const b=g.id.split("").reduce((x,j)=>{const y=(x<<5)-x+j.charCodeAt(0);return y&y},0);f.set(g.id,{x:Math.abs(b)%u+v*100%u,y:Math.abs(b>>16)%m+v*150%m,vx:0,vy:0})});for(let g=0;g<200;g+=1){for(let v=0;v<p;v+=1)for(let b=v+1;b<p;b+=1){const x=d[v],j=d[b];if(!x||!j)continue;const y=f.get(x.id),w=f.get(j.id);if(!y||!w)continue;const k=y.x-w.x,N=y.y-w.y,C=Math.sqrt(k*k+N*N)||1,z=(200-C)*.5,q=k/C*z,D=N/C*z;y.vx+=q,y.vy+=D,w.vx-=q,w.vy-=D}h.forEach(v=>{const b=f.get(v.source),x=f.get(v.target);if(!b||!x)return;const j=x.x-b.x,y=x.y-b.y,w=Math.sqrt(j*j+y*y)||1,N=(w-120)*.3,C=j/w*N,E=y/w*N;b.vx+=C,b.vy+=E,x.vx-=C,x.vy-=E}),f.forEach(v=>{v.x+=v.vx*.1,v.y+=v.vy*.1,v.vx*=.9,v.vy*=.9,v.x=Math.max(80,Math.min(u-80,v.x)),v.y=Math.max(80,Math.min(m-80,v.y))})}return f},o=new Set(e.map(d=>d.id)),s=[];e.forEach(d=>{if(!d.out_node_id)return;(Array.isArray(d.out_node_id)?d.out_node_id:[d.out_node_id]).forEach(u=>{o.has(u)&&s.push({id:`${d.id}-${u}`,source:d.id,target:u,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ms.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 ta=Ge({"src/components/graph-chat/FloatingHelper.tsx"(){}});function Vh({toX:e,toY:r,fromPosition:n,toPosition:a,fromNode:o}){if(!o)return null;const s={id:"connection-target",measured:{width:1,height:1},internals:{positionAbsolute:{x:e,y:r}}},{sx:l,sy:i,tx:d,ty:h,sourcePos:u,targetPos:m}=Ko(o,s),[f]=$s({sourceX:l,sourceY:i,sourcePosition:u||n,targetPosition:m||a,targetX:d||e,targetY:h||r});return t.jsxs("g",{children:[t.jsx("path",{fill:"none",stroke:"currentColor",strokeWidth:1.5,className:"animated",d:f}),t.jsx("circle",{cx:d||e,cy:h||r,fill:"var(--theme-panel)",r:3,stroke:"currentColor",strokeWidth:1.5})]})}var Kh=Ge({"src/components/graph-chat/FloatingConnectionLine.tsx"(){ta()}});function qh({id:e,source:r,target:n,markerEnd:a,style:o}){const s=ka(r),l=ka(n);if(!s||!l)return null;const{sx:i,sy:d,tx:h,ty:u,sourcePos:m,targetPos:f}=Ko(s,l),[p]=$s({sourceX:i,sourceY:d,sourcePosition:m,targetPosition:f,targetX:h,targetY:u});return t.jsx("path",{id:e,className:"react-flow__edge-path",d:p,markerEnd:a,style:o})}var Xh=Ge({"src/components/graph-chat/FloatingEdge.tsx"(){ta()}});function Yh({nodes:e}){const[r,n,a]=hd([]),[o,s,l]=ud([]),i=c.useMemo(()=>Uh(e),[e]),d=c.useMemo(()=>({floating:qh}),[]),h=c.useMemo(()=>({styledNode:({data:m,isConnectable:f})=>t.jsxs("div",{className:"thread-graph-flow-node",children:[m.label,t.jsx(va,{type:"target",position:$t.Top,isConnectable:f,style:{opacity:0,pointerEvents:"none"}}),t.jsx(va,{type:"source",position:$t.Bottom,isConnectable:f,style:{opacity:0,pointerEvents:"none"}})]})}),[]);c.useEffect(()=>{n(i.nodes),s(i.edges)},[i.edges,i.nodes,s,n]);const u=c.useCallback(m=>s(f=>md({...m,type:"floating",sourceHandle:null,targetHandle:null,markerEnd:{type:Ms.Arrow}},f)),[s]);return t.jsx("div",{className:"thread-graph-flow h-full min-h-0",children:t.jsx(pd,{children:t.jsxs(fd,{nodes:r,edges:o,onNodesChange:a,onEdgesChange:l,onConnect:u,fitView:!0,nodeTypes:h,edgeTypes:d,connectionLineComponent:Vh,children:[t.jsx(gd,{}),t.jsx(xd,{gap:16})]})})})}var Zh=Ge({"src/components/graph-chat/GraphVisualization.tsx"(){Kh(),Xh(),ta()}});function Jh(e){return{...Xo,...e}}function qa(e,r){const n=a=>{switch(a){case"workspace":return e.workspace;case"tools":return e.toolUsage;case"guide":return e.guide;case"graph":return e.threadGraph;case"extensions":return e.extensions}};return r&&n(r)?r:["workspace","tools","guide","graph","extensions"].find(n)??null}function Qh(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 eu(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:Wr(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:Wr(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 Wr(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 tu(e){switch(e.kind){case"userMessage":return"User";case"agentMessage":return"Agent";default:return Wr(e.kind)}}function ru(e){return(e.previewText??e.text??e.detailText??e.kind).replace(/\s+/g," ").slice(0,96)}function nu(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:tu(d),description:ru(d),out_node_id:u}),i=h,d.kind==="artifact"&&d.artifact&&n.push({id:`artifact:${d.artifact.id}`,name:d.artifact.title||d.artifact.type,description:d.artifact.summaryText??d.artifact.type,out_node_id:h})}}const o=new Set(n.map(s=>s.id));for(const s of r){const l=`tool:${s.id}`;o.has(l)||o.has(`item:${s.id}`)||n.push({id:l,name:s.label,description:s.preview,out_node_id:s.turnId?`turn:${s.turnId}`:`thread:${e.thread.id}`})}return n.slice(0,120)}function qo({detail:e,status:r,plugins:n,workspaceAdapter:a,metaContent:o,settingsContent:s,activeView:l="chat",features:i,focusPathRequest:d=null}){const h=c.useMemo(()=>Jh(i),[i]),u=qa(h,i==null?void 0:i.defaultTab),[m,f]=c.useState(u),p=c.useMemo(()=>Vc(e),[e]),g=c.useMemo(()=>eu(e),[e]),v=c.useMemo(()=>{const k=new Map;for(const N of g)k.set(N.kind,(k.get(N.kind)??0)+1);return[...k.entries()].sort((N,C)=>C[1]-N[1])},[g]),b=n.getThreadPanels(),x=Math.max(...v.map(([,k])=>k),1),j=c.useMemo(()=>nu(e,g),[e,g]),y=c.useMemo(()=>{const k=[];return h.workspace&&k.push({id:"workspace",label:"Workspace",icon:null}),h.toolUsage&&k.push({id:"tools",label:"Tool Usage",icon:M.BarChart2}),h.guide&&k.push({id:"guide",label:"Guide",icon:M.BookOpen}),k},[h.guide,h.toolUsage,h.workspace]),w=c.useMemo(()=>{const k=[];return h.threadGraph&&k.push({id:"graph",label:"Thread graph",icon:M.GitBranch}),h.extensions&&k.push({id:"extensions",label:"Remote Codex extensions",icon:M.Wrench}),k},[h.extensions,h.threadGraph]);return c.useEffect(()=>{(!m||!Qh(h,m))&&f(qa(h,i==null?void 0:i.defaultTab))},[m,i==null?void 0:i.defaultTab,h]),c.useEffect(()=>{d&&h.workspace&&f("workspace")},[h.workspace,d==null?void 0:d.requestId]),m?t.jsxs("div",{className:"thread-graph-right-panel flex h-full min-h-0 flex-col overflow-hidden",children:[t.jsxs("div",{className:"thread-graph-right-tabs flex shrink-0 items-center gap-1 overflow-hidden border-b px-3 py-2",children:[y.map(k=>{const N=k.icon;return t.jsxs("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 shrink-0 items-center gap-1.5 rounded-md px-3 text-xs font-medium transition ${m===k.id?"is-active":""}`,children:[N?t.jsx(N,{className:"h-3.5 w-3.5"}):null,k.label]},k.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(k=>{const N=k.icon;return t.jsx("button",{type:"button",onClick:()=>f(k.id),className:`thread-graph-right-tab inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-xs font-medium transition ${m===k.id?"is-active":""}`,title:k.label,"aria-label":k.label,children:t.jsx(N,{className:"h-3.5 w-3.5"})},k.id)})}):null]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[m==="workspace"?t.jsx(Mh,{activeView:l,detail:e,artifacts:p,plugins:n,status:r,focusPathRequest:d,workspaceAdapter:a??null}):null,m==="tools"?t.jsx(Oh,{formatToolKind:Wr,toolCounts:v,toolEvents:g,maxToolCount:x}):null,m==="graph"?t.jsx("div",{className:"thread-graph-visualization-panel h-full min-h-0 p-3",children:t.jsx(Yh,{nodes:j})}):null,m==="extensions"?t.jsx("div",{className:"h-full min-h-0 overflow-y-auto p-3",children:t.jsxs("div",{className:"grid gap-3",children:[t.jsx(Zt,{label:"Plugin Panels",children:b.length?t.jsx("div",{className:"flex flex-wrap gap-2",children:b.map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.label},k.id))}):t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"No thread panels are enabled."})}),t.jsx(Zt,{label:"Enabled Renderers",children:t.jsx("div",{className:"flex flex-wrap gap-2",children:n.plugins.filter(k=>k.enabled).map(k=>t.jsx("span",{className:"rounded-full border border-[var(--theme-border)] px-2 py-1 text-xs text-[var(--theme-fg-soft)]",children:k.name},k.id))})}),t.jsx(Zt,{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(M.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(M.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(M.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(Zt,{label:"Thread Meta",children:o}):null,s?t.jsx(Zt,{label:"Settings",children:s}):null]})}):null,m==="guide"?t.jsx(Bh,{}):null]})]}):null}var Xo,Yo,au=Ge({"src/components/ThreadGraphWorkspacePanel.tsx"(){$h(),zo(),Gh(),Wh(),ea(),Zh(),Xo={workspace:!0,toolUsage:!0,guide:!0,threadGraph:!0,extensions:!0},Yo=c.memo(qo)}}),Zo={};Uc(Zo,{MemoizedThreadGraphWorkspacePanel:()=>Yo,ThreadGraphWorkspacePanel:()=>qo});var su=Ge({"src/workspace-panel.ts"(){au()}});function nr(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))}nr(`.thread-ui-shell,
|
|
14
14
|
.thread-graph-dialog {
|
|
15
15
|
color-scheme: light;
|
|
16
16
|
--radius: 0.625rem;
|
|
@@ -638,7 +638,7 @@ import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c
|
|
|
638
638
|
border-color: #465164;
|
|
639
639
|
background: #2b313d;
|
|
640
640
|
}
|
|
641
|
-
`);
|
|
641
|
+
`);nr(`.thread-ui-shell .thread-detail-surface {
|
|
642
642
|
border-color: transparent;
|
|
643
643
|
background: var(--theme-surface);
|
|
644
644
|
box-shadow: none;
|
|
@@ -886,7 +886,7 @@ import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c
|
|
|
886
886
|
.thread-ui-shell .thread-graph-history-group-list {
|
|
887
887
|
border-color: var(--theme-border);
|
|
888
888
|
}
|
|
889
|
-
`);
|
|
889
|
+
`);nr(`.thread-ui-shell .thread-workspace-panel {
|
|
890
890
|
background: var(--theme-panel);
|
|
891
891
|
}
|
|
892
892
|
.thread-ui-shell .thread-workspace-card {
|
|
@@ -1358,7 +1358,7 @@ import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c
|
|
|
1358
1358
|
display: inline-flex;
|
|
1359
1359
|
transform: translateY(-50%);
|
|
1360
1360
|
}
|
|
1361
|
-
`);
|
|
1361
|
+
`);nr(`} .thread-ui-shell .thread-graph-panel-expand-fab.left-3 {
|
|
1362
1362
|
left: 0.75rem;
|
|
1363
1363
|
}
|
|
1364
1364
|
.thread-ui-shell .thread-graph-panel-expand-fab.right-3 {
|
|
@@ -2694,7 +2694,7 @@ import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c
|
|
|
2694
2694
|
padding: 0.375rem 1rem;
|
|
2695
2695
|
}
|
|
2696
2696
|
}
|
|
2697
|
-
`);
|
|
2697
|
+
`);nr(`.thread-ui-shell .timeline-soft-text,
|
|
2698
2698
|
.thread-ui-shell .thread-message-prose :where(blockquote) {
|
|
2699
2699
|
color: var(--theme-fg-soft);
|
|
2700
2700
|
}
|
|
@@ -3506,7 +3506,7 @@ import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c
|
|
|
3506
3506
|
.thread-ui-shell[data-theme-effective=light] .thread-graph-plan-step-text {
|
|
3507
3507
|
color: rgb(15 23 42) !important;
|
|
3508
3508
|
}
|
|
3509
|
-
`);
|
|
3509
|
+
`);nr(`.thread-export-dialog-root {
|
|
3510
3510
|
--export-bg: rgb(248 250 252);
|
|
3511
3511
|
--export-panel: rgb(255 255 255);
|
|
3512
3512
|
--export-surface: rgb(241 245 249);
|
|
@@ -3635,9 +3635,9 @@ import{l as M,R as Bi,I as Gi,C as Fi,S as As,H as Hi,T as Oi,a as Ui,b as Wi,c
|
|
|
3635
3635
|
padding: 1.5rem;
|
|
3636
3636
|
}
|
|
3637
3637
|
}
|
|
3638
|
-
`);function
|
|
3639
|
-
`)}function
|
|
3640
|
-
`).map(o=>o.trim()).filter(Boolean).find(o=>/^\[mcp_servers\.[^\]]+\]$/.test(o));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function
|
|
3638
|
+
`);function ou(e){return e.replace(/\u00a0/g," ")}function lu(e,r){if(!e)return[];const n=[],a=[...r].sort((l,i)=>i.placeholder.length-l.placeholder.length);let o=0,s=0;for(;o<e.length;){const l=a.find(h=>e.startsWith(h.placeholder,o));if(l){n.push({type:"attachment",key:`${l.clientId}-${o}`,attachment:l}),o+=l.placeholder.length;continue}let i=e.length;for(const h of a){const u=e.indexOf(h.placeholder,o);u!==-1&&u<i&&(i=u)}const d=e.slice(o,i);d&&(n.push({type:"text",key:`text-${s}`,text:d}),s+=1),o=i}return n}function iu(e,r,n){const a=e==="photo"?"PHOTO":"FILE";let o=0;for(;;){const s=o===0?r:`${r} (${o+1})`,l=`[${a} ${s}]`;if(!n.has(l))return l;o+=1}}function du(e,r,n){const a=r.start>0?e[r.start-1]:"",o=r.end<e.length?e[r.end]:"",s=!!(a&&!/\s/.test(a)),l=!o||!/\s/.test(o);return`${s?" ":""}${n.join(" ")}${l?" ":""}`}function cu({files:e,kindForFile:r,usedPlaceholders:n,buildClientId:a}){return e.map(o=>{const s=r(o),l=ju(o,s),i=iu(s,Nu(l),n);return n.add(i),{clientId:a(),kind:s,originalName:l,placeholder:i,file:o}})}function hu({prompt:e,attachments:r,files:n,selection:a,kindForFile:o,buildClientId:s}){const l=new Set(r.map(p=>p.placeholder)),i=cu({files:n,kindForFile:o,usedPlaceholders:l,buildClientId:s}),d=a?{start:a.start,end:a.end}:{start:e.length,end:e.length},h=du(e,d,i.map(p=>p.placeholder)),u=`${e.slice(0,d.start)}${h}${e.slice(d.end)}`,m=h.endsWith(" ")?1:0,f=d.start+h.length-m;return{draft:{prompt:u,attachments:[...r,...i]},selection:{start:f,end:f},insertedAttachmentIds:i.map(p=>p.clientId)}}function uu({prompt:e,attachments:r,isShellView:n}){if(n)return{prompt:e};const a=e.trim();if(!a)return null;const o=r.filter(s=>a.includes(s.placeholder));return o.length>0?{prompt:a,attachments:o}:{prompt:a}}function mu({files:e,plainText:r,htmlText:n,htmlToText:a}){if(e.length>0)return{type:"append-files",preventDefault:!0,files:e};const o=r||a(n);return!o&&!n?{type:"ignore",preventDefault:!1}:{type:"insert-text",preventDefault:!0,text:o}}function Xa(e){return e?{type:"accept-files",preventDefault:!0,activateDragTarget:!0}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function pu(e){return e.length>0?{type:"accept-files",preventDefault:!0,activateDragTarget:!0,files:e}:{type:"ignore",preventDefault:!1,activateDragTarget:!1}}function fu({key:e,metaKey:r,ctrlKey:n,busy:a,disabled:o}){const s=e==="Enter"&&(r||n);return{preventDefault:s,submit:s&&!a&&!o}}function gu({nextMode:e,previousOptimisticMode:r}){return{optimisticMode:e??null,rollbackMode:e?r:null,shouldRollbackMode:!!e,closeMenuOnSuccess:!0}}function Pr(e){return`${e.prompt}${e.attachments.map(r=>`${r.clientId}${r.kind}${r.placeholder}${r.originalName}`).join("")}`}function Ya(e){if(!e)return"Auto";switch(e){case"xhigh":return"xhigh";default:return e}}function xu(e){const r=e.trim();if(!r)return null;const n=Number(r);return!Number.isFinite(n)||n<=0?Number.NaN:Math.round(n*1e3)}function bu(e){if(!e)return"";const r=e/1e3;return Number.isInteger(r)?String(r):String(Number(r.toFixed(1)))}function _n(e){return e.replace(/\r\n/g,`
|
|
3639
|
+
`)}function vu(e){const r=e.trim();return/^[A-Za-z0-9_-]+$/.test(r)?r:null}function ku(e){const n=_n(e).split(`
|
|
3640
|
+
`).map(o=>o.trim()).filter(Boolean).find(o=>/^\[mcp_servers\.[^\]]+\]$/.test(o));if(!n)return null;const a=n.match(/^\[mcp_servers\.([A-Za-z0-9_-]+)\]$/);return(a==null?void 0:a[1])??null}function wu(e,r){return`[mcp_servers.${e}]
|
|
3641
3641
|
url = ${JSON.stringify(r.trim())}
|
|
3642
3642
|
`}function Za(e,r,n){var m,f;const a=_n(e),o=`${_n(n).trim()}
|
|
3643
3643
|
`,s=a.split(`
|
|
@@ -3650,28 +3650,28 @@ url = ${JSON.stringify(r.trim())}
|
|
|
3650
3650
|
`).concat(`
|
|
3651
3651
|
`)}const u=a.trimEnd();return u?`${u}
|
|
3652
3652
|
|
|
3653
|
-
${o}`:o}function Zo(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function fn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function wu(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,`${fn(n)} used / ${fn(a)}`,`${fn(o)} left`,`${Zo(r.remainingPercent)}% context left`].join(" · ")}function yu(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 ju(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Mn(e){return e.type.startsWith("image/")?"photo":"file"}function $n(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 Ja(e,r){return $n(e,r).length>0}function Nu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Qa(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Nu(e.originalName)}var Or=[{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 Cu({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Su({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 Tu(){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 Eu(){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 Lu(){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 Pu(){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 zu(){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 Dn(){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 Iu(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Ru(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function Au(e){var r;return((r=Or.find(n=>n.value===e))==null?void 0:r.label)??e}function _u(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 Mu(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function $u(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 Du(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Jo(e){const r=Du(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 Bu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Gu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Zo(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 Mt({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 Fu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Hu(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Ou(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?Bu(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Uu(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function Wu(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 Vu(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function Ku(e){return!!e.querySelector("[style], font")}function Dt(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function Qo(e){let r="";for(const n of Array.from(e.childNodes))r+=Dt(n);return r.replace(/\u00a0/g," ")}function es(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Dt(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return Qo(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Dt(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Dt(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,Dt(d).length);l+=Dt(d).length}return l}function qu(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:es(e,n.startContainer,n.startOffset),end:es(e,n.endContainer,n.endOffset)}}function ts(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Dt(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 Xu(e,r){const n=ts(e,r.start),a=ts(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 Yu(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}Yr();zt();function Zu({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 Ju=kr("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 Qu({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:Qe(Ju({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 em=kr("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 wt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(vr,{type:r,"data-size":a,variant:n,className:Qe(em({size:a}),e),...o})}function tm({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 rm({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 nm({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-0 z-[90] inline-flex h-11 min-w-[7rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",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 am({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:m,formRef:f,promptSlot:p,toolbarSlot:g,goalSlot:v,shellPromptSlot:b}){return t.jsxs("div",{className:r,children:[t.jsx(rm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(nm,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:f,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:m,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Zu,{className:o,children:[p,g]}),v,b]}),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 sm({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(wt,{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(Eu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var el=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function rs(e){var r;return((r=el.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function om({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:v,fastMode:b,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:w,effortControlTitle:k,inlineToggleClassName:N,menuItemClassName:C,planToggleActiveClassName:E,sendButtonBaseClassName:I,onSetOpenMenu:q,onUpdateSettings:D}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>q($=>$==="model"?null:"model"),title:b?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${N} 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(Gu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map($=>t.jsx("button",{type:"button",onClick:()=>D({model:$.model,reasoningEffort:$.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.model===r?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.model})},$.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:w,onClick:()=>q($=>$==="effort"?null:"effort"),title:k,className:`${N} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${w?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ya(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map($=>t.jsx("button",{type:"button",onClick:()=>D({reasoningEffort:$.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.reasoningEffort===s?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ya($.reasoningEffort)})},$.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${rs(d)}`,disabled:m,onClick:()=>q($=>$==="sandbox"?null:"sandbox"),title:`Sandbox: ${rs(d)}`,className:`${N} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:el.map($=>t.jsx("button",{type:"button",onClick:()=>D({sandboxMode:$.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.mode===d?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.label})},$.mode))})})]}),h&&t.jsx(wt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>D({collaborationMode:i==="plan"?"default":"plan"}),className:`${N} rounded-full px-2.5 ${i==="plan"?`${E} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(wt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?v:!1),className:`${I} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function lm({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(Dn,{}),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(Dn,{}),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(Mt,{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(Mt,{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(Mt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"DOWN"})})]})})}function im({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 dm({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 cm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:v,onSetHooksPanelMode:b,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:w,onSetHookMatcher:k,onSetHookCommand:N,onSetHookTimeoutSec:C,onSetHookStatusMessage:E,onSaveHook:I,onStartEditingHook:q,onTrustHook:D,onUntrustHook:$}){var Q,Z,B,ee,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Q=r.data)==null?void 0:Q.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),v(),b("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",$u((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:A=>y(A.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:A=>w(A.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:Or.map(A=>t.jsx("option",{value:A.value,children:A.label},A.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:A=>k(A.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:A=>N(A.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:A=>C(A.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:A=>E(A.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:()=>{b("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void I(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(A=>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:A},A))}):null,e==="list"&&((B=r.data)!=null&&B.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(A=>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:A.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:A.path})]},`${A.path}:${A.message}`))}):null,e==="list"&&((ee=r.data)!=null&&ee.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(A=>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:[Au(A.eventName),A.matcher?` · ${A.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:A.command??A.handlerType}),A.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:A.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:[Jo(A)?t.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),q(A)},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&&A.trustStatus==="trusted"&&!A.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:J=>{J.stopPropagation(),$(A)},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,(A.trustStatus==="untrusted"||A.trustStatus==="modified")&&!A.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!A.currentHash,onClick:J=>{J.stopPropagation(),D(A)},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:Mu(A.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:_u(A.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:A.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[A.timeoutSec,"s"]})]})]},A.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function hm({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:v,onSetMcpRawBlock:b,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var w,k;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:N=>g(N.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:N=>v(N.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:N=>b(N.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((w=r.data)!=null&&w.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(N=>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:N.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[N.tools.length," tools · ",N.resourceCount," ","resources · ",N.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:Iu(N.authStatus)})]}),N.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:N.tools.slice(0,4).map(C=>C.title??C.name).join(" · ")}):null]},N.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function um({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:Ru(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(Dn,{}),"$",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 mm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:v,hookScope:b,hookEventName:x,hookMatcher:j,hookCommand:y,hookTimeoutSec:w,hookStatusMessage:k,mcpPanelMode:N,mcpState:C,mcpConfigEditing:E,mcpConfigPath:I,mcpConfigError:q,mcpConfigSuccess:D,mcpConfigBusy:$,mcpHttpName:Q,mcpHttpUrl:Z,mcpRawBlock:B,iconButtonClassName:ee,menuClassName:oe,menuItemClassName:A,panelButtonClassName:J,chipButtonClassName:R,onToggle:Y,onToolboxItemClick:H,toolboxItemDisabled:T,toolboxItemClassName:O,toolboxItemStatus:G,onSetSlashPanelView:L,onOpenForkTurns:S,onForkLatest:V,onForkTurn:K,onCopySkillInvokeName:le,onResetHookForm:X,onSetHooksPanelMode:ce,onClearHookConfigStatus:re,onSetEditingHookTarget:fe,onSetHookScope:he,onSetHookEventName:ve,onSetHookMatcher:Re,onSetHookCommand:ie,onSetHookTimeoutSec:ye,onSetHookStatusMessage:Te,onSaveHook:U,onStartEditingHook:ae,onTrustHook:xe,onUntrustHook:ke,onSetMcpPanelMode:$e,onClearMcpConfigStatus:Me,onSetMcpHttpName:je,onSetMcpHttpUrl:De,onSetMcpRawBlock:F,onPrepareRawMcpBlock:de,onSaveHttpMcp:we,onSaveRawMcpBlock:P}){return t.jsxs("div",{className:"relative",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:Y,className:`${ee} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Lu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${oe} 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:_=>{_.stopPropagation()},onMouseDown:_=>{_.stopPropagation()},onPointerDown:_=>{_.stopPropagation()},onTouchStart:_=>{_.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((_,se)=>t.jsx("button",{type:"button",disabled:T(_),onClick:ge=>H(_,ge),className:`${O(_)} ${se===0?"mt-0":""}`,title:_.description??_.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:_.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:G(_)})]})},`${_.action}:${_.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(im,{busy:a,forkBusy:o,composerMenuItemClassName:A,onForkLatest:V,onSelectForkTurnPanel:()=>(L("forkTurns"),S())}):r==="forkTurns"?t.jsx(dm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:J,onForkTurn:K}):r==="skills"?t.jsx(um,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:R,onCopySkillInvokeName:le}):r==="hooks"?t.jsx(cm,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:v,hookScope:b,hookEventName:x,hookMatcher:j,hookCommand:y,hookTimeoutSec:w,hookStatusMessage:k,composerChipButtonClassName:R,onResetHookForm:X,onSetHooksPanelMode:ce,onClearHookConfigStatus:re,onSetEditingHookTarget:fe,onSetHookScope:he,onSetHookEventName:ve,onSetHookMatcher:Re,onSetHookCommand:ie,onSetHookTimeoutSec:ye,onSetHookStatusMessage:Te,onSaveHook:U,onStartEditingHook:ae,onTrustHook:xe,onUntrustHook:ke}):t.jsx(hm,{mcpPanelMode:N,mcpState:C,mcpConfigEditing:E,mcpConfigPath:I,mcpConfigError:q,mcpConfigSuccess:D,mcpConfigBusy:$,mcpHttpName:Q,mcpHttpUrl:Z,mcpRawBlock:B,composerPanelButtonClassName:J,composerChipButtonClassName:R,onSetMcpPanelMode:$e,onClearMcpConfigStatus:Me,onSetMcpHttpName:je,onSetMcpHttpUrl:De,onSetMcpRawBlock:F,onPrepareRawMcpBlock:de,onSaveHttpMcp:we,onSaveRawMcpBlock:P})})})]})}function pm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(Qu,{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(mm,{...i}):null,!e&&d?t.jsx(sm,{...d}):null,r&&t.jsx(wt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Pu,{}):t.jsx(Tu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(om,{...h}):null,e&&a?t.jsx(tm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(zu,{})}),o==="shellTools"&&u?t.jsx(lm,{...u}):null]})]})]})}function fm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function gm(e){return[...e.filter(r=>Mn(r)==="photo"),...e.filter(r=>Mn(r)==="file")]}function xm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=fm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=cu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(gm(f),Mn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function ns(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function bm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){ns(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()=>{ns(s)}},[]),a}var vm=180;function gn(e,r){return{prompt:e??"",attachments:r??[]}}function km({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>gn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Lr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Lr(gn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=gn(r,n),w=Lr(y);w!==p.current&&(p.current=w,u.current=w,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const w=Lr(y);w!==u.current&&(u.current=w,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const v=c.useCallback((y,w)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),w==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},vm)}},[m,g]),b=c.useCallback((y=h.current)=>{v(y,"immediate")},[v]),x=c.useCallback((y,w="immediate")=>{if(m){const k=y(h.current);h.current=k,i(k),v(k,w);return}s(k=>y(k))},[m,v]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:b}}function wm({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 ym({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[v,b]=c.useState(null),x=c.useCallback(async()=>{const w=e.trim();if(!w)return b("Goal objective cannot be empty."),!1;const k=m.trim(),N=gu(k);if(k.length>0&&(N===null||!Number.isInteger(N)||N<=0))return b("Token budget must be a positive number in thousands."),!1;if(!s)return b("/goal is unavailable in this view."),!1;g(!0),b(null);try{return o&&await o({objective:w,tokenBudget:N})===!1?!1:(await s({objective:w,status:"active",tokenBudget:N}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(C){return b(C instanceof Error?C.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(xu(r==null?void 0:r.tokenBudget)),b(null),a==null||a(),requestAnimationFrame(()=>{var w;(w=n.current)==null||w.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),b(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:v,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var xn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function jm(e){const r=new Map;for(const n of e??[])r.set(n.eventName,n.command);return r}function Nm({slashPanelView:e,hookCommandTemplates:r,onCreateHook:n,onUpdateHook:a,onTrustHook:o,onUntrustHook:s}){const[l,i]=c.useState("list"),[d,h]=c.useState("project"),[u,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,v]=c.useState(xn),[b,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[w,k]=c.useState(null),[N,C]=c.useState(!1),[E,I]=c.useState(null),[q,D]=c.useState(null),$=c.useMemo(()=>jm(r),[r]),Q=c.useCallback(Y=>$.get(Y)??$.get("preToolUse")??xn,[$]),Z=c.useMemo(()=>new Set([xn,...$.values()]),[$]),B=c.useCallback(()=>{I(null),D(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),B())},[B,e]),c.useEffect(()=>{const Y=Or.find(H=>H.value===u);p(H=>{const T=H.trim(),O=new Set(Or.map(G=>G.matcherHint).filter(Boolean));return T&&!O.has(T)?H:(Y==null?void 0:Y.matcherHint)??""}),v(H=>Z.has(H.trim())?Q(u):H)},[Q,Z,u]);const ee=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),v(Q("preToolUse")),x("30"),y("Running hook")},[Q]),oe=c.useCallback(Y=>{const H=Jo(Y);if(!H){I("Only command hooks in global or project hooks.json can be edited here.");return}k(H),h(H.scope),m(H.eventName),p(H.matcher??""),v(H.command),x(H.timeoutSec?String(H.timeoutSec):""),y(H.statusMessage??""),I(null),D(null),i("edit")},[]),A=c.useCallback(async()=>{if(l==="edit"&&!a){I("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){I("Hook editing is unavailable in this view.");return}if(l==="edit"&&!w){I("Select a hook to edit first.");return}const Y=g.trim();if(!Y){I("Hook command cannot be empty.");return}const H=b.trim(),T=H?Number(H):null;if(H&&(T===null||!Number.isInteger(T)||T<=0)){I("Timeout must be a positive number of seconds.");return}C(!0),I(null),D(null);try{const O={scope:d,eventName:u,matcher:f.trim()||null,command:Y,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...O,target:w})):await(n==null?void 0:n(O)),D(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(O){I(O instanceof Error?O.message:"Unable to write hooks.json.")}finally{C(!1)}},[w,g,u,f,d,j,b,l,n,a]),J=c.useCallback(async Y=>{if(!o||!Y.currentHash){I("Hook trust is unavailable in this view.");return}C(!0),I(null),D(null);try{await o({key:Y.key,currentHash:Y.currentHash}),D("Hook trusted.")}catch(H){I(H instanceof Error?H.message:"Unable to trust hook.")}finally{C(!1)}},[o]),R=c.useCallback(async Y=>{if(!s){I("Hook trust is unavailable in this view.");return}C(!0),I(null),D(null);try{await s({key:Y.key}),D("Hook untrusted.")}catch(H){I(H instanceof Error?H.message:"Unable to untrust hook.")}finally{C(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:b,hookStatusMessage:j,editingHookTarget:w,hookConfigBusy:N,hookConfigError:E,hookConfigSuccess:q,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:v,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:B,resetHookForm:ee,startEditingHook:oe,saveHook:A,trustHook:J,untrustHook:R}}var Cm=`[mcp_servers.example_stdio]
|
|
3653
|
+
${o}`:o}function Jo(e){return typeof e!="number"||Number.isNaN(e)?0:Math.max(0,Math.min(100,Math.round(e)))}function xn(e){const r=e/1e3;return Number.isInteger(r)?`${r}k`:`${Number(r.toFixed(1))}k`}function yu(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,`${xn(n)} used / ${xn(a)}`,`${xn(o)} left`,`${Jo(r.remainingPercent)}% context left`].join(" · ")}function ju(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 Nu(e){return e.replace(/[\r\n[\]]+/g," ").replace(/\s+/g," ").trim()||"attachment"}function Mn(e){return e.type.startsWith("image/")?"photo":"file"}function $n(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 Ja(e,r){return $n(e,r).length>0}function Cu(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function Qa(e){const r=e.placeholder.match(/^\[(?:PHOTO|FILE)\s+(.+)\]$/);return r!=null&&r[1]?r[1]:Cu(e.originalName)}var Ur=[{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 Su({goalComposeMode:e,goalBusy:r,threadConnected:n,busy:a,isShellView:o,disabledPlaceholder:s,settingsBusy:l,supportedEffortCount:i,fastMode:d}){const h=e?"Describe the goal the backend should continue working toward...":s??(o?"Send shell input to the attached terminal...":"Ask the backend to inspect, modify, or explain code..."),u=e?r?"Setting...":"Set goal":!n&&a?"Connecting...":n&&a&&!o?"Sending...":"Send",m=n?e?"ui-action-info":"ui-action-primary":"ui-action-danger",f=l;return{promptPlaceholder:h,interruptLabel:o?"Send Ctrl-C":"Stop Current Turn",sendButtonLabel:u,sendButtonClassName:m,modelControlsDisabled:f,effortControlsDisabled:f||i===0,effortControlTitle:d?"Fast mode is on. Turn it off from the slash toolbox to edit reasoning.":i===0?"The selected model does not expose adjustable reasoning effort.":"Select reasoning effort"}}function Tu({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 Eu(){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 Lu(){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 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.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 Iu(){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 zu(){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 Dn(){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 Ru(e){switch(e){case"bearerToken":return"Token";case"oAuth":return"OAuth";case"notLoggedIn":return"Login";case"unsupported":return"Public";default:return"Unknown"}}function Au(e){switch(e){case"repo":return"Repo";case"system":return"System";case"admin":return"Admin";case"user":default:return"User"}}function _u(e){var r;return((r=Ur.find(n=>n.value===e))==null?void 0:r.label)??e}function Mu(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 $u(e){switch(e){case"managed":return"Managed";case"modified":return"Modified";case"trusted":return"Trusted";case"untrusted":return"Review"}}function Du(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 Bu(e){return e.source==="user"?"global":e.source==="project"?"project":null}function Qo(e){const r=Bu(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 Gu(e){switch(e){case"active":return"Active";case"paused":return"Paused";case"budgetLimited":return"Budget";case"complete":return"Complete";default:return e}}function Fu({contextUsage:e}){const r=(e==null?void 0:e.availability)??"unavailable",n=Jo(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 Mt({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 Hu(e,r){return(e??[]).filter(n=>{switch(n.action){case"fast":return r.fast;case"compact":return r.compact;case"goal":return r.goal;case"fork":return r.fork;case"skills":return r.skills;case"mcp":return r.mcp;case"hooks":return r.hooks;case"prompt":case"unsupported":return!0;default:return!1}})}function Ou(e,{fastMode:r,goalComposeMode:n}){switch(e.action){case"fast":return{type:"toggleFast",fastMode:!r};case"compact":return{type:"runCompact"};case"goal":return n?{type:"exitGoalCompose"}:{type:"enterGoalCompose"};case"fork":case"skills":case"mcp":case"hooks":return{type:"openPanel",panel:e.action};case"prompt":return{type:"insertPrompt",text:`${e.command} `};default:return{type:"noop"}}}function Wu(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?Gu(o):"Open";case"fork":return s?"Idle only":"Open";case"skills":case"mcp":case"hooks":return"View";case"prompt":return"Compose";case"unsupported":return"Unavailable";default:return""}}function Uu(e,{settingsBusy:r,compactBusy:n,busy:a,forkBusy:o}){switch(e.action){case"fast":return r;case"compact":return n||a;case"fork":return a||o;case"unsupported":return!0;default:return!1}}function Vu(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 Ku(e){if(!e)return"";const r=document.createElement("div");return r.innerHTML=e,r.textContent??""}function qu(e){return!!e.querySelector("[style], font")}function Dt(e){return e instanceof HTMLElement&&e.dataset.segmentType==="attachment"&&e.dataset.placeholder?e.dataset.placeholder:e.textContent??""}function el(e){let r="";for(const n of Array.from(e.childNodes))r+=Dt(n);return r.replace(/\u00a0/g," ")}function es(e,r,n){var i;let a=null,o=n;if(r===e){const d=Array.from(e.childNodes);let h=0;for(let u=0;u<Math.min(n,d.length);u+=1){const m=d[u];m&&(h+=Dt(m).length)}return h}if(r.nodeType===Node.TEXT_NODE)a=r;else{const d=Array.from(e.childNodes).find(h=>h.contains(r));if(!d)return el(e).length;if(a=d,d instanceof HTMLElement&&d.dataset.segmentType==="attachment"){const h=document.createRange();h.selectNodeContents(d);const u=Dt(d).length;try{h.setEnd(r,n);const m=h.toString().length,f=((i=d.textContent)==null?void 0:i.length)??0;f===0?o=u:o=Math.round(Math.min(1,m/f)*u)}catch{o=u}}else{const h=document.createRange();h.selectNodeContents(d);try{h.setEnd(r,n),o=h.toString().length}catch{o=Dt(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,Dt(d).length);l+=Dt(d).length}return l}function Xu(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:es(e,n.startContainer,n.startOffset),end:es(e,n.endContainer,n.endOffset)}}function ts(e,r){let n=Math.max(0,r);const a=Array.from(e.childNodes);for(const[o,s]of a.entries()){const i=Dt(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 Yu(e,r){const n=ts(e,r.start),a=ts(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 Zu(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}Jr();It();function Ju({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 Qu=wr("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 em({className:e,align:r="inline-start",...n}){return t.jsx("div",{role:"group","data-slot":"input-group-addon","data-align":r,className:Qe(Qu({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 tm=wr("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 wt({className:e,type:r="button",variant:n="ghost",size:a="xs",...o}){return t.jsx(kr,{type:r,"data-size":a,variant:n,className:Qe(tm({size:a}),e),...o})}function rm({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 nm({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 am({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-0 z-[90] inline-flex h-11 min-w-[7rem] -translate-x-1/2 -translate-y-full items-end justify-center bg-transparent pb-1 touch-manipulation sm:h-10",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 sm({activeView:e,layerClassName:r,formClassName:n,shellClassName:a,inputGroupClassName:o,error:s,followTail:l,photoInputRef:i,fileInputRef:d,onAppendAttachments:h,onToggleFollow:u,onSubmit:m,formRef:f,promptSlot:p,toolbarSlot:g,goalSlot:v,shellPromptSlot:b}){return t.jsxs("div",{className:r,children:[t.jsx(nm,{photoInputRef:i,fileInputRef:d,onAppendAttachments:h}),t.jsx(am,{activeView:e,followTail:l,onToggleFollow:u}),t.jsxs("form",{ref:f,"data-testid":e==="chat"?"chat-composer":void 0,onSubmit:m,className:n,children:[t.jsxs("div",{className:`${a} flex w-full flex-col overflow-visible rounded-[16px] sm:rounded-[18px]`,children:[t.jsxs(Ju,{className:o,children:[p,g]}),v,b]}),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 om({open:e,iconButtonClassName:r,menuClassName:n,menuItemClassName:a,onToggle:o,onPickPhoto:s,onPickFile:l}){return t.jsxs("div",{className:"relative",children:[t.jsx(wt,{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(Lu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${n} absolute bottom-full left-0 mb-2 w-32 overflow-hidden rounded-2xl border bg-stone-900/72 shadow-2xl shadow-stone-950/20`,children:t.jsxs("div",{className:"p-2",children:[t.jsx("button",{type:"button",onClick:s,className:`${a} block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"Photo"}),t.jsx("button",{type:"button",onClick:l,className:`${a} mt-1 block w-full rounded-xl px-3 py-2 text-left text-sm transition`,children:"File"})]})})]})}var tl=[{mode:"read-only",label:"Read only"},{mode:"workspace-write",label:"Workspace write"},{mode:"danger-full-access",label:"Danger"}];function rs(e){var r;return((r=tl.find(n=>n.mode===e))==null?void 0:r.label)??"Default"}function lm({openMenu:e,model:r,modelOptions:n,modelContextTitle:a,contextUsage:o,reasoningEffort:s,supportedEfforts:l,displayedCollaborationMode:i,sandboxMode:d,planModeAvailable:h,sandboxModeAvailable:u,settingsBusy:m,goalComposeMode:f,goalBusy:p,activeView:g,disabled:v,fastMode:b,sendButtonLabel:x,sendButtonClassName:j,modelControlsDisabled:y,effortControlsDisabled:w,effortControlTitle:k,inlineToggleClassName:N,menuItemClassName:C,planToggleActiveClassName:E,sendButtonBaseClassName:z,onSetOpenMenu:q,onUpdateSettings:D}){return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative min-w-0",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="model","aria-label":r??"Select model",disabled:y||n.length===0,onClick:()=>q($=>$==="model"?null:"model"),title:b?`Fast mode is on. Turn it off from the slash toolbox to edit model. ${a}`:a,className:`${N} 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(Fu,{contextUsage:o}):null,e==="model"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[14rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:n.map($=>t.jsx("button",{type:"button",onClick:()=>D({model:$.model,reasoningEffort:$.defaultReasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.model===r?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.model})},$.id))})})]}),t.jsxs("div",{className:"relative",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="effort",disabled:w,onClick:()=>q($=>$==="effort"?null:"effort"),title:k,className:`${N} rounded-full px-2 disabled:cursor-not-allowed disabled:text-stone-700 ${w?"text-stone-500":"text-stone-300 hover:text-stone-100"}`,children:Ya(s)}),e==="effort"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[8rem] max-w-[12rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:l.map($=>t.jsx("button",{type:"button",onClick:()=>D({reasoningEffort:$.reasoningEffort}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.reasoningEffort===s?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:Ya($.reasoningEffort)})},$.reasoningEffort))})})]}),u&&t.jsxs("div",{className:"relative",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"xs","data-composer-menu-trigger":"true","aria-haspopup":"menu","aria-expanded":e==="sandbox","aria-label":`Sandbox: ${rs(d)}`,disabled:m,onClick:()=>q($=>$==="sandbox"?null:"sandbox"),title:`Sandbox: ${rs(d)}`,className:`${N} rounded-full px-2.5 text-stone-300 disabled:cursor-not-allowed disabled:text-stone-700`,children:"Sandbox"}),e==="sandbox"&&t.jsx("div",{"data-composer-menu-surface":"true",className:"absolute bottom-full left-0 mb-2 w-max min-w-[9rem] max-w-[13rem] overflow-hidden rounded-2xl border border-stone-700 bg-stone-900 shadow-2xl shadow-stone-950/40",children:t.jsx("div",{className:"max-h-72 overflow-auto p-2",children:tl.map($=>t.jsx("button",{type:"button",onClick:()=>D({sandboxMode:$.mode}),className:`block w-full rounded-xl px-3 py-2 text-left transition ${$.mode===d?"ui-status-warning":`${C} text-stone-300`}`,children:t.jsx("p",{className:"text-sm font-medium",children:$.label})},$.mode))})})]}),h&&t.jsx(wt,{type:"button",variant:"ghost",size:"xs","aria-pressed":i==="plan",disabled:m,onClick:()=>D({collaborationMode:i==="plan"?"default":"plan"}),className:`${N} rounded-full px-2.5 ${i==="plan"?`${E} border !border-[oklch(0.78_0.16_86_/_0.76)] !bg-[oklch(0.44_0.095_82_/_0.72)] !text-[oklch(0.96_0.055_92)] shadow-[0_0_0_1px_oklch(0.78_0.16_86_/_0.24),0_0_18px_oklch(0.78_0.16_86_/_0.42),inset_0_0_0_1px_oklch(0.98_0.04_96_/_0.18)]`:"text-stone-500"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Plan"}),t.jsx(wt,{type:"submit",variant:"default",size:"icon-xs","aria-label":f?"Set goal":"Send Prompt",title:x,disabled:p||(g==="chat"?v:!1),className:`${z} h-9 w-9 rounded-full text-sm font-medium disabled:cursor-not-allowed sm:h-8 sm:w-8 ${j}`,children:t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-none stroke-current",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M8 13V3"}),t.jsx("path",{d:"m4 7 4-4 4 4"})]})})]})}function im({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(Dn,{}),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(Dn,{}),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(Mt,{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(Mt,{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(Mt,{label:"CTRL-D"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("esc"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"ESC"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("tab"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"TAB"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("up"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"UP"})}),t.jsx("button",{type:"button",disabled:!l,onClick:()=>s("down"),className:"disabled:cursor-not-allowed disabled:opacity-45",children:t.jsx(Mt,{label:"DOWN"})})]})})}function dm({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 cm({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 hm({hooksPanelMode:e,hooksState:r,hostConfigFilesAvailable:n,hookTrustAvailable:a,hookConfigBusy:o,hookConfigError:s,hookConfigSuccess:l,editingHookTarget:i,hookScope:d,hookEventName:h,hookMatcher:u,hookCommand:m,hookTimeoutSec:f,hookStatusMessage:p,composerChipButtonClassName:g,onResetHookForm:v,onSetHooksPanelMode:b,onClearHookConfigStatus:x,onSetEditingHookTarget:j,onSetHookScope:y,onSetHookEventName:w,onSetHookMatcher:k,onSetHookCommand:N,onSetHookTimeoutSec:C,onSetHookStatusMessage:E,onSaveHook:z,onStartEditingHook:q,onTrustHook:D,onUntrustHook:$}){var Q,Z,B,ee,oe;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"Hook config sources"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:((Q=r.data)==null?void 0:Q.projectHooksPath)??"<workspace hooks config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:A=>{A.stopPropagation(),v(),b("add"),x()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add Hook"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading hooks..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:s}):null,l?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:l}):null,e==="add"||e==="edit"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[e==="edit"?t.jsxs("p",{className:"rounded-lg border border-stone-800 bg-stone-950 px-3 py-2 text-[11px] text-stone-400",children:["Editing"," ",Du((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:A=>y(A.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:A=>w(A.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:Ur.map(A=>t.jsx("option",{value:A.value,children:A.label},A.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:A=>k(A.target.value),placeholder:"Bash",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"Command"}),t.jsx("textarea",{"aria-label":"Hook command",value:m,onChange:A=>N(A.target.value),rows:3,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 font-mono text-xs text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[t.jsxs("label",{className:"block text-xs text-stone-400",children:["Timeout",t.jsx("input",{"aria-label":"Hook timeout seconds",value:f,onChange:A=>C(A.target.value),inputMode:"numeric",className:"mt-1 w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none focus:border-sky-300/50"})]}),t.jsxs("label",{className:"block text-xs text-stone-400",children:["Status message",t.jsx("input",{"aria-label":"Hook status message",value:p,onChange:A=>E(A.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:()=>{b("list"),j(null)},className:`${g} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void z(),disabled:o,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:o?"Saving...":e==="edit"?"Update Hook":"Write Hook"})]})]}):null,e==="list"&&((Z=r.data)!=null&&Z.warnings.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.warnings.map(A=>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:A},A))}):null,e==="list"&&((B=r.data)!=null&&B.errors.length)?t.jsx("div",{className:"mb-2 space-y-2",children:r.data.errors.map(A=>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:A.message}),t.jsx("p",{className:"mt-1 break-all text-rose-100/60",children:A.path})]},`${A.path}:${A.message}`))}):null,e==="list"&&((ee=r.data)!=null&&ee.hooks.length)?t.jsx("div",{className:"space-y-2",children:r.data.hooks.map(A=>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:[_u(A.eventName),A.matcher?` · ${A.matcher}`:""]}),t.jsx("p",{className:"mt-0.5 truncate font-mono text-[11px] text-stone-400",children:A.command??A.handlerType}),A.statusMessage?t.jsx("p",{className:"mt-1 truncate text-[11px] text-stone-500",children:A.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:[Qo(A)?t.jsx("button",{type:"button",onClick:J=>{J.stopPropagation(),q(A)},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&&A.trustStatus==="trusted"&&!A.isManaged?t.jsx("button",{type:"button",disabled:o,onClick:J=>{J.stopPropagation(),$(A)},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,(A.trustStatus==="untrusted"||A.trustStatus==="modified")&&!A.isManaged&&a?t.jsx("button",{type:"button",disabled:o||!A.currentHash,onClick:J=>{J.stopPropagation(),D(A)},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:$u(A.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:Mu(A.source)}),t.jsx("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:A.enabled?"Enabled":"Disabled"}),t.jsxs("span",{className:"rounded-full border border-stone-700 px-2 py-1",children:[A.timeoutSec,"s"]})]})]},A.key))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((oe=r.data)==null?void 0:oe.hooks.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No hooks configured for this workspace."}):null]})}function um({mcpPanelMode:e,mcpState:r,mcpConfigEditing:n,mcpConfigPath:a,mcpConfigError:o,mcpConfigSuccess:s,mcpConfigBusy:l,mcpHttpName:i,mcpHttpUrl:d,mcpRawBlock:h,composerPanelButtonClassName:u,composerChipButtonClassName:m,onSetMcpPanelMode:f,onClearMcpConfigStatus:p,onSetMcpHttpName:g,onSetMcpHttpUrl:v,onSetMcpRawBlock:b,onPrepareRawMcpBlock:x,onSaveHttpMcp:j,onSaveRawMcpBlock:y}){var w,k;return t.jsxs("div",{className:"p-2",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"text-xs text-stone-400",children:"MCP config source"}),t.jsx("p",{className:"truncate text-[11px] text-stone-500",children:a??"<provider config>"})]}),e==="list"&&n?t.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f("add"),p()},className:"shrink-0 rounded-full border border-sky-300/35 px-3 py-1.5 text-xs text-sky-100 transition hover:bg-sky-300/10",children:"Add MCP"}):null]}),r.status==="loading"&&!r.data?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"Loading MCP servers..."}):null,r.error?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:r.error}):null,o?t.jsx("p",{className:"mb-2 rounded-xl border border-rose-500/35 bg-rose-500/10 px-3 py-3 text-sm text-rose-100/90",children:o}):null,s?t.jsx("p",{className:"mb-2 rounded-xl border border-emerald-500/35 bg-emerald-500/10 px-3 py-3 text-sm text-emerald-100/90",children:s}):null,e==="add"?t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),f("http"),p()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"HTTP / Streamable HTTP"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"Form"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Add an MCP server with a name and URL, then write the matching block into provider config."})]}),t.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),x()},className:`${u} block w-full rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-left transition`,children:[t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{className:"text-sm text-stone-100",children:"stdio / raw block"}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-500",children:"TOML"})]}),t.jsx("p",{className:"mt-1 text-xs text-stone-400",children:"Write a single `[mcp_servers.name]` block, then save it back into provider config."})]})]}):null,e==="http"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"mb-1 block text-xs text-stone-400",children:"MCP name"}),t.jsx("input",{"aria-label":"MCP name",value:i,onChange:N=>g(N.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:N=>v(N.target.value),placeholder:"https://developers.openai.com/mcp",className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"})]}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void j(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write HTTP MCP"})]})]}):null,e==="stdio"?t.jsxs("div",{className:"space-y-2 rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3",children:[t.jsx("label",{className:"block text-xs text-stone-400",children:"MCP block for provider config"}),t.jsx("textarea",{"aria-label":"MCP block for provider config",value:h,onChange:N=>b(N.target.value),rows:8,className:"w-full rounded-lg border border-stone-700 bg-stone-950 px-3 py-2 text-sm text-stone-100 outline-none placeholder:text-stone-500 focus:border-sky-300/50"}),t.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[t.jsx("button",{type:"button",onClick:()=>f("add"),className:`${m} rounded-full border border-stone-700 px-3 py-1.5 text-xs text-stone-300 transition`,children:"Back"}),t.jsx("button",{type:"button",onClick:()=>void y(),disabled:l,className:"ui-status-info rounded-full px-3 py-1.5 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",children:l?"Saving...":"Write raw block"})]})]}):null,e==="list"&&((w=r.data)!=null&&w.servers.length)?t.jsx("div",{className:"space-y-2",children:r.data.servers.map(N=>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:N.name}),t.jsxs("p",{className:"mt-0.5 text-xs text-stone-400",children:[N.tools.length," tools · ",N.resourceCount," ","resources · ",N.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:Ru(N.authStatus)})]}),N.tools.length>0?t.jsx("p",{className:"mt-2 line-clamp-2 text-xs text-stone-500",children:N.tools.slice(0,4).map(C=>C.title??C.name).join(" · ")}):null]},N.name))}):null,e==="list"&&r.status!=="loading"&&!r.error&&(((k=r.data)==null?void 0:k.servers.length)??0)===0?t.jsx("p",{className:"rounded-xl border border-stone-800 bg-stone-950/70 px-3 py-3 text-sm text-stone-400",children:"No MCP servers available right now."}):null]})}function mm({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:Au(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(Dn,{}),"$",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 pm({open:e,slashPanelView:r,availableToolboxItems:n,busy:a,forkBusy:o,forkTurnOptionsState:s,skillsState:l,copiedSkillName:i,hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:v,hookScope:b,hookEventName:x,hookMatcher:j,hookCommand:y,hookTimeoutSec:w,hookStatusMessage:k,mcpPanelMode:N,mcpState:C,mcpConfigEditing:E,mcpConfigPath:z,mcpConfigError:q,mcpConfigSuccess:D,mcpConfigBusy:$,mcpHttpName:Q,mcpHttpUrl:Z,mcpRawBlock:B,iconButtonClassName:ee,menuClassName:oe,menuItemClassName:A,panelButtonClassName:J,chipButtonClassName:R,onToggle:Y,onToolboxItemClick:H,toolboxItemDisabled:T,toolboxItemClassName:O,toolboxItemStatus:G,onSetSlashPanelView:L,onOpenForkTurns:S,onForkLatest:V,onForkTurn:K,onCopySkillInvokeName:le,onResetHookForm:X,onSetHooksPanelMode:ce,onClearHookConfigStatus:re,onSetEditingHookTarget:fe,onSetHookScope:he,onSetHookEventName:ve,onSetHookMatcher:Re,onSetHookCommand:ie,onSetHookTimeoutSec:ye,onSetHookStatusMessage:Te,onSaveHook:W,onStartEditingHook:ae,onTrustHook:xe,onUntrustHook:ke,onSetMcpPanelMode:$e,onClearMcpConfigStatus:Me,onSetMcpHttpName:je,onSetMcpHttpUrl:De,onSetMcpRawBlock:F,onPrepareRawMcpBlock:de,onSaveHttpMcp:we,onSaveRawMcpBlock:P}){return t.jsxs("div",{className:"relative",children:[t.jsx(wt,{type:"button",variant:"ghost",size:"icon-xs","data-composer-menu-trigger":"true","aria-label":"Open slash toolbox",title:"Open slash toolbox",onClick:Y,className:`${ee} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:t.jsx(Pu,{})}),e&&t.jsx("div",{"data-composer-menu-surface":"true",className:`${oe} 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:_=>{_.stopPropagation()},onMouseDown:_=>{_.stopPropagation()},onPointerDown:_=>{_.stopPropagation()},onTouchStart:_=>{_.stopPropagation()},children:r==="root"?t.jsxs("div",{className:"p-2",children:[n.map((_,se)=>t.jsx("button",{type:"button",disabled:T(_),onClick:ge=>H(_,ge),className:`${O(_)} ${se===0?"mt-0":""}`,title:_.description??_.label,children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsx("span",{children:_.command}),t.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-stone-400",children:G(_)})]})},`${_.action}:${_.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(dm,{busy:a,forkBusy:o,composerMenuItemClassName:A,onForkLatest:V,onSelectForkTurnPanel:()=>(L("forkTurns"),S())}):r==="forkTurns"?t.jsx(cm,{forkTurnOptionsState:s,forkBusy:o,composerPanelButtonClassName:J,onForkTurn:K}):r==="skills"?t.jsx(mm,{skillsState:l,copiedSkillName:i,composerChipButtonClassName:R,onCopySkillInvokeName:le}):r==="hooks"?t.jsx(hm,{hooksPanelMode:d,hooksState:h,hostConfigFilesAvailable:u,hookTrustAvailable:m,hookConfigBusy:f,hookConfigError:p,hookConfigSuccess:g,editingHookTarget:v,hookScope:b,hookEventName:x,hookMatcher:j,hookCommand:y,hookTimeoutSec:w,hookStatusMessage:k,composerChipButtonClassName:R,onResetHookForm:X,onSetHooksPanelMode:ce,onClearHookConfigStatus:re,onSetEditingHookTarget:fe,onSetHookScope:he,onSetHookEventName:ve,onSetHookMatcher:Re,onSetHookCommand:ie,onSetHookTimeoutSec:ye,onSetHookStatusMessage:Te,onSaveHook:W,onStartEditingHook:ae,onTrustHook:xe,onUntrustHook:ke}):t.jsx(um,{mcpPanelMode:N,mcpState:C,mcpConfigEditing:E,mcpConfigPath:z,mcpConfigError:q,mcpConfigSuccess:D,mcpConfigBusy:$,mcpHttpName:Q,mcpHttpUrl:Z,mcpRawBlock:B,composerPanelButtonClassName:J,composerChipButtonClassName:R,onSetMcpPanelMode:$e,onClearMcpConfigStatus:Me,onSetMcpHttpName:je,onSetMcpHttpUrl:De,onSetMcpRawBlock:F,onPrepareRawMcpBlock:de,onSaveHttpMcp:we,onSaveRawMcpBlock:P})})})]})}function fm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:i,attachmentMenuProps:d,settingsToolbarProps:h,shellToolsPanelProps:u,onToggleView:m,onDismissPromptFocus:f,onSetOpenMenu:p}){return t.jsxs(em,{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(pm,{...i}):null,!e&&d?t.jsx(om,{...d}):null,r&&t.jsx(wt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":e?"Switch to chat":"Switch to shell",title:e?"Switch to chat":"Switch to shell",onClick:()=>m==null?void 0:m(),className:`${l} h-9 w-9 rounded-full sm:h-8 sm:w-8`,children:e?t.jsx(Iu,{}):t.jsx(Eu,{})})]}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-end gap-1.5",children:[!e&&h?t.jsx(lm,{...h}):null,e&&a?t.jsx(rm,{className:"min-w-0 max-w-[12rem] truncate rounded-full px-1.5 py-1 text-stone-400",title:a,children:a}):null,n&&t.jsxs("div",{className:"relative",children:[t.jsx("button",{type:"button","data-composer-menu-trigger":"true","aria-label":o==="shellTools"?"Close shell tools":"Open shell tools","aria-haspopup":"menu","aria-expanded":o==="shellTools",title:o==="shellTools"?"Close shell tools":"Open shell tools",onClick:()=>{f(),p(g=>g==="shellTools"?null:"shellTools")},className:"inline-flex h-7 w-7 items-center justify-center rounded-full border border-stone-700 bg-stone-900/92 text-stone-200 transition hover:bg-stone-800",children:t.jsx(zu,{})}),o==="shellTools"&&u?t.jsx(im,{...u}):null]})]})]})}function gm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`attachment-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function xm(e){return[...e.filter(r=>Mn(r)==="photo"),...e.filter(r=>Mn(r)==="file")]}function bm({prompt:e,attachments:r,updateDraft:n,getSelection:a,selectionSnapshotRef:o,pendingSelectionRef:s,pendingInsertedAttachmentIdsRef:l,onInserted:i,buildClientId:d=gm}){const h=c.useCallback((f,p)=>{if(f.length===0)return!1;const g=hu({prompt:e,attachments:r,files:f,selection:a()??o.current,kindForFile:p,buildClientId:d});return n(()=>g.draft),s.current=g.selection,o.current=g.selection,l.current=g.insertedAttachmentIds,i==null||i(),!0},[r,d,a,i,l,s,e,o,n]),u=c.useCallback((f,p)=>!f||f.length===0?!1:h(Array.from(f),()=>p),[h]),m=c.useCallback(f=>h(xm(f),Mn),[h]);return{appendAttachments:u,appendDroppedAttachments:m}}function ns(e){for(const r of e.values())URL.revokeObjectURL(r);e.clear()}function vm({attachments:e,isShellView:r}){const n=c.useRef(new Map),[a,o]=c.useState({});return c.useEffect(()=>{const s=n.current;if(r){ns(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()=>{ns(s)}},[]),a}var km=180;function bn(e,r){return{prompt:e??"",attachments:r??[]}}function wm({isShellView:e,draftPrompt:r,draftAttachments:n,onDraftChange:a}){const[o,s]=c.useState({prompt:"",attachments:[]}),[l,i]=c.useState(()=>bn(r,n)),d=c.useRef(null),h=c.useRef(l),u=c.useRef(Pr(l)),m=!e&&r!==void 0&&n!==void 0&&typeof a=="function",f=m?Pr(bn(r,n)):"",p=c.useRef(f);c.useLayoutEffect(()=>{if(!m){p.current="";return}const y=bn(r,n),w=Pr(y);w!==p.current&&(p.current=w,u.current=w,h.current=y,d.current!==null&&(window.clearTimeout(d.current),d.current=null),i(y))},[n,r,m]);const g=c.useCallback(y=>{if(!m||!a)return;const w=Pr(y);w!==u.current&&(u.current=w,a(()=>({prompt:y.prompt,attachments:y.attachments})))},[m,a]);c.useEffect(()=>()=>{g(h.current),d.current!==null&&window.clearTimeout(d.current)},[g]);const v=c.useCallback((y,w)=>{if(m){if(d.current!==null&&(window.clearTimeout(d.current),d.current=null),w==="immediate"){g(y);return}d.current=window.setTimeout(()=>{d.current=null,g(h.current)},km)}},[m,g]),b=c.useCallback((y=h.current)=>{v(y,"immediate")},[v]),x=c.useCallback((y,w="immediate")=>{if(m){const k=y(h.current);h.current=k,i(k),v(k,w);return}s(k=>y(k))},[m,v]),j=m?l:o;return{prompt:j.prompt,attachments:j.attachments,isDraftControlled:m,updateDraft:x,flushControlledDraftToHost:b}}function ym({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 jm({prompt:e,goalTokenBudgetSource:r,promptRef:n,onOpenGoal:a,onPrepareGoalSubmit:o,onUpdateGoal:s,updateDraft:l,closeMenu:i,resetSlashPanel:d}){const[h,u]=c.useState(!1),[m,f]=c.useState(""),[p,g]=c.useState(!1),[v,b]=c.useState(null),x=c.useCallback(async()=>{const w=e.trim();if(!w)return b("Goal objective cannot be empty."),!1;const k=m.trim(),N=xu(k);if(k.length>0&&(N===null||!Number.isInteger(N)||N<=0))return b("Token budget must be a positive number in thousands."),!1;if(!s)return b("/goal is unavailable in this view."),!1;g(!0),b(null);try{return o&&await o({objective:w,tokenBudget:N})===!1?!1:(await s({objective:w,status:"active",tokenBudget:N}),f(""),u(!1),l(()=>({prompt:"",attachments:[]})),!0)}catch(C){return b(C instanceof Error?C.message:"Unable to set goal."),!1}finally{g(!1)}},[m,o,s,e,l]),j=c.useCallback(()=>{i(),d(),u(!0),f(bu(r==null?void 0:r.tokenBudget)),b(null),a==null||a(),requestAnimationFrame(()=>{var w;(w=n.current)==null||w.focus()})},[i,r==null?void 0:r.tokenBudget,a,n,d]),y=c.useCallback(()=>{u(!1),b(null)},[]);return{goalComposeMode:h,goalTokenBudget:m,goalBusy:p,goalLocalError:v,setGoalTokenBudget:f,submitGoal:x,enterGoalComposeMode:j,exitGoalComposeMode:y}}var vn=`node -e "process.stdin.resume(); process.stdin.on('end', () => console.error('hook ran'))"`;function Nm(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,m]=c.useState("preToolUse"),[f,p]=c.useState("Bash"),[g,v]=c.useState(vn),[b,x]=c.useState("30"),[j,y]=c.useState("Running hook"),[w,k]=c.useState(null),[N,C]=c.useState(!1),[E,z]=c.useState(null),[q,D]=c.useState(null),$=c.useMemo(()=>Nm(r),[r]),Q=c.useCallback(Y=>$.get(Y)??$.get("preToolUse")??vn,[$]),Z=c.useMemo(()=>new Set([vn,...$.values()]),[$]),B=c.useCallback(()=>{z(null),D(null)},[]);c.useEffect(()=>{e!=="hooks"&&(i("list"),B())},[B,e]),c.useEffect(()=>{const Y=Ur.find(H=>H.value===u);p(H=>{const T=H.trim(),O=new Set(Ur.map(G=>G.matcherHint).filter(Boolean));return T&&!O.has(T)?H:(Y==null?void 0:Y.matcherHint)??""}),v(H=>Z.has(H.trim())?Q(u):H)},[Q,Z,u]);const ee=c.useCallback(()=>{k(null),h("project"),m("preToolUse"),p("Bash"),v(Q("preToolUse")),x("30"),y("Running hook")},[Q]),oe=c.useCallback(Y=>{const H=Qo(Y);if(!H){z("Only command hooks in global or project hooks.json can be edited here.");return}k(H),h(H.scope),m(H.eventName),p(H.matcher??""),v(H.command),x(H.timeoutSec?String(H.timeoutSec):""),y(H.statusMessage??""),z(null),D(null),i("edit")},[]),A=c.useCallback(async()=>{if(l==="edit"&&!a){z("Hook editing is unavailable in this view.");return}if(l!=="edit"&&!n){z("Hook editing is unavailable in this view.");return}if(l==="edit"&&!w){z("Select a hook to edit first.");return}const Y=g.trim();if(!Y){z("Hook command cannot be empty.");return}const H=b.trim(),T=H?Number(H):null;if(H&&(T===null||!Number.isInteger(T)||T<=0)){z("Timeout must be a positive number of seconds.");return}C(!0),z(null),D(null);try{const O={scope:d,eventName:u,matcher:f.trim()||null,command:Y,timeoutSec:T,statusMessage:j.trim()||null};l==="edit"?await(a==null?void 0:a({...O,target:w})):await(n==null?void 0:n(O)),D(`${d==="project"?"Project":"Global"} hook ${l==="edit"?"updated":"written"} in hooks.json and trusted.`),i("list"),k(null)}catch(O){z(O instanceof Error?O.message:"Unable to write hooks.json.")}finally{C(!1)}},[w,g,u,f,d,j,b,l,n,a]),J=c.useCallback(async Y=>{if(!o||!Y.currentHash){z("Hook trust is unavailable in this view.");return}C(!0),z(null),D(null);try{await o({key:Y.key,currentHash:Y.currentHash}),D("Hook trusted.")}catch(H){z(H instanceof Error?H.message:"Unable to trust hook.")}finally{C(!1)}},[o]),R=c.useCallback(async Y=>{if(!s){z("Hook trust is unavailable in this view.");return}C(!0),z(null),D(null);try{await s({key:Y.key}),D("Hook untrusted.")}catch(H){z(H instanceof Error?H.message:"Unable to untrust hook.")}finally{C(!1)}},[s]);return{hooksPanelMode:l,hookScope:d,hookEventName:u,hookMatcher:f,hookCommand:g,hookTimeoutSec:b,hookStatusMessage:j,editingHookTarget:w,hookConfigBusy:N,hookConfigError:E,hookConfigSuccess:q,setHooksPanelMode:i,setEditingHookTarget:k,setHookScope:h,setHookEventName:m,setHookMatcher:p,setHookCommand:v,setHookTimeoutSec:x,setHookStatusMessage:y,clearHookConfigStatus:B,resetHookForm:ee,startEditingHook:oe,saveHook:A,trustHook:J,untrustHook:R}}var Sm=`[mcp_servers.example_stdio]
|
|
3654
3654
|
command = "npx"
|
|
3655
3655
|
args = ["-y", "your-mcp-server"]
|
|
3656
|
-
`,as="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Sm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[v,b]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{b(null),j(null)},[]),w=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const I=await r();return f(I.path),I},[e,r]),k=c.useCallback(async I=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const q=await n(I);return f(q.path),q},[e,n]),N=c.useCallback(async()=>{const I=bu(s),q=i.trim();if(!I){b("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(q)){b("HTTP MCP URL must start with http:// or https://");return}g(!0),b(null),j(null);try{const D=await w(),$=Za(D.content,I,ku(I,q));await k($),j(as),a("list"),l(""),d(""),o==null||o()}catch(D){b(D instanceof Error?D.message:"Unable to update provider config.")}finally{g(!1)}},[w,s,i,o,a,k]),C=c.useCallback(async()=>{g(!0),b(null),j(null);try{await w(),u(I=>I||Cm),a("stdio")}catch(I){b(I instanceof Error?I.message:"Unable to load provider config.")}finally{g(!1)}},[w,a]),E=c.useCallback(async()=>{const I=vu(h);if(!I){b("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),b(null),j(null);try{const q=await w(),D=Za(q.content,I,h);await k(D),j(as),a("list"),o==null||o()}catch(q){b(q instanceof Error?q.message:"Unable to update provider config.")}finally{g(!1)}},[w,h,o,a,k]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:v,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:C,saveHttpMcp:N,saveRawMcpBlock:E}}function Tm({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Em(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=Qa(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=Qa(n),a.append(o,s),a}function Lm(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(Em(a,r))}return n}function Pm({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const v=i.current,b=f()!==n||u.current!==s||m.current!==l;b&&(g.replaceChildren(Lm(a,o)),u.current=s,m.current=l),v!==null?(g.focus(),Yu(g,d.current)||p(v),h.current=v):document.activeElement===g&&b&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function zm({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 Im({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:v,onDragOver:b,onDragLeave:x,onDrop:j}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:v,onDragOver:b,onDragLeave:x,onDrop:j,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(wt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:y=>{y.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 Rm({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function Am({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:v,sendButtonClassName:b,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:w,onPromptKeyUp:k,onPromptMouseUp:N,onPromptBlur:C,onPromptDragEnter:E,onPromptDragOver:I,onPromptDragLeave:q,onPromptDrop:D,onGoalTokenBudgetChange:$,onCancelGoal:Q,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Im,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:w,onKeyUp:k,onMouseUp:N,onBlur:C,onDragEnter:E,onDragOver:I,onDragLeave:q,onDrop:D}),goalSlot:u&&!e?t.jsx(zm,{tokenBudget:m,error:f,onTokenBudgetChange:$,onCancel:Q}):null,shellPromptSlot:e?t.jsx(Rm,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:v,sendButtonClassName:b,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:w,onInterrupt:x}):null}}function _m({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=fu({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 Mm({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:v,busy:b,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:w,goalComposeMode:k,goalBusy:N,goalStatus:C,activeView:E,disabled:I,model:q,modelOptions:D,modelContextTitle:$,contextUsage:Q,reasoningEffort:Z,supportedEfforts:B,displayedCollaborationMode:ee,sandboxMode:oe,sendButtonLabel:A,sendButtonClassName:J,modelControlsDisabled:R,effortControlsDisabled:Y,effortControlTitle:H,forkTurnOptionsState:T,skillsState:O,copiedSkillName:G,hooksPanelMode:L,hooksState:S,hookConfigBusy:V,hookConfigError:K,hookConfigSuccess:le,editingHookTarget:X,hookScope:ce,hookEventName:re,hookMatcher:fe,hookCommand:he,hookTimeoutSec:ve,hookStatusMessage:Re,mcpPanelMode:ie,mcpState:ye,mcpConfigPath:Te,mcpConfigError:U,mcpConfigSuccess:ae,mcpConfigBusy:xe,mcpHttpName:ke,mcpHttpUrl:$e,mcpRawBlock:Me,capabilities:je,shellControlState:De,onToggleView:F,onDismissPromptFocus:de,onSetOpenMenu:we,onToolboxItemClick:P,onSetSlashPanelView:_,onOpenForkTurns:se,onForkLatest:ge,onForkTurn:Ne,onCopySkillInvokeName:Ae,onResetHookForm:Se,onSetHooksPanelMode:Be,onClearHookConfigStatus:We,onSetEditingHookTarget:at,onSetHookScope:et,onSetHookEventName:tt,onSetHookMatcher:rt,onSetHookCommand:it,onSetHookTimeoutSec:_e,onSetHookStatusMessage:Fe,onSaveHook:dt,onStartEditingHook:z,onTrustHook:W,onUntrustHook:pe,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:te,onSetMcpHttpName:He,onSetMcpHttpUrl:Ue,onSetMcpRawBlock:Oe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:ct,onSaveRawMcpBlock:bt,onPickPhoto:st,onPickFile:yt,onUpdateSettings:jt,onPasteShell:Nt,onCopyShell:be,onClearShell:ze,onShellControl:ot}){const Je=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:v,busy:b,forkBusy:y,forkTurnOptionsState:T,skillsState:O,copiedSkillName:G,hooksPanelMode:L,hooksState:S,hostConfigFilesAvailable:je.hostConfigFiles,hookTrustAvailable:je.hookTrust,hookConfigBusy:V,hookConfigError:K,hookConfigSuccess:le,editingHookTarget:X,hookScope:ce,hookEventName:re,hookMatcher:fe,hookCommand:he,hookTimeoutSec:ve,hookStatusMessage:Re,mcpPanelMode:ie,mcpState:ye,mcpConfigEditing:je.mcpConfigEditing,mcpConfigPath:Te,mcpConfigError:U,mcpConfigSuccess:ae,mcpConfigBusy:xe,mcpHttpName:ke,mcpHttpUrl:$e,mcpRawBlock:Me,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>we(ut=>ut==="slash"?null:"slash"),onToolboxItemClick:P,toolboxItemDisabled:ut=>Uu(ut,{settingsBusy:x,compactBusy:j,busy:b,forkBusy:y}),toolboxItemClassName:ut=>Wu(ut,{fastMode:w,goalComposeMode:k,goalStatus:C,menuItemClassName:d}),toolboxItemStatus:ut=>Ou(ut,{fastMode:w,compactBusy:j,goalComposeMode:k,goalStatus:C,busy:b}),onSetSlashPanelView:_,onOpenForkTurns:se,onForkLatest:ge,onForkTurn:Ne,onCopySkillInvokeName:Ae,onResetHookForm:Se,onSetHooksPanelMode:Be,onClearHookConfigStatus:We,onSetEditingHookTarget:at,onSetHookScope:et,onSetHookEventName:tt,onSetHookMatcher:rt,onSetHookCommand:it,onSetHookTimeoutSec:_e,onSetHookStatusMessage:Fe,onSaveHook:dt,onStartEditingHook:z,onTrustHook:W,onUntrustHook:pe,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:te,onSetMcpHttpName:He,onSetMcpHttpUrl:Ue,onSetMcpRawBlock:Oe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:ct,onSaveRawMcpBlock:bt},ht=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>we(ut=>ut==="attachments"?null:"attachments"),onPickPhoto:st,onPickFile:yt},ar=e?null:{openMenu:o,model:q,modelOptions:D,modelContextTitle:$,contextUsage:Q,reasoningEffort:Z,supportedEfforts:B,displayedCollaborationMode:ee,sandboxMode:oe,planModeAvailable:je.planMode,sandboxModeAvailable:je.sandboxMode,settingsBusy:x,goalComposeMode:k,goalBusy:N,activeView:E,disabled:I,fastMode:w,sendButtonLabel:A,sendButtonClassName:J,modelControlsDisabled:R,effortControlsDisabled:Y,effortControlTitle:H,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:we,onUpdateSettings:jt};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Je,attachmentMenuProps:ht,settingsToolbarProps:ar,shellToolsPanelProps:o==="shellTools"?{busy:b,shellControlState:De,onPaste:Nt,onCopy:be,onClear:ze,onShellControl:ot}:null,shellControlState:De,onToggleView:F,onDismissPromptFocus:de,onSetOpenMenu:we}}function Bn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:v=null,hookCommandTemplates:b=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:w=!0,disabled:k=!1,disabledPlaceholder:N,shellControlState:C=null,draftPrompt:E,draftAttachments:I,onPickAttachment:q,skillsState:D={status:"idle",data:null,error:null},mcpState:$={status:"idle",data:null,error:null},hooksState:Q={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},forkTurnOptionsState:B={status:"idle",data:null,error:null},onDraftChange:ee,onSubmit:oe,onInterrupt:A,onCompact:J,onOpenSkills:R,onOpenMcp:Y,onOpenHooks:H,onCreateHook:T,onUpdateHook:O,onTrustHook:G,onUntrustHook:L,onOpenGoal:S,onPrepareGoalSubmit:V,onUpdateGoal:K,onOpenForkTurns:le,onForkLatest:X,onForkTurn:ce,onReadProviderConfig:re,onWriteProviderConfig:fe,onToggleFollow:he,onUpdateSettings:ve,onToggleView:Re,onShellCopy:ie,onShellControl:ye,canInterrupt:Te=!1}){var ba;const[U,ae]=c.useState(null),[xe,ke]=c.useState("root"),[$e,Me]=c.useState("list"),je=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!re&&!!fe,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,re,fe]),De=c.useMemo(()=>Fu(v,je),[je,v]),F=c.useRef(null),de=c.useRef(null),we=c.useRef(null),P=c.useRef(null),_=c.useRef(null),se=c.useRef([]),ge=c.useRef(null),Ne=c.useRef(""),Ae=c.useRef(0),Se=e==="shell",Be=w||Se,We=!!(Se&&(C!=null&&C.isMobileShell)),at=(C==null?void 0:C.promptLabel)??null,[et,tt]=c.useState(!1),[rt,it]=c.useState(0),{prompt:_e,attachments:Fe,isDraftControlled:dt,updateDraft:z,flushControlledDraftToHost:W}=km({isShellView:Se,draftPrompt:E,draftAttachments:I,onDraftChange:ee}),pe=bm({attachments:Fe,isShellView:Se}),{displayedCollaborationMode:Pe,updateSettings:te}=_m({collaborationMode:h,onUpdateSettings:ve,closeMenu:()=>ae(null)}),{forkBusy:He,forkLatest:Ue,forkTurn:Oe}=wm({slashPanelView:xe,onForkLatest:X,onForkTurn:ce,closeMenu:()=>ae(null)}),{hooksPanelMode:qe,hookScope:ct,hookEventName:bt,hookMatcher:st,hookCommand:yt,hookTimeoutSec:jt,hookStatusMessage:Nt,editingHookTarget:be,hookConfigBusy:ze,hookConfigError:ot,hookConfigSuccess:Je,setHooksPanelMode:ht,setEditingHookTarget:ar,setHookScope:sr,setHookEventName:ut,setHookMatcher:jl,setHookCommand:Nl,setHookTimeoutSec:Cl,setHookStatusMessage:Sl,clearHookConfigStatus:da,resetHookForm:Tl,startEditingHook:El,saveHook:Ll,trustHook:Pl,untrustHook:zl}=Nm({slashPanelView:xe,hookCommandTemplates:b,onCreateHook:T,onUpdateHook:O,onTrustHook:G,onUntrustHook:L}),{goalComposeMode:or,goalTokenBudget:Il,goalBusy:rn,goalLocalError:Rl,setGoalTokenBudget:Al,submitGoal:_l,enterGoalComposeMode:Ml,exitGoalComposeMode:ca}=ym({prompt:_e,goalTokenBudgetSource:Z.data,promptRef:de,onOpenGoal:S,onPrepareGoalSubmit:V,onUpdateGoal:K,updateDraft:z,closeMenu:()=>ae(null),resetSlashPanel:()=>ke("root")}),{mcpHttpName:$l,mcpHttpUrl:Dl,mcpRawBlock:Bl,mcpConfigPath:Gl,mcpConfigBusy:Fl,mcpConfigError:Hl,mcpConfigSuccess:Ol,setMcpHttpName:Ul,setMcpHttpUrl:Wl,setMcpRawBlock:Vl,clearMcpConfigStatus:ha,prepareRawMcpBlock:Kl,saveHttpMcp:ql,saveRawMcpBlock:Xl}=Sm({hostConfigFilesAvailable:je.hostConfigFiles,onReadProviderConfig:re,onWriteProviderConfig:fe,setMcpPanelMode:Me,onOpenMcp:Y}),{copiedSkillName:Yl,copySkillInvokeName:Zl}=Tm({openMenu:U,setOpenMenu:ae,slashPanelView:xe,setSlashPanelView:ke,setMcpPanelMode:Me,clearMcpConfigStatus:ha,clearHookConfigStatus:da}),Jl=c.useCallback(ne=>{z(Ce=>{if(typeof ne=="function"){const Ie=ne(Ce.prompt,Ce.attachments);return{prompt:Ie.prompt,attachments:Ie.attachments??Ce.attachments}}return{prompt:ne,attachments:Ce.attachments}})},[z]),nn=c.useMemo(()=>f.find(ne=>ne.model===l)??null,[l,f]),Ql=wu(l,p),ua=(nn==null?void 0:nn.supportedReasoningEfforts)??[],ei=c.useMemo(()=>ou(_e,Fe),[Fe,_e]),ti=c.useMemo(()=>Object.entries(pe).sort(([ne],[Ce])=>ne.localeCompare(Ce)).map(([ne,Ce])=>`${ne}:${Ce}`).join("|"),[pe]);function ri(ne,Ce){Ce.stopPropagation();const Ie=Hu(ne,{fastMode:d,goalComposeMode:or});switch(Ie.type){case"toggleFast":te({fastMode:Ie.fastMode});break;case"runCompact":ae(null),J==null||J();break;case"enterGoalCompose":Ml();break;case"exitGoalCompose":ca(),ae(null);break;case"openPanel":ke(Ie.panel),Ie.panel==="skills"?R==null||R():Ie.panel==="mcp"?Y==null||Y():Ie.panel==="hooks"&&(H==null||H());break;case"insertPrompt":on(Ie.text),ke("root"),ae(null);break}}function Wt(){const ne=de.current;return ne?qu(ne):null}const ni=c.useCallback(ne=>{const Ce=de.current;!Ce||!ne||Xu(Ce,ne)},[]),an=c.useCallback(()=>{const ne=de.current;return ne?Qo(ne):_e},[_e]),{appendAttachments:sn,appendDroppedAttachments:ma}=xm({prompt:_e,attachments:Fe,updateDraft:z,getSelection:Wt,selectionSnapshotRef:ge,pendingSelectionRef:_,pendingInsertedAttachmentIdsRef:se,onInserted:()=>ae(null)}),pa=c.useCallback((ne,Ce)=>{var Ie;if(It(),q){q({kind:ne,appendAttachments:(Ye,nt=ne)=>sn(Ye,nt),defaultPick:()=>{var Ye;return(Ye=Ce.current)==null?void 0:Ye.click()}});return}(Ie=Ce.current)==null||Ie.click()},[sn,It,q]);function on(ne){if(!ne)return;const Ce=Wt()??ge.current,Ie=(Ce==null?void 0:Ce.start)??_e.length,Ye=(Ce==null?void 0:Ce.end)??Ie,nt=su(ne),Vt=`${_e.slice(0,Ie)}${nt}${_e.slice(Ye)}`;z(Di=>({prompt:Vt,attachments:Di.attachments}));const Rt=Ie+nt.length;_.current={start:Rt,end:Rt},ge.current={start:Rt,end:Rt}}Pm({promptRef:de,isShellView:Se,prompt:_e,promptSegments:ei,attachmentPreviewUrls:pe,previewSignature:ti,editorSanitizeNonce:rt,pendingSelectionRef:_,pendingInsertedAttachmentIdsRef:se,selectionSnapshotRef:ge,renderedPreviewSignatureRef:Ne,renderedSanitizeNonceRef:Ae,serializeEditorPrompt:an,restoreSelection:ni});function It(){var ne;(ne=de.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function ai(){var ne;if(It(),ae(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const Ce=await navigator.clipboard.readText();on(Ce)}catch{return}}async function fa(){if(dt&&W(),or&&!Se){await _l();return}const ne=hu({prompt:_e,attachments:Fe,isShellView:Se});!ne||await oe(ne)===!1||z(()=>({prompt:"",attachments:[]}))}async function si(ne){ne.preventDefault(),await fa()}function oi(){const ne=an(),Ce=Wt();ge.current=Ce;const Ie=de.current;(Ie?Ku(Ie):!1)&&(_.current=Ce,it(nt=>nt+1)),z(nt=>({prompt:ne,attachments:nt.attachments.filter(Vt=>ne.includes(Vt.placeholder))}),"deferred")}function li(ne){var Ye,nt,Vt,Rt;const Ce=$n((Ye=ne.clipboardData)==null?void 0:Ye.items,(nt=ne.clipboardData)==null?void 0:nt.files),Ie=uu({files:Ce,plainText:((Vt=ne.clipboardData)==null?void 0:Vt.getData("text/plain"))??"",htmlText:((Rt=ne.clipboardData)==null?void 0:Rt.getData("text/html"))??"",htmlToText:Vu});Ie.preventDefault&&ne.preventDefault(),Ie.type==="insert-text"?on(Ie.text):Ie.type==="append-files"&&ma(Ie.files)}function ii(ne){var Ie,Ye;const Ce=Xa(Ja((Ie=ne.dataTransfer)==null?void 0:Ie.items,(Ye=ne.dataTransfer)==null?void 0:Ye.files));Ce.preventDefault&&ne.preventDefault(),Ce.activateDragTarget&&tt(!0)}function di(ne){var Ie,Ye;const Ce=Xa(Ja((Ie=ne.dataTransfer)==null?void 0:Ie.items,(Ye=ne.dataTransfer)==null?void 0:Ye.files));Ce.preventDefault&&ne.preventDefault(),Ce.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),Ce.activateDragTarget&&tt(!0)}function ci(ne){ne.currentTarget.contains(ne.relatedTarget)||tt(!1)}function hi(ne){var Ye,nt;const Ce=$n((Ye=ne.dataTransfer)==null?void 0:Ye.items,(nt=ne.dataTransfer)==null?void 0:nt.files),Ie=mu(Ce);Ie.preventDefault&&ne.preventDefault(),Ie.type==="accept-files"&&(tt(!1),ma(Ie.files??[]))}function ui(ne){if(e==="chat"&&ne.key==="/"&&!ne.metaKey&&!ne.ctrlKey&&!ne.altKey&&!n&&!k&&De.length>0&&an().trim().length===0){ne.preventDefault(),ke("root"),ae("slash");return}const Ce=pu({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:k});Ce.preventDefault&&ne.preventDefault(),Ce.submit&&fa()}const{promptPlaceholder:mi,interruptLabel:pi,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:fi,effortControlsDisabled:gi,effortControlTitle:xi}=Cu({goalComposeMode:or,goalBusy:rn,threadConnected:y,busy:n,isShellView:Se,disabledPlaceholder:N,settingsBusy:a,supportedEffortCount:ua.length,fastMode:d}),{composerLayerClassName:bi,formClassName:vi,composerShellClassName:ki,composerToolbarClassName:wi,composerIconButtonClassName:yi,composerMenuClassName:ji,composerMenuItemClassName:Ni,composerInlineToggleClassName:Ci,composerPanelButtonClassName:Si,composerChipButtonClassName:Ti,composerPlanToggleActiveClassName:Ei,composerSendButtonClassName:Li,composerPromptRegionClassName:Pi,promptInputClassName:zi,graphChatInputGroupClassName:Ii,graphChatInputClassName:Ri}=Su({isShellView:Se,edgeToEdgeMobile:r,isMobileShell:We,openMenu:U!==null,isDragTargetActive:et,busy:n}),Ai=Mm({isShellView:Se,canToggleShellView:Be,isMobileShell:We,shellPromptLabel:at,openMenu:U,toolbarClassName:wi,iconButtonClassName:yi,menuClassName:ji,menuItemClassName:Ni,panelButtonClassName:Si,chipButtonClassName:Ti,inlineToggleClassName:Ci,planToggleActiveClassName:Ei,sendButtonBaseClassName:Li,slashPanelView:xe,availableToolboxItems:De,busy:n,settingsBusy:a,compactBusy:o,forkBusy:He,fastMode:d,goalComposeMode:or,goalBusy:rn,goalStatus:(ba=Z.data)==null?void 0:ba.status,activeView:e,disabled:k,model:l,modelOptions:f,modelContextTitle:Ql,contextUsage:p,reasoningEffort:i,supportedEfforts:ua,displayedCollaborationMode:Pe,sandboxMode:u,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:fi,effortControlsDisabled:gi,effortControlTitle:xi,forkTurnOptionsState:B,skillsState:D,copiedSkillName:Yl,hooksPanelMode:qe,hooksState:Q,hookConfigBusy:ze,hookConfigError:ot,hookConfigSuccess:Je,editingHookTarget:be,hookScope:ct,hookEventName:bt,hookMatcher:st,hookCommand:yt,hookTimeoutSec:jt,hookStatusMessage:Nt,mcpPanelMode:$e,mcpState:$,mcpConfigPath:Gl,mcpConfigError:Hl,mcpConfigSuccess:Ol,mcpConfigBusy:Fl,mcpHttpName:$l,mcpHttpUrl:Dl,mcpRawBlock:Bl,capabilities:{hostConfigFiles:je.hostConfigFiles,hookTrust:je.hookTrust,mcpConfigEditing:je.mcpConfigEditing,planMode:je.planMode,sandboxMode:m?!1:je.sandboxMode},shellControlState:C,onToggleView:Re,onDismissPromptFocus:It,onSetOpenMenu:ae,onToolboxItemClick:ri,onSetSlashPanelView:ke,onOpenForkTurns:()=>le==null?void 0:le(),onForkLatest:Ue,onForkTurn:Oe,onCopySkillInvokeName:Zl,onResetHookForm:Tl,onSetHooksPanelMode:ht,onClearHookConfigStatus:da,onSetEditingHookTarget:ar,onSetHookScope:sr,onSetHookEventName:ut,onSetHookMatcher:jl,onSetHookCommand:Nl,onSetHookTimeoutSec:Cl,onSetHookStatusMessage:Sl,onSaveHook:Ll,onStartEditingHook:El,onTrustHook:Pl,onUntrustHook:zl,onSetMcpPanelMode:Me,onClearMcpConfigStatus:ha,onSetMcpHttpName:Ul,onSetMcpHttpUrl:Wl,onSetMcpRawBlock:Vl,onPrepareRawMcpBlock:Kl,onSaveHttpMcp:ql,onSaveRawMcpBlock:Xl,onPickPhoto:()=>pa("photo",we),onPickFile:()=>pa("file",P),onUpdateSettings:ne=>void te(ne),onPasteShell:()=>void ai(),onCopyShell:()=>{It(),ae(null),ie==null||ie()},onClearShell:()=>{It(),ae(null),oe({prompt:"clear"})},onShellControl:ne=>{It(),ae(null),ye==null||ye(ne)}}),{promptSlot:_i,goalSlot:Mi,shellPromptSlot:$i}=Am({isShellView:Se,promptRef:de,prompt:_e,disabled:k,promptPlaceholder:mi,canInterrupt:Te,interruptLabel:pi,composerPromptRegionClassName:Pi,graphChatInputClassName:Ri,promptInputClassName:zi,goalComposeMode:or,goalTokenBudget:Il,goalLocalError:Rl,goalBusy:rn,busy:n,sendButtonLabel:ga,sendButtonClassName:xa,onInterrupt:A,onPromptInput:oi,onPromptPaste:li,onPromptKeyDown:ui,onPromptKeyUp:()=>{ge.current=Wt()},onPromptMouseUp:()=>{ge.current=Wt()},onPromptBlur:()=>{ge.current=Wt(),tt(!1),dt&&W()},onPromptDragEnter:ii,onPromptDragOver:di,onPromptDragLeave:ci,onPromptDrop:hi,onGoalTokenBudgetChange:Al,onCancelGoal:ca,onShellPromptChange:Jl});return t.jsx(am,{activeView:e,layerClassName:bi,formClassName:vi,shellClassName:ki,inputGroupClassName:Ii,error:s,followTail:j,photoInputRef:we,fileInputRef:P,onAppendAttachments:sn,onToggleFollow:he,onSubmit:si,formRef:F,promptSlot:_i,toolbarSlot:t.jsx(pm,{...Ai}),goalSlot:Mi,shellPromptSlot:$i})}var $m=c.createContext(null);function tl(){return c.useContext($m)}function gt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Ft(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Dm(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 Bm(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 rl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Gm({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 Ur.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 Fm({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 Hm({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 Om({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 Um({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function Wm({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 Vm({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 Km({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}jo();zt();function ss({...e}){return t.jsx(Ui,{"data-slot":"dialog",...e})}function os({...e}){return t.jsx(Wi,{"data-slot":"dialog-trigger",...e})}function qm({...e}){return t.jsx(Yi,{"data-slot":"dialog-portal",...e})}function Xm({className:e,...r}){return t.jsx(Zi,{"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 ls({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(qm,{"data-slot":"dialog-portal",children:[t.jsx(Xm,{}),t.jsxs(Vi,{"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(Ki,{"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(M.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function is({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 ds({className:e,...r}){return t.jsx(qi,{"data-slot":"dialog-title",className:Qe("text-lg font-semibold leading-none",e),...r})}function cs({className:e,...r}){return t.jsx(Xi,{"data-slot":"dialog-description",className:Qe("text-sm text-muted-foreground",e),...r})}var Ym=[{value:"system",label:"Follow system",icon:M.Monitor},{value:"dark",label:"Dark",icon:M.Moon},{value:"light",label:"Light",icon:M.Sun}];function Zm({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),v=a[e.workspaceId],b=v&&!n?v:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const C=e.providerSessionId;if(C)try{await navigator.clipboard.writeText(C),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const y=()=>o(e.id),w=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,k=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(M.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),C.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(M.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:C=>{C.stopPropagation(),C.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[b?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:b,children:b}):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 ${Bm(e.status)}`,children:Dm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:gt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),C.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(M.Trash2,{className:"h-3.5 w-3.5"})}):null]}),N=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:k,className:w,onClick:y})}):N?t.jsx("a",{href:N,onClick:C=>{C.preventDefault(),y()},title:m?e.title:void 0,className:w,children:k}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),y())},title:m?e.title:void 0,className:w,children:k})}function Jm({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(v=>t.jsx(Zm,{thread:v,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},v.id))})})}function Qm({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:v=null,currentWorkspaceLabel:b=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:w,metaContent:k,settingsContent:N,globalSettingsContent:C,workspaceLabels:E={},workspaceReturnHref:I,onWorkspaceReturn:q,getThreadHref:D,onOpenThread:$,getNewThreadHref:Q,newThreadHref:Z,newThreadLabel:B="New Chat",onNewThread:ee,onNewThreadTitle:oe,renderNewThreadDialogContent:A,renderThreadLink:J,onCloseAppNavigation:R,onRenameThread:Y,onDeleteThread:H,workspaceContent:T,workspaceTitle:O="Workspace",workspaceActions:G,children:L}){const S=tl(),V=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[K,le]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),X=i??(S==null?void 0:S.themeMode)??"system",ce=l??(S==null?void 0:S.effectiveTheme)??(X==="system"?K?"dark":"light":X),[re,fe]=c.useState(!1),[he,ve]=c.useState(!1),[Re,ie]=c.useState(!V),[ye,Te]=c.useState(V),[U,ae]=c.useState("chat"),[xe,ke]=c.useState(null),[$e,Me]=c.useState(""),[je,De]=c.useState(null),[F,de]=c.useState(!1),[we,P]=c.useState(""),[_,se]=c.useState(!1),[ge,Ne]=c.useState(!1),[Ae,Se]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(max-width: 639px)"),ze=()=>{Te(be.matches)};return ze(),be.addEventListener("change",ze),()=>{be.removeEventListener("change",ze)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(prefers-color-scheme: dark)"),ze=()=>{le(be.matches)};return ze(),be.addEventListener("change",ze),()=>{be.removeEventListener("change",ze)}},[]);const Be=c.useMemo(()=>[...v?e.filter(ze=>ze.workspaceId===v):e].sort((ze,ot)=>{if(ze.id===p)return-1;if(ot.id===p)return 1;const Je=Date.parse(ze.lastTurnStartedAt??ze.updatedAt);return Date.parse(ot.lastTurnStartedAt??ot.updatedAt)-Je}),[p,v,e]),We=Z??(Q==null?void 0:Q(v)),at=b??v??"all",et=x??g??p??"default_session",tt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),rt=d??(S==null?void 0:S.setThemeMode),it=!!rt,_e=()=>{fe(!1),R==null||R()};async function Fe(be){if(!Y)return;const ze=$e.trim();if(ze){De(be);try{await Y(be,ze),ke(null),Me("")}finally{De(null)}}}function dt(be){ke(be.id),Me(be.title)}function z(){ke(null),Me("")}function W(be){$==null||$(be),_e()}function pe(){de(!1),P("")}function Pe(be){if(!We||!be.trim())return We;try{const ze=new URL(We,window.location.origin);return ze.searchParams.set("title",be.trim()),`${ze.pathname}${ze.search}${ze.hash}`}catch{const ze=We.includes("?")?"&":"?";return`${We}${ze}title=${encodeURIComponent(be.trim())}`}}async function te(){const be=we.trim();se(!0);try{if(be&&oe){await oe(be),P(""),de(!1),_e();return}if(We){window.location.assign(Pe(be)??We);return}await(ee==null?void 0:ee()),P(""),de(!1),_e()}finally{se(!1)}}function He(be,ze=!1){const ot=ze?t.jsxs(t.Fragment,{children:[t.jsx(M.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:B})]}):t.jsxs(t.Fragment,{children:[t.jsx(M.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:B})]});return t.jsxs(ss,{open:F,onOpenChange:Je=>{_||de(Je)},children:[t.jsx(os,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":ze?B:void 0,title:B,className:be,children:ot})}),t.jsx(ls,{"data-testid":"create-thread-dialog","data-theme-effective":ce,"data-theme-mode":X,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:A?A({close:pe,closeNavigation:_e,currentWorkspaceId:v}):t.jsxs(t.Fragment,{children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Create New Chat"}),t.jsx(cs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Je=>P(Je.target.value),onKeyDown:Je=>{Je.key==="Enter"&&(Je.preventDefault(),te())},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 te(),disabled:_,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:_?"Creating...":"Create"})]})]})})]})}function Ue(){if(!N&&!k&&!C&&!it)return null;const be=!!(N||k),ze=!!C,ot=be&&ze,Je=Ae==="global"&&ze||!be&&ze?"global":"session";return t.jsxs(ss,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(os,{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(M.Settings,{className:"h-4 w-4"})})}),t.jsxs(ls,{"data-testid":"settings-dialog","data-theme-effective":ce,"data-theme-mode":X,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Settings"}),t.jsx(cs,{children:"Manage this session and host-wide preferences."})]}),it?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: ",ce]})]}),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:Ym.map(ht=>{const ar=ht.icon,sr=X===ht.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${ht.value}`,"aria-pressed":sr,disabled:!it,onClick:()=>rt==null?void 0:rt(ht.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 ${sr?"is-selected":""}`,children:[t.jsx(ar,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:ht.label})]},ht.value)})})]})}):null,ot?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":Je==="session",onClick:()=>Se("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Je==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Je==="global",onClick:()=>Se("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Je==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Je==="session"?t.jsxs("div",{className:"grid gap-4",children:[N?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:N}):null,k?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:k}):null,be?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:C})})]})]})}function Oe(be=!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)] ${be?"justify-center":""}`,children:[t.jsx(M.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:be?"sr-only":"",children:"Rooms"}),!be&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&Be.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,Be.length>0?t.jsx(Jm,{threads:Be,currentThreadId:p,currentWorkspaceId:v,workspaceLabels:E,onOpenThread:W,collapsed:be,...Y?{onBeginRenameThread:dt}:{},showDeleteButton:!!H,...D?{getThreadHref:D}:{},...J?{renderThreadLink:J}:{},...H?{onDeleteThread:H}:{}}):null]})]})})}function qe(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ie(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(M.ChevronsRight,{className:"h-4 w-4"})}),G?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:G})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:O}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??v??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G,t.jsx("button",{type:"button",onClick:()=>ie(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(M.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:b??v??"All threads"})]})]})})]})}const ct=!!T,bt=s==="mobile"||s==="responsive"&&ye,st=bt,yt=st&&!re,Nt=!!(I||q)?t.jsx("a",{href:I??"#",onClick:be=>{q&&(be.preventDefault(),q())},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(M.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Fm,{effectiveTheme:ce,layoutMode:s,themeMode:X,viewportConstrained:o,children:t.jsxs(Hm,{roomsRailCollapsed:he,children:[t.jsx(Om,{open:re,onClose:()=>fe(!1)}),t.jsxs(Um,{collapsed:he,mobileOpen:re,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${he?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${he?"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:()=>ve(be=>!be),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:he?"Expand rooms":"Collapse rooms","aria-label":he?"Expand rooms":"Collapse rooms",children:he?t.jsx(M.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(M.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)] ${he?"thread-desktop-collapsed-hidden":""}`,children:(b??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${he?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:b??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:v??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${he?"thread-desktop-collapsed-hidden":""}`,children:[Ue(),Nt,t.jsx("button",{type:"button",onClick:()=>fe(!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(M.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${he?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:He(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${he?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,he)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${he?"w-full px-2 py-2":"px-3 py-3"}`,children:Oe(he)})]}),t.jsxs(Wm,{children:[t.jsx(Vm,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[yt?t.jsx("button",{type:"button",onClick:()=>fe(!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(M.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[st?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:g??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ne(be=>!be)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:at})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var be;et&&((be=navigator.clipboard)==null||be.writeText(et))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:tt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||w?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,w]}):null,st&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,st&&ct?t.jsx("button",{type:"button",onClick:()=>ae(be=>be==="workspace"?"chat":"workspace"),"aria-label":U==="workspace"?"Show chat":"Show workspace",title:U==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:U==="workspace"?t.jsx(M.MessageSquare,{className:"h-4 w-4"}):t.jsx(M.Folder,{className:"h-4 w-4"})}):null,st?f:null,st&&h?He("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(Km,{children:ct&&!Re?bt?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 ${U==="chat"?"block":"thread-mobile-chat-hidden"}`,children:L}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${U==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:qe()})]}):t.jsxs(En,{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(Qt,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:L}),t.jsx(Ln,{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(Qt,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:qe()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ct&&Re?t.jsx("button",{type:"button",onClick:()=>ie(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(M.ChevronsLeft,{className:"h-4 w-4"})}):null,L]})})]})]})}),t.jsx(Gm,{open:xe!==null,title:"Rename Thread",label:"Thread Title",value:$e,busy:je!==null,onChange:Me,onCancel:z,onSubmit:()=>xe?Fe(xe):void 0})]})}function ep({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?Ur.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 tp=[/^(?: {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],rp=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,np=/!?\[[^\]\n]+\]\([^)]+\)/,ap=/`[^`\n]+`/,sp=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,op=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,lp=/~~[^~\n]+~~/;function ip(e){const r=e.trim();return r?tp.some(n=>n.test(r))||rp.test(r)?!0:/[`[\]*_~!]/.test(r)?np.test(r)||ap.test(r)||sp.test(r)||op.test(r)||lp.test(r):!1:!1}Yr();function Gn(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 ra(e=[]){const r=Gn(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 na=c.createContext(ra());function aa(){return c.useContext(na)??ra()}Nr();function nl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hs(e){return nl(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function al(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 dp(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)}):al(r)}function us({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(M.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(M.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>hs(o),[o]),i=c.useMemo(()=>hs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:nl(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(wr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(yr,{value:"item-1",className:"border-0",children:[t.jsx(Zr,{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(M.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(jr,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),al(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),dp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ms=null;function cp(){return ms??(ms=Promise.all([Ke(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Ke(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ke(()=>import("./ayu-light-BA47KaF1.js"),[]),Ke(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ke(()=>import("./javascript-wDzz0qaB.js"),[]),Ke(()=>import("./typescript-BPQ3VLAy.js"),[]),Ke(()=>import("./tsx-COt5Ahok.js"),[]),Ke(()=>import("./jsx-g9-lgVsj.js"),[]),Ke(()=>import("./python-B6aJPvgy.js"),[]),Ke(()=>import("./json-Cp-IABpG.js"),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ke(()=>import("./yaml-Buea-lGh.js"),[]),Ke(()=>import("./toml-vGWfd6FD.js"),[]),Ke(()=>import("./markdown-Cvjx9yec.js"),[]),Ke(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ke(()=>import("./css-CLj8gQPS.js"),[]),Ke(()=>import("./sql-CRqJ_cUM.js"),[]),Ke(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,v,b,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,v.default,b.default,x.default,j.default]}))),ms}function Jr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fn(e){if(!e)return{};if(Jr(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 Hn(){return{finalResult:null,stdout:"",stderr:""}}function hp(e){return typeof e=="string"?{result:e}:e}function sl(e){const r=Jr(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 ps(e){if(!e)return"pending";if(!Jr(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 up(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=hp(d.result),m=r.get(h)??Hn();return Jr(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Fn(d.args);if(typeof h=="string"&&r.has(h)){const f=sl(r.get(h)??Hn());return`\`\`\`tool-merged
|
|
3656
|
+
`,as="MCP entry written to provider config. Restart the backend if it does not appear immediately.";function Tm({hostConfigFilesAvailable:e,onReadProviderConfig:r,onWriteProviderConfig:n,setMcpPanelMode:a,onOpenMcp:o}){const[s,l]=c.useState(""),[i,d]=c.useState(""),[h,u]=c.useState(""),[m,f]=c.useState(null),[p,g]=c.useState(!1),[v,b]=c.useState(null),[x,j]=c.useState(null),y=c.useCallback(()=>{b(null),j(null)},[]),w=c.useCallback(async()=>{if(!e||!r)throw new Error("Provider config editing is unavailable for this thread.");const z=await r();return f(z.path),z},[e,r]),k=c.useCallback(async z=>{if(!e||!n)throw new Error("Provider config editing is unavailable for this thread.");const q=await n(z);return f(q.path),q},[e,n]),N=c.useCallback(async()=>{const z=vu(s),q=i.trim();if(!z){b("MCP name must use only letters, numbers, underscore, or hyphen.");return}if(!/^https?:\/\//i.test(q)){b("HTTP MCP URL must start with http:// or https://");return}g(!0),b(null),j(null);try{const D=await w(),$=Za(D.content,z,wu(z,q));await k($),j(as),a("list"),l(""),d(""),o==null||o()}catch(D){b(D instanceof Error?D.message:"Unable to update provider config.")}finally{g(!1)}},[w,s,i,o,a,k]),C=c.useCallback(async()=>{g(!0),b(null),j(null);try{await w(),u(z=>z||Sm),a("stdio")}catch(z){b(z instanceof Error?z.message:"Unable to load provider config.")}finally{g(!1)}},[w,a]),E=c.useCallback(async()=>{const z=ku(h);if(!z){b("The raw MCP block must start with a header like [mcp_servers.name].");return}g(!0),b(null),j(null);try{const q=await w(),D=Za(q.content,z,h);await k(D),j(as),a("list"),o==null||o()}catch(q){b(q instanceof Error?q.message:"Unable to update provider config.")}finally{g(!1)}},[w,h,o,a,k]);return{mcpHttpName:s,mcpHttpUrl:i,mcpRawBlock:h,mcpConfigPath:m,mcpConfigBusy:p,mcpConfigError:v,mcpConfigSuccess:x,setMcpHttpName:l,setMcpHttpUrl:d,setMcpRawBlock:u,clearMcpConfigStatus:y,prepareRawMcpBlock:C,saveHttpMcp:N,saveRawMcpBlock:E}}function Em({openMenu:e,setOpenMenu:r,slashPanelView:n,setSlashPanelView:a,setMcpPanelMode:o,clearMcpConfigStatus:s,clearHookConfigStatus:l}){const[i,d]=c.useState(null);c.useEffect(()=>{e!=="slash"&&(a("root"),o("list"),s(),l())},[l,s,e,o,a]),c.useEffect(()=>{n!=="mcp"&&(o("list"),s())},[s,o,n]),c.useEffect(()=>{if(!i)return;const u=window.setTimeout(()=>{d(m=>m===i?null:m)},1400);return()=>{window.clearTimeout(u)}},[i]),c.useEffect(()=>{function u(m){(typeof m.composedPath=="function"?m.composedPath():[]).some(g=>g instanceof HTMLElement&&(g.dataset.composerMenuSurface==="true"||g.dataset.composerMenuTrigger==="true"))||e&&r(null)}if(e)return window.addEventListener("pointerdown",u),()=>{window.removeEventListener("pointerdown",u)}},[e,r]);const h=c.useCallback(async u=>{try{await navigator.clipboard.writeText(`$${u}`),d(u)}catch{d(null)}},[]);return{copiedSkillName:i,copySkillInvokeName:h}}function Lm(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=Qa(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=Qa(n),a.append(o,s),a}function Pm(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(Lm(a,r))}return n}function Im({promptRef:e,isShellView:r,prompt:n,promptSegments:a,attachmentPreviewUrls:o,previewSignature:s,editorSanitizeNonce:l,pendingSelectionRef:i,pendingInsertedAttachmentIdsRef:d,selectionSnapshotRef:h,renderedPreviewSignatureRef:u,renderedSanitizeNonceRef:m,serializeEditorPrompt:f,restoreSelection:p}){c.useLayoutEffect(()=>{const g=e.current;if(!g||r)return;const v=i.current,b=f()!==n||u.current!==s||m.current!==l;b&&(g.replaceChildren(Pm(a,o)),u.current=s,m.current=l),v!==null?(g.focus(),Zu(g,d.current)||p(v),h.current=v):document.activeElement===g&&b&&p(h.current),i.current=null,d.current=[]},[o,l,r,s,n,e,a,d,i,u,m,p,h,f])}function zm({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 Rm({promptRef:e,prompt:r,disabled:n,promptPlaceholder:a,canInterrupt:o,interruptLabel:s,composerPromptRegionClassName:l,graphChatInputClassName:i,onInterrupt:d,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:v,onDragOver:b,onDragLeave:x,onDrop:j}){return t.jsxs("div",{"data-slot":"input-group-control",className:`${l} relative w-full`,children:[t.jsxs("div",{className:i,children:[r.length===0&&t.jsx("span",{className:`pointer-events-none absolute left-3 top-3 truncate text-slate-500 sm:left-4 sm:top-4 dark:text-slate-400 ${o?"right-12":"right-3 sm:right-4"}`,children:a}),t.jsx("div",{ref:e,role:"textbox","aria-label":"Prompt","aria-multiline":"true",contentEditable:!n,suppressContentEditableWarning:!0,onInput:h,onPaste:u,onKeyDown:m,onKeyUp:f,onMouseUp:p,onBlur:g,onDragEnter:v,onDragOver:b,onDragLeave:x,onDrop:j,className:`relative z-[1] min-h-[4.25rem] whitespace-pre-wrap break-words pb-2 outline-none sm:min-h-[4.25rem] ${o?"pr-12":""} ${n?"cursor-not-allowed text-slate-500":""}`})]}),o?t.jsx(wt,{type:"button",variant:"ghost",size:"icon-xs","aria-label":s,title:s,onClick:y=>{y.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 Am({prompt:e,promptPlaceholder:r,promptRegionClassName:n,promptInputClassName:a,interruptLabel:o,canInterrupt:s,sendButtonLabel:l,sendButtonClassName:i,sendDisabled:d,onPromptChange:h,onPromptKeyDown:u,onInterrupt:m}){return t.jsxs("div",{className:`${n} relative`,children:[t.jsx("textarea",{"aria-label":"Prompt",disabled:!1,value:e,onChange:f=>h(f.target.value),onKeyDown:u,rows:2,placeholder:r,className:`${a} resize-y pb-10`}),t.jsx("button",{type:"button","aria-label":o,title:o,onClick:()=>void(m==null?void 0:m()),disabled:!s,className:`absolute right-2.5 top-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full border transition ${s?"border-rose-300/55 bg-rose-300/[0.14] text-rose-50 shadow-lg shadow-rose-950/20 hover:bg-rose-300/[0.22]":"cursor-not-allowed border-stone-700/30 bg-stone-400/[0.02] text-stone-500/55 opacity-55"}`,children:t.jsx("span",{"aria-hidden":"true",className:"block h-2.5 w-2.5 rounded-[2px] bg-current"})}),t.jsx("button",{type:"submit","aria-label":"Send Shell Input",onMouseDown:f=>{f.preventDefault()},onPointerDown:f=>{f.preventDefault()},onTouchStart:f=>{f.preventDefault()},disabled:d,className:`absolute bottom-2.5 right-2.5 rounded-full px-3.5 py-1.5 text-sm font-medium shadow-lg shadow-stone-950/30 transition disabled:cursor-not-allowed disabled:bg-stone-700 disabled:text-stone-300 ${i}`,children:l})]})}function _m({isShellView:e,promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,promptInputClassName:h,goalComposeMode:u,goalTokenBudget:m,goalLocalError:f,goalBusy:p,busy:g,sendButtonLabel:v,sendButtonClassName:b,onInterrupt:x,onPromptInput:j,onPromptPaste:y,onPromptKeyDown:w,onPromptKeyUp:k,onPromptMouseUp:N,onPromptBlur:C,onPromptDragEnter:E,onPromptDragOver:z,onPromptDragLeave:q,onPromptDrop:D,onGoalTokenBudgetChange:$,onCancelGoal:Q,onShellPromptChange:Z}){return{promptSlot:e?null:t.jsx(Rm,{promptRef:r,prompt:n,disabled:a,promptPlaceholder:o,canInterrupt:s,interruptLabel:l,composerPromptRegionClassName:i,graphChatInputClassName:d,onInterrupt:x,onInput:j,onPaste:y,onKeyDown:w,onKeyUp:k,onMouseUp:N,onBlur:C,onDragEnter:E,onDragOver:z,onDragLeave:q,onDrop:D}),goalSlot:u&&!e?t.jsx(zm,{tokenBudget:m,error:f,onTokenBudgetChange:$,onCancel:Q}):null,shellPromptSlot:e?t.jsx(Am,{prompt:n,promptPlaceholder:o,promptRegionClassName:i,promptInputClassName:h,interruptLabel:l,canInterrupt:s,sendButtonLabel:v,sendButtonClassName:b,sendDisabled:p||g,onPromptChange:Z,onPromptKeyDown:w,onInterrupt:x}):null}}function Mm({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=gu({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 $m({isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,inlineToggleClassName:m,planToggleActiveClassName:f,sendButtonBaseClassName:p,slashPanelView:g,availableToolboxItems:v,busy:b,settingsBusy:x,compactBusy:j,forkBusy:y,fastMode:w,goalComposeMode:k,goalBusy:N,goalStatus:C,activeView:E,disabled:z,model:q,modelOptions:D,modelContextTitle:$,contextUsage:Q,reasoningEffort:Z,supportedEfforts:B,displayedCollaborationMode:ee,sandboxMode:oe,sendButtonLabel:A,sendButtonClassName:J,modelControlsDisabled:R,effortControlsDisabled:Y,effortControlTitle:H,forkTurnOptionsState:T,skillsState:O,copiedSkillName:G,hooksPanelMode:L,hooksState:S,hookConfigBusy:V,hookConfigError:K,hookConfigSuccess:le,editingHookTarget:X,hookScope:ce,hookEventName:re,hookMatcher:fe,hookCommand:he,hookTimeoutSec:ve,hookStatusMessage:Re,mcpPanelMode:ie,mcpState:ye,mcpConfigPath:Te,mcpConfigError:W,mcpConfigSuccess:ae,mcpConfigBusy:xe,mcpHttpName:ke,mcpHttpUrl:$e,mcpRawBlock:Me,capabilities:je,shellControlState:De,onToggleView:F,onDismissPromptFocus:de,onSetOpenMenu:we,onToolboxItemClick:P,onSetSlashPanelView:_,onOpenForkTurns:se,onForkLatest:ge,onForkTurn:Ne,onCopySkillInvokeName:Ae,onResetHookForm:Se,onSetHooksPanelMode:Be,onClearHookConfigStatus:Ue,onSetEditingHookTarget:at,onSetHookScope:et,onSetHookEventName:tt,onSetHookMatcher:rt,onSetHookCommand:it,onSetHookTimeoutSec:_e,onSetHookStatusMessage:Fe,onSaveHook:dt,onStartEditingHook:I,onTrustHook:U,onUntrustHook:pe,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:te,onSetMcpHttpName:He,onSetMcpHttpUrl:We,onSetMcpRawBlock:Oe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:ct,onSaveRawMcpBlock:bt,onPickPhoto:st,onPickFile:yt,onUpdateSettings:jt,onPasteShell:Nt,onCopyShell:be,onClearShell:Ie,onShellControl:ot}){const Je=e?null:{open:o==="slash",slashPanelView:g,availableToolboxItems:v,busy:b,forkBusy:y,forkTurnOptionsState:T,skillsState:O,copiedSkillName:G,hooksPanelMode:L,hooksState:S,hostConfigFilesAvailable:je.hostConfigFiles,hookTrustAvailable:je.hookTrust,hookConfigBusy:V,hookConfigError:K,hookConfigSuccess:le,editingHookTarget:X,hookScope:ce,hookEventName:re,hookMatcher:fe,hookCommand:he,hookTimeoutSec:ve,hookStatusMessage:Re,mcpPanelMode:ie,mcpState:ye,mcpConfigEditing:je.mcpConfigEditing,mcpConfigPath:Te,mcpConfigError:W,mcpConfigSuccess:ae,mcpConfigBusy:xe,mcpHttpName:ke,mcpHttpUrl:$e,mcpRawBlock:Me,iconButtonClassName:l,menuClassName:i,menuItemClassName:d,panelButtonClassName:h,chipButtonClassName:u,onToggle:()=>we(ut=>ut==="slash"?null:"slash"),onToolboxItemClick:P,toolboxItemDisabled:ut=>Uu(ut,{settingsBusy:x,compactBusy:j,busy:b,forkBusy:y}),toolboxItemClassName:ut=>Vu(ut,{fastMode:w,goalComposeMode:k,goalStatus:C,menuItemClassName:d}),toolboxItemStatus:ut=>Wu(ut,{fastMode:w,compactBusy:j,goalComposeMode:k,goalStatus:C,busy:b}),onSetSlashPanelView:_,onOpenForkTurns:se,onForkLatest:ge,onForkTurn:Ne,onCopySkillInvokeName:Ae,onResetHookForm:Se,onSetHooksPanelMode:Be,onClearHookConfigStatus:Ue,onSetEditingHookTarget:at,onSetHookScope:et,onSetHookEventName:tt,onSetHookMatcher:rt,onSetHookCommand:it,onSetHookTimeoutSec:_e,onSetHookStatusMessage:Fe,onSaveHook:dt,onStartEditingHook:I,onTrustHook:U,onUntrustHook:pe,onSetMcpPanelMode:Pe,onClearMcpConfigStatus:te,onSetMcpHttpName:He,onSetMcpHttpUrl:We,onSetMcpRawBlock:Oe,onPrepareRawMcpBlock:qe,onSaveHttpMcp:ct,onSaveRawMcpBlock:bt},ht=e?null:{open:o==="attachments",iconButtonClassName:l,menuClassName:i,menuItemClassName:d,onToggle:()=>we(ut=>ut==="attachments"?null:"attachments"),onPickPhoto:st,onPickFile:yt},sr=e?null:{openMenu:o,model:q,modelOptions:D,modelContextTitle:$,contextUsage:Q,reasoningEffort:Z,supportedEfforts:B,displayedCollaborationMode:ee,sandboxMode:oe,planModeAvailable:je.planMode,sandboxModeAvailable:je.sandboxMode,settingsBusy:x,goalComposeMode:k,goalBusy:N,activeView:E,disabled:z,fastMode:w,sendButtonLabel:A,sendButtonClassName:J,modelControlsDisabled:R,effortControlsDisabled:Y,effortControlTitle:H,inlineToggleClassName:m,menuItemClassName:d,planToggleActiveClassName:f,sendButtonBaseClassName:p,onSetOpenMenu:we,onUpdateSettings:jt};return{isShellView:e,canToggleShellView:r,isMobileShell:n,shellPromptLabel:a,openMenu:o,toolbarClassName:s,iconButtonClassName:l,slashToolboxProps:Je,attachmentMenuProps:ht,settingsToolbarProps:sr,shellToolsPanelProps:o==="shellTools"?{busy:b,shellControlState:De,onPaste:Nt,onCopy:be,onClear:Ie,onShellControl:ot}:null,shellControlState:De,onToggleView:F,onDismissPromptFocus:de,onSetOpenMenu:we}}function Bn({activeView:e,edgeToEdgeMobile:r=!1,busy:n=!1,settingsBusy:a=!1,compactBusy:o=!1,error:s,model:l=null,reasoningEffort:i=null,fastMode:d=!1,collaborationMode:h="default",sandboxMode:u=null,hideSandboxModeControl:m=!1,modelOptions:f=[],contextUsage:p=null,capabilities:g=null,toolboxItems:v=null,hookCommandTemplates:b=null,mcpConfigFormat:x="none",followTail:j=!1,threadConnected:y=!0,shellAvailable:w=!0,disabled:k=!1,disabledPlaceholder:N,shellControlState:C=null,draftPrompt:E,draftAttachments:z,onPickAttachment:q,skillsState:D={status:"idle",data:null,error:null},mcpState:$={status:"idle",data:null,error:null},hooksState:Q={status:"idle",data:null,error:null},goalState:Z={status:"idle",data:null,error:null},forkTurnOptionsState:B={status:"idle",data:null,error:null},onDraftChange:ee,onSubmit:oe,onInterrupt:A,onCompact:J,onOpenSkills:R,onOpenMcp:Y,onOpenHooks:H,onCreateHook:T,onUpdateHook:O,onTrustHook:G,onUntrustHook:L,onOpenGoal:S,onPrepareGoalSubmit:V,onUpdateGoal:K,onOpenForkTurns:le,onForkLatest:X,onForkTurn:ce,onReadProviderConfig:re,onWriteProviderConfig:fe,onToggleFollow:he,onUpdateSettings:ve,onToggleView:Re,onShellCopy:ie,onShellControl:ye,canInterrupt:Te=!1}){var ba;const[W,ae]=c.useState(null),[xe,ke]=c.useState("root"),[$e,Me]=c.useState("list"),je=c.useMemo(()=>({fast:(g==null?void 0:g.controls.performanceMode)??!1,compact:(g==null?void 0:g.turns.compact)??!1,goal:(g==null?void 0:g.controls.goals)??!1,fork:(g==null?void 0:g.branching.fork)??!1,skills:(g==null?void 0:g.management.skills)??!1,mcp:(g==null?void 0:g.management.mcpStatus)??!1,hooks:(g==null?void 0:g.management.hooks)??!1,hostConfigFiles:(g==null?void 0:g.management.hostConfigFiles)??!1,mcpConfigEditing:x==="codex-toml"&&!!(g!=null&&g.management.hostConfigFiles)&&!!re&&!!fe,hookTrust:(g==null?void 0:g.management.hookTrust)??!1,planMode:(g==null?void 0:g.controls.planMode)??!1,sandboxMode:(g==null?void 0:g.controls.sandboxMode)??!1}),[g,x,re,fe]),De=c.useMemo(()=>Hu(v,je),[je,v]),F=c.useRef(null),de=c.useRef(null),we=c.useRef(null),P=c.useRef(null),_=c.useRef(null),se=c.useRef([]),ge=c.useRef(null),Ne=c.useRef(""),Ae=c.useRef(0),Se=e==="shell",Be=w||Se,Ue=!!(Se&&(C!=null&&C.isMobileShell)),at=(C==null?void 0:C.promptLabel)??null,[et,tt]=c.useState(!1),[rt,it]=c.useState(0),{prompt:_e,attachments:Fe,isDraftControlled:dt,updateDraft:I,flushControlledDraftToHost:U}=wm({isShellView:Se,draftPrompt:E,draftAttachments:z,onDraftChange:ee}),pe=vm({attachments:Fe,isShellView:Se}),{displayedCollaborationMode:Pe,updateSettings:te}=Mm({collaborationMode:h,onUpdateSettings:ve,closeMenu:()=>ae(null)}),{forkBusy:He,forkLatest:We,forkTurn:Oe}=ym({slashPanelView:xe,onForkLatest:X,onForkTurn:ce,closeMenu:()=>ae(null)}),{hooksPanelMode:qe,hookScope:ct,hookEventName:bt,hookMatcher:st,hookCommand:yt,hookTimeoutSec:jt,hookStatusMessage:Nt,editingHookTarget:be,hookConfigBusy:Ie,hookConfigError:ot,hookConfigSuccess:Je,setHooksPanelMode:ht,setEditingHookTarget:sr,setHookScope:or,setHookEventName:ut,setHookMatcher:Nl,setHookCommand:Cl,setHookTimeoutSec:Sl,setHookStatusMessage:Tl,clearHookConfigStatus:da,resetHookForm:El,startEditingHook:Ll,saveHook:Pl,trustHook:Il,untrustHook:zl}=Cm({slashPanelView:xe,hookCommandTemplates:b,onCreateHook:T,onUpdateHook:O,onTrustHook:G,onUntrustHook:L}),{goalComposeMode:lr,goalTokenBudget:Rl,goalBusy:an,goalLocalError:Al,setGoalTokenBudget:_l,submitGoal:Ml,enterGoalComposeMode:$l,exitGoalComposeMode:ca}=jm({prompt:_e,goalTokenBudgetSource:Z.data,promptRef:de,onOpenGoal:S,onPrepareGoalSubmit:V,onUpdateGoal:K,updateDraft:I,closeMenu:()=>ae(null),resetSlashPanel:()=>ke("root")}),{mcpHttpName:Dl,mcpHttpUrl:Bl,mcpRawBlock:Gl,mcpConfigPath:Fl,mcpConfigBusy:Hl,mcpConfigError:Ol,mcpConfigSuccess:Wl,setMcpHttpName:Ul,setMcpHttpUrl:Vl,setMcpRawBlock:Kl,clearMcpConfigStatus:ha,prepareRawMcpBlock:ql,saveHttpMcp:Xl,saveRawMcpBlock:Yl}=Tm({hostConfigFilesAvailable:je.hostConfigFiles,onReadProviderConfig:re,onWriteProviderConfig:fe,setMcpPanelMode:Me,onOpenMcp:Y}),{copiedSkillName:Zl,copySkillInvokeName:Jl}=Em({openMenu:W,setOpenMenu:ae,slashPanelView:xe,setSlashPanelView:ke,setMcpPanelMode:Me,clearMcpConfigStatus:ha,clearHookConfigStatus:da}),Ql=c.useCallback(ne=>{I(Ce=>{if(typeof ne=="function"){const ze=ne(Ce.prompt,Ce.attachments);return{prompt:ze.prompt,attachments:ze.attachments??Ce.attachments}}return{prompt:ne,attachments:Ce.attachments}})},[I]),sn=c.useMemo(()=>f.find(ne=>ne.model===l)??null,[l,f]),ei=yu(l,p),ua=(sn==null?void 0:sn.supportedReasoningEfforts)??[],ti=c.useMemo(()=>lu(_e,Fe),[Fe,_e]),ri=c.useMemo(()=>Object.entries(pe).sort(([ne],[Ce])=>ne.localeCompare(Ce)).map(([ne,Ce])=>`${ne}:${Ce}`).join("|"),[pe]);function ni(ne,Ce){Ce.stopPropagation();const ze=Ou(ne,{fastMode:d,goalComposeMode:lr});switch(ze.type){case"toggleFast":te({fastMode:ze.fastMode});break;case"runCompact":ae(null),J==null||J();break;case"enterGoalCompose":$l();break;case"exitGoalCompose":ca(),ae(null);break;case"openPanel":ke(ze.panel),ze.panel==="skills"?R==null||R():ze.panel==="mcp"?Y==null||Y():ze.panel==="hooks"&&(H==null||H());break;case"insertPrompt":dn(ze.text),ke("root"),ae(null);break}}function Ut(){const ne=de.current;return ne?Xu(ne):null}const ai=c.useCallback(ne=>{const Ce=de.current;!Ce||!ne||Yu(Ce,ne)},[]),on=c.useCallback(()=>{const ne=de.current;return ne?el(ne):_e},[_e]),{appendAttachments:ln,appendDroppedAttachments:ma}=bm({prompt:_e,attachments:Fe,updateDraft:I,getSelection:Ut,selectionSnapshotRef:ge,pendingSelectionRef:_,pendingInsertedAttachmentIdsRef:se,onInserted:()=>ae(null)}),pa=c.useCallback((ne,Ce)=>{var ze;if(zt(),q){q({kind:ne,appendAttachments:(Ye,nt=ne)=>ln(Ye,nt),defaultPick:()=>{var Ye;return(Ye=Ce.current)==null?void 0:Ye.click()}});return}(ze=Ce.current)==null||ze.click()},[ln,zt,q]);function dn(ne){if(!ne)return;const Ce=Ut()??ge.current,ze=(Ce==null?void 0:Ce.start)??_e.length,Ye=(Ce==null?void 0:Ce.end)??ze,nt=ou(ne),Vt=`${_e.slice(0,ze)}${nt}${_e.slice(Ye)}`;I(Bi=>({prompt:Vt,attachments:Bi.attachments}));const Rt=ze+nt.length;_.current={start:Rt,end:Rt},ge.current={start:Rt,end:Rt}}Im({promptRef:de,isShellView:Se,prompt:_e,promptSegments:ti,attachmentPreviewUrls:pe,previewSignature:ri,editorSanitizeNonce:rt,pendingSelectionRef:_,pendingInsertedAttachmentIdsRef:se,selectionSnapshotRef:ge,renderedPreviewSignatureRef:Ne,renderedSanitizeNonceRef:Ae,serializeEditorPrompt:on,restoreSelection:ai});function zt(){var ne;(ne=de.current)==null||ne.blur(),document.activeElement instanceof HTMLElement&&document.activeElement!==document.body&&document.activeElement.blur()}async function si(){var ne;if(zt(),ae(null),!!((ne=navigator.clipboard)!=null&&ne.readText))try{const Ce=await navigator.clipboard.readText();dn(Ce)}catch{return}}async function fa(){if(dt&&U(),lr&&!Se){await Ml();return}const ne=uu({prompt:_e,attachments:Fe,isShellView:Se});!ne||await oe(ne)===!1||I(()=>({prompt:"",attachments:[]}))}async function oi(ne){ne.preventDefault(),await fa()}function li(){const ne=on(),Ce=Ut();ge.current=Ce;const ze=de.current;(ze?qu(ze):!1)&&(_.current=Ce,it(nt=>nt+1)),I(nt=>({prompt:ne,attachments:nt.attachments.filter(Vt=>ne.includes(Vt.placeholder))}),"deferred")}function ii(ne){var Ye,nt,Vt,Rt;const Ce=$n((Ye=ne.clipboardData)==null?void 0:Ye.items,(nt=ne.clipboardData)==null?void 0:nt.files),ze=mu({files:Ce,plainText:((Vt=ne.clipboardData)==null?void 0:Vt.getData("text/plain"))??"",htmlText:((Rt=ne.clipboardData)==null?void 0:Rt.getData("text/html"))??"",htmlToText:Ku});ze.preventDefault&&ne.preventDefault(),ze.type==="insert-text"?dn(ze.text):ze.type==="append-files"&&ma(ze.files)}function di(ne){var ze,Ye;const Ce=Xa(Ja((ze=ne.dataTransfer)==null?void 0:ze.items,(Ye=ne.dataTransfer)==null?void 0:Ye.files));Ce.preventDefault&&ne.preventDefault(),Ce.activateDragTarget&&tt(!0)}function ci(ne){var ze,Ye;const Ce=Xa(Ja((ze=ne.dataTransfer)==null?void 0:ze.items,(Ye=ne.dataTransfer)==null?void 0:Ye.files));Ce.preventDefault&&ne.preventDefault(),Ce.activateDragTarget&&ne.dataTransfer&&(ne.dataTransfer.dropEffect="copy"),Ce.activateDragTarget&&tt(!0)}function hi(ne){ne.currentTarget.contains(ne.relatedTarget)||tt(!1)}function ui(ne){var Ye,nt;const Ce=$n((Ye=ne.dataTransfer)==null?void 0:Ye.items,(nt=ne.dataTransfer)==null?void 0:nt.files),ze=pu(Ce);ze.preventDefault&&ne.preventDefault(),ze.type==="accept-files"&&(tt(!1),ma(ze.files??[]))}function mi(ne){if(e==="chat"&&ne.key==="/"&&!ne.metaKey&&!ne.ctrlKey&&!ne.altKey&&!n&&!k&&De.length>0&&on().trim().length===0){ne.preventDefault(),ke("root"),ae("slash");return}const Ce=fu({key:ne.key,metaKey:ne.metaKey,ctrlKey:ne.ctrlKey,busy:n,disabled:k});Ce.preventDefault&&ne.preventDefault(),Ce.submit&&fa()}const{promptPlaceholder:pi,interruptLabel:fi,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:gi,effortControlsDisabled:xi,effortControlTitle:bi}=Su({goalComposeMode:lr,goalBusy:an,threadConnected:y,busy:n,isShellView:Se,disabledPlaceholder:N,settingsBusy:a,supportedEffortCount:ua.length,fastMode:d}),{composerLayerClassName:vi,formClassName:ki,composerShellClassName:wi,composerToolbarClassName:yi,composerIconButtonClassName:ji,composerMenuClassName:Ni,composerMenuItemClassName:Ci,composerInlineToggleClassName:Si,composerPanelButtonClassName:Ti,composerChipButtonClassName:Ei,composerPlanToggleActiveClassName:Li,composerSendButtonClassName:Pi,composerPromptRegionClassName:Ii,promptInputClassName:zi,graphChatInputGroupClassName:Ri,graphChatInputClassName:Ai}=Tu({isShellView:Se,edgeToEdgeMobile:r,isMobileShell:Ue,openMenu:W!==null,isDragTargetActive:et,busy:n}),_i=$m({isShellView:Se,canToggleShellView:Be,isMobileShell:Ue,shellPromptLabel:at,openMenu:W,toolbarClassName:yi,iconButtonClassName:ji,menuClassName:Ni,menuItemClassName:Ci,panelButtonClassName:Ti,chipButtonClassName:Ei,inlineToggleClassName:Si,planToggleActiveClassName:Li,sendButtonBaseClassName:Pi,slashPanelView:xe,availableToolboxItems:De,busy:n,settingsBusy:a,compactBusy:o,forkBusy:He,fastMode:d,goalComposeMode:lr,goalBusy:an,goalStatus:(ba=Z.data)==null?void 0:ba.status,activeView:e,disabled:k,model:l,modelOptions:f,modelContextTitle:ei,contextUsage:p,reasoningEffort:i,supportedEfforts:ua,displayedCollaborationMode:Pe,sandboxMode:u,sendButtonLabel:ga,sendButtonClassName:xa,modelControlsDisabled:gi,effortControlsDisabled:xi,effortControlTitle:bi,forkTurnOptionsState:B,skillsState:D,copiedSkillName:Zl,hooksPanelMode:qe,hooksState:Q,hookConfigBusy:Ie,hookConfigError:ot,hookConfigSuccess:Je,editingHookTarget:be,hookScope:ct,hookEventName:bt,hookMatcher:st,hookCommand:yt,hookTimeoutSec:jt,hookStatusMessage:Nt,mcpPanelMode:$e,mcpState:$,mcpConfigPath:Fl,mcpConfigError:Ol,mcpConfigSuccess:Wl,mcpConfigBusy:Hl,mcpHttpName:Dl,mcpHttpUrl:Bl,mcpRawBlock:Gl,capabilities:{hostConfigFiles:je.hostConfigFiles,hookTrust:je.hookTrust,mcpConfigEditing:je.mcpConfigEditing,planMode:je.planMode,sandboxMode:m?!1:je.sandboxMode},shellControlState:C,onToggleView:Re,onDismissPromptFocus:zt,onSetOpenMenu:ae,onToolboxItemClick:ni,onSetSlashPanelView:ke,onOpenForkTurns:()=>le==null?void 0:le(),onForkLatest:We,onForkTurn:Oe,onCopySkillInvokeName:Jl,onResetHookForm:El,onSetHooksPanelMode:ht,onClearHookConfigStatus:da,onSetEditingHookTarget:sr,onSetHookScope:or,onSetHookEventName:ut,onSetHookMatcher:Nl,onSetHookCommand:Cl,onSetHookTimeoutSec:Sl,onSetHookStatusMessage:Tl,onSaveHook:Pl,onStartEditingHook:Ll,onTrustHook:Il,onUntrustHook:zl,onSetMcpPanelMode:Me,onClearMcpConfigStatus:ha,onSetMcpHttpName:Ul,onSetMcpHttpUrl:Vl,onSetMcpRawBlock:Kl,onPrepareRawMcpBlock:ql,onSaveHttpMcp:Xl,onSaveRawMcpBlock:Yl,onPickPhoto:()=>pa("photo",we),onPickFile:()=>pa("file",P),onUpdateSettings:ne=>void te(ne),onPasteShell:()=>void si(),onCopyShell:()=>{zt(),ae(null),ie==null||ie()},onClearShell:()=>{zt(),ae(null),oe({prompt:"clear"})},onShellControl:ne=>{zt(),ae(null),ye==null||ye(ne)}}),{promptSlot:Mi,goalSlot:$i,shellPromptSlot:Di}=_m({isShellView:Se,promptRef:de,prompt:_e,disabled:k,promptPlaceholder:pi,canInterrupt:Te,interruptLabel:fi,composerPromptRegionClassName:Ii,graphChatInputClassName:Ai,promptInputClassName:zi,goalComposeMode:lr,goalTokenBudget:Rl,goalLocalError:Al,goalBusy:an,busy:n,sendButtonLabel:ga,sendButtonClassName:xa,onInterrupt:A,onPromptInput:li,onPromptPaste:ii,onPromptKeyDown:mi,onPromptKeyUp:()=>{ge.current=Ut()},onPromptMouseUp:()=>{ge.current=Ut()},onPromptBlur:()=>{ge.current=Ut(),tt(!1),dt&&U()},onPromptDragEnter:di,onPromptDragOver:ci,onPromptDragLeave:hi,onPromptDrop:ui,onGoalTokenBudgetChange:_l,onCancelGoal:ca,onShellPromptChange:Ql});return t.jsx(sm,{activeView:e,layerClassName:vi,formClassName:ki,shellClassName:wi,inputGroupClassName:Ri,error:s,followTail:j,photoInputRef:we,fileInputRef:P,onAppendAttachments:ln,onToggleFollow:he,onSubmit:oi,formRef:F,promptSlot:Mi,toolbarSlot:t.jsx(fm,{..._i}),goalSlot:$i,shellPromptSlot:Di})}var Dm=c.createContext(null);function rl(){return c.useContext(Dm)}function gt(e){return e?new Date(e).toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",second:"2-digit"}):"Time unavailable"}function Ft(e){return e?new Date(e).toLocaleString():"Time unavailable"}function Bm(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 Gm(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 nl(e){switch(e){case"sending":return"Sending";case"completed":return"Completed";case"interrupted":return"Interrupted";case"failed":return"Failed";case"inProgress":return"Running"}}function Fm({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 Vr.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 Hm({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 Om({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 Wm({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 Um({children:e,collapsed:r,mobileOpen:n}){return t.jsx("aside",{className:`thread-graph-rooms-surface thread-rooms-rail fixed inset-y-0 left-0 z-50 flex min-h-0 min-w-0 w-[min(20rem,calc(100vw-2rem))] flex-col overflow-x-hidden border-r border-slate-200/80 bg-white shadow-[0_20px_50px_rgba(15,23,42,0.18)] transition-transform duration-200 ease-out sm:static sm:z-auto sm:w-auto sm:translate-x-0 sm:rounded-[12px] sm:border sm:shadow-[0_10px_30px_rgba(15,23,42,0.04)] ${n?"translate-x-0":"pointer-events-none -translate-x-full sm:pointer-events-auto"} ${r?"thread-ui-rail-collapsed sm:items-center":""}`,style:{paddingTop:"var(--android-safe-area-top, 0px)"},children:e})}function Vm({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 Km({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 qm({children:e}){return t.jsx("div",{className:"thread-split-region min-h-0 flex-1 overflow-hidden p-0 sm:p-2",children:e})}No();It();function ss({...e}){return t.jsx(Ui,{"data-slot":"dialog",...e})}function os({...e}){return t.jsx(Vi,{"data-slot":"dialog-trigger",...e})}function Xm({...e}){return t.jsx(Zi,{"data-slot":"dialog-portal",...e})}function Ym({className:e,...r}){return t.jsx(Ji,{"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 ls({children:e,className:r,showCloseButton:n=!0,...a}){return t.jsxs(Xm,{"data-slot":"dialog-portal",children:[t.jsx(Ym,{}),t.jsxs(Ki,{"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(qi,{"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(M.XIcon,{}),t.jsx("span",{className:"sr-only",children:"Close"})]}):null]})]})}function is({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 ds({className:e,...r}){return t.jsx(Xi,{"data-slot":"dialog-title",className:Qe("text-lg font-semibold leading-none",e),...r})}function cs({className:e,...r}){return t.jsx(Yi,{"data-slot":"dialog-description",className:Qe("text-sm text-muted-foreground",e),...r})}var Zm=[{value:"system",label:"Follow system",icon:M.Monitor},{value:"dark",label:"Dark",icon:M.Moon},{value:"light",label:"Light",icon:M.Sun}];function Jm({thread:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,showDeleteButton:h=!1,showSessionCopyButton:u=!1,collapsed:m=!1}){const[f,p]=c.useState("idle"),g=c.useRef(null),v=a[e.workspaceId],b=v&&!n?v:null,x=r===e.id;c.useEffect(()=>()=>{g.current!==null&&window.clearTimeout(g.current)},[]);async function j(){const C=e.providerSessionId;if(C)try{await navigator.clipboard.writeText(C),p("copied"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1200)}catch{p("failed"),g.current!==null&&window.clearTimeout(g.current),g.current=window.setTimeout(()=>p("idle"),1600)}}const y=()=>o(e.id),w=`thread-graph-room-card group flex w-full items-center gap-3 rounded-xl border text-left transition ${x?"is-active":""} ${m?"justify-center px-2 py-2":"px-3 py-2.5"}`,k=t.jsxs(t.Fragment,{children:[t.jsx("div",{className:`thread-graph-room-card-icon flex h-8 w-8 shrink-0 items-center justify-center rounded-full ${x?"is-active":""}`,children:t.jsx(M.MessageSquare,{className:"h-4 w-4"})}),t.jsxs("div",{className:`min-w-0 flex-1 ${m?"thread-desktop-collapsed-hidden":""}`,children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[t.jsx("p",{className:"thread-graph-room-card-title min-w-0 flex-1 truncate text-sm font-medium",title:e.title,children:e.title}),i&&!m?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),C.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(M.Pencil,{className:"h-3 w-3"})}):null,u&&e.providerSessionId?t.jsx("button",{type:"button","aria-label":"Copy session ID",title:f==="copied"?"Copied":f==="failed"?"Copy failed":"Copy session ID",onClick:C=>{C.stopPropagation(),C.preventDefault(),j()},className:"thread-card-quiet-button thread-card-session-copy-button inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-full transition",children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2",children:[b?t.jsx("p",{className:"thread-graph-room-card-meta min-w-0 flex-1 truncate text-[11px] text-[var(--theme-fg-muted)]",title:b,children:b}):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 ${Gm(e.status)}`,children:Bm(e.status)}),t.jsx("time",{className:"shrink-0 text-[11px] text-[var(--theme-fg-muted)]",dateTime:e.lastTurnStartedAt??e.updatedAt,children:gt(e.lastTurnStartedAt??e.updatedAt)})]})]}),h&&d&&!m?t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),C.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(M.Trash2,{className:"h-3.5 w-3.5"})}):null]}),N=s==null?void 0:s(e.id);return l?t.jsx(t.Fragment,{children:l({thread:e,children:k,className:w,onClick:y})}):N?t.jsx("a",{href:N,onClick:C=>{C.preventDefault(),y()},title:m?e.title:void 0,className:w,children:k}):t.jsx("div",{role:"link",tabIndex:0,onClick:y,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),y())},title:m?e.title:void 0,className:w,children:k})}function Qm({threads:e,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a={},onOpenThread:o,getThreadHref:s,renderThreadLink:l,onBeginRenameThread:i,onDeleteThread:d,scrollable:h=!1,maxHeightClassName:u="max-h-full",showDeleteButton:m=!1,showSessionCopyButton:f=!1,collapsed:p=!1}){const g=h?`min-h-0 min-w-0 overflow-x-hidden overflow-y-auto overscroll-contain pr-1 ${u}`:"";return t.jsx("div",{className:g,children:t.jsx("div",{className:"min-w-0 space-y-1",children:e.map(v=>t.jsx(Jm,{thread:v,currentThreadId:r,currentWorkspaceId:n,workspaceLabels:a,onOpenThread:o,showDeleteButton:m,showSessionCopyButton:f,collapsed:p,...s?{getThreadHref:s}:{},...l?{renderThreadLink:l}:{},...i?{onBeginRenameThread:i}:{},...d?{onDeleteThread:d}:{}},v.id))})})}function ep({threads:e,status:r,loading:n=!1,error:a,viewportConstrained:o=!1,layoutMode:s="responsive",effectiveTheme:l,themeMode:i,onThemeModeChange:d,showMobileNewThreadShortcut:h=!0,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,currentThreadId:p,currentThreadLabel:g=null,currentWorkspaceId:v=null,currentWorkspaceLabel:b=null,sessionLabel:x=null,usageLabel:j=null,threadActionsButton:y,topbarActions:w,metaContent:k,settingsContent:N,globalSettingsContent:C,workspaceLabels:E={},workspaceReturnHref:z,onWorkspaceReturn:q,getThreadHref:D,onOpenThread:$,getNewThreadHref:Q,newThreadHref:Z,newThreadLabel:B="New Chat",onNewThread:ee,onNewThreadTitle:oe,renderNewThreadDialogContent:A,renderThreadLink:J,onCloseAppNavigation:R,onRenameThread:Y,onDeleteThread:H,workspaceContent:T,workspaceTitle:O="Workspace",workspaceActions:G,children:L}){const S=rl(),V=typeof window<"u"?window.matchMedia("(max-width: 639px)").matches:s==="mobile",[K,le]=c.useState(()=>typeof window<"u"?window.matchMedia("(prefers-color-scheme: dark)").matches:!1),X=i??(S==null?void 0:S.themeMode)??"system",ce=l??(S==null?void 0:S.effectiveTheme)??(X==="system"?K?"dark":"light":X),[re,fe]=c.useState(!1),[he,ve]=c.useState(!1),[Re,ie]=c.useState(!V),[ye,Te]=c.useState(V),[W,ae]=c.useState("chat"),[xe,ke]=c.useState(null),[$e,Me]=c.useState(""),[je,De]=c.useState(null),[F,de]=c.useState(!1),[we,P]=c.useState(""),[_,se]=c.useState(!1),[ge,Ne]=c.useState(!1),[Ae,Se]=c.useState("session");c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(max-width: 639px)"),Ie=()=>{Te(be.matches)};return Ie(),be.addEventListener("change",Ie),()=>{be.removeEventListener("change",Ie)}},[]),c.useEffect(()=>{if(typeof window>"u")return;const be=window.matchMedia("(prefers-color-scheme: dark)"),Ie=()=>{le(be.matches)};return Ie(),be.addEventListener("change",Ie),()=>{be.removeEventListener("change",Ie)}},[]);const Be=c.useMemo(()=>[...v?e.filter(Ie=>Ie.workspaceId===v):e].sort((Ie,ot)=>{if(Ie.id===p)return-1;if(ot.id===p)return 1;const Je=Date.parse(Ie.lastTurnStartedAt??Ie.updatedAt);return Date.parse(ot.lastTurnStartedAt??ot.updatedAt)-Je}),[p,v,e]),Ue=Z??(Q==null?void 0:Q(v)),at=b??v??"all",et=x??g??p??"default_session",tt=j??(r!=null&&r.state?`runtime ${r.state}`:"waiting for agent usage"),rt=d??(S==null?void 0:S.setThemeMode),it=!!rt,_e=()=>{fe(!1),R==null||R()};async function Fe(be){if(!Y)return;const Ie=$e.trim();if(Ie){De(be);try{await Y(be,Ie),ke(null),Me("")}finally{De(null)}}}function dt(be){ke(be.id),Me(be.title)}function I(){ke(null),Me("")}function U(be){$==null||$(be),_e()}function pe(){de(!1),P("")}function Pe(be){if(!Ue||!be.trim())return Ue;try{const Ie=new URL(Ue,window.location.origin);return Ie.searchParams.set("title",be.trim()),`${Ie.pathname}${Ie.search}${Ie.hash}`}catch{const Ie=Ue.includes("?")?"&":"?";return`${Ue}${Ie}title=${encodeURIComponent(be.trim())}`}}async function te(){const be=we.trim();se(!0);try{if(be&&oe){await oe(be),P(""),de(!1),_e();return}if(Ue){window.location.assign(Pe(be)??Ue);return}await(ee==null?void 0:ee()),P(""),de(!1),_e()}finally{se(!1)}}function He(be,Ie=!1){const ot=Ie?t.jsxs(t.Fragment,{children:[t.jsx(M.Plus,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:B})]}):t.jsxs(t.Fragment,{children:[t.jsx(M.Plus,{className:"h-4 w-4"}),t.jsx("span",{children:B})]});return t.jsxs(ss,{open:F,onOpenChange:Je=>{_||de(Je)},children:[t.jsx(os,{asChild:!0,children:t.jsx("button",{type:"button","aria-label":Ie?B:void 0,title:B,className:be,children:ot})}),t.jsx(ls,{"data-testid":"create-thread-dialog","data-theme-effective":ce,"data-theme-mode":X,className:"thread-graph-create-thread-dialog thread-graph-dialog max-h-[min(86vh,42rem)] overflow-hidden p-4 sm:max-w-[34rem]",children:A?A({close:pe,closeNavigation:_e,currentWorkspaceId:v}):t.jsxs(t.Fragment,{children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Create New Chat"}),t.jsx(cs,{children:"Name the room so it is easy to find later."})]}),t.jsxs("div",{className:"grid gap-3",children:[t.jsx("input",{id:"thread-graph-create-thread-title",name:"thread-title",value:we,onChange:Je=>P(Je.target.value),onKeyDown:Je=>{Je.key==="Enter"&&(Je.preventDefault(),te())},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 te(),disabled:_,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:_?"Creating...":"Create"})]})]})})]})}function We(){if(!N&&!k&&!C&&!it)return null;const be=!!(N||k),Ie=!!C,ot=be&&Ie,Je=Ae==="global"&&Ie||!be&&Ie?"global":"session";return t.jsxs(ss,{...u!==void 0?{open:u}:{},...m?{onOpenChange:m}:{},children:[t.jsx(os,{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(M.Settings,{className:"h-4 w-4"})})}),t.jsxs(ls,{"data-testid":"settings-dialog","data-theme-effective":ce,"data-theme-mode":X,className:"thread-graph-settings-dialog thread-graph-dialog",children:[t.jsxs(is,{children:[t.jsx(ds,{children:"Settings"}),t.jsx(cs,{children:"Manage this session and host-wide preferences."})]}),it?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: ",ce]})]}),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:Zm.map(ht=>{const sr=ht.icon,or=X===ht.value;return t.jsxs("button",{type:"button","data-testid":`theme-mode-${ht.value}`,"aria-pressed":or,disabled:!it,onClick:()=>rt==null?void 0:rt(ht.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 ${or?"is-selected":""}`,children:[t.jsx(sr,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:ht.label})]},ht.value)})})]})}):null,ot?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":Je==="session",onClick:()=>Se("session"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Je==="session"?"is-active":""}`,children:"Session"}),t.jsx("button",{type:"button","aria-pressed":Je==="global",onClick:()=>Se("global"),className:`thread-graph-settings-tab-button rounded-md px-3 py-2 text-sm font-medium transition ${Je==="global"?"is-active":""}`,children:"Global"})]}):null,t.jsx("div",{className:"thread-graph-settings-body mt-4 min-h-0 overflow-y-auto pr-1 text-sm",children:Je==="session"?t.jsxs("div",{className:"grid gap-4",children:[N?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:N}):null,k?t.jsx("div",{className:"thread-graph-settings-card rounded-lg border p-3",children:k}):null,be?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:C})})]})]})}function Oe(be=!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)] ${be?"justify-center":""}`,children:[t.jsx(M.Rows3,{className:"h-3.5 w-3.5"}),t.jsx("span",{className:be?"sr-only":"",children:"Rooms"}),!be&&n?t.jsx("span",{className:"ml-auto text-xs text-[var(--theme-fg-muted)]",children:"Refreshing..."}):null]}),t.jsxs("div",{className:"min-h-0 min-w-0 flex-1 overflow-x-hidden overflow-y-auto px-1",children:[a?t.jsx("div",{className:"rounded-xl border border-rose-500/30 bg-rose-500/10 px-3 py-3 text-sm text-rose-900 dark:text-rose-100",children:a}):null,!a&&Be.length===0&&!n?t.jsx("div",{className:"rounded-xl border border-dashed border-[var(--theme-border)] bg-[var(--theme-surface)] px-4 py-6 text-sm text-[var(--theme-fg-muted)]",children:"No threads available in this view."}):null,Be.length>0?t.jsx(Qm,{threads:Be,currentThreadId:p,currentWorkspaceId:v,workspaceLabels:E,onOpenThread:U,collapsed:be,...Y?{onBeginRenameThread:dt}:{},showDeleteButton:!!H,...D?{getThreadHref:D}:{},...J?{renderThreadLink:J}:{},...H?{onDeleteThread:H}:{}}):null]})]})})}function qe(){return T?t.jsxs("div",{className:"thread-workspace-panel relative flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsx("button",{type:"button",onClick:()=>ie(!0),className:"thread-workspace-collapse-tab thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(M.ChevronsRight,{className:"h-4 w-4"})}),G?t.jsx("div",{className:"pointer-events-none absolute right-12 top-2 z-20 flex items-center gap-1",children:t.jsx("div",{className:"pointer-events-auto",children:G})}):null,t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T})]}):t.jsxs("div",{className:"thread-workspace-panel flex h-full min-h-0 flex-col overflow-hidden rounded-[12px] border",children:[t.jsxs("div",{className:"thread-workspace-panel-header flex h-12 shrink-0 items-center justify-between gap-3 border-b border-[var(--theme-border)] px-3 sm:h-[60px] sm:px-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate text-base font-semibold text-[var(--theme-fg)] sm:text-[18px]",children:O}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:b??v??"Current context"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[G,t.jsx("button",{type:"button",onClick:()=>ie(!0),className:"thread-workspace-small-toggle thread-desktop-only-inline-flex",title:"Collapse workspace","aria-label":"Collapse workspace",children:t.jsx(M.ChevronsRight,{className:"h-4 w-4"})})]})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:T??t.jsxs("div",{className:"grid h-full min-h-0 gap-3 overflow-y-auto p-3 text-sm text-[var(--theme-fg-soft)]",children:[t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Runtime"}),t.jsx("p",{className:"mt-2 text-[var(--theme-fg)]",children:(r==null?void 0:r.state)??"unknown"})]}),t.jsxs("div",{className:"thread-workspace-card rounded-lg border p-3",children:[t.jsx("p",{className:"text-xs font-medium uppercase tracking-[0.14em] text-[var(--theme-fg-muted)]",children:"Workspace"}),t.jsx("p",{className:"mt-2 break-words text-[var(--theme-fg)]",children:b??v??"All threads"})]})]})})]})}const ct=!!T,bt=s==="mobile"||s==="responsive"&&ye,st=bt,yt=st&&!re,Nt=!!(z||q)?t.jsx("a",{href:z??"#",onClick:be=>{q&&(be.preventDefault(),q())},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(M.ArrowLeft,{className:"h-4 w-4"})}):null;return t.jsxs(t.Fragment,{children:[t.jsx(Hm,{effectiveTheme:ce,layoutMode:s,themeMode:X,viewportConstrained:o,children:t.jsxs(Om,{roomsRailCollapsed:he,children:[t.jsx(Wm,{open:re,onClose:()=>fe(!1)}),t.jsxs(Um,{collapsed:he,mobileOpen:re,children:[t.jsx("div",{className:`thread-rooms-rail-header flex h-[calc(3rem+env(safe-area-inset-top))] shrink-0 items-end border-b border-[var(--theme-border)] px-4 pb-2 sm:h-16 sm:items-center sm:pb-0 ${he?"sm:w-full sm:justify-center sm:px-2":""}`,children:t.jsxs("div",{className:`flex w-full items-center gap-3 ${he?"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:()=>ve(be=>!be),className:"thread-icon-button thread-desktop-only-flex h-9 w-9 shrink-0 items-center justify-center rounded-full",title:he?"Expand rooms":"Collapse rooms","aria-label":he?"Expand rooms":"Collapse rooms",children:he?t.jsx(M.PanelLeftOpen,{className:"h-4 w-4"}):t.jsx(M.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)] ${he?"thread-desktop-collapsed-hidden":""}`,children:(b??"R").charAt(0).toUpperCase()}),t.jsxs("div",{className:`min-w-0 ${he?"thread-desktop-collapsed-hidden":""}`,children:[t.jsx("p",{className:"truncate text-sm font-semibold text-[var(--theme-fg)]",children:b??"Remote Codex"}),t.jsx("p",{className:"truncate text-xs text-[var(--theme-fg-muted)]",children:v??"Thread workspace"})]})]}),t.jsxs("div",{className:`flex shrink-0 items-center gap-1 ${he?"thread-desktop-collapsed-hidden":""}`,children:[We(),Nt,t.jsx("button",{type:"button",onClick:()=>fe(!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(M.X,{className:"h-4 w-4"})})]})]})}),t.jsx("div",{className:`thread-graph-new-room-strip flex shrink-0 items-center border-b ${he?"h-12 w-full justify-center px-2 sm:h-12":"h-[68px] px-4"}`,children:He(`thread-graph-new-room-button inline-flex items-center justify-center rounded-xl font-medium transition ${he?"h-9 w-9 p-0":"h-11 w-full gap-2 px-3 text-sm sm:h-9"}`,he)}),t.jsx("div",{className:`flex min-h-0 flex-1 flex-col ${he?"w-full px-2 py-2":"px-3 py-3"}`,children:Oe(he)})]}),t.jsxs(Vm,{children:[t.jsx(Km,{children:t.jsx("div",{className:"thread-topbar-row flex min-h-12 items-center px-3 py-1.5 sm:min-h-12 sm:px-4",children:t.jsxs("div",{className:"flex w-full items-center justify-between gap-3 sm:gap-4",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[yt?t.jsx("button",{type:"button",onClick:()=>fe(!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(M.Menu,{className:"h-4 w-4"})}):null,t.jsxs("div",{className:"min-w-0",children:[st?t.jsx("h1",{className:"thread-mobile-only-block min-w-0 truncate text-sm font-semibold leading-none text-[var(--theme-fg)]",children:g??"Shared Workspace"}):null,t.jsxs("div",{className:"relative flex min-w-0 items-center gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{Ne(be=>!be)},"aria-expanded":ge,"aria-haspopup":"dialog",className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-1 text-left text-[11px] leading-none sm:text-xs",title:"Session and usage",children:[t.jsx("span",{className:"shrink-0",children:"Room"}),t.jsx("span",{className:"truncate font-mono",children:at})]}),ge?t.jsxs("div",{className:"thread-topbar-details-popover absolute left-0 top-[calc(100%+0.5rem)] z-50 w-[min(28rem,calc(100vw-1.5rem))] rounded-lg border p-2.5 shadow-lg",role:"dialog","aria-label":"Session and usage",children:[t.jsxs("button",{type:"button",onClick:()=>{var be;et&&((be=navigator.clipboard)==null||be.writeText(et))},className:"thread-topbar-meta-row flex min-w-0 max-w-full items-center gap-2 text-left text-xs leading-5",title:"Copy session ID",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Session"}),t.jsx("span",{className:"truncate font-mono",children:et})]}),t.jsxs("div",{className:"thread-topbar-meta-row mt-1 flex min-w-0 max-w-full items-center gap-2 text-xs leading-5",title:"Session token usage and estimated cost",children:[t.jsx("span",{className:"w-14 shrink-0",children:"Usage"}),t.jsx("span",{className:"truncate font-mono",children:tt})]})]}):null]})]})]}),t.jsxs("div",{className:"relative z-[1] inline-flex shrink-0 items-center gap-2",children:[y||w?t.jsxs("div",{className:"thread-graph-topbar-actions thread-desktop-only-inline-flex items-center rounded-lg border p-0.5 shadow-none",children:[y,w]}):null,st&&y?t.jsx("div",{className:"thread-mobile-only-inline-flex",children:y}):null,st&&ct?t.jsx("button",{type:"button",onClick:()=>ae(be=>be==="workspace"?"chat":"workspace"),"aria-label":W==="workspace"?"Show chat":"Show workspace",title:W==="workspace"?"Show chat":"Show workspace",className:"thread-icon-button thread-mobile-only-inline-flex h-10 w-10 items-center justify-center rounded-full",children:W==="workspace"?t.jsx(M.MessageSquare,{className:"h-4 w-4"}):t.jsx(M.Folder,{className:"h-4 w-4"})}):null,st?f:null,st&&h?He("thread-secondary-action inline-flex h-10 items-center justify-center gap-2 rounded-lg border px-3 text-sm font-medium sm:h-9"):null]})]})})}),t.jsx(qm,{children:ct&&!Re?bt?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 ${W==="chat"?"block":"thread-mobile-chat-hidden"}`,children:L}),t.jsx("div",{className:`h-full min-h-0 overflow-hidden ${W==="workspace"?"block":"thread-mobile-workspace-hidden"}`,children:qe()})]}):t.jsxs(En,{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(er,{defaultSize:47,minSize:30,maxSize:75,className:"thread-split-chat-pane min-w-0 overflow-hidden",children:L}),t.jsx(Ln,{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(er,{defaultSize:53,minSize:30,maxSize:70,className:"thread-split-workspace-pane min-w-0 overflow-hidden",children:qe()})]}):t.jsxs("div",{className:"thread-split-container relative h-full min-h-0 overflow-hidden",children:[ct&&Re?t.jsx("button",{type:"button",onClick:()=>ie(!1),className:"thread-workspace-expand-fab thread-desktop-only-inline-flex",title:"Expand workspace","aria-label":"Expand workspace",children:t.jsx(M.ChevronsLeft,{className:"h-4 w-4"})}):null,L]})})]})]})}),t.jsx(Fm,{open:xe!==null,title:"Rename Thread",label:"Thread Title",value:$e,busy:je!==null,onChange:Me,onCancel:I,onSubmit:()=>xe?Fe(xe):void 0})]})}function tp({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?Vr.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 rp=[/^(?: {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],np=/^(?:\|?[^|\n]+\|[^|\n]+(?:\|[^|\n]+)*\|?\s*\n\|?\s*:?-{3,}:?\s*(?:\|\s*:?-{3,}:?\s*)+\|?\s*$)/m,ap=/!?\[[^\]\n]+\]\([^)]+\)/,sp=/`[^`\n]+`/,op=/(?:\*\*[^*\n]+\*\*|__[^_\n]+__)/,lp=/(^|[^\w])(?:\*[^*\n]+\*|_[^_\n]+_)(?=[^\w]|$)/,ip=/~~[^~\n]+~~/;function dp(e){const r=e.trim();return r?rp.some(n=>n.test(r))||np.test(r)?!0:/[`[\]*_~!]/.test(r)?ap.test(r)||sp.test(r)||op.test(r)||lp.test(r)||ip.test(r):!1:!1}Jr();function Gn(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 ra(e=[]){const r=Gn(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 na=c.createContext(ra());function aa(){return c.useContext(na)??ra()}Cr();function al(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hs(e){return al(e)?Object.entries(e):e==null||e===""?[]:[["value",e]]}function sl(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 cp(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)}):sl(r)}function us({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(M.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"};case"failed":return{className:"is-failed",icon:t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"};default:return{className:"is-pending",icon:t.jsx(M.Loader2,{className:"h-3.5 w-3.5 animate-spin"}),label:"Running"}}},[n]),l=c.useMemo(()=>hs(o),[o]),i=c.useMemo(()=>hs(a),[a]),d=c.useMemo(()=>typeof o=="string"?o.length>0:al(o)?["stdout","stderr","result"].some(f=>{const p=o[f];return typeof p=="string"&&p.length>0}):!1,[o]),h=n==="pending"||d,[u,m]=c.useState(h?"item-1":void 0);return c.useEffect(()=>{h&&m("item-1")},[e,h]),t.jsx("div",{className:"thread-graph-tool-call my-2 w-full font-sans not-prose",children:t.jsx(yr,{type:"single",collapsible:!0,onValueChange:f=>m(f||void 0),className:"thread-graph-tool-accordion w-full overflow-hidden rounded-lg border",...u!==void 0?{value:u}:{},children:t.jsxs(jr,{value:"item-1",className:"border-0",children:[t.jsx(Qr,{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(M.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(Nr,{className:"thread-graph-tool-content px-4 pb-4 pt-1",children:[t.jsxs("section",{children:[t.jsx("h4",{children:"Parameters"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),i.length>0?i.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),sl(p),g<i.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)):t.jsx("div",{children:t.jsx("span",{className:"thread-graph-tool-null",children:"empty"})}),"}"]})]}),l.length>0?t.jsxs("section",{children:[t.jsx("h4",{children:"Result"}),t.jsxs("div",{className:"thread-graph-tool-json",children:["{",t.jsx("br",{}),l.map(([f,p],g)=>t.jsxs("div",{children:[t.jsxs("span",{className:"thread-graph-tool-key",children:['"',f,'"']}),t.jsx("span",{className:"thread-graph-tool-punctuation",children:": "}),cp(f,p),g<l.length-1?t.jsx("span",{className:"thread-graph-tool-punctuation",children:","}):null]},f)),"}"]})]}):null]})]})})})}var ms=null;function hp(){return ms??(ms=Promise.all([Ke(()=>import("./core-DODVy7wn.js"),__vite__mapDeps([0,1,2])),Ke(()=>import("./engine-javascript-DBd1bXLz.js"),[]),Ke(()=>import("./ayu-light-BA47KaF1.js"),[]),Ke(()=>import("./ayu-dark-DYE7WIF3.js"),[]),Ke(()=>import("./javascript-wDzz0qaB.js"),[]),Ke(()=>import("./typescript-BPQ3VLAy.js"),[]),Ke(()=>import("./tsx-COt5Ahok.js"),[]),Ke(()=>import("./jsx-g9-lgVsj.js"),[]),Ke(()=>import("./python-B6aJPvgy.js"),[]),Ke(()=>import("./json-Cp-IABpG.js"),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.b),[]),Ke(()=>import("./shellscript-CEILq0vU.js").then(e=>e.s),[]),Ke(()=>import("./yaml-Buea-lGh.js"),[]),Ke(()=>import("./toml-vGWfd6FD.js"),[]),Ke(()=>import("./markdown-Cvjx9yec.js"),[]),Ke(()=>import("./html-pp8916En.js"),__vite__mapDeps([3,4,5])),Ke(()=>import("./css-CLj8gQPS.js"),[]),Ke(()=>import("./sql-CRqJ_cUM.js"),[]),Ke(()=>import("./csv-fuZLfV_i.js"),[])]).then(([{createHighlighterCore:e},{createJavaScriptRegexEngine:r},n,a,o,s,l,i,d,h,u,m,f,p,g,v,b,x,j])=>e({engine:r(),themes:[n.default,a.default],langs:[o.default,s.default,l.default,i.default,d.default,h.default,u.default,m.default,f.default,p.default,g.default,v.default,b.default,x.default,j.default]}))),ms}function en(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Fn(e){if(!e)return{};if(en(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 Hn(){return{finalResult:null,stdout:"",stderr:""}}function up(e){return typeof e=="string"?{result:e}:e}function ol(e){const r=en(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 ps(e){if(!e)return"pending";if(!en(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 mp(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=up(d.result),m=r.get(h)??Hn();return en(u)&&u.status==="stream"&&typeof u.chunk=="string"?u.stream==="stderr"?m.stderr+=u.chunk:m.stdout+=u.chunk:m.finalResult=u,r.set(h,m),""}catch{return l}}),o=/```tool-call\s*([\s\S]*?)\s*```/g;return{processedContent:a.replace(o,(l,i)=>{try{const d=JSON.parse(i),h=d.call_id,u=d.tool;if(typeof u!="string")return l;const m=Fn(d.args);if(typeof h=="string"&&r.has(h)){const f=ol(r.get(h)??Hn());return`\`\`\`tool-merged
|
|
3657
3657
|
${JSON.stringify({call:{tool:u,args:m,call_id:h},result:f},null,2)}
|
|
3658
|
-
\`\`\``}return l}catch{return l}}),resultMap:r}}var
|
|
3659
|
-
`)||E!==
|
|
3658
|
+
\`\`\``}return l}catch{return l}}),resultMap:r}}var pp=["/api/","/assets/","/control-plane","/devices/","/relay/","/relay-account","/relay-admin","/relay-devices","/relay-portal","/threads","/workspaces"];function fs(e){return e.replace(/background-color:[^;"]+;?/g,"background-color: transparent;").replace(/background:[^;"]+;?/g,"background: transparent;")}function gs(e){return Array.isArray(e)?e.map(r=>String(r)).join(""):String(e??"")}function fp(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 gp(e){if(!e)return null;let r=e.trim();if(!r)return null;try{if(typeof window>"u")return null;const s=new URL(r,window.location.origin);if(s.origin!==window.location.origin&&s.protocol!=="file:")return null;r=(s.protocol==="file:",s.pathname)}catch{}try{r=decodeURIComponent(r)}catch{}if(!r.startsWith("/")||pp.some(s=>r===s||r.startsWith(s)))return null;const n=r.match(/:(\d+)(?::\d+)?$/),a=n?Number.parseInt(n[1]??"",10):void 0,o=n?r.slice(0,-n[0].length):r;return!o||o==="/"?null:{path:o,...Number.isFinite(a)?{line:a}:{}}}function xp({children:e,...r}){return bp(e)?t.jsx(t.Fragment,{children:e}):t.jsx("pre",{...r,children:e})}function bp(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 vp=c.memo(function({className:r="thread-graph-markdown",content:n,onOpenWorkspaceFile:a}){const o=c.useRef(null),s=aa(),[l,i]=c.useState(null),[d,h]=c.useState({}),[u,m]=c.useState(!1),{processedContent:f,resultMap:p}=c.useMemo(()=>mp(n),[n]);c.useEffect(()=>{let b=!0;return hp().then(x=>{b&&i(x)}).catch(()=>{}),()=>{b=!1}},[]),c.useEffect(()=>{const b=o.current,x=b==null?void 0:b.closest(".thread-ui-shell"),j=()=>x?x.getAttribute("data-theme-effective")==="dark"||x.classList.contains("dark")||x.classList.contains("thread-ui-theme-dark"):document.documentElement.classList.contains("dark");if(m(j()),!x)return;const y=new MutationObserver(()=>m(j()));return y.observe(x,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>y.disconnect()},[]);async function g(b,x){try{await navigator.clipboard.writeText(x),h(j=>({...j,[b]:"copied"})),window.setTimeout(()=>{h(j=>{const y={...j};return delete y[b],y})},1200)}catch{h(j=>({...j,[b]:"failed"}))}}const v=({children:b,className:x,inline:j,node:y,...w})=>{var $;const k=/language-(\w+(?:-\w+)*)/.exec(x||""),N=k?k[1]??"":"",C=gs(b).replace(/\n$/,""),{startLine:E,endLine:z}=fp(y),q=j===!1||!!x||C.includes(`
|
|
3659
|
+
`)||E!==z;if(N==="tool-merged"){let Q={call:{tool:"Unknown",args:{},call_id:void 0},result:null};try{Q=JSON.parse(C)}catch{Q={call:{tool:"Error",args:{raw:C}},result:{status:"failed"}}}const Z=typeof Q.call.tool=="string"?Q.call.tool:"Unknown",B=typeof Q.call.call_id=="string"?Q.call.call_id:void 0;return t.jsx(us,{callId:B,toolName:Z,status:ps(Q.result),parameters:Fn(Q.call.args),result:Q.result})}if(N==="tool-call"){let Q={tool:"Unknown",args:{},call_id:void 0};try{Q=JSON.parse(C)}catch{Q={tool:"Error",args:{raw:C}}}const Z=typeof Q.call_id=="string"?Q.call_id:void 0,B=Z&&p.has(Z)?ol(p.get(Z)??Hn()):void 0;return t.jsx(us,{callId:Z,toolName:typeof Q.tool=="string"?Q.tool:"Unknown",status:B?ps(B):"pending",parameters:Fn(Q.args),result:B})}if(N==="tool-result")return null;if(["xyz","extxyz","cif","pdb"].includes(N)){const Q=s.renderInlineCode({code:C,isIncomplete:!1,language:N});if(c.isValidElement(Q))return Q}if(q){const Z=((($=l==null?void 0:l.getLoadedLanguages)==null?void 0:$.call(l))??[]).includes(N)?N:"text",B=u?"ayu-dark":"ayu-light",ee=`${N||"text"}:${C.length}:${C.slice(0,32)}`;let oe="";if(l)try{oe=fs(l.codeToHtml(C,{lang:Z,theme:B}))}catch{oe=fs(l.codeToHtml(C,{lang:"text",theme:B}))}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(kr,{type:"button",onClick:()=>void g(ee,C),variant:"ghost",size:"sm",className:"thread-graph-code-copy absolute right-2 top-2 z-10 rounded-md p-1.5",title:d[ee]==="copied"?"Copied":d[ee]==="failed"?"Copy failed":"Copy","aria-label":"Copy code",children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}),oe?t.jsx("div",{dangerouslySetInnerHTML:{__html:oe}}):t.jsx("pre",{children:t.jsx("code",{className:"whitespace-pre",children:C})})]})}const D=gs(b).replace(/`+/g,"");return t.jsx("code",{className:`thread-graph-inline-code rounded px-1 py-0.5 font-mono font-normal text-[0.9em] ${x||""}`,...w,children:D})};return t.jsx("div",{ref:o,className:`thread-graph-message-markdown ${r}`,children:t.jsx(bd,{remarkPlugins:[kd,wd],rehypePlugins:[vd],components:{a({href:b,children:x,...j}){const y=gp(b);return y&&a?t.jsx("a",{...j,href:b,className:"thread-inline-link",onClick:w=>{w.preventDefault(),a(y)},children:x}):t.jsx("a",{...j,href:b,className:"thread-inline-link",children:x})},code:v,pre:xp},children:f})})}),xs=2400,kp=/\b(?:https?:\/\/|www\.)[^\s<>"'`]+/gi,wp=/[),.;:!?]+$/;function yp(e){return e.startsWith("www.")?`https://${e}`:e}function bs(e){const r=e.replace(/[\\/]+$/,"").trim();return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function jp(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 rr({text:e}){var a;const r=[];let n=0;for(const o of e.matchAll(kp)){const s=o[0],l=o.index??0,i=((a=s.match(wp))==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:yp(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 ll=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,containerClassName:o="",plainTextClassName:s="thread-graph-plain-text whitespace-pre-wrap break-words text-[15px] leading-6",markdownClassName:l="thread-graph-markdown",onBeforeResize:i,onOpenWorkspaceFile:d}){const h=c.useRef(null),u=c.useRef(null),[m,f]=c.useState(!1),p=dp(r),g=!a&&r.length>xs,v=g&&!m?`${r.slice(0,xs).trimEnd()}
|
|
3660
3660
|
|
|
3661
|
-
...`:r,[b,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,w=h.current,k=(w==null?void 0:w.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&k!==null?{root:y,top:k}:null,f(N=>!N)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,w=h.current;if(!y||!w)return;u.current=null;const k=()=>{const C=w.getBoundingClientRect().top;y.root.scrollTop+=C-y.top};k();const N=window.requestAnimationFrame(k);return()=>{window.cancelAnimationFrame(N)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(b||!h.current)return;const y=new IntersectionObserver(w=>{for(const k of w)if(k.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[b,n,a]),t.jsxs("div",{ref:h,className:o,children:[b&&p?t.jsx(
|
|
3661
|
+
...`:r,[b,x]=c.useState(a||typeof IntersectionObserver>"u"),j=c.useCallback(()=>{const y=n.current,w=h.current,k=(w==null?void 0:w.getBoundingClientRect().top)??null;i==null||i(),u.current=y&&k!==null?{root:y,top:k}:null,f(N=>!N)},[i,n]);return c.useLayoutEffect(()=>{const y=u.current,w=h.current;if(!y||!w)return;u.current=null;const k=()=>{const C=w.getBoundingClientRect().top;y.root.scrollTop+=C-y.top};k();const N=window.requestAnimationFrame(k);return()=>{window.cancelAnimationFrame(N)}},[m]),c.useEffect(()=>{if(a||typeof IntersectionObserver>"u"){x(!0);return}if(b||!h.current)return;const y=new IntersectionObserver(w=>{for(const k of w)if(k.isIntersecting){x(!0),y.disconnect();break}},{root:n.current,threshold:0});return y.observe(h.current),()=>{y.disconnect()}},[b,n,a]),t.jsxs("div",{ref:h,className:o,children:[b&&p?t.jsx(vp,{content:v,className:l,onOpenWorkspaceFile:d}):t.jsx("p",{className:s,children:t.jsx(rr,{text:v})}),g?t.jsx("button",{type:"button",onClick:j,className:"thread-graph-show-more timeline-meta-text mt-1.5 flex w-full items-center justify-center rounded-md border border-[var(--theme-border)] px-2 py-0.5 text-[10px] leading-4 transition hover:bg-[var(--theme-hover)] hover:text-[var(--theme-fg)]",children:m?"Show less":`Show more (${r.length.toLocaleString()} chars)`}):null]})}),Np=c.memo(function({text:r,scrollRootRef:n,streaming:a=!1,onBeforeResize:o,onOpenWorkspaceFile:s}){return t.jsx(ll,{text:r,scrollRootRef:n,streaming:a,containerClassName:"thread-graph-message-prose",...o?{onBeforeResize:o}:{},...s?{onOpenWorkspaceFile:s}:{}})}),Cp=c.memo(function({threadId:r,text:n,attachmentPreviewUrls:a,getImageAssetUrl:o}){const s=c.useMemo(()=>jp(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=bs(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=bs(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 Sp(){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 vs({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(M.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):a?t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}):o?t.jsx(M.CheckCircle2,{className:"h-3.5 w-3.5"}):t.jsx(M.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(Sp,{}):l}),t.jsx("span",{className:"thread-graph-status-label",children:e})]})}function Tp({children:e,copyButton:r,kind:n,metaControl:a,reasoning:o,status:s,timeLabel:l,timeTitle:i}){const d=n==="userMessage",h=l?t.jsx("span",{title:i??void 0,className:"thread-graph-message-time text-[10px] leading-none sm:text-[11px]",children:l}):null;return t.jsx("div",{"data-testid":"chat-message","data-role":d?"user":"assistant",className:"thread-graph-message flex justify-start",children:t.jsxs("div",{className:`thread-graph-message-bubble min-w-0 w-full max-w-full ${d?"is-user":"is-assistant"}`,children:[d?null:t.jsxs("div",{className:"thread-graph-message-header mb-2 flex min-w-0 items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"thread-graph-message-sender rounded-full px-2.5 py-1 text-xs font-semibold tracking-[0.02em]",children:"Assistant"}),t.jsx(vs,{status:s??"Complete"})]}),a?t.jsx("div",{className:"thread-graph-message-header-meta flex min-w-0 flex-1 justify-center",children:a}):null,r||h?t.jsxs("div",{className:"thread-graph-message-header-actions flex shrink-0 items-center gap-1.5 sm:gap-2",children:[r,h]}):null]}),o,t.jsx("div",{className:`thread-graph-message-content min-w-0 ${d?"is-user":"is-assistant"}`,children:e}),d&&(s||h)?t.jsxs("div",{className:"mt-1 flex items-center justify-end gap-2",children:[s?t.jsx(vs,{status:s}):null,h]}):null]})})}Cr();function Ep(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function Lp({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 Lt=c.memo(function({threadId:r,item:n,scrollRootRef:a,streaming:o=!1,adapter:s,timeLabel:l,timeTitle:i,onBeforeMessageResize:d}){const[h,u]=c.useState("idle"),[m,f]=c.useState(!1),p=c.useRef(null),g=n.kind==="agentMessage"?n.reasoningItems??[]:[],v=g.map(C=>C.text.trim()).filter(Boolean).join(`
|
|
3662
3662
|
|
|
3663
|
-
`),b=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(C=>!C)}const y=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null,w=g.some(C=>Tp(C.status)),k=n.kind==="agentMessage"&&v?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(M.Brain,{className:`h-3.5 w-3.5 ${w?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),w?t.jsx(Ep,{tone:"sky"}):null]}):null,N=n.kind==="agentMessage"&&v?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(wr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:C=>f(!!C),...m?{value:"thoughts"}:{},children:t.jsx(yr,{value:"thoughts",className:"border-b-0",children:t.jsx(jr,{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(tr,{text:v})})})})})}):null;return t.jsx(Sp,{kind:n.kind,status:b||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:k,reasoning:N,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(jp,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Np,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function ks(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function ll(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?ks(r[1]):null,a=ks(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 Lp(e){return e==="userMessage"||e==="agentMessage"}function Pp(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function zp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Ip(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&&Pp(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=>zp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function St(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Pr(e){return St(e)?e.sequence:Number.POSITIVE_INFINITY}function ws(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!St(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(St))return e;const o=a.map(u=>Pr(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(St(u)){l.push({item:u,index:i,order:Pr(u)}),i+=1;continue}const m=i;for(;i<a.length&&!St(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(St),g=a.slice(i).find(St),v=p?Pr(p):null,b=g?Pr(g):null;f.forEach((x,j)=>{let y;if(v===null&&b!==null)y=b-(f.length-j)/(f.length+1);else if(v!==null&&b!==null&&b>v){const w=b-v;y=v+(j+1)/(f.length+1)*w}else y=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:y})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function Rp(e,r){if(!r||r.length===0)return ws(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),o=[...n.values()];return o.length===0&&!a.some(St)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:ws(a)}function Ap(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 il(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function pr(e){return e==="inProgress"||e==="sending"}function _p(e){var a;const r=[];let n=0;for(;n<e.length;){const o=e[n];if(!o)break;if(o.kind!=="commandExecution"&&o.kind!=="fileChange"&&o.kind!=="webSearch"&&o.kind!=="fileRead"){r.push({kind:"item",key:o.id,item:o}),n+=1;continue}const s=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===o.kind;)s.push(e[n]),n+=1;if(s.length===1){r.push({kind:"item",key:s[0].id,item:s[0]});continue}const l=s.map(i=>i.id).join(":");if(o.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:s});continue}if(o.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:s});continue}if(o.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:s});continue}r.push({kind:"searchGroup",key:l,items:s})}return r}function dl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function fr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function cl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function Mp({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?fr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?fr(l,p.turnId,p):d.push(p);const h=dl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=cl(h,p.createdAt);if(!g){m.push(p);continue}fr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function $p({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=dl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?fr(i,m.anchorTurnId,m):s.push(m);continue}const f=cl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}fr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function hl({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function v(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(w=>w===u?(s[x.id]??"").trim():w.trim()).filter(Boolean);if(j===u){const w=(s[x.id]??"").trim();return w?[w]:[]}const y=j.trim();return y?[y]:[]}function b(x,j){o(y=>{const w=y[x],k=Array.isArray(w)?w:[],N=k.includes(j)?k.filter(C=>C!==j):[...k,j];return{...y,[x]:N}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,y)=>{const w=f(j.label),k=w.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[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/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?k?"Starting...":"Saving...":w.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const y=f(j.label),w=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?b(x.id,j.label):o(k=>({...k,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(w)&&w.includes(j.label):w===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?b(x.id,u):o(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:w=>l(k=>({...k,[x.id]:w.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>o(y=>({...y,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:v(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function ul({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 ml({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:Ft(e.createdAt),className:"timeline-meta-text text-[10px]",children:gt(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 dr({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(ml,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function On({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(ul,{note:a.note},a.id):t.jsx(hl,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Dp({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(On,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function Bp({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(ml,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(ul,{note:s.note},s.id):t.jsx(hl,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function Gp({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 Qr({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${o}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":s,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Nr();zt();var Fp=kr("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 en({asChild:e=!1,className:r,variant:n,...a}){const o=e?As:"span";return t.jsx(o,{"data-slot":"badge",className:Qe(Fp({variant:n,className:r})),...a})}function sa(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Hp(){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 Op(){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 Up(){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 Wp(){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 Vp(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 pl(e,r=42){const n=Vp(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),o=(a==null?void 0:a[1])??"",s=o?n.slice(0,-o.length):n;if(s.length<=r)return`${s}${o}`;const i=s.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=o.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function Kp(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 Un({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 qp(e){var n;const r=e.replace(/\r\n/g,`
|
|
3663
|
+
`),b=n.kind==="userMessage"&&(n.status==="Steering"||n.status==="Accepted"||n.status==="Awaiting response");c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current)},[]);async function x(){try{await navigator.clipboard.writeText(n.text),u("copied"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1200)}catch{u("failed"),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>u("idle"),1600)}}function j(){d==null||d(),f(C=>!C)}const y=n.kind==="agentMessage"?t.jsx("button",{type:"button","aria-label":"Copy agent reply",title:h==="copied"?"Copied":h==="failed"?"Copy failed":"Copy agent reply",onClick:()=>void x(),className:`thread-graph-message-copy inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md border transition ${h==="copied"?"ui-status-info":h==="failed"?"ui-status-danger":""}`,children:t.jsx(M.Copy,{className:"h-3.5 w-3.5"})}):null,w=g.some(C=>Ep(C.status)),k=n.kind==="agentMessage"&&v?t.jsxs("button",{type:"button","aria-label":m?"Hide chain of thought":"Show chain of thought","aria-expanded":m,title:m?"Hide CoT":"Show CoT",onClick:j,className:`thread-graph-thinking-toggle inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border px-2 text-xs font-medium transition ${m?"is-open":""}`,children:[t.jsx(M.Brain,{className:`h-3.5 w-3.5 ${w?"animate-pulse":""}`}),t.jsx("span",{children:"CoT"}),w?t.jsx(Lp,{tone:"sky"}):null]}):null,N=n.kind==="agentMessage"&&v?t.jsx("div",{className:"thread-graph-message-thinking mb-3",children:t.jsx(yr,{type:"single",collapsible:!0,className:"thread-graph-thinking-accordion w-full border-none",onValueChange:C=>f(!!C),...m?{value:"thoughts"}:{},children:t.jsx(jr,{value:"thoughts",className:"border-b-0",children:t.jsx(Nr,{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(rr,{text:v})})})})})}):null;return t.jsx(Tp,{kind:n.kind,status:b||n.kind==="agentMessage"?n.status:null,copyButton:y,metaControl:k,reasoning:N,timeLabel:l,timeTitle:i,children:n.kind==="agentMessage"?t.jsx(Np,{text:n.text,scrollRootRef:a,streaming:o,...d?{onBeforeResize:d}:{},...s!=null&&s.onOpenWorkspaceFile?{onOpenWorkspaceFile:s.onOpenWorkspaceFile}:{}}):t.jsx(Cp,{threadId:r,text:n.text,attachmentPreviewUrls:n.attachmentPreviewUrls,getImageAssetUrl:s==null?void 0:s.getImageAssetUrl})})});function ks(e){return e.replace(/"/g,'"').replace(/'/g,"'").replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function il(e){const r=e.trim().match(/^<hook_prompt(?:\s+hook_run_id="([^"]+)")?>([\s\S]*)<\/hook_prompt>$/);if(!r)return null;const n=r[1]?ks(r[1]):null,a=ks(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 Pp(e){return e==="userMessage"||e==="agentMessage"}function Ip(e){return e==="commandExecution"||e==="webSearch"||e==="fileRead"||e==="fileChange"||e==="image"||e==="contextCompaction"}function zp(e){return e==="agentMessage"||e==="reasoning"||e==="agentToolCall"||e==="skillToolCall"||e==="toolCall"||e==="plan"}function Rp(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&&Ip(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=>zp(d.kind))?s:{...s,status:"Awaiting response"}:(o=!0,s))}function St(e){return typeof e.sequence=="number"&&Number.isFinite(e.sequence)}function Ir(e){return St(e)?e.sequence:Number.POSITIVE_INFINITY}function ws(e){var h;const r=[];let n=0;for(;n<e.length&&((h=e[n])==null?void 0:h.kind)==="userMessage"&&!St(e[n]);)r.push(e[n]),n+=1;const a=e.slice(n);if(!a.some(St))return e;const o=a.map(u=>Ir(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(St(u)){l.push({item:u,index:i,order:Ir(u)}),i+=1;continue}const m=i;for(;i<a.length&&!St(a[i]);)i+=1;const f=a.slice(m,i),p=[...a.slice(0,m)].reverse().find(St),g=a.slice(i).find(St),v=p?Ir(p):null,b=g?Ir(g):null;f.forEach((x,j)=>{let y;if(v===null&&b!==null)y=b-(f.length-j)/(f.length+1);else if(v!==null&&b!==null&&b>v){const w=b-v;y=v+(j+1)/(f.length+1)*w}else y=s+1+j/(f.length+1);l.push({item:x,index:m+j,order:y})})}const d=l.sort((u,m)=>{const f=u.order-m.order;return f===0?u.index-m.index:f}).map(u=>u.item);return[...r,...d]}function Ap(e,r){if(!r||r.length===0)return ws(e);const n=new Map(r.map(s=>[s.id,s])),a=e.map(s=>{const l=n.get(s.id);if(!l)return s;n.delete(s.id);const i={...s,...l,text:l.text||s.text},d=l.detailText??s.detailText,h=l.previewText??s.previewText,u=l.status??s.status,m=l.sequence??s.sequence;return d!==void 0&&(i.detailText=d),h!==void 0&&(i.previewText=h),u!==void 0&&(i.status=u),m!==void 0&&(i.sequence=m),i}),o=[...n.values()];return o.length===0&&!a.some(St)||(a.push(...o),!a.some(s=>typeof s.sequence=="number"&&Number.isFinite(s.sequence)))?a:ws(a)}function _p(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 dl(e){if(!e)return!1;const r=e.toLowerCase();return r.includes("running")||r.includes("inprogress")||r.includes("in_progress")}function fr(e){return e==="inProgress"||e==="sending"}function Mp(e){var a;const r=[];let n=0;for(;n<e.length;){const o=e[n];if(!o)break;if(o.kind!=="commandExecution"&&o.kind!=="fileChange"&&o.kind!=="webSearch"&&o.kind!=="fileRead"){r.push({kind:"item",key:o.id,item:o}),n+=1;continue}const s=[];for(;n<e.length&&((a=e[n])==null?void 0:a.kind)===o.kind;)s.push(e[n]),n+=1;if(s.length===1){r.push({kind:"item",key:s[0].id,item:s[0]});continue}const l=s.map(i=>i.id).join(":");if(o.kind==="commandExecution"){r.push({kind:"commandGroup",key:l,items:s});continue}if(o.kind==="fileChange"){r.push({kind:"fileChangeGroup",key:l,items:s});continue}if(o.kind==="fileRead"){r.push({kind:"fileReadGroup",key:l,items:s});continue}r.push({kind:"searchGroup",key:l,items:s})}return r}function cl(e,r){return[...e.map(n=>({id:n.id,startedAt:n.startedAt??""})),...r?[{id:r.id,startedAt:r.startedAt??""}]:[]]}function gr(e,r,n){const a=e.get(r)??[];a.push(n),e.set(r,a)}function hl(e,r){return e.find(n=>r&&n.startedAt&&r.localeCompare(n.startedAt)<=0)}function $p({answeredRequestNotes:e,pendingRequests:r,visibleTurns:n,optimisticTurn:a}){const o=new Set(n.map(p=>p.id)),s=new Map,l=new Map,i=[],d=[];for(const p of e)p.turnId&&o.has(p.turnId)?gr(s,p.turnId,p):i.push(p);for(const p of r)p.turnId&&o.has(p.turnId)?gr(l,p.turnId,p):d.push(p);const h=cl(n,a),u=new Map,m=[],f=[...i.map(p=>({kind:"note",id:p.id,createdAt:p.createdAt??"",note:p})),...d.map(p=>({kind:"request",id:p.id,createdAt:p.createdAt,request:p}))].sort((p,g)=>p.createdAt.localeCompare(g.createdAt));for(const p of f){const g=hl(h,p.createdAt);if(!g){m.push(p);continue}gr(u,g.id,p)}return{notesByTurnId:s,pendingRequestsByTurnId:l,beforeTurnId:u,trailing:m}}function Dp({activityNotes:e,visibleTurns:r,optimisticTurn:n}){const a=[...e].sort((m,f)=>m.createdAt.localeCompare(f.createdAt)),o=cl(r,n),s=[],l=new Map,i=new Map,d=[],u=o.map(m=>m.startedAt).filter(m=>!!m).sort().at(-1)??null;for(const m of a){if(m.anchorTurnId==="__leading__"){s.push(m);continue}if(m.anchorTurnId){o.some(p=>p.id===m.anchorTurnId)?gr(i,m.anchorTurnId,m):s.push(m);continue}const f=hl(o,m.createdAt);if(!f){!u||m.createdAt.localeCompare(u)<=0?s.push(m):d.push(m);continue}gr(l,f.id,m)}return{leading:s,beforeTurnId:l,afterTurnId:i,trailing:d}}function ul({request:e,busy:r=!1,onRespond:n}){const[a,o]=c.useState({}),[s,l]=c.useState({}),[i,d]=c.useState(null),h=e.questions[0]??null,u="__other__",m=e.kind==="planDecision"?"Plan":e.kind==="requestUserInput"?"Answer Required":e.title;function f(x){const j=/\s*\(recommended\)\s*$/i.test(x);return{rawLabel:x,displayLabel:x.replace(/\s*\(recommended\)\s*$/i,"").trim(),recommended:j}}function p(x){h&&(d(x),n==null||n(e.id,{answers:{[h.id]:{answers:[x]}}}))}function g(x){const j=a[x.id]??"";return Array.isArray(j)?j.map(y=>y===u?(s[x.id]??"").trim():y.trim()).filter(Boolean).join(", "):j===u?(s[x.id]??"").trim():j.trim()}function v(x){const j=a[x.id]??"";if(Array.isArray(j))return j.map(w=>w===u?(s[x.id]??"").trim():w.trim()).filter(Boolean);if(j===u){const w=(s[x.id]??"").trim();return w?[w]:[]}const y=j.trim();return y?[y]:[]}function b(x,j){o(y=>{const w=y[x],k=Array.isArray(w)?w:[],N=k.includes(j)?k.filter(C=>C!==j):[...k,j];return{...y,[x]:N}})}return t.jsxs("div",{className:"timeline-pending-card w-full rounded-[1rem] border px-3 py-3 sm:rounded-[1.2rem] sm:px-4",children:[t.jsx("div",{className:"flex items-center justify-between gap-3",children:t.jsxs("div",{children:[t.jsx("p",{className:"timeline-primary-text text-sm font-medium",children:m}),e.kind!=="planDecision"&&e.description&&t.jsx("p",{className:"timeline-soft-text mt-1 text-[13px] leading-5",children:e.description})]})}),t.jsx("div",{className:"mt-3 space-y-3",children:e.questions.map(x=>t.jsxs("div",{className:"timeline-question-section rounded-xl border p-2.5 sm:p-3",children:[t.jsx("p",{className:"timeline-meta-text text-xs uppercase tracking-[0.2em]",children:x.header}),t.jsx("p",{className:"timeline-primary-text mt-1 text-[13px] leading-5 sm:text-sm",children:x.question}),e.kind==="planDecision"&&x.options&&x.options.length>0?t.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:x.options.map((j,y)=>{const w=f(j.label),k=w.displayLabel.toLowerCase()==="implement";return t.jsxs("button",{type:"button",disabled:r,onClick:()=>p(j.label),className:`relative rounded-2xl border px-2.5 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${y===0?"ui-action-info":"border-stone-700 text-stone-200 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[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/18 text-[10px] leading-none text-current",children:"✦"}):null,r&&i===j.label?k?"Starting...":"Saving...":w.displayLabel]},j.label)})}):x.options&&x.options.length>0?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[x.options.map(j=>{const y=f(j.label),w=a[x.id];return t.jsxs("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?b(x.id,j.label):o(k=>({...k,[x.id]:j.label})),className:`relative rounded-2xl border px-3 py-1.5 pr-6 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(w)&&w.includes(j.label):w===j.label)?"ui-status-warning":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,title:j.description,children:[y.recommended?t.jsx("span",{"aria-hidden":"true",className:"absolute right-1.5 top-1 inline-flex h-3.5 w-3.5 items-center justify-center rounded-full bg-white/10 text-[10px] leading-none text-amber-100/90",children:"✦"}):null,y.displayLabel]},j.label)}),x.isOther&&(()=>{const j=a[x.id];return t.jsx("button",{type:"button",disabled:r,onClick:()=>x.multiSelect?b(x.id,u):o(y=>({...y,[x.id]:u})),className:`rounded-2xl border px-3 py-1.5 text-[12px] leading-4 transition sm:text-[13px] ${(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?"ui-status-info":"border-stone-700 text-stone-300 hover:bg-stone-800"} disabled:cursor-not-allowed disabled:opacity-60`,children:"Not from above"})})()]}),x.isOther&&(()=>{const j=a[x.id];return(x.multiSelect?Array.isArray(j)&&j.includes(u):j===u)?t.jsx("input",{"aria-label":`${x.header} custom answer`,value:s[x.id]??"",onChange:w=>l(k=>({...k,[x.id]:w.target.value})),placeholder:"Enter a custom answer",className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-sky-300"}):null})()]}):t.jsx("input",{"aria-label":x.header,value:a[x.id]??"",onChange:j=>o(y=>({...y,[x.id]:j.target.value})),className:"mt-3 w-full rounded-xl border border-stone-700 bg-stone-900 px-3 py-2 text-sm text-stone-100 outline-none transition focus:border-amber-300"})]},x.id))}),e.kind!=="planDecision"&&t.jsx("div",{className:"mt-3 flex justify-end",children:t.jsx("button",{type:"button",disabled:r||e.questions.some(x=>!g(x)),onClick:()=>void(n==null?void 0:n(e.id,{answers:Object.fromEntries(e.questions.map(x=>[x.id,{answers:v(x)}]))})),className:"ui-action-info rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed",children:r?"Submitting...":"Submit"})})]})}function ml({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 pl({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:Ft(e.createdAt),className:"timeline-meta-text text-[10px]",children:gt(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 cr({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(pl,{note:a,onOpenThread:r,onOpenLinkedThread:n},a.id))})}function On({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(ml,{note:a.note},a.id):t.jsx(ul,{request:a.request,busy:r===a.request.id,onRespond:n},a.id))})}function Bp({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(On,{entries:o,respondingRequestId:n,onRespondToRequest:a})}function Gp({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(pl,{note:s.note,onOpenThread:a,onOpenLinkedThread:o},s.id):s.kind==="note"?t.jsx(ml,{note:s.note},s.id):t.jsx(ul,{request:s.request,busy:r===s.request.id,onRespond:n},s.id))})}function Fp({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 tn({children:e,className:r,count:n,countBadgeClassName:a,desktopIconClassName:o,expanded:s,expandedListClassName:l,icon:i,onToggleExpanded:d,runningIndicator:h,summary:u,timeMeta:m,toggleAriaLabel:f,trailingSummary:p}){return t.jsx("div",{className:`thread-graph-history-group ${r} relative min-w-0 w-full overflow-hidden rounded-[0.9rem] border px-3 py-2.5`,children:t.jsxs("div",{className:"flex items-start gap-2.5",children:[t.jsxs("div",{className:"thread-graph-history-group-icon mt-0.5 flex shrink-0 items-center",children:[t.jsxs("span",{className:`relative inline-flex h-8 w-8 items-center justify-center rounded-[0.9rem] border shadow-sm shadow-stone-950/20 ${o}`,children:[i,t.jsx("span",{className:`absolute -right-1 -top-1 inline-flex min-w-[1.1rem] items-center justify-center rounded-full border bg-stone-950/90 px-1 text-[9px] font-semibold leading-4 ${a}`,children:n})]}),h]}),t.jsxs("div",{className:"thread-graph-history-group-card min-w-0 flex-1 rounded-[0.85rem] border px-3 py-2",children:[t.jsxs("button",{type:"button","aria-expanded":s,"aria-label":f,onClick:d,className:"thread-graph-history-group-toggle flex w-full min-w-0 items-center justify-between gap-3 text-left",children:[t.jsx("div",{className:"thread-graph-history-group-summary min-w-0 flex flex-1 flex-wrap items-center gap-2 pr-1",children:u}),p||m?t.jsxs("div",{className:"inline-flex shrink-0 items-center gap-2",children:[p,m]}):null]}),s?t.jsx("div",{className:`thread-graph-history-group-list mt-3 space-y-2 border-t pt-3 ${l}`,children:e}):null]})]})})}Cr();It();var Hp=wr("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 rn({asChild:e=!1,className:r,variant:n,...a}){const o=e?_s:"span";return t.jsx(o,{"data-slot":"badge",className:Qe(Hp({variant:n,className:r})),...a})}function sa(e){if(!e)return!1;const r=e.trim().toLowerCase();return r==="running"||r==="in_progress"||r==="in progress"||r==="pending"}function Op(){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 Wp(){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 Up(){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 Vp(){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 Kp(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 fl(e,r=42){const n=Kp(e);if(!n)return"";const a=n.match(/(, \+\d+ more.*)$/),o=(a==null?void 0:a[1])??"",s=o?n.slice(0,-o.length):n;if(s.length<=r)return`${s}${o}`;const i=s.replace(/\\/g,"/").split("/").filter(Boolean);if(i.length>1){const d=[];let h=o.length+4;for(let u=i.length-1;u>=0;u-=1){const m=i[u],f=h+m.length+(d.length>0?1:0);if(d.length>0&&f>r)break;d.unshift(m),h=f}if(d.length>0)return`.../${d.join("/")}${o}`}return`...${s.slice(-(r-o.length-3))}${o}`}function qp(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 Wn({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 Xp(e){var n;const r=e.replace(/\r\n/g,`
|
|
3664
3664
|
`).split(`
|
|
3665
|
-
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function xt(e){const r=qp(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function fl(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(M.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:sa(e)?{className:"is-pending",icon:t.jsx(M.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 Xp(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 Yp(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 Ut({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=fl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Yp(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:o}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),s.status?t.jsxs(en,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function nr({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=fl(l.status),[p,g]=c.useState(n?"item-1":void 0),v=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):v.current&&g(void 0),v.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Xp(m)} ${a??""}`,children:t.jsx(wr,{type:"single",collapsible:!0,onValueChange:b=>{g(b||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(yr,{value:"item-1",className:"border-0",children:[t.jsxs(Zr,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(en,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(jr,{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(tr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(M.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Zp=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(Ut,{className:"thread-graph-event-plan",icon:t.jsx(M.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:o,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(ol,{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}:{}})})})}),Jp=c.memo(function({item:r,timeMeta:n}){const a=sa(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(Ut,{className:"thread-graph-event-context",icon:t.jsx(M.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:o}),a?t.jsx(Un,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),Qp=c.memo(function({item:r,timeMeta:n}){return t.jsx(Ut,{className:"thread-graph-event-generic",icon:t.jsx(M.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(tr,{text:r.text})})})}),ef=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.previewText??n.text);return t.jsx(nr,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(M.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),tf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.text);return t.jsx(nr,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(M.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),rf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.text);return t.jsx(nr,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(M.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),nf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.text);return t.jsx(nr,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(M.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),af=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=xt(s);return t.jsx(nr,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(M.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:o,title:"web_search",tone:"search"})}),sf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=xt(s);return t.jsx(nr,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(M.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),of=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o,timeMeta:s}){const l=n.assetPath??n.detailText??null,i=r&&l?(o==null?void 0:o({threadId:r,path:l}))??null:null;return t.jsxs(Ut,{className:"thread-graph-event-image",icon:t.jsx(M.Image,{className:"h-4 w-4"}),item:n,timeMeta:s,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),lf=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const o=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((f=r.detailText)==null?void 0:f.trim())||null,l=pl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=Kp(r),d=!!(s||r.hasDeferredDetail),h=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:o??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",s??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:o??l,children:h}):h;return t.jsx(Ut,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(M.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),df=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=aa(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Ut,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!o.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(M.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(M.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:s?"Hide":"Open"})]}),s?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),cf=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
|
|
3666
|
-
`).trim())??"",o=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=xt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(Ut,{className:"thread-graph-event-hook",icon:t.jsx(M.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:o}),t.jsx(tr,{text:i.firstLine})]}):t.jsx(tr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),hf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>sa(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(Qr,{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(Up,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Un,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Un,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=xt(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>o(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),uf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(Qr,{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(Wp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=xt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>o(`Web Search ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),mf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(Qr,{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(Op,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=xt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>o(`File Read ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),pf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(Qr,{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(Hp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,v,b,x;const f=((g=u.detailText)==null?void 0:g.trim())||((v=u.previewText)==null?void 0:v.trim())||u.text,p=(b=u.previewText)!=null&&b.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>o(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:pl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function ff(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 gf({status:e}){const r=ff(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(en,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(M.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(M.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(M.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function xf({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(en,{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(gf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function bf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(xf,{livePlan:o}):null,n??a??null,e]})}function vf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function kf(){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 wf(){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 yf(){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 jf(){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 zr(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 oa(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 mr(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function Ir(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function gl(e){var i,d,h,u,m;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:zr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?mr(e.priceEstimate.inputUsd):"--",usdRawValue:((d=e.priceEstimate)==null?void 0:d.inputUsd)??null,className:"token-badge-in",icon:t.jsx(kf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:zr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?mr(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(yf,{})}:null,s>0?{id:"out",label:"Output",tokenCompactValue:zr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?mr(Ir(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:Ir((u=e.priceEstimate)==null?void 0:u.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-out",icon:t.jsx(wf,{})}:null,o>0?{id:"reason",label:"Reasoning",tokenCompactValue:zr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?mr(Ir(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),o)??0):"--",usdRawValue:Ir((m=e.priceEstimate)==null?void 0:m.outputUsd,Math.max(r.outputTokens,0),o),className:"token-badge-reason",icon:t.jsx(jf,{})}:null].filter(f=>f!==null)}function Nf(e){return gl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function xl(e){return{label:e.priceEstimate?oa(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${mr(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var bn="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 Cf({turn:e}){const r=gl(e),n=xl(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,v=m.current;if(!g||!v)return;const b=g.getBoundingClientRect(),x=v.offsetWidth||v.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,w=b.left+b.width/2-x/2,k=y,N=Math.max(k,j-y-x),C=Math.min(Math.max(w,k),N);d(Math.round(C-w))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&o(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[s,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":s,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${bn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),s&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${bn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>o(p=>!p),className:`${bn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Sf({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 ys(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 Tf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!il(e.status);default:return!1}}function Ef(e,r,n){if(!e||!pr(n))return e;const a=e.plan.findIndex(i=>ys(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&ys(i.status)==="pending");if(o<0||!r.some(i=>Tf(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 Lf(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 js({status:e}){const r=rl(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(Sf,{tone:"emerald"})})}function Ns({turn:e,variant:r="header"}){const n=rl(e.status),a=Lf(e),o=Nf(e),s=xl(e),l=pr(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(js,{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:Ft(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:gt(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(js,{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 la=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var v,b,x;if(Lp(n.kind))return t.jsx(Lt,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(Lt,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(df,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(ef,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(tf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(rf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(nf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((v=j.detailText)==null?void 0:v.trim())||j.text||"Web search";return t.jsx(af,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((b=j.detailText)==null?void 0:b.trim())||j.text||"File read";return t.jsx(sf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(of,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Zp,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(lf,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Jp,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(cf,{item:n,timeMeta:p}):t.jsx(Qp,{item:n,timeMeta:p})});function Cs(e){return e==="completed"||e==="failed"||e==="interrupted"}function zf(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function If(e){let r=null;for(const n of e){const a=zf(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Rf(e,r){const n=Date.parse(e??""),a=If(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 Af(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?gt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function gr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Ft(n),i=Af(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function Rr(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function _f(e){const r=e.filter(s=>s.kind==="item"),n=r.map(s=>s.item).filter(s=>s.kind==="userMessage"),a=r.map(s=>s.item).reverse().find(s=>s.kind==="agentMessage"&&s.text.trim().length>0),o=e.filter(s=>s.kind!=="item"?!0:s.item.kind!=="userMessage"&&s.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:o}}var vn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:o,isCollapsed:s,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:v,onBeforeMessageResize:b,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const w=!!l||!!d||!!(i&&i.length>0),k=h||pr(a.status)||w||y,N=k&&!pr(a.status)?{...a,status:"inProgress"}:a,C=c.useMemo(()=>Rp(a.items,i),[i,a.items]),E=c.useMemo(()=>Ef(l,C,a.status),[l,C,a.status]),I=c.useMemo(()=>Ap(d,C),[d,C]),q=c.useMemo(()=>Ip(C,k),[k,C]),D=c.useMemo(()=>_p(q),[q]),$=h||pr(a.status)||w,Q=gt(a.startedAt),Z=Ft(a.startedAt),B=c.useMemo(()=>ll(I),[I]),[ee,oe]=c.useState({}),A=c.useCallback(X=>{oe(ce=>({...ce,[X]:!ce[X]}))},[]),J=t.jsx(Mf,{entries:D,expandedGroups:ee,onToggleGroupedItem:A,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...b?{onBeforeMessageResize:b}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Q,fallbackTimeTitle:Z,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:$,...v?{onSelectArtifact:v}:{},...n?{adapter:n}:{}}),R=B?t.jsx(la,{threadId:r,item:B,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(gr,{absoluteLabel:Q,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Q,timeTitle:Z,timeMeta:null,...v?{onSelectArtifact:v}:{},...n?{adapter:n}:{}}):null,Y=!B&&I?t.jsx(Lt,{item:{id:"live-agent-message",kind:"agentMessage",text:I},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(gr,{absoluteLabel:Q,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Q,timeTitle:Z,streaming:!0,...b?{onBeforeMessageResize:b}:{}}):null,H=k?t.jsx(Ns,{turn:N,variant:"footer"}):null,T=c.useMemo(()=>_f(D),[D]),O=c.useMemo(()=>Rf(a.startedAt,C),[C,a.startedAt]),G=T.hiddenEntries.length>0,L=s&&G,V=Cs(a.status)&&G&&!L?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${O}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:O}),t.jsx(M.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,K=Cs(a.status)&&G?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(X=>t.jsx(Lt,{threadId:r,item:X,scrollRootRef:x,timeLabel:X.createdAt?gt(X.createdAt):Q,timeTitle:X.createdAt?Ft(X.createdAt):Z,...b?{onBeforeMessageResize:b}:{},...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":`${O}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:O}),t.jsx(M.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),T.finalAgent?t.jsx(Lt,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(gr,{absoluteLabel:gt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Q,timeTitle:T.finalAgent.createdAt?Ft(T.finalAgent.createdAt):Z,...b?{onBeforeMessageResize:b}:{},...n?{adapter:n}:{}}):null]}):null,le=t.jsx(bf,{footer:H,history:t.jsxs(t.Fragment,{children:[V,J]}),liveHookPrompt:R,liveOutput:Y,livePlan:E});return t.jsx(vf,{absoluteIndex:o,body:le,collapsed:L,collapsedBody:K,error:a.error,headerStatus:t.jsx(Ns,{turn:a}),isActive:k,refCallback:j,startedAt:a.startedAt,timeLabel:Q,timeTitle:Z,tokenSummary:t.jsx(Cf,{turn:a})})});function Mf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:v,autoOpenLatestToolDetails:b=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(w=>w?t.jsx(gr,{absoluteLabel:gt(w),timestamp:w,turnStartedAt:v??f}):null,[f,v]);return t.jsx(Gp,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(w,k,N)=>t.jsx(hf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:l,timeMeta:j(Rr(w))},w.key),renderFileChangeGroup:(w,k,N)=>t.jsx(pf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:s,timeMeta:j(Rr(w))},w.key),renderSearchGroup:(w,k,N)=>t.jsx(uf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:s,timeMeta:j(Rr(w))},w.key),renderFileReadGroup:(w,k,N)=>t.jsx(mf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:s,timeMeta:j(Rr(w))},w.key),renderItem:w=>{const k=Pf(w.item,f??null),C=w.item.kind==="userMessage"?w.item.createdAt?gt(k):p:w.item.createdAt?t.jsx(gr,{absoluteLabel:gt(k),timestamp:k,turnStartedAt:v??f}):p;return t.jsx(la,{threadId:a,item:w.item,scrollRootRef:o,timeLabel:C,timeTitle:w.item.createdAt?Ft(k):g,timeMeta:j(k),autoOpenToolDetails:b&&w.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},w.key)}})}var Ss=3,$f=3,Wn=80;function cr(e,r=Wn){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Df(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 Bf(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Gf(e,r){return{id:e,startedAt:Bf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Ts(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Ff({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((p,g)=>{s({title:p,text:g})},[]),i=c.useCallback((p,g,v)=>{if(v&&r){r({item:p,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:v,loadingText:b,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Ts(p,g,v),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const w=n.current+1;n.current=w,j&&r||s({title:g,text:b});try{const k=await e(p.id);if(a.current.set(p.id,k),n.current!==w)return;i(p,k,j)}catch(k){if(n.current!==w)return;i(p,Ts(p,g,k instanceof Error?k.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var v;await d({item:p,fallbackTitle:g,fallbackText:((v=p.detailText)==null?void 0:v.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var v;await d({item:p,fallbackTitle:g,fallbackText:((v=p.detailText)==null?void 0:v.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,v,b,x)=>{await d({item:p,fallbackTitle:g,fallbackText:v,loadingText:b,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function Hf(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 Of({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:o,scrollRequestKey:s,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(s),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),v=c.useRef(0),b=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),w=c.useRef(!0),k=c.useRef(!1),N=c.useRef(!1),C=c.useRef(!1),E=c.useRef(!1),I=c.useRef(null),q=c.useRef(0),[D,$]=c.useState(Ss),[Q,Z]=c.useState(0),[B,ee]=c.useState(!0),oe=Hf(d),A=typeof o=="function"||n!==void 0,J=n??r,R=A?0:Math.max(0,r-D),H=(A?Math.max(0,J-r):0)+R,T=A?r:r-R,O=A?0:r-T,G=A?Math.max(0,J-r):0,L=A?G+O:O,S=!A&&L>0&&Q>=2,V=A&&G>0&&O===0&&typeof o=="function",K=c.useCallback(()=>{const U=h.current;if(!U){b.current=null;return}b.current={scrollHeight:U.scrollHeight,scrollTop:U.scrollTop}},[]),le=c.useCallback(()=>!V||a||C.current?!1:(K(),C.current=!0,E.current=!1,q.current=0,o==null||o(),!0),[V,a,o,K]),X=c.useCallback(()=>{const U=h.current,ae=x.current;if(!U)return;const xe=ae?Df(U,ae):cr(U);y.current=xe,ee(ke=>ke===xe?ke:xe)},[]),ce=c.useCallback(()=>{const U=h.current;if(U){N.current=!0;const ae=U.scrollTop,xe=v.current,ke=ae-xe;v.current=ae,cr(U,1)?(k.current=!1,w.current=!0):ke<-1?(k.current=!0,w.current=!1):ke>1&&(w.current=!k.current&&cr(U,Wn)),ae<=0&&N.current?E.current=!0:ae>0&&(E.current=!1,q.current=0)}X()},[X]),re=c.useCallback(()=>{const U=h.current;U&&(U.scrollTop=U.scrollHeight,v.current=U.scrollTop,g.current=U.scrollHeight,y.current=!0,ee(ae=>ae||!0),k.current=!1,w.current=!0)},[]),fe=c.useCallback(()=>{const U=h.current;U&&(v.current=U.scrollTop,g.current=U.scrollHeight,w.current=!1,k.current=!0)},[]),he=c.useCallback(()=>{if(A&&O===0){le();return}$(U=>Math.min(r,U+$f)),Z(U=>U+1)},[O,A,le,r]),ve=c.useCallback(U=>{const ae=h.current;if(!(!ae||U.deltaY>=-8||ae.scrollTop>0||!V)){if(!E.current){E.current=!0;return}le()}},[V,le]),Re=c.useCallback(U=>{var ae;I.current=((ae=U.touches.item(0))==null?void 0:ae.clientY)??null,q.current=0},[]),ie=c.useCallback(U=>{var Me;const ae=h.current,xe=((Me=U.touches.item(0))==null?void 0:Me.clientY)??null,ke=I.current;if(I.current=xe,!ae||xe===null||ke===null||ae.scrollTop>0||!V){q.current=0;return}const $e=xe-ke;if($e<=0){q.current=0;return}if(!E.current){E.current=!0,q.current=0;return}q.current+=$e,q.current>=28&&le()},[V,le]),ye=c.useCallback(()=>{I.current=null,q.current=0},[]),Te=c.useCallback(()=>{$(r)},[r]);return c.useLayoutEffect(()=>{const U=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(U)}},[e,re]),c.useEffect(()=>{C.current=!1,N.current=!1,E.current=!1,b.current=null},[e]),c.useEffect(()=>{a||(C.current=!1)},[a,r]),c.useLayoutEffect(()=>{const U=b.current,ae=h.current;if(!U||!ae||a)return;b.current=null;const xe=ae.scrollHeight-U.scrollHeight;if(xe<=0){g.current=ae.scrollHeight,v.current=ae.scrollTop;return}const ke=U.scrollTop+xe;ae.scrollTop=ke,v.current=ke,g.current=ae.scrollHeight,k.current=!0,w.current=!1,E.current=!1},[a,r]),c.useEffect(()=>{$(U=>U>=r-1?r:Math.max(U,Ss))},[r]),c.useEffect(()=>{const U=h.current;U&&(g.current=U.scrollHeight,v.current=U.scrollTop,cr(U,1)?(k.current=!1,w.current=!0):(k.current||!cr(U,Wn))&&(w.current=!1)),X()},[oe,X,D]),c.useEffect(()=>{const U=s!==m.current,ae=f.current!==oe;if(f.current=oe,!(U||ae&&w.current&&!k.current))return;const ke=window.requestAnimationFrame(()=>{re()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(ke)}},[oe,B,re,s]),c.useEffect(()=>{const U=h.current,ae=u.current;if(!U||!ae||typeof ResizeObserver>"u")return;g.current=U.scrollHeight;const xe=new ResizeObserver(()=>{const ke=U.scrollHeight,$e=g.current;if(g.current=ke,ke<=$e)return;const Me=$e>0&&$e-U.scrollTop-U.clientHeight<=1;k.current||!(w.current||Me||y.current)||window.requestAnimationFrame(()=>{re()})});return xe.observe(ae),()=>{xe.disconnect()}},[re]),c.useEffect(()=>{if(!w.current||k.current){p.current=l;return}if(l===p.current)return;p.current=l;const U=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(U)}},[l,re]),c.useEffect(()=>{i==null||i(B)},[B,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:B,handleScroll:ce,handleWheel:ve,handleTouchStart:Re,handleTouchMove:ie,handleTouchEnd:ye,preserveScrollPositionForResize:fe,serverManagedHistory:A,effectiveTotalTurnCount:J,startIndex:R,visibleTurnAbsoluteOffset:H,hiddenCount:L,loadedHiddenCount:O,unloadedHiddenCount:G,showLoadAll:S,handleLoadEarlierClick:he,handleLoadAllClick:Te}}function Uf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Wf(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 Vf({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,bottomSpacer:p=0,className:g="",onTailVisibilityChange:v,loadingEarlier:b=!1,onLoadEarlier:x,ephemeralUserNote:j=null,answeredRequestNotes:y=[],activityNotes:w=[],optimisticSteers:k=[],optimisticTurn:N=null,onLoadHistoryItemDetail:C,onOpenThread:E,onSelectArtifact:I,onSelectHistoryItemDetail:q,adapter:D,autoCollapseCompletedTurns:$}){var dt,z,W,pe,Pe;const Q=tl(),Z=$??(Q==null?void 0:Q.autoCollapseCompletedTurns)??!1,[B,ee]=c.useState({}),[oe,A]=c.useState(()=>new Set),J=(D==null?void 0:D.onLoadHistoryItemDetail)??C,R=D==null?void 0:D.onOpenLinkedThread,{expandedText:Y,openExpandedText:H,openCommandDetail:T,openToolCallDetail:O,openDeferredHistoryItemDetail:G,closeExpandedText:L}=Ff({loadHistoryItemDetail:J,onSelectHistoryItemDetail:q}),{scrollContainerRef:S,scrollContentRef:V,tailSentinelRef:K,topSentinelRef:le,handleScroll:X,handleWheel:ce,handleTouchStart:re,handleTouchMove:fe,handleTouchEnd:he,preserveScrollPositionForResize:ve,serverManagedHistory:Re,effectiveTotalTurnCount:ie,startIndex:ye,visibleTurnAbsoluteOffset:Te,hiddenCount:U,loadedHiddenCount:ae,unloadedHiddenCount:xe,showLoadAll:ke,handleLoadEarlierClick:$e,handleLoadAllClick:Me}=Of({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:b,onLoadEarlier:x,scrollRequestKey:f,bottomSpacer:p,onTailVisibilityChange:v,contentRevisionInputs:[r,a,l,k,m,i,d,N,y,w,j,p]}),je=c.useCallback((te,He)=>{ee(Ue=>({...Ue,[te]:!He}))},[]),De=c.useCallback((te,He)=>{const Ue=B[te.id];return Ue!==void 0?Ue:!!(Z&&Uf(te.status)&&!He.forceActive&&!He.hasLiveActivity)},[B,Z]),F=Re?r:r.slice(ye),de=ie+1,we=s&&(!o||!F.some(te=>te.id===o)&&(N==null?void 0:N.id)!==o),P=(N==null?void 0:N.id)??((dt=F.at(-1))==null?void 0:dt.id)??null,_=we&&P!==null,se=!!d&&(F.some(te=>te.id===d.turnId)||(N==null?void 0:N.id)===d.turnId),ge=d&&se?d.turnId:d&&_?P:null,Ne=N&&ge===N.id?(d==null?void 0:d.items)??null:null,Ae=((d==null?void 0:d.items.length)??0)>0,Se=d&&ge===null?d.items:null,Be=c.useMemo(()=>d&&ge===null&&d.items.length>0?Gf(d.turnId,d.items):null,[d,ge]),We=Math.max(1,ie+(N?1:0)),at=!!m&&!!N&&N.status!=="failed"&&!Ne,et=m&&F.length>0?o&&F.some(te=>te.id===o)?o:((z=F.findLast(te=>il(te.status)))==null?void 0:z.id)??(_?P:null):null,tt=!!et,rt=c.useMemo(()=>ll(m),[m]),it=[...l.map(te=>({id:te.id,prompt:te.prompt,status:"Accepted",createdAt:te.createdAt,canCancel:!0})),...k.map(te=>({id:te.id,prompt:te.prompt,status:te.status==="steering"?"Steering":null,createdAt:te.createdAt,canCancel:!1}))].sort((te,He)=>te.createdAt.localeCompare(He.createdAt)),_e=c.useMemo(()=>Mp({answeredRequestNotes:y,pendingRequests:a,visibleTurns:F,optimisticTurn:N}),[y,N,a,F]),Fe=c.useMemo(()=>$p({activityNotes:w,visibleTurns:F,optimisticTurn:N}),[w,N,F]);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:S,"data-testid":"thread-scroll-container",onScroll:X,onWheel:ce,onTouchStart:re,onTouchMove:fe,onTouchEnd:he,onTouchCancel:he,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:p>0?{paddingBottom:p}:void 0,children:t.jsxs("div",{ref:V,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:le,"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:[U>0&&t.jsx("button",{type:"button",onClick:$e,disabled:b,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:b?"Loading earlier...":"Load 3 earlier"}),ke&&t.jsx("button",{type:"button",onClick:Me,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 ",F.length," of ",ie," turns",U>0?` · ${U} earlier hidden${ae>0&&xe>0?` (${ae} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!N&&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."}),(F.length>0||N||Fe.leading.length>0||Fe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Fe.leading.length>0?t.jsx(dr,{notes:Fe.leading,onOpenThread:E,onOpenLinkedThread:R}):null,F.map((te,He)=>{var Ue,Oe,qe,ct,bt;return t.jsxs("div",{children:[(((Ue=Fe.beforeTurnId.get(te.id))==null?void 0:Ue.length)??0)>0?t.jsx(dr,{notes:Fe.beforeTurnId.get(te.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null,(((Oe=_e.beforeTurnId.get(te.id))==null?void 0:Oe.length)??0)>0?t.jsx(On,{entries:_e.beforeTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const st=Wf(te,N),yt=(i==null?void 0:i.turnId)===te.id?i:null,jt=ge===te.id?(d==null?void 0:d.items)??null:null,Nt=et===te.id?m:"",be=o===te.id||_&&P===te.id,ze=!!yt||!!Nt||!!(jt&&jt.length>0),ot=De(st,{forceActive:be,hasLiveActivity:ze});return t.jsx(vn,{threadId:e,...D?{adapter:D}:{},turn:st,absoluteIndex:Te+He+1,isCollapsed:ot,livePlan:yt,liveItems:jt,liveOutput:Nt,forceActive:be,onToggleCollapse:je,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...I?{onSelectArtifact:I}:{},scrollRootRef:S,articleRef:void 0})})(),(((qe=Fe.afterTurnId.get(te.id))==null?void 0:qe.length)??0)>0?t.jsx(dr,{notes:Fe.afterTurnId.get(te.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null,(ct=_e.notesByTurnId.get(te.id))!=null&&ct.length||(bt=_e.pendingRequestsByTurnId.get(te.id))!=null&&bt.length?t.jsx(Dp,{notes:_e.notesByTurnId.get(te.id)??[],requests:_e.pendingRequestsByTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},te.id)}),N&&F.every(te=>te.id!==N.id)&&t.jsxs(t.Fragment,{children:[(((W=Fe.beforeTurnId.get(N.id))==null?void 0:W.length)??0)>0?t.jsx(dr,{notes:Fe.beforeTurnId.get(N.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null,(((pe=_e.beforeTurnId.get(N.id))==null?void 0:pe.length)??0)>0?t.jsx(On,{entries:_e.beforeTurnId.get(N.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const te=at?m:"",He=o===N.id||_&&P===N.id,Ue=!!(Ne&&Ne.length>0)||!!te,Oe=De(N,{forceActive:He,hasLiveActivity:Ue});return t.jsx(vn,{threadId:e,...D?{adapter:D}:{},turn:N,absoluteIndex:de,isCollapsed:Oe,livePlan:null,liveItems:Ne,liveOutput:te,forceActive:He,onToggleCollapse:je,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...I?{onSelectArtifact:I}:{},scrollRootRef:S})})(),(((Pe=Fe.afterTurnId.get(N.id))==null?void 0:Pe.length)??0)>0?t.jsx(dr,{notes:Fe.afterTurnId.get(N.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null]})]}),it.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:it.map(te=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Lt,{threadId:e,item:{id:te.id,kind:"userMessage",text:te.prompt,status:te.status},scrollRootRef:S,onBeforeMessageResize:ve,...D?{adapter:D}:{}}),e&&te.canCancel&&(D!=null&&D.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:oe.has(te.id),onClick:()=>{var He;A(Ue=>new Set(Ue).add(te.id)),Promise.resolve((He=D.cancelPendingSteer)==null?void 0:He.call(D,e,te.id)).catch(()=>{}).finally(()=>{A(Ue=>{const Oe=new Set(Ue);return Oe.delete(te.id),Oe})})},children:oe.has(te.id)?"Canceling...":"Cancel"})}):null]},te.id))}),(_e.trailing.length>0||Fe.trailing.length>0)&&t.jsx(Bp,{entries:[...Fe.trailing.map(te=>({kind:"activity",id:te.id,createdAt:te.createdAt,note:te})),..._e.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:E,onOpenLinkedThread:R}),j&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Lt,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:j},scrollRootRef:S,onBeforeMessageResize:ve})}),Be&&Se&&Se.length>0&&t.jsx(vn,{threadId:e,...D?{adapter:D}:{},turn:Be,absoluteIndex:We,isCollapsed:B[Be.id]??!1,livePlan:(i==null?void 0:i.turnId)===Be.id?i:null,liveItems:Se,liveOutput:"",forceActive:!0,onToggleCollapse:je,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...I?{onSelectArtifact:I}:{},scrollRootRef:S}),m&&!tt&&!at&&!Ae&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:rt?t.jsx(la,{threadId:e,item:rt,scrollRootRef:S,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...I?{onSelectArtifact:I}:{},...D?{adapter:D}:{}}):t.jsx(Lt,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:S,streaming:!0,onBeforeMessageResize:ve,...D?{adapter:D}:{}})}),t.jsx("div",{ref:K,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(ep,{open:Y!==null,title:(Y==null?void 0:Y.title)??"Full text",text:(Y==null?void 0:Y.text)??"",onClose:L})]})}var bl=c.memo(Vf);function Kf(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Vn(e){return e.replace(/\r\n/g,`
|
|
3667
|
-
`)}function
|
|
3665
|
+
`);for(;r.length>1&&((n=r.at(-1))==null?void 0:n.trim())==="";)r.pop();return r}function xt(e){const r=Xp(e);return r.length===1?{firstLine:r[0]??"",showGap:!1,isTruncated:!1}:{firstLine:r[0]??"",showGap:!0,isTruncated:!0}}function gl(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(M.CheckCircle2,{className:"h-3.5 w-3.5"}),label:"Completed"}:r==="failed"||r==="failure"||r==="error"||r==="errored"?{className:"is-failed",icon:t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}),label:"Failed"}:sa(e)?{className:"is-pending",icon:t.jsx(M.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 Yp(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 Zp(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 Wt({actions:e,children:r,className:n,headerMeta:a,icon:o,item:s,timeMeta:l,title:i,tone:d}){const h=gl(s.status);return t.jsxs("div",{className:`thread-graph-event thread-graph-history-event ${Zp(d)} ${n??""}`,children:[t.jsx("div",{className:"thread-graph-history-event-icon","aria-hidden":"true",children:o}),t.jsxs("div",{className:"thread-graph-history-event-card",children:[t.jsxs("div",{className:"thread-graph-history-event-header",children:[t.jsxs("div",{className:"thread-graph-history-event-heading flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-event-title min-w-0 truncate font-mono text-sm font-semibold",children:i}),s.status?t.jsxs(rn,{variant:"outline",className:`thread-graph-tool-badge ${h.className} rounded-full px-2 py-0.5 text-xs font-normal`,title:h.label,"aria-label":`Status: ${h.label}`,children:[h.icon,t.jsx("span",{className:"thread-graph-status-label",children:h.label})]}):null,a]}),e||l?t.jsxs("div",{className:"thread-graph-history-event-actions",children:[e,l]}):null]}),r?t.jsx("div",{className:"thread-graph-history-event-body",children:r}):null]})]})}function ar({actionLabel:e="Open details",actionTitle:r,autoOpen:n=!1,className:a,details:o,icon:s,item:l,onOpen:i,preview:d,timeMeta:h,title:u,tone:m}){const f=gl(l.status),[p,g]=c.useState(n?"item-1":void 0),v=c.useRef(n);return c.useLayoutEffect(()=>{n?g("item-1"):v.current&&g(void 0),v.current=n},[n,l.id]),t.jsx("div",{className:`thread-graph-event thread-graph-history-tool ${Yp(m)} ${a??""}`,children:t.jsx(yr,{type:"single",collapsible:!0,onValueChange:b=>{g(b||void 0)},className:"thread-graph-tool-accordion thread-graph-history-tool-accordion w-full overflow-hidden rounded-lg border",value:p??"",children:t.jsxs(jr,{value:"item-1",className:"border-0",children:[t.jsxs(Qr,{"aria-label":`${p==="item-1"?"Collapse":"Expand"} ${u} history item`,className:"thread-graph-tool-trigger thread-graph-history-tool-trigger px-4 py-3 hover:no-underline",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-tool-icon shrink-0",children:s}),t.jsx("span",{className:"min-w-0 truncate font-mono text-sm font-semibold",children:u}),t.jsxs(rn,{variant:"outline",className:`thread-graph-tool-badge ${f.className} ml-1 sm:ml-2 rounded-full px-2 py-0.5 text-xs font-normal`,title:f.label,"aria-label":`Status: ${f.label}`,children:[f.icon,t.jsx("span",{className:"thread-graph-status-label",children:f.label})]})]}),h?t.jsx("span",{className:"thread-graph-history-tool-time shrink-0",children:h}):null]}),t.jsxs(Nr,{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(rr,{text:d.firstLine}),d.showGap?t.jsx("span",{className:"thread-graph-history-tool-ellipsis",children:"..."}):null]})]}),o?t.jsx("section",{children:o}):null,t.jsxs("button",{type:"button","aria-label":e,onClick:i,className:"thread-graph-history-tool-open inline-flex items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium transition",children:[t.jsx(M.ExternalLink,{className:"h-3.5 w-3.5"}),r]})]})]})})})}var Jp=c.memo(function({item:r,scrollRootRef:n,onBeforeResize:a,timeMeta:o}){return t.jsx(Wt,{className:"thread-graph-event-plan",icon:t.jsx(M.ClipboardList,{className:"h-4 w-4"}),item:r,timeMeta:o,title:"plan",tone:"plan",children:t.jsx("div",{className:"thread-graph-history-event-prose",children:t.jsx(ll,{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}:{}})})})}),Qp=c.memo(function({item:r,timeMeta:n}){const a=sa(r.status)||r.text==="Compacting context",o=a?"Compacting context":"Context compacted",s=r.detailText&&r.detailText!==o?r.detailText:null;return t.jsxs(Wt,{className:"thread-graph-event-context",icon:t.jsx(M.Archive,{className:"h-4 w-4"}),item:r,timeMeta:n,title:"context",tone:"context",children:[t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("span",{className:"thread-graph-history-event-primary",children:o}),a?t.jsx(Wn,{tone:"emerald"}):null]}),s?t.jsx("p",{className:"thread-graph-history-event-secondary",title:s,children:s}):null]})}),ef=c.memo(function({item:r,timeMeta:n}){return t.jsx(Wt,{className:"thread-graph-event-generic",icon:t.jsx(M.Info,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.kind,tone:"generic",children:t.jsx("pre",{className:"thread-graph-history-event-pre",children:t.jsx(rr,{text:r.text})})})}),tf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.previewText??n.text);return t.jsx(ar,{actionLabel:"Open full command",actionTitle:"Command Output",autoOpen:r,className:"thread-graph-event-command",icon:t.jsx(M.Terminal,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Command Output"),preview:s,timeMeta:o,title:"command",tone:"command"})}),rf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.text);return t.jsx(ar,{actionLabel:"Open full tool call",actionTitle:"Tool Call Details",autoOpen:r,className:"thread-graph-event-tool",icon:t.jsx(M.Wrench,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Tool Call Details"),preview:s,timeMeta:o,title:"tool_call",tone:"tool"})}),nf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.text);return t.jsx(ar,{actionLabel:"Open agent details",actionTitle:"Agent Details",autoOpen:r,className:"thread-graph-event-agent-tool",icon:t.jsx(M.Bot,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Agent Details"),preview:s,timeMeta:o,title:"agent",tone:"agent"})}),af=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){const s=xt(n.text);return t.jsx(ar,{actionLabel:"Open skill details",actionTitle:"Skill Details",autoOpen:r,className:"thread-graph-event-skill-tool",icon:t.jsx(M.Sparkles,{className:"h-4 w-4"}),item:n,onOpen:()=>a(n,"Skill Details"),preview:s,timeMeta:o,title:"skill",tone:"skill"})}),sf=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"Web search",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"Web search",i=xt(s);return t.jsx(ar,{actionLabel:"Open full web search",actionTitle:"Web Search Details",autoOpen:r,className:"thread-graph-event-search",icon:t.jsx(M.Search,{className:"h-4 w-4"}),item:n,onOpen:()=>a("Web Search Details",l),preview:i,timeMeta:o,title:"web_search",tone:"search"})}),of=c.memo(function({autoOpen:r,item:n,onOpen:a,timeMeta:o}){var d,h;const s=((d=n.previewText)==null?void 0:d.trim())||n.text||"File read",l=((h=n.detailText)==null?void 0:h.trim())||n.text||"File read",i=xt(s);return t.jsx(ar,{actionLabel:"Open full file read",actionTitle:"File Read Details",autoOpen:r,className:"thread-graph-event-file-read",icon:t.jsx(M.FileText,{className:"h-4 w-4"}),item:n,onOpen:()=>a("File Read Details",l),preview:i,timeMeta:o,title:"file_read",tone:"fileRead"})}),lf=c.memo(function({threadId:r,item:n,onOpen:a,getImageAssetUrl:o,timeMeta:s}){const l=n.assetPath??n.detailText??null,i=r&&l?(o==null?void 0:o({threadId:r,path:l}))??null:null;return t.jsxs(Wt,{className:"thread-graph-event-image",icon:t.jsx(M.Image,{className:"h-4 w-4"}),item:n,timeMeta:s,title:"image",tone:"image",children:[i?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l??n.text),className:"block w-full text-left",children:t.jsx("img",{src:i,alt:n.text||"Image preview",className:"thread-graph-history-event-image",loading:"lazy"})}):t.jsx("div",{className:"thread-graph-history-event-summary",children:n.text}),l?t.jsx("button",{type:"button",onClick:()=>a("Image Path",l),className:"thread-graph-history-event-path",title:l,children:l}):null]})}),df=c.memo(function({item:r,onOpen:n,timeMeta:a}){var m,f,p;const o=(m=r.previewText)!=null&&m.trim()&&r.text.trim()!==r.previewText.trim()?r.text.trim():null,s=((f=r.detailText)==null?void 0:f.trim())||null,l=fl(o??((p=r.previewText)==null?void 0:p.trim())??r.text,48),i=qp(r),d=!!(s||r.hasDeferredDetail),h=t.jsxs("div",{className:"thread-graph-event-line thread-graph-file-change-inline flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip text-sm",title:o??l,children:l}),i.length>0&&t.jsx("div",{className:"inline-flex shrink-0 items-center justify-end gap-1.5 text-xs",children:i.map(g=>t.jsx("span",{className:`thread-graph-history-delta-badge ${g.startsWith("+")?"is-add":g.startsWith("-")?"is-remove":"is-neutral"}`,children:g},g))})]}),u=d?t.jsx("button",{type:"button","aria-label":"Open file change details",onClick:()=>n("File Change Details",s??r.text),className:"thread-graph-file-change-inline-button min-w-0 flex-1 text-left",title:o??l,children:h}):h;return t.jsx(Wt,{className:"thread-graph-event-file-change",headerMeta:u,icon:t.jsx(M.FilePenLine,{className:"h-4 w-4"}),item:r,timeMeta:a,title:"file_change",tone:"fileChange"})}),cf=c.memo(function({item:r,onSelect:n,timeMeta:a}){const o=aa(),[s,l]=c.useState(!1),i=r.artifact,d=i?o.renderArtifact({artifact:i,expanded:s,onToggleExpanded:()=>l(h=>!h)}):null;return t.jsx(Wt,{actions:t.jsxs("span",{className:"inline-flex items-center gap-2",children:[i&&!o.hasRendererForArtifact(i)?t.jsx("span",{className:"thread-graph-history-event-secondary",children:"No renderer"}):null,i&&n?t.jsxs("button",{type:"button","aria-label":`Open artifact inspector for ${i.title}`,onClick:()=>n(r,i),className:"thread-graph-history-event-action",children:[t.jsx(M.PackageOpen,{className:"h-3.5 w-3.5"}),"Inspect"]}):null]}),className:"thread-graph-event-artifact",icon:t.jsx(M.PackageOpen,{className:"h-4 w-4"}),item:r,timeMeta:a,title:(i==null?void 0:i.type)??"artifact",tone:"artifact",children:d??t.jsxs("div",{className:"space-y-2",children:[t.jsxs("button",{type:"button",onClick:()=>l(h=>!h),className:"thread-graph-history-event-summary is-clickable flex w-full items-center justify-between gap-3 text-left",children:[t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"thread-graph-history-event-primary block truncate",children:(i==null?void 0:i.title)??r.text}),t.jsx("span",{className:"thread-graph-history-event-secondary mt-1 block truncate",children:(i==null?void 0:i.summaryText)??r.previewText??r.text})]}),t.jsx("span",{className:"thread-graph-history-event-pill",children:s?"Hide":"Open"})]}),s?t.jsx("pre",{className:"thread-graph-history-event-pre max-h-80 overflow-auto",children:JSON.stringify((i==null?void 0:i.payload)??r,null,2)}):null]})})}),hf=c.memo(function({item:r,timeMeta:n}){var h,u;const a=((h=r.hookOutputEntries)==null?void 0:h.map(m=>m.text.trim()).filter(Boolean).join(`
|
|
3666
|
+
`).trim())??"",o=r.hookEventLabel?`${r.hookEventLabel} hook`:r.text,s=((u=r.hookStatusMessage)==null?void 0:u.trim())||(r.previewText&&r.previewText!==r.hookStatusMessage?r.previewText.trim():"")||r.text.trim(),i=xt(a||(s&&s!==o?s:o)),d=!!(a&&i.showGap);return t.jsx(Wt,{className:"thread-graph-event-hook",icon:t.jsx(M.Webhook,{className:"h-4 w-4"}),item:r,timeMeta:n,title:r.hookEventLabel?`${r.hookEventLabel}_hook`:"hook",tone:"hook",children:t.jsxs("div",{className:"thread-graph-history-event-line",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:a?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"thread-graph-history-event-secondary mr-2 font-sans text-[11px] uppercase",children:o}),t.jsx(rr,{text:i.firstLine})]}):t.jsx(rr,{text:i.firstLine&&i.firstLine!==o?`${o} · ${i.firstLine}`:o})}),d?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})})}),uf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.filter(d=>sa(d.status)).length,i=r.length===1?"1 command":`${r.length} commands`;return t.jsx(tn,{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(Up,{}),onToggleExpanded:a,runningIndicator:l>0?t.jsx(Wn,{}):null,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-amber-300/28 bg-amber-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-amber-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:i}),l>0?t.jsx("span",{className:"inline-flex items-center text-xs text-amber-100/90",children:t.jsx(Wn,{})}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} command entries`,children:r.map((d,h)=>{const u=xt(d.text);return t.jsxs("button",{type:"button","aria-label":`Open grouped command ${h+1}`,onClick:()=>o(d,`Command Output ${h+1}`),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-amber-300/18 bg-amber-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-amber-100",children:["Step ",h+1]}),d.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:d.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},d.id)})})}),mf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 search":`${r.length} searches`;return t.jsx(tn,{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(Vp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-sky-300/28 bg-sky-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-sky-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} web search entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"Web search",u=xt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"Web search";return t.jsxs("button",{type:"button","aria-label":`Open grouped web search ${d+1}`,onClick:()=>o(`Web Search ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-sky-300/18 bg-sky-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-sky-100",children:["Search ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),pf=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.length===1?"1 file read":`${r.length} file reads`;return t.jsx(tn,{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(Wp,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-cyan-300/28 bg-cyan-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-cyan-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:l})]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file read entries`,children:r.map((i,d)=>{var f,p;const h=((f=i.previewText)==null?void 0:f.trim())||i.text||"File read",u=xt(h),m=((p=i.detailText)==null?void 0:p.trim())||i.text||"File read";return t.jsxs("button",{type:"button","aria-label":`Open grouped file read ${d+1}`,onClick:()=>o(`File Read ${d+1}`,m),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsxs("span",{className:"rounded-full border border-cyan-300/18 bg-cyan-300/[0.07] px-2 py-0.5 text-[10px] uppercase tracking-[0.18em] text-cyan-100",children:["Read ",d+1]}),i.status&&t.jsx("span",{className:"thread-graph-history-detail-meta text-xs",children:i.status})]}),t.jsxs("div",{className:"mt-1 flex min-w-0 items-center gap-2 text-sm leading-6",children:[t.jsx("p",{className:"thread-graph-history-detail-text min-w-0 flex-1 overflow-hidden whitespace-nowrap text-clip",children:u.firstLine}),u.showGap?t.jsx("span",{className:"thread-graph-history-detail-meta shrink-0 text-[11px] font-medium tracking-[0.28em]",children:"..."}):null]})]},i.id)})})}),ff=c.memo(function({items:r,expanded:n,onToggleExpanded:a,onOpen:o,timeMeta:s}){const l=r.reduce((u,m)=>u+(m.changedFiles??0),0),i=r.reduce((u,m)=>u+(m.addedLines??0),0),d=r.reduce((u,m)=>u+(m.removedLines??0),0),h=r.length===1?"1 file change":`${r.length} file changes`;return t.jsx(tn,{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(Op,{}),onToggleExpanded:a,summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"rounded-full border border-lime-300/28 bg-lime-300/12 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.24em] text-lime-100",children:"Batch"}),t.jsx("span",{className:"rounded-full border border-stone-700/90 bg-stone-900/80 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.16em] text-stone-300",children:h}),l>0?t.jsxs("span",{className:"thread-graph-history-detail-meta text-xs",children:[l," files"]}):null]}),timeMeta:s,toggleAriaLabel:`${n?"Collapse":"Expand"} ${r.length} file change entries`,trailingSummary:t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[i>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",i]}):null,d>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",d]}):null]}),children:r.map((u,m)=>{var g,v,b,x;const f=((g=u.detailText)==null?void 0:g.trim())||((v=u.previewText)==null?void 0:v.trim())||u.text,p=(b=u.previewText)!=null&&b.trim()&&u.text.trim()!==u.previewText.trim()?u.text.trim():((x=u.previewText)==null?void 0:x.trim())||u.text;return t.jsx("button",{type:"button","aria-label":`Open grouped file change ${m+1}`,onClick:()=>o(`File Change ${m+1}`,f),className:"thread-graph-history-detail-row block w-full rounded-md border px-3 py-2 text-left transition",children:t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"thread-graph-history-detail-text min-w-0 flex-1 text-sm leading-6",title:p,children:fl(p,34)}),t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5",children:[(u.addedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-add",children:["+",u.addedLines]}):null,(u.removedLines??0)>0?t.jsxs("span",{className:"thread-graph-history-delta-badge is-remove",children:["-",u.removedLines]}):null]})]})},u.id)})})});function gf(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 xf({status:e}){const r=gf(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(rn,{"aria-label":n,title:n.replace("Plan step status: ",""),className:a,children:r==="completed"?t.jsx(M.CheckCircle2,{className:"h-3.5 w-3.5"}):r==="in_progress"?t.jsx(M.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):r==="pending"?t.jsx(M.Clock3,{className:"h-3.5 w-3.5"}):r==="failed"?t.jsx(M.XCircle,{className:"h-3.5 w-3.5"}):t.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-[0.14em]",children:"?"})})}function bf({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(rn,{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(xf,{status:r.status})]},`${e.turnId}-${n}`))})]})}function vf({footer:e,history:r,liveHookPrompt:n,liveOutput:a,livePlan:o}){return t.jsxs(t.Fragment,{children:[r,o?t.jsx(bf,{livePlan:o}):null,n??a??null,e]})}function kf({absoluteIndex:e,body:r,collapsed:n,collapsedBody:a,error:o,footer:s,headerStatus:l,isActive:i=!1,refCallback:d,startedAt:h,timeLabel:u,timeTitle:m,tokenSummary:f}){return t.jsxs("article",{ref:d,"data-testid":"chat-turn","data-turn-active":i?"true":"false",className:"thread-graph-turn px-3 py-2 sm:px-5 sm:py-3",children:[t.jsx("div",{className:"thread-graph-turn-header flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0 flex flex-1 items-start gap-1.5",children:[t.jsxs("div",{className:"min-w-0 flex flex-1 items-center gap-1.5 overflow-hidden",children:[t.jsxs("span",{className:"thread-graph-turn-index rounded-[0.6rem] border px-1.5 py-0.5 text-[10px] uppercase tracking-[0.16em]",children:["Turn ",e]}),t.jsx("time",{dateTime:h??void 0,title:m,className:"thread-graph-turn-time shrink-0 text-[10px] sm:text-[11px]",children:u}),l,o?t.jsx("p",{className:"hidden truncate text-[11px] text-rose-200 sm:block",children:o}):null]}),f]})}),o?t.jsx("p",{className:"mt-1 text-[11px] text-rose-200 sm:hidden",children:o}):null,t.jsxs("div",{className:"thread-graph-turn-body mt-2 space-y-2",children:[n?a:r,n?null:s]})]})}function wf(){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 yf(){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 ys(){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 jf(){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 hr(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 oa(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 Jt(e){return!Number.isFinite(e)||e<=0?"$0.0000":`$${e.toFixed(4)}`}function zr(e,r,n){const a=e??null;return!Number.isFinite(a??NaN)||a===null||r<=0||n<=0?null:a*n/r}function xl(e){var d,h,u,m,f,p;const r=(d=e.tokenUsage)==null?void 0:d.total;if(!r)return[];const n=Math.max(r.inputTokens-r.cachedInputTokens-(r.cacheWriteInputTokens??0),0),a=Math.max(r.cachedInputTokens,0),o=Math.max(r.cacheWriteInputTokens??0,0),s=Math.max(r.reasoningOutputTokens,0),l=Math.max(r.outputTokens-s,0);return[n>0?{id:"in",label:"Input",tokenCompactValue:hr(n),tokenRawValue:n,usdCompactValue:e.priceEstimate?Jt(e.priceEstimate.inputUsd):"--",usdRawValue:((h=e.priceEstimate)==null?void 0:h.inputUsd)??null,className:"token-badge-in",icon:t.jsx(wf,{})}:null,a>0?{id:"cache",label:"Cached input",tokenCompactValue:hr(a),tokenRawValue:a,usdCompactValue:e.priceEstimate?Jt(e.priceEstimate.cachedInputUsd):"--",usdRawValue:((u=e.priceEstimate)==null?void 0:u.cachedInputUsd)??null,className:"token-badge-cache",icon:t.jsx(ys,{})}:null,o>0?{id:"cache-write",label:"Cache write",tokenCompactValue:hr(o),tokenRawValue:o,usdCompactValue:e.priceEstimate?Jt(e.priceEstimate.cacheWriteInputUsd??0):"--",usdRawValue:((m=e.priceEstimate)==null?void 0:m.cacheWriteInputUsd)??null,className:"token-badge-cache",icon:t.jsx(ys,{})}:null,l>0?{id:"out",label:"Output",tokenCompactValue:hr(l),tokenRawValue:l,usdCompactValue:e.priceEstimate?Jt(zr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),l)??0):"--",usdRawValue:zr((f=e.priceEstimate)==null?void 0:f.outputUsd,Math.max(r.outputTokens,0),l),className:"token-badge-out",icon:t.jsx(yf,{})}:null,s>0?{id:"reason",label:"Reasoning",tokenCompactValue:hr(s),tokenRawValue:s,usdCompactValue:e.priceEstimate?Jt(zr(e.priceEstimate.outputUsd,Math.max(r.outputTokens,0),s)??0):"--",usdRawValue:zr((p=e.priceEstimate)==null?void 0:p.outputUsd,Math.max(r.outputTokens,0),s),className:"token-badge-reason",icon:t.jsx(jf,{})}:null].filter(g=>g!==null)}function Nf(e){return xl(e).map(r=>({id:r.id,label:r.tokenCompactValue,title:`${r.label}: ${r.tokenRawValue} tokens`,className:r.className,icon:r.icon}))}function bl(e){return{label:e.priceEstimate?oa(e.priceEstimate.totalUsd):"--",title:e.priceEstimate===null||e.priceEstimate===void 0?"Price estimate unavailable for this model.":`Estimated cost: ${Jt(e.priceEstimate.totalUsd)}`,className:e.priceEstimate?"token-badge-total":"token-badge-empty"}}var kn="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 Cf({turn:e}){const r=xl(e),n=bl(e),[a,o]=c.useState(!1),[s,l]=c.useState(!1),[i,d]=c.useState(0),h=c.useRef(null),u=c.useRef(null),m=c.useRef(null);if(c.useLayoutEffect(()=>{if(!a||r.length===0){d(0);return}const p=()=>{const g=h.current,v=m.current;if(!g||!v)return;const b=g.getBoundingClientRect(),x=v.offsetWidth||v.getBoundingClientRect().width;if(x<=0)return;const j=window.innerWidth||document.documentElement.clientWidth,y=12,w=b.left+b.width/2-x/2,k=y,N=Math.max(k,j-y-x),C=Math.min(Math.max(w,k),N);d(Math.round(C-w))};return p(),window.addEventListener("resize",p),()=>{window.removeEventListener("resize",p)}},[r.length,a]),c.useEffect(()=>{if(!a&&!s)return;const p=g=>{g.target instanceof Node&&(h.current&&!h.current.contains(g.target)&&o(!1),u.current&&!u.current.contains(g.target)&&l(!1))};return document.addEventListener("pointerdown",p),()=>{document.removeEventListener("pointerdown",p)}},[s,a]),!n&&r.length===0)return null;const f=()=>t.jsx("div",{className:"thread-token-popover min-w-[12rem] rounded-2xl border p-2.5 shadow-2xl shadow-black/20 backdrop-blur",children:t.jsx("div",{className:"space-y-1",children:r.map(p=>t.jsxs("div",{className:"thread-token-popover-row flex items-center justify-between gap-3 rounded-xl border px-2.5 py-1.5 text-[11px]",title:`${p.label}: ${p.tokenRawValue} tokens`,children:[t.jsxs("span",{className:"thread-token-popover-text inline-flex min-w-0 items-center gap-2",children:[t.jsx("span",{className:"inline-flex shrink-0",children:p.icon}),t.jsx("span",{className:"thread-token-popover-strong font-medium",children:p.usdCompactValue})]}),t.jsx("span",{className:"thread-token-popover-text shrink-0 font-medium",children:p.tokenCompactValue})]},p.id))})});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"hidden shrink-0 items-center gap-1.5 md:inline-flex",children:[n?t.jsxs("div",{ref:u,className:"relative shrink-0",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),children:[t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":s,onFocus:()=>l(!0),onBlur:()=>l(!1),className:`${kn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}),s&&r.length>0?t.jsx("div",{className:"absolute left-1/2 top-full z-30 mt-1.5 -translate-x-1/2",children:f()}):null]}):null,r.map(p=>t.jsxs("span",{className:`${kn} ${p.className}`,title:`${p.label}: ${p.usdCompactValue}, ${p.tokenRawValue} tokens`,children:[p.icon,t.jsx("span",{className:"thread-token-badge-value font-medium",children:p.tokenCompactValue})]},p.id))]}),t.jsxs("div",{ref:h,className:"relative shrink-0 md:hidden",children:[n?t.jsx("button",{type:"button","aria-label":"Show token and price details","aria-expanded":a,onClick:()=>o(p=>!p),className:`${kn} appearance-none whitespace-nowrap bg-transparent !text-[10px] !font-normal !leading-none transition hover:bg-[var(--theme-hover)] sm:!text-[11px] ${n.className}`,title:n.title,children:n.label}):null,a&&r.length>0?t.jsx("div",{ref:m,className:"absolute left-1/2 top-full z-30 mt-1.5",style:{transform:`translateX(${i}px) translateX(-50%)`},children:f()}):null]})]})}function Sf({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 js(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 Tf(e){switch(e.kind){case"fileChange":case"webSearch":case"image":case"contextCompaction":return!0;case"commandExecution":case"toolCall":return!dl(e.status);default:return!1}}function Ef(e,r,n){if(!e||!fr(n))return e;const a=e.plan.findIndex(i=>js(i.status)==="in_progress");if(a<0)return e;const o=e.plan.findIndex((i,d)=>d>a&&js(i.status)==="pending");if(o<0||!r.some(i=>Tf(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 Lf(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 Ns({status:e}){const r=nl(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(Sf,{tone:"emerald"})})}function Cs({turn:e,variant:r="header"}){const n=nl(e.status),a=Lf(e),o=Nf(e),s=bl(e),l=fr(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(Ns,{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:Ft(e.startedAt),className:"timeline-meta-text shrink-0 text-[11px]",children:gt(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(Ns,{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 la=c.memo(function({threadId:r,item:n,scrollRootRef:a,onOpenExpandedText:o,onOpenCommandDetail:s,onOpenToolCallDetail:l,onOpenDeferredHistoryItemDetail:i,onSelectArtifact:d,onBeforeMessageResize:h,adapter:u,timeLabel:m,timeTitle:f,timeMeta:p,autoOpenToolDetails:g=!1}){var v,b,x;if(Pp(n.kind))return t.jsx(Lt,{threadId:r,item:n,scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{},...u?{adapter:u}:{}});if(n.kind==="reasoning")return t.jsx(Lt,{item:{...n,kind:"agentMessage",status:n.status??null},scrollRootRef:a,timeLabel:m,timeTitle:f,...h?{onBeforeMessageResize:h}:{}});if(n.kind==="artifact")return t.jsx(cf,{item:n,timeMeta:p,...d?{onSelect:(j,y)=>d({item:j,artifact:y})}:{}});if(n.kind==="commandExecution")return t.jsx(tf,{autoOpen:g,item:n,onOpen:s,timeMeta:p});if(n.kind==="toolCall")return t.jsx(rf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="agentToolCall")return t.jsx(nf,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="skillToolCall")return t.jsx(af,{autoOpen:g,item:n,onOpen:l,timeMeta:p});if(n.kind==="webSearch"){const j=n,y=((v=j.detailText)==null?void 0:v.trim())||j.text||"Web search";return t.jsx(sf,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"Web Search Details",y,"Loading full web search details...","Unable to load full web search details.")})}if(n.kind==="fileRead"){const j=n,y=((b=j.detailText)==null?void 0:b.trim())||j.text||"File read";return t.jsx(of,{autoOpen:g,item:j,timeMeta:p,onOpen:()=>i(j,"File Read Details",y,"Loading full file read details...","Unable to load full file read details.")})}if(n.kind==="image")return t.jsx(lf,{threadId:r,item:n,onOpen:o,getImageAssetUrl:u==null?void 0:u.getImageAssetUrl,timeMeta:p});if(n.kind==="plan")return t.jsx(Jp,{item:n,scrollRootRef:a,timeMeta:p,...h?{onBeforeResize:h}:{}});if(n.kind==="fileChange"){const j=n,y=((x=j.detailText)==null?void 0:x.trim())||j.text||"File change";return t.jsx(df,{item:j,timeMeta:p,onOpen:()=>i(j,"File Change Details",y,"Loading full file change details...","Unable to load full file change details.")})}return n.kind==="contextCompaction"?t.jsx(Qp,{item:n,timeMeta:p}):n.kind==="hook"?t.jsx(hf,{item:n,timeMeta:p}):t.jsx(ef,{item:n,timeMeta:p})});function Ss(e){return e==="completed"||e==="failed"||e==="interrupted"}function If(e){const r=Date.parse(e.createdAt??"");return Number.isFinite(r)?r:null}function zf(e){let r=null;for(const n of e){const a=If(n);a!==null&&(r=r===null?a:Math.max(r,a))}return r}function Rf(e,r){const n=Date.parse(e??""),a=zf(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 Af(e,r){const n=Date.parse(e??""),a=Date.parse(r??"");if(!Number.isFinite(n)||!Number.isFinite(a))return r?gt(r):"Time unavailable";const o=Math.max(0,Math.round((a-n)/1e3)),s=Math.floor(o/3600),l=Math.floor(o%3600/60),i=o%60;return s>0?`${s}h ${l}m`:l>0?`${l}m ${i}s`:`${i}s`}function xr({absoluteLabel:e,className:r="",timestamp:n,turnStartedAt:a}){const[o,s]=c.useState(!1);if(!n)return null;const l=Ft(n),i=Af(a,n),d=o?e:i;return t.jsx("span",{role:"button",tabIndex:0,className:`thread-graph-relative-time rounded-full px-1.5 py-0.5 text-[10px] leading-none transition sm:text-[11px] ${r}`,title:o?i:l,"aria-label":`Toggle timestamp, currently ${d}`,onClick:h=>{h.stopPropagation(),s(u=>!u)},onKeyDown:h=>{h.key!=="Enter"&&h.key!==" "||(h.preventDefault(),h.stopPropagation(),s(u=>!u))},children:t.jsx("time",{dateTime:n,children:d})})}function Rr(e){var r;return e.kind==="item"?e.item.createdAt??null:((r=e.items.find(n=>n.createdAt))==null?void 0:r.createdAt)??null}function _f(e){const r=e.filter(s=>s.kind==="item"),n=r.map(s=>s.item).filter(s=>s.kind==="userMessage"),a=r.map(s=>s.item).reverse().find(s=>s.kind==="agentMessage"&&s.text.trim().length>0),o=e.filter(s=>s.kind!=="item"?!0:s.item.kind!=="userMessage"&&s.item.id!==(a==null?void 0:a.id));return{users:n,finalAgent:a,hiddenEntries:o}}var wn=c.memo(function({threadId:r,adapter:n,turn:a,absoluteIndex:o,isCollapsed:s,livePlan:l,liveItems:i,liveOutput:d,forceActive:h=!1,onToggleCollapse:u,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,onSelectArtifact:v,onBeforeMessageResize:b,scrollRootRef:x,articleRef:j,isLatestVisibleTurn:y=!1}){const w=!!l||!!d||!!(i&&i.length>0),k=h||fr(a.status)||w||y,N=k&&!fr(a.status)?{...a,status:"inProgress"}:a,C=c.useMemo(()=>Ap(a.items,i),[i,a.items]),E=c.useMemo(()=>Ef(l,C,a.status),[l,C,a.status]),z=c.useMemo(()=>_p(d,C),[d,C]),q=c.useMemo(()=>Rp(C,k),[k,C]),D=c.useMemo(()=>Mp(q),[q]),$=h||fr(a.status)||w,Q=gt(a.startedAt),Z=Ft(a.startedAt),B=c.useMemo(()=>il(z),[z]),[ee,oe]=c.useState({}),A=c.useCallback(X=>{oe(ce=>({...ce,[X]:!ce[X]}))},[]),J=t.jsx(Mf,{entries:D,expandedGroups:ee,onToggleGroupedItem:A,threadId:r,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,...b?{onBeforeMessageResize:b}:{},fallbackTimestamp:a.startedAt,fallbackTimeLabel:Q,fallbackTimeTitle:Z,turnStartedAt:a.startedAt,autoOpenLatestToolDetails:$,...v?{onSelectArtifact:v}:{},...n?{adapter:n}:{}}),R=B?t.jsx(la,{threadId:r,item:B,scrollRootRef:x,onOpenExpandedText:m,onOpenCommandDetail:f,onOpenToolCallDetail:p,onOpenDeferredHistoryItemDetail:g,timeLabel:a.startedAt?t.jsx(xr,{absoluteLabel:Q,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Q,timeTitle:Z,timeMeta:null,...v?{onSelectArtifact:v}:{},...n?{adapter:n}:{}}):null,Y=!B&&z?t.jsx(Lt,{item:{id:"live-agent-message",kind:"agentMessage",text:z},scrollRootRef:x,timeLabel:a.startedAt?t.jsx(xr,{absoluteLabel:Q,timestamp:a.startedAt,turnStartedAt:a.startedAt}):Q,timeTitle:Z,streaming:!0,...b?{onBeforeMessageResize:b}:{}}):null,H=k?t.jsx(Cs,{turn:N,variant:"footer"}):null,T=c.useMemo(()=>_f(D),[D]),O=c.useMemo(()=>Rf(a.startedAt,C),[C,a.startedAt]),G=T.hiddenEntries.length>0,L=s&&G,V=Ss(a.status)&&G&&!L?t.jsxs("button",{type:"button",className:"thread-graph-worked-summary group flex w-full items-center gap-2 py-2 text-left text-sm transition",onClick:()=>u(a.id,!1),"aria-label":`${O}. Collapse turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:O}),t.jsx(M.ChevronDown,{className:"h-4 w-4 shrink-0 transition group-hover:translate-y-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}):null,K=Ss(a.status)&&G?t.jsxs("div",{className:"thread-graph-turn-collapsed-summary space-y-2",children:[T.users.map(X=>t.jsx(Lt,{threadId:r,item:X,scrollRootRef:x,timeLabel:X.createdAt?gt(X.createdAt):Q,timeTitle:X.createdAt?Ft(X.createdAt):Z,...b?{onBeforeMessageResize:b}:{},...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":`${O}. Expand turn ${o}`,children:[t.jsx("span",{className:"thread-graph-worked-label shrink-0",children:O}),t.jsx(M.ChevronRight,{className:"h-4 w-4 shrink-0 transition group-hover:translate-x-0.5"}),t.jsx("span",{className:"thread-graph-worked-rule h-px min-w-0 flex-1","aria-hidden":"true"})]}),T.finalAgent?t.jsx(Lt,{threadId:r,item:T.finalAgent,scrollRootRef:x,timeLabel:T.finalAgent.createdAt?t.jsx(xr,{absoluteLabel:gt(T.finalAgent.createdAt),timestamp:T.finalAgent.createdAt,turnStartedAt:a.startedAt}):Q,timeTitle:T.finalAgent.createdAt?Ft(T.finalAgent.createdAt):Z,...b?{onBeforeMessageResize:b}:{},...n?{adapter:n}:{}}):null]}):null,le=t.jsx(vf,{footer:H,history:t.jsxs(t.Fragment,{children:[V,J]}),liveHookPrompt:R,liveOutput:Y,livePlan:E});return t.jsx(kf,{absoluteIndex:o,body:le,collapsed:L,collapsedBody:K,error:a.error,headerStatus:t.jsx(Cs,{turn:a}),isActive:k,refCallback:j,startedAt:a.startedAt,timeLabel:Q,timeTitle:Z,tokenSummary:t.jsx(Cf,{turn:a})})});function Mf({entries:e,expandedGroups:r,onToggleGroupedItem:n,threadId:a,scrollRootRef:o,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,onSelectArtifact:h,onBeforeMessageResize:u,adapter:m,fallbackTimestamp:f,fallbackTimeLabel:p,fallbackTimeTitle:g,turnStartedAt:v,autoOpenLatestToolDetails:b=!1}){var y;const x=((y=e.at(-1))==null?void 0:y.key)??null,j=c.useCallback(w=>w?t.jsx(xr,{absoluteLabel:gt(w),timestamp:w,turnStartedAt:v??f}):null,[f,v]);return t.jsx(Fp,{entries:e,expandedGroups:r,onToggleGroupedItem:n,renderCommandGroup:(w,k,N)=>t.jsx(uf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:l,timeMeta:j(Rr(w))},w.key),renderFileChangeGroup:(w,k,N)=>t.jsx(ff,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:s,timeMeta:j(Rr(w))},w.key),renderSearchGroup:(w,k,N)=>t.jsx(mf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:s,timeMeta:j(Rr(w))},w.key),renderFileReadGroup:(w,k,N)=>t.jsx(pf,{items:w.items,expanded:k,onToggleExpanded:N,onOpen:s,timeMeta:j(Rr(w))},w.key),renderItem:w=>{const k=Pf(w.item,f??null),C=w.item.kind==="userMessage"?w.item.createdAt?gt(k):p:w.item.createdAt?t.jsx(xr,{absoluteLabel:gt(k),timestamp:k,turnStartedAt:v??f}):p;return t.jsx(la,{threadId:a,item:w.item,scrollRootRef:o,timeLabel:C,timeTitle:w.item.createdAt?Ft(k):g,timeMeta:j(k),autoOpenToolDetails:b&&w.key===x,onOpenExpandedText:s,onOpenCommandDetail:l,onOpenToolCallDetail:i,onOpenDeferredHistoryItemDetail:d,...u?{onBeforeMessageResize:u}:{},...h?{onSelectArtifact:h}:{},...m?{adapter:m}:{}},w.key)}})}var Ts=3,$f=3,Un=80;function ur(e,r=Un){return e.scrollHeight-e.scrollTop-e.clientHeight<=r}function Df(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 Bf(e){return e.map(n=>{const a=n.createdAt;return typeof a=="string"&&a.trim()?a:null}).filter(n=>!!n).sort()[0]??null}function Gf(e,r){return{id:e,startedAt:Bf(r),status:"inProgress",error:null,model:null,reasoningEffort:null,reasoningEffortAvailable:null,tokenUsage:null,priceEstimate:null,items:[]}}function Es(e,r,n){return{id:e.id,kind:e.kind,title:r,text:n}}function Ff({loadHistoryItemDetail:e,onSelectHistoryItemDetail:r}){const n=c.useRef(0),a=c.useRef(new Map),[o,s]=c.useState(null),l=c.useCallback((p,g)=>{s({title:p,text:g})},[]),i=c.useCallback((p,g,v)=>{if(v&&r){r({item:p,detail:g});return}s({title:g.title,text:g.text})},[r]),d=c.useCallback(async({item:p,fallbackTitle:g,fallbackText:v,loadingText:b,errorText:x,useSelectionCallback:j})=>{if(!p.hasDeferredDetail||!e){i(p,Es(p,g,v),j);return}const y=a.current.get(p.id);if(y){i(p,y,j);return}const w=n.current+1;n.current=w,j&&r||s({title:g,text:b});try{const k=await e(p.id);if(a.current.set(p.id,k),n.current!==w)return;i(p,k,j)}catch(k){if(n.current!==w)return;i(p,Es(p,g,k instanceof Error?k.message:x),j)}},[e,r,i]),h=c.useCallback(async(p,g)=>{var v;await d({item:p,fallbackTitle:g,fallbackText:((v=p.detailText)==null?void 0:v.trim())||p.text||"Command output",loadingText:"Loading full command output...",errorText:"Unable to load full command output.",useSelectionCallback:!0})},[d]),u=c.useCallback(async(p,g)=>{var v;await d({item:p,fallbackTitle:g,fallbackText:((v=p.detailText)==null?void 0:v.trim())||p.text||"Tool call",loadingText:"Loading full tool call details...",errorText:"Unable to load full tool call details.",useSelectionCallback:!0})},[d]),m=c.useCallback(async(p,g,v,b,x)=>{await d({item:p,fallbackTitle:g,fallbackText:v,loadingText:b,errorText:x,useSelectionCallback:!1})},[d]),f=c.useCallback(()=>{n.current+=1,s(null)},[]);return{expandedText:o,openExpandedText:l,openCommandDetail:h,openToolCallDetail:u,openDeferredHistoryItemDetail:m,closeExpandedText:f}}function Hf(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 Of({threadId:e,turnsLength:r,totalTurnCount:n,loadingEarlier:a,onLoadEarlier:o,scrollRequestKey:s,bottomSpacer:l,onTailVisibilityChange:i,contentRevisionInputs:d}){const h=c.useRef(null),u=c.useRef(null),m=c.useRef(s),f=c.useRef(null),p=c.useRef(l),g=c.useRef(0),v=c.useRef(0),b=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(!0),w=c.useRef(!0),k=c.useRef(!1),N=c.useRef(!1),C=c.useRef(!1),E=c.useRef(!1),z=c.useRef(null),q=c.useRef(0),[D,$]=c.useState(Ts),[Q,Z]=c.useState(0),[B,ee]=c.useState(!0),oe=Hf(d),A=typeof o=="function"||n!==void 0,J=n??r,R=A?0:Math.max(0,r-D),H=(A?Math.max(0,J-r):0)+R,T=A?r:r-R,O=A?0:r-T,G=A?Math.max(0,J-r):0,L=A?G+O:O,S=!A&&L>0&&Q>=2,V=A&&G>0&&O===0&&typeof o=="function",K=c.useCallback(()=>{const W=h.current;if(!W){b.current=null;return}b.current={scrollHeight:W.scrollHeight,scrollTop:W.scrollTop}},[]),le=c.useCallback(()=>!V||a||C.current?!1:(K(),C.current=!0,E.current=!1,q.current=0,o==null||o(),!0),[V,a,o,K]),X=c.useCallback(()=>{const W=h.current,ae=x.current;if(!W)return;const xe=ae?Df(W,ae):ur(W);y.current=xe,ee(ke=>ke===xe?ke:xe)},[]),ce=c.useCallback(()=>{const W=h.current;if(W){N.current=!0;const ae=W.scrollTop,xe=v.current,ke=ae-xe;v.current=ae,ur(W,1)?(k.current=!1,w.current=!0):ke<-1?(k.current=!0,w.current=!1):ke>1&&(w.current=!k.current&&ur(W,Un)),ae<=0&&N.current?E.current=!0:ae>0&&(E.current=!1,q.current=0)}X()},[X]),re=c.useCallback(()=>{const W=h.current;W&&(W.scrollTop=W.scrollHeight,v.current=W.scrollTop,g.current=W.scrollHeight,y.current=!0,ee(ae=>ae||!0),k.current=!1,w.current=!0)},[]),fe=c.useCallback(()=>{const W=h.current;W&&(v.current=W.scrollTop,g.current=W.scrollHeight,w.current=!1,k.current=!0)},[]),he=c.useCallback(()=>{if(A&&O===0){le();return}$(W=>Math.min(r,W+$f)),Z(W=>W+1)},[O,A,le,r]),ve=c.useCallback(W=>{const ae=h.current;if(!(!ae||W.deltaY>=-8||ae.scrollTop>0||!V)){if(!E.current){E.current=!0;return}le()}},[V,le]),Re=c.useCallback(W=>{var ae;z.current=((ae=W.touches.item(0))==null?void 0:ae.clientY)??null,q.current=0},[]),ie=c.useCallback(W=>{var Me;const ae=h.current,xe=((Me=W.touches.item(0))==null?void 0:Me.clientY)??null,ke=z.current;if(z.current=xe,!ae||xe===null||ke===null||ae.scrollTop>0||!V){q.current=0;return}const $e=xe-ke;if($e<=0){q.current=0;return}if(!E.current){E.current=!0,q.current=0;return}q.current+=$e,q.current>=28&&le()},[V,le]),ye=c.useCallback(()=>{z.current=null,q.current=0},[]),Te=c.useCallback(()=>{$(r)},[r]);return c.useLayoutEffect(()=>{const W=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(W)}},[e,re]),c.useEffect(()=>{C.current=!1,N.current=!1,E.current=!1,b.current=null},[e]),c.useEffect(()=>{a||(C.current=!1)},[a,r]),c.useLayoutEffect(()=>{const W=b.current,ae=h.current;if(!W||!ae||a)return;b.current=null;const xe=ae.scrollHeight-W.scrollHeight;if(xe<=0){g.current=ae.scrollHeight,v.current=ae.scrollTop;return}const ke=W.scrollTop+xe;ae.scrollTop=ke,v.current=ke,g.current=ae.scrollHeight,k.current=!0,w.current=!1,E.current=!1},[a,r]),c.useEffect(()=>{$(W=>W>=r-1?r:Math.max(W,Ts))},[r]),c.useEffect(()=>{const W=h.current;W&&(g.current=W.scrollHeight,v.current=W.scrollTop,ur(W,1)?(k.current=!1,w.current=!0):(k.current||!ur(W,Un))&&(w.current=!1)),X()},[oe,X,D]),c.useEffect(()=>{const W=s!==m.current,ae=f.current!==oe;if(f.current=oe,!(W||ae&&w.current&&!k.current))return;const ke=window.requestAnimationFrame(()=>{re()});return s!==m.current&&(m.current=s),()=>{window.cancelAnimationFrame(ke)}},[oe,B,re,s]),c.useEffect(()=>{const W=h.current,ae=u.current;if(!W||!ae||typeof ResizeObserver>"u")return;g.current=W.scrollHeight;const xe=new ResizeObserver(()=>{const ke=W.scrollHeight,$e=g.current;if(g.current=ke,ke<=$e)return;const Me=$e>0&&$e-W.scrollTop-W.clientHeight<=1;k.current||!(w.current||Me||y.current)||window.requestAnimationFrame(()=>{re()})});return xe.observe(ae),()=>{xe.disconnect()}},[re]),c.useEffect(()=>{if(!w.current||k.current){p.current=l;return}if(l===p.current)return;p.current=l;const W=window.requestAnimationFrame(()=>{re()});return()=>{window.cancelAnimationFrame(W)}},[l,re]),c.useEffect(()=>{i==null||i(B)},[B,i]),{scrollContainerRef:h,scrollContentRef:u,tailSentinelRef:x,topSentinelRef:j,isTailVisible:B,handleScroll:ce,handleWheel:ve,handleTouchStart:Re,handleTouchMove:ie,handleTouchEnd:ye,preserveScrollPositionForResize:fe,serverManagedHistory:A,effectiveTotalTurnCount:J,startIndex:R,visibleTurnAbsoluteOffset:H,hiddenCount:L,loadedHiddenCount:O,unloadedHiddenCount:G,showLoadAll:S,handleLoadEarlierClick:he,handleLoadAllClick:Te}}function Wf(e){return e==="completed"||e==="failed"||e==="interrupted"}function Uf(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 Vf({threadId:e,turns:r,totalTurnCount:n,pendingRequests:a=[],activeTurnId:o=null,threadRunning:s=!1,pendingSteers:l=[],livePlan:i=null,liveItems:d=null,respondingRequestId:h=null,onRespondToRequest:u,liveOutput:m,scrollRequestKey:f=0,bottomSpacer:p=0,className:g="",onTailVisibilityChange:v,loadingEarlier:b=!1,onLoadEarlier:x,ephemeralUserNote:j=null,answeredRequestNotes:y=[],activityNotes:w=[],optimisticSteers:k=[],optimisticTurn:N=null,onLoadHistoryItemDetail:C,onOpenThread:E,onSelectArtifact:z,onSelectHistoryItemDetail:q,adapter:D,autoCollapseCompletedTurns:$}){var dt,I,U,pe,Pe;const Q=rl(),Z=$??(Q==null?void 0:Q.autoCollapseCompletedTurns)??!1,[B,ee]=c.useState({}),[oe,A]=c.useState(()=>new Set),J=(D==null?void 0:D.onLoadHistoryItemDetail)??C,R=D==null?void 0:D.onOpenLinkedThread,{expandedText:Y,openExpandedText:H,openCommandDetail:T,openToolCallDetail:O,openDeferredHistoryItemDetail:G,closeExpandedText:L}=Ff({loadHistoryItemDetail:J,onSelectHistoryItemDetail:q}),{scrollContainerRef:S,scrollContentRef:V,tailSentinelRef:K,topSentinelRef:le,handleScroll:X,handleWheel:ce,handleTouchStart:re,handleTouchMove:fe,handleTouchEnd:he,preserveScrollPositionForResize:ve,serverManagedHistory:Re,effectiveTotalTurnCount:ie,startIndex:ye,visibleTurnAbsoluteOffset:Te,hiddenCount:W,loadedHiddenCount:ae,unloadedHiddenCount:xe,showLoadAll:ke,handleLoadEarlierClick:$e,handleLoadAllClick:Me}=Of({threadId:e,turnsLength:r.length,totalTurnCount:n,loadingEarlier:b,onLoadEarlier:x,scrollRequestKey:f,bottomSpacer:p,onTailVisibilityChange:v,contentRevisionInputs:[r,a,l,k,m,i,d,N,y,w,j,p]}),je=c.useCallback((te,He)=>{ee(We=>({...We,[te]:!He}))},[]),De=c.useCallback((te,He)=>{const We=B[te.id];return We!==void 0?We:!!(Z&&Wf(te.status)&&!He.forceActive&&!He.hasLiveActivity)},[B,Z]),F=Re?r:r.slice(ye),de=ie+1,we=s&&(!o||!F.some(te=>te.id===o)&&(N==null?void 0:N.id)!==o),P=(N==null?void 0:N.id)??((dt=F.at(-1))==null?void 0:dt.id)??null,_=we&&P!==null,se=!!d&&(F.some(te=>te.id===d.turnId)||(N==null?void 0:N.id)===d.turnId),ge=d&&se?d.turnId:d&&_?P:null,Ne=N&&ge===N.id?(d==null?void 0:d.items)??null:null,Ae=((d==null?void 0:d.items.length)??0)>0,Se=d&&ge===null?d.items:null,Be=c.useMemo(()=>d&&ge===null&&d.items.length>0?Gf(d.turnId,d.items):null,[d,ge]),Ue=Math.max(1,ie+(N?1:0)),at=!!m&&!!N&&N.status!=="failed"&&!Ne,et=m&&F.length>0?o&&F.some(te=>te.id===o)?o:((I=F.findLast(te=>dl(te.status)))==null?void 0:I.id)??(_?P:null):null,tt=!!et,rt=c.useMemo(()=>il(m),[m]),it=[...l.map(te=>({id:te.id,prompt:te.prompt,status:"Accepted",createdAt:te.createdAt,canCancel:!0})),...k.map(te=>({id:te.id,prompt:te.prompt,status:te.status==="steering"?"Steering":null,createdAt:te.createdAt,canCancel:!1}))].sort((te,He)=>te.createdAt.localeCompare(He.createdAt)),_e=c.useMemo(()=>$p({answeredRequestNotes:y,pendingRequests:a,visibleTurns:F,optimisticTurn:N}),[y,N,a,F]),Fe=c.useMemo(()=>Dp({activityNotes:w,visibleTurns:F,optimisticTurn:N}),[w,N,F]);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:S,"data-testid":"thread-scroll-container",onScroll:X,onWheel:ce,onTouchStart:re,onTouchMove:fe,onTouchEnd:he,onTouchCancel:he,className:"thread-graph-scroll-container min-h-0 flex-1 overflow-y-auto overscroll-contain",style:p>0?{paddingBottom:p}:void 0,children:t.jsxs("div",{ref:V,className:"thread-graph-scroll-content",children:[t.jsx("div",{ref:le,"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:[W>0&&t.jsx("button",{type:"button",onClick:$e,disabled:b,className:"thread-graph-history-button rounded-full border px-2.5 py-1.5 transition",children:b?"Loading earlier...":"Load 3 earlier"}),ke&&t.jsx("button",{type:"button",onClick:Me,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 ",F.length," of ",ie," turns",W>0?` · ${W} earlier hidden${ae>0&&xe>0?` (${ae} loaded)`:""}`:""]})]})}),r.length===0&&!m&&!N&&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."}),(F.length>0||N||Fe.leading.length>0||Fe.trailing.length>0)&&t.jsxs("div",{className:"thread-graph-message-list",children:[Fe.leading.length>0?t.jsx(cr,{notes:Fe.leading,onOpenThread:E,onOpenLinkedThread:R}):null,F.map((te,He)=>{var We,Oe,qe,ct,bt;return t.jsxs("div",{children:[(((We=Fe.beforeTurnId.get(te.id))==null?void 0:We.length)??0)>0?t.jsx(cr,{notes:Fe.beforeTurnId.get(te.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null,(((Oe=_e.beforeTurnId.get(te.id))==null?void 0:Oe.length)??0)>0?t.jsx(On,{entries:_e.beforeTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const st=Uf(te,N),yt=(i==null?void 0:i.turnId)===te.id?i:null,jt=ge===te.id?(d==null?void 0:d.items)??null:null,Nt=et===te.id?m:"",be=o===te.id||_&&P===te.id,Ie=!!yt||!!Nt||!!(jt&&jt.length>0),ot=De(st,{forceActive:be,hasLiveActivity:Ie});return t.jsx(wn,{threadId:e,...D?{adapter:D}:{},turn:st,absoluteIndex:Te+He+1,isCollapsed:ot,livePlan:yt,liveItems:jt,liveOutput:Nt,forceActive:be,onToggleCollapse:je,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...z?{onSelectArtifact:z}:{},scrollRootRef:S,articleRef:void 0})})(),(((qe=Fe.afterTurnId.get(te.id))==null?void 0:qe.length)??0)>0?t.jsx(cr,{notes:Fe.afterTurnId.get(te.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null,(ct=_e.notesByTurnId.get(te.id))!=null&&ct.length||(bt=_e.pendingRequestsByTurnId.get(te.id))!=null&&bt.length?t.jsx(Bp,{notes:_e.notesByTurnId.get(te.id)??[],requests:_e.pendingRequestsByTurnId.get(te.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null]},te.id)}),N&&F.every(te=>te.id!==N.id)&&t.jsxs(t.Fragment,{children:[(((U=Fe.beforeTurnId.get(N.id))==null?void 0:U.length)??0)>0?t.jsx(cr,{notes:Fe.beforeTurnId.get(N.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null,(((pe=_e.beforeTurnId.get(N.id))==null?void 0:pe.length)??0)>0?t.jsx(On,{entries:_e.beforeTurnId.get(N.id)??[],respondingRequestId:h,onRespondToRequest:u??void 0}):null,(()=>{const te=at?m:"",He=o===N.id||_&&P===N.id,We=!!(Ne&&Ne.length>0)||!!te,Oe=De(N,{forceActive:He,hasLiveActivity:We});return t.jsx(wn,{threadId:e,...D?{adapter:D}:{},turn:N,absoluteIndex:de,isCollapsed:Oe,livePlan:null,liveItems:Ne,liveOutput:te,forceActive:He,onToggleCollapse:je,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...z?{onSelectArtifact:z}:{},scrollRootRef:S})})(),(((Pe=Fe.afterTurnId.get(N.id))==null?void 0:Pe.length)??0)>0?t.jsx(cr,{notes:Fe.afterTurnId.get(N.id)??[],onOpenThread:E,onOpenLinkedThread:R}):null]})]}),it.length>0&&t.jsx("div",{className:"thread-graph-message-section space-y-3 px-3 py-4 sm:px-5",children:it.map(te=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(Lt,{threadId:e,item:{id:te.id,kind:"userMessage",text:te.prompt,status:te.status},scrollRootRef:S,onBeforeMessageResize:ve,...D?{adapter:D}:{}}),e&&te.canCancel&&(D!=null&&D.cancelPendingSteer)?t.jsx("div",{className:"flex justify-end px-1",children:t.jsx("button",{type:"button",className:"thread-graph-history-button rounded-full border px-2.5 py-1 text-xs transition disabled:cursor-not-allowed disabled:opacity-60",disabled:oe.has(te.id),onClick:()=>{var He;A(We=>new Set(We).add(te.id)),Promise.resolve((He=D.cancelPendingSteer)==null?void 0:He.call(D,e,te.id)).catch(()=>{}).finally(()=>{A(We=>{const Oe=new Set(We);return Oe.delete(te.id),Oe})})},children:oe.has(te.id)?"Canceling...":"Cancel"})}):null]},te.id))}),(_e.trailing.length>0||Fe.trailing.length>0)&&t.jsx(Gp,{entries:[...Fe.trailing.map(te=>({kind:"activity",id:te.id,createdAt:te.createdAt,note:te})),..._e.trailing],respondingRequestId:h,onRespondToRequest:u??void 0,onOpenThread:E,onOpenLinkedThread:R}),j&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:t.jsx(Lt,{threadId:e,item:{id:"ephemeral-plan-decision-note",kind:"userMessage",text:j},scrollRootRef:S,onBeforeMessageResize:ve})}),Be&&Se&&Se.length>0&&t.jsx(wn,{threadId:e,...D?{adapter:D}:{},turn:Be,absoluteIndex:Ue,isCollapsed:B[Be.id]??!1,livePlan:(i==null?void 0:i.turnId)===Be.id?i:null,liveItems:Se,liveOutput:"",forceActive:!0,onToggleCollapse:je,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...z?{onSelectArtifact:z}:{},scrollRootRef:S}),m&&!tt&&!at&&!Ae&&t.jsx("div",{className:"thread-graph-message-section px-3 py-2.5 sm:px-5",children:rt?t.jsx(la,{threadId:e,item:rt,scrollRootRef:S,onOpenExpandedText:H,onOpenCommandDetail:T,onOpenToolCallDetail:O,onOpenDeferredHistoryItemDetail:G,onBeforeMessageResize:ve,...z?{onSelectArtifact:z}:{},...D?{adapter:D}:{}}):t.jsx(Lt,{threadId:e,item:{id:"live-agent-message-fallback",kind:"agentMessage",text:m},scrollRootRef:S,streaming:!0,onBeforeMessageResize:ve,...D?{adapter:D}:{}})}),t.jsx("div",{ref:K,"aria-hidden":"true",className:"h-px w-full"})]})})}),t.jsx(tp,{open:Y!==null,title:(Y==null?void 0:Y.title)??"Full text",text:(Y==null?void 0:Y.text)??"",onClose:L})]})}var vl=c.memo(Vf);function Kf(e){return/^[a-z]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)-64):null}function Vn(e){return e.replace(/\r\n/g,`
|
|
3667
|
+
`)}function Ls(e){const r=Vn(e),n=r.split(`
|
|
3668
3668
|
`);return r.endsWith(`
|
|
3669
|
-
`)&&n.at(-1)===""&&n.pop(),n}function qf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Xf(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 Yf(e,r,n){var d,h;const a=
|
|
3670
|
-
`).trimEnd()}function Zf(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function Ls(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function kn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function tn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ia(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function wn(e){return Math.min(75,Math.max(25,e))}function Jf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Qf({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function Ps(){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 yn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var eg=120,tg=800,rg=4e3,ng=4500,ag="Shell connection timed out. Reconnecting...";function sg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:ag,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function og({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function lg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function ig({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:lg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function dg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function vl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:o,hasTerminal:s,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||o===e||!s?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:dg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function cg({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:o}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:o?{type:"joinPending"}:{type:"startAttach"}}function hg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function ug({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function mg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function kl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function pg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:kl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function fg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=kl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:o,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:s,shouldCloseSocket:!0,shouldClearSocketRef:l}}function gg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:o}){return o?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function xg(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:ia(n??tn(r),a),isCommandRunning:e.isCommandRunning===!0}}function bg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Vn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:Yf(o.beforeSnapshot,s,o.command)}}function vg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const o=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:o==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:o==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function wl(e,r,n,a,o){const s=r.replace(/\r\n/g,`
|
|
3669
|
+
`)&&n.at(-1)===""&&n.pop(),n}function qf(e){const r=e.trim();return r?/(?:[$%#>])\s*$/.test(r):!1}function Xf(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 Yf(e,r,n){var d,h;const a=Ls(e),o=Ls(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=Xf(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())===""||qf(i.at(-1)??""));)i.pop();return i.join(`
|
|
3670
|
+
`).trimEnd()}function Zf(e){switch(e){case"ctrl_c":return"";case"ctrl_d":return"";case"esc":return"\x1B";case"tab":return" ";case"up":return"\x1B[A";case"down":return"\x1B[B"}}function Ps(e){return{background:e==="light"?"#f2ede5":"#0c1117",foreground:e==="light"?"#3f3a36":"#d6dde6",cursor:e==="light"?"#3f3a36":"#d6dde6",black:e==="light"?"#d8cfc2":"#0f1720",brightBlack:e==="light"?"#8a7f73":"#475569",red:"#f87171",brightRed:"#fb7185",green:e==="light"?"#16a34a":"#86efac",brightGreen:e==="light"?"#22c55e":"#4ade80",yellow:"#fbbf24",brightYellow:"#fcd34d",blue:e==="light"?"#2563eb":"#93c5fd",brightBlue:e==="light"?"#3b82f6":"#60a5fa",magenta:e==="light"?"#7c3aed":"#c4b5fd",brightMagenta:e==="light"?"#8b5cf6":"#a78bfa",cyan:e==="light"?"#0891b2":"#67e8f9",brightCyan:e==="light"?"#06b6d4":"#22d3ee",white:e==="light"?"#5b5148":"#e2e8f0",brightWhite:e==="light"?"#2c2723":"#f8fafc"}}function yn(e){switch(e){case"not_created":return"Not created";case"creating":return"Creating";case"running":return"Running";case"attached":return"Attached";case"detached":return"Detached";case"exited":return"Exited";case"not_found":return"Missing";case"workspace_missing":return"Workspace missing"}}function nn(e){if(!e)return"";const r=e.replace(/[\\/]+$/,"");return r?r.split(/[\\/]/).filter(Boolean).at(-1)??r:""}function ia(e,r){const n=[r==null?void 0:r.trim(),e==null?void 0:e.trim()].filter(Boolean);return n.length>0?n.join(" "):null}function jn(e){return Math.min(75,Math.max(25,e))}function Jf(){return t.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 20 20",className:"h-4 w-4 fill-current",children:[t.jsx("path",{fillRule:"evenodd",d:"M14.5 10C16.9853 10 19 7.98528 19 5.5C19 5.01783 18.9242 4.55338 18.7838 4.11791C18.6792 3.79367 18.2734 3.72683 18.0325 3.96772L15.3402 6.66002C15.2098 6.79041 15.0168 6.84163 14.8466 6.77074C14.1172 6.46695 13.5334 5.88351 13.2292 5.15431C13.1582 4.98403 13.2094 4.79088 13.3398 4.66042L16.0327 1.9676C16.2735 1.72672 16.2067 1.32092 15.8825 1.21636C15.4469 1.07588 14.9823 1 14.5 1C12.0147 1 10 3.01472 10 5.5C10 5.59783 10.0031 5.69494 10.0093 5.79122C10.065 6.66418 9.88174 7.59855 9.20974 8.15855L1.98017 14.1832C1.3591 14.7008 1 15.4674 1 16.2759C1 17.7804 2.21962 19 3.7241 19C4.53256 19 5.29925 18.6409 5.81681 18.0198L11.8414 10.7903C12.4014 10.1183 13.3358 9.93497 14.2088 9.99073C14.3051 9.99688 14.4022 10 14.5 10ZM5 16C5 16.5523 4.55228 17 4 17C3.44772 17 3 16.5523 3 16C3 15.4477 3.44772 15 4 15C4.55228 15 5 15.4477 5 16Z",clipRule:"evenodd"}),t.jsx("path",{d:"M14.5 11.5C14.6731 11.5 14.8445 11.4927 15.0138 11.4783L18.7678 15.2323C19.7441 16.2086 19.7441 17.7915 18.7678 18.7678C17.7915 19.7441 16.2086 19.7441 15.2323 18.7678L10.8216 14.3571L12.9938 11.7505C13.0455 11.6885 13.1413 11.6131 13.3357 11.5552C13.5378 11.4951 13.805 11.468 14.1132 11.4877C14.2413 11.4959 14.3702 11.5 14.5 11.5Z"}),t.jsx("path",{d:"M6.00003 4.58582L8.33056 6.91635C8.3027 6.95627 8.27496 6.98497 8.24946 7.00622L6.79994 8.21415L4.58582 6.00003H3.30905C3.11966 6.00003 2.94653 5.89303 2.86184 5.72364L1.1612 2.32237C1.06495 2.12987 1.10268 1.89739 1.25486 1.74521L1.74521 1.25486C1.89739 1.10268 2.12987 1.06495 2.32237 1.1612L5.72364 2.86184C5.89303 2.94653 6.00003 3.11966 6.00003 3.30905V4.58582Z"})]})}function Qf({connected:e}){return e?t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.19 8.688a4.5 4.5 0 0 1 1.242 7.244l-4.5 4.5a4.5 4.5 0 0 1-6.364-6.364l1.757-1.757m13.35-.622 1.757-1.757a4.5 4.5 0 0 0-6.364-6.364l-4.5 4.5a4.5 4.5 0 0 0 1.242 7.244"})}):t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 24 24",className:"h-4.5 w-4.5 fill-none stroke-current",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M13.181 8.68a4.503 4.503 0 0 1 1.903 6.405m-9.768-2.782L3.56 14.06a4.5 4.5 0 0 0 6.364 6.365l3.129-3.129m5.614-5.615 1.757-1.757a4.5 4.5 0 0 0-6.364-6.365l-4.5 4.5c-.258.26-.479.541-.661.84m1.903 6.405a4.495 4.495 0 0 1-1.242-.88 4.483 4.483 0 0 1-1.062-1.683m6.587 2.345 5.907 5.907m-5.907-5.907L8.898 8.898M2.991 2.99 8.898 8.9"})})}function Is(){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 Nn({label:e,tone:r="stone"}){const n=r==="rose"?"border-rose-300/35 bg-rose-300/14 text-rose-600 dark:text-rose-50":r==="sky"?"border-sky-300/35 bg-sky-300/14 text-sky-600 dark:text-sky-50":"shell-control-chip border";return t.jsx("span",{className:`inline-flex min-w-[3.45rem] items-center justify-center rounded-full border px-2.5 py-1.5 text-[11px] font-medium tracking-[0.12em] ${n}`,children:e})}var eg=120,tg=800,rg=4e3,ng=4500,ag="Shell connection timed out. Reconnecting...";function sg({isCurrentSocket:e,viewerId:r}){return!e||r?null:{connectionError:ag,isConnecting:!1,settleAttachPromise:!1,closeSocket:!0}}function og({isCurrentSocket:e,shellId:r,attachSize:n}){return e?{message:{type:"shell.attach",shellId:r,cols:n.cols,rows:n.rows},shouldScheduleAttachTimeout:!0}:null}function lg({intentionalDisconnect:e,userDisconnectedShellId:r,shellId:n}){return!e&&r!==n}function ig({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o}){return e?{shouldDetachShell:r,shouldScheduleReconnect:lg({intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o})}:null}function dg({hasAttachSize:e,hasPendingRetry:r}){return!e&&!r}function kl({shellId:e,terminalReady:r,isVisible:n,canAttachShell:a,userDisconnectedShellId:o,hasTerminal:s,attachSize:l,hasPendingAttachRetry:i,hasCurrentSocketForShell:d,hasReconnectTimer:h}){return!e||!r||!n||!a||o===e||!s?{type:"skip"}:l===void 0?{type:"measureSize"}:l?d?{type:"reuseSocket",shouldClearAttachRetry:i}:{type:"startAttach",attachSize:l,shouldClearAttachRetry:i,shouldClearReconnectTimer:h}:dg({hasAttachSize:!1,hasPendingRetry:i})?{type:"scheduleRetry"}:{type:"skip"}}function cg({hasShellId:e,terminalReady:r,workspacePathMissing:n,hasViewer:a,hasPendingAttach:o}){return!e||!r||n?{type:"reject"}:a?{type:"alreadyConnected"}:o?{type:"joinPending"}:{type:"startAttach"}}function hg({shellId:e,userDisconnectedShellId:r}){return{shouldClearUserDisconnectedShellId:!!e&&r===e,intentionalDisconnect:!1,connectionError:null,isConnecting:!0,shouldIncrementReconnectKey:!0}}function ug({hasShell:e}){return e?null:{viewerId:null,isConnecting:!1,settleAttachPromise:!1,connectionError:null,runtimePromptLabel:null,isCommandRunning:!1,shellSnapshot:"",lastCommandOutput:"",pendingCommand:null,shouldResetTerminal:!0}}function mg({hasReconnectTimer:e,hasAttachTimeout:r,hasAttachRetry:n}){return{shouldClearReconnectTimer:e,shouldClearAttachTimeout:r,shouldClearAttachRetry:n,settleAttachPromise:!1}}function wl({shellId:e,viewerId:r}){return e&&r?{type:"shell.detach",shellId:e,viewerId:r}:null}function pg({shellId:e,viewerId:r,hasSocket:n}){return{userDisconnectedShellId:e,intentionalDisconnect:!0,detachMessage:wl({shellId:e,viewerId:r}),shouldCloseSocket:n,shouldClearSocketRef:!0,shouldClearLastSentSize:!0,shouldDetachShell:!!e}}function fg({shellId:e,viewerId:r,socketReadyState:n,openReadyState:a,hasAttachRetryTimer:o,hasAttachTimeout:s,isCurrentSocket:l}){const i=wl({shellId:e,viewerId:r});return{intentionalDisconnect:!0,shouldClearAttachRetry:o,detachMessage:i,shouldSendDetachMessage:!!(i&&n===a),shouldClearViewer:!0,isConnecting:!1,settleAttachPromise:l?!1:void 0,shouldClearAttachTimeout:s,shouldCloseSocket:!0,shouldClearSocketRef:l}}function gg({size:e,previousSize:r,shellId:n,viewerId:a,syncBackendSize:o}){return o?(r==null?void 0:r.cols)===e.cols&&r.rows===e.rows?{nextLastSentSize:r,message:null}:{nextLastSentSize:e,message:n&&a?{type:"shell.resize",shellId:n,viewerId:a,cols:e.cols,rows:e.rows}:null}:{nextLastSentSize:r??e,message:null}}function xg(e,r){const n=typeof e.cwdBaseName=="string"?e.cwdBaseName:null,a=typeof e.envPrefix=="string"?e.envPrefix:null;return{data:typeof e.data=="string"?e.data:"",replace:e.replace===!0,cursorX:typeof e.cursorX=="number"?e.cursorX:void 0,cursorY:typeof e.cursorY=="number"?e.cursorY:void 0,paneHeight:typeof e.paneHeight=="number"?e.paneHeight:void 0,promptLabel:ia(n??nn(r),a),isCommandRunning:e.isCommandRunning===!0}}function bg({currentSnapshot:e,data:r,replace:n,isCommandRunning:a,pendingCommand:o}){if(!r)return{nextSnapshot:e,nextPendingCommand:o,lastCommandOutput:null};const s=Vn(n?r:`${e}${r}`);return!n||a||!o?{nextSnapshot:s,nextPendingCommand:o,lastCommandOutput:null}:{nextSnapshot:s,nextPendingCommand:null,lastCommandOutput:Yf(o.beforeSnapshot,s,o.command)}}function vg({event:e,currentViewerId:r}){if(e.type==="shell.output")return null;if(e.type==="shell.connected"){const a=String(e.payload.viewerId??"");return{viewerId:a||null,isConnecting:!1,settleAttachPromise:!!a,isCommandRunning:void 0,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:"attached",attachedViewerId:a}}}if(e.type==="shell.error")return{viewerId:void 0,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:void 0,connectionError:String(e.payload.message??"Shell connection failed."),intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:e.payload.code==="viewer_conflict"?{status:"detached",attachedViewerId:null}:void 0};if(e.type==="shell.detached"){const a=String(e.payload.viewerId??"");if(!a||a!==r)return null;const o=String(e.payload.reason??"");return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:o==="replaced"?"This shell connection was taken over by another pane or device.":null,intentionalDisconnect:o==="replaced"?!0:void 0,closeSocket:!0,shellUpdate:{status:"detached",attachedViewerId:null}}}if(e.type==="shell.exited")return{viewerId:null,isConnecting:!1,settleAttachPromise:!1,isCommandRunning:!1,connectionError:void 0,intentionalDisconnect:!0,closeSocket:!0,shellUpdate:{status:e.payload.state==="exited"?"exited":"not_found",attachedViewerId:null}};const n=e.payload.state;return{viewerId:n==="attached"?void 0:null,isConnecting:n==="attached"?void 0:!1,settleAttachPromise:n==="attached"?void 0:!1,isCommandRunning:n==="attached"?void 0:!1,connectionError:void 0,intentionalDisconnect:void 0,closeSocket:!1,shellUpdate:{status:n,attachedViewerId:n==="attached"?void 0:null}}}function yl(e,r,n,a,o){const s=r.replace(/\r\n/g,`
|
|
3671
3671
|
`),l=s.split(`
|
|
3672
3672
|
`);s.endsWith(`
|
|
3673
3673
|
`)&&l.at(-1)===""&&l.pop();let d=l.join(`\r
|
|
3674
3674
|
`);if(n!==void 0&&a!==void 0){const u=(o!==void 0?Math.max(0,l.length-o):0)+a,m=Math.max(0,l.length-u-1);m>0&&(d+=`\x1B[${m}A`),d+=`\r\x1B[${n+1}G`}e.reset(),e.write(d,()=>{e.scrollToBottom()})}function zs(e){return e?Array.from(e.querySelectorAll(".xterm-rows > div")).map(n=>n.textContent??"").filter((n,a,o)=>n.length>0||a<o.length-1).join(`
|
|
3675
|
-
`).trimEnd():""}function kg({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 Is={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function ft(e){return e.status!=="exited"&&e.status!=="not_found"}function wg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&ft(e))}function yg(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 jg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&ft(r)):null)??(e.shell&&ft(e.shell)?e.shell:null)??e.shells.find(ft)??null}function Ng({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&&!ft(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&&!ft(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 Cg({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?ia(tn(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Bt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Sg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=eg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Tg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=tg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Eg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=rg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=sg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(o(d.connectionError),s(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Lg(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 fg({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 zg({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&&Bt(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Lg,"detached"),u.shouldScheduleReconnect&&Tg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function Ig({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Bt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Bt(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Rg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Ag(e){return vl({...e,attachSize:void 0})}function _g({attachSize:e,...r}){return vl({...r,attachSize:e})}function Mg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=og({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function $g(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function Dg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=xg(e.payload,r),s=o.data?bg({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function Bg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=ig({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 Gg(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 Fg(e){return e.current}function Hg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:v,pendingCommandRef:b,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:w,setViewerId:k,setIsConnecting:N,setConnectionError:C,setRuntimePromptLabel:E,setIsCommandRunning:I,settleAttachPromise:q,onShellUpdate:D}){const $=e==null?void 0:e.id,Q=e==null?void 0:e.cwd;c.useEffect(()=>{const Z=s.current,B={shellId:$??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Z,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===$),hasReconnectTimer:h.current!==null};if(Ag(B).type==="skip")return;const oe=y.current(),A=_g({...B,attachSize:oe});if(A.type==="skip"||A.type==="measureSize")return;if(A.type==="scheduleRetry"){Sg({attachRetryTimerRef:m,setReconnectKey:w});return}if(A.shouldClearAttachRetry&&Bt(m),A.type==="reuseSocket"||(A.shouldClearReconnectTimer&&Bt(h),!$||!Z))return;const J=A.attachSize;d.current=$,Z.reset(),C(null),k(null),N(!0),p.current=!1;const R=r.connectSocket({onConnected:()=>{var O;const Y=u.current,H=Mg({isCurrentSocket:((O=l.current)==null?void 0:O.socket)===R.socket,shellId:$,attachSize:J,hasAttachTimeout:Y!==null}),T=H.openAction;T&&(R.send(T.message),H.shouldClearAttachTimeout&&Y!==null&&Bt(u),T.shouldScheduleAttachTimeout&&Eg({shellSocket:R,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:C,setIsConnecting:N,settleAttachPromise:q}))},onShellEvent:Y=>{var O;if(!Rg({eventShellId:Y.shellId,shellId:$,socketExists:!!R.socket,isCurrentSocket:((O=l.current)==null?void 0:O.socket)===R.socket}))return;if(Y.type==="shell.connected"){Bt(u);const G=$g(Y);k(G.viewerId),N(!1),q(G.settleAttachPromise),D($,G.nextShell,"attached");return}if(Y.type==="shell.output"){const{output:G,snapshotUpdate:L}=Dg({event:Y,shellCwd:Q,currentSnapshot:v.current,pendingCommand:b.current});j.current={cursorX:G.cursorX,cursorY:G.cursorY,paneHeight:G.paneHeight},E(G.promptLabel),I(G.isCommandRunning),L&&(v.current=L.nextSnapshot,b.current=L.nextPendingCommand,L.lastCommandOutput!==null&&(x.current=L.lastCommandOutput),G.replace?wl(Z,G.data,G.cursorX,G.cursorY,G.paneHeight):Z.write(G.data));return}const T=vg({event:Y,currentViewerId:i.current});T&&(T.viewerId!==void 0&&k(T.viewerId),T.isConnecting!==void 0&&N(T.isConnecting),T.settleAttachPromise!==void 0&&q(T.settleAttachPromise),T.isCommandRunning!==void 0&&I(T.isCommandRunning),T.connectionError!==void 0&&C(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&D($,G=>Gg(G,T),T.shellUpdate.status),T.closeSocket&&R.socket.close())}});return l.current=R,R.socket.addEventListener("close",()=>{var T;const Y=u.current,H=Bg({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===R.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:$,hasAttachTimeout:Y!==null});zg({closeApplication:H,shellId:$,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:k,setIsConnecting:N,settleAttachPromise:q,onShellUpdate:D,setReconnectKey:w})}),()=>{const Y=Fg(i),H=Pg({shellId:$,viewerId:Y,shellSocket:R,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});Ig({cleanupAction:H,shellSocket:R,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:k,setIsConnecting:N,settleAttachPromise:q})}},[m,u,n,p,f,x,D,b,o,h,C,I,N,w,E,k,q,Q,$,r,d,v,j,l,y,a,s,g,i])}function jn(e){return e.current}var Rs=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),v=c.useRef(null),b=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),w=c.useRef(null),k=c.useRef(null),N=c.useRef(!1),C=c.useRef(null),E=c.useRef(""),I=c.useRef(null),q=c.useRef(""),D=c.useRef(null),$=c.useRef(null),Q=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Z=c.useRef(!1),B=c.useRef(null),ee=c.useRef(o),oe=c.useRef(s),A=c.useRef(()=>!1),J=c.useRef(()=>null),R=c.useRef(()=>{}),Y=c.useRef(kg({clearTimeout:window.clearTimeout})),[H,T]=c.useState(null),[O,G]=c.useState(!1),[L,S]=c.useState(null),[V,K]=c.useState(!1),[le,X]=c.useState(null),[ce,re]=c.useState(null),[fe,he]=c.useState(!1),[ve,Re]=c.useState(0),ie=(n==null?void 0:n.status)??"not_created",ye=wg({shell:n,workspacePathMissing:i}),Te=c.useMemo(()=>ia(tn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),U=ce??Te,ae=c.useCallback(F=>{x.current=F,S(F)},[]),xe=c.useCallback(F=>{Y.current.settle(F)},[]);c.useEffect(()=>{ee.current=o},[o]),c.useEffect(()=>{oe.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ke=c.useCallback(F=>{const de=b.current,we=j.current,P=x.current;return!de||!we||!P?!1:(de.send({type:"shell.input",shellId:we,viewerId:P,data:F}),!0)},[]);c.useEffect(()=>{A.current=ke},[ke]);const $e=c.useCallback(()=>{const F=b.current,de=j.current,we=x.current;return!F||!de||!we?!1:(F.send({type:"shell.clear",shellId:de,viewerId:we}),!0)},[]),Me=c.useCallback(()=>{if(!o||!H)return!1;const F=H.getBoundingClientRect();return F.width>0&&F.height>0},[o,H]),je=c.useCallback(F=>{const de=g.current,we=v.current;if(!de||!we||!Me()||(we.fit(),de.cols<=0||de.rows<=0))return null;const P={cols:de.cols,rows:de.rows},_=gg({size:P,previousSize:$.current,shellId:j.current,viewerId:x.current,syncBackendSize:(F==null?void 0:F.syncBackendSize)!==!1});return(F==null?void 0:F.syncBackendSize)===!1||($.current=_.nextLastSentSize,!_.message)||b.current&&b.current.send(_.message),P},[Me]);c.useEffect(()=>{J.current=je},[je]);const De=c.useCallback(F=>{const de=g.current;!de||!Me()||(je((F==null?void 0:F.syncBackendSize)===void 0?void 0:{syncBackendSize:F.syncBackendSize}),E.current&&!zs(H)?wl(de,E.current,Q.current.cursorX,Q.current.cursorY,Q.current.paneHeight):de.scrollToBottom(),F!=null&&F.focus&&!s&&de.focus())},[s,Me,je,H]);return c.useEffect(()=>{R.current=()=>De()},[De]),c.useEffect(()=>{m({status:L?"attached":ie,shellInputEnabled:!!(L&&n),isConnecting:V,isCommandRunning:fe,promptLabel:U,error:le,hasShell:!!n})},[le,V,fe,m,U,n,ie,L]),c.useEffect(()=>{if(!H||g.current||Z.current)return;let F=!1;return Z.current=!0,(async()=>{const[{Terminal:de},{FitAddon:we}]=await Promise.all([Ke(()=>import("./terminal-vendor-C5bTa-Ka.js").then(se=>se.x),__vite__mapDeps([6,2,7])),Ke(()=>import("./terminal-vendor-C5bTa-Ka.js").then(se=>se.a),__vite__mapDeps([6,2,7]))]);if(F||!H){Z.current=!1;return}const P=new de({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Ls(l)}),_=new we;P.loadAddon(_),P.open(H),g.current=P,v.current=_,J.current(),P.attachCustomKeyEventHandler(se=>{if(oe.current||se.type!=="keydown")return!0;if(se.ctrlKey&&!se.altKey&&!se.metaKey&&!se.shiftKey){const ge=Kf(se.key);if(!ge)return!0;if(A.current(ge))return se.preventDefault(),!1}return!0}),G(!0),Z.current=!1,D.current=new ResizeObserver(()=>{R.current()}),D.current.observe(H),B.current=P.onData(se=>{oe.current||A.current(se)})})(),()=>{var de,we,P;F=!0,Z.current=!1,(de=B.current)==null||de.dispose(),B.current=null,(we=D.current)==null||we.disconnect(),D.current=null,G(!1),(P=g.current)==null||P.dispose(),g.current=null,v.current=null,$.current=null}},[l,H]),c.useEffect(()=>{var de;const F=ug({hasShell:!!n});F&&(ae(F.viewerId),K(F.isConnecting),xe(F.settleAttachPromise),X(F.connectionError),re(F.runtimePromptLabel),he(F.isCommandRunning),E.current=F.shellSnapshot,q.current=F.lastCommandOutput,I.current=F.pendingCommand,F.shouldResetTerminal&&((de=g.current)==null||de.reset()))},[ae,xe,n]),c.useEffect(()=>{const F=g.current;F&&(F.options.theme=Ls(l))},[l]),c.useEffect(()=>{const F=g.current;F&&(F.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!O)return;const F=window.requestAnimationFrame(()=>{De({focus:a,syncBackendSize:!1}),!b.current&&(n!=null&&n.id)&&C.current!==n.id&&Re(de=>de+1)});return()=>{window.cancelAnimationFrame(F)}},[a,o,De,n==null?void 0:n.id,O]),Hg({shell:n,shellAdapter:d,canAttachShell:ye,terminalReady:O,reconnectKey:ve,terminalRef:g,socketRef:b,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:w,attachRetryTimerRef:k,isVisibleRef:ee,intentionalDisconnectRef:N,userDisconnectedShellIdRef:C,shellSnapshotRef:E,pendingCommandRef:I,lastCommandOutputRef:q,snapshotCursorRef:Q,syncTerminalSizeRef:J,setReconnectKey:Re,setViewerId:ae,setIsConnecting:K,setConnectionError:X,setRuntimePromptLabel:re,setIsCommandRunning:he,settleAttachPromise:xe,onShellUpdate:u}),c.useEffect(()=>()=>{const F=jn(y),de=jn(w),we=jn(k),P=mg({hasReconnectTimer:F!==null,hasAttachTimeout:de!==null,hasAttachRetry:we!==null});P.shouldClearReconnectTimer&&F!==null&&window.clearTimeout(F),P.shouldClearAttachTimeout&&de!==null&&window.clearTimeout(de),P.shouldClearAttachRetry&&we!==null&&window.clearTimeout(we),xe(P.settleAttachPromise)},[xe]),c.useImperativeHandle(p,()=>({disconnect(){const F=b.current,de=j.current,we=x.current,P=pg({shellId:de,viewerId:we,hasSocket:!!F});C.current=P.userDisconnectedShellId,N.current=P.intentionalDisconnect,F&&P.detachMessage&&F.send(P.detachMessage),ae(null),K(!1),xe(!1),P.shouldCloseSocket&&(F==null||F.socket.close()),b.current=null,$.current=null,P.shouldDetachShell&&de&&u(de,_=>({..._,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const F=cg({hasShellId:!!j.current,terminalReady:O,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:Y.current.hasPending()});if(F.type==="reject")return Promise.resolve(!1);if(F.type==="alreadyConnected")return Promise.resolve(!0);if(F.type==="joinPending")return Y.current.joinPending();const de=Y.current.start({timeoutMs:ng,setTimeout:window.setTimeout,onTimeout:()=>{K(!1)}}),we=hg({shellId:j.current,userDisconnectedShellId:C.current});return we.shouldClearUserDisconnectedShellId&&(C.current=null),N.current=we.intentionalDisconnect,X(we.connectionError),K(we.isConnecting),Re(P=>P+1),de},sendInput(F){return ke(F)},sendCommand(F){const de={command:F,beforeSnapshot:E.current};if(I.current=de,F.trim()==="clear"){const _=$e();return!_&&I.current===de&&(I.current=null),_}const we=F.endsWith(`
|
|
3675
|
+
`).trimEnd():""}function kg({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 Rs={status:"not_created",shellInputEnabled:!1,isConnecting:!1,isCommandRunning:!1,promptLabel:null,error:null,hasShell:!1};function ft(e){return e.status!=="exited"&&e.status!=="not_found"}function wg({shell:e,workspacePathMissing:r}){return!!(e&&!r&&ft(e))}function yg(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 jg(e){return(e.activeShellId?e.shells.find(r=>r.id===e.activeShellId&&ft(r)):null)??(e.shell&&ft(e.shell)?e.shell:null)??e.shells.find(ft)??null}function Ng({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&&!ft(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&&!ft(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 Cg({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?ia(nn(r.cwd),null):null),isMobileShell:o,hasShell:!!r,busy:s,loading:l,error:e.error??i}}function Bt(e){return e.current===null?!1:(window.clearTimeout(e.current),e.current=null,!0)}function Sg({attachRetryTimerRef:e,setReconnectKey:r,delayMs:n=eg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Tg({reconnectTimerRef:e,setReconnectKey:r,delayMs:n=tg}){e.current=window.setTimeout(()=>{e.current=null,r(a=>a+1)},n)}function Eg({shellSocket:e,socketRef:r,viewerIdRef:n,attachTimeoutRef:a,setConnectionError:o,setIsConnecting:s,settleAttachPromise:l,delayMs:i=rg}){a.current=window.setTimeout(()=>{var h,u,m;a.current=null;const d=sg({isCurrentSocket:!e.socket||((h=r.current)==null?void 0:h.socket)===e.socket,viewerId:n.current});d&&(o(d.connectionError),s(d.isConnecting),l(d.settleAttachPromise),d.closeSocket&&((u=e.close)==null||u.call(e),(m=e.socket)==null||m.close()))},i)}function Lg(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 fg({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 Ig({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&&Bt(n),e.shouldClearSocketRef&&(a.current=null),s(e.viewerId),l(e.isConnecting),i(e.settleAttachPromise),u.shouldDetachShell&&d(r,Lg,"detached"),u.shouldScheduleReconnect&&Tg({reconnectTimerRef:o,setReconnectKey:h}),!0):!1}function zg({cleanupAction:e,shellSocket:r,attachRetryTimerRef:n,attachTimeoutRef:a,socketRef:o,intentionalDisconnectRef:s,setViewerId:l,setIsConnecting:i,settleAttachPromise:d}){s.current=e.intentionalDisconnect,e.shouldClearAttachRetry&&Bt(n),e.shouldSendDetachMessage&&e.detachMessage&&r.send(e.detachMessage),l(null),i(e.isConnecting),e.settleAttachPromise!==void 0&&d(e.settleAttachPromise),e.shouldClearAttachTimeout&&Bt(a),r.socket.close(),e.shouldClearSocketRef&&(o.current=null)}function Rg({eventShellId:e,shellId:r,socketExists:n,isCurrentSocket:a}){return n&&!a?!1:e===r}function Ag(e){return kl({...e,attachSize:void 0})}function _g({attachSize:e,...r}){return kl({...r,attachSize:e})}function Mg({isCurrentSocket:e,shellId:r,attachSize:n,hasAttachTimeout:a}){const o=og({isCurrentSocket:e,shellId:r,attachSize:n});return{openAction:o,shouldClearAttachTimeout:!!(o&&a)}}function $g(e){const r=String(e.payload.viewerId??"");return{viewerId:r||null,settleAttachPromise:!!r,nextShell:n=>({...n,status:"attached",attachedViewerId:r})}}function Dg({event:e,shellCwd:r,currentSnapshot:n,pendingCommand:a}){const o=xg(e.payload,r),s=o.data?bg({currentSnapshot:n,data:o.data,replace:o.replace,isCommandRunning:o.isCommandRunning,pendingCommand:a}):null;return{output:o,snapshotUpdate:s}}function Bg({isCurrentSocket:e,hadViewer:r,intentionalDisconnect:n,userDisconnectedShellId:a,shellId:o,hasAttachTimeout:s}){const l=ig({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 Gg(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 Fg(e){return e.current}function Hg({shell:e,shellAdapter:r,canAttachShell:n,terminalReady:a,reconnectKey:o,terminalRef:s,socketRef:l,viewerIdRef:i,shellIdRef:d,reconnectTimerRef:h,attachTimeoutRef:u,attachRetryTimerRef:m,isVisibleRef:f,intentionalDisconnectRef:p,userDisconnectedShellIdRef:g,shellSnapshotRef:v,pendingCommandRef:b,lastCommandOutputRef:x,snapshotCursorRef:j,syncTerminalSizeRef:y,setReconnectKey:w,setViewerId:k,setIsConnecting:N,setConnectionError:C,setRuntimePromptLabel:E,setIsCommandRunning:z,settleAttachPromise:q,onShellUpdate:D}){const $=e==null?void 0:e.id,Q=e==null?void 0:e.cwd;c.useEffect(()=>{const Z=s.current,B={shellId:$??null,terminalReady:a,isVisible:f.current,canAttachShell:n,userDisconnectedShellId:g.current,hasTerminal:!!Z,hasPendingAttachRetry:m.current!==null,hasCurrentSocketForShell:!!(l.current&&d.current===$),hasReconnectTimer:h.current!==null};if(Ag(B).type==="skip")return;const oe=y.current(),A=_g({...B,attachSize:oe});if(A.type==="skip"||A.type==="measureSize")return;if(A.type==="scheduleRetry"){Sg({attachRetryTimerRef:m,setReconnectKey:w});return}if(A.shouldClearAttachRetry&&Bt(m),A.type==="reuseSocket"||(A.shouldClearReconnectTimer&&Bt(h),!$||!Z))return;const J=A.attachSize;d.current=$,Z.reset(),C(null),k(null),N(!0),p.current=!1;const R=r.connectSocket({onConnected:()=>{var O;const Y=u.current,H=Mg({isCurrentSocket:((O=l.current)==null?void 0:O.socket)===R.socket,shellId:$,attachSize:J,hasAttachTimeout:Y!==null}),T=H.openAction;T&&(R.send(T.message),H.shouldClearAttachTimeout&&Y!==null&&Bt(u),T.shouldScheduleAttachTimeout&&Eg({shellSocket:R,socketRef:l,viewerIdRef:i,attachTimeoutRef:u,setConnectionError:C,setIsConnecting:N,settleAttachPromise:q}))},onShellEvent:Y=>{var O;if(!Rg({eventShellId:Y.shellId,shellId:$,socketExists:!!R.socket,isCurrentSocket:((O=l.current)==null?void 0:O.socket)===R.socket}))return;if(Y.type==="shell.connected"){Bt(u);const G=$g(Y);k(G.viewerId),N(!1),q(G.settleAttachPromise),D($,G.nextShell,"attached");return}if(Y.type==="shell.output"){const{output:G,snapshotUpdate:L}=Dg({event:Y,shellCwd:Q,currentSnapshot:v.current,pendingCommand:b.current});j.current={cursorX:G.cursorX,cursorY:G.cursorY,paneHeight:G.paneHeight},E(G.promptLabel),z(G.isCommandRunning),L&&(v.current=L.nextSnapshot,b.current=L.nextPendingCommand,L.lastCommandOutput!==null&&(x.current=L.lastCommandOutput),G.replace?yl(Z,G.data,G.cursorX,G.cursorY,G.paneHeight):Z.write(G.data));return}const T=vg({event:Y,currentViewerId:i.current});T&&(T.viewerId!==void 0&&k(T.viewerId),T.isConnecting!==void 0&&N(T.isConnecting),T.settleAttachPromise!==void 0&&q(T.settleAttachPromise),T.isCommandRunning!==void 0&&z(T.isCommandRunning),T.connectionError!==void 0&&C(T.connectionError),T.intentionalDisconnect!==void 0&&(p.current=T.intentionalDisconnect),T.shellUpdate&&D($,G=>Gg(G,T),T.shellUpdate.status),T.closeSocket&&R.socket.close())}});return l.current=R,R.socket.addEventListener("close",()=>{var T;const Y=u.current,H=Bg({isCurrentSocket:((T=l.current)==null?void 0:T.socket)===R.socket,hadViewer:!!i.current,intentionalDisconnect:p.current,userDisconnectedShellId:g.current,shellId:$,hasAttachTimeout:Y!==null});Ig({closeApplication:H,shellId:$,attachTimeoutRef:u,socketRef:l,reconnectTimerRef:h,setViewerId:k,setIsConnecting:N,settleAttachPromise:q,onShellUpdate:D,setReconnectKey:w})}),()=>{const Y=Fg(i),H=Pg({shellId:$,viewerId:Y,shellSocket:R,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,openReadyState:WebSocket.OPEN});zg({cleanupAction:H,shellSocket:R,attachRetryTimerRef:m,attachTimeoutRef:u,socketRef:l,intentionalDisconnectRef:p,setViewerId:k,setIsConnecting:N,settleAttachPromise:q})}},[m,u,n,p,f,x,D,b,o,h,C,z,N,w,E,k,q,Q,$,r,d,v,j,l,y,a,s,g,i])}function Cn(e){return e.current}var As=c.forwardRef(function({paneId:r,shell:n,isActive:a,isVisible:o,isMobileShell:s,effectiveTheme:l,workspacePathMissing:i,shellAdapter:d,onActivate:h,onShellUpdate:u,onRuntimeStateChange:m,onFeedback:f},p){const g=c.useRef(null),v=c.useRef(null),b=c.useRef(null),x=c.useRef(null),j=c.useRef(null),y=c.useRef(null),w=c.useRef(null),k=c.useRef(null),N=c.useRef(!1),C=c.useRef(null),E=c.useRef(""),z=c.useRef(null),q=c.useRef(""),D=c.useRef(null),$=c.useRef(null),Q=c.useRef({cursorX:void 0,cursorY:void 0,paneHeight:void 0}),Z=c.useRef(!1),B=c.useRef(null),ee=c.useRef(o),oe=c.useRef(s),A=c.useRef(()=>!1),J=c.useRef(()=>null),R=c.useRef(()=>{}),Y=c.useRef(kg({clearTimeout:window.clearTimeout})),[H,T]=c.useState(null),[O,G]=c.useState(!1),[L,S]=c.useState(null),[V,K]=c.useState(!1),[le,X]=c.useState(null),[ce,re]=c.useState(null),[fe,he]=c.useState(!1),[ve,Re]=c.useState(0),ie=(n==null?void 0:n.status)??"not_created",ye=wg({shell:n,workspacePathMissing:i}),Te=c.useMemo(()=>ia(nn(n==null?void 0:n.cwd),null),[n==null?void 0:n.cwd]),W=ce??Te,ae=c.useCallback(F=>{x.current=F,S(F)},[]),xe=c.useCallback(F=>{Y.current.settle(F)},[]);c.useEffect(()=>{ee.current=o},[o]),c.useEffect(()=>{oe.current=s},[s]),c.useEffect(()=>{j.current=(n==null?void 0:n.id)??null},[n==null?void 0:n.id]);const ke=c.useCallback(F=>{const de=b.current,we=j.current,P=x.current;return!de||!we||!P?!1:(de.send({type:"shell.input",shellId:we,viewerId:P,data:F}),!0)},[]);c.useEffect(()=>{A.current=ke},[ke]);const $e=c.useCallback(()=>{const F=b.current,de=j.current,we=x.current;return!F||!de||!we?!1:(F.send({type:"shell.clear",shellId:de,viewerId:we}),!0)},[]),Me=c.useCallback(()=>{if(!o||!H)return!1;const F=H.getBoundingClientRect();return F.width>0&&F.height>0},[o,H]),je=c.useCallback(F=>{const de=g.current,we=v.current;if(!de||!we||!Me()||(we.fit(),de.cols<=0||de.rows<=0))return null;const P={cols:de.cols,rows:de.rows},_=gg({size:P,previousSize:$.current,shellId:j.current,viewerId:x.current,syncBackendSize:(F==null?void 0:F.syncBackendSize)!==!1});return(F==null?void 0:F.syncBackendSize)===!1||($.current=_.nextLastSentSize,!_.message)||b.current&&b.current.send(_.message),P},[Me]);c.useEffect(()=>{J.current=je},[je]);const De=c.useCallback(F=>{const de=g.current;!de||!Me()||(je((F==null?void 0:F.syncBackendSize)===void 0?void 0:{syncBackendSize:F.syncBackendSize}),E.current&&!zs(H)?yl(de,E.current,Q.current.cursorX,Q.current.cursorY,Q.current.paneHeight):de.scrollToBottom(),F!=null&&F.focus&&!s&&de.focus())},[s,Me,je,H]);return c.useEffect(()=>{R.current=()=>De()},[De]),c.useEffect(()=>{m({status:L?"attached":ie,shellInputEnabled:!!(L&&n),isConnecting:V,isCommandRunning:fe,promptLabel:W,error:le,hasShell:!!n})},[le,V,fe,m,W,n,ie,L]),c.useEffect(()=>{if(!H||g.current||Z.current)return;let F=!1;return Z.current=!0,(async()=>{const[{Terminal:de},{FitAddon:we}]=await Promise.all([Ke(()=>import("./terminal-vendor-C5bTa-Ka.js").then(se=>se.x),__vite__mapDeps([6,2,7])),Ke(()=>import("./terminal-vendor-C5bTa-Ka.js").then(se=>se.a),__vite__mapDeps([6,2,7]))]);if(F||!H){Z.current=!1;return}const P=new de({cursorBlink:!0,disableStdin:oe.current,fontFamily:"IBM Plex Mono, SFMono-Regular, Menlo, monospace",fontSize:13,lineHeight:1.25,scrollback:3e3,theme:Ps(l)}),_=new we;P.loadAddon(_),P.open(H),g.current=P,v.current=_,J.current(),P.attachCustomKeyEventHandler(se=>{if(oe.current||se.type!=="keydown")return!0;if(se.ctrlKey&&!se.altKey&&!se.metaKey&&!se.shiftKey){const ge=Kf(se.key);if(!ge)return!0;if(A.current(ge))return se.preventDefault(),!1}return!0}),G(!0),Z.current=!1,D.current=new ResizeObserver(()=>{R.current()}),D.current.observe(H),B.current=P.onData(se=>{oe.current||A.current(se)})})(),()=>{var de,we,P;F=!0,Z.current=!1,(de=B.current)==null||de.dispose(),B.current=null,(we=D.current)==null||we.disconnect(),D.current=null,G(!1),(P=g.current)==null||P.dispose(),g.current=null,v.current=null,$.current=null}},[l,H]),c.useEffect(()=>{var de;const F=ug({hasShell:!!n});F&&(ae(F.viewerId),K(F.isConnecting),xe(F.settleAttachPromise),X(F.connectionError),re(F.runtimePromptLabel),he(F.isCommandRunning),E.current=F.shellSnapshot,q.current=F.lastCommandOutput,z.current=F.pendingCommand,F.shouldResetTerminal&&((de=g.current)==null||de.reset()))},[ae,xe,n]),c.useEffect(()=>{const F=g.current;F&&(F.options.theme=Ps(l))},[l]),c.useEffect(()=>{const F=g.current;F&&(F.options.disableStdin=s)},[s]),c.useEffect(()=>{if(!o||!O)return;const F=window.requestAnimationFrame(()=>{De({focus:a,syncBackendSize:!1}),!b.current&&(n!=null&&n.id)&&C.current!==n.id&&Re(de=>de+1)});return()=>{window.cancelAnimationFrame(F)}},[a,o,De,n==null?void 0:n.id,O]),Hg({shell:n,shellAdapter:d,canAttachShell:ye,terminalReady:O,reconnectKey:ve,terminalRef:g,socketRef:b,viewerIdRef:x,shellIdRef:j,reconnectTimerRef:y,attachTimeoutRef:w,attachRetryTimerRef:k,isVisibleRef:ee,intentionalDisconnectRef:N,userDisconnectedShellIdRef:C,shellSnapshotRef:E,pendingCommandRef:z,lastCommandOutputRef:q,snapshotCursorRef:Q,syncTerminalSizeRef:J,setReconnectKey:Re,setViewerId:ae,setIsConnecting:K,setConnectionError:X,setRuntimePromptLabel:re,setIsCommandRunning:he,settleAttachPromise:xe,onShellUpdate:u}),c.useEffect(()=>()=>{const F=Cn(y),de=Cn(w),we=Cn(k),P=mg({hasReconnectTimer:F!==null,hasAttachTimeout:de!==null,hasAttachRetry:we!==null});P.shouldClearReconnectTimer&&F!==null&&window.clearTimeout(F),P.shouldClearAttachTimeout&&de!==null&&window.clearTimeout(de),P.shouldClearAttachRetry&&we!==null&&window.clearTimeout(we),xe(P.settleAttachPromise)},[xe]),c.useImperativeHandle(p,()=>({disconnect(){const F=b.current,de=j.current,we=x.current,P=pg({shellId:de,viewerId:we,hasSocket:!!F});C.current=P.userDisconnectedShellId,N.current=P.intentionalDisconnect,F&&P.detachMessage&&F.send(P.detachMessage),ae(null),K(!1),xe(!1),P.shouldCloseSocket&&(F==null||F.socket.close()),b.current=null,$.current=null,P.shouldDetachShell&&de&&u(de,_=>({..._,status:"detached",attachedViewerId:null}),"detached")},reconnect(){const F=cg({hasShellId:!!j.current,terminalReady:O,workspacePathMissing:i,hasViewer:!!x.current,hasPendingAttach:Y.current.hasPending()});if(F.type==="reject")return Promise.resolve(!1);if(F.type==="alreadyConnected")return Promise.resolve(!0);if(F.type==="joinPending")return Y.current.joinPending();const de=Y.current.start({timeoutMs:ng,setTimeout:window.setTimeout,onTimeout:()=>{K(!1)}}),we=hg({shellId:j.current,userDisconnectedShellId:C.current});return we.shouldClearUserDisconnectedShellId&&(C.current=null),N.current=we.intentionalDisconnect,X(we.connectionError),K(we.isConnecting),Re(P=>P+1),de},sendInput(F){return ke(F)},sendCommand(F){const de={command:F,beforeSnapshot:E.current};if(z.current=de,F.trim()==="clear"){const _=$e();return!_&&z.current===de&&(z.current=null),_}const we=F.endsWith(`
|
|
3676
3676
|
`)?F:`${F}
|
|
3677
|
-
`,P=ke(we);return!P&&I.current===de&&(I.current=null),P},sendControl(F){return F==="clear"?$e():ke(Zf(F))},async copyLastCommandOutput(){const F=q.current.trim()||zs(H);if(!F)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(F),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var F;(F=g.current)==null||F.focus()},refreshLayout(F){De(F)}}),[f,u,De,$e,ke,ae,xe,H,O,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var F;h(),(F=g.current)==null||F.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),Og=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:o=!0,showFloatingToolbox:s=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),v=c.useRef(null),b=c.useRef(!1),[x,j]=c.useState(null),[y,w]=c.useState(!0),[k,N]=c.useState(!1),[C,E]=c.useState(null),[I,q]=c.useState("primary"),[D,$]=c.useState(null),[Q,Z]=c.useState(null),[B,ee]=c.useState("single"),[oe,A]=c.useState(50),[J,R]=c.useState(null),[Y,H]=c.useState(""),[T,O]=c.useState(!1),[G,L]=c.useState(!1),[S,V]=c.useState(!1),[K,le]=c.useState({primary:Is,secondary:Is}),[X,ce]=c.useState(null),re=(x==null?void 0:x.state)??"not_created",fe=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),he=c.useMemo(()=>fe.filter(ft),[fe]),ve=c.useMemo(()=>he.find(z=>z.id===D)??null,[he,D]),Re=c.useMemo(()=>he.find(z=>z.id===Q)??null,[he,Q]),ie=I==="secondary"?Re:ve,ye=K[I],Te=(x==null?void 0:x.workspacePathStatus)==="missing",U=I==="secondary"?f:m,ae=Ng({activeRuntime:ye,activeShell:ie,busy:k,loading:y,status:re,workspacePathMissing:Te}),xe=ae.disabled,ke=ae.label,$e=ae.className,Me=(X==null?void 0:X.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(X==null?void 0:X.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",je=c.useCallback((z,W)=>{ce({tone:z,text:W}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{ce(null),p.current=null},1800)},[]),De=c.useCallback((z,W,pe)=>{j(Pe=>{var Ue;if(!Pe)return Pe;const te=Pe.shells.map(Oe=>Oe.id===z?W(Oe):Oe),He=((Ue=Pe.shell)==null?void 0:Ue.id)===z?W(Pe.shell):te.find(Oe=>{var qe;return Oe.id===((qe=Pe.shell)==null?void 0:qe.id)})??Pe.shell;return{...Pe,...pe?{state:pe}:{},shell:He,shells:te}})},[]),F=c.useCallback(async()=>{w(!0);try{const z=await n.fetchState(r);j(z),E(null)}catch(z){E(z instanceof Error?z.message:"Unable to load shell state.")}finally{w(!1)}},[n,r]);c.useEffect(()=>{F()},[F]),c.useEffect(()=>{const z=i==null?void 0:i(r);if(z==null){A(50);return}const W=typeof z=="number"?z:Number.parseFloat(String(z));A(Number.isFinite(W)?wn(W):50)},[i,r]),c.useEffect(()=>{if(!x){$(null),Z(null);return}const z=jg(x);$(W=>W&&x.shells.some(pe=>pe.id===W&&ft(pe))?W:(z==null?void 0:z.id)??null),Z(W=>{if(B!=="columns")return null;if(W&&x.shells.some(Pe=>Pe.id===W&&ft(Pe)))return W;const pe=x.shells.find(Pe=>ft(Pe)&&Pe.id!==(z==null?void 0:z.id));return(pe==null?void 0:pe.id)??null})},[x,B]),c.useEffect(()=>{B!=="columns"&&(q("primary"),Z(null))},[B]),c.useEffect(()=>{if(B!=="columns"||Q||he.length<2)return;const z=he.find(W=>W.id!==(ve==null?void 0:ve.id))??null;z&&Z(z.id)},[he,ve==null?void 0:ve.id,Q,B]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const z=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),W=()=>{O(z.matches),z.matches||(V(!1),L(!1))};return W(),z.addEventListener("change",W),()=>{z.removeEventListener("change",W)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),v.current!==null&&window.cancelAnimationFrame(v.current)},[]);const de=c.useCallback((z,W)=>{le(pe=>{const Pe=pe[z];return yg(Pe,W)?pe:{...pe,[z]:W}})},[]),we=c.useCallback(z=>de("primary",z),[de]),P=c.useCallback(z=>de("secondary",z),[de]),_=c.useCallback(z=>{var pe;if((pe=z.label)!=null&&pe.trim())return z.label.trim();const W=fe.findIndex(Pe=>Pe.id===z.id);return`Shell ${W>=0?W+1:""}`.trim()},[fe]),se=c.useCallback(z=>{var W;R(z.id),H(((W=z.label)==null?void 0:W.trim())||_(z))},[_]),ge=c.useCallback(()=>{R(null),H("")},[]),Ne=c.useCallback(async()=>{if(J){N(!0);try{const z=Y.trim(),W=await n.updateShell(J,{label:z.length>0?z:null});j(pe=>{var Pe;return pe&&{...pe,state:pe.activeShellId===W.id?W.status:pe.state,shell:((Pe=pe.shell)==null?void 0:Pe.id)===W.id?W:pe.shell,shells:pe.shells.map(te=>te.id===W.id?W:te)}}),R(null),H(""),E(null)}catch(z){E(z instanceof Error?z.message:"Unable to rename shell.")}finally{N(!1)}}},[Y,J,n]),Ae=c.useCallback((z,W)=>{if(z==="primary"){$(W),Z(pe=>pe===W?null:pe);return}Z(W),$(pe=>pe===W?null:pe)},[]),Se=c.useCallback(z=>{var W,pe;if(z==="primary"){(W=m.current)==null||W.disconnect(),$(null),B==="columns"&&q("secondary");return}(pe=f.current)==null||pe.disconnect(),Z(null),q("primary"),ee("single")},[B]),Be=c.useCallback((z,W=I)=>{const pe=B==="columns"?W:"primary";Ae(pe,z.id),B!=="columns"&&Z(null),q(pe)},[I,Ae,B]),We=c.useCallback(async(z=I)=>{var W;if(!b.current){b.current=!0,N(!0);try{const pe=await n.createShell(r);j(pe);const Pe=pe.activeShellId??((W=pe.shell)==null?void 0:W.id)??null;if(Pe){const te=B==="columns"?z:"primary";Ae(te,Pe),B!=="columns"&&Z(null),q(te)}E(null)}catch(pe){E(pe instanceof Error?pe.message:"Unable to create shell.")}finally{b.current=!1,N(!1)}}},[I,Ae,n,B,r]);c.useEffect(()=>{!a||!x||y||k||Te||re==="creating"||he.length>0||We("primary")},[k,We,a,he.length,y,x,re,Te]);const at=c.useCallback(async(z=(ie==null?void 0:ie.id)??"")=>{if(z){N(!0);try{await n.terminateShell(z),$(W=>W===z?null:W),Z(W=>W===z?null:W),await F(),E(null)}catch(W){E(W instanceof Error?W.message:"Unable to terminate shell.")}finally{N(!1)}}},[ie==null?void 0:ie.id,F,n]),et=c.useCallback(async()=>{var z,W;if(!xe){if(ye.shellInputEnabled){(z=U.current)==null||z.disconnect();return}if(!ie||ie.status==="exited"||ie.status==="not_found"){await We(I);return}await((W=U.current)==null?void 0:W.reconnect())}},[I,U,ye.shellInputEnabled,ie,xe,We]),tt=c.useCallback(z=>{typeof window>"u"||d==null||d(r,wn(z))},[d,r]),rt=c.useCallback(()=>{var z,W;(z=m.current)==null||z.refreshLayout({syncBackendSize:!0}),(W=f.current)==null||W.refreshLayout({syncBackendSize:!0})},[]),it=c.useCallback(z=>{var He,Ue;if(B!=="columns")return;const W=g.current;if(!W)return;z.preventDefault(),(Ue=(He=z.currentTarget).setPointerCapture)==null||Ue.call(He,z.pointerId);const pe=Oe=>{const qe=W.getBoundingClientRect();if(qe.width<=0)return;const ct=wn((Oe-qe.left)/qe.width*100);A(ct),v.current!==null&&window.cancelAnimationFrame(v.current),v.current=window.requestAnimationFrame(()=>{v.current=null,rt()})},Pe=Oe=>{pe(Oe.clientX)},te=Oe=>{pe(Oe.clientX);const qe=W.getBoundingClientRect();qe.width>0&&tt((Oe.clientX-qe.left)/qe.width*100),window.removeEventListener("pointermove",Pe),window.removeEventListener("pointerup",te)};window.addEventListener("pointermove",Pe),window.addEventListener("pointerup",te,{once:!0})},[tt,rt,B]),_e=c.useCallback((z,W)=>{Ae(W,z.id),q(W)},[Ae]),Fe=c.useCallback(async()=>{var W;return await((W=U.current)==null?void 0:W.copyLastCommandOutput())?!0:(je("failed","Nothing to copy"),!1)},[U,je]);c.useEffect(()=>{h==null||h(Cg({activeRuntime:ye,activeShell:ie,connectionButtonDisabled:xe,connectionButtonLabel:ke,isMobileShell:T,busy:k,loading:y,error:C}))},[ye,ie,k,xe,ke,C,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(z){var W;return((W=U.current)==null?void 0:W.sendInput(z))??!1},sendCommand(z){var W;return((W=U.current)==null?void 0:W.sendCommand(z))??!1},sendControl(z){var W;return((W=U.current)==null?void 0:W.sendControl(z))??!1},async copyLastCommandOutput(){var z;return await((z=U.current)==null?void 0:z.copyLastCommandOutput())??!1},async terminate(){await at()},focus(){var z;(z=U.current)==null||z.focus()},refreshLayout(z){var W,pe;(W=m.current)==null||W.refreshLayout(z),B==="columns"&&((pe=f.current)==null||pe.refreshLayout(z))}}),[U,et,at,B]);const dt=z=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${z.id===(ie==null?void 0:ie.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===z.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:W=>{W.preventDefault(),Ne()},children:t.jsx("input",{value:Y,onChange:W=>H(W.currentTarget.value),onKeyDown:W=>{W.key==="Escape"&&(W.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>Be(z),onDoubleClick:()=>se(z),className:"min-w-0 flex-1 text-left",title:z.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:_(z)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[kn(z.status)," · ",tn(z.cwd)||z.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[J===z.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ne(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>se(z),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"}),B==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>_e(z,"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:()=>_e(z,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:k,onClick:()=>void at(z.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"})]})]})},z.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:ye.promptLabel??(ie==null?void 0:ie.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ke,title:`${ke} (${kn(ye.status)})`,disabled:xe,onClick:()=>void et(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${$e}`,children:t.jsx(Qf,{connected:ye.shellInputEnabled})}),ie&&t.jsx("button",{type:"button",disabled:k,onClick:()=>void at(ie.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"})]})]}),(C||y||Te)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Te&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&C&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:C})]})]}),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:ie?_(ie):"No live shell process"}),ie&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:kn(ye.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 ",he.length]}),t.jsx("button",{type:"button","aria-expanded":G,"aria-label":G?"Hide shell processes":"Show shell processes",onClick:()=>L(z=>!z),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),G&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[he.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[he.map(dt),he.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:k||y||Te,onClick:()=>void We(I),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:"+"})})]}),re==="not_created"||Te?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."}),!Te&&t.jsx("button",{type:"button",disabled:k||y,onClick:()=>void We("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&&(C||y||Te)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Te&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&C&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:C})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${B==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:B==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(Rs,{ref:m,paneId:"primary",shell:ve,isActive:I==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Te,shellAdapter:n,onActivate:()=>q("primary"),onShellUpdate:De,onRuntimeStateChange:we,onFeedback:je}),B==="columns"&&t.jsx("button",{type:"button",onClick:()=>Se("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"}),B==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:it,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"}),B==="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(Rs,{ref:f,paneId:"secondary",shell:Re,isActive:I==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Te,shellAdapter:n,onActivate:()=>q("secondary"),onShellUpdate:De,onRuntimeStateChange:P,onFeedback:je}),t.jsx("button",{type:"button",onClick:()=>Se("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),s&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[X&&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 ${Me}`,children:X.text}),S&&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:()=>{je("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(Ps,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void Fe(),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(Ps,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var z;(z=U.current)!=null&&z.sendControl("clear")?je("done","Cleared"):je("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(yn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled||!ye.isCommandRunning,onClick:()=>{var z;(z=U.current)!=null&&z.sendInput("")?je("done","Sent Ctrl-C"):je("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(yn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(z=>t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var W;(W=U.current)!=null&&W.sendControl(z)?je("done",`Sent ${z.toUpperCase().replace("_","-")}`):je("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(yn,{label:z.toUpperCase().replace("_","-"),tone:"stone"})},z))]})}),t.jsx("button",{type:"button","aria-expanded":S,"aria-label":S?"Close shell tools":"Open shell tools",onClick:()=>V(z=>!z),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(Jf,{})})]})]}),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:[he.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[he.map(dt),he.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:k||y||Te,onClick:()=>void We(I),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:"+"})})]})]})]})})]})}),Ug=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(au(),Yo))).ThreadGraphWorkspacePanel}));function Wg(){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 yl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Wg,{}),children:t.jsx(Ug,{...e})})}c.memo(yl);function dx({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?Ur.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 Vg(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 Kg(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function qg(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function Xg(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function Yg(e){return e==="read"?"View only":"Collaborator"}function Zg(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function cx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var O,G,L;const p=c.useMemo(()=>{var S;return((S=n.data)==null?void 0:S.turns)??[]},[(O=n.data)==null?void 0:O.turns]),[g,v]=c.useState(l),[b,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[w,k]=c.useState(!0),[N,C]=c.useState(""),[E,I]=c.useState("read"),[q,D]=c.useState("none"),[$,Q]=c.useState(""),[Z,B]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(v(l),x("latest-10"),k(!0),C(""),I("read"),D("none"),Q(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(S=>S.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function S(V){V.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r,i,e]),c.useEffect(()=>{if(!e)return;const S=document.querySelector(".thread-ui-shell"),V=()=>S?S.getAttribute("data-theme-effective")==="dark"||S.classList.contains("dark")||S.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(B(V()),!S)return;const K=new MutationObserver(()=>B(V()));return K.observe(S,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>K.disconnect()},[e]),!e)return null;const ee=Xg(b),oe=ee!==null?Math.min(ee,((G=n.data)==null?void 0:G.totalTurnCount)??ee):b==="all-loaded"?p.length:j.size,A=!r&&g!=="share"&&(ee!==null||b==="all-loaded"||j.size>0),J=!r&&a&&!!u&&N.trim().length>0;function R(S){y(V=>{const K=new Set(V);return K.has(S)?K.delete(S):K.add(S),K})}function Y(){if(g==="share")return;const S={format:g,...ee!==null?{mode:"latest",limit:ee}:b==="all-loaded"?{mode:"selected",turnIds:p.map(V=>V.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:w}};h(S)}function H(S){S.preventDefault(),J&&(u==null||u({targetIdentifier:N.trim(),threadAccess:E,workspaceAccess:q,label:$.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Ur.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${Z} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":Z,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:T.map(S=>t.jsx("button",{type:"button",onClick:()=>v(S.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===S.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:S.label},S.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:H,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:S=>C(S.target.value),placeholder:"username or email",value:N})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([S,V])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:E===S,disabled:!a||r,onChange:()=>I(S)}),V]},S))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([S,V])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:q===S,disabled:!a||r,onChange:()=>D(S)}),V]},S))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:S=>Q(S.target.value),placeholder:"optional",value:$})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(s==null?void 0:s.shares.length)??0})]}),(s==null?void 0:s.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:s.error}):s!=null&&s.shares.length?t.jsx("div",{className:"divide-y",children:s.shares.map(S=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:S.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[S.label?`${S.label} · `:"",Yg(S.threadAccess)," / ",Zg(S.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(S.id),children:"Revoke"}):null]},S.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:b,onChange:S=>x(S.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(S=>t.jsx("option",{value:S,children:qg(S)},S))})]}),b==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(S=>S.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>y(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(S=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(S.turnId),onChange:()=>R(S.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 ",S.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:Vg(S.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:S.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:Kg(S.status)})]},S.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:w,onChange:S=>k(S.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${oe} ${oe===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!J,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:Y,disabled:!A,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 Nn(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 Jg(e){const r=`in ${Nn(e.input)} / out ${Nn(e.output)} / cache ${Nn(e.cache)}`;return e.pricedTurns>0?`${r} / cost ${oa(e.priceUsd)}`:r}function Qg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=bl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:f}){const[p,g]=c.useState(!1),[v,b]=c.useState(0),[x,j]=c.useState(0),[y,w]=c.useState(0),[k,N]=c.useState(!1),C=c.useRef(null),E=i==null?void 0:i.onTailVisibilityChange,I=e.pendingRequests.length>0,q=c.useCallback(J=>{E==null||E(J)},[E]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const J=window.matchMedia("(max-width: 639px)"),R=()=>g(J.matches);return R(),J.addEventListener("change",R),()=>{J.removeEventListener("change",R)}},[]),c.useEffect(()=>{var R,Y;if(typeof window>"u")return;const J=()=>{const H=window.visualViewport,T=H?Math.max(0,Math.round(window.innerHeight-H.height-H.offsetTop)):0,O=H?Math.max(0,Math.round(window.innerHeight-H.height)):T,G=Math.min(T,O),L=Math.max(0,Math.round(window.innerHeight*.52));w(Math.min(G,L))};return J(),(R=window.visualViewport)==null||R.addEventListener("resize",J),(Y=window.visualViewport)==null||Y.addEventListener("scroll",J),window.addEventListener("resize",J),()=>{var H,T;(H=window.visualViewport)==null||H.removeEventListener("resize",J),(T=window.visualViewport)==null||T.removeEventListener("scroll",J),window.removeEventListener("resize",J)}},[]),c.useLayoutEffect(()=>{const J=C.current;if(!J||!p){b(0);return}const R=()=>{b(Math.ceil(J.getBoundingClientRect().height))};if(R(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(R);return Y.observe(J),()=>{Y.disconnect()}},[p,l,I]),c.useLayoutEffect(()=>{var H,T;const J=C.current;if(!J||!p){j(0);return}const R=()=>{const O=J.getBoundingClientRect();j(Math.max(0,Math.ceil(window.innerHeight-O.top)))};R(),window.addEventListener("resize",R),(H=window.visualViewport)==null||H.addEventListener("resize",R),(T=window.visualViewport)==null||T.addEventListener("scroll",R);let Y=null;return typeof ResizeObserver<"u"&&(Y=new ResizeObserver(R),Y.observe(J)),()=>{var O,G;window.removeEventListener("resize",R),(O=window.visualViewport)==null||O.removeEventListener("resize",R),(G=window.visualViewport)==null||G.removeEventListener("scroll",R),Y==null||Y.disconnect()}},[p,y,k,l,I]),c.useEffect(()=>{if(!p){N(!1);return}const J=Y=>{var T;const H=Y.target;H instanceof HTMLElement&&((T=C.current)!=null&&T.contains(H))&&N(!0)},R=Y=>{var T;const H=Y.relatedTarget;H instanceof HTMLElement&&((T=C.current)!=null&&T.contains(H))||N(!1)};return document.addEventListener("focusin",J),document.addEventListener("focusout",R),()=>{document.removeEventListener("focusin",J),document.removeEventListener("focusout",R)}},[p]);const D=c.useCallback(J=>{C.current=J,f&&(f.current=J)},[f]),$=p&&k?Math.max(0,y-m):0,Q=Math.max(v,144),Z=Math.max(x,Q+$),B=p?Z+12:0,ee=B>0?{"--thread-graph-chat-scroll-bottom-spacer":`${B}px`}:void 0,oe=u&&p?{bottom:`${m+$}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,A=c.useMemo(()=>{const J=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:J,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:q})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,q,o,n,i]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:ee,children:[s,A,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?Jg(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:D,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:oe??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Bn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:D,className:"thread-graph-composer-host shrink-0",children:t.jsx(Bn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function ex(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,priceUsd:0,pricedTurns:0,turns:0})}function Cn(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 tx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${Cn(e.input)} / out ${Cn(e.output)} / cache ${Cn(e.cache)}`;return e.pricedTurns>0?`${r} / cost ${oa(e.priceUsd)}`:r}function hx({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:v,onWorkspaceReturn:b,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:w,workspaceTitle:k,workspaceActions:N,workspaceFeatures:C,workspaceFocusPathRequest:E=null,onNewThreadTitle:I,beforeTimelineContent:q,errorContent:D,workspaceMissingContent:$,dialogs:Q,currentThreadId:Z,currentWorkspaceId:B,currentWorkspaceLabel:ee,onCloseAppNavigation:oe,className:A="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:J="chat",liveOutput:R="",timelineProps:Y,composerProps:H,shellComposerProps:T,useFloatingMobileComposer:O=!1,floatingMobileComposerBottomOffset:G=0,composerHostRef:L,shellPanelRef:S,shellEffectiveTheme:V="dark",shellThemeMode:K=V,onShellThemeModeChange:le,onShellStateChange:X,shellUnavailableContent:ce,shellDisconnectedContent:re,timelineComponent:fe=bl,shellPanelComponent:he=Og,shellContent:ve,loadingContent:Re,emptyContent:ie}){const ye=aa(),Te=s??ye??ra(),{getImageAssetUrl:U,loadHistoryItemDetail:ae,openWorkspaceFile:xe,openThread:ke,cancelPendingSteer:$e}=l,Me=c.useMemo(()=>({...U?{getImageAssetUrl:se=>U(se.path)}:{},onOpenLinkedThread:ke,...xe?{onOpenWorkspaceFile:xe}:{},...ae?{onLoadHistoryItemDetail:ae}:{},...$e?{cancelPendingSteer:$e}:{}}),[$e,U,ae,xe,ke]),je=Te.getThreadPanels().some(se=>se.kind==="terminal"),De=c.useMemo(()=>r?ex(r):null,[r]),F=c.useMemo(()=>tx(De),[De]),de=c.useMemo(()=>{var se;return r?r.turns.reduce((ge,Ne)=>ge+Ne.items.length,((se=r.liveItems)==null?void 0:se.items.length)??0):0},[r]),we=w??(r?t.jsx(yl,{detail:r,status:o,plugins:Te,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:J,features:C,focusPathRequest:E}):null),P=n?Re??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:A,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(D??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&($??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:r.workspace.absPath})]})),t.jsx("div",{className:J==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Qg,{detail:r,adapter:l,timelineAdapter:Me,TimelineComponent:fe,liveOutput:R,threadUsageSummary:De,transcriptItemCount:de,useFloatingMobileComposer:O,floatingMobileComposerBottomOffset:G,...q?{beforeTimelineContent:q}:{},...H?{composerProps:H}:{},...Y?{timelineProps:Y}:{},...L?{composerHostRef:L}:{}})}),t.jsxs("div",{className:J==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ve??(r.thread.isLoaded&&je&&l.shell?t.jsx(he,{ref:S,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:V,isVisible:J==="shell",showHeader:!1,showFloatingToolbox:!1,...X?{onStateChange:X}:{}}):r.thread.isLoaded&&!je?ce??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."})]})}):re??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."})]})})),J==="shell"&&T&&!ve?t.jsx(Bn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Q]}):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."}),_=t.jsx(Qm,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:Z??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:B??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:ee??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:F,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:V,themeMode:K,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:v,...b?{onWorkspaceReturn:b}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:we,workspaceTitle:k??"Workspace",workspaceActions:N,...I?{onNewThreadTitle:I}:{},...oe?{onCloseAppNavigation:oe}:{},...le?{onThemeModeChange:le}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:P});return s?t.jsx(na.Provider,{value:Te,children:_}):_}var rx={},nx=[];function ux({adapter:e=rx,builtinPlugins:r=nx,children:n}){const[a,o]=c.useState(()=>Gn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];o(Gn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,w)=>{if(e.updatePlugin){const k=await e.updatePlugin(y,{enabled:w});o(N=>N.map(C=>C.id===k.id?k:C));return}o(k=>k.map(N=>N.id===y?{...N,enabled:w}:N))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const w=await e.importPlugin(y);o(k=>[...k.filter(C=>C.id!==w.id),w])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const w=await e.deletePlugin(y);o(k=>k.filter(N=>N.id!==w.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(w=>w.enabled).map(w=>w.id));return r.filter(w=>y.has(w.manifest.id))},[r,a]),g=c.useCallback(y=>{var k;const w=p.find(N=>N.renderArtifact&&N.manifest.capabilities.artifactTypes.some(C=>C.type===y.artifact.type));return((k=w==null?void 0:w.renderArtifact)==null?void 0:k.call(w,y))??null},[p]),v=c.useCallback(y=>{for(const w of p)for(const k of w.inlineCodeRenderers??[]){if(!k.languages.includes(y.language.trim().toLowerCase()))continue;const N=k.render(y);if(N)return N}return null},[p]),b=c.useCallback(y=>p.some(w=>!!w.renderArtifact&&w.manifest.capabilities.artifactTypes.some(k=>k.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:v,hasRendererForArtifact:b,getThreadPanels:x}),[i,x,b,m,s,a,h,g,v,u,f]);return t.jsx(na.Provider,{value:j,children:n})}export{$m as A,dx as C,ep as L,ux as P,cx as T,aa as a,hx as b,Og as c,bl as d,Qm as e,Ft as f,Jm as g,Dm as t,tl as u};
|
|
3677
|
+
`,P=ke(we);return!P&&z.current===de&&(z.current=null),P},sendControl(F){return F==="clear"?$e():ke(Zf(F))},async copyLastCommandOutput(){const F=q.current.trim()||zs(H);if(!F)return f==null||f("failed","Nothing to copy"),!1;try{return await navigator.clipboard.writeText(F),f==null||f("done","Copied"),!0}catch{return f==null||f("failed","Copy failed"),!1}},focus(){var F;(F=g.current)==null||F.focus()},refreshLayout(F){De(F)}}),[f,u,De,$e,ke,ae,xe,H,O,i]),t.jsxs("div",{className:`relative min-h-0 flex-1 overflow-hidden ${a?"shell-pane-active":""}`,onMouseDown:h,"data-pane-id":r,children:[t.jsx("div",{ref:T,className:`h-full w-full px-2 py-2 sm:px-3 sm:py-3 ${s?"mobile-shell-selectable":""}`,onMouseDown:()=>{var F;h(),(F=g.current)==null||F.focus()}}),a&&t.jsx("div",{className:"pointer-events-none absolute right-2 top-2 rounded-md border border-sky-300/30 bg-sky-300/10 px-2 py-1 text-[10px] uppercase tracking-[0.12em] text-sky-100",children:"Active"})]})}),Og=c.forwardRef(function({threadId:r,shellAdapter:n,isVisible:a=!0,showHeader:o=!0,showFloatingToolbox:s=!0,effectiveTheme:l="dark",loadSplitRatio:i,saveSplitRatio:d,onStateChange:h},u){const m=c.useRef(null),f=c.useRef(null),p=c.useRef(null),g=c.useRef(null),v=c.useRef(null),b=c.useRef(!1),[x,j]=c.useState(null),[y,w]=c.useState(!0),[k,N]=c.useState(!1),[C,E]=c.useState(null),[z,q]=c.useState("primary"),[D,$]=c.useState(null),[Q,Z]=c.useState(null),[B,ee]=c.useState("single"),[oe,A]=c.useState(50),[J,R]=c.useState(null),[Y,H]=c.useState(""),[T,O]=c.useState(!1),[G,L]=c.useState(!1),[S,V]=c.useState(!1),[K,le]=c.useState({primary:Rs,secondary:Rs}),[X,ce]=c.useState(null),re=(x==null?void 0:x.state)??"not_created",fe=c.useMemo(()=>(x==null?void 0:x.shells)??[],[x==null?void 0:x.shells]),he=c.useMemo(()=>fe.filter(ft),[fe]),ve=c.useMemo(()=>he.find(I=>I.id===D)??null,[he,D]),Re=c.useMemo(()=>he.find(I=>I.id===Q)??null,[he,Q]),ie=z==="secondary"?Re:ve,ye=K[z],Te=(x==null?void 0:x.workspacePathStatus)==="missing",W=z==="secondary"?f:m,ae=Ng({activeRuntime:ye,activeShell:ie,busy:k,loading:y,status:re,workspacePathMissing:Te}),xe=ae.disabled,ke=ae.label,$e=ae.className,Me=(X==null?void 0:X.tone)==="done"?"shell-floating-feedback shell-floating-feedback-done":(X==null?void 0:X.tone)==="failed"?"shell-floating-feedback shell-floating-feedback-failed":"shell-floating-feedback",je=c.useCallback((I,U)=>{ce({tone:I,text:U}),p.current!==null&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{ce(null),p.current=null},1800)},[]),De=c.useCallback((I,U,pe)=>{j(Pe=>{var We;if(!Pe)return Pe;const te=Pe.shells.map(Oe=>Oe.id===I?U(Oe):Oe),He=((We=Pe.shell)==null?void 0:We.id)===I?U(Pe.shell):te.find(Oe=>{var qe;return Oe.id===((qe=Pe.shell)==null?void 0:qe.id)})??Pe.shell;return{...Pe,...pe?{state:pe}:{},shell:He,shells:te}})},[]),F=c.useCallback(async()=>{w(!0);try{const I=await n.fetchState(r);j(I),E(null)}catch(I){E(I instanceof Error?I.message:"Unable to load shell state.")}finally{w(!1)}},[n,r]);c.useEffect(()=>{F()},[F]),c.useEffect(()=>{const I=i==null?void 0:i(r);if(I==null){A(50);return}const U=typeof I=="number"?I:Number.parseFloat(String(I));A(Number.isFinite(U)?jn(U):50)},[i,r]),c.useEffect(()=>{if(!x){$(null),Z(null);return}const I=jg(x);$(U=>U&&x.shells.some(pe=>pe.id===U&&ft(pe))?U:(I==null?void 0:I.id)??null),Z(U=>{if(B!=="columns")return null;if(U&&x.shells.some(Pe=>Pe.id===U&&ft(Pe)))return U;const pe=x.shells.find(Pe=>ft(Pe)&&Pe.id!==(I==null?void 0:I.id));return(pe==null?void 0:pe.id)??null})},[x,B]),c.useEffect(()=>{B!=="columns"&&(q("primary"),Z(null))},[B]),c.useEffect(()=>{if(B!=="columns"||Q||he.length<2)return;const I=he.find(U=>U.id!==(ve==null?void 0:ve.id))??null;I&&Z(I.id)},[he,ve==null?void 0:ve.id,Q,B]),c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const I=window.matchMedia("(max-width: 767px), (hover: none) and (pointer: coarse)"),U=()=>{O(I.matches),I.matches||(V(!1),L(!1))};return U(),I.addEventListener("change",U),()=>{I.removeEventListener("change",U)}},[]),c.useEffect(()=>()=>{p.current!==null&&window.clearTimeout(p.current),v.current!==null&&window.cancelAnimationFrame(v.current)},[]);const de=c.useCallback((I,U)=>{le(pe=>{const Pe=pe[I];return yg(Pe,U)?pe:{...pe,[I]:U}})},[]),we=c.useCallback(I=>de("primary",I),[de]),P=c.useCallback(I=>de("secondary",I),[de]),_=c.useCallback(I=>{var pe;if((pe=I.label)!=null&&pe.trim())return I.label.trim();const U=fe.findIndex(Pe=>Pe.id===I.id);return`Shell ${U>=0?U+1:""}`.trim()},[fe]),se=c.useCallback(I=>{var U;R(I.id),H(((U=I.label)==null?void 0:U.trim())||_(I))},[_]),ge=c.useCallback(()=>{R(null),H("")},[]),Ne=c.useCallback(async()=>{if(J){N(!0);try{const I=Y.trim(),U=await n.updateShell(J,{label:I.length>0?I:null});j(pe=>{var Pe;return pe&&{...pe,state:pe.activeShellId===U.id?U.status:pe.state,shell:((Pe=pe.shell)==null?void 0:Pe.id)===U.id?U:pe.shell,shells:pe.shells.map(te=>te.id===U.id?U:te)}}),R(null),H(""),E(null)}catch(I){E(I instanceof Error?I.message:"Unable to rename shell.")}finally{N(!1)}}},[Y,J,n]),Ae=c.useCallback((I,U)=>{if(I==="primary"){$(U),Z(pe=>pe===U?null:pe);return}Z(U),$(pe=>pe===U?null:pe)},[]),Se=c.useCallback(I=>{var U,pe;if(I==="primary"){(U=m.current)==null||U.disconnect(),$(null),B==="columns"&&q("secondary");return}(pe=f.current)==null||pe.disconnect(),Z(null),q("primary"),ee("single")},[B]),Be=c.useCallback((I,U=z)=>{const pe=B==="columns"?U:"primary";Ae(pe,I.id),B!=="columns"&&Z(null),q(pe)},[z,Ae,B]),Ue=c.useCallback(async(I=z)=>{var U;if(!b.current){b.current=!0,N(!0);try{const pe=await n.createShell(r);j(pe);const Pe=pe.activeShellId??((U=pe.shell)==null?void 0:U.id)??null;if(Pe){const te=B==="columns"?I:"primary";Ae(te,Pe),B!=="columns"&&Z(null),q(te)}E(null)}catch(pe){E(pe instanceof Error?pe.message:"Unable to create shell.")}finally{b.current=!1,N(!1)}}},[z,Ae,n,B,r]);c.useEffect(()=>{!a||!x||y||k||Te||re==="creating"||he.length>0||Ue("primary")},[k,Ue,a,he.length,y,x,re,Te]);const at=c.useCallback(async(I=(ie==null?void 0:ie.id)??"")=>{if(I){N(!0);try{await n.terminateShell(I),$(U=>U===I?null:U),Z(U=>U===I?null:U),await F(),E(null)}catch(U){E(U instanceof Error?U.message:"Unable to terminate shell.")}finally{N(!1)}}},[ie==null?void 0:ie.id,F,n]),et=c.useCallback(async()=>{var I,U;if(!xe){if(ye.shellInputEnabled){(I=W.current)==null||I.disconnect();return}if(!ie||ie.status==="exited"||ie.status==="not_found"){await Ue(z);return}await((U=W.current)==null?void 0:U.reconnect())}},[z,W,ye.shellInputEnabled,ie,xe,Ue]),tt=c.useCallback(I=>{typeof window>"u"||d==null||d(r,jn(I))},[d,r]),rt=c.useCallback(()=>{var I,U;(I=m.current)==null||I.refreshLayout({syncBackendSize:!0}),(U=f.current)==null||U.refreshLayout({syncBackendSize:!0})},[]),it=c.useCallback(I=>{var He,We;if(B!=="columns")return;const U=g.current;if(!U)return;I.preventDefault(),(We=(He=I.currentTarget).setPointerCapture)==null||We.call(He,I.pointerId);const pe=Oe=>{const qe=U.getBoundingClientRect();if(qe.width<=0)return;const ct=jn((Oe-qe.left)/qe.width*100);A(ct),v.current!==null&&window.cancelAnimationFrame(v.current),v.current=window.requestAnimationFrame(()=>{v.current=null,rt()})},Pe=Oe=>{pe(Oe.clientX)},te=Oe=>{pe(Oe.clientX);const qe=U.getBoundingClientRect();qe.width>0&&tt((Oe.clientX-qe.left)/qe.width*100),window.removeEventListener("pointermove",Pe),window.removeEventListener("pointerup",te)};window.addEventListener("pointermove",Pe),window.addEventListener("pointerup",te,{once:!0})},[tt,rt,B]),_e=c.useCallback((I,U)=>{Ae(U,I.id),q(U)},[Ae]),Fe=c.useCallback(async()=>{var U;return await((U=W.current)==null?void 0:U.copyLastCommandOutput())?!0:(je("failed","Nothing to copy"),!1)},[W,je]);c.useEffect(()=>{h==null||h(Cg({activeRuntime:ye,activeShell:ie,connectionButtonDisabled:xe,connectionButtonLabel:ke,isMobileShell:T,busy:k,loading:y,error:C}))},[ye,ie,k,xe,ke,C,T,y,h]),c.useImperativeHandle(u,()=>({async toggleConnection(){await et()},sendInput(I){var U;return((U=W.current)==null?void 0:U.sendInput(I))??!1},sendCommand(I){var U;return((U=W.current)==null?void 0:U.sendCommand(I))??!1},sendControl(I){var U;return((U=W.current)==null?void 0:U.sendControl(I))??!1},async copyLastCommandOutput(){var I;return await((I=W.current)==null?void 0:I.copyLastCommandOutput())??!1},async terminate(){await at()},focus(){var I;(I=W.current)==null||I.focus()},refreshLayout(I){var U,pe;(U=m.current)==null||U.refreshLayout(I),B==="columns"&&((pe=f.current)==null||pe.refreshLayout(I))}}),[W,et,at,B]);const dt=I=>t.jsx("div",{className:`rounded-md border px-2 py-1.5 text-xs ${I.id===(ie==null?void 0:ie.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===I.id?t.jsx("form",{className:"min-w-0 flex-1",onSubmit:U=>{U.preventDefault(),Ne()},children:t.jsx("input",{value:Y,onChange:U=>H(U.currentTarget.value),onKeyDown:U=>{U.key==="Escape"&&(U.preventDefault(),ge())},autoFocus:!0,className:"w-full rounded border border-sky-300/35 bg-stone-950/70 px-2 py-1 text-xs text-stone-100 outline-none","aria-label":"Shell name"})}):t.jsxs("button",{type:"button",onClick:()=>Be(I),onDoubleClick:()=>se(I),className:"min-w-0 flex-1 text-left",title:I.tmuxSessionName,children:[t.jsx("span",{className:"block truncate",children:_(I)}),t.jsxs("span",{className:"block truncate text-[10px] text-[var(--theme-fg-muted)]",children:[yn(I.status)," · ",nn(I.cwd)||I.cwd]})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[J===I.id?t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>void Ne(),className:"rounded border border-sky-300/35 bg-sky-300/12 px-1.5 py-1 text-[10px] text-sky-50",title:"Save shell name",children:"Save"}),t.jsx("button",{type:"button",onClick:ge,className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200",title:"Cancel rename",children:"Cancel"})]}):t.jsx("button",{type:"button",onClick:()=>se(I),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"}),B==="columns"&&t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:()=>_e(I,"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:()=>_e(I,"secondary"),className:"rounded border border-stone-700 px-1.5 py-1 text-[10px] text-stone-200 hover:border-sky-300/40",title:"Open in right pane",children:"R"})]}),t.jsx("button",{type:"button",disabled:k,onClick:()=>void at(I.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"})]})]})},I.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:ye.promptLabel??(ie==null?void 0:ie.cwd)??"Create a terminal for this thread."})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("button",{type:"button","aria-label":ke,title:`${ke} (${yn(ye.status)})`,disabled:xe,onClick:()=>void et(),className:`inline-flex h-10 w-10 items-center justify-center rounded-full border shadow-lg shadow-stone-950/25 transition disabled:cursor-not-allowed disabled:opacity-60 ${$e}`,children:t.jsx(Qf,{connected:ye.shellInputEnabled})}),ie&&t.jsx("button",{type:"button",disabled:k,onClick:()=>void at(ie.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"})]})]}),(C||y||Te)&&t.jsxs("div",{className:"shell-banner mt-3 rounded-2xl border px-3 py-3 text-sm",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Te&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&C&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:C})]})]}),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:ie?_(ie):"No live shell process"}),ie&&t.jsx("span",{className:"shrink-0 text-[10px] uppercase tracking-[0.12em] text-[var(--theme-fg-muted)]",children:yn(ye.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 ",he.length]}),t.jsx("button",{type:"button","aria-expanded":G,"aria-label":G?"Hide shell processes":"Show shell processes",onClick:()=>L(I=>!I),className:"rounded-md border border-stone-700/80 bg-stone-900/50 px-2.5 py-1.5 text-xs text-stone-200 sm:hidden",children:"Processes"})]})]}),G&&t.jsxs("div",{className:"shrink-0 border-b border-stone-800/80 bg-stone-950/55 p-2 sm:hidden",children:[t.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[t.jsx("p",{className:"text-xs uppercase tracking-[0.16em] text-[var(--theme-fg-muted)]",children:"Processes"}),t.jsxs("span",{className:"text-[10px] text-[var(--theme-fg-muted)]",children:[he.length," live"]})]}),t.jsxs("div",{className:"max-h-52 space-y-1 overflow-y-auto",children:[he.map(dt),he.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:k||y||Te,onClick:()=>void Ue(z),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:"+"})})]}),re==="not_created"||Te?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."}),!Te&&t.jsx("button",{type:"button",disabled:k||y,onClick:()=>void Ue("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&&(C||y||Te)&&t.jsxs("div",{className:"shell-banner absolute left-2 right-2 top-2 z-10 rounded-2xl border px-3 py-3 text-sm backdrop-blur sm:left-3 sm:right-3 sm:top-3",children:[y&&t.jsx("p",{className:"text-[var(--theme-fg-muted)]",children:"Loading shell state..."}),!y&&Te&&t.jsx("p",{className:"text-rose-600 dark:text-rose-100",children:"Workspace path is missing on this machine. Restore the path before creating a shell."}),!y&&C&&t.jsx("p",{className:"text-amber-700 dark:text-amber-100",children:C})]}),t.jsxs("div",{ref:g,className:`relative grid h-full min-h-0 ${B==="columns"?"grid-cols-1 sm:grid-cols-[var(--shell-left)_0.35rem_var(--shell-right)]":"grid-cols-1"}`,style:B==="columns"?{"--shell-left":`${oe}fr`,"--shell-right":`${100-oe}fr`}:void 0,"data-shell-split-ratio":oe,children:[t.jsx(As,{ref:m,paneId:"primary",shell:ve,isActive:z==="primary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Te,shellAdapter:n,onActivate:()=>q("primary"),onShellUpdate:De,onRuntimeStateChange:we,onFeedback:je}),B==="columns"&&t.jsx("button",{type:"button",onClick:()=>Se("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"}),B==="columns"&&t.jsx("button",{type:"button","aria-label":"Resize shell panes",title:"Resize shell panes",onPointerDown:it,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"}),B==="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(As,{ref:f,paneId:"secondary",shell:Re,isActive:z==="secondary",isVisible:a,isMobileShell:T,effectiveTheme:l,workspacePathMissing:Te,shellAdapter:n,onActivate:()=>q("secondary"),onShellUpdate:De,onRuntimeStateChange:P,onFeedback:je}),t.jsx("button",{type:"button",onClick:()=>Se("secondary"),className:"absolute left-2 top-2 z-10 rounded-md border border-stone-700/80 bg-stone-950/70 px-2 py-1 text-[10px] text-stone-200 hover:border-rose-300/40",title:"Close right pane",children:"Close"})]})]}),s&&T&&t.jsxs("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20 flex flex-col items-end gap-2",children:[X&&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 ${Me}`,children:X.text}),S&&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:()=>{je("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(Is,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Paste"})]})}),t.jsx("button",{type:"button",onClick:()=>void Fe(),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(Is,{}),t.jsx("span",{className:"text-[11px] font-medium tracking-[0.12em]",children:"Copy"})]})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var I;(I=W.current)!=null&&I.sendControl("clear")?je("done","Cleared"):je("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Nn,{label:"CLEAR",tone:"sky"})}),t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled||!ye.isCommandRunning,onClick:()=>{var I;(I=W.current)!=null&&I.sendInput("")?je("done","Sent Ctrl-C"):je("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Nn,{label:"CTRL-C",tone:"rose"})}),["ctrl_d","esc","tab","up","down"].map(I=>t.jsx("button",{type:"button",disabled:!ye.shellInputEnabled,onClick:()=>{var U;(U=W.current)!=null&&U.sendControl(I)?je("done",`Sent ${I.toUpperCase().replace("_","-")}`):je("failed","Connect the shell first")},className:"disabled:opacity-45",children:t.jsx(Nn,{label:I.toUpperCase().replace("_","-"),tone:"stone"})},I))]})}),t.jsx("button",{type:"button","aria-expanded":S,"aria-label":S?"Close shell tools":"Open shell tools",onClick:()=>V(I=>!I),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(Jf,{})})]})]}),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:[he.length," live"]})]}),t.jsxs("div",{className:"min-h-0 flex-1 space-y-1 overflow-y-auto",children:[he.map(dt),he.length===0&&t.jsx("p",{className:"px-2 py-3 text-xs text-[var(--theme-fg-muted)]",children:"No live shell processes"})]}),t.jsx("div",{className:"mt-2 flex justify-end border-t border-stone-800/80 pt-2",children:t.jsx("button",{type:"button","aria-label":"New shell",title:"New shell",disabled:k||y||Te,onClick:()=>void Ue(z),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:"+"})})]})]})]})})]})}),Wg=c.lazy(async()=>({default:(await Promise.resolve().then(()=>(su(),Zo))).ThreadGraphWorkspacePanel}));function Ug(){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 jl(e){return t.jsx(c.Suspense,{fallback:t.jsx(Ug,{}),children:t.jsx(Wg,{...e})})}c.memo(jl);function dx({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?Vr.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 Vg(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 Kg(e){switch(e){case"inProgress":return"running";case"completed":return"completed";case"interrupted":return"interrupted";case"failed":return"failed"}}function qg(e){switch(e){case"latest-3":return"Latest 3";case"latest-10":return"Latest 10";case"latest-20":return"Latest 20";case"all-loaded":return"All loaded";case"custom":return"Custom"}}function Xg(e){switch(e){case"latest-3":return 3;case"latest-10":return 10;case"latest-20":return 20;default:return null}}function Yg(e){return e==="read"?"View only":"Collaborator"}function Zg(e){switch(e){case"write":return"Workspace write";case"read":return"Workspace read";case"none":default:return"No workspace"}}function cx({open:e,busy:r=!1,turnsState:n,shareAvailable:a=!1,shareUnavailableMessage:o="Relay sharing will be enabled after the relay permission model is connected.",shareState:s,initialMode:l="pdf",onCancel:i,onLoadTurns:d,onExport:h,onCreateShare:u,onRevokeShare:m,onOpenDeviceSharing:f}){var O,G,L;const p=c.useMemo(()=>{var S;return((S=n.data)==null?void 0:S.turns)??[]},[(O=n.data)==null?void 0:O.turns]),[g,v]=c.useState(l),[b,x]=c.useState("latest-10"),[j,y]=c.useState(()=>new Set),[w,k]=c.useState(!0),[N,C]=c.useState(""),[E,z]=c.useState("read"),[q,D]=c.useState("none"),[$,Q]=c.useState(""),[Z,B]=c.useState(()=>typeof document<"u"&&!document.documentElement.classList.contains("dark")?"light":"dark");if(c.useEffect(()=>{e&&(v(l),x("latest-10"),k(!0),C(""),z("read"),D("none"),Q(""),d())},[l,d,e]),c.useEffect(()=>{e&&p.length>0&&y(new Set(p.slice(0,10).map(S=>S.turnId)))},[e,p]),c.useEffect(()=>{if(!e)return;function S(V){V.key==="Escape"&&!r&&i()}return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[r,i,e]),c.useEffect(()=>{if(!e)return;const S=document.querySelector(".thread-ui-shell"),V=()=>S?S.getAttribute("data-theme-effective")==="dark"||S.classList.contains("dark")||S.classList.contains("thread-ui-theme-dark")?"dark":"light":document.documentElement.classList.contains("dark")?"dark":"light";if(B(V()),!S)return;const K=new MutationObserver(()=>B(V()));return K.observe(S,{attributes:!0,attributeFilter:["class","data-theme-effective"]}),()=>K.disconnect()},[e]),!e)return null;const ee=Xg(b),oe=ee!==null?Math.min(ee,((G=n.data)==null?void 0:G.totalTurnCount)??ee):b==="all-loaded"?p.length:j.size,A=!r&&g!=="share"&&(ee!==null||b==="all-loaded"||j.size>0),J=!r&&a&&!!u&&N.trim().length>0;function R(S){y(V=>{const K=new Set(V);return K.has(S)?K.delete(S):K.add(S),K})}function Y(){if(g==="share")return;const S={format:g,...ee!==null?{mode:"latest",limit:ee}:b==="all-loaded"?{mode:"selected",turnIds:p.map(V=>V.turnId)}:{mode:"selected",turnIds:[...j]},profile:"review",options:{includeTokenAndPrice:w}};h(S)}function H(S){S.preventDefault(),J&&(u==null||u({targetIdentifier:N.trim(),threadAccess:E,workspaceAccess:q,label:$.trim()||null}))}const T=[{mode:"pdf",label:"PDF"},{mode:"html",label:"HTML"},{mode:"share",label:"Share"}];return Vr.createPortal(t.jsxs("div",{className:`thread-export-dialog-root thread-ui-theme-${Z} fixed inset-0 z-[96] flex items-end justify-center p-0 sm:items-center sm:p-6`,"data-theme-effective":Z,children:[t.jsx("button",{type:"button","aria-label":"Close thread actions",onClick:i,disabled:r,className:"thread-export-dialog-backdrop absolute inset-0 backdrop-blur-sm disabled:cursor-not-allowed"}),t.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Thread actions",className:"thread-export-dialog-panel relative z-[1] flex max-h-[min(48rem,calc(100vh-1rem))] w-full max-w-2xl flex-col rounded-t-[1.6rem] border shadow-2xl sm:rounded-[1.6rem]",children:[t.jsxs("div",{className:"thread-export-dialog-header flex items-start justify-between gap-3 border-b px-5 py-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-title text-sm font-semibold",children:"Thread actions"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Export a review copy or share this thread."})]}),t.jsx("button",{type:"button","aria-label":"Close dialog",onClick:i,disabled:r,className:"thread-export-dialog-icon-button inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-full border transition disabled:cursor-not-allowed disabled:opacity-60",children:t.jsx("svg",{"aria-hidden":"true",viewBox:"0 0 16 16",className:"h-4 w-4 fill-current",children:t.jsx("path",{d:"M3.22 2.47 8 7.25l4.78-4.78 1.06 1.06L9.06 8.31l4.78 4.78-1.06 1.06L8 9.37l-4.78 4.78-1.06-1.06 4.78-4.78-4.78-4.78 1.06-1.06Z"})})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-auto px-5 py-4",children:[t.jsx("div",{className:"thread-export-dialog-segment inline-flex rounded-full border p-1",children:T.map(S=>t.jsx("button",{type:"button",onClick:()=>v(S.mode),className:`rounded-full px-3 py-1.5 text-sm transition ${g===S.mode?"ui-status-warning":"thread-export-dialog-muted-action"}`,children:S.label},S.mode))}),g==="share"?t.jsxs("form",{id:"thread-actions-share-form",className:"mt-4 space-y-4",onSubmit:H,children:[a?null:t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle rounded-2xl border px-3 py-3 text-sm",children:o}),a&&f?t.jsxs("div",{className:"thread-export-dialog-box flex flex-wrap items-center justify-between gap-3 rounded-2xl border px-3 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Share this thread"}),t.jsx("p",{className:"thread-export-dialog-subtitle mt-1 text-xs",children:"Need broader access? Share the whole device from Relay Portal."})]}),t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs font-medium transition",disabled:r,onClick:f,children:"Share whole device"})]}):null,t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Relay identifier",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:S=>C(S.target.value),placeholder:"username or email",value:N})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Thread access"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[["read","View only"],["control","Collaborator"]].map(([S,V])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:E===S,disabled:!a||r,onChange:()=>z(S)}),V]},S))})]}),t.jsxs("fieldset",{className:"thread-export-dialog-box rounded-2xl border p-3",children:[t.jsx("legend",{className:"thread-export-dialog-subtitle px-1 text-xs",children:"Workspace"}),t.jsx("div",{className:"mt-2 grid gap-2 sm:grid-cols-3",children:[["none","No access"],["read","Read files"],["write","Read and edit"]].map(([S,V])=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex items-center gap-2 rounded-xl px-2.5 py-2 text-sm",children:[t.jsx("input",{type:"radio",checked:q===S,disabled:!a||r,onChange:()=>D(S)}),V]},S))})]}),t.jsxs("label",{className:"thread-export-dialog-body-text block text-sm",children:["Label",t.jsx("input",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",disabled:!a||r,onChange:S=>Q(S.target.value),placeholder:"optional",value:$})]}),t.jsxs("div",{className:"thread-export-dialog-box rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex items-center justify-between border-b px-3 py-2.5",children:[t.jsx("p",{className:"thread-export-dialog-strong text-sm font-medium",children:"Shared by me"}),t.jsx("span",{className:"thread-export-dialog-status-pill rounded-full border px-2 py-0.5 text-[10px]",children:(s==null?void 0:s.shares.length)??0})]}),(s==null?void 0:s.status)==="failed"?t.jsx("p",{className:"px-3 py-3 text-sm text-rose-500 dark:text-rose-200",children:s.error}):s!=null&&s.shares.length?t.jsx("div",{className:"divide-y",children:s.shares.map(S=>t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2.5 text-sm",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"thread-export-dialog-strong truncate font-medium",children:S.targetUsername}),t.jsxs("p",{className:"thread-export-dialog-subtitle mt-0.5 text-xs",children:[S.label?`${S.label} · `:"",Yg(S.threadAccess)," / ",Zg(S.workspaceAccess)]})]}),m?t.jsx("button",{type:"button",className:"thread-export-dialog-secondary-button rounded-full border px-3 py-1.5 text-xs transition",disabled:r,onClick:()=>void m(S.id),children:"Revoke"}):null]},S.id))}):t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-3 text-sm",children:"No active shares for this thread."})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("label",{className:"thread-export-dialog-body-text mt-4 block text-sm",children:["Turns",t.jsx("select",{className:"thread-export-dialog-box mt-2 w-full rounded-xl border bg-transparent px-3 py-2 outline-none",value:b,onChange:S=>x(S.target.value),children:["latest-3","latest-10","latest-20","all-loaded","custom"].map(S=>t.jsx("option",{value:S,children:qg(S)},S))})]}),b==="custom"?t.jsxs("div",{className:"thread-export-dialog-box mt-4 rounded-2xl border",children:[t.jsxs("div",{className:"thread-export-dialog-box-header flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2.5",children:[t.jsxs("p",{className:"thread-export-dialog-subtitle text-xs",children:["Selected ",j.size," of ",((L=n.data)==null?void 0:L.totalTurnCount)??p.length]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:()=>y(new Set(p.map(S=>S.turnId))),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Select all"}),t.jsx("button",{type:"button",onClick:()=>y(new Set),className:"thread-export-dialog-secondary-button rounded-full border px-2.5 py-1 text-xs transition",children:"Clear"})]})]}),n.status==="loading"?t.jsx("p",{className:"thread-export-dialog-subtitle px-3 py-6 text-sm",children:"Loading turns..."}):n.status==="failed"?t.jsx("p",{className:"px-3 py-6 text-sm text-rose-500 dark:text-rose-200",children:n.error}):t.jsx("div",{className:"max-h-80 overflow-auto p-2",children:p.map(S=>t.jsxs("label",{className:"thread-export-dialog-turn-row flex cursor-pointer items-center gap-3 rounded-xl px-2.5 py-2 text-sm transition",children:[t.jsx("input",{type:"checkbox",checked:j.has(S.turnId),onChange:()=>R(S.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 ",S.turnNumber]}),t.jsx("span",{className:"thread-export-dialog-subtitle shrink-0 text-xs",children:Vg(S.startedAt)}),t.jsx("span",{className:"thread-export-dialog-body-text min-w-0 flex-1 truncate text-left",children:S.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:Kg(S.status)})]},S.turnId))})]}):null,t.jsxs("div",{className:"thread-export-dialog-body-text mt-4 grid gap-2 text-sm sm:grid-cols-2",children:[t.jsxs("label",{className:"thread-export-dialog-box flex items-center gap-2 rounded-xl border px-3 py-2",children:[t.jsx("input",{type:"checkbox",checked:w,onChange:S=>k(S.target.checked),className:"thread-export-dialog-checkbox h-4 w-4"}),"Token and price"]}),t.jsx("p",{className:"thread-export-dialog-box thread-export-dialog-subtitle flex items-center rounded-xl border px-3 py-2 text-xs",children:g==="html"?"HTML keeps the chat timeline styling and omits raw command output.":"Review exports keep message text readable and omit tool activity."})]})]})]}),t.jsxs("div",{className:"thread-export-dialog-footer flex items-center justify-between gap-3 border-t px-5 py-4",children:[t.jsx("p",{className:"thread-export-dialog-subtitle min-w-0 text-xs",children:g==="share"?a?"Share access is enforced by the relay server.":"Share permissions are not wired yet.":`${oe} ${oe===1?"turn":"turns"} selected.`}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",onClick:i,disabled:r,className:"thread-export-dialog-secondary-button rounded-full border px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:"Cancel"}),g==="share"?t.jsx("button",{type:"submit",form:"thread-actions-share-form",disabled:!J,className:"ui-status-warning rounded-full px-4 py-2 text-sm font-medium transition disabled:cursor-not-allowed disabled:opacity-60",children:r?"Sharing...":"Share this thread"}):t.jsx("button",{type:"button",onClick:Y,disabled:!A,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 Ar(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 Jg(e){const r=`in ${Ar(e.input)} / out ${Ar(e.output)} / cache read ${Ar(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${Ar(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${oa(e.priceUsd)}`:n}function Qg({detail:e,adapter:r,timelineAdapter:n,TimelineComponent:a=vl,liveOutput:o="",beforeTimelineContent:s,composerProps:l,timelineProps:i,threadUsageSummary:d,transcriptItemCount:h,useFloatingMobileComposer:u=!1,floatingMobileComposerBottomOffset:m=0,composerHostRef:f}){const[p,g]=c.useState(!1),[v,b]=c.useState(0),[x,j]=c.useState(0),[y,w]=c.useState(0),[k,N]=c.useState(!1),C=c.useRef(null),E=i==null?void 0:i.onTailVisibilityChange,z=e.pendingRequests.length>0,q=c.useCallback(J=>{E==null||E(J)},[E]);c.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const J=window.matchMedia("(max-width: 639px)"),R=()=>g(J.matches);return R(),J.addEventListener("change",R),()=>{J.removeEventListener("change",R)}},[]),c.useEffect(()=>{var R,Y;if(typeof window>"u")return;const J=()=>{const H=window.visualViewport,T=H?Math.max(0,Math.round(window.innerHeight-H.height-H.offsetTop)):0,O=H?Math.max(0,Math.round(window.innerHeight-H.height)):T,G=Math.min(T,O),L=Math.max(0,Math.round(window.innerHeight*.52));w(Math.min(G,L))};return J(),(R=window.visualViewport)==null||R.addEventListener("resize",J),(Y=window.visualViewport)==null||Y.addEventListener("scroll",J),window.addEventListener("resize",J),()=>{var H,T;(H=window.visualViewport)==null||H.removeEventListener("resize",J),(T=window.visualViewport)==null||T.removeEventListener("scroll",J),window.removeEventListener("resize",J)}},[]),c.useLayoutEffect(()=>{const J=C.current;if(!J||!p){b(0);return}const R=()=>{b(Math.ceil(J.getBoundingClientRect().height))};if(R(),typeof ResizeObserver>"u")return;const Y=new ResizeObserver(R);return Y.observe(J),()=>{Y.disconnect()}},[p,l,z]),c.useLayoutEffect(()=>{var H,T;const J=C.current;if(!J||!p){j(0);return}const R=()=>{const O=J.getBoundingClientRect();j(Math.max(0,Math.ceil(window.innerHeight-O.top)))};R(),window.addEventListener("resize",R),(H=window.visualViewport)==null||H.addEventListener("resize",R),(T=window.visualViewport)==null||T.addEventListener("scroll",R);let Y=null;return typeof ResizeObserver<"u"&&(Y=new ResizeObserver(R),Y.observe(J)),()=>{var O,G;window.removeEventListener("resize",R),(O=window.visualViewport)==null||O.removeEventListener("resize",R),(G=window.visualViewport)==null||G.removeEventListener("scroll",R),Y==null||Y.disconnect()}},[p,y,k,l,z]),c.useEffect(()=>{if(!p){N(!1);return}const J=Y=>{var T;const H=Y.target;H instanceof HTMLElement&&((T=C.current)!=null&&T.contains(H))&&N(!0)},R=Y=>{var T;const H=Y.relatedTarget;H instanceof HTMLElement&&((T=C.current)!=null&&T.contains(H))||N(!1)};return document.addEventListener("focusin",J),document.addEventListener("focusout",R),()=>{document.removeEventListener("focusin",J),document.removeEventListener("focusout",R)}},[p]);const D=c.useCallback(J=>{C.current=J,f&&(f.current=J)},[f]),$=p&&k?Math.max(0,y-m):0,Q=Math.max(v,144),Z=Math.max(x,Q+$),B=p?Z+12:0,ee=B>0?{"--thread-graph-chat-scroll-bottom-spacer":`${B}px`}:void 0,oe=u&&p?{bottom:`${m+$}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"}:void 0,A=c.useMemo(()=>{const J=e.thread.status==="running"||e.thread.activeTurnId!==null;return t.jsx(a,{threadId:e.thread.id,turns:e.turns,totalTurnCount:e.totalTurnCount??e.turns.length,pendingRequests:e.pendingRequests,activeTurnId:e.thread.activeTurnId,threadRunning:J,liveOutput:o,className:"thread-timeline-surface min-h-0 flex-1",...i,adapter:n,onOpenThread:(i==null?void 0:i.onOpenThread)??r.openThread,onTailVisibilityChange:q})},[a,r.openThread,e.pendingRequests,e.thread.activeTurnId,e.thread.id,e.thread.status,e.totalTurnCount,e.turns,q,o,n,i]);return t.jsxs("div",{"data-testid":"chat-panel",className:"thread-graph-chat-panel relative flex h-full min-h-0 flex-col",style:ee,children:[s,A,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?Jg(d):"waiting for agent usage"]})]}),l?u?t.jsx("div",{ref:D,className:"fixed inset-x-0 bottom-0 z-50 overflow-visible sm:hidden",style:oe??{bottom:`${m}px`,paddingBottom:"max(env(safe-area-inset-bottom), var(--android-safe-area-bottom, 0px))"},children:t.jsx(Bn,{...l,activeView:"chat",edgeToEdgeMobile:!0,onSubmit:r.sendPrompt})}):t.jsx("div",{ref:D,className:"thread-graph-composer-host shrink-0",children:t.jsx(Bn,{...l,activeView:"chat",onSubmit:r.sendPrompt})}):null]})}function ex(e){return e.turns.reduce((r,n)=>{var o,s;const a=(o=n.tokenUsage)==null?void 0:o.total;return a?{input:r.input+a.inputTokens,output:r.output+a.outputTokens,cache:r.cache+a.cachedInputTokens,cacheWrite:r.cacheWrite+(a.cacheWriteInputTokens??0),priceUsd:r.priceUsd+(((s=n.priceEstimate)==null?void 0:s.totalUsd)??0),pricedTurns:r.pricedTurns+(n.priceEstimate?1:0),turns:r.turns+1}:r},{input:0,output:0,cache:0,cacheWrite:0,priceUsd:0,pricedTurns:0,turns:0})}function _r(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 tx(e){if(!e||e.turns<=0)return"waiting for agent usage";const r=`in ${_r(e.input)} / out ${_r(e.output)} / cache read ${_r(e.cache)}`,n=e.cacheWrite>0?`${r} / cache write ${_r(e.cacheWrite)}`:r;return e.pricedTurns>0?`${n} / cost ${oa(e.priceUsd)}`:n}function hx({threads:e,detail:r,loading:n,error:a,status:o=null,plugins:s,adapter:l,metaContent:i,settingsContent:d,globalSettingsContent:h,settingsDialogOpen:u,onSettingsDialogOpenChange:m,mobileHeaderAction:f,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:v,onWorkspaceReturn:b,threadActionsButton:x,surfaceActions:j,floatingPanel:y,workspaceContent:w,workspaceTitle:k,workspaceActions:N,workspaceFeatures:C,workspaceFocusPathRequest:E=null,onNewThreadTitle:z,beforeTimelineContent:q,errorContent:D,workspaceMissingContent:$,dialogs:Q,currentThreadId:Z,currentWorkspaceId:B,currentWorkspaceLabel:ee,onCloseAppNavigation:oe,className:A="thread-detail-surface relative flex h-full min-h-0 flex-1 flex-col overflow-hidden",activeView:J="chat",liveOutput:R="",timelineProps:Y,composerProps:H,shellComposerProps:T,useFloatingMobileComposer:O=!1,floatingMobileComposerBottomOffset:G=0,composerHostRef:L,shellPanelRef:S,shellEffectiveTheme:V="dark",shellThemeMode:K=V,onShellThemeModeChange:le,onShellStateChange:X,shellUnavailableContent:ce,shellDisconnectedContent:re,timelineComponent:fe=vl,shellPanelComponent:he=Og,shellContent:ve,loadingContent:Re,emptyContent:ie}){const ye=aa(),Te=s??ye??ra(),{getImageAssetUrl:W,loadHistoryItemDetail:ae,openWorkspaceFile:xe,openThread:ke,cancelPendingSteer:$e}=l,Me=c.useMemo(()=>({...W?{getImageAssetUrl:se=>W(se.path)}:{},onOpenLinkedThread:ke,...xe?{onOpenWorkspaceFile:xe}:{},...ae?{onLoadHistoryItemDetail:ae}:{},...$e?{cancelPendingSteer:$e}:{}}),[$e,W,ae,xe,ke]),je=Te.getThreadPanels().some(se=>se.kind==="terminal"),De=c.useMemo(()=>r?ex(r):null,[r]),F=c.useMemo(()=>tx(De),[De]),de=c.useMemo(()=>{var se;return r?r.turns.reduce((ge,Ne)=>ge+Ne.items.length,((se=r.liveItems)==null?void 0:se.items.length)??0):0},[r]),we=w??(r?t.jsx(jl,{detail:r,status:o,plugins:Te,workspaceAdapter:l.workspace??null,metaContent:i,settingsContent:d,activeView:J,features:C,focusPathRequest:E}):null),P=n?Re??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:A,children:[y?t.jsx("div",{className:"fixed right-3 top-20 z-50 lg:absolute lg:right-4 lg:top-16",children:y}):null,a&&!n&&(D??t.jsx("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:a})),r.workspacePathStatus==="missing"&&($??t.jsxs("div",{className:"shrink-0 border-b border-rose-500/20 bg-rose-500/10 px-5 py-4 text-sm text-rose-100 sm:px-6",children:[t.jsx("p",{className:"font-medium text-rose-50",children:"Workspace path missing"}),t.jsx("p",{className:"mt-1 break-words text-rose-100/90",children:r.workspace.absPath})]})),t.jsx("div",{className:J==="chat"?"flex min-h-0 flex-1 flex-col":"hidden",children:t.jsx(Qg,{detail:r,adapter:l,timelineAdapter:Me,TimelineComponent:fe,liveOutput:R,threadUsageSummary:De,transcriptItemCount:de,useFloatingMobileComposer:O,floatingMobileComposerBottomOffset:G,...q?{beforeTimelineContent:q}:{},...H?{composerProps:H}:{},...Y?{timelineProps:Y}:{},...L?{composerHostRef:L}:{}})}),t.jsxs("div",{className:J==="shell"?"flex min-h-0 flex-1 flex-col":"hidden",children:[ve??(r.thread.isLoaded&&je&&l.shell?t.jsx(he,{ref:S,threadId:r.thread.id,shellAdapter:l.shell,effectiveTheme:V,isVisible:J==="shell",showHeader:!1,showFloatingToolbox:!1,...X?{onStateChange:X}:{}}):r.thread.isLoaded&&!je?ce??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."})]})}):re??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."})]})})),J==="shell"&&T&&!ve?t.jsx(Bn,{...T,activeView:"shell",onSubmit:l.sendPrompt}):null]}),Q]}):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."}),_=t.jsx(ep,{threads:e,status:o,loading:n,error:n?null:a,viewportConstrained:!0,currentThreadId:Z??(r==null?void 0:r.thread.id),currentThreadLabel:r==null?void 0:r.thread.title,currentWorkspaceId:B??(r==null?void 0:r.thread.workspaceId),currentWorkspaceLabel:ee??(r==null?void 0:r.workspace.label),sessionLabel:(r==null?void 0:r.thread.providerSessionId)??(r==null?void 0:r.thread.id),usageLabel:F,threadActionsButton:x,topbarActions:j,metaContent:i,settingsContent:d,globalSettingsContent:h,...u!==void 0?{settingsDialogOpen:u}:{},...m?{onSettingsDialogOpenChange:m}:{},mobileHeaderAction:f,effectiveTheme:V,themeMode:K,appMenuButton:p,appNavigationMenu:g,workspaceReturnHref:v,...b?{onWorkspaceReturn:b}:{},showMobileAppMenu:!!p,showMobileThreadNavToggle:!0,showMobileNewThreadShortcut:!1,onOpenThread:l.openThread,workspaceContent:we,workspaceTitle:k??"Workspace",workspaceActions:N,...z?{onNewThreadTitle:z}:{},...oe?{onCloseAppNavigation:oe}:{},...le?{onThemeModeChange:le}:{},...l.getThreadHref?{getThreadHref:l.getThreadHref}:{},...l.getNewThreadHref?{getNewThreadHref:l.getNewThreadHref}:{},...l.renderNewThreadDialogContent?{renderNewThreadDialogContent:l.renderNewThreadDialogContent}:{},...l.renameThread?{onRenameThread:l.renameThread}:{},...l.deleteThread?{onDeleteThread:l.deleteThread}:{},children:P});return s?t.jsx(na.Provider,{value:Te,children:_}):_}var rx={},nx=[];function ux({adapter:e=rx,builtinPlugins:r=nx,children:n}){const[a,o]=c.useState(()=>Gn(r,[])),[s,l]=c.useState(!1),[i,d]=c.useState(null),h=c.useCallback(async()=>{l(!0),d(null);try{const y=e.fetchPlugins?await e.fetchPlugins():[];o(Gn(r,y))}catch(y){d(y instanceof Error?y.message:"Unable to load plugins.")}finally{l(!1)}},[e,r]);c.useEffect(()=>{h()},[h]);const u=c.useCallback(async(y,w)=>{if(e.updatePlugin){const k=await e.updatePlugin(y,{enabled:w});o(N=>N.map(C=>C.id===k.id?k:C));return}o(k=>k.map(N=>N.id===y?{...N,enabled:w}:N))},[e]),m=c.useCallback(async y=>{if(!e.importPlugin)throw new Error("Plugin import is not available.");const w=await e.importPlugin(y);o(k=>[...k.filter(C=>C.id!==w.id),w])},[e]),f=c.useCallback(async y=>{if(!e.deletePlugin)throw new Error("Plugin uninstall is not available.");const w=await e.deletePlugin(y);o(k=>k.filter(N=>N.id!==w.id))},[e]),p=c.useMemo(()=>{const y=new Set(a.filter(w=>w.enabled).map(w=>w.id));return r.filter(w=>y.has(w.manifest.id))},[r,a]),g=c.useCallback(y=>{var k;const w=p.find(N=>N.renderArtifact&&N.manifest.capabilities.artifactTypes.some(C=>C.type===y.artifact.type));return((k=w==null?void 0:w.renderArtifact)==null?void 0:k.call(w,y))??null},[p]),v=c.useCallback(y=>{for(const w of p)for(const k of w.inlineCodeRenderers??[]){if(!k.languages.includes(y.language.trim().toLowerCase()))continue;const N=k.render(y);if(N)return N}return null},[p]),b=c.useCallback(y=>p.some(w=>!!w.renderArtifact&&w.manifest.capabilities.artifactTypes.some(k=>k.type===y.type)),[p]),x=c.useCallback(()=>p.flatMap(y=>y.threadPanels??[]),[p]),j=c.useMemo(()=>({plugins:a,loading:s,error:i,refresh:h,importPluginManifest:m,setPluginEnabled:u,uninstallPlugin:f,renderArtifact:g,renderInlineCode:v,hasRendererForArtifact:b,getThreadPanels:x}),[i,x,b,m,s,a,h,g,v,u,f]);return t.jsx(na.Provider,{value:j,children:n})}export{Dm as A,dx as C,tp as L,ux as P,cx as T,aa as a,hx as b,Og as c,vl as d,ep as e,Ft as f,Qm as g,Bm as t,rl as u};
|