@jingyi0605/codingns 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/public/assets/{AdaptiveButlerPage-174Mg-9X.js → AdaptiveButlerPage-CgBX49t-.js} +3 -3
  2. package/dist/public/assets/{App-BRupl2Ul.js → App-tXOqoHNl.js} +3 -3
  3. package/dist/public/assets/{BootstrapPage-BKzDRWtn.js → BootstrapPage-DoRMz87R.js} +1 -1
  4. package/dist/public/assets/ConversationPage-DXR6Hp4O.js +9 -0
  5. package/dist/public/assets/{DesktopDetachPreviewPage-DtHzSQOX.js → DesktopDetachPreviewPage-Cyk-ZYCk.js} +1 -1
  6. package/dist/public/assets/{DesktopWindowPage-ppc3h5sO.js → DesktopWindowPage-DNVNK3hs.js} +1 -1
  7. package/dist/public/assets/{FileContextPanel-h0kvRbSR.js → FileContextPanel-xGTYDclT.js} +1 -1
  8. package/dist/public/assets/{GitSidebar-TlaPNhxG.js → GitSidebar-Cr3Z9OUI.js} +1 -1
  9. package/dist/public/assets/{MobileCreateSessionSheet-Bp4xOKdt.js → MobileCreateSessionSheet-DMW0V6GJ.js} +1 -1
  10. package/dist/public/assets/{MobileTopHeaderFrame-BawK1vUE.js → MobileTopHeaderFrame-CkdnZ_MU.js} +1 -1
  11. package/dist/public/assets/{MobileWorkspaceSwitcherHeader-CWPXAMoX.js → MobileWorkspaceSwitcherHeader-KIbqBYJN.js} +1 -1
  12. package/dist/public/assets/{RelayConnectEntryPage-B0-OBZXu.js → RelayConnectEntryPage-DIRBH3hw.js} +1 -1
  13. package/dist/public/assets/{ServerSettingsModal-P_pcDvyR.js → ServerSettingsModal-C-9RxdWP.js} +1 -1
  14. package/dist/public/assets/{SessionIndexPage-r8AZ0pJv.js → SessionIndexPage-bRlIydRA.js} +1 -1
  15. package/dist/public/assets/{SettingsPage-B-uNuML1.js → SettingsPage-CMEt4ua9.js} +1 -1
  16. package/dist/public/assets/{TerminalManagerPanel-Bkgr9ZNV.js → TerminalManagerPanel-2bi9wVhT.js} +1 -1
  17. package/dist/public/assets/{TerminalPage-BpFpA3My.js → TerminalPage-DayZz2Tf.js} +1 -1
  18. package/dist/public/assets/{TerminalRuntimeFallbackModal-D_BUt6HD.js → TerminalRuntimeFallbackModal-DgwYcp-Y.js} +1 -1
  19. package/dist/public/assets/{ToolFilesPage-BE9-iHL0.js → ToolFilesPage-YvnP_FXW.js} +1 -1
  20. package/dist/public/assets/{ToolGitPage-ChUkwKgK.js → ToolGitPage-GMcQKtV9.js} +1 -1
  21. package/dist/public/assets/{ToolProcessesPage-C4dli_mi.js → ToolProcessesPage-DFIQ7BCd.js} +1 -1
  22. package/dist/public/assets/{ToolsHomePage-ZmcEotg4.js → ToolsHomePage-CSilFzXR.js} +1 -1
  23. package/dist/public/assets/{WorkbenchLandingPage-DZzbQZHt.js → WorkbenchLandingPage-1VtToSz9.js} +1 -1
  24. package/dist/public/assets/WorkbenchLayout-DScHaza9.js +244 -0
  25. package/dist/public/assets/{WorkbenchModal-CAj_TqWW.js → WorkbenchModal-BWXYSXmC.js} +1 -1
  26. package/dist/public/assets/WorkbenchShellRoute-DN6LdrqC.js +1 -0
  27. package/dist/public/assets/{WorkspaceDebugDetailPage-qku5AzZQ.js → WorkspaceDebugDetailPage-Ux8_Q7la.js} +1 -1
  28. package/dist/public/assets/{WorkspaceDetailPage-BtrSsZVP.js → WorkspaceDetailPage-B402p99m.js} +1 -1
  29. package/dist/public/assets/{WorkspaceHomePage-BhekFDSu.js → WorkspaceHomePage-D2pob6HI.js} +1 -1
  30. package/dist/public/assets/{client-runtime-manager-CgogHxt0.js → client-runtime-manager-C5D76ewj.js} +1 -1
  31. package/dist/public/assets/{file-tree-icon-CLfk31E7.js → file-tree-icon-lfU9Ag77.js} +1 -1
  32. package/dist/public/assets/index-CFYXCsyx.css +1 -0
  33. package/dist/public/assets/{index-DvkfRpBe.js → index-NGxWr8Ix.js} +3 -3
  34. package/dist/public/assets/{login-direct-candidate-resolver-DvJnjQCi.js → login-direct-candidate-resolver-wXSaB0i7.js} +1 -1
  35. package/dist/public/assets/{model-switch-api-Dps4yN2t.js → model-switch-api-CPtou49j.js} +1 -1
  36. package/dist/public/assets/{preferences-service-ohVuseA-.js → preferences-service-CdaK7zA8.js} +1 -1
  37. package/dist/public/assets/{realtime-client-CIci6rCd.js → realtime-client-BjQazYsK.js} +1 -1
  38. package/dist/public/assets/{relay-entry-WiotM2TL.js → relay-entry-BwE5nw0l.js} +1 -1
  39. package/dist/public/assets/{terminal-runtime-meta-C3Mr0zW5.js → terminal-runtime-meta-C-Lbyx2i.js} +1 -1
  40. package/dist/public/assets/{useRegisteredDebugTemplates-DVQBPV-V.js → useRegisteredDebugTemplates-BM7-c-gx.js} +1 -1
  41. package/dist/public/index.html +2 -2
  42. package/dist/server/config/env.js +36 -29
  43. package/dist/server/config/env.js.map +1 -1
  44. package/dist/server/modules/sessions/session-history-service.d.ts +3 -1
  45. package/dist/server/modules/sessions/session-history-service.js +55 -2
  46. package/dist/server/modules/sessions/session-history-service.js.map +1 -1
  47. package/dist/server/modules/sessions/session-provider-error-mapper.js +2 -2
  48. package/dist/server/modules/sessions/session-provider-error-mapper.js.map +1 -1
  49. package/dist/server/server/release-manifest-sync.d.ts +7 -0
  50. package/dist/server/server/release-manifest-sync.js +96 -0
  51. package/dist/server/server/release-manifest-sync.js.map +1 -0
  52. package/dist/server/server/start-host.js +2 -0
  53. package/dist/server/server/start-host.js.map +1 -1
  54. package/dist/server/ws/ws-server.js +1 -1
  55. package/dist/server/ws/ws-server.js.map +1 -1
  56. package/node_modules/@codingns/session-sync-core/package.json +1 -1
  57. package/package.json +3 -2
  58. package/scripts/postinstall.mjs +167 -22
  59. package/dist/public/assets/ConversationPage-BLQXBsBc.js +0 -6
  60. package/dist/public/assets/WorkbenchLayout-Cht6Un5X.js +0 -244
  61. package/dist/public/assets/WorkbenchShellRoute-DzbO05cD.js +0 -1
  62. package/dist/public/assets/index-CkkzIvxs.css +0 -1
@@ -0,0 +1,9 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js"])))=>i.map(i=>d[i]);
2
+ var qi=Object.defineProperty;var Hi=(e,t,s)=>t in e?qi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var xe=(e,t,s)=>Hi(e,typeof t!="symbol"?t+"":t,s);import{t as l,b as c,u as Bi,E as Fi,j as i,m as Ss,A as Wi,_ as Mn}from"./index-NGxWr8Ix.js";import{D as fs,W as Ui}from"./WorkbenchModal-BWXYSXmC.js";import{l as $i,m as Vi,n as Gi,o as ts,p as At,q as Xi,s as gr,t as zi,v as ps,f as vt,h as Jt,a as Lt,M as Yi,w as vr,x as sn,y as br,z as wr,A as Ki,S as Qi,B as Zi,C as Ji,D as eo,E as to,F as so,G as no,H as Fs,I as Sn,J as ro,K as io,L as oo,N as ao,O as Mr,u as lo,e as nn,P as co,Q as uo,R as ho,T as fo,U as po,i as mo,j as go,V as vo}from"./model-switch-api-CPtou49j.js";import{u as xt,Q as In,R as Yt,S as yn,T as bo,U as wo,V as Is,X as xn,Y as Mo,f as Pn,Z as ct,c as Xe,_ as So,$ as Io,a0 as yo,a1 as xo,a2 as Po,a3 as Ro,a4 as To,I as Co,i as Sr,b as Rn,a5 as Tn,a6 as Ir,a7 as be,a8 as ss,a9 as yr,w as ko,aa as ze,ab as ys,ac as xr,ad as Pr,ae as Eo,af as Rr,ag as Ao,ah as rn,ai as St,aj as Ht,ak as jo,r as Tr,al as ms,M as gs,K as on,am as es,an,ao as Ws,ap as _o,O as vs,aq as No,ar as Cn,H as Oo,as as Lo,F as Do,at as qo,au as Cr,av as bt,aw as Ho,ax as Us,ay as ln,n as _t,az as Bo,aA as Fo,aB as Wo,aC as Uo,o as $o,C as Pt,aD as kr,aE as Er,aF as Ar,aG as jr,D as _r,g as Bt,aH as Nr,P as Or,aI as Vo,aJ as kn,aK as Go,aL as Xo,aM as zo,aN as Yo,L as Ko,J as Qo}from"./WorkbenchLayout-DScHaza9.js";import{f as at,u as dt,e as Rt,g as It,h as cn,c as Zo}from"./App-tXOqoHNl.js";import{R as Jo,P as Lr,C as un}from"./realtime-client-BjQazYsK.js";import{FileContextPanel as Dr}from"./FileContextPanel-xGTYDclT.js";import{GitSidebar as qr}from"./GitSidebar-Cr3Z9OUI.js";import{TerminalManagerPanel as Hr}from"./TerminalManagerPanel-2bi9wVhT.js";import{TerminalPage as ea}from"./TerminalPage-DayZz2Tf.js";import{f as Br,a as bs,M as Fr}from"./MobileWorkspaceSwitcherHeader-KIbqBYJN.js";import{w as Nt,r as xs,a as En,b as An}from"./styles-JKFlsYFv.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-BwE5nw0l.js";import"./file-tree-icon-lfU9Ag77.js";import"./terminal-runtime-meta-C-Lbyx2i.js";import"./TerminalRuntimeFallbackModal-DgwYcp-Y.js";import"./MobileTopHeaderFrame-CkdnZ_MU.js";function dn({connectionState:e,onReconnect:t}){const{showToast:s,dismissToast:n}=at(),r=$i(),a=r?l(Vi(r.kind)):null;return c.useEffect(()=>{if(e==="connected"||e==="closed"){n("conversation-connection-state");return}if(e==="reconnect_failed"){s({id:"conversation-connection-state",title:l("conversation.connectionReconnectFailed"),description:a?l("conversation.reconnectFailedExplainWithRoute",{route:a}):l("conversation.reconnectFailedExplain"),tone:"warning",durationMs:null,action:{label:l("conversation.reconnectButton"),onClick:t}});return}s({id:"conversation-connection-state",title:l("conversation.connectionReconnecting"),description:a?l("conversation.reconnectExplainWithRoute",{route:a}):l("conversation.reconnectExplain"),tone:"info",durationMs:3200})},[a,e,n,t,s]),null}const ta=48;function sa(e){if(typeof document>"u")return!1;const t=document.createElement("textarea");t.value=e,t.setAttribute("readonly","true"),t.style.position="fixed",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(t)}}async function na(e,t){var s;if(!(t.isDesktop&&(await t.bridge.writeClipboardText(e)).ok)){if(typeof navigator<"u"&&((s=navigator.clipboard)!=null&&s.writeText))try{await navigator.clipboard.writeText(e);return}catch{}if(!sa(e))throw new Error(l("conversation.copyContentFailed"))}}function jn(e,t,s){return Math.min(Math.max(e,t),s)}function Ps(e,t=ts){return e&&t.includes(e)?e:t[0]??"codex"}function ra(e){return ts.includes(e)}function ia(e,t){const s=e.flatMap(n=>ra(n)?[n]:[]);return s.length>0?s:t?[t]:[]}function $s(e){return e?e.nodeType===Node.ELEMENT_NODE?e:e.parentElement:null}function _n(e){var s,n;const t=$s(e);return((n=(s=t==null?void 0:t.closest("[data-message-id]"))==null?void 0:s.getAttribute("data-message-id"))==null?void 0:n.trim())||null}function oa(e,t){return[t.trim()||l("conversation.selectionActionDefaultPrompt"),"",l("conversation.selectionActionQuotedLabel"),"```text",e.trim(),"```"].join(`
3
+ `)}function Rs(e){if(typeof window>"u")return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const s=t.getRangeAt(0),n=$s(s.startContainer),r=$s(s.endContainer);if(!n||!r||!e.contains(n)||!e.contains(r))return null;const a=t.toString().trim();if(!a)return null;const o=s.getBoundingClientRect();if(!o.width&&!o.height)return null;const u=_n(s.startContainer),d=_n(s.endContainer);return{text:a,sourceMessageId:u&&u===d?u:null,rect:{left:o.left,top:o.top,right:o.right,bottom:o.bottom,width:o.width,height:o.height}}}function aa({containerRef:e,session:t,currentCapabilities:s}){const n=dt(),r=Rt(),{showToast:a}=at(),{shellMode:o,requestNavigationRefresh:u,selectWorkspace:d,upsertNavigationSession:h}=xt(),f=Bi(g=>g.profile.providers),p=c.useMemo(()=>In(t==null?void 0:t.providerConfigMode,t==null?void 0:t.providerPresetId),[t==null?void 0:t.providerConfigMode,t==null?void 0:t.providerPresetId]),[x,v]=c.useState(null),[w,M]=c.useState(null),[j,y]=c.useState(!1),{visibleProviders:O}=Gi(ts,j),[C,_]=c.useState(""),[A,P]=c.useState(!1),[k,m]=c.useState(Ps(t==null?void 0:t.provider)),[b,L]=c.useState(Yt),[G,X]=c.useState(p.providerConfigMode),[Z,te]=c.useState(p.providerPresetId),[D,ge]=c.useState({}),[B,S]=c.useState(!1),[U,H]=c.useState(null),[K,oe]=c.useState({}),[ue,de]=c.useState(!1),[ve,E]=c.useState(!1),[V,z]=c.useState(!1),[$,ae]=c.useState(0),[F,re]=c.useState(null),[Te,Ne]=c.useState(()=>({width:typeof window>"u"?0:window.innerWidth,height:typeof window>"u"?0:window.innerHeight})),q=c.useRef(!1),W=c.useRef(!1),he=c.useRef(!1),Ce=c.useRef(null),me=c.useRef(null),Ee=o==="mobile"||r.isMobile,Be=c.useMemo(()=>g=>{var Y,Q;return(Fi(g)?(Q=(Y=f[g])==null?void 0:Y.defaultModel)==null?void 0:Q.trim():null)||Yt},[f]),J=c.useMemo(()=>In(G,Z),[G,Z]),se=c.useMemo(()=>ia(O,k),[k,O]),we=c.useMemo(()=>yn(k),[k]),Fe=c.useMemo(()=>we?D[we]??null:null,[D,we]),R=c.useMemo(()=>bo(Fe),[Fe]),N=c.useMemo(()=>wo(Fe),[Fe]),Ie=J.providerConfigMode==="cc-switch-preset"?J.providerPresetId??Is:Is,Pe=c.useMemo(()=>N.find(g=>g.value===Ie)??N[0]??null,[N,Ie]),ne=c.useMemo(()=>k===(t==null?void 0:t.provider)&&J.providerConfigMode===p.providerConfigMode&&J.providerPresetId===p.providerPresetId&&s?s:U??At(k),[s,U,k,J.providerConfigMode,J.providerPresetId,t==null?void 0:t.provider,p.providerConfigMode,p.providerPresetId]),fe=c.useMemo(()=>{var Y;const g=At(k).modelOptions??[];return(Y=ne.modelOptions)!=null&&Y.length?ne.modelOptions:g},[ne.modelOptions,k]),le=c.useMemo(()=>fe.map(g=>({value:g.id,label:xn(g)?l("conversation.modelUseCliDefault"):g.name})),[fe]),Oe=c.useMemo(()=>fe.find(g=>g.id===b)??fe[0]??null,[fe,b]),Me=c.useMemo(()=>{const g=Oe?xn(Oe)?l("conversation.modelUseCliDefault"):Oe.name:l("conversation.modelUseCliDefault");return R?`${(Pe==null?void 0:Pe.label)??l("conversation.deploymentDefaultPreset")} · ${g}`:g},[Oe,Pe,R]),De=c.useCallback(g=>{if(m(g),L(Be(g)),t&&g===t.provider&&yn(g)){X(p.providerConfigMode),te(p.providerPresetId);return}X("global-default"),te(null)},[Be,t,p.providerConfigMode,p.providerPresetId]),Re=c.useMemo(()=>{const g=K[k]??(k===(t==null?void 0:t.provider)&&J.providerConfigMode===p.providerConfigMode&&J.providerPresetId===p.providerPresetId?s:U);return!g||g.canStartSession!==!1?null:g.limitations[0]??l("conversation.capabilityDenied")},[s,U,K,k,J.providerConfigMode,J.providerPresetId,t==null?void 0:t.provider,p.providerConfigMode,p.providerPresetId]),et=c.useMemo(()=>{var je;if(!x||typeof window>"u")return null;const g=(je=e.current)==null?void 0:je.getBoundingClientRect(),Y=g?Math.max(80,g.left+80):96,Q=g?Math.min(Te.width-80,g.right-80):Te.width-96,ye=g?Math.max(12,g.top+12):12,qe=g?Math.max(ye,g.bottom-48):Math.max(12,Te.height-48),We=x.rect.left+x.rect.width/2;return{left:jn(We,Y,Math.max(Y,Q)),top:jn(x.rect.top-48,ye,qe)}},[e,x,Te.height,Te.width]);c.useEffect(()=>{if(typeof window>"u")return;const g=()=>{Ne({width:window.innerWidth,height:window.innerHeight})};return g(),window.addEventListener("resize",g),()=>{window.removeEventListener("resize",g)}},[]),c.useEffect(()=>{if(!t){me.current!==null&&typeof window<"u"&&(window.clearTimeout(me.current),me.current=null),Ce.current=null,he.current=!1,v(null),M(null),y(!1);return}const g=Ps(t.provider);De(g)},[De,t]),c.useEffect(()=>{if(!j){S(!1);return}if(!we){S(!1);return}let g=!1;return S(!0),Xi().then(Y=>{g||ge(Object.fromEntries(Y.items.map(Q=>[Q.app,Q])))}).catch(()=>{g||ge({})}).finally(()=>{g||S(!1)}),()=>{g=!0}},[j,we]),c.useEffect(()=>{!we||J.providerConfigMode!=="cc-switch-preset"||!J.providerPresetId||B||!Fe||Fe.options.some(g=>g.id===J.providerPresetId)||(X("global-default"),te(null))},[B,Fe,we,J.providerConfigMode,J.providerPresetId]),c.useEffect(()=>{if(!t||!e.current||typeof window>"u"){me.current!==null&&(window.clearTimeout(me.current),me.current=null),Ce.current=null,he.current=!1,v(null),M(null);return}const g=e.current,Y=_e=>{q.current||(Ce.current=_e,v(_e),_e||y(!1))},Q=()=>{me.current!==null&&(window.clearTimeout(me.current),me.current=null)},ye=(_e,lt)=>{if(Ce.current=_e,Q(),lt!=null&&lt.immediate){Y(_e);return}me.current=window.setTimeout(()=>{me.current=null,Y(Ce.current)},ta)},qe=()=>{const _e=Rs(g);if(he.current){Ce.current=_e;return}ye(_e)},We=()=>{const _e=Rs(g);if(he.current){Ce.current=_e;return}ye(_e,{immediate:!0})},je=_e=>{!(_e.target instanceof Node)||!g.contains(_e.target)||(he.current=!0,Q())},Le=()=>{he.current&&(he.current=!1,ye(Rs(g)))};return document.addEventListener("pointerdown",je),document.addEventListener("selectionchange",qe),window.addEventListener("pointerup",Le),window.addEventListener("pointercancel",Le),window.addEventListener("mouseup",Le),window.addEventListener("touchend",Le),window.addEventListener("resize",We),window.addEventListener("scroll",We,!0),()=>{Q(),document.removeEventListener("pointerdown",je),document.removeEventListener("selectionchange",qe),window.removeEventListener("pointerup",Le),window.removeEventListener("pointercancel",Le),window.removeEventListener("mouseup",Le),window.removeEventListener("touchend",Le),window.removeEventListener("resize",We),window.removeEventListener("scroll",We,!0)}},[e,t]),c.useEffect(()=>{(!j||!(w!=null&&w.sourceMessageId))&&P(!1)},[j,w==null?void 0:w.sourceMessageId]),c.useEffect(()=>{if(!j||!t)return;let g=!1;return k===t.provider&&J.providerConfigMode===p.providerConfigMode&&J.providerPresetId===p.providerPresetId&&s?(de(!1),H(s),()=>{g=!0}):(de(!0),H(At(k)),gr(k,t.workspaceId,we?{providerConfigMode:J.providerConfigMode,providerPresetId:J.providerPresetId}:void 0).then(Y=>{g||H(Y)}).catch(()=>{g||H(At(k))}).finally(()=>{g||de(!1)}),()=>{g=!0})},[j,s,we,k,J.providerConfigMode,J.providerPresetId,t,p.providerConfigMode,p.providerPresetId]),c.useEffect(()=>{if(!j||!t){oe({});return}let g=!1;return zi(se,t.workspaceId).then(Y=>{g||oe(Y)}),()=>{g=!0}},[j,t,se]),c.useEffect(()=>{if(!j||!t)return;const g=se.filter(Q=>{const ye=K[Q];return!ye||ye.canStartSession!==!1});if(g.length===0||g.includes(k))return;const Y=g[0];De(Y)},[j,De,K,k,t,se]),c.useEffect(()=>{var Y;const g=Be(k);if(!fe.some(Q=>Q.id===b)){if(fe.some(Q=>Q.id===g)){L(g);return}L(((Y=fe[0])==null?void 0:Y.id)??Yt)}},[fe,Be,b,k]),c.useEffect(()=>{if(!j){q.current=!1;return}q.current=!0},[j]),c.useEffect(()=>{if(typeof window>"u")return;const g=Y=>{Y.key==="Escape"&&(y(!1),M(null),v(null),q.current=!1)};return window.addEventListener("keydown",g),()=>{window.removeEventListener("keydown",g)}},[]);async function it(){var Y,Q;if(!x)return;const g=x.text;v(null),typeof window<"u"&&((Q=(Y=window.getSelection())==null?void 0:Y.removeAllRanges)==null||Q.call(Y));try{await na(g,r),a({title:l("conversation.copyContentSuccess"),tone:"success"})}catch(ye){a({title:ye instanceof Error?ye.message:l("conversation.copyContentFailed"),tone:"error"})}}function ht(){x&&(re({title:"",content:x.text}),ae(g=>g+1),z(!0),y(!1),M(null),v(null),q.current=!1)}function ft(){var Q,ye;if(!x||!t)return;const g=x,Y=Ps(t.provider,se.length>0?se:ts);De(Y),_(""),P(!1),M(g),v(null),y(!0),typeof window<"u"&&((ye=(Q=window.getSelection())==null?void 0:Q.removeAllRanges)==null||ye.call(Q))}function Ze(g){g.preventDefault(),q.current=!0}function tt(){W.current=!0,ft()}function pt(){if(W.current){W.current=!1;return}ft()}async function Ae(){var g,Y,Q,ye;if(!(!w||!t)){if(Re){a({title:Re,tone:"error"});return}E(!0);try{const qe=oa(w.text,C),We=(Oe==null?void 0:Oe.id)===Yt?null:(Oe==null?void 0:Oe.id)??null;let je=null;if(A&&w.sourceMessageId)je=await vr(t.sessionId,{sourceType:"message",sourceMessageId:w.sourceMessageId,strategy:"auto",targetProvider:k,providerConfigMode:J.providerConfigMode,providerPresetId:J.providerPresetId,sessionKind:"annotation",annotationSourceMessageId:w.sourceMessageId,annotationSourceText:w.text}),h(je),await sn(je.sessionId,{content:qe,clientRequestId:((Y=(g=globalThis.crypto)==null?void 0:g.randomUUID)==null?void 0:Y.call(g))??`selection-action-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:We,permissionMode:ct(),providerConfigMode:J.providerConfigMode,providerPresetId:J.providerPresetId});else{const Le=await br({workspaceId:t.workspaceId,provider:k,content:qe,clientRequestId:((ye=(Q=globalThis.crypto)==null?void 0:Q.randomUUID)==null?void 0:ye.call(Q))??`selection-action-${Date.now()}-${Math.random().toString(16).slice(2)}`,model:We,permissionMode:ct(),providerConfigMode:J.providerConfigMode,providerPresetId:J.providerPresetId,parentSessionId:t.sessionId,sessionKind:"annotation",annotationSourceMessageId:w.sourceMessageId??null,annotationSourceText:w.text});je=Le.session??await wr(Le.sessionId)}h(je),u(),d(je.workspaceId),n(Xe(je.workspaceId,je.sessionId)),y(!1),M(null),v(null),q.current=!1}catch(qe){a({title:qe instanceof Error?qe.message:l("conversation.selectionActionFailed"),tone:"error"})}finally{E(!1)}}}function st(g=!1){y(!1),M(null),q.current=!1,g&&v(null)}const ot=!!(!j&&x&&et),Ve=!!(j&&w),ke=i.jsxs(ps,{children:[i.jsx("button",{type:"button",className:"secondary-button",onClick:()=>st(!1),children:l("common.cancel")}),i.jsx("button",{type:"button",className:"primary-button",disabled:ve||!!Re||se.length===0,onClick:()=>void Ae(),children:ve?l("conversation.sendingState"):l("conversation.selectionActionSubmit")})]}),ce=w?i.jsxs(i.Fragment,{children:[i.jsx(vt,{className:"conversation-selection-preview-section",heading:l("conversation.selectionActionPreviewLabel"),children:i.jsx("div",{className:"conversation-selection-action-dialog-quote",children:w.text})}),i.jsxs(vt,{className:"conversation-selection-request-section",children:[i.jsx(Jt,{className:"conversation-selection-field conversation-selection-prompt-field",label:l("conversation.selectionActionPromptLabel"),children:i.jsx("textarea",{value:C,rows:4,placeholder:l("conversation.selectionActionPromptPlaceholder"),onChange:g=>_(g.target.value)})}),i.jsxs("div",{className:"conversation-selection-context-block",children:[i.jsxs("label",{className:"conversation-selection-checkbox",children:[i.jsx("input",{type:"checkbox",checked:A,disabled:!w.sourceMessageId,onChange:g=>P(g.target.checked)}),i.jsx("span",{children:l("conversation.selectionActionIncludeContext")})]}),w.sourceMessageId?null:i.jsx("p",{className:"conversation-selection-hint",children:l("conversation.selectionActionContextUnavailable")}),Re?i.jsx("p",{className:"conversation-selection-hint",children:Re}):null]})]}),i.jsx(vt,{className:"conversation-selection-target-section",heading:l("conversation.selectionActionTargetLabel"),children:i.jsxs("div",{className:"conversation-selection-grid",children:[i.jsx(Jt,{className:"conversation-selection-field",label:l("conversation.forkTargetProviderLabel"),children:i.jsx("select",{value:k,onChange:g=>{De(g.target.value)},children:se.map(g=>{var Y;return i.jsx("option",{value:g,disabled:((Y=K[g])==null?void 0:Y.canStartSession)===!1,children:Lt(g,"full")},g)})})}),i.jsx(Jt,{className:"conversation-selection-field",label:l("conversation.forkTargetModelLabel"),children:we?i.jsx("div",{className:"conversation-selection-deployment-select",children:i.jsx(Mo,{ariaLabel:l("conversation.forkTargetModelLabel"),triggerLabel:Me,presetOptions:N,selectedPresetValue:Ie,selectedPresetSummary:(Pe==null?void 0:Pe.summary)??null,onSelectPreset:g=>{if(g===Is){X("global-default"),te(null);return}X("cc-switch-preset"),te(g)},modelOptions:le,selectedModelValue:b,onSelectModel:L,loadingPresets:B,loadingModels:ue,modelColumnDisabled:ue||!!Re,showPresetColumn:R,modelEmptyText:l("conversation.deploymentModelEmpty")})}):i.jsx("select",{value:b,disabled:ue||!!Re,onChange:g=>L(g.target.value),children:fe.map(g=>i.jsx("option",{value:g.id,children:g.name},g.id))})})]})})]}):null;return!t||!ot&&!Ve||typeof document>"u"?i.jsx(Pn,{open:V,preferredWorkspaceId:(t==null?void 0:t.workspaceId)??null,preferredSessionId:(t==null?void 0:t.sessionId)??null,creationRequestId:$,initialDraft:F,onClose:()=>z(!1)}):i.jsxs(i.Fragment,{children:[It.createPortal(ot?i.jsxs("div",{className:"conversation-selection-toolbar",style:et??void 0,onMouseDown:g=>g.preventDefault(),children:[i.jsx("button",{type:"button",className:"conversation-selection-action",onClick:()=>void it(),children:l("conversation.copyAction")}),i.jsx("button",{type:"button",className:"conversation-selection-action",onClick:ht,children:l("conversation.selectionTodoAction")}),i.jsx("button",{type:"button",className:"conversation-selection-action is-primary",onPointerDown:Ze,onMouseDown:Ze,onPointerUp:tt,onClick:pt,children:l("conversation.selectionActionButton")})]}):null,document.body),Ee?i.jsx(Yi,{open:Ve,title:l("conversation.selectionActionButton"),height:"auto",kind:"form",showHandle:!0,showCancelButton:!1,cardClassName:"conversation-selection-action-dialog",bodyClassName:"conversation-selection-action-dialog-body",footer:ke,onClose:()=>st(!1),children:ce}):i.jsx(fs,{open:Ve,title:l("conversation.selectionActionButton"),size:"compact",layout:"form",className:"conversation-selection-action-dialog",bodyClassName:"conversation-selection-action-dialog-body",footer:ke,onClose:()=>st(!1),children:ce}),i.jsx(Pn,{open:V,preferredWorkspaceId:t.workspaceId,preferredSessionId:t.sessionId,creationRequestId:$,initialDraft:F,onClose:()=>z(!1)})]})}const Et=5,Wr=["codex","claude-code"];function Ur(){return[{id:"recommended",label:l("conversation.butlerCompletionTemplateRecommendedLabel"),description:l("conversation.butlerCompletionTemplateRecommendedDescription"),value:l("conversation.butlerCompletionTemplateRecommendedValue")},{id:"spec-finish",label:l("conversation.butlerCompletionTemplateSpecLabel"),description:l("conversation.butlerCompletionTemplateSpecDescription"),value:l("conversation.butlerCompletionTemplateSpecValue")},{id:"bugfix",label:l("conversation.butlerCompletionTemplateBugfixLabel"),description:l("conversation.butlerCompletionTemplateBugfixDescription"),value:l("conversation.butlerCompletionTemplateBugfixValue")}]}function Ts(){var e;return((e=Ur()[0])==null?void 0:e.value)??""}function Cs(e,t=Wr){return e==="claude-code"&&t.includes("claude-code")?"claude-code":t.includes("codex")?"codex":t[0]??null}function $r(e){return e==="codex"||e==="claude-code"}function la(e){return e.flatMap(t=>!t.enabled||!$r(t.provider)?[]:[t.provider])}function Vr({session:e,showTrigger:t=!0,openRequestKey:s=0}){const{showToast:n}=at(),{requestNavigationRefresh:r}=xt(),a=c.useId(),o=c.useId(),u=c.useId(),d=c.useId(),[h,f]=c.useState(!1),[p,x]=c.useState(!1),[v,w]=c.useState(null),[M,j]=c.useState(null),[y,O]=c.useState(null),[C,_]=c.useState(Cs(e==null?void 0:e.provider)),[A,P]=c.useState(""),[k,m]=c.useState(()=>Ts()),[b,L]=c.useState(Et),[G,X]=c.useState(!1),[Z,te]=c.useState(0),{items:D}=Ki(!!(e!=null&&e.sessionId)),ge=Ur(),B=c.useMemo(()=>D?la(D):Wr,[D]),S=D!==null&&B.length===0,U=c.useMemo(()=>{var F;return((F=e==null?void 0:e.title)==null?void 0:F.trim())||null},[e==null?void 0:e.title]),H=c.useMemo(()=>v?{workspaceId:v.workspaceId,project:v.project,session:v.session}:null,[v]),K=(v==null?void 0:v.latestFollowUpTask)??null,oe=(v==null?void 0:v.latestVerificationRun)??null,ue=K&&(K.status==="active"||K.status==="waiting_user")?K:null,de=oe&&(oe.status==="queued"||oe.status==="running")?oe:null;c.useEffect(()=>{f(!1),X(!1),j(null),w(null),P(""),_(Cs(e==null?void 0:e.provider)),m(Ts()),L(Et)},[e==null?void 0:e.sessionId]),c.useEffect(()=>{const F=Cs(e==null?void 0:e.provider,B);(!C||!B.includes(C))&&_(F)},[B,C,e==null?void 0:e.provider]),c.useEffect(()=>{if(!(e!=null&&e.sessionId)){x(!1);return}let F=!1;return x(!0),j(null),So(e.sessionId).then(re=>{F||w(re.context)}).catch(re=>{F||(w(null),j(re instanceof Error?re.message:l("conversation.butlerActionLoadFailed")))}).finally(()=>{F||x(!1)}),()=>{F=!0}},[Z,e==null?void 0:e.sessionId]);function ve(){p||te(F=>F+1)}function E(){!v&&!p&&ve()}if(c.useEffect(()=>{t||s<=0||(f(!0),E())},[p,s,t,v]),!(e!=null&&e.sessionId))return null;async function V(){if(!H){E();return}if(!C)return;const F=A.trim(),re=k.trim();if(!F){n({title:l("conversation.butlerFollowUpObjectiveRequired"),tone:"warning"});return}if(!re){n({title:l("conversation.butlerFollowUpCompletionCriteriaRequired"),tone:"warning"});return}O("follow-up");try{const Te=await Ro({projectId:H.project.id,butlerSessionId:H.session.id,providerId:C,objective:F,completionCriteria:re,maxAutoContinueCount:b});w(Ne=>Ne&&{...Ne,latestFollowUpTask:Te.task}),r(),n({title:l("conversation.butlerFollowUpStarted"),description:l("conversation.butlerFollowUpStartedDescription",{projectName:H.project.name}),tone:"success"}),P(""),m(Ts()),L(Et),f(!1)}catch(Te){n({title:l("conversation.butlerFollowUpFailed"),description:Te instanceof Error?Te.message:void 0,tone:"error"})}finally{O(null)}}async function z(){if(K){O("follow-up");try{const F=await yo(K.id);w(re=>re&&{...re,latestFollowUpTask:F.task}),r(),n({title:l("conversation.butlerFollowUpStopped"),description:l("conversation.butlerFollowUpStoppedDescription"),tone:"success"}),f(!1)}catch(F){n({title:l("conversation.butlerFollowUpStopFailed"),description:F instanceof Error?F.message:void 0,tone:"error"})}finally{O(null)}}}async function $(){if(!H){E();return}O("verification");try{const F=await Po({projectId:H.project.id,butlerSessionId:H.session.id,verificationType:"browser",targetRef:U||H.session.title||H.project.name});w(re=>re&&{...re,latestVerificationRun:F.result.run}),r(),n({title:l("conversation.butlerVerificationStarted"),description:l("conversation.butlerVerificationStartedDescription",{projectName:H.project.name}),tone:"success"}),f(!1)}catch(F){n({title:l("conversation.butlerVerificationFailed"),description:F instanceof Error?F.message:void 0,tone:"error"})}finally{O(null)}}async function ae(){if(oe){O("verification");try{const F=await xo(oe.projectId,oe.id);w(re=>re&&{...re,latestVerificationRun:F.run}),r(),n({title:l("conversation.butlerVerificationStopped"),description:l("conversation.butlerVerificationStoppedDescription"),tone:"success"}),f(!1)}catch(F){n({title:l("conversation.butlerVerificationStopFailed"),description:F instanceof Error?F.message:void 0,tone:"error"})}finally{O(null)}}}return i.jsxs(i.Fragment,{children:[t?i.jsxs("div",{className:"conversation-butler-entry",onMouseEnter:()=>{X(!0),E()},onMouseLeave:()=>{X(!1)},children:[i.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":l("conversation.butlerActionButton"),title:l("conversation.butlerActionButton"),onFocus:()=>{X(!0),E()},onBlur:()=>{X(!1)},onClick:()=>{f(!0),E()},children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(Io,{})})}),G?i.jsxs("div",{className:"conversation-butler-analysis-popover",role:"status","aria-live":"polite",children:[i.jsx("strong",{children:l("conversation.butlerAnalysisTitle")}),p?i.jsx("p",{children:l("conversation.butlerActionLoading")}):M?i.jsx("p",{children:M}):K?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:[l("conversation.butlerAnalysisObjectiveLabel"),":",K.objective]}),i.jsxs("p",{children:[l("conversation.butlerAnalysisStatusLabel"),":",Nn(K.status)]}),i.jsxs("p",{children:[l("conversation.butlerAnalysisSummaryLabel"),":",K.lastAutomationSummary||K.waitingReason||l("conversation.butlerAnalysisEmpty")]}),K.waitingReason?i.jsxs("p",{children:[l("conversation.butlerAnalysisWaitingReasonLabel"),":",K.waitingReason]}):null]}):i.jsx("p",{children:l("conversation.butlerAnalysisEmpty")})]}):null]}):null,i.jsx(Ui,{open:h,title:l("conversation.butlerActionModalTitle"),description:l("conversation.butlerActionModalDescription"),className:"conversation-butler-modal-card",footer:!p&&!M&&H?i.jsxs(ps,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:y!==null,onClick:()=>{$()},children:l("conversation.butlerVerificationAction")}),i.jsx("button",{type:"button",className:"primary-button",disabled:y!==null||S||!C,onClick:()=>{V()},children:l("conversation.butlerFollowUpAction")})]}):void 0,onClose:()=>{y||f(!1)},children:i.jsxs("div",{className:"conversation-butler-modal",children:[p?i.jsx("p",{className:"conversation-butler-modal-hint",children:l("conversation.butlerActionLoading")}):null,!p&&M?i.jsx("p",{className:"conversation-butler-modal-error",children:M}):null,!p&&!M&&H?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"conversation-butler-target-grid",children:[i.jsxs("div",{className:"conversation-butler-target-card",children:[i.jsx("span",{children:l("conversation.butlerActionProjectLabel")}),i.jsx("strong",{children:H.project.name})]}),i.jsxs("div",{className:"conversation-butler-target-card",children:[i.jsx("span",{children:l("conversation.butlerActionSessionLabel")}),i.jsx("strong",{children:H.session.title||U||H.session.sessionId})]})]}),i.jsxs("div",{className:"conversation-butler-follow-up-grid",children:[i.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field",children:[i.jsxs("div",{className:"conversation-butler-field-heading",children:[i.jsx("label",{children:l("conversation.butlerFollowUpProviderLabel")}),i.jsx("small",{children:l("conversation.butlerFollowUpProviderHint")})]}),S?i.jsx("p",{className:"conversation-butler-modal-hint",children:l("conversation.butlerFollowUpProviderHint")}):i.jsx(Qi,{workspaceId:H.workspaceId,providers:B,selectedProvider:C,disabled:y!==null,onSelect:F=>{$r(F)&&_(F)}})]}),i.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field conversation-butler-round-limit-field",children:[i.jsxs("div",{className:"conversation-butler-field-heading",children:[i.jsx("label",{htmlFor:d,children:l("conversation.butlerFollowUpRoundLimitLabel")}),i.jsx("small",{children:l("conversation.butlerFollowUpRoundLimitHint")})]}),i.jsx("input",{id:d,type:"number",min:1,max:20,value:b,disabled:y!==null,onChange:F=>{const re=Number.parseInt(F.target.value,10);L(Number.isFinite(re)?re:Et)}})]})]}),i.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field",children:[i.jsx("label",{htmlFor:a,children:l("conversation.butlerFollowUpObjectiveLabel")}),i.jsx("textarea",{id:a,rows:3,value:A,placeholder:l("conversation.butlerFollowUpObjectivePlaceholder"),disabled:y!==null,onChange:F=>{P(F.target.value)}})]}),i.jsxs("div",{className:"workbench-modal-field conversation-butler-modal-field",children:[i.jsxs("div",{className:"conversation-butler-field-heading",children:[i.jsx("label",{htmlFor:o,children:l("conversation.butlerFollowUpCompletionCriteriaLabel")}),i.jsx("small",{id:u,children:l("conversation.butlerCompletionTemplateSectionHint")})]}),i.jsx("textarea",{id:o,rows:3,value:k,placeholder:l("conversation.butlerFollowUpCompletionCriteriaPlaceholder"),"aria-describedby":u,disabled:y!==null,onChange:F=>{m(F.target.value)}}),i.jsx("div",{className:"conversation-butler-preset-grid",role:"group","aria-label":l("conversation.butlerCompletionTemplateSectionLabel"),children:ge.map(F=>i.jsxs("button",{type:"button",className:"conversation-butler-preset-card","data-selected":k.trim()===F.value,"aria-pressed":k.trim()===F.value,disabled:y!==null,onClick:()=>{m(F.value)},children:[i.jsx("strong",{children:F.label}),i.jsx("span",{children:F.description})]},F.id))})]}),ue||de?i.jsxs("div",{className:"conversation-butler-meta-grid",children:[ue?i.jsxs("div",{className:"conversation-butler-target-card conversation-butler-current-task-card",children:[i.jsx("span",{children:l("conversation.butlerCurrentFollowUpLabel")}),i.jsx("strong",{children:Nn(ue.status)}),i.jsx("small",{children:l("conversation.butlerCurrentFollowUpProgress",{current:ue.autoContinueCount,max:ue.maxAutoContinueCount??Et})}),i.jsx("button",{type:"button",className:"workbench-secondary-button",disabled:y!==null,onClick:()=>{z()},children:l("conversation.butlerStopFollowUpAction")})]}):null,de?i.jsxs("div",{className:"conversation-butler-target-card conversation-butler-current-task-card",children:[i.jsx("span",{children:l("conversation.butlerCurrentVerificationLabel")}),i.jsx("strong",{children:ca(de.status)}),i.jsx("small",{children:de.targetRef||de.verificationType}),i.jsx("button",{type:"button",className:"workbench-secondary-button",disabled:y!==null,onClick:()=>{ae()},children:l("conversation.butlerStopVerificationAction")})]}):null]}):null]}):null]})})]})}function Nn(e){switch(e){case"waiting_user":return l("shell.butlerAutomationStatusWaitingUser");case"completed":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":return l("shell.butlerAutomationStatusCancelled");case"active":default:return l("shell.butlerAutomationStatusActive")}}function ca(e){switch(e){case"queued":case"running":return l("shell.butlerAutomationStatusActive");case"passed":case"skipped":return l("shell.butlerAutomationStatusCompleted");case"failed":return l("shell.butlerAutomationStatusFailed");case"cancelled":default:return l("shell.butlerAutomationStatusCancelled")}}const ua=340;function da({session:e,onOpenBranchTree:t}){const s=dt(),n=cn(),r=c.useRef(null),a=c.useRef(null),[o,u]=c.useState(!1),[d,h]=c.useState(null),[f,p]=c.useState(null),[x,v]=c.useState(0);c.useEffect(()=>{u(!1),h(null)},[n.pathname,n.search]),c.useLayoutEffect(()=>{if(!o||!d||typeof window>"u"){p(null);return}const P=()=>{var L,G;const b=Co(d,{width:((L=a.current)==null?void 0:L.offsetWidth)??0,height:((G=a.current)==null?void 0:G.offsetHeight)??0},{width:window.innerWidth,height:window.innerHeight},{estimatedHeightPx:ua});p({position:"fixed",left:`${Math.round(b.left)}px`,top:`${Math.round(b.top)}px`,width:`${Math.round(b.width)}px`,maxWidth:"calc(100vw - 24px)",maxHeight:`${Math.round(b.maxHeight)}px`,transformOrigin:b.transformOrigin})},k=b=>{var G,X;const L=b.target;L&&!((G=a.current)!=null&&G.contains(L))&&!((X=r.current)!=null&&X.contains(L))&&M()},m=b=>{b.key==="Escape"&&M()};return P(),window.addEventListener("pointerdown",k),window.addEventListener("keydown",m),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0),()=>{window.removeEventListener("pointerdown",k),window.removeEventListener("keydown",m),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}},[d,o]);function w(){var k;const P=(k=r.current)==null?void 0:k.getBoundingClientRect();P&&(h({x:P.right,y:P.bottom}),u(!0))}function M(){u(!1),h(null)}function j(P){s(P),M()}function y(P){const k=new URLSearchParams(n.search);k.set("toolPanel",P),j(`${n.pathname}?${k.toString()}`)}function O(){if(o){M();return}w()}function C(P){P.key!=="ContextMenu"&&!(P.shiftKey&&P.key==="F10")||(P.preventDefault(),P.stopPropagation(),w())}if(!e)return null;const _=[{key:"assistant",label:l("shell.butlerEntry"),onSelect:()=>{v(P=>P+1),M()}},...t?[{key:"branch",label:l("conversation.branchAction"),onSelect:()=>{t(),M()}}]:[],{key:"files",label:l("shell.filesEntry"),onSelect:()=>{y("files")}},{key:"git",label:l("shell.gitEntry"),onSelect:()=>{y("git")}},{key:"processes",label:l("shell.mobileConversationToolProcessesTab"),onSelect:()=>{y("processes")}}],A=o&&typeof document<"u"?It.createPortal(i.jsx("div",{ref:a,className:"session-action-menu mobile-conversation-action-menu surface-card",role:"menu","aria-label":l("conversation.moreSessionActions"),style:f??{position:"fixed",top:0,left:0,visibility:"hidden"},onClick:P=>P.stopPropagation(),children:_.map(P=>i.jsx("button",{type:"button",className:"session-action-menu-item mobile-conversation-action-menu-item",role:"menuitem",onClick:P.onSelect,children:P.label},P.key))}),document.body):null;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"mobile-conversation-session-actions",children:[i.jsx("button",{ref:r,type:"button",className:"conversation-header-ai-button mobile-conversation-more-button","aria-label":l("conversation.moreSessionActions"),title:l("conversation.moreSessionActions"),"aria-haspopup":"menu","aria-expanded":o,onClick:O,onKeyDown:C,children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(To,{})})}),i.jsx(Vr,{session:e,showTrigger:!1,openRequestKey:x})]}),A]})}function Gr({items:e,deletingQueueItemId:t=null,steeringQueueItemId:s=null,canSteer:n=!1,onDelete:r,onSteer:a}){return e.length===0?null:i.jsxs("section",{className:"queued-message-list","aria-label":l("conversation.queueTitle"),children:[i.jsx("div",{className:"queued-message-list__header",children:i.jsx("h2",{children:`${l("conversation.queueTitle")} · ${e.length}`})}),i.jsx("div",{className:"queued-message-list__items",children:e.map((o,u)=>{const d=o.status==="queued"||o.status==="failed",h=n&&typeof a=="function"&&(o.status==="queued"||o.status==="failed");return i.jsxs("article",{className:"queued-message-item",children:[i.jsxs("div",{className:"queued-message-item__main",children:[i.jsx("span",{className:"queued-message-item__order","aria-hidden":"true",children:u+1}),i.jsx("p",{className:"queued-message-item__content",title:o.content||l("conversation.queueImageOnly"),children:o.content||l("conversation.queueImageOnly")}),i.jsx("span",{className:`queued-message-item__status queued-message-item__status--${o.status}`,children:o.status==="failed"?l("conversation.queueStatusFailed"):l("conversation.queueStatusQueued")}),i.jsxs("div",{className:"queued-message-item__actions",children:[h?i.jsx("button",{type:"button",className:"queued-message-item__action queued-message-item__action--steer",onClick:()=>void a(o.id),disabled:s===o.id,"aria-label":l("conversation.queueSteer"),title:l("conversation.queueSteer"),children:s===o.id?l("conversation.queueSteering"):l("conversation.queueSteer")}):null,d?i.jsx("button",{type:"button",className:"queued-message-item__action queued-message-item__action--delete",onClick:()=>void r(o.id),disabled:t===o.id,"aria-label":l("conversation.queueDelete"),title:l("conversation.queueDelete"),children:t===o.id?"…":"×"}):null]})]}),o.errorDetail?i.jsx("p",{className:"queued-message-item__error",children:o.errorDetail}):null]},o.id)})})]})}function ha(e){const{sending:t,setSending:s,session:n,runtimeHasActiveRun:r,runtimeCanInterrupt:a}=e,o=c.useRef(!1);c.useEffect(()=>{if(!t){o.current=!1;return}if(fa(n,r,a)){o.current=!0;return}o.current&&(o.current=!1,s(!1))},[a,r,t,n,s])}function fa(e,t,s){return t===!0||s===!0||(e==null?void 0:e.runningState)==="stale"||(e==null?void 0:e.runningState)==="unknown"?!0:Sr(e)}const pa=30,ks=80,jt=60,Xr=600,On=300*1e3,ma=600,ga=5e3,va=1e4,Vs=120*1e3,ba=8,wa=/\[\[CODINGNS_IMAGE_ATTACHMENTS\]\][\s\S]*?\[\[\/CODINGNS_IMAGE_ATTACHMENTS\]\]/g;class Ma{constructor(t,s={}){xe(this,"state");xe(this,"authoritativeMessages",[]);xe(this,"runtimeOverlayMessages",[]);xe(this,"activeRuntimeOverlayKeys",[]);xe(this,"pendingMessages",[]);xe(this,"listeners",new Set);xe(this,"realtimeClient",null);xe(this,"historyBootstrapFallbackTimer",null);xe(this,"historyBootstrapEnvelopeReceived",!1);xe(this,"markSeenTimer",null);xe(this,"markSeenInFlight",!1);xe(this,"lastMarkSeenRequestAt",0);xe(this,"seenWatermark",null);xe(this,"runtimeRefreshTimer",null);xe(this,"runtimeRefreshMode",null);xe(this,"replaceSnapshotSeedOnBackfill",!1);xe(this,"olderHistoryPrefetchCursor",null);xe(this,"olderHistoryPrefetchPromise",null);xe(this,"prefetchedOlderHistoryPage",null);xe(this,"pendingReplyDebugTraces",[]);xe(this,"hasAuthoritativeBootstrapMessages");xe(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));xe(this,"getState",()=>this.state);var o;this.sessionId=t,this.options=s;const n=Rn(qs(t),On);this.hasAuthoritativeBootstrapMessages=(((o=s.bootstrapMessages)==null?void 0:o.length)??0)>0;const r=Kt(s.initialSession??null,(n==null?void 0:n.session)??null),a=Bn(Sa(),this.sessionId,{type:"timeline.seed",source:"constructor_seed",snapshotMessages:(n==null?void 0:n.messages)??[],bootstrapMessages:s.bootstrapMessages??[],replaceSnapshotSeedOnBackfill:!this.hasAuthoritativeBootstrapMessages&&((n==null?void 0:n.messages.length)??0)>0&&((n==null?void 0:n.messages.length)??0)<jt&&((n==null?void 0:n.pagesLoaded)??0)<=1});this.authoritativeMessages=a.timeline.authoritativeMessages,this.runtimeOverlayMessages=a.timeline.runtimeOverlayMessages,this.activeRuntimeOverlayKeys=a.timeline.activeRuntimeOverlayKeys,this.pendingMessages=a.timeline.pendingMessages,this.replaceSnapshotSeedOnBackfill=a.timeline.replaceSnapshotSeedOnBackfill,this.state=Tn({session:r,capabilities:(n==null?void 0:n.capabilities)??null,runtimeHasActiveRun:(n==null?void 0:n.runtimeHasActiveRun)??null,runtimeCanInterrupt:(n==null?void 0:n.runtimeCanInterrupt)??null,contextUsage:(n==null?void 0:n.contextUsage)??null,messages:a.messages,timelineItems:js(r,a.messages),permissionRequests:(n==null?void 0:n.permissionRequests)??[],queuedMessages:(n==null?void 0:n.queuedMessages)??[],olderCursor:(n==null?void 0:n.olderCursor)??null,hasOlderMessages:(n==null?void 0:n.hasOlderMessages)??!1,lastCursor:(n==null?void 0:n.lastCursor)??null,interruptSource:(n==null?void 0:n.interruptSource)??null,pagesLoaded:(n==null?void 0:n.pagesLoaded)??0}),this.seenWatermark=(r==null?void 0:r.lastSeenAt)??null}async initialize(){this.historyBootstrapEnvelopeReceived=!1,this.clearHistoryBootstrapFallbackTimer(),this.clearOlderHistoryPrefetch();const t=this.options.bootstrapMessages??[],s=this.applyTimelineEvent({type:"history.merge",source:"initialize_bootstrap",messages:t,replaceSnapshotSeed:!1}),n=this.hasAuthoritativeBootstrapMessages;this.patch({messages:s.messages,historyState:Qa(this.state.session,n?this.authoritativeMessages.length:0),loadingOlderMessages:!1,olderCursor:n?null:this.state.olderCursor,hasOlderMessages:gt({session:this.state.session,loadedMessageCount:this.authoritativeMessages.length,olderCursor:n?null:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),pagesLoaded:n?Math.max(this.state.pagesLoaded,1):this.state.pagesLoaded,errorCode:null,errorDetail:null}),this.shouldRefreshSessionDetail()&&this.refreshSessionMetadata(),this.shouldRefreshRuntimeSnapshot()&&this.refreshRuntimeSnapshot("bootstrap"),this.refreshPermissionRequests(),this.refreshQueue();try{this.startRealtime(),n&&this.scheduleMarkSeen()}catch(r){this.handleError(r)}}async reload(){var n,r;this.clearHistoryBootstrapFallbackTimer(),this.historyBootstrapEnvelopeReceived=!1,this.clearOlderHistoryPrefetch(),(n=this.realtimeClient)==null||n.close(),this.realtimeClient=null;const t=Rn(qs(this.sessionId),On),s=this.applyTimelineEvent({type:"timeline.seed",source:"reload_seed",snapshotMessages:(t==null?void 0:t.messages)??[],bootstrapMessages:this.options.bootstrapMessages??[],replaceSnapshotSeedOnBackfill:!this.hasAuthoritativeBootstrapMessages&&((t==null?void 0:t.messages.length)??0)>0&&((t==null?void 0:t.messages.length)??0)<jt&&((t==null?void 0:t.pagesLoaded)??0)<=1});this.state=Tn({session:Kt(this.options.initialSession??null,(t==null?void 0:t.session)??null),capabilities:(t==null?void 0:t.capabilities)??null,runtimeHasActiveRun:(t==null?void 0:t.runtimeHasActiveRun)??null,runtimeCanInterrupt:(t==null?void 0:t.runtimeCanInterrupt)??null,contextUsage:(t==null?void 0:t.contextUsage)??null,messages:s.messages,permissionRequests:(t==null?void 0:t.permissionRequests)??[],queuedMessages:(t==null?void 0:t.queuedMessages)??[],olderCursor:(t==null?void 0:t.olderCursor)??null,hasOlderMessages:(t==null?void 0:t.hasOlderMessages)??!1,lastCursor:(t==null?void 0:t.lastCursor)??null,pagesLoaded:(t==null?void 0:t.pagesLoaded)??0}),this.seenWatermark=((r=this.state.session)==null?void 0:r.lastSeenAt)??null,this.emit(),await this.initialize()}applyNavigationSession(t){if(!t||t.sessionId!==this.sessionId)return;const s=Kt(this.state.session,t);s!==this.state.session&&this.patch({session:s,hasOlderMessages:gt({session:s,loadedMessageCount:this.authoritativeMessages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages})})}async sendMessage(t,s){const n=Kn();this.beginPendingReplyDebugTrace("send_live",n,t.length);const r=Ir(this.sessionId,t,n,(s==null?void 0:s.attachmentMeta)??[],(s==null?void 0:s.attachments)??[],Xa(this.buildTimelineMessages("send_sequence"),this.state.session)),a=this.applyTimelineEvent({type:"pending.insert",source:"send_pending",pending:r});this.patch({messages:a.messages,session:Je(this.state.session,"running"),runtimeHasActiveRun:Qn(this.state.session,this.state.capabilities)?!0:this.state.runtimeHasActiveRun,runtimeCanInterrupt:Zn(this.state.session,this.state.capabilities)?!0:this.state.runtimeCanInterrupt});try{const o=await this.sendMessageWithFallback(t,n,s);this.markPendingReplyDebugTraceResponseReady(n,{returnedMessageId:o.message.messageId,returnedProviderSessionId:o.message.providerSessionId}),this.resolvePendingMessage(o.message,n),this.patch({messages:this.buildTimelineMessages("send_resolved")})}catch(o){this.failPendingReplyDebugTrace(n,o);const u=this.applyTimelineEvent({type:"pending.fail",source:"send_failed",clientRequestId:n});throw this.patch({messages:u.messages,session:Je(this.state.session,"failed"),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1}),o}}async retryMessage(t){const s=this.pendingMessages.find(r=>r.clientRequestId===t);if(!s)return;const n=this.applyTimelineEvent({type:"pending.retry",source:"retry_pending",clientRequestId:t});this.patch({messages:n.messages,runtimeHasActiveRun:Qn(this.state.session,this.state.capabilities)?!0:this.state.runtimeHasActiveRun,runtimeCanInterrupt:Zn(this.state.session,this.state.capabilities)?!0:this.state.runtimeCanInterrupt}),this.beginPendingReplyDebugTrace("retry_live",t,s.content.length);try{const r=await this.sendMessageWithFallback(s.content,t,{attachments:s.attachmentPayloads??[],attachmentMeta:s.attachments});this.markPendingReplyDebugTraceResponseReady(t,{returnedMessageId:r.message.messageId,returnedProviderSessionId:r.message.providerSessionId}),this.resolvePendingMessage(r.message,t),this.patch({messages:this.buildTimelineMessages("retry_resolved")})}catch(r){this.failPendingReplyDebugTrace(t,r);const a=this.applyTimelineEvent({type:"pending.fail",source:"retry_failed",clientRequestId:t});throw this.patch({messages:a.messages,session:Je(this.state.session,"failed")}),r}}async enqueueMessage(t,s){const n=Kn();try{const r=await Zi(this.sessionId,{content:t,clientRequestId:n,model:(s==null?void 0:s.model)??null,reasoningLevel:(s==null?void 0:s.reasoningLevel)??null,permissionMode:ct(),attachments:(s==null?void 0:s.attachments)??[],providerConfigMode:s==null?void 0:s.providerConfigMode,providerPresetId:(s==null?void 0:s.providerPresetId)??null});this.patch({queuedMessages:al(this.state.queuedMessages,r)}),await this.refreshQueue()}catch(r){throw r}}async deleteQueuedMessage(t){await Ji(this.sessionId,t),await this.refreshQueue()}async steerQueuedMessage(t){await eo(this.sessionId,t),await this.refreshRuntimeSnapshot("queue_steer")}async interrupt(){await to(this.sessionId),this.patch({session:Je(this.state.session,"interrupted"),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:"user",errorCode:null,errorDetail:null})}async replyPermissionRequest(t,s){if(!(this.state.permissionRequests.find(a=>a.id===t)??null))return;const r=await so(this.sessionId,t,s);this.patch({permissionRequests:Hs(this.state.permissionRequests,r)})}reconnect(){var t;(t=this.realtimeClient)==null||t.reconnectNow()}async loadOlderMessages(){var t;if(!(this.state.historyState!=="ready"||this.state.loadingOlderMessages||!this.state.olderCursor)){this.patch({loadingOlderMessages:!0,errorCode:null,errorDetail:null});try{const s=this.state.olderCursor,n=await this.takePrefetchedOlderHistoryPage(s);if(n&&this.state.olderCursor===s){this.applyOlderHistoryPage(n,"prefetch_cache");return}if(!((t=this.realtimeClient)==null?void 0:t.requestOlderMessages(s,ks)))throw new Error("REALTIME_NOT_CONNECTED")}catch(s){const n=s instanceof Error?s.message:"unknown";this.patch({loadingOlderMessages:!1,errorCode:"HISTORY_LOAD_MORE_FAILED",errorDetail:n})}}}destroy(){var t;this.clearHistoryBootstrapFallbackTimer(),this.clearOlderHistoryPrefetch(),(t=this.realtimeClient)==null||t.close(),this.realtimeClient=null,this.pendingReplyDebugTraces.length=0,this.markSeenTimer!==null&&(window.clearTimeout(this.markSeenTimer),this.markSeenTimer=null),this.runtimeRefreshTimer!==null&&(window.clearTimeout(this.runtimeRefreshTimer),this.runtimeRefreshTimer=null),this.runtimeRefreshMode=null}startRealtime(){var s;if(!((s=Ss.getState().session)==null?void 0:s.accessToken)){Ss.clear();return}this.realtimeClient=new Jo({sessionId:this.sessionId,cursor:this.state.lastCursor,limit:jt,onSubscribed:()=>{be("session_send.realtime_subscribed",{sessionId:this.sessionId,lastCursor:this.state.lastCursor}),this.patch({connectionState:"connected",hasOlderMessages:gt({session:this.state.session,loadedMessageCount:this.authoritativeMessages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages})}),this.scheduleHistoryBootstrapFallback()},onConnectionChange:n=>{var a;const r=this.state.connectionState;if(this.patch({connectionState:n,session:n==="reconnecting"&&Qe((a=this.state.session)==null?void 0:a.runningState)?Je(this.state.session,"reconnecting"):this.state.session}),n==="connected"){this.clearRuntimeRefreshTimer("poll"),r!=="closed"&&r!=="connected"&&this.patch({errorCode:null,errorDetail:null});return}this.scheduleRuntimeRefresh("poll","connection_state_change")},onEnvelope:n=>{var u,d;this.historyBootstrapEnvelopeReceived=!0,this.clearHistoryBootstrapFallbackTimer();const r=n.type==="session.backfill"&&this.replaceSnapshotSeedOnBackfill,{messages:a,replacedSnapshotSeed:o}=this.mergeHistoryMessages(n.messages,r,n.type==="session.backfill"?"realtime_backfill":"realtime_delta");this.patch({messages:a,lastCursor:n.cursor,historyState:"ready",olderCursor:n.type==="session.backfill"&&!o&&this.state.pagesLoaded>1?this.state.olderCursor:n.olderCursor??this.state.olderCursor,hasOlderMessages:n.type==="session.backfill"?!o&&this.state.pagesLoaded>1?this.state.hasOlderMessages:!!n.olderCursor:gt({session:this.state.session,loadedMessageCount:this.authoritativeMessages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),pagesLoaded:n.type==="session.backfill"?!o&&this.state.pagesLoaded>1?this.state.pagesLoaded:Math.max(this.state.pagesLoaded,this.authoritativeMessages.length>0?1:0):this.state.pagesLoaded,session:Je(this.state.session,Gn(n.type,(u=this.state.session)==null?void 0:u.runningState))}),(d=this.realtimeClient)==null||d.updateCursor(n.cursor),this.scheduleMarkSeen(),this.scheduleOlderHistoryPrefetch(n.type==="session.backfill"?"backfill":"delta"),this.state.queuedMessages.length>0&&this.refreshQueue()},onOlderHistory:n=>{this.applyOlderHistoryPage({messages:n.messages,nextCursor:n.olderCursor},"realtime")},onRuntimeMessage:n=>{this.handleRuntimeMessage(n)},onActivity:n=>{this.handleActivity(n)},onRuntimeStatus:n=>{this.handleRuntimeStatus(n)},onRuntimeError:n=>{this.handleRuntimeError(n)},onInterrupted:n=>{this.handleInterrupted(n)},onPermissionRequest:n=>{this.handlePermissionRequest(n)},onPermissionRequestResolved:n=>{this.handlePermissionRequestResolved(n)},onError:n=>{this.patch({loadingOlderMessages:!1,errorCode:n.error_code,errorDetail:n.detail})},onUnauthorized:()=>{Ss.clear()}}),this.realtimeClient.start()}patch(t){let s=t;Object.prototype.hasOwnProperty.call(t,"session")&&(this.syncSeenWatermark(t.session??null),s={...t,session:this.applySeenWatermark(t.session??null)}),(Object.prototype.hasOwnProperty.call(s,"session")||Object.prototype.hasOwnProperty.call(s,"messages"))&&(s={...s,timelineItems:js((Object.prototype.hasOwnProperty.call(s,"session")?s.session:this.state.session)??null,(Object.prototype.hasOwnProperty.call(s,"messages")?s.messages:this.state.messages)??[])}),this.state={...this.state,...s},(Object.prototype.hasOwnProperty.call(s,"session")||Object.prototype.hasOwnProperty.call(s,"capabilities")||Object.prototype.hasOwnProperty.call(s,"contextUsage")||Object.prototype.hasOwnProperty.call(s,"messages")||Object.prototype.hasOwnProperty.call(s,"timelineItems")||Object.prototype.hasOwnProperty.call(s,"permissionRequests")||Object.prototype.hasOwnProperty.call(s,"queuedMessages"))&&this.persistSnapshot(),this.emit()}applyTimelineEvent(t){const s=Bn({authoritativeMessages:this.authoritativeMessages,runtimeOverlayMessages:this.runtimeOverlayMessages,activeRuntimeOverlayKeys:this.activeRuntimeOverlayKeys,pendingMessages:this.pendingMessages,replaceSnapshotSeedOnBackfill:this.replaceSnapshotSeedOnBackfill},this.sessionId,t);this.authoritativeMessages=s.timeline.authoritativeMessages,this.runtimeOverlayMessages=s.timeline.runtimeOverlayMessages,this.activeRuntimeOverlayKeys=s.timeline.activeRuntimeOverlayKeys,this.pendingMessages=s.timeline.pendingMessages,this.replaceSnapshotSeedOnBackfill=s.timeline.replaceSnapshotSeedOnBackfill;const n=Va(s.previousMessages,s.messages,"assistant"),r=$a(t);return(s.validationIssues.length>0||r.some(o=>o.role==="assistant")||n.length>0)&&ss("timeline.event",{sessionId:this.sessionId,eventType:t.type,source:t.source,replacedSnapshotSeed:s.replacedSnapshotSeed,validationIssues:s.validationIssues,authoritativeCount:this.authoritativeMessages.length,runtimeOverlayCount:this.runtimeOverlayMessages.length,pendingCount:this.pendingMessages.length,eventMessages:r.map(o=>ii(o)),assistantMoves:n,previousTail:Wn(s.previousMessages.slice(-6)),nextTail:Wn(s.messages.slice(-6))}),s}mergeHistoryMessages(t,s,n){const r=this.applyTimelineEvent({type:"history.merge",source:n,messages:t,replaceSnapshotSeed:s});return this.logCodexMergeDebug(n,r.previousMessages,t,r.messages,{replacedSnapshotSeedAttempted:s,replacedSnapshotSeed:r.replacedSnapshotSeed,baseMessageCount:r.replacedSnapshotSeed?0:r.previousMessages.length}),{messages:r.messages,replacedSnapshotSeed:r.replacedSnapshotSeed}}buildTimelineMessages(t){return Ys({authoritativeMessages:this.authoritativeMessages,runtimeOverlayMessages:this.runtimeOverlayMessages,activeRuntimeOverlayKeys:this.activeRuntimeOverlayKeys,pendingMessages:this.pendingMessages,replaceSnapshotSeedOnBackfill:this.replaceSnapshotSeedOnBackfill})}clearActiveRuntimeTail(t){if(this.activeRuntimeOverlayKeys.length===0)return;this.activeRuntimeOverlayKeys=[];const s=this.buildTimelineMessages(t);this.patch({messages:s})}resolvePendingMessage(t,s){this.applyTimelineEvent({type:"pending.resolve",source:"pending_resolved",clientRequestId:s,message:t})}handleError(t){this.clearHistoryBootstrapFallbackTimer();const s=t instanceof Error?t.message:"unknown";this.patch({historyState:"error",errorCode:"RUNTIME_INIT_FAILED",errorDetail:s})}scheduleMarkSeen(){if(this.markSeenTimer!==null)return;const t=this.getTargetSeenAt();if(this.markSeenInFlight||t===null)return;const s=this.getMarkSeenThrottleDelayMs(),n=Math.max(ma,s);this.markSeenTimer=window.setTimeout(()=>{this.markSeenTimer=null;const r=this.getTargetSeenAt();r!==null&&(be("session_seen.start",{sessionId:this.sessionId,targetSeenAt:r,seenWatermark:this.seenWatermark}),this.markSeenInFlight=!0,this.lastMarkSeenRequestAt=Date.now(),no(this.sessionId).then(()=>{var a,o;this.bumpSeenWatermark(r),this.patch({session:Un(this.state.session,r)}),(o=(a=this.options).onSeen)==null||o.call(a,this.sessionId,r),be("session_seen.end",{sessionId:this.sessionId,seenWatermark:this.seenWatermark})}).catch(()=>{be("session_seen.error",{sessionId:this.sessionId,targetSeenAt:r})}).finally(()=>{this.markSeenInFlight=!1,this.shouldMarkSeen()&&this.scheduleMarkSeen()}))},n)}clearRuntimeRefreshTimer(t){this.runtimeRefreshTimer!==null&&(t&&this.runtimeRefreshMode!==t||(window.clearTimeout(this.runtimeRefreshTimer),this.runtimeRefreshTimer=null,this.runtimeRefreshMode=null))}scheduleHistoryBootstrapFallback(){this.historyBootstrapEnvelopeReceived||this.historyBootstrapFallbackTimer!==null||(this.historyBootstrapFallbackTimer=window.setTimeout(()=>{this.historyBootstrapFallbackTimer=null,!this.historyBootstrapEnvelopeReceived&&this.resolveHistoryBootstrapFallback()},350))}clearHistoryBootstrapFallbackTimer(){this.historyBootstrapFallbackTimer!==null&&(window.clearTimeout(this.historyBootstrapFallbackTimer),this.historyBootstrapFallbackTimer=null)}async resolveHistoryBootstrapFallback(){try{const t=Math.min(Xr,Math.max(jt,this.authoritativeMessages.length,pa)),s=await Fs(this.sessionId,null,t,"backward");if(this.historyBootstrapEnvelopeReceived)return;this.historyBootstrapEnvelopeReceived=!0;const{messages:n,replacedSnapshotSeed:r}=this.mergeHistoryMessages(s.messages,this.replaceSnapshotSeedOnBackfill,"http_bootstrap_fallback");this.patch({messages:n,historyState:"ready",olderCursor:!r&&this.state.pagesLoaded>1?this.state.olderCursor:s.nextCursor,hasOlderMessages:!r&&this.state.pagesLoaded>1?this.state.hasOlderMessages:gt({session:this.state.session,loadedMessageCount:this.authoritativeMessages.length,olderCursor:s.nextCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),lastCursor:s.cursor??this.state.lastCursor,pagesLoaded:!r&&this.state.pagesLoaded>1?this.state.pagesLoaded:this.authoritativeMessages.length>0?Math.max(this.state.pagesLoaded,1):this.state.pagesLoaded,errorCode:null,errorDetail:null}),this.scheduleMarkSeen(),this.scheduleOlderHistoryPrefetch("bootstrap_fallback")}catch{}}applyOlderHistoryPage(t,s){const{messages:n}=this.mergeHistoryMessages(t.messages,!1,s==="realtime"?"older_history_realtime":"older_history_prefetch_cache");this.patch({messages:n,historyState:"ready",loadingOlderMessages:!1,olderCursor:t.nextCursor,hasOlderMessages:!!t.nextCursor,pagesLoaded:this.state.pagesLoaded+1,errorCode:null,errorDetail:null}),be("session.history_older.applied",{sessionId:this.sessionId,source:s,messageCount:t.messages.length,nextCursor:t.nextCursor}),this.scheduleOlderHistoryPrefetch(s)}scheduleOlderHistoryPrefetch(t){var n;const s=this.state.olderCursor;this.state.historyState!=="ready"||this.state.loadingOlderMessages||!s||((n=this.prefetchedOlderHistoryPage)==null?void 0:n.requestedCursor)!==s&&(this.olderHistoryPrefetchPromise&&this.olderHistoryPrefetchCursor===s||this.prefetchOlderHistoryPage(s,t))}async prefetchOlderHistoryPage(t,s){var r;if(((r=this.prefetchedOlderHistoryPage)==null?void 0:r.requestedCursor)===t)return this.prefetchedOlderHistoryPage.page;if(this.olderHistoryPrefetchPromise&&this.olderHistoryPrefetchCursor===t)return this.olderHistoryPrefetchPromise;this.olderHistoryPrefetchCursor=t,be("session.history_older.prefetch.start",{sessionId:this.sessionId,requestedCursor:t,reason:s,limit:ks});const n=Fs(this.sessionId,t,ks,"backward").then(a=>(this.state.olderCursor===t&&(this.prefetchedOlderHistoryPage={requestedCursor:t,page:a}),be("session.history_older.prefetch.end",{sessionId:this.sessionId,requestedCursor:t,messageCount:a.messages.length,nextCursor:a.nextCursor}),a)).catch(a=>(be("session.history_older.prefetch.error",{sessionId:this.sessionId,requestedCursor:t,message:a instanceof Error?a.message:"unknown"}),null)).finally(()=>{this.olderHistoryPrefetchPromise===n&&(this.olderHistoryPrefetchPromise=null),this.olderHistoryPrefetchCursor===t&&(this.olderHistoryPrefetchCursor=null)});return this.olderHistoryPrefetchPromise=n,n}async takePrefetchedOlderHistoryPage(t){var s;if(((s=this.prefetchedOlderHistoryPage)==null?void 0:s.requestedCursor)===t){const n=this.prefetchedOlderHistoryPage.page;return this.prefetchedOlderHistoryPage=null,be("session.history_older.prefetch.hit",{sessionId:this.sessionId,requestedCursor:t,messageCount:n.messages.length,nextCursor:n.nextCursor}),n}if(this.olderHistoryPrefetchPromise&&this.olderHistoryPrefetchCursor===t){const n=await this.olderHistoryPrefetchPromise;return!n||this.state.olderCursor!==t?null:(this.prefetchedOlderHistoryPage=null,be("session.history_older.prefetch.await_hit",{sessionId:this.sessionId,requestedCursor:t,messageCount:n.messages.length,nextCursor:n.nextCursor}),n)}return null}clearOlderHistoryPrefetch(){this.olderHistoryPrefetchCursor=null,this.olderHistoryPrefetchPromise=null,this.prefetchedOlderHistoryPage=null}scheduleRuntimeRefresh(t,s){var n,r;if(!Qe((n=this.state.session)==null?void 0:n.runningState)){this.clearRuntimeRefreshTimer();return}t==="poll"&&this.state.connectionState==="connected"||(this.clearRuntimeRefreshTimer(),this.runtimeRefreshMode=t,be("session_runtime.refresh.schedule",{sessionId:this.sessionId,mode:t,reason:s,connectionState:this.state.connectionState,runningState:((r=this.state.session)==null?void 0:r.runningState)??null}),this.runtimeRefreshTimer=window.setTimeout(()=>{const a=this.runtimeRefreshMode??t;this.runtimeRefreshTimer=null,this.runtimeRefreshMode=null,this.refreshRuntimeState(a,s)},t==="poll"?va:1200))}async refreshRuntimeState(t,s){var n,r,a,o,u;be("session_runtime.refresh.start",{sessionId:this.sessionId,mode:t,reason:s,connectionState:this.state.connectionState,runningState:((n=this.state.session)==null?void 0:n.runningState)??null});try{const d=await Sn(this.sessionId),h=Ls(this.state.runtimeHasActiveRun,d.runningState,d.hasActiveRun),f=Ds(this.state.runtimeCanInterrupt,d.runningState,h,d.canInterrupt);this.patch({session:$n(this.state.session,d),runtimeHasActiveRun:h,runtimeCanInterrupt:f,contextUsage:d.contextUsage,...Ns(d,this.state.interruptSource)}),await this.refreshQueue();const p=t==="poll"&&this.state.connectionState!=="connected"&&Qe((r=this.state.session)==null?void 0:r.runningState);be("session_runtime.refresh.end",{sessionId:this.sessionId,mode:t,reason:s,connectionState:this.state.connectionState,runningState:((a=this.state.session)==null?void 0:a.runningState)??null,continuePolling:p}),p&&this.scheduleRuntimeRefresh("poll","connection_poll")}catch(d){be("session_runtime.refresh.error",{sessionId:this.sessionId,mode:t,reason:s,connectionState:this.state.connectionState,runningState:((o=this.state.session)==null?void 0:o.runningState)??null,message:d instanceof Error?d.message:"unknown"}),t==="poll"&&this.state.connectionState!=="connected"&&Qe((u=this.state.session)==null?void 0:u.runningState)&&this.scheduleRuntimeRefresh("poll","connection_poll_retry")}}async refreshSessionMetadata(){const t=[];this.state.session===null&&t.push(wr(this.sessionId).then(s=>{this.patch({session:Kt(s,this.state.session)})}).catch(()=>{})),Vn(this.state.capabilities)&&t.push(ro(this.sessionId).then(s=>{this.patch({capabilities:s})}).catch(()=>{})),t.length!==0&&await Promise.allSettled(t)}async refreshPermissionRequests(){try{const t=await io(this.sessionId);this.patch({permissionRequests:t.items})}catch{return}}shouldRefreshSessionDetail(){return this.state.session===null||Vn(this.state.capabilities)||this.state.session.runningState===null}shouldRefreshRuntimeSnapshot(){return this.state.contextUsage===null||ol(this.state.session,this.state.runtimeHasActiveRun,this.state.runtimeCanInterrupt)}async refreshRuntimeSnapshot(t){be("session_runtime.snapshot.start",{sessionId:this.sessionId,reason:t});try{const s=await Sn(this.sessionId),n=Ls(this.state.runtimeHasActiveRun,s.runningState,s.hasActiveRun),r=Ds(this.state.runtimeCanInterrupt,s.runningState,n,s.canInterrupt);this.patch({session:$n(this.state.session,s),runtimeHasActiveRun:n,runtimeCanInterrupt:r,contextUsage:s.contextUsage,...Ns(s,this.state.interruptSource)}),await this.refreshQueue(),be("session_runtime.snapshot.end",{sessionId:this.sessionId,reason:t,hasContextUsage:s.contextUsage!==null})}catch(s){be("session_runtime.snapshot.error",{sessionId:this.sessionId,reason:t,message:s instanceof Error?s.message:"unknown"})}}async refreshQueue(){try{const t=await oo(this.sessionId);this.patch({queuedMessages:t.items})}catch{return}}async sendMessageWithFallback(t,s,n){var r;try{return await sn(this.sessionId,{content:t,clientRequestId:s,model:(n==null?void 0:n.model)??null,reasoningLevel:(n==null?void 0:n.reasoningLevel)??null,permissionMode:ct(),attachments:(n==null?void 0:n.attachments)??[],providerConfigMode:n==null?void 0:n.providerConfigMode,providerPresetId:(n==null?void 0:n.providerPresetId)??null})}catch(a){if(!(a instanceof Wi)||a.status!==404&&a.status!==405||(((r=n==null?void 0:n.attachments)==null?void 0:r.length)??0)>0)throw a;return be("session_send.live_fallback",{sessionId:this.sessionId,clientRequestId:s,reason:a.message}),ao(this.sessionId,{content:t,clientRequestId:s,permissionMode:ct()})}}handleRuntimeStatus(t){var n;const s=_s((n=this.state.session)==null?void 0:n.runningState,t.status);this.patch({session:Je(this.state.session,s),runtimeHasActiveRun:Qe(s)?this.state.runtimeHasActiveRun??!0:!1,runtimeCanInterrupt:Qe(s)?this.state.runtimeCanInterrupt:!1,interruptSource:s==="interrupted"?t.interruptSource??this.state.interruptSource:s==="completed"||s==="failed"?null:this.state.interruptSource,errorCode:null,errorDetail:s===t.status?t.detail:this.state.errorDetail}),qt(s)&&(this.clearActiveRuntimeTail("runtime_status_terminal"),this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_terminal_before_message",{status:t.status,detail:t.detail}),this.clearRuntimeRefreshTimer(),this.refreshQueue(),this.refreshRuntimeSnapshot("runtime_terminal"))}handleActivity(t){const s=Ls(this.state.runtimeHasActiveRun,t.runningState,t.hasActiveRun),n=Ds(this.state.runtimeCanInterrupt,t.runningState,s,t.canInterrupt);if(this.patch({session:Ja(this.state.session,t),runtimeHasActiveRun:s,runtimeCanInterrupt:n,...Ns(t,this.state.interruptSource)}),qt(t.runningState)){this.clearActiveRuntimeTail("activity_terminal"),this.clearRuntimeRefreshTimer(),this.refreshQueue();return}(t.runningState==="stale"||t.runningState==="unknown")&&this.scheduleRuntimeRefresh("tail","activity_watchdog")}handleRuntimeMessage(t){var r;t.message.role==="assistant"&&this.completePendingReplyDebugTrace(t);const s=this.applyTimelineEvent({type:"runtime.message",source:t.source,message:yr(this.sessionId,t.message)}),n=s.messages;this.logCodexMergeDebug("runtime_message",s.previousMessages,[t.message],n,{runtimeSource:t.source}),this.patch({messages:n,historyState:"ready",hasOlderMessages:gt({session:this.state.session,loadedMessageCount:this.authoritativeMessages.length,olderCursor:this.state.olderCursor,pagesLoaded:this.state.pagesLoaded,currentHasOlderMessages:this.state.hasOlderMessages}),session:Je(this.state.session,Gn("session.delta",(r=this.state.session)==null?void 0:r.runningState))}),this.scheduleMarkSeen(),this.state.queuedMessages.length>0&&this.refreshQueue()}handleRuntimeError(t){var n;const s=_s((n=this.state.session)==null?void 0:n.runningState,"failed");this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_runtime_error",{errorCode:t.error_code,detail:t.detail}),this.clearRuntimeRefreshTimer(),this.patch({session:Je(this.state.session,s),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:null,errorCode:s==="failed"?t.error_code:this.state.errorCode,errorDetail:s==="failed"?t.detail:this.state.errorDetail}),this.refreshQueue()}handleInterrupted(t){var n;const s=_s((n=this.state.session)==null?void 0:n.runningState,"interrupted");this.completePendingReplyDebugTraceWithoutAssistant("session_send.client_interrupted",{detail:t.detail}),this.clearRuntimeRefreshTimer(),this.patch({session:Je(this.state.session,s),runtimeHasActiveRun:!1,runtimeCanInterrupt:!1,interruptSource:s==="interrupted"?t.interruptSource??this.state.interruptSource:this.state.interruptSource,errorCode:s==="interrupted"?null:this.state.errorCode,errorDetail:s==="interrupted"?t.detail:this.state.errorDetail}),this.refreshQueue()}handlePermissionRequest(t){this.patch({permissionRequests:Hs(this.state.permissionRequests,t.request)})}handlePermissionRequestResolved(t){this.patch({permissionRequests:Hs(this.state.permissionRequests,t.request)})}shouldMarkSeen(){return this.getTargetSeenAt()!==null}getTargetSeenAt(){const t=[...this.state.messages].reverse().find(n=>n.role!=="user");if(!t)return null;const s=this.seenWatermark;return s?t.timestamp>s?t.timestamp:null:t.timestamp}syncSeenWatermark(t){t!=null&&t.lastSeenAt&&this.bumpSeenWatermark(t.lastSeenAt)}bumpSeenWatermark(t){this.seenWatermark&&this.seenWatermark>=t||(this.seenWatermark=t)}getMarkSeenThrottleDelayMs(){return this.lastMarkSeenRequestAt<=0?0:Math.max(0,ga-(Date.now()-this.lastMarkSeenRequestAt))}applySeenWatermark(t){return!t||!this.seenWatermark?t:Un(t,this.seenWatermark)}emit(){for(const t of this.listeners)t()}persistSnapshot(){ko(qs(this.sessionId),{session:this.state.session,capabilities:this.state.capabilities,runtimeHasActiveRun:this.state.runtimeHasActiveRun,runtimeCanInterrupt:this.state.runtimeCanInterrupt,contextUsage:this.state.contextUsage,messages:Jn(this.authoritativeMessages),timelineItems:js(this.state.session,Jn(this.authoritativeMessages)),permissionRequests:this.state.permissionRequests,queuedMessages:this.state.queuedMessages,olderCursor:this.state.olderCursor,hasOlderMessages:this.state.hasOlderMessages,lastCursor:this.state.lastCursor,pagesLoaded:this.state.pagesLoaded,interruptSource:this.state.interruptSource})}beginPendingReplyDebugTrace(t,s,n){const r={mode:t,clientRequestId:s,startedAtMs:performance.now(),responseReadyAtMs:null,contentLength:n};this.pendingReplyDebugTraces.push(r),be(`session_send.${t}.client_start`,{sessionId:this.sessionId,clientRequestId:s,contentLength:n})}markPendingReplyDebugTraceResponseReady(t,s={}){const n=this.pendingReplyDebugTraces.find(r=>r.clientRequestId===t);!n||n.responseReadyAtMs!==null||(n.responseReadyAtMs=performance.now(),be(`session_send.${n.mode}.client_response`,{sessionId:this.sessionId,clientRequestId:t,durationMs:Math.round(n.responseReadyAtMs-n.startedAtMs),...s}))}failPendingReplyDebugTrace(t,s){const n=this.pendingReplyDebugTraces.find(r=>r.clientRequestId===t);n&&(be(`session_send.${n.mode}.client_error`,{sessionId:this.sessionId,clientRequestId:t,durationMs:Math.round(performance.now()-n.startedAtMs),error:s instanceof Error?s.message:String(s)}),this.removePendingReplyDebugTrace(n.clientRequestId))}completePendingReplyDebugTrace(t){const s=this.pendingReplyDebugTraces[0];if(!s)return;const n=performance.now();be(`session_send.${s.mode}.first_assistant_message`,{sessionId:this.sessionId,clientRequestId:s.clientRequestId,durationMs:Math.round(n-s.startedAtMs),responseToAssistantMs:s.responseReadyAtMs===null?null:Math.round(n-s.responseReadyAtMs),messageId:t.message.messageId,kind:t.message.kind,contentLength:t.message.content.length}),this.removePendingReplyDebugTrace(s.clientRequestId)}completePendingReplyDebugTraceWithoutAssistant(t,s={}){const n=this.pendingReplyDebugTraces[0];n&&(be(t,{sessionId:this.sessionId,clientRequestId:n.clientRequestId,durationMs:Math.round(performance.now()-n.startedAtMs),responseReady:n.responseReadyAtMs!==null,...s}),this.removePendingReplyDebugTrace(n.clientRequestId))}removePendingReplyDebugTrace(t){const s=this.pendingReplyDebugTraces.findIndex(n=>n.clientRequestId===t);s<0||this.pendingReplyDebugTraces.splice(s,1)}logCodexMergeDebug(t,s,n,r,a={}){const o=n.filter(tl);if(o.length===0)return;const u=zn(s),d=zn(r);ze("session.messages.merge",{sessionId:this.sessionId,source:t,beforeCount:s.length,incomingCount:n.length,afterCount:r.length,incoming:o.slice(0,5).map(nl),beforeDuplicateGroupCount:u.length,afterDuplicateGroupCount:d.length,afterDuplicateGroups:d.slice(0,3),...a})}}function Sa(){return{authoritativeMessages:[],runtimeOverlayMessages:[],activeRuntimeOverlayKeys:[],pendingMessages:[],replaceSnapshotSeedOnBackfill:!1}}function Ia(e,t){const s=new Map,n=new Set;for(const r of e)s.set(r.id,r),n.add(r.id);for(const r of t){const a=s.get(r.id)??null,o=si(s,n,r,a);if(o){const h=s.get(o)??null;if(h){ze("session.messages.runtime_overlay_authoritative_bridge",{mode:"prefer_equivalent",previous:pe(h),overlay:pe(r),replacedSameId:a?pe(a):null}),s.set(o,Es(h,r));continue}}if(a){ze("session.messages.runtime_overlay_authoritative_bridge",{mode:"same_id",previous:pe(a),overlay:pe(r)}),s.set(r.id,Es(a,r));continue}const u=hn(s,n,r);if(u){const h=s.get(u)??null;if(h){ze("session.messages.runtime_overlay_authoritative_bridge",{mode:"codex_compat",previous:pe(h),overlay:pe(r)}),s.set(u,Es(h,r));continue}}const d=fn(s,r);if(d&&n.has(d)){const h=s.get(d)??null;if(h){if(ze("session.messages.runtime_overlay_authoritative_bridge",{mode:"opencode_compat",previous:pe(h),overlay:pe(r)}),ws(h,r)){s.set(d,Ln(h,r));continue}s.set(d,Ln(h,r));continue}}ze("session.messages.runtime_overlay_authoritative_bridge",{mode:"insert",overlay:pe(r)}),s.set(r.id,r)}return Ta(Array.from(s.values()))}function Es(e,t){return{...zr(e,{...t,id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId}),id:e.id,rawRef:e.rawRef,timestamp:e.timestamp,sequence:e.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function zr(e,t){if(e.id!==t.id)return t;if(Dt(e,t)){const o=ns(e.toolCall,t.toolCall),u=Yr(e,t,o,rs),d=is(e.attachments,t.attachments),h=os(e,t);return{...wt(e,t),kind:(o==null?void 0:o.status)==="running"?"tool_call":"tool_result",content:u,toolCall:o,attachments:d,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:h.rawRef,timestamp:h.timestamp,sequence:h.sequence}}if(e.role!==t.role||e.kind!==t.kind)return wt(e,t);const s=ns(e.toolCall,t.toolCall),n=rs(e.content,t.content,e.timestamp,t.timestamp),r=is(e.attachments,t.attachments),a=os(e,t);return{...wt(e,t),content:n,toolCall:s,attachments:r,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:a.rawRef,timestamp:a.timestamp,sequence:a.sequence}}function Ln(e,t){if(Dt(e,t)){const o=ns(e.toolCall,t.toolCall),u=Yr(e,t,o,rs),d=is(e.attachments,t.attachments),h=os(e,t);return{...wt(e,t),id:e.id,kind:(o==null?void 0:o.status)==="running"?"tool_call":"tool_result",content:u,toolCall:o,attachments:d,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:h.rawRef,timestamp:h.timestamp,sequence:h.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}if(e.role!==t.role||e.kind!==t.kind)return{...wt(e,t),id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId};const s=ns(e.toolCall,t.toolCall),n=rs(e.content,t.content,e.timestamp,t.timestamp),r=is(e.attachments,t.attachments),a=os(e,t);return{...wt(e,t),id:e.id,content:n,toolCall:s,attachments:r,attachmentPayloads:e.attachmentPayloads??t.attachmentPayloads??null,rawRef:a.rawRef,timestamp:a.timestamp,sequence:a.sequence,clientRequestId:e.clientRequestId??t.clientRequestId}}function Dt(e,t){return ws(e,t)||Ms(e,t)}function Yr(e,t,s,n){if((s==null?void 0:s.status)==="running"){if(t.kind==="tool_call"&&t.content)return t.content;if(e.kind==="tool_call"&&e.content)return e.content}else{if(t.kind==="tool_result"&&t.content)return t.content;if(e.kind==="tool_result"&&e.content)return e.content;if(s!=null&&s.output)return s.output}return n(e.content,t.content,e.timestamp,t.timestamp)}function hn(e,t,s){if(!zs(s))return null;for(const[n,r]of e.entries())if(!(n===s.id||!t.has(n)||!ya(r,s)))return ze("session.messages.codex_identity_bridge_match",{previous:pe(r),incoming:pe(s)}),n;return null}function ya(e,t){if(!ka(e,t))return!1;if(e.rawRef===t.rawRef)return!0;if(e.kind==="tool_call"||e.kind==="tool_result")return Ms(e,t);const s=ls(e.rawRef),n=ls(t.rawRef);if(!s||!n||s!==n)return!1;const r=Math.abs(e.sequence-t.sequence);return r>1?(ze("session.messages.codex_identity_bridge_rejected",{reason:"sequence_distance",sequenceDistance:r,previous:pe(e),incoming:pe(t)}),!1):!0}function fn(e,t){if(!qn(t))return null;const s=as(t.rawRef);if(s===null)return null;const n=yt(t.timestamp);let r=null,a=Number.POSITIVE_INFINITY;for(const[o,u]of e.entries()){if(o===t.id||!qn(u)||u.role!==t.role)continue;if(ws(u,t))return o;if(u.kind!==t.kind||as(u.rawRef)!==s)continue;const h=yt(u.timestamp),f=Math.abs(h-n),x=Math.abs(u.sequence-t.sequence)*6e4+f;x<a&&(r=o,a=x)}return r}function xa(e,t,s){if(!pn(t))return!1;const n=Gs(e.authoritativeMessages,t,"authoritative",s);if(n)return ze("session.messages.runtime_user_echo_suppressed",{sessionId:s,target:"authoritative",matched:pe(n),incoming:pe(t)}),!0;const r=Gs(e.pendingMessages,t,"pending",s);return r?(ze("session.messages.runtime_user_echo_suppressed",{sessionId:s,target:"pending",matched:pe(r),incoming:pe(t)}),!0):!1}function Gs(e,t,s,n){const r=yt(t.timestamp),a=$e(t.content),o=Xs(t.content),u=cs(t.attachments);let d=null,h=Number.POSITIVE_INFINITY;const f=[];for(const p of e){if(!(s==="authoritative"?Ca(p):Qr(p)))continue;const v=$e(p.content),w=Xs(p.content),M=v===a,j=w===o;if(!M&&!j)continue;const y=yt(p.timestamp),O=Math.abs(y-r);if(O>300*1e3)continue;const C=Math.abs(p.sequence-t.sequence),_=cs(p.attachments),A=Aa(_,u);if(f.push(_a(p,{strictTextMatches:M,relaxedTextMatches:j,attachmentCompatibility:A,distanceMs:O,sequenceDistance:C})),A==="conflict"&&(M||a.length===0))continue;const P=O+C*15e3+(M?0:500)+ja(A);P<h&&(d=p,h=P)}return f.length>0&&ze("session.messages.runtime_user_match",{sessionId:n,target:s,matchedId:(d==null?void 0:d.id)??null,matchedScore:Number.isFinite(h)?h:null,incoming:Na(t,{relaxedContent:o,attachmentSignature:u}),candidates:f.slice(0,5)}),d}function Pa(e,t,s){for(const n of t){if(n.role!=="user"||n.kind!=="text")continue;const r=yr(s,n,"sent",null);if(!Gs(e,r,"authoritative",s))return!0}return!1}function ns(e,t){return e?t?{...Ra(e,t),input:Kr(e.input,t.input),output:Dn(e.output,t.output),error:Dn(e.error,t.error)}:e:t}function Ra(e,t){const s=e.status==="running"?0:1,n=t.status==="running"?0:1;return n!==s?n>s?t:e:t}function rs(e,t,s,n){const r=$e(e),a=$e(t);return r===a?e.length>=t.length?e:t:r.length>a.length&&r.includes(a)?e:a.length>r.length&&a.includes(r)||n.localeCompare(s)>=0?t:e}function is(e,t){const s=(e==null?void 0:e.length)??0,n=(t==null?void 0:t.length)??0;return n!==s?n>s?t:e:t??e}function Kr(e,t){return t.length>e.length?t:e}function Dn(e,t){return e===null?t:t===null?e:Kr(e,t)}function wt(e,t){return t.timestamp!==e.timestamp?t.timestamp.localeCompare(e.timestamp)>=0?t:e:t.sequence!==e.sequence?t.sequence>=e.sequence?t:e:t}function os(e,t){return Ht(e,t)<=0?e:t}function $e(e){return e.replace(wa,"").replace(/\r\n/g,`
4
+ `).trimEnd()}function Xs(e){return $e(e).replace(/[ \t]+\n/g,`
5
+ `).replace(/\n{2,}/g,`
6
+ `).trim()}function Ta(e){return[...e].sort((t,s)=>Ht(t,s))}function zs(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("codex://")&&(e.role==="assistant"||e.role==="tool")}function pn(e){return e.role==="user"&&e.kind==="text"}function Qr(e){return pn(e)&&e.deliveryState!=="failed"&&(e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic"))}function Ca(e){return pn(e)&&!Qr(e)}function qn(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&!(e.rawRef.startsWith("pending://")||e.rawRef.startsWith("synthetic://")||e.rawRef.includes("#synthetic"))&&(e.role==="user"||e.role==="assistant"||e.role==="tool")}function Hn(e){return e.deliveryState==="sent"&&e.rawRef.startsWith("opencode://")&&e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")&&e.toolCall!==null}function ws(e,t){var r,a;if(!Hn(e)||!Hn(t))return!1;const s=((r=e.toolCall)==null?void 0:r.callId.trim())??"",n=((a=t.toolCall)==null?void 0:a.callId.trim())??"";return s&&n?s===n:as(e.rawRef)===as(t.rawRef)}function as(e){if(!e.startsWith("opencode://"))return null;const t=e.indexOf("#"),s=t>=0?e.slice(t):"",n=t>=0?e.slice(0,t):e,r=n.indexOf("?");if(r<0)return e;const a=n.slice(0,r),o=new URLSearchParams(n.slice(r+1));if(!o.has("part"))return e;o.delete("part");const u=o.toString();return`${a}${u?`?${u}`:""}${s}`}function ka(e,t){if(!zs(e)||!zs(t)||e.role!==t.role)return!1;const s=(e.kind==="tool_call"||e.kind==="tool_result")&&(t.kind==="tool_call"||t.kind==="tool_result");return!s&&e.kind!==t.kind?!1:s?Ms(e,t):Math.abs(e.sequence-t.sequence)>ba||!Jr(e.timestamp,t.timestamp,Vs)?!1:t.kind==="text"||t.kind==="thinking"?Zr(e,t,Vs):!1}function Zr(e,t,s){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!==t.role||e.kind!==t.kind||e.toolCall!==null||t.toolCall!==null||e.kind!=="text"&&e.kind!=="thinking")return!1;const n=St(e.content),r=St(t.content);return Jr(e.timestamp,t.timestamp,s)&&$e(n.text)===$e(r.text)&&Ea(n.inlineImages,r.inlineImages)}function Ms(e,t){if(e.deliveryState!=="sent"||t.deliveryState!=="sent"||!e.rawRef.startsWith("codex://")||!t.rawRef.startsWith("codex://")||e.role!=="tool"||t.role!=="tool"||e.kind!=="tool_call"&&e.kind!=="tool_result"||t.kind!=="tool_call"&&t.kind!=="tool_result"||e.toolCall===null||t.toolCall===null)return!1;const s=e.toolCall.callId.trim(),n=t.toolCall.callId.trim();return s.length>0&&s===n}function ls(e){const t=e.match(/^codex:\/\/(.+?)(?:#|$)/);return(t==null?void 0:t[1])??null}function Ea(e,t){return e.length===0||t.length===0?!0:e.length!==t.length?!1:e.every((s,n)=>{var r;return s.url===((r=t[n])==null?void 0:r.url)})}function Jr(e,t,s){return Math.abs(yt(e)-yt(t))<=s}function yt(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function pe(e){var t;return{id:e.id,rawRef:e.rawRef,role:e.role,kind:e.kind,sequence:e.sequence,timestamp:e.timestamp,callId:((t=e.toolCall)==null?void 0:t.callId)??null,contentPreview:e.kind==="text"||e.kind==="thinking"?$e(St(e.content).text).slice(0,160):$e(e.content).slice(0,160)}}function cs(e){return(e??[]).map(t=>[t.kind,t.fileName.trim().toLowerCase(),t.mimeType.trim().toLowerCase(),String(t.fileSize)].join(":")).sort().join("|")}function Aa(e,t){return!e&&!t?"same":!e||!t?"one_side_missing":e===t?"same":"conflict"}function ja(e){switch(e){case"same":return 0;case"one_side_missing":return 2500;case"conflict":default:return 12e4}}function _a(e,t){return{...pe(e),comparableContent:Xs(e.content).slice(0,160),attachmentSignature:cs(e.attachments),strictTextMatches:t.strictTextMatches,relaxedTextMatches:t.relaxedTextMatches,attachmentCompatibility:t.attachmentCompatibility,distanceMs:t.distanceMs,sequenceDistance:t.sequenceDistance}}function Na(e,t){return{...pe(e),comparableContent:t.relaxedContent.slice(0,160),attachmentSignature:t.attachmentSignature}}function Ys(e){let t=Ia(e.authoritativeMessages,e.runtimeOverlayMessages);for(const s of e.pendingMessages)t=Pr(t,s);return Da(t,e.authoritativeMessages,e.runtimeOverlayMessages,e.activeRuntimeOverlayKeys)}function Bn(e,t,s){const n=Ys(e);let r=e,a=!1;switch(s.type){case"timeline.seed":{r={authoritativeMessages:ys(s.snapshotMessages,t,s.bootstrapMessages),runtimeOverlayMessages:[],activeRuntimeOverlayKeys:[],pendingMessages:[],replaceSnapshotSeedOnBackfill:s.replaceSnapshotSeedOnBackfill};break}case"history.merge":{a=s.replaceSnapshotSeed&&e.replaceSnapshotSeedOnBackfill&&za(e.authoritativeMessages,s.messages);const u=a?[]:e.authoritativeMessages;r={...e,authoritativeMessages:ys(u,t,s.messages),activeRuntimeOverlayKeys:Pa(e.authoritativeMessages,s.messages,t)?[]:e.activeRuntimeOverlayKeys,replaceSnapshotSeedOnBackfill:a?!1:e.replaceSnapshotSeedOnBackfill};break}case"runtime.message":{if(xa(e,s.message,t)){r=e;break}r={...e,runtimeOverlayMessages:Eo(e.runtimeOverlayMessages,[s.message]),activeRuntimeOverlayKeys:qa(e,e.activeRuntimeOverlayKeys,s.message)};break}case"pending.insert":{r={...e,activeRuntimeOverlayKeys:s.pending.role==="user"?[]:e.activeRuntimeOverlayKeys,pendingMessages:Pr(e.pendingMessages,s.pending)};break}case"pending.retry":{r={...e,pendingMessages:e.pendingMessages.map(u=>u.clientRequestId===s.clientRequestId?{...u,deliveryState:"sending"}:u)};break}case"pending.fail":{r={...e,pendingMessages:xr(e.pendingMessages,s.clientRequestId)};break}case"pending.resolve":{const u=e.pendingMessages.find(h=>h.clientRequestId===s.clientRequestId)??null;let d=ys(e.authoritativeMessages,t,[s.message]);u&&(d=d.map(h=>{if(h.id!==s.message.messageId)return h;const f=h.attachments??[];return{...h,attachments:f.length>0?f:u.attachments??[],attachmentPayloads:u.attachmentPayloads??h.attachmentPayloads??null,clientRequestId:s.clientRequestId}})),r={...e,authoritativeMessages:d,activeRuntimeOverlayKeys:s.message.role==="user"?[]:e.activeRuntimeOverlayKeys,pendingMessages:e.pendingMessages.filter(h=>h.clientRequestId!==s.clientRequestId)};break}}r={...r,runtimeOverlayMessages:La(r.authoritativeMessages,r.runtimeOverlayMessages)},r={...r,activeRuntimeOverlayKeys:Ba(r.authoritativeMessages,r.runtimeOverlayMessages,r.activeRuntimeOverlayKeys)};const o=Ys(r);return{timeline:r,previousMessages:n,messages:o,replacedSnapshotSeed:a,validationIssues:Oa(e,r,s,n,o)}}function Oa(e,t,s,n,r){var f,p,x;const a=[],o=ei(r,t.authoritativeMessages,t.runtimeOverlayMessages,t.activeRuntimeOverlayKeys),u=As(r.map(v=>v.id));u.length>0&&a.push(`rendered_duplicate_ids:${u.join(",")}`);const d=As(t.authoritativeMessages.map(v=>v.id));d.length>0&&a.push(`authoritative_duplicate_ids:${d.join(",")}`);const h=As(t.pendingMessages.map(v=>v.clientRequestId).filter(v=>!!v));if(h.length>0&&a.push(`pending_duplicate_client_request_ids:${h.join(",")}`),Qs(r,o)||a.push("rendered_order_not_monotonic"),s.type==="pending.resolve"&&t.pendingMessages.some(w=>w.clientRequestId===s.clientRequestId)&&a.push(`pending_not_cleared:${s.clientRequestId}`),s.type==="runtime.message"&&!ri(e.authoritativeMessages,t.authoritativeMessages)&&a.push("runtime_message_mutated_authoritative_layer"),s.type==="history.merge"&&s.source.startsWith("older_history")&&!Ua(e.authoritativeMessages,t.authoritativeMessages)&&a.push("older_history_rewound_authoritative_tail"),n.length>0&&r.length>0&&s.type==="history.merge"&&s.source.startsWith("older_history")&&((f=n.at(-1))==null?void 0:f.id)!==((p=r.at(-1))==null?void 0:p.id)&&a.push("older_history_changed_rendered_tail"),o.length>0){const v=((x=r.at(-1))==null?void 0:x.id)??null;(!v||!o.includes(v))&&a.push("runtime_live_item_not_pinned_to_tail")}return a}function La(e,t){if(t.length===0)return t;const s=new Map(e.map(o=>[o.id,o])),n=new Set(s.keys()),r=e.at(-1)??null,a=t.filter(o=>{const u=Ks(s,n,o);if(!u)return!0;const d=us(u,o);return!d&&ti(r,o)?(ss("timeline.runtime_overlay_stale_dropped",{overlay:pe(o),authoritativeMatch:pe(u),latestAuthoritative:r?pe(r):null}),!1):(!d&&ni(o)&&ss("timeline.runtime_overlay_not_absorbed",{overlay:pe(o),authoritativeMatch:pe(u)}),!d)});return a.length===t.length?t:a}function Da(e,t,s,n){const r=ei(e,t,s,n);if(r.length===0)return e;const a=new Set(r),o=[...e.filter(u=>!a.has(u.id)),...e.filter(u=>a.has(u.id))];return ri(e,o)?e:o}function ei(e,t,s,n){if(s.length===0||e.length===0||n.length===0)return[];const r=new Map(t.map(f=>[f.id,f])),a=new Set(r.keys()),o=new Map(e.map(f=>[f.id,f])),u=new Set(o.keys()),d=new Map(s.map(f=>[rn(f),f])),h=[];for(const f of n){const p=d.get(f)??null;if(!p||!mn(t,p))continue;const x=Ks(r,a,p);if(x&&us(x,p))continue;const v=Ks(o,u,p);!v||h.includes(v.id)||h.push(v.id)}return h}function qa(e,t,s){if(!mn(e.authoritativeMessages,s))return t;const n=rn(s);return t.includes(n)?t:[...t,n]}function mn(e,t){return ni(t)?!ti(e.at(-1)??null,t):!1}function ti(e,t){return!e||Dt(t,e)?!1:Ha(t,e)<0}function Ha(e,t){const s=e.timestamp.localeCompare(t.timestamp);return s!==0?s:e.sequence!==t.sequence?e.sequence-t.sequence:Ht(e,t)}function Ba(e,t,s){if(s.length===0)return s;const n=new Map(t.map(o=>[rn(o),o])),r=e.at(-1)??null,a=s.filter(o=>{const u=n.get(o)??null;if(!u)return!1;const d=mn(e,u);return d||ss("timeline.runtime_overlay_tail_deactivated",{overlay:pe(u),latestAuthoritative:r?pe(r):null}),d});return a.length===s.length?s:a}function Ks(e,t,s){const n=e.get(s.id)??null,r=si(e,t,s,n);if(r)return e.get(r)??null;if(n)return n;const a=hn(e,t,s);if(a)return e.get(a)??null;const o=fn(e,s);return o?e.get(o)??null:null}function si(e,t,s,n){const r=Fa(e,t,s),a=hn(e,t,s),o=fn(e,s),u=r??a??o;if(!u)return null;if(!n)return u;const d=e.get(u)??null;return!d||!Wa(n,d,s)?null:u}function Fa(e,t,s){if(s.role!=="assistant"||s.kind!=="text"&&s.kind!=="thinking"||s.deliveryState!=="sent"||!s.rawRef.startsWith("codex://"))return null;const n=ls(s.rawRef);if(!n)return null;for(const[r,a]of e.entries()){if(r===s.id||!t.has(r)||a.role!==s.role||a.kind!==s.kind||a.deliveryState!=="sent"||!a.rawRef.startsWith("codex://"))continue;const o=ls(a.rawRef);if(!(!o||o!==n||Ht(a,s)<0||!Zr(a,s,Vs)))return ze("session.messages.codex_runtime_overlay_bridge_match",{previous:pe(a),incoming:pe(s)}),r}return null}function Wa(e,t,s){return!Dt(e,s)||!Dt(t,s)?!1:!us(e,s)&&us(t,s)}function ni(e){return e.role==="assistant"&&(e.kind==="text"||e.kind==="thinking")||e.role==="tool"&&(e.kind==="tool_call"||e.kind==="tool_result")}function us(e,t){if(e.role!==t.role||e.kind!==t.kind&&!(ws(e,t)||Ms(e,t)))return!1;const s=zr(e,{...t,id:e.id,clientRequestId:e.clientRequestId??t.clientRequestId});return Fn(s)===Fn(e)}function Fn(e){const t=e.kind==="text"||e.kind==="thinking"?$e(St(e.content).text):$e(e.content);return JSON.stringify({role:e.role,kind:e.kind,content:t,attachments:cs(e.attachments),toolCall:e.toolCall===null?null:{callId:e.toolCall.callId,name:e.toolCall.name,status:e.toolCall.status,input:$e(e.toolCall.input),output:$e(e.toolCall.output??""),error:$e(e.toolCall.error??"")}})}function As(e){const t=new Map;for(const s of e)t.set(s,(t.get(s)??0)+1);return Array.from(t.entries()).filter(([,s])=>s>1).map(([s])=>s)}function Qs(e,t=[]){if(t.length>0){const s=new Set(t),n=e.filter(r=>s.has(r.id));if(n.length>0){const r=e.filter(o=>!s.has(o.id));return e.slice(-n.length).some(o=>!s.has(o.id))?!1:Qs(r)&&Qs(n)}}for(let s=1;s<e.length;s+=1)if(Ht(e[s-1],e[s])>0)return!1;return!0}function ri(e,t){var s,n;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r+=1)if(((s=e[r])==null?void 0:s.id)!==((n=t[r])==null?void 0:n.id))return!1;return!0}function Ua(e,t){const s=e.at(-1)??null;if(!s)return!0;const n=t.at(-1)??null;return n?s.id===n.id:!1}function $a(e){switch(e.type){case"timeline.seed":return[...e.snapshotMessages,...e.bootstrapMessages];case"history.merge":return e.messages;case"runtime.message":return[e.message];case"pending.insert":return[e.pending];case"pending.resolve":return[e.message];case"pending.retry":case"pending.fail":default:return[]}}function Va(e,t,s){const n=new Map(e.map((h,f)=>[h.id,f])),r=new Map(t.map((h,f)=>[h.id,f])),a=new Map(e.map(h=>[h.id,h])),o=new Map(t.map(h=>[h.id,h])),u=new Set([...e.map(h=>h.id),...t.map(h=>h.id)]),d=[];for(const h of u){const f=a.get(h)??null,p=o.get(h)??null,x=p??f;if(!x||x.role!==s)continue;const v=n.get(h)??null,w=r.get(h)??null;v!==w&&d.push({messageId:h,fromIndex:v,toIndex:w,fromSequence:(f==null?void 0:f.sequence)??null,toSequence:(p==null?void 0:p.sequence)??null,fromRawRef:(f==null?void 0:f.rawRef)??null,toRawRef:(p==null?void 0:p.rawRef)??null,anchorChanged:(f==null?void 0:f.sequence)!==(p==null?void 0:p.sequence)||(f==null?void 0:f.timestamp)!==(p==null?void 0:p.timestamp)||(f==null?void 0:f.rawRef)!==(p==null?void 0:p.rawRef)})}return d.slice(0,8)}function ii(e){return{messageId:"id"in e?e.id:e.messageId,role:e.role,kind:e.kind??"text",sequence:e.sequence,timestamp:e.timestamp,rawRef:e.rawRef,contentPreview:Ga(e.content)}}function Wn(e){return e.map(t=>ii(t))}function Ga(e){const t=e.replace(/\s+/g," ").trim();return t.length>80?`${t.slice(0,80)}...`:t}function He(e,t){const[s,n]=c.useState(()=>t(e.getState()));return c.useEffect(()=>(n(t(e.getState())),e.subscribe(()=>{n(t(e.getState()))})),[t,e]),s}function js(e,t){return Rr({messages:t,sessionRunningState:(e==null?void 0:e.runningState)??null,sessionSyncStatus:(e==null?void 0:e.syncStatus)??null,sessionLastErrorCode:(e==null?void 0:e.lastErrorCode)??null,sessionLastErrorDetail:(e==null?void 0:e.lastErrorDetail)??null})}function oi(e){const t=e==null?void 0:e.messageCount;return typeof t=="number"&&Number.isFinite(t)?t:null}function Xa(e,t){const s=Ao(e),n=oi(t);return n===null?s:Math.max(s,n+1)}function za(e,t){const s=Ya(t);if(!s)return!1;const n=Ka(e);return n?gn(s.sequence,s.timestamp,n.sequence,n.timestamp)>=0:!0}function Ya(e){let t=null;for(const s of e)(!t||gn(s.sequence,s.timestamp,t.sequence,t.timestamp)>0)&&(t=s);return t}function Ka(e){let t=null;for(const s of e)s.deliveryState==="sent"&&(!t||gn(s.sequence,s.timestamp,t.sequence,t.timestamp)>0)&&(t=s);return t}function gn(e,t,s,n){return e!==s?e-s:t.localeCompare(n)}function Qa(e,t){return t>0?"ready":"loading"}function Za(e,t){const s=oi(e);return s!==null?s>t:t>=jt}function gt(e){return e.olderCursor?!0:e.pagesLoaded>1?e.currentHasOlderMessages:Za(e.session,e.loadedMessageCount)}function Je(e,t){return e&&{...e,runningState:t,activityState:li(e,t,e.completedAt??null,Qe(t))}}function Un(e,t){return!e||e.lastSeenAt&&e.lastSeenAt>=t?e:{...e,lastSeenAt:t,activityState:e.activityState==="completed_unread"?"idle":e.activityState}}function $n(e,t){return ai(e,{runningState:t.runningState,activityResolutionSource:t.activityResolutionSource,activityConfidence:t.activityConfidence,runId:t.runId,detail:t.detail,interruptSource:t.interruptSource,errorCode:t.errorCode,errorDetail:t.errorDetail,hasActiveRun:t.hasActiveRun,updatedAt:t.updatedAt,watchdogTriggeredAt:t.watchdogTriggeredAt})}function Ja(e,t){return ai(e,t)}function ai(e,t){if(!e)return e;const s=el(t.activityResolutionSource),n=qt(t.runningState)?Os(e.completedAt,t.updatedAt):null,r=t.runningState==="completed"||t.runningState==="interrupted"||t.runningState==="failed"?Os(e.lastEventAt,t.updatedAt):t.updatedAt;return{...e,runningState:t.runningState,activitySource:s,activityResolutionSource:t.activityResolutionSource,activityConfidence:t.activityConfidence,runId:t.runId,lastEventAt:r,completedAt:n,lastErrorCode:t.runningState==="failed"?t.errorCode??e.lastErrorCode:null,lastErrorDetail:t.runningState==="failed"?t.errorDetail??t.detail??e.lastErrorDetail:null,watchdogTriggeredAt:t.watchdogTriggeredAt,updatedAt:Os(e.updatedAt,t.updatedAt)??t.updatedAt,activityState:li(e,t.runningState,n,t.hasActiveRun)}}function li(e,t,s,n){return n||Qe(t)?"running":s&&(!e.lastSeenAt||s>e.lastSeenAt)?"completed_unread":e.activityState==="running"||e.activityState==="completed_unread"?"idle":e.activityState??"idle"}function Qe(e){return e==="starting"||e==="running"||e==="reconnecting"}function qt(e){return e==="completed"||e==="interrupted"||e==="failed"}function Vn(e){if(e===null||e.provider==="opencode")return!0;const t=e.modelOptions??[];return t.length===0?!0:t.every(s=>s.usesProviderDefault===!0)}function Gn(e,t){return e==="session.backfill"?t??"idle":t==="completed"||t==="interrupted"||t==="failed"?t:"running"}function _s(e,t){return qt(e)?e:t}function Ns(e,t){return e.runningState==="failed"?{interruptSource:null,errorCode:e.errorCode,errorDetail:e.errorDetail??e.detail}:e.runningState==="interrupted"?{interruptSource:e.interruptSource??null,errorCode:null,errorDetail:e.detail}:e.runningState==="completed"?{interruptSource:null,errorCode:null,errorDetail:e.detail}:{interruptSource:t,errorCode:null,errorDetail:null}}function el(e){return e==="authoritative_runtime"||e==="authoritative_provider_event"?"runtime":e==="inferred_log"?"inferred":"none"}function tl(e){return e.provider==="codex"&&(e.role==="assistant"||e.role==="tool")}function sl(e){return e.rawRef.startsWith("codex://")&&e.deliveryState==="sent"&&(e.role==="assistant"||e.role==="tool")}function nl(e){var t;return{id:e.messageId,rawRef:e.rawRef,role:e.role,kind:e.kind??(e.role==="tool"?"tool_result":"text"),sequence:e.sequence,timestamp:e.timestamp,callId:((t=e.toolCall)==null?void 0:t.callId)??null,contentPreview:ci(e.content,e.kind??"text")}}function Xn(e){var t;return{id:e.id,rawRef:e.rawRef,role:e.role,kind:e.kind,sequence:e.sequence,timestamp:e.timestamp,callId:((t=e.toolCall)==null?void 0:t.callId)??null,contentPreview:ci(e.content,e.kind)}}function zn(e){const t=new Map;for(const n of e){if(!sl(n))continue;const r=rl(n),a=t.get(r);if(a){a.push(n);continue}t.set(r,[n])}const s=[];for(const[n,r]of t.entries()){const a=[...r].sort((u,d)=>u.sequence!==d.sequence?u.sequence-d.sequence:u.timestamp.localeCompare(d.timestamp));let o=[];for(const u of a){const d=o.at(-1)??null;if(!d||il(d,u)){o.push(u);continue}o.length>1&&s.push({signature:n,messages:o.map(Xn)}),o=[u]}o.length>1&&s.push({signature:n,messages:o.map(Xn)})}return s}function rl(e){var r,a;if(e.kind==="tool_call"||e.kind==="tool_result")return[e.role,e.kind,((r=e.toolCall)==null?void 0:r.callId)??"",((a=e.toolCall)==null?void 0:a.name)??""].join(":");const t=St(e.content),s=Zs(t.text),n=t.inlineImages.map(o=>o.url).join("|");return[e.role,e.kind,s,n].join(":")}function il(e,t){const s=Yn(e.timestamp),n=Yn(t.timestamp);return Math.abs(s-n)<=120*1e3&&Math.abs(e.sequence-t.sequence)<=8}function ci(e,t){return t==="text"||t==="thinking"?Zs(St(e).text).slice(0,160):Zs(e).slice(0,160)}function Zs(e){return e.replace(/\r\n/g,`
7
+ `).trimEnd()}function Yn(e){const t=Date.parse(e);return Number.isFinite(t)?t:0}function Os(e,t){return e?t?e>=t?e:t:e:t??null}function Kn(){var e,t;if(typeof((e=globalThis.crypto)==null?void 0:e.randomUUID)=="function")return globalThis.crypto.randomUUID();if(typeof((t=globalThis.crypto)==null?void 0:t.getRandomValues)=="function"){const s=new Uint8Array(16);globalThis.crypto.getRandomValues(s),s[6]=s[6]&15|64,s[8]=s[8]&63|128;const n=Array.from(s,r=>r.toString(16).padStart(2,"0")).join("");return`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`}return`fallback-${Date.now()}-${Math.random().toString(16).slice(2,10)}`}function ui(e,t){return t&&(!e||e.provider===t.provider)?t:null}function Qn(e,t){const s=ui(e,t);return s?!!s.canSendMessage:e?Mr(e.provider):!1}function Zn(e,t){const s=ui(e,t);return s?!(!s.supportsInterrupt||(e==null?void 0:e.provider)==="claude-code"&&e.activitySource==="inferred"):e?e.provider==="codex"||e.provider==="opencode"?!0:e.provider==="claude-code"&&e.activitySource!=="inferred":!1}function ol(e,t,s){return t===!0||s===!0?!0:e?e.activityState==="running"||e.runningState==="starting"||e.runningState==="running"||e.runningState==="reconnecting"||e.runningState==="stale"||e.runningState==="unknown":!1}function Ls(e,t,s){return s?!0:e===!0&&Qe(t)}function Ds(e,t,s,n){return n?!0:e===!0&&(s||Qe(t))}function qs(e){return`session-runtime.snapshot.${e}`}function Jn(e){return e.filter(t=>t.deliveryState==="sent").slice(-Xr)}function al(e,t){const s=e.filter(n=>n.id!==t.id);return s.push(t),s.sort((n,r)=>n.orderIndex-r.orderIndex),s}function Hs(e,t){const s=e.filter(n=>n.id!==t.id);return s.push(t),s.sort((n,r)=>n.status!==r.status?n.status==="pending"?-1:1:r.createdAt.localeCompare(n.createdAt)),s}function Kt(e,t){if(!e)return t;if(!t||er(e,t)||tr(e,t))return e;if(er(t,e)||tr(t,e))return t;const s=Date.parse(e.updatedAt||e.lastMessageAt||e.createdAt),n=Date.parse(t.updatedAt||t.lastMessageAt||t.createdAt);return!Number.isFinite(s)||!Number.isFinite(n)?t:s>=n?e:t}function er(e,t){return sr(e)&&!sr(t)&&e.lastEventAt===t.lastEventAt&&e.lastMessageAt===t.lastMessageAt&&e.completedAt===t.completedAt}function tr(e,t){if(!nr(e)||nr(t))return!1;const s=e.completedAt??e.lastEventAt??null;return s?(!t.lastEventAt||t.lastEventAt<=s)&&(!t.completedAt||t.completedAt<=s):!1}function sr(e){return e.activityState==="running"||Qe(e.runningState)}function nr(e){return qt(e.runningState)}const ll="workbench:focus-composer",cl=15e3,ul=320;function di(){typeof window>"u"||window.dispatchEvent(new CustomEvent(ll))}function hi(e){var se,we,Fe;const t=c.useRef(null),s=c.useRef(null),[n,r]=c.useState(!1),[a,o]=c.useState(null),[u,d]=c.useState(null),[h,f]=c.useState(null),[p,x]=c.useState(null),v=at(),{showToast:w}=v,M=v.dismissToast??(()=>{}),j=lo(R=>R.notificationPreferences.notifyOnPermissionRequest),y=Rt(),O=nn(),C=c.useRef(null),_=c.useRef(null),A=c.useRef(null),P=c.useRef(((se=e.externalSession)==null?void 0:se.runningState)??null),k=c.useRef(new Set);(!t.current||s.current!==e.sessionId)&&((we=t.current)==null||we.destroy(),t.current=new Ma(e.sessionId,{initialSession:e.externalSession,bootstrapMessages:e.bootstrapMessages??[],onSeen:e.onSeen}),s.current=e.sessionId);const m=t.current,b=He(m,R=>R.session),L=He(m,R=>R.capabilities),G=He(m,R=>R.runtimeHasActiveRun),X=He(m,R=>R.runtimeCanInterrupt),Z=He(m,R=>R.messages),te=He(m,R=>R.timelineItems),D=He(m,R=>R.permissionRequests),ge=He(m,R=>R.queuedMessages),B=He(m,R=>R.contextUsage),S=He(m,R=>R.historyState),U=He(m,R=>R.errorCode),H=He(m,R=>R.errorDetail),K=He(m,R=>R.interruptSource),oe=He(m,R=>R.loadingOlderMessages),ue=He(m,R=>R.hasOlderMessages),de=He(m,R=>R.connectionState),ve=Sr(b),E=n&&!p,V=ve||G===!0||E?!0:G,z=X===!0||E?!0:X,$=ve||E,ae=(b==null?void 0:b.provider)===(L==null?void 0:L.provider)&&co(L),F=ge.some(R=>R.status==="queued"||R.status==="dispatching"),re=b??e.externalSession??null,Te=fl({sessionId:e.sessionId,provider:(b==null?void 0:b.provider)??null,runningState:(b==null?void 0:b.runningState)??null,activityState:(b==null?void 0:b.activityState)??null,runtimeHasActiveRun:G,messages:Z}),Ne=e.enableThinkingPlaceholder===!1||!Te?null:l("conversation.runtimeThinkingPlaceholder",{provider:l("conversation.providerCodex")}),q=c.useMemo(()=>jo(te,Ne),[te,Ne]);ha({sending:n,setSending:r,session:b,runtimeHasActiveRun:G,runtimeCanInterrupt:X}),c.useEffect(()=>{m.applyNavigationSession(e.externalSession)},[e.externalSession,m]),c.useEffect(()=>(m.initialize(),()=>{m.destroy(),t.current===m&&(t.current=null)}),[m]),c.useEffect(()=>{x(null),k.current.clear()},[e.sessionId]),c.useEffect(()=>{if(e.onBindSessionWorkspace)return e.onBindSessionWorkspace(e.sessionId,(b==null?void 0:b.workspaceId)??null),()=>{var R;(R=e.onBindSessionWorkspace)==null||R.call(e,e.sessionId,null)}},[e.onBindSessionWorkspace,e.sessionId,b==null?void 0:b.workspaceId]),c.useEffect(()=>{if(e.enableCompletionHaptics===!1)return;const R=P.current,N=(b==null?void 0:b.runningState)??null;(R==="starting"||R==="running"||R==="reconnecting")&&N==="completed"&&O.trigger("success"),P.current=N},[O,e.enableCompletionHaptics,b==null?void 0:b.runningState]),c.useEffect(()=>{var Pe;if((e.permissionRequestNotificationMode??"always")==="current_only"&&!e.isCurrent)return;const N=D.filter(ne=>ne.status==="pending"),Ie=(b==null?void 0:b.workspaceId)??((Pe=e.externalSession)==null?void 0:Pe.workspaceId)??null;for(const ne of N)k.current.has(ne.id)||(k.current.add(ne.id),j&&(w({id:`${e.permissionToastIdPrefix??"permission-request"}-${ne.id}`,title:l("conversation.permissionRequestToastTitle"),description:ne.title,tone:"warning",durationMs:8e3,action:Ie&&e.onNavigateToSession?{label:l("shell.contextOpenSession"),onClick:()=>{var fe;(fe=e.onNavigateToSession)==null||fe.call(e,Ie,e.sessionId)}}:void 0}),y.bridge.showNotification(l("conversation.permissionRequestToastTitle"),ne.title)))},[(Fe=e.externalSession)==null?void 0:Fe.workspaceId,e.isCurrent,e.onNavigateToSession,e.permissionRequestNotificationMode,e.permissionToastIdPrefix,e.sessionId,j,D,y.bridge,b==null?void 0:b.workspaceId,w]),c.useEffect(()=>{if(e.enableRuntimeErrorHandling!==!1)return()=>{A.current!==null&&(window.clearTimeout(A.current),A.current=null)}},[e.enableRuntimeErrorHandling]),c.useEffect(()=>{var R;e.enableRuntimeErrorHandling!==!1&&(U!=="SESSION_NOT_FOUND"&&U!=="WORKSPACE_NOT_FOUND"||(M("conversation-runtime-error"),(R=e.onResolveMissingSession)==null||R.call(e)))},[M,e.enableRuntimeErrorHandling,e.onResolveMissingSession,U]),c.useEffect(()=>{if(e.enableRuntimeErrorHandling===!1)return;if(U==="SESSION_NOT_FOUND"||U==="WORKSPACE_NOT_FOUND"){A.current!==null&&(window.clearTimeout(A.current),A.current=null),_.current=null,C.current=null,M("conversation-runtime-error");return}if(!U||!H){A.current!==null&&(window.clearTimeout(A.current),A.current=null),_.current=null,C.current=null,M("conversation-runtime-error");return}const R=`${U}:${H}`;if(!(C.current===R||_.current===R)){if(A.current!==null&&(window.clearTimeout(A.current),A.current=null),hl((b==null?void 0:b.provider)??null,U,H)){_.current=R,A.current=window.setTimeout(()=>{_.current=null,A.current=null,C.current=R,w({id:"conversation-runtime-error",title:l("conversation.runtimeErrorTitle"),description:H,tone:"error",durationMs:null})},cl);return}_.current=null,C.current=R,w({id:"conversation-runtime-error",title:l("conversation.runtimeErrorTitle"),description:H,tone:"error",durationMs:null})}},[M,e.enableRuntimeErrorHandling,U,H,b==null?void 0:b.provider,w]);const W=c.useCallback(async(R,N)=>{var ne,fe,le,Oe,Me,De,Re;const Ie=p;if(!Ie){await m.sendMessage(R,{model:N==null?void 0:N.model,reasoningLevel:N==null?void 0:N.reasoningLevel,providerConfigMode:N==null?void 0:N.providerConfigMode,providerPresetId:(N==null?void 0:N.providerPresetId)??null,attachments:N==null?void 0:N.attachments,attachmentMeta:N==null?void 0:N.attachmentMeta}),(ne=e.onRequestNavigationRefresh)==null||ne.call(e);return}let Pe=null;try{Pe=await vr(e.sessionId,{sourceType:"message",sourceMessageId:Ie.sourceMessageId,sourceMessageSnapshot:Ie.sourceMessageSnapshot,strategy:"auto",targetProvider:Ie.targetProvider,providerConfigMode:Ie.targetProviderConfigMode??(N==null?void 0:N.providerConfigMode),providerPresetId:Ie.targetProviderPresetId??(N==null?void 0:N.providerPresetId)??null}),(fe=e.onUpsertNavigationSession)==null||fe.call(e,Pe),await sn(Pe.sessionId,{content:R,clientRequestId:dl(),model:Ie.targetModel,reasoningLevel:(N==null?void 0:N.reasoningLevel)??null,permissionMode:ct(),attachments:(N==null?void 0:N.attachments)??[],providerConfigMode:Ie.targetProviderConfigMode??(N==null?void 0:N.providerConfigMode),providerPresetId:Ie.targetProviderPresetId??(N==null?void 0:N.providerPresetId)??null}),x(null),(le=e.onRequestNavigationRefresh)==null||le.call(e),(Oe=e.onNavigateToSession)==null||Oe.call(e,Pe.workspaceId,Pe.sessionId),(Me=e.onForkSuccess)==null||Me.call(e,Pe)}catch(et){throw Pe&&((De=e.onUpsertNavigationSession)==null||De.call(e,Pe),(Re=e.onRequestNavigationRefresh)==null||Re.call(e)),et}},[p,e,m]),he=c.useCallback(async(R,N)=>{r(!0);try{await W(R,N)}finally{r(!1)}},[W]),Ce=c.useCallback(async(R,N)=>{r(!0);try{p?await W(R,N):await m.enqueueMessage(R,{model:N==null?void 0:N.model,reasoningLevel:N==null?void 0:N.reasoningLevel,providerConfigMode:N==null?void 0:N.providerConfigMode,providerPresetId:(N==null?void 0:N.providerPresetId)??null,attachments:N==null?void 0:N.attachments,attachmentMeta:N==null?void 0:N.attachmentMeta})}finally{r(!1)}},[p,W,m]),me=c.useCallback(async(R,N)=>{o(R);try{await m.replyPermissionRequest(R,N)}catch(Ie){w({title:l("conversation.permissionRequestReplyFailed"),description:Ie instanceof Error?Ie.message:void 0,tone:"error"})}finally{o(null)}},[w,m]),Ee=c.useCallback(async R=>{d(R);try{await m.deleteQueuedMessage(R)}finally{d(null)}},[m]),Be=c.useCallback(async R=>{var N;f(R);try{await m.steerQueuedMessage(R),(N=e.onRequestNavigationRefresh)==null||N.call(e)}finally{f(null)}},[e.onRequestNavigationRefresh,m]),J=c.useCallback(async()=>{var R;await m.interrupt(),(R=e.onRequestNavigationRefresh)==null||R.call(e)},[e.onRequestNavigationRefresh,m]);return{session:re,capabilities:L,runtimeHasActiveRun:G,runtimeCanInterrupt:X,messages:Z,timelineItems:q,permissionRequests:D,queuedMessages:ge,contextUsage:B,historyState:S,runtimeErrorCode:U,runtimeErrorDetail:H,runtimeInterruptSource:K,loadingOlderMessages:oe,hasOlderMessages:ue,connectionState:de,sending:n,replyingPermissionRequestId:a,deletingQueueItemId:u,steeringQueueItemId:h,forkDraft:p,setForkDraft:x,composerHasActiveRun:V,composerCanInterrupt:z,composerIsRunning:$,canSteerQueuedMessage:ae,hasPendingQueuedMessages:F,reconnect:m.reconnect.bind(m),loadOlderMessages:m.loadOlderMessages.bind(m),retryMessage:m.retryMessage.bind(m),send:he,queue:Ce,interrupt:J,replyPermissionRequest:me,deleteQueuedMessage:Ee,steerQueuedMessage:Be}}function dl(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`}function hl(e,t,s){return e!=="opencode"?!1:t==="OPENCODE_REQUEST_TIMEOUT"||t==="PROVIDER_RUNTIME_TIMEOUT"||/\bSERVER_TIMEOUT\b/i.test(s)||/timeout/i.test(s)||/超时/.test(s)}function fl(e){const t=pl(e),[s,n]=c.useState(t==="show"),r=c.useRef(null);return c.useEffect(()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null),n(t==="show")},[e.sessionId]),c.useEffect(()=>{if(t==="show"){r.current!==null&&(window.clearTimeout(r.current),r.current=null),n(!0);return}if(t==="hide_immediately"){r.current!==null&&(window.clearTimeout(r.current),r.current=null),n(!1);return}!s||r.current!==null||(r.current=window.setTimeout(()=>{r.current=null,n(!1)},ul))},[t,s]),c.useEffect(()=>()=>{r.current!==null&&window.clearTimeout(r.current)},[]),s}function pl(e){const{provider:t,runningState:s,activityState:n,runtimeHasActiveRun:r,messages:a}=e;if(t!=="codex")return"hide_immediately";const o=vl(a);return o<0||gl(a,o)?"hide_immediately":ml(s,n,r)?"show":"hide_deferred"}function ml(e,t,s){return s===!0||t==="running"||e==="starting"||e==="running"||e==="reconnecting"}function gl(e,t){return e.slice(t+1).some(s=>s.role==="assistant"&&(s.kind==="text"||s.kind==="thinking"))}function vl(e){let t=-1;for(let s=e.length-1;s>=0;s-=1){const n=e[s];if(n.role==="user"&&n.kind==="text"){t=s;break}}return t}const bl=1.5,wl=24,Ml=72,Sl=296,Il=16,rr={2:496,3:408,4:344};function fi(e){return rr[e]??rr[4]}function yl({memberCount:e,currentWidth:t,monitorWidth:s}){if(e<2||t<=0||s<=0)return t;const n=Sl,r=Math.max(0,e-1)*Il,a=Math.max(0,(t-n-r)/e),o=fi(e);if(a>=o)return t;const u=n+r+e*o,d=Math.min(t*bl,Math.max(t,s-Ml)),h=Math.min(Math.max(t,u),d);return h<=t+wl?t:h}const xl=240,ir=920,or=760,vn=360,bn=320,Ue=16,ar=428,Pl=404,nt=12;function Ot(e,t){if(typeof window>"u")return e;const s=Math.max(0,window.innerWidth-Ue*2),n=Math.max(0,window.innerHeight-Ue*2),r=Math.min((t==null?void 0:t.minWidth)??vn,s),a=Math.min((t==null?void 0:t.minHeight)??bn,n),o=Math.max(r,s),u=Math.max(a,n),d=Math.min(Math.max(e.width,r),o),h=Math.min(Math.max(e.height,a),u),f=Math.min(Math.max(e.x,Ue),Math.max(Ue,window.innerWidth-d-Ue)),p=Math.min(Math.max(e.y,Ue),Math.max(Ue,window.innerHeight-h-Ue));return{x:f,y:p,width:d,height:h}}function Rl(e){if(typeof window>"u")return{x:Ue,y:Ue,width:ir,height:or};const t=Math.min(ir,Math.max(vn,window.innerWidth-Ue*2)),s=Math.min(or,Math.max(bn,window.innerHeight-Ue*2));return Ot({x:((e==null?void 0:e.right)??window.innerWidth-Ue)-t+28,y:Math.max(((e==null?void 0:e.bottom)??48)+8,Ue),width:t,height:s})}function Tl(e){return!e||e.width<=0||e.height<=0?null:Ot({x:e.left,y:e.top,width:e.width,height:e.height},{minWidth:Math.min(vn,e.width),minHeight:Math.min(bn,e.height)})}function Cl(e){if(typeof window>"u")return{x:nt,y:nt,width:ar};const t=Math.min(ar,Math.max(Pl,window.innerWidth-nt*2));return{x:Math.min(Math.max(((e==null?void 0:e.right)??window.innerWidth-nt)-t,nt),Math.max(nt,window.innerWidth-t-nt)),y:Math.max(nt,((e==null?void 0:e.bottom)??nt)+8),width:t}}function kl({groupId:e,currentSessionId:t}){var ue,de,ve;const s=dt(),n=Rt(),r=Tr(n),{showToast:a}=at(),{navigationGroups:o,requestNavigationRefresh:u}=xt(),d=c.useMemo(()=>ms(o),[o]),h=c.useMemo(()=>new Map(d.map(E=>[E.session.sessionId,E])),[d]),f=c.useMemo(()=>gs(d),[d]),p=c.useMemo(()=>{const E=new Map,V=z=>{for(const $ of z)E.set($.item.session.sessionId,$),V(vs($))};return V(f),E},[f]),x=c.useMemo(()=>on(o),[o]),[v,w]=c.useState(null),[M,j]=c.useState(!0),[y,O]=c.useState(null),[C,_]=c.useState(null),[A,P]=c.useState(null),[k,m]=c.useState(null),[b,L]=c.useState(null),[G,X]=c.useState(!1),Z=c.useRef(null),te=c.useRef(null);c.useEffect(()=>{let E=!1;async function V(){j(!0),O(null);try{const z=await uo(e);if(E)return;w(z)}catch(z){if(E)return;O(z instanceof Error?z.message:l("shell.parallelGroupLoadFailed"))}finally{E||j(!1)}}return V(),()=>{E=!0}},[e]),c.useEffect(()=>{const E=No(e);E&&S(E)},[e]),c.useEffect(()=>()=>{te.current!==null&&window.clearTimeout(te.current)},[]);const D=c.useMemo(()=>v?v.members.slice().sort((E,V)=>E.member.ordinal-V.member.ordinal).map(E=>{const V=h.get(E.session.sessionId),z=(V==null?void 0:V.session)??E.session;return{session:z,workspaceId:(V==null?void 0:V.workspace.id)??es(z,E.sessionIsolatedWorkspace),ordinal:E.member.ordinal,memberPrompt:E.member.memberPrompt,model:E.member.model,sessionIsolatedWorkspace:E.sessionIsolatedWorkspace,subagentTree:ql(z.sessionId,v.group.id,p)}}):[],[v,h,p]);c.useEffect(()=>{if(!n.isDesktop||n.ui.osFamily!=="macos"&&n.ui.osFamily!=="windows"||D.length<2)return;const E=`${e}:${D.length}`;if(Z.current===E)return;Z.current=E;let V=!1;async function z(){try{const $=await Mn(()=>import("./window-BVUB8gMK.js").then(Ee=>Ee.w),__vite__mapDeps([0,1])),ae=await Mn(()=>import("./window-BVUB8gMK.js").then(Ee=>Ee.d),__vite__mapDeps([0,1])),F=$.getCurrentWindow(),re=await F.innerSize(),Te=await F.scaleFactor(),Ne=await $.currentMonitor();if(V||Te<=0)return;const q=re.width/Te,W=re.height/Te,he=Ne?Ne.workArea.size.width/Ne.scaleFactor:q*1.5,Ce=yl({memberCount:D.length,currentWidth:q,monitorWidth:he});if(Ce<=q+24)return;const me=10;await new Promise(Ee=>window.setTimeout(Ee,56));for(let Ee=1;Ee<=me;Ee+=1){if(V)return;const Be=Ee/me,J=1-Math.pow(1-Be,3),se=q+(Ce-q)*J;await F.setSize(new ae.LogicalSize(se,W)),await new Promise(we=>window.setTimeout(we,xl/me))}}catch{return}}return z(),()=>{V=!0}},[e,D.length,n.isDesktop,n.ui.osFamily]);async function ge(E){P(E);try{const V=await fo(E);await u(),w(z=>z&&{...z,members:z.members.map($=>{var ae;return((ae=$.sessionIsolatedWorkspace)==null?void 0:ae.id)===E?{...$,sessionIsolatedWorkspace:{...$.sessionIsolatedWorkspace,workspaceId:V.workspace.id,lifecycleStatus:"promoted",promotedAt:V.record.promotedAt}}:$})}),a({title:l("shell.parallelWorkspacePromotedBadge"),tone:"success"})}catch(V){a({title:V instanceof Error?V.message:l("shell.parallelGroupLoadFailed"),tone:"error"})}finally{P(null)}}async function B(E){if(k)return;const V=E.trim();if(!V)return;const z=D.find(ae=>ae.session.sessionId!==V)??null,$=(v==null?void 0:v.group.workspaceId)??(z==null?void 0:z.workspaceId)??null;m(V);try{await ho(V),Us(V,null),_(ae=>ae===V?null:ae),w(ae=>ae&&{...ae,members:ae.members.filter(F=>F.session.sessionId!==V)}),await u(),t===V&&(z?s(Xe(z.workspaceId,z.session.sessionId)):$&&s(_t($))),a({title:l("shell.deleteSessionSuccess"),tone:"success"})}catch(ae){a({title:ae instanceof Error?ae.message:l("shell.deleteSessionFailed"),tone:"error"})}finally{m(null)}}function S(E){L(E),te.current!==null&&window.clearTimeout(te.current),te.current=window.setTimeout(()=>{L(null),te.current=null},E.totalDurationMs)}if(M&&!v)return i.jsx("main",{className:"workbench-page conversation-page-shell parallel-conversation-page",children:i.jsx("section",{className:"parallel-conversation-empty-state",children:i.jsx("strong",{children:l("shell.parallelCreateSubmitting")})})});if(y&&!v)return i.jsx("main",{className:"workbench-page conversation-page-shell parallel-conversation-page",children:i.jsxs("section",{className:"parallel-conversation-empty-state error",children:[i.jsx("strong",{children:l("shell.parallelGroupLoadFailed")}),i.jsx("p",{children:y})]})});if(D.length===0)return i.jsx("main",{className:"workbench-page conversation-page-shell parallel-conversation-page",children:i.jsx("section",{className:"parallel-conversation-empty-state",children:i.jsx("strong",{children:l("shell.parallelGroupEmpty")})})});const U=((ue=x[(v==null?void 0:v.group.workspaceId)??""])==null?void 0:ue.displayName)??(v==null?void 0:v.group.workspaceId)??l("common.unknown"),H=D.find(E=>E.session.sessionId===(v==null?void 0:v.group.anchorSessionId))??D[0]??null,K=D.length<4,oe={"--parallel-pane-min-width":`${fi(D.length)}px`,...b?{"--parallel-pane-enter-delay":`${b.paneEnterDelayMs}ms`,"--parallel-pane-enter-duration":`${b.paneEnterDurationMs}ms`,"--parallel-grid-reveal-delay":`${b.gridRevealDelayMs}ms`,"--parallel-grid-reveal-duration":`${b.gridRevealDurationMs}ms`,"--parallel-shell-expand-duration":`${b.shellExpandDurationMs}ms`,"--parallel-pane-stagger-delay":`${b.paneStaggerMs}ms`}:{}};return i.jsxs("main",{className:"workbench-page conversation-page-shell parallel-conversation-page","data-parallel-count":D.length,"data-parallel-entering":b?"true":void 0,style:oe,children:[i.jsx("header",{className:"parallel-conversation-group-header","data-window-drag-handle":"parallel-conversation-group-titlebar","data-tauri-drag-region":r,children:i.jsxs("div",{className:"parallel-conversation-group-titlebar","data-tauri-drag-region":r,children:[i.jsxs("div",{className:"parallel-conversation-group-titlemain","data-tauri-drag-region":r,children:[i.jsx("span",{className:"session-parallel-badge",children:l("shell.parallelGroupBadge")}),i.jsx("strong",{"data-tauri-drag-region":r,children:((de=v==null?void 0:v.group.sharedPrompt)==null?void 0:de.trim())||l("common.unknown")})]}),i.jsx("button",{type:"button",className:"secondary-button parallel-conversation-group-add-button","aria-label":l("shell.parallelAppendAction"),title:l("shell.parallelAppendAction"),"data-window-drag":"ignore",disabled:!K,onClick:()=>{K&&X(!0)},children:i.jsx("span",{"aria-hidden":"true",children:"+"})})]})}),i.jsx("div",{className:"parallel-conversation-grid",children:D.map(E=>{const V=x[E.workspaceId]??an({id:E.workspaceId,name:E.session.workspaceId,path:E.session.workspaceId,repoRoot:E.session.workspaceId});return i.jsx(El,{entry:E,isCurrent:E.session.sessionId===t||Ft(E.subagentTree,t),routeCurrentSessionId:t,workspaceContext:V,infoOpen:C===E.session.sessionId,promotingWorkspaceId:A,onCloseInfo:()=>{_(null)},onToggleInfo:()=>{_(z=>z===E.session.sessionId?null:E.session.sessionId)},onPromoteWorkspace:ge,onRemoveSession:B,removingSessionId:k},E.session.sessionId)})}),i.jsx(Ws,{open:G,source:v?{kind:"group",groupId:v.group.id,workspaceId:v.group.workspaceId,workspaceName:U,sharedPrompt:((ve=v.group.sharedPrompt)==null?void 0:ve.trim())||"",currentMemberCount:D.length,defaultProvider:(H==null?void 0:H.session.provider)??"codex"}:null,onClose:()=>X(!1),onCreated:async E=>{w(E),X(!1),S(_o("append")),await u(),a({title:l("shell.parallelAppendSucceeded"),tone:"success"})}})]})}function El({entry:e,isCurrent:t,routeCurrentSessionId:s,workspaceContext:n,infoOpen:r,onCloseInfo:a,onToggleInfo:o,onPromoteWorkspace:u,promotingWorkspaceId:d,onRemoveSession:h,removingSessionId:f}){var $t,Ct,mt,kt,Vt,Gt,Xt;const p=dt(),x=Rt(),{showToast:v}=at(),{navigationGroups:w,requestNavigationRefresh:M,setSessionWorkspace:j,upsertNavigationSession:y,markNavigationSessionSeen:O,selectWorkspace:C}=xt(),_=e.session.sessionId,[A,P]=c.useState(()=>Hl(e,s)),k=c.useMemo(()=>new Map(ms(w).map(T=>[T.session.sessionId,T])),[w]),m=A===_?e.session:(($t=k.get(A))==null?void 0:$t.session)??mi(e.subagentTree,A)??e.session,b=A===_?e.workspaceId:((Ct=k.get(A))==null?void 0:Ct.workspace.id)??gi(e.subagentTree,A)??e.workspaceId,L=m.sessionId,[G,X]=c.useState(!1),[Z,te]=c.useState("files"),[D,ge]=c.useState(!1),[B,S]=c.useState(null),[U,H]=c.useState(null),K=c.useRef(null),oe=c.useRef(null),ue=c.useRef(null),de=c.useRef(null),ve=c.useRef(null),E=c.useRef(null),[V,z]=c.useState(()=>Cn(_)),{session:$,capabilities:ae,messages:F,timelineItems:re,permissionRequests:Te,queuedMessages:Ne,contextUsage:q,historyState:W,runtimeInterruptSource:he,loadingOlderMessages:Ce,hasOlderMessages:me,connectionState:Ee,sending:Be,replyingPermissionRequestId:J,deletingQueueItemId:se,steeringQueueItemId:we,forkDraft:Fe,setForkDraft:R,composerHasActiveRun:N,composerCanInterrupt:Ie,composerIsRunning:Pe,canSteerQueuedMessage:ne,hasPendingQueuedMessages:fe,reconnect:le,loadOlderMessages:Oe,retryMessage:Me,send:De,queue:Re,interrupt:et,replyPermissionRequest:it,deleteQueuedMessage:ht,steerQueuedMessage:ft}=hi({sessionId:L,externalSession:m,onSeen:(T,ie)=>{O(T,ie)},onRequestNavigationRefresh:M,onUpsertNavigationSession:y,onNavigateToSession:(T,ie)=>{C(T),p(Xe(T,ie))},onBindSessionWorkspace:A===_?j:void 0,onResolveMissingSession:()=>{M()},permissionRequestNotificationMode:"current_only",permissionToastIdPrefix:"parallel-permission-request",isCurrent:t,enableRuntimeErrorHandling:!0,enableCompletionHaptics:!1,enableThinkingPlaceholder:!0,enableForkTimelineSanitizer:!0}),Ze=Oo(($==null?void 0:$.parallelGroup)??e.session.parallelGroup),tt=Lo({groupId:((mt=($==null?void 0:$.parallelGroup)??e.session.parallelGroup)==null?void 0:mt.groupId)??"parallel-group",ordinal:e.ordinal,overrideColor:V}),pt=Do(($==null?void 0:$.parallelGroup)??e.session.parallelGroup),Ae=($==null?void 0:$.sessionIsolatedWorkspace)??e.sessionIsolatedWorkspace,st=qo(Ae),ot=((kt=q==null?void 0:q.modelId)==null?void 0:kt.trim())||((Vt=e.model)==null?void 0:Vt.trim())||l("shell.parallelPaneModelFallback"),Ve=((Gt=e.memberPrompt)==null?void 0:Gt.trim())||l("shell.parallelPanePromptFallback"),ke=b,ce=Cr($??m,Ae),g=ce===ke?(n==null?void 0:n.displayName)??ke:st??Ve,Y=c.useMemo(()=>{var T;return((T=w.find(ie=>ie.workspace.id===ce))==null?void 0:T.workspace.path)??null},[w,ce]),Q=f===L;async function ye(T){await De(Object.entries(T.answers).map(([,ie])=>ie.filter(Boolean).join(" / ")).filter(Boolean).join(`
8
+ `))}const qe=r&&U?{...bt(n)??{},...Ze??{},...tt,left:`${U.x}px`,top:`${U.y}px`,width:`${U.width}px`}:void 0,We=G&&B?{...bt(n)??{},...Ze??{},...tt,left:`${B.x}px`,top:`${B.y}px`,width:`${B.width}px`,height:`${B.height}px`}:void 0;c.useEffect(()=>{z(Cn(_)),X(!1),ge(!1),S(null),H(null),te("files")},[_]),c.useEffect(()=>{if(Ft(e.subagentTree,s)){P(s);return}if(s===_){P(_);return}P(T=>Bl(e,T)?T:_)},[e,_,s]),c.useEffect(()=>{if(!r)return;const T=ie=>{var Ge,Ke,I;const Ye=ie.target;Ye instanceof HTMLElement&&((Ge=oe.current)!=null&&Ge.contains(Ye)||(Ke=de.current)!=null&&Ke.contains(Ye)||(I=ve.current)!=null&&I.contains(Ye)||a())};return window.addEventListener("pointerdown",T),()=>{window.removeEventListener("pointerdown",T)}},[r,a]),c.useEffect(()=>{if(!r){H(null);return}const T=()=>{var ie;H(Cl(((ie=ue.current)==null?void 0:ie.getBoundingClientRect())??null))};return T(),window.addEventListener("resize",T),window.addEventListener("scroll",T,!0),()=>{window.removeEventListener("resize",T),window.removeEventListener("scroll",T,!0)}},[r]),c.useEffect(()=>{if(!G)return;const T=()=>{S(ie=>ie&&Ot(ie))};return window.addEventListener("resize",T),()=>{window.removeEventListener("resize",T)}},[G]);async function je(){if(ce===ke&&C(ke),x.isDesktop&&x.bridge.supported){const T=await Uo(x,{workspaceId:ce,workspaceName:g,focusOwner:"terminal-page"});T.ok||v({title:T.detail??l("terminalManager.openExternalFailed"),tone:"error"});return}p($o(ce))}async function Le(){if(!(!x.isDesktop||!x.bridge.supported)){if(Z==="files"){const T=await Bo(x,{workspaceId:ce,workspaceName:g,sessionId:L,focusOwner:"file-context-panel"});T.ok||v({title:T.detail??l("conversation.filePanelOpenExternalFailed"),tone:"error"});return}if(Z==="git"){const T=await Fo(x,{workspaceId:ce,workspaceName:g,focusOwner:"git-sidebar"});T.ok||v({title:T.detail??l("git.openExternalFailed"),tone:"error"});return}if(Z==="processes"){const T=await Wo(x,{workspaceId:ce,workspaceName:g,focusOwner:"terminal-manager-panel"});T.ok||v({title:T.detail??l("terminalManager.openExternalFailed"),tone:"error"});return}await je()}}function _e(){var T,ie;X(!0),S(Tl(((T=K.current)==null?void 0:T.getBoundingClientRect())??null)??Rl(((ie=E.current)==null?void 0:ie.getBoundingClientRect())??null))}function lt(T){if(T.button!==0||!B)return;T.preventDefault();const ie=T.clientX,Ye=T.clientY,Ge=B,Ke=ee=>{S(Ot({...Ge,x:Ge.x+(ee.clientX-ie),y:Ge.y+(ee.clientY-Ye)}))},I=()=>{window.removeEventListener("pointermove",Ke),window.removeEventListener("pointerup",I)};window.addEventListener("pointermove",Ke),window.addEventListener("pointerup",I)}function Wt(T){if(T.button!==0||!B)return;T.preventDefault(),T.stopPropagation();const ie=T.clientX,Ye=T.clientY,Ge=B,Ke=ee=>{S(Ot({...Ge,width:Ge.width+(ee.clientX-ie),height:Ge.height+(ee.clientY-Ye)}))},I=()=>{window.removeEventListener("pointermove",Ke),window.removeEventListener("pointerup",I)};window.addEventListener("pointermove",Ke),window.addEventListener("pointerup",I)}const Ut=G&&typeof document<"u"?It.createPortal(i.jsxs("div",{ref:ve,className:"parallel-pane-tools-popover","data-parallel-pane-layer":L,"data-pinned":D?"true":void 0,"data-workspace-tone":(n==null?void 0:n.tone)??"root",style:We,children:[i.jsxs("div",{className:"parallel-pane-tools-toolbar",children:[i.jsxs("div",{className:"parallel-pane-tools-drag-handle",onPointerDown:lt,children:[i.jsx("span",{className:"parallel-pane-tools-drag-dots","aria-hidden":"true",children:i.jsx(_l,{})}),i.jsx("span",{children:l("shell.parallelPaneToolsAction")})]}),i.jsx("div",{className:"parallel-pane-tools-tabs",role:"tablist","aria-label":l("shell.parallelPaneToolsAction"),children:["files","git","processes","terminals"].map(T=>i.jsx("button",{type:"button",role:"tab","aria-selected":Z===T,className:"parallel-pane-tools-tab",onClick:()=>{te(T)},children:T==="files"?l("shell.filesEntry"):T==="git"?l("shell.gitEntry"):T==="processes"?l("shell.parallelPaneProcessesEntry"):l("shell.terminalsEntry")},T))}),i.jsxs("div",{className:"parallel-pane-tools-actions",children:[i.jsx("button",{type:"button",className:`conversation-header-ai-button${D?" active":""}`,"aria-label":l("shell.parallelPanePinAction"),title:l("shell.parallelPanePinAction"),"aria-pressed":D,onClick:()=>{ge(T=>!T)},children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(Nl,{})})}),x.isDesktop&&x.bridge.supported?i.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":l("shell.parallelPaneDetachAction"),title:l("shell.parallelPaneDetachAction"),onClick:()=>{Le()},children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(Ol,{})})}):null,i.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":l("common.close"),title:l("common.close"),onClick:()=>{X(!1)},children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(Ll,{})})})]})]}),i.jsx("div",{className:"parallel-pane-tools-body","data-panel":Z,children:Z==="files"?i.jsx(Dr,{className:"parallel-pane-tools-surface",hideHeading:!0,sessionId:L,workspaceId:ce}):Z==="git"?i.jsx(qr,{className:"parallel-pane-tools-surface",panelActive:!0,workspaceId:ce}):Z==="processes"?i.jsx(Hr,{className:"parallel-pane-tools-surface parallel-pane-tools-process-panel",currentWorkspaceId:ce,navigationGroups:w}):i.jsx(ea,{embeddedMode:!0,externalWindowWorkspaceId:ce,workbenchShellOverrides:{navigationGroups:w,currentWorkspaceId:ce,selectWorkspace:C}})}),i.jsx("button",{type:"button",className:"parallel-pane-tools-resize-handle","aria-label":l("shell.parallelPaneResizeAction"),title:l("shell.parallelPaneResizeAction"),onPointerDown:Wt,children:i.jsx("span",{"aria-hidden":"true",children:i.jsx(Dl,{})})})]}),document.body):null,Tt=r&&typeof document<"u"?It.createPortal(i.jsxs("div",{ref:de,className:"parallel-pane-info-popover","data-parallel-pane-layer":L,"data-workspace-tone":(n==null?void 0:n.tone)??"root",style:qe,children:[i.jsx("strong",{className:"parallel-pane-info-title",children:l("shell.parallelPaneInfoTitle")}),i.jsx(vt,{children:i.jsxs("dl",{className:"parallel-pane-info-list",children:[i.jsxs("div",{children:[i.jsx("dt",{children:l("shell.createSessionProviderLabel")}),i.jsx("dd",{children:Lt(($??e.session).provider,"full")})]}),i.jsxs("div",{children:[i.jsx("dt",{children:l("shell.parallelPaneModelFallback")}),i.jsx("dd",{children:ot})]}),i.jsxs("div",{children:[i.jsx("dt",{children:l("shell.parallelPaneIsolatedWorkspaceTitle")}),i.jsx("dd",{children:st??l("common.unknown")})]})]})}),i.jsx(vt,{heading:l("shell.parallelPaneColorPaletteLabel"),description:l("shell.parallelPaneColorPaletteDescription"),actions:i.jsx("button",{type:"button",className:"ghost-button parallel-pane-color-reset",disabled:!V||Q,onClick:()=>{Us(_,null),z(null)},children:l("shell.parallelPaneColorPaletteReset")}),children:i.jsx("div",{className:"workbench-manage-color-palette parallel-pane-color-palette","aria-label":l("shell.parallelPaneColorPaletteLabel"),children:Ho.map(T=>i.jsx("button",{type:"button",className:"workbench-manage-color-swatch","aria-label":l("shell.manageWorkspaceColorSelectSwatch",{color:T}),"aria-pressed":V===T,"data-selected":V===T,disabled:Q,style:{backgroundColor:T},onClick:()=>{const ie=Us(_,T);z(ie)}},T))})}),i.jsx(vt,{heading:l("shell.parallelPaneIsolatedWorkspaceTitle"),description:(Ae==null?void 0:Ae.lifecycleStatus)==="active"?l("shell.parallelPanePromoteDescription"):(Ae==null?void 0:Ae.lifecycleStatus)==="promoted"?l("shell.parallelPaneRemovePromotedDescription"):l("shell.parallelPaneRemoveDescription"),children:i.jsxs(ps,{align:"start",className:"parallel-pane-action-row",children:[(Ae==null?void 0:Ae.lifecycleStatus)==="active"?i.jsx("button",{type:"button",className:"secondary-button parallel-pane-promote-action",disabled:d===Ae.id||Q,onClick:()=>{const T=Ae==null?void 0:Ae.id;T&&u(T)},children:d===Ae.id?l("shell.parallelPanePromoting"):l("shell.parallelPanePromoteAction")}):null,i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:Q,onClick:()=>{h(L)},children:Q?l("shell.parallelPaneRemoving"):l("shell.parallelPaneRemoveAction")})]})})]}),document.body):null;return i.jsxs(i.Fragment,{children:[i.jsxs("article",{ref:K,className:"parallel-conversation-pane","data-current":t?"true":void 0,"data-workspace-tone":(n==null?void 0:n.tone)??"root","data-parallel-role":((Xt=($==null?void 0:$.parallelGroup)??e.session.parallelGroup)==null?void 0:Xt.role)??void 0,style:{"--parallel-pane-order":String(e.ordinal),...bt(n)??{},...Ze??{},...tt},children:[i.jsxs("header",{ref:oe,className:"parallel-conversation-pane-header",children:[i.jsx("span",{className:"parallel-conversation-pane-connector","aria-hidden":"true"}),i.jsxs("div",{className:"parallel-conversation-pane-heading",children:[pt?i.jsx("span",{className:"session-parallel-badge",children:pt}):null,i.jsx("p",{className:"parallel-conversation-pane-subtitle",title:Ve,children:Ve}),i.jsxs("div",{className:"parallel-conversation-pane-meta",children:[i.jsx("span",{className:`session-provider-badge ${($??e.session).provider}`,children:Lt(($??e.session).provider)}),i.jsx("span",{className:"parallel-conversation-pane-model",children:ot})]})]}),i.jsxs("div",{className:"parallel-conversation-pane-actions",children:[i.jsx("button",{ref:ue,type:"button",className:"conversation-header-ai-button","aria-label":l("shell.parallelPaneInfoAction"),title:l("shell.parallelPaneInfoAction"),"aria-expanded":r,onClick:()=>{X(!1),o()},children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(Al,{})})}),i.jsx("button",{ref:E,type:"button",className:`conversation-header-ai-button${G?" active":""}`,"aria-label":l("shell.parallelPaneToolsAction"),title:l("shell.parallelPaneToolsAction"),"aria-expanded":G,onClick:()=>{a(),_e()},children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(jl,{})})})]})]}),i.jsxs("div",{className:"parallel-conversation-pane-body",children:[i.jsx(dn,{connectionState:Ee,onReconnect:le}),i.jsx(Lr,{requests:Te,replyingRequestId:J,onReply:it}),i.jsx("div",{className:"parallel-conversation-pane-timeline",children:i.jsx(ln,{sessionId:L,sessionSummary:$??e.session,workspaceId:ce,workspacePath:Y,items:re,historyState:W,loadingOlderMessages:Ce,hasOlderMessages:me,provider:($==null?void 0:$.provider)??e.session.provider,interruptedSource:he,followTailUpdates:!0,onLoadOlderMessages:Oe,onRetryMessage:Me,onSubmitStructuredQuestion:ye,onForkMessage:T=>{const ie=$??e.session;R({sourceMessageId:T.id,sourceMessageSnapshot:{role:T.role,kind:T.kind??(T.role==="tool"?"tool_result":"text"),content:T.content},content:T.content,sourceProvider:ie.provider,workspaceId:ie.workspaceId,targetProvider:ie.provider,targetModel:null,targetProviderConfigMode:ie.providerConfigMode??"global-default",targetProviderPresetId:ie.providerPresetId??null}),di()}})}),i.jsx(Gr,{items:Ne,deletingQueueItemId:se,steeringQueueItemId:we,canSteer:ne,onDelete:ht,onSteer:ft}),i.jsx(un,{capabilities:ae,draftStorageId:L,initialModel:e.model,workspaceId:($??e.session).workspaceId,initialProviderConfigMode:($??e.session).providerConfigMode??"global-default",initialProviderPresetId:($??e.session).providerPresetId??null,forkDraft:Fe,onClearForkDraft:()=>R(null),onForkDraftChange:T=>R(T),hasActiveRun:N,contextUsage:q,taskProvider:($??e.session).provider,taskMessages:F,hasPendingQueuedMessages:fe,canInterrupt:Ie,isSubmitting:Be,isRunning:Pe,onInterrupt:et,onSend:De,onQueueSend:Re})]})]}),Tt,Ut]})}function Al(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("circle",{cx:"8",cy:"8",r:"5.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),i.jsx("path",{d:"M8 6.1H8.01M7.35 7.6H8V10.3H8.65",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.4"})]})}function jl(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("rect",{x:"2.5",y:"2.5",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("rect",{x:"9.3",y:"2.5",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("rect",{x:"2.5",y:"9.3",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"}),i.jsx("rect",{x:"9.3",y:"9.3",width:"4.2",height:"4.2",rx:"1.2",fill:"none",stroke:"currentColor",strokeWidth:"1.2"})]})}function _l(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("circle",{cx:"5",cy:"4.5",r:"0.9",fill:"currentColor"}),i.jsx("circle",{cx:"11",cy:"4.5",r:"0.9",fill:"currentColor"}),i.jsx("circle",{cx:"5",cy:"8",r:"0.9",fill:"currentColor"}),i.jsx("circle",{cx:"11",cy:"8",r:"0.9",fill:"currentColor"}),i.jsx("circle",{cx:"5",cy:"11.5",r:"0.9",fill:"currentColor"}),i.jsx("circle",{cx:"11",cy:"11.5",r:"0.9",fill:"currentColor"})]})}function Nl(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M10.9 3.1 12.9 5.1 10.9 6.1v2.1l-2.1 2.1v2.6l-.8-.8-.8.8v-2.6L5 8.2V6.1L3.1 5.1l2-2h5.8Z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.1"})})}function Ol(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M5 3.1H3.8A1.3 1.3 0 0 0 2.5 4.4v7.8a1.3 1.3 0 0 0 1.3 1.3h7.8a1.3 1.3 0 0 0 1.3-1.3V11",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.2"}),i.jsx("path",{d:"M8.1 3.1h4.4v4.4M12.3 3.3 7 8.6",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.2"})]})}function Ll(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M4.5 4.5 11.5 11.5M11.5 4.5 4.5 11.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeWidth:"1.3"})})}function Dl(){return i.jsx("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:i.jsx("path",{d:"M6.5 12.2 12.2 6.5M9 12.4 12.4 9M11.4 12.4 12.4 11.4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.1"})})}function ql(e,t,s){const n=s.get(e);return n?vs(n).flatMap(r=>pi(r,t)):[]}function pi(e,t){var r;const s=e.item.session;if(((r=s.parallelGroup)==null?void 0:r.groupId)===t)return[];const n=vs(e).flatMap(a=>pi(a,t));return s.isSubagent!==!0?n:[{session:s,workspaceId:e.item.workspace.id,children:n}]}function Ft(e,t){const s=t.trim();return s?e.some(n=>n.session.sessionId===s||Ft(n.children,s)):!1}function Hl(e,t){return t===e.session.sessionId?e.session.sessionId:Ft(e.subagentTree,t)?t:e.session.sessionId}function Bl(e,t){const s=t.trim();return s?s===e.session.sessionId||Ft(e.subagentTree,s):!1}function mi(e,t){const s=t.trim();if(!s)return null;for(const n of e){if(n.session.sessionId===s)return n.session;const r=mi(n.children,s);if(r)return r}return null}function gi(e,t){const s=t.trim();if(!s)return null;for(const n of e){if(n.session.sessionId===s)return n.workspaceId;const r=gi(n.children,s);if(r)return r}return null}const Mt=196,ut=82,lr=28,cr=24,vi=34,Js=18,Fl=332,Qt=360,ds=840,ur=18,Wl=.22,Ul=2.4,$l=6;function Vl(e,t){return(t.lastMessageAt??t.updatedAt).localeCompare(e.lastMessageAt??e.updatedAt)}function bi(e,t,s){var v,w;if(!t)return null;const n=e.find(M=>M.workspace.id===t);if(!n)return null;const r=new Map(n.sessions.map(M=>[M.sessionId,M])),a=r.get(s)??null;if(!a)return null;const o=new Map;for(const M of n.sessions){const j=((v=M.parentSessionId)==null?void 0:v.trim())||null;if(!j)continue;const y=o.get(j)??[];o.set(j,[...y,M.sessionId])}const u=new Set,d=new Set;let h=a,f=a.sessionId;for(;h&&!d.has(h.sessionId);){u.add(h.sessionId),d.add(h.sessionId),f=h.sessionId;const M=((w=h.parentSessionId)==null?void 0:w.trim())||null;h=M?r.get(M)??null:null}const p=wi(f,0,r,o,new Set),x=Xl(p);return{root:p,current:a,currentPathIds:u,relatedSessionIds:x,sessionsById:r}}function Gl(e){return((e==null?void 0:e.relatedSessionIds.size)??0)>1}function wi(e,t,s,n,r){const a=s.get(e);if(!a)throw new Error(`Session ${e} not found`);const o=new Set(r);o.add(e);const u=[...n.get(e)??[]].filter(d=>!o.has(d)).sort((d,h)=>{const f=s.get(d),p=s.get(h);return!f||!p?0:Vl(f,p)});return{session:a,depth:t,children:u.map(d=>wi(d,t+1,s,n,o))}}function Xl(e){const t=new Set;function s(n){t.add(n.session.sessionId),n.children.forEach(s)}return s(e),t}function Mi(e){const t=_r(e),s=e.lastMessageAt??e.updatedAt,n=s?new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(s)):null;return[Lt(e.provider),n,t].filter(Boolean).join(" · ")}function Si(e){return e.isArchived===!0}function zl(e){return[...e].sort((t,s)=>t.sequence-s.sequence).filter(t=>t.content.trim().length>0||t.kind==="tool_call"||t.kind==="tool_result")}function Ii(e,t){return e<=0||t<=0?1:Math.min(1,e/t)}function Yl(e,t,s,n){const r=Ii(e,s),a=s*r,o=n*r,u=a<e?(e-a)/2:0;return{scale:r,offsetX:u,offsetY:0,shellWidth:Math.max(e,a),shellHeight:o}}function en(e,t,s){return Math.min(s,Math.max(t,e))}function Kl(e,t,s,n){if(e<=0||t<=0||s<=0||n<=0)return 1;const r=Math.max(1,e-ur*2),a=Math.max(1,t-ur*2);return Math.min(1,r/s,a/n)}function hs(e,t,s,n,r){const a=n*e.scale,o=r*e.scale,u=(t-a)/2,d=(s-o)/2,h=a<=t?u:en(e.offsetX,t-a,0),f=o<=s?d:en(e.offsetY,s-o,0);return{scale:e.scale,offsetX:h,offsetY:f}}function Zt(e,t,s,n){const r=Kl(e,t,s,n);return hs({scale:r,offsetX:(e-s*r)/2,offsetY:(t-n*r)/2},e,t,s,n)}function Ql(e,t,s,n,r,a,o,u){const d=(s-e.offsetX)/e.scale,h=(n-e.offsetY)/e.scale;return hs({scale:t,offsetX:s-d*t,offsetY:n-h*t},r,a,o,u)}function Zl(e){var s;const t=e.content.trim();if(t.length>0){const n=t.replace(/\s+/g," ").trim();return n.length<=160?n:`${n.slice(0,157)}...`}return(s=e.toolCall)!=null&&s.name?`${e.toolCall.name} ${l("conversation.branchTreeToolMessageFallback")}`:l("conversation.branchTreeMessageEmpty")}function Jl(e){switch(e.role){case"assistant":return l("conversation.roleAssistant");case"system":return l("conversation.roleSystem");case"tool":return l("conversation.roleTool");case"user":default:return l("conversation.roleUser")}}function tn(e,t){const s=t.get(e.session.sessionId);if(s!==void 0)return s;if(e.children.length===0)return t.set(e.session.sessionId,Mt),Mt;const n=e.children.reduce((a,o,u)=>{const d=a+tn(o,t);return u===0?d:d+Js},0),r=Math.max(Mt,n);return t.set(e.session.sessionId,r),r}function ec(e){const t=new Map,s=[],n=new Map;function r(u,d,h){const f=tn(u,t),p=d+f/2,x=cr+h*(ut+vi),v=p-Mt/2,w=u.children.reduce((O,C,_)=>{const A=O+tn(C,t);return _===0?A:A+Js},0);let M=d+Math.max(0,(f-w)/2);const j=u.children.map(O=>{const C=r(O,M,h+1);return M+=C.subtreeWidth+Js,C}),y={node:u,children:j,x:v,y:x,centerX:p,centerY:x+ut/2,subtreeWidth:f};return s.push(y),n.set(u.session.sessionId,y),y}const a=r(e,lr,0),o=s.reduce((u,d)=>Math.max(u,d.y+ut),0);return{root:a,nodes:s,bySessionId:n,width:a.subtreeWidth+lr*2,height:o+cr}}function tc(e){return Math.max(0,Math.min(255,Number.parseFloat(e)))}function sc(e){const t=e.trim();if(t.startsWith("#")){const n=t.slice(1);if(n.length===3){const[r,a,o]=n.split("").map(u=>Number.parseInt(u.repeat(2),16));return{r,g:a,b:o}}if(n.length>=6)return{r:Number.parseInt(n.slice(0,2),16),g:Number.parseInt(n.slice(2,4),16),b:Number.parseInt(n.slice(4,6),16)}}const s=t.match(/rgba?\(([^)]+)\)/i);if(s){const[n,r,a]=s[1].split(",").map(o=>tc(o));return{r:n,g:r,b:a}}return null}function rt(e,t,s){const n=sc(e);return n?`rgba(${n.r}, ${n.g}, ${n.b}, ${t})`:s}function nc(e,t,s,n,r,a){const o=e.getContext("2d");if(!o)return;const u=o,d=window.devicePixelRatio||1;e.width=Math.max(1,Math.floor(t.width*d)),e.height=Math.max(1,Math.floor(t.height*d)),e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,u.setTransform(d,0,0,d,0,0),u.clearRect(0,0,t.width,t.height);const h=window.getComputedStyle(e),f=h.getPropertyValue("--accent").trim()||"#3b82f6",p=h.getPropertyValue("--border-primary").trim()||"#d4d8df",x=h.getPropertyValue("--bg-surface").trim()||"#ffffff";if(!a){const w=u.createLinearGradient(0,0,t.width,t.height);w.addColorStop(0,rt(x,.38,"rgba(255, 255, 255, 0.38)")),w.addColorStop(1,rt(f,.05,"rgba(59, 130, 246, 0.05)")),u.fillStyle=w,u.fillRect(0,0,t.width,t.height)}function v(w){for(const M of w.children){const j=n.has(w.node.session.sessionId)&&n.has(M.node.session.sessionId),y=w.node.session.sessionId===r||M.node.session.sessionId===r;u.beginPath(),u.moveTo(w.centerX,w.y+ut-10);const O=w.y+ut+vi*.52;u.bezierCurveTo(w.centerX,O,M.centerX,O,M.centerX,M.y+10),u.lineWidth=y?3:j?2.5:1.5,u.strokeStyle=y?rt(f,.52,"rgba(59, 130, 246, 0.52)"):j?rt(f,.32,"rgba(59, 130, 246, 0.32)"):rt(p,.72,"rgba(148, 163, 184, 0.72)"),u.stroke(),u.beginPath(),u.arc(M.centerX,M.y,y?4.5:3.5,0,Math.PI*2),u.fillStyle=y?rt(f,.9,"rgba(59, 130, 246, 0.9)"):rt(p,.78,"rgba(148, 163, 184, 0.78)"),u.fill(),v(M)}}v(t.root);for(const w of t.nodes){const M=w.node.session.sessionId===s,j=w.node.session.sessionId===r,y=n.has(w.node.session.sessionId);if(!M&&!j&&!y)continue;const O=u.createRadialGradient(w.centerX,w.centerY,10,w.centerX,w.centerY,j?90:64);O.addColorStop(0,rt(f,j?.22:.14,"rgba(59, 130, 246, 0.22)")),O.addColorStop(1,"rgba(59, 130, 246, 0)"),u.fillStyle=O,u.beginPath(),u.ellipse(w.centerX,w.centerY,Mt*.72,ut*.9,0,0,Math.PI*2),u.fill(),(j||M)&&(u.beginPath(),u.arc(w.centerX,w.y+12,j?6:5,0,Math.PI*2),u.fillStyle=rt(f,.94,"rgba(59, 130, 246, 0.94)"),u.fill())}}function rc(e,t,s){const n=Math.min(Fl,t-24),r=e.left+e.width/2-n/2,a=Math.max(12,Math.min(t-n-12,r)),d=s-e.bottom-12<220&&e.top>Qt?Math.max(12,e.top-Qt-12):Math.max(12,Math.min(s-Qt-12,e.bottom+12));return{width:n,left:a,top:d,maxHeight:Math.min(Qt,s-24)}}function ic({model:e,selectedSession:t,selectedTreeNode:s,previewEntry:n,onClose:r,onOpenSession:a}){const o=Pt(t.title,l("common.unknown")),u=t.sessionId===e.current.sessionId,d=Si(t),h=kr(s.session),f=Er(s.session),p=Ar(s.session),x=jr(s.session);return i.jsxs("div",{className:"conversation-branch-preview-popover",role:"dialog","aria-label":`${l("conversation.branchTreePreviewTitle")} ${o.fullTitle}`,children:[i.jsxs("div",{className:"conversation-branch-preview-popover-header",children:[i.jsxs("div",{className:"conversation-branch-preview-card-title-row",children:[i.jsx("strong",{title:o.fullTitle,children:o.displayTitle}),u?i.jsx("span",{className:"conversation-branch-current-badge",children:l("conversation.branchTreeCurrentBadge")}):null,d?i.jsx("span",{className:"conversation-branch-archived-badge",children:l("conversation.branchTreeArchivedBadge")}):null]}),i.jsx("button",{type:"button",className:"conversation-branch-preview-close","aria-label":l("common.close"),onClick:r,children:"x"})]}),i.jsx("p",{className:"conversation-branch-preview-popover-meta",children:Mi(t)}),f&&h||x&&p?i.jsxs("div",{className:"conversation-branch-badge-row",children:[x&&p?i.jsx("span",{className:`session-fork-badge ${p}`,children:x}):null,f&&h?i.jsx("span",{className:`session-fork-badge ${h}`,children:f}):null]}):null,i.jsx("div",{className:"conversation-branch-preview-messages",children:n.status==="loading"?i.jsx("p",{className:"conversation-branch-empty",children:l("conversation.branchTreePreviewLoading")}):n.status==="error"?i.jsx("p",{className:"conversation-branch-empty",children:n.error||l("conversation.branchTreePreviewFailed")}):n.messages.length>0?n.messages.map(v=>i.jsxs("article",{className:"conversation-branch-preview-message",children:[i.jsxs("div",{className:"conversation-branch-preview-message-meta",children:[i.jsx("span",{children:Jl(v)}),i.jsx("span",{children:new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"}).format(new Date(v.timestamp))})]}),i.jsx("p",{children:Zl(v)})]},`${t.sessionId}:${v.messageId}`)):i.jsx("p",{className:"conversation-branch-empty",children:l("conversation.branchTreePreviewEmpty")})}),i.jsx("div",{className:"conversation-branch-preview-actions",children:i.jsx("button",{type:"button",className:"secondary-button",disabled:u,onClick:()=>a(t),children:u?l("conversation.branchTreeCurrentAction"):l("conversation.branchTreeSwitchAction")})})]})}function oc({layout:e,model:t,selectedSessionId:s,onSelectSession:n,onBackgroundClick:r,stageScale:a,desktopStageLayout:o,transform:u,isMobileViewport:d,viewportRef:h,onRegisterNodeElement:f,onViewportTouchStart:p,onViewportTouchMove:x,onViewportTouchEnd:v}){const w=c.useRef(null);return c.useEffect(()=>{const M=w.current;M&&nc(M,e,t.current.sessionId,t.currentPathIds,s,d)},[d,e,t.current.sessionId,t.currentPathIds,s]),i.jsx("div",{ref:h,className:"conversation-branch-canvas-viewport","data-scaled":a<.999,"data-mobile":d,onClick:M=>{M.target===M.currentTarget&&(r==null||r())},onTouchStart:p,onTouchMove:x,onTouchEnd:v,onTouchCancel:v,children:i.jsx("div",{className:"conversation-branch-canvas-stage-shell",style:{width:d?"100%":o.shellWidth,height:d?"100%":o.shellHeight},onClick:M=>{M.target===M.currentTarget&&(r==null||r())},children:i.jsxs("div",{className:"conversation-branch-canvas-stage",style:{width:e.width,height:e.height,transform:u?`translate(${u.offsetX}px, ${u.offsetY}px) scale(${u.scale})`:`translate(${o.offsetX}px, ${o.offsetY}px) scale(${o.scale})`,transformOrigin:"top left"},onClick:()=>{if(r){r();return}n(null)},children:[i.jsx("canvas",{ref:w,className:"conversation-branch-canvas",width:e.width,height:e.height,"aria-hidden":"true"}),e.nodes.map(M=>{const j=Pt(M.node.session.title,l("common.unknown")),y=kr(M.node.session),O=Er(M.node.session),C=Ar(M.node.session),_=jr(M.node.session),A=M.node.session.sessionId===t.current.sessionId,P=M.node.session.sessionId===s,k=t.currentPathIds.has(M.node.session.sessionId),m=Si(M.node.session);return i.jsx("button",{ref:b=>f(M.node.session.sessionId,b),type:"button",className:"conversation-branch-smart-card conversation-branch-canvas-node","data-current":A,"data-selected":P,"data-current-path":k,"data-archived":m,style:{left:M.x,top:M.y,width:Mt,minHeight:ut},"aria-pressed":P,onClick:b=>{b.stopPropagation(),n(M.node.session.sessionId)},children:i.jsxs("div",{className:"conversation-branch-smart-card-main",children:[i.jsxs("div",{className:"conversation-branch-smart-card-title-row",children:[i.jsx("strong",{title:j.fullTitle,children:j.displayTitle}),A?i.jsx("span",{className:"conversation-branch-current-badge",children:l("conversation.branchTreeCurrentBadge")}):null,m?i.jsx("span",{className:"conversation-branch-archived-badge",children:l("conversation.branchTreeArchivedBadge")}):null]}),i.jsx("p",{children:Mi(M.node.session)}),O&&y||_&&C?i.jsxs("div",{className:"conversation-branch-badge-row",children:[_&&C?i.jsx("span",{className:`session-fork-badge ${C}`,children:_}):null,O&&y?i.jsx("span",{className:`session-fork-badge ${y}`,children:O}):null]}):null]})},M.node.session.sessionId)})]})})})}function dr({model:e,onOpenSession:t,onClose:s}){const n=c.useMemo(()=>ec(e.root),[e.root]),r=c.useRef(null),a=c.useRef(new Map),[o,u]=c.useState(null),[d,h]=c.useState(0),[f,p]=c.useState(0),[x,v]=c.useState(null),[w,M]=c.useState({}),j=c.useRef(new Set),[y,O]=c.useState(typeof window<"u"?window.innerWidth<=ds:!1),[C,_]=c.useState(null),A=c.useRef({mode:"idle",startDistance:0,startScale:1,startOffsetX:0,startOffsetY:0,startTouchX:0,startTouchY:0,anchorX:0,anchorY:0,moved:!1});c.useEffect(()=>{const B=r.current;if(!B)return;const S=B;function U(){h(S.clientWidth),p(S.clientHeight),O(window.innerWidth<=ds)}if(U(),typeof ResizeObserver>"u")return window.addEventListener("resize",U),()=>window.removeEventListener("resize",U);const H=new ResizeObserver(U);return H.observe(B),()=>H.disconnect()},[]),c.useEffect(()=>{u(null)},[e.current.sessionId,e.root.session.sessionId]);const P=c.useMemo(()=>Ii(d,n.width),[d,n.width]),k=c.useMemo(()=>Yl(d,f,n.width,n.height),[f,d,n.height,n.width]);c.useEffect(()=>{if(!y||d<=0||f<=0){_(null);return}_(B=>B?hs(B,d,f,n.width,n.height):Zt(d,f,n.width,n.height))},[f,d,y,n.height,n.width]);const m=o?e.sessionsById.get(o)??null:null,b=m?n.bySessionId.get(m.sessionId)??null:null,L=m?w[m.sessionId]??{status:"idle",messages:[],error:null}:null,G=y&&!!s,X=!!s&&!G;c.useEffect(()=>{if(!o){v(null);return}const B=o;function S(){const U=a.current.get(B);if(!U){v(null);return}v(U.getBoundingClientRect())}return S(),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[o,P]),c.useEffect(()=>{if(!y)return;const B=o;if(!B)return;const S=window.requestAnimationFrame(()=>{const U=a.current.get(B);U&&v(U.getBoundingClientRect())});return()=>window.cancelAnimationFrame(S)},[y,C,o]),c.useEffect(()=>{if(!(m!=null&&m.sessionId)||(L==null?void 0:L.status)==="ready"||j.current.has(m.sessionId))return;let B=!1;return j.current.add(m.sessionId),M(S=>{var U;return{...S,[m.sessionId]:{status:"loading",messages:((U=S[m.sessionId])==null?void 0:U.messages)??[],error:null}}}),Fs(m.sessionId,null,6,"backward").then(S=>{j.current.delete(m.sessionId),!B&&M(U=>({...U,[m.sessionId]:{status:"ready",messages:zl(S.messages),error:null}}))}).catch(S=>{j.current.delete(m.sessionId),!B&&M(U=>{var H;return{...U,[m.sessionId]:{status:"error",messages:((H=U[m.sessionId])==null?void 0:H.messages)??[],error:S instanceof Error?S.message:l("conversation.branchTreePreviewFailed")}}})}),()=>{B=!0}},[m==null?void 0:m.sessionId]);function Z(B){!y||d<=0||f<=0||_(S=>{const U=S??Zt(d,f,n.width,n.height);return hs(B(U),d,f,n.width,n.height)})}function te(B){if(!y)return;const S=B.currentTarget.getBoundingClientRect();if(B.touches.length>=2){const K=B.touches[0],oe=B.touches[1],ue=Math.hypot(oe.clientX-K.clientX,oe.clientY-K.clientY),de=(K.clientX+oe.clientX)/2-S.left,ve=(K.clientY+oe.clientY)/2-S.top,E=C??Zt(d,f,n.width,n.height);A.current={mode:"pinch",startDistance:ue,startScale:E.scale,startOffsetX:E.offsetX,startOffsetY:E.offsetY,startTouchX:de,startTouchY:ve,anchorX:de,anchorY:ve,moved:!1};return}const U=B.touches[0],H=C??Zt(d,f,n.width,n.height);A.current={mode:"pan",startDistance:0,startScale:H.scale,startOffsetX:H.offsetX,startOffsetY:H.offsetY,startTouchX:U.clientX,startTouchY:U.clientY,anchorX:0,anchorY:0,moved:!1}}function D(B){if(!y)return;const S=A.current;if(B.touches.length>=2){const ue=B.currentTarget.getBoundingClientRect(),de=B.touches[0],ve=B.touches[1],E=Math.hypot(ve.clientX-de.clientX,ve.clientY-de.clientY);if(E<=0||S.startDistance<=0)return;B.preventDefault();const V=(de.clientX+ve.clientX)/2-ue.left,z=(de.clientY+ve.clientY)/2-ue.top,$=en(S.startScale*(E/S.startDistance),Wl,Ul);A.current={...S,mode:"pinch",moved:!0,anchorX:V,anchorY:z},Z(ae=>Ql({...ae,scale:S.startScale,offsetX:S.startOffsetX,offsetY:S.startOffsetY},$,V,z,d,f,n.width,n.height));return}if(S.mode!=="pan"||B.touches.length!==1)return;const U=B.touches[0],H=U.clientX-S.startTouchX,K=U.clientY-S.startTouchY;(S.moved||Math.hypot(H,K)>=$l)&&(B.preventDefault(),A.current={...S,moved:!0},Z(ue=>({...ue,offsetX:S.startOffsetX+H,offsetY:S.startOffsetY+K})))}function ge(){A.current={mode:"idle",startDistance:0,startScale:(C==null?void 0:C.scale)??1,startOffsetX:(C==null?void 0:C.offsetX)??0,startOffsetY:(C==null?void 0:C.offsetY)??0,startTouchX:0,startTouchY:0,anchorX:0,anchorY:0,moved:!1}}return i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:`conversation-branch-tree-pane${s?" conversation-branch-dialog":""}${G?" conversation-branch-dialog-mobile-bare":""}`,role:s?"dialog":void 0,"aria-modal":s?"true":void 0,"aria-label":s?l("conversation.branchTreeTitle"):void 0,children:[X?i.jsx("div",{className:"conversation-branch-tree-pane-header",children:i.jsxs("div",{className:"conversation-branch-tree-pane-topbar",children:[i.jsxs("div",{className:"conversation-branch-tree-pane-heading",children:[i.jsx("h3",{children:l("conversation.branchTreeMapTitle")}),i.jsx("p",{children:l("conversation.branchTreeMapDescription")})]}),s?i.jsx("button",{type:"button",className:"conversation-branch-pane-close","aria-label":l("common.close"),onClick:s,children:"x"}):null]})}):null,i.jsxs("div",{className:"conversation-branch-canvas-shell",children:[G?i.jsx("button",{type:"button",className:"conversation-branch-pane-close conversation-branch-mobile-floating-close","aria-label":l("common.close"),onClick:s,children:"x"}):null,G?null:i.jsx("div",{className:"conversation-branch-canvas-tip",children:l("conversation.branchTreePreviewDescription")}),i.jsx(oc,{layout:n,model:e,selectedSessionId:o,onSelectSession:u,onBackgroundClick:G?s:void 0,stageScale:P,desktopStageLayout:k,transform:y?C:null,isMobileViewport:y,viewportRef:r,onRegisterNodeElement:(B,S)=>{if(S){a.current.set(B,S);return}a.current.delete(B)},onViewportTouchStart:te,onViewportTouchMove:D,onViewportTouchEnd:ge})]})]}),m&&b&&L&&x&&typeof document<"u"?It.createPortal(i.jsx("div",{className:"conversation-branch-preview-floating",style:rc(x,window.innerWidth,window.innerHeight),children:i.jsx(ic,{model:e,selectedSession:m,selectedTreeNode:b.node,previewEntry:L,onClose:()=>u(null),onOpenSession:t})}),document.body):null]})}function ac({open:e,navigationGroups:t,workspaceId:s,sessionId:n,onClose:r,onOpenSession:a}){const o=c.useMemo(()=>bi(t,s,n),[t,n,s]),[u,d]=c.useState(typeof window<"u"?window.innerWidth>ds:!0);return c.useEffect(()=>{if(typeof window>"u")return;function h(){d(window.innerWidth>ds)}return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),!e||!o||typeof document>"u"?null:u?i.jsx(fs,{open:e,title:l("conversation.branchTreeMapTitle"),description:l("conversation.branchTreeMapDescription"),size:"regular",layout:"viewer",bodyClassName:"conversation-branch-modal-body",onClose:r,children:i.jsx(dr,{model:o,onOpenSession:a})}):It.createPortal(i.jsxs("div",{className:"workbench-modal-layer conversation-branch-panel-layer",children:[i.jsx("button",{type:"button",className:"workbench-modal-backdrop","aria-label":l("common.close"),onClick:r}),i.jsx(dr,{model:o,onOpenSession:a,onClose:r})]}),document.body)}function lc(e){const t=e.trim().length;return t<=16?"xl":t<=26?"lg":t<=38?"md":"sm"}function yi({session:e,actions:t,workspaceContext:s=null}){const n=Rt(),r=Tr(n);if(!e)return i.jsxs("header",{className:"conversation-header conversation-header-skeleton","aria-hidden":"true","data-window-drag-handle":"conversation-header","data-tauri-drag-region":r,children:[i.jsxs("div",{className:"conversation-header-main","data-tauri-drag-region":r,children:[i.jsx("span",{className:"skeleton-line short"}),i.jsx("span",{className:"skeleton-line long"})]}),t?i.jsx("div",{className:"conversation-header-actions",children:t}):null]});const a=Pt(e.title,l("conversation.titleFallback")),o=lc(a.displayTitle);return i.jsxs("header",{className:"conversation-header","data-workspace-tone":(s==null?void 0:s.tone)??"root",style:bt(s),"data-window-drag-handle":"conversation-header","data-tauri-drag-region":r,children:[i.jsx("div",{className:"conversation-header-main","data-tauri-drag-region":r,children:i.jsx("h1",{className:`conversation-title is-${o}`,title:a.fullTitle,"data-tauri-drag-region":r,children:a.displayTitle})}),t?i.jsx("div",{className:"conversation-header-actions",children:t}):null]})}function cc(e,t,s){if(!t)return null;const n=e.find(o=>o.workspace.id===t);if(!n)return null;const r=ms([n]).filter(o=>!o.session.isArchived&&!Bt(o.session)),a=r.findIndex(o=>o.session.sessionId===s);return a<0?null:r[a+1]??null}const hr=.6,Bs=.6,fr=8,uc=36,dc=48,hc=96;function tu(){const{sessionId:e="",workspaceId:t}=Zo(),s=cn(),n=dt(),r=c.useMemo(()=>new URLSearchParams(s.search),[s.search]),a=wc(r.get("toolPanel")),o=(t==null?void 0:t.trim())||null,u=c.useMemo(()=>vc(e,o,r),[o,r,e]),d=c.useMemo(()=>Ac(e,s.state),[s.state,e]),h=c.useMemo(()=>jc(e,s.state),[s.state,e]);return u?i.jsx(gc,{draft:u,navigate:n,initialToolPanel:a}):i.jsx(fc,{sessionId:e,bootstrapMessages:d,initialComposerModel:h.initialModel,initialComposerProviderConfigMode:h.providerConfigMode,initialComposerProviderPresetId:h.providerPresetId,initialToolPanel:a})}function fc({sessionId:e,bootstrapMessages:t,initialComposerModel:s,initialComposerProviderConfigMode:n,initialComposerProviderPresetId:r,initialToolPanel:a}){var ie,Ye,Ge,Ke;const{shellMode:o,navigationGroups:u,requestNavigationRefresh:d,selectWorkspace:h,setSessionWorkspace:f,markNavigationSessionSeen:p,favoriteSessions:x,archiveSession:v,unarchiveSession:w,startDraftSession:M,upsertNavigationSession:j}=xt(),y=dt(),[O,C]=c.useState(!1),[_,A]=c.useState(!1),[P,k]=c.useState(null),[m,b]=c.useState(!1),[L,G]=c.useState(!1),[X,Z]=c.useState(!1),te=c.useMemo(()=>ms(u),[u]),D=c.useMemo(()=>{var I;return((I=te.find(ee=>ee.session.sessionId===e))==null?void 0:I.session)??null},[te,e]),{showToast:ge}=at(),B=()=>{var Se;const I=(D==null?void 0:D.workspaceId)??((Se=u[0])==null?void 0:Se.workspace.id)??null,ee=(I?te.find(zt=>zt.workspace.id===I)??null:null)??te[0]??null;y(ee?Xe(ee.workspace.id,ee.session.sessionId):I?_t(I):o==="mobile"?Yo():"/landing",{replace:!0})},{session:S,capabilities:U,messages:H,timelineItems:K,permissionRequests:oe,queuedMessages:ue,contextUsage:de,historyState:ve,runtimeInterruptSource:E,loadingOlderMessages:V,hasOlderMessages:z,connectionState:$,sending:ae,replyingPermissionRequestId:F,deletingQueueItemId:re,steeringQueueItemId:Te,forkDraft:Ne,setForkDraft:q,composerHasActiveRun:W,composerCanInterrupt:he,composerIsRunning:Ce,canSteerQueuedMessage:me,hasPendingQueuedMessages:Ee,reconnect:Be,loadOlderMessages:J,retryMessage:se,send:we,queue:Fe,interrupt:R,replyPermissionRequest:N,deleteQueuedMessage:Ie,steerQueuedMessage:Pe}=hi({sessionId:e,externalSession:D,bootstrapMessages:t,onSeen:(I,ee)=>{p(I,ee)},onRequestNavigationRefresh:d,onUpsertNavigationSession:j,onNavigateToSession:(I,ee)=>{h(I),y(Xe(I,ee))},onBindSessionWorkspace:f,onResolveMissingSession:B,onForkSuccess:()=>{Nt("preview"),ge({title:l("conversation.forkMessageSucceeded"),tone:"success"})},enableRuntimeErrorHandling:!0,enableCompletionHaptics:!0,enableThinkingPlaceholder:!0,enableForkTimelineSanitizer:!0}),ne=o!=="mobile",fe=Ni(!ne),le=S??D??null,Oe=(S==null?void 0:S.sessionIsolatedWorkspace)??(D==null?void 0:D.sessionIsolatedWorkspace)??null,Me=le?es(le,Oe):null,De=le?Cr(le,Oe):null,Re=ji({enabled:!ne,initialPanel:a,workspaceId:De,suspendMainGesture:!ne&&fe.isVisible}),et=c.useMemo(()=>new Set(x.map(I=>I.session.sessionId)),[x]),it=c.useMemo(()=>u.map(I=>I.workspace),[u]),ht=c.useMemo(()=>Br(u),[u]),ft=c.useMemo(()=>on(u),[u]),Ze=c.useMemo(()=>Ri(u,Me,et),[et,Me,u]),tt=c.useMemo(()=>Ti(x,u),[x,u]);async function pt(I){await we(pc(I.answers))}const[Ae,st]=c.useState([]),ot=c.useMemo(()=>[...tt,...Ze],[tt,Ze]),Ve=c.useMemo(()=>Me?it.find(I=>I.id===Me)??null:null,[Me,it]),ke=(Me?ft[Me]??null:null)??(Ve?an(Ve):null),ce=c.useMemo(()=>bs(u,Me),[Me,u]),g=ht.find(I=>I.workspace.id===Me)??(ce?{workspace:ce.workspace,label:ce.workspace.name,subtitle:ce.workspace.path}:null),Y=c.useMemo(()=>cc(u,Me,e),[Me,u,e]),Q=(S==null?void 0:S.provider)??(D==null?void 0:D.provider)??null,ye=c.useMemo(()=>{var I;return Pt(((I=S??D)==null?void 0:I.title)??null,l("conversation.titleFallback"))},[D,S]),qe=ne,We=c.useMemo(()=>{var Se;if(!qe)return null;if(Vo(le))return((Se=le==null?void 0:le.parallelGroup)==null?void 0:Se.groupId)??null;const I=gs(te);return mc(I,e)},[le,te,e,qe]),je=ne?null:Ai(fe.mainGestureHandlers,Re.mainGestureHandlers);c.useEffect(()=>{const I=Or(ot,e,ee=>ee.session.sessionId);I.length!==0&&st(ee=>{const Se=new Set(ee);let zt=!1;for(const wn of I)Se.has(wn)||(Se.add(wn),zt=!0);return zt?Array.from(Se):ee})},[ot,e]);const Le=(le==null?void 0:le.workspaceId)??(D==null?void 0:D.workspaceId)??null,_e=c.useMemo(()=>bi(u,Le,e),[Le,u,e]),lt=Gl(_e),Wt=!!(le&&Le&&lt),Ut=()=>{G(!0)},Tt=c.useMemo(()=>(ce==null?void 0:ce.sessions.filter(I=>I.isArchived===!0&&!Bt(I)))??[],[ce]),$t=c.useRef(null),Ct=c.useRef(null),mt=c.useRef(null),kt=c.useRef(null),[Vt,Gt]=c.useState(null),{composerPortalTarget:Xt}=Nr();c.useEffect(()=>{G(!1)},[e]),ki(mt,Vt,!ne,e),Ei(mt,kt,!ne,e);function T(I){h(I),y(_t(I))}return ne&&We?i.jsxs(i.Fragment,{children:[i.jsx(kl,{groupId:We,currentSessionId:e}),i.jsx(Ws,{open:X,source:le?{kind:"session",sessionId:e,workspaceId:le.workspaceId,workspaceName:(ke==null?void 0:ke.displayName)??le.workspaceId,sessionTitle:le.title,defaultProvider:le.provider}:null,onClose:()=>Z(!1),onCreated:async I=>{I.members.forEach(Se=>{j(Se.session)}),kn(I.group.id),await d();const ee=I.members.find(Se=>Se.session.sessionId===I.group.anchorSessionId)??I.members[0]??null;if(ee){const Se=es(ee.session,ee.sessionIsolatedWorkspace);h(Se),y(Xe(Se,ee.session.sessionId))}Z(!1),ge({title:l("shell.parallelCreateSucceeded"),tone:"success"})}})]}):i.jsxs(i.Fragment,{children:[i.jsxs("main",{ref:mt,className:"workbench-page conversation-page-shell mobile-page-fixed-root mobile-conversation-page","data-mobile-shell":!ne,"data-preview-mode":ne?void 0:fe.displayMode,"data-preview-dragging":ne?void 0:fe.isDragging,"data-workspace-tone":(ke==null?void 0:ke.tone)??"root","data-worktree-depth":(ke==null?void 0:ke.depth)??0,"data-tool-panel-open":ne?void 0:Re.isOpen,style:{...ne?{}:fe.pageStyle,...bt(ke)??{}},children:[ne?i.jsx(yi,{session:S??D,workspaceContext:ke,actions:i.jsxs(i.Fragment,{children:[Wt?i.jsx(Tc,{onOpenBranchTree:Ut}):null,le?i.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":l("shell.parallelCreateAction"),title:l("shell.parallelCreateAction"),onClick:()=>Z(!0),children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(Cc,{})})}):null,i.jsx(Vr,{session:S??D})]})}):null,ne?null:i.jsx(Fr,{containerRef:kt,className:"mobile-conversation-page-header",gestureHandlers:je??void 0,currentWorkspace:g?{id:g.workspace.id,name:g.label,path:g.subtitle}:it[0]??null,workspaces:it,workspaceOptions:ht,onSelectWorkspace:T,heading:ye.fullTitle,trailing:i.jsxs("div",{className:"mobile-conversation-toolbar-main",children:[i.jsx("span",{className:"mobile-conversation-toolbar-title",title:ye.fullTitle,children:ye.displayTitle}),i.jsx(da,{session:S??D,onOpenBranchTree:Wt?Ut:void 0})]})}),ne?null:i.jsx(Oi,{visible:!Re.isOpen&&fe.isVisible,widthPx:fe.previewWidthPx,isDragging:fe.isDragging,gestureHandlers:fe.railGestureHandlers,activeSessionId:e,createSessionActionLabel:Me&&Q?l("shell.createSession"):void 0,favoriteItems:tt,items:Ze,expandedRootIds:Ae,workspaceSectionLabel:(g==null?void 0:g.label)??l("shell.mobileConversationCurrentWorkspaceSection"),onCreateSession:Me&&Q?()=>{M(Me,Q)}:void 0,archiveCurrentActionLabel:l("shell.archiveCurrentSessionAction"),archiveFolderActionLabel:Tt.length>0?l("shell.archiveFolderLabel"):void 0,onArchiveActiveSession:()=>{C(!0)},onOpenArchiveFolder:Tt.length>0?()=>{A(!0)}:void 0,onToggleSubsessions:I=>{st(ee=>ee.includes(I)?ee.filter(Se=>Se!==I):[...ee,I])},onActivate:I=>{fe.closePreview(),h(I.workspace.id),y(Xe(I.workspace.id,I.session.sessionId))}}),i.jsx("div",{className:"mobile-conversation-stage",...je??{},children:i.jsxs("div",{ref:$t,className:"mobile-conversation-main",children:[i.jsx(dn,{connectionState:$,onReconnect:Be}),i.jsx(Lr,{requests:oe,replyingRequestId:F,onReply:N}),i.jsx("div",{ref:Ct,className:"conversation-timeline-shell",children:i.jsx(ln,{sessionId:e,sessionSummary:S??D??null,workspaceId:De,workspacePath:(Ve==null?void 0:Ve.path)??null,items:K,historyState:ve,loadingOlderMessages:V,hasOlderMessages:z,provider:(S==null?void 0:S.provider)??null,interruptedSource:E,onLoadOlderMessages:J,onRetryMessage:se,onSubmitStructuredQuestion:pt,onForkMessage:I=>{S&&(q({sourceMessageId:I.id,sourceMessageSnapshot:{role:I.role,kind:I.kind??(I.role==="tool"?"tool_result":"text"),content:I.content},content:I.content,sourceProvider:S.provider,workspaceId:S.workspaceId,targetProvider:S.provider,targetModel:null,targetProviderConfigMode:S.providerConfigMode??"global-default",targetProviderPresetId:S.providerPresetId??null}),di())}})}),i.jsx(aa,{containerRef:Ct,session:S??D??null,currentCapabilities:U}),i.jsx(Gr,{items:ue,deletingQueueItemId:re,steeringQueueItemId:Te,canSteer:me,onDelete:Ie,onSteer:Pe}),Re.isOpen?null:i.jsx(un,{capabilities:U,draftStorageId:e,initialModel:s,workspaceId:((ie=S??D)==null?void 0:ie.workspaceId)??null,initialProviderConfigMode:n??((Ye=S??D)==null?void 0:Ye.providerConfigMode)??"global-default",initialProviderPresetId:r??((Ge=S??D)==null?void 0:Ge.providerPresetId)??null,forkDraft:Ne,onClearForkDraft:()=>q(null),onForkDraftChange:I=>q(I),panelRef:ne?void 0:Gt,portalContainer:ne?null:Xt,hasActiveRun:W,contextUsage:de,taskProvider:((Ke=S??D)==null?void 0:Ke.provider)??null,taskMessages:H,hasPendingQueuedMessages:Ee,canInterrupt:he,isSubmitting:ae,isRunning:Ce,onInterrupt:R,onSend:we,onQueueSend:Fe})]})}),!ne&&De?i.jsx(_i,{activePanel:Re.activePanel,open:Re.isOpen,sessionId:e,workspaceId:De,navigationGroups:u,onClose:()=>{Re.closePanel()},onSelectPanel:I=>{Re.selectPanel(I)},onSelectPanelBySwipe:I=>{if(I===null){Re.closePanel();return}Re.selectPanel(I)}}):null]}),i.jsx(ac,{open:L,navigationGroups:u,workspaceId:Le,sessionId:e,onClose:()=>G(!1),onOpenSession:I=>{G(!1),h(I.workspaceId),Nt("preview"),y(Xe(I.workspaceId,I.sessionId))}}),i.jsx(Rc,{open:O,busy:m,onClose:()=>{m||C(!1)},onConfirm:async()=>{if(!m){b(!0);try{if(await v(e),C(!1),ge({title:l("shell.archiveAdded"),tone:"success"}),Me){if(h(Me),Nt("preview"),Y){y(Xe(Y.workspace.id,Y.session.sessionId));return}y(_t(Me));return}y("/workspaces")}catch(I){ge({title:I instanceof Error?I.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{b(!1)}}}}),i.jsx(Di,{open:_,workspaceName:(ce==null?void 0:ce.workspace.name)??null,sessions:Tt,restoringSessionId:P,onClose:()=>{P||A(!1)},onRestore:async I=>{k(I);try{await w(I),ge({title:l("shell.archiveRestored"),tone:"success"})}catch(ee){ge({title:ee instanceof Error?ee.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{k(null)}}}),qe?i.jsx(Ws,{open:X,source:le?{kind:"session",sessionId:e,workspaceId:le.workspaceId,workspaceName:(ke==null?void 0:ke.displayName)??le.workspaceId,sessionTitle:le.title,defaultProvider:le.provider}:null,onClose:()=>Z(!1),onCreated:async I=>{I.members.forEach(Se=>{j(Se.session)}),kn(I.group.id),await d();const ee=I.members.find(Se=>Se.session.sessionId===I.group.anchorSessionId)??I.members[0]??null;if(ee){const Se=es(ee.session,ee.sessionIsolatedWorkspace);h(Se),y(Xe(Se,ee.session.sessionId))}Z(!1),ge({title:l("shell.parallelCreateSucceeded"),tone:"success"})}}):null]})}function pc(e){return Object.entries(e).map(([,t])=>t.filter(Boolean).join(" / ")).filter(Boolean).join(`
9
+ `)}function mc(e,t){const s=t.trim();if(!s)return null;for(const n of e){const r=xi(n,s,null);if(r)return r}return null}function xi(e,t,s){var r,a;const n=((a=(r=e.item.session.parallelGroup)==null?void 0:r.groupId)==null?void 0:a.trim())||s;if(e.item.session.sessionId===t)return n;for(const o of vs(e)){const u=xi(o,t,n);if(u)return u}return null}function gc({draft:e,navigate:t,initialToolPanel:s}){const{shellMode:n,navigationGroups:r,requestNavigationRefresh:a,selectWorkspace:o,setSessionWorkspace:u,upsertNavigationSession:d,favoriteSessions:h,unarchiveSession:f,startDraftSession:p}=xt(),[x,v]=c.useState(!1),[w,M]=c.useState([]),j=c.useMemo(()=>At(e.provider),[e.provider]),[y,O]=c.useState(j),C=n!=="mobile",{showToast:_}=at(),A=c.useMemo(()=>bc(e),[e]),P=Ni(!C),k=ji({enabled:!C,initialPanel:s,sessionId:e.sessionId,workspaceId:e.workspaceId,suspendMainGesture:!C&&P.isVisible}),m=c.useMemo(()=>new Set(h.map(q=>q.session.sessionId)),[h]),b=c.useMemo(()=>r.map(q=>q.workspace),[r]),L=c.useMemo(()=>Br(r),[r]),G=c.useMemo(()=>on(r),[r]),X=c.useMemo(()=>b.find(q=>q.id===e.workspaceId)??null,[e.workspaceId,b]),Z=G[e.workspaceId]??(X?an(X):null),te=c.useMemo(()=>Pt(A.title??null,l("conversation.titleFallback")),[A]),D=c.useMemo(()=>Ri(r,e.workspaceId,m),[e.workspaceId,m,r]),ge=c.useMemo(()=>Ti(h,r),[h,r]),[B,S]=c.useState([]),U=c.useMemo(()=>[...ge,...D],[ge,D]),H=c.useMemo(()=>bs(r,e.workspaceId),[e.workspaceId,r]),K=c.useMemo(()=>(H==null?void 0:H.sessions.filter(q=>q.isArchived===!0&&!Bt(q)))??[],[H]),oe=L.find(q=>q.workspace.id===e.workspaceId)??(H?{workspace:H.workspace,label:H.workspace.name,subtitle:H.workspace.path}:null),ue=C?null:Ai(P.mainGestureHandlers,k.mainGestureHandlers),[de,ve]=c.useState(!1),[E,V]=c.useState(null),z=c.useRef(null),$=c.useRef(null),ae=c.useRef(null),[F,re]=c.useState(null),{composerPortalTarget:Te}=Nr();c.useEffect(()=>{const q=Or(U,e.sessionId,W=>W.session.sessionId);q.length!==0&&S(W=>{const he=new Set(W);let Ce=!1;for(const me of q)he.has(me)||(he.add(me),Ce=!0);return Ce?Array.from(he):W})},[e.sessionId,U]),c.useEffect(()=>(u(e.sessionId,e.workspaceId),()=>{u(e.sessionId,null)}),[e.sessionId,e.workspaceId,u]),c.useEffect(()=>{let q=!1;return O(j),gr(e.provider,e.workspaceId).then(W=>{q||O(W)}).catch(()=>{}),()=>{q=!0}},[e.provider,e.workspaceId,j]),ki($,F,!C,e.sessionId),Ei($,ae,!C,e.sessionId);function Ne(q){o(q),t(_t(q))}return i.jsx(i.Fragment,{children:i.jsxs("main",{ref:$,className:"workbench-page conversation-page-shell mobile-page-fixed-root mobile-conversation-page","data-mobile-shell":!C,"data-preview-mode":C?void 0:P.displayMode,"data-preview-dragging":C?void 0:P.isDragging,"data-workspace-tone":(Z==null?void 0:Z.tone)??"root","data-worktree-depth":(Z==null?void 0:Z.depth)??0,"data-tool-panel-open":C?void 0:k.isOpen,style:{...C?{}:P.pageStyle,...bt(Z)??{}},children:[C?i.jsx(yi,{session:A,workspaceContext:Z}):null,C?null:i.jsx(Fr,{containerRef:ae,className:"mobile-conversation-page-header",gestureHandlers:ue??void 0,currentWorkspace:oe?{id:oe.workspace.id,name:oe.label,path:oe.subtitle}:b[0]??null,workspaces:b,workspaceOptions:L,onSelectWorkspace:Ne,heading:te.fullTitle,trailing:i.jsx("span",{className:"mobile-conversation-toolbar-title",title:te.fullTitle,children:te.displayTitle})}),C?null:i.jsx(Oi,{visible:!k.isOpen&&P.isVisible,widthPx:P.previewWidthPx,isDragging:P.isDragging,gestureHandlers:P.railGestureHandlers,activeSessionId:e.sessionId,createSessionActionLabel:l("shell.createSession"),favoriteItems:ge,items:D,expandedRootIds:B,workspaceSectionLabel:(oe==null?void 0:oe.label)??l("shell.mobileConversationCurrentWorkspaceSection"),onCreateSession:()=>{p(e.workspaceId,e.provider)},archiveFolderActionLabel:K.length>0?l("shell.archiveFolderLabel"):void 0,onOpenArchiveFolder:K.length>0?()=>{ve(!0)}:void 0,onToggleSubsessions:q=>{S(W=>W.includes(q)?W.filter(he=>he!==q):[...W,q])},onActivate:q=>{P.closePreview(),o(q.workspace.id),t(Xe(q.workspace.id,q.session.sessionId))}}),i.jsx("div",{className:"mobile-conversation-stage",...ue??{},children:i.jsxs("div",{ref:z,className:"mobile-conversation-main",children:[i.jsx(dn,{connectionState:"closed",onReconnect:()=>{}}),i.jsx("div",{className:"conversation-timeline-shell",children:i.jsx(ln,{sessionId:e.sessionId,sessionSummary:null,workspaceId:e.workspaceId,workspacePath:(X==null?void 0:X.path)??null,items:Rr({messages:w}),historyState:"ready",loadingOlderMessages:!1,hasOlderMessages:!1,provider:e.provider,onLoadOlderMessages:()=>{},onRetryMessage:()=>{}})}),k.isOpen?null:i.jsx(un,{capabilities:y,draftStorageId:e.sessionId,workspaceId:e.workspaceId,panelRef:C?void 0:re,portalContainer:C?null:Te,contextUsage:null,taskProvider:e.provider,taskMessages:w,isSubmitting:x,isRunning:!1,onSend:async(q,W)=>{var me,Ee,Be,J;const he=Nc();M(se=>[...se,Ir(e.sessionId,q,he,(W==null?void 0:W.attachmentMeta)??[],(W==null?void 0:W.attachments)??[])]),v(!0);const Ce=performance.now();be("session_send.start_live.client_start",{draftSessionId:e.sessionId,workspaceId:e.workspaceId,provider:e.provider,clientRequestId:he,contentLength:q.length});try{const se=await br({workspaceId:e.workspaceId,provider:e.provider,content:q,clientRequestId:he,model:(W==null?void 0:W.model)??null,reasoningLevel:(W==null?void 0:W.reasoningLevel)??null,permissionMode:ct(),attachments:(W==null?void 0:W.attachments)??[],providerConfigMode:(W==null?void 0:W.providerConfigMode)??"global-default",providerPresetId:(W==null?void 0:W.providerPresetId)??null});be("session_send.start_live.client_response",{draftSessionId:e.sessionId,sessionId:se.sessionId,workspaceId:((me=se.session)==null?void 0:me.workspaceId)??e.workspaceId,provider:se.provider,clientRequestId:he,durationMs:Math.round(performance.now()-Ce),returnedMessageId:((Ee=se.message)==null?void 0:Ee.messageId)??null}),se.session&&d(se.session);const we=((J=(Be=se.session)==null?void 0:Be.workspaceId)==null?void 0:J.trim())||e.workspaceId;u(se.sessionId,we),Nt("preview"),t(Xe(we,se.sessionId),{replace:!0,state:{composer:{sessionId:se.sessionId,initialModel:(W==null?void 0:W.model)??null,providerConfigMode:(W==null?void 0:W.providerConfigMode)??"global-default",providerPresetId:(W==null?void 0:W.providerPresetId)??null},bootstrap:{sessionId:se.sessionId,messages:[Ec({created:se,provider:e.provider,content:q,clientRequestId:he,attachments:(W==null?void 0:W.attachmentMeta)??[]})]}}}),a()}catch(se){throw be("session_send.start_live.client_error",{draftSessionId:e.sessionId,workspaceId:e.workspaceId,provider:e.provider,clientRequestId:he,durationMs:Math.round(performance.now()-Ce),error:se instanceof Error?se.message:String(se)}),M(we=>xr(we,he)),se}finally{v(!1)}}})]})}),C?null:i.jsx(_i,{activePanel:k.activePanel,open:k.isOpen,sessionId:e.sessionId,workspaceId:e.workspaceId,navigationGroups:r,onClose:()=>{k.closePanel()},onSelectPanel:q=>{k.selectPanel(q)},onSelectPanelBySwipe:q=>{if(q===null){k.closePanel();return}k.selectPanel(q)}}),i.jsx(Di,{open:de,workspaceName:(H==null?void 0:H.workspace.name)??null,sessions:K,restoringSessionId:E,onClose:()=>{E||ve(!1)},onRestore:async q=>{V(q);try{await f(q),_({title:l("shell.archiveRestored"),tone:"success"})}catch(W){_({title:W instanceof Error?W.message:l("shell.navigationLoadFailed"),tone:"error"})}finally{V(null)}}})]})})}function vc(e,t,s,n=null){var o,u;if(!kc(e))return null;const r=t??((o=s.get("workspaceId"))==null?void 0:o.trim())??null,a=((u=s.get("provider"))==null?void 0:u.trim())??n??null;return!r||!Mr(a)?null:{sessionId:e,workspaceId:r,provider:a}}function bc(e){const t=new Date().toISOString();return{sessionId:e.sessionId,workspaceId:e.workspaceId,provider:e.provider,providerSessionId:`draft://${e.sessionId}`,rawStoreRef:`draft://${e.sessionId}`,providerConfigMode:"global-default",providerPresetId:null,parentSessionId:null,isSubagent:!1,subagentLabel:null,isArchived:!1,title:po(e.provider),messageCount:0,lastMessageAt:null,createdAt:t,updatedAt:t,syncStatus:"idle",syncCursor:null,lastSyncAt:null,lastErrorCode:null,lastErrorDetail:null,resumedAt:null,runningState:"idle",activitySource:"none",lastEventAt:null,completedAt:null,lastSeenAt:null,activityState:"idle"}}function Pi(e){const t=new Map(e.map(r=>[r.sessionId,r])),s=new Map,n=r=>{const a=s.get(r.sessionId);if(typeof a=="boolean")return a;if(r.isArchived)return s.set(r.sessionId,!1),!1;const o=Ko(r,{mode:"mobile"});if(!o)return s.set(r.sessionId,!0),!0;const u=t.get(o);if(!u)return s.set(r.sessionId,!0),!0;if(u.isArchived){const h=!Bt(r);return s.set(r.sessionId,h),h}const d=n(u);return s.set(r.sessionId,d),d};return e.filter(r=>n(r))}function Ri(e,t,s){if(!t)return[];const n=bs(e,t);if(!n)return[];const r=Pi(n.sessions).map(o=>({session:o,workspace:n.workspace}));return gs(r,{mode:"mobile"}).filter(o=>!s.has(o.item.session.sessionId)&&!Go(o.children,u=>s.has(u.session.sessionId)))}function Ti(e,t){return e.filter(s=>!Bt(s.session)).flatMap(s=>{const n=bs(t,s.workspace.id);if(!n)return[];const r=gs(Pi(n.sessions).map(o=>({session:o,workspace:n.workspace})),{mode:"mobile"}),a=Ci(r,s.session.sessionId);return a?[a]:[]})}function Ci(e,t){for(const s of e){if(s.item.session.sessionId===t)return s;const n=Ci(s.children,t);if(n)return n}return null}function ki(e,t,s,n){c.useEffect(()=>{const r=e.current;if(!s||!r){r&&r.style.removeProperty("--mobile-conversation-composer-height");return}if(!t){r.style.removeProperty("--mobile-conversation-composer-height");return}const a=r,o=t;function u(){!e.current||!o.isConnected||a.style.setProperty("--mobile-conversation-composer-height",`${o.offsetHeight}px`)}u();const d=typeof ResizeObserver<"u"?new ResizeObserver(u):null;return d==null||d.observe(o),window.addEventListener("resize",u),()=>{d==null||d.disconnect(),window.removeEventListener("resize",u),r.style.removeProperty("--mobile-conversation-composer-height")}},[t,s,n,e])}function Ei(e,t,s,n){c.useEffect(()=>{const r=e.current,a=t.current;if(!s||!r){r&&r.style.removeProperty("--mobile-conversation-page-header-height");return}if(!a){r.style.removeProperty("--mobile-conversation-page-header-height");return}const o=r,u=a;function d(){!e.current||!u.isConnected||o.style.setProperty("--mobile-conversation-page-header-height",`${u.offsetHeight}px`)}d();const h=typeof ResizeObserver<"u"?new ResizeObserver(d):null;return h==null||h.observe(u),window.addEventListener("resize",d),()=>{h==null||h.disconnect(),window.removeEventListener("resize",d),r.style.removeProperty("--mobile-conversation-page-header-height")}},[s,t,n,e])}function wc(e){return e==="files"||e==="git"||e==="processes"?e:null}function Ai(...e){const t=e.filter(Boolean);return{onTouchStart(s){t.forEach(n=>n.onTouchStart(s))},onTouchMove(s){t.forEach(n=>n.onTouchMove(s))},onTouchEnd(s){t.forEach(n=>n.onTouchEnd(s))},onTouchCancel(s){t.forEach(n=>n.onTouchCancel(s))}}}function ji(e){const t=cn(),s=dt(),n=nn(),r=Rt(),a=c.useRef(null),o=c.useRef(!1),[u,d]=c.useState(()=>e.initialPanel??En()),h=e.initialPanel??u,f=e.enabled&&e.workspaceId!==null&&e.initialPanel!==null;c.useEffect(()=>{if(!e.enabled){a.current=null,o.current=!1;return}const _=e.initialPanel??En();d(_),An(_)},[e.enabled,e.initialPanel]),c.useEffect(()=>{if(!f){o.current=!1;return}if(r.platform!=="android"||!Mc(t.state)||o.current||typeof window>"u"||window.location.pathname!==t.pathname)return;const _=new URLSearchParams(t.search);_.delete("toolPanel");const A=_.toString(),P=`${t.pathname}${A?`?${A}`:""}${t.hash}`,k=`${t.pathname}${t.search}${t.hash}`;window.history.replaceState(window.history.state,"",P),window.history.pushState(window.history.state,"",k),o.current=!0},[f,t.hash,t.pathname,t.search,t.state,r.platform]);function p(_,A){const P=new URLSearchParams(t.search);_?(P.set("toolPanel",_),d(_),An(_)):P.delete("toolPanel");const k=P.toString();s({pathname:t.pathname,search:k?`?${k}`:""},{replace:(A==null?void 0:A.replace)??!1})}function x(_){n.trigger("selection"),p(_,{replace:f})}function v(){if(f){if(n.trigger("gesture"),o.current&&typeof window<"u"){o.current=!1,window.history.back();return}p(null,{replace:!0})}}function w(_){if(!e.enabled||!e.workspaceId)return;const A=_??h;n.trigger("gesture"),p(A)}function M(_){if(!e.enabled||_.changedTouches.length!==1){a.current=null;return}if(Sc(_.target)){a.current=null;return}const A=_.changedTouches[0];a.current={x:A.clientX,y:A.clientY}}function j(_){const A=a.current;if(a.current=null,!A||_.changedTouches.length!==1||f||e.suspendMainGesture)return;const P=_.changedTouches[0],k=P.clientX-A.x,m=P.clientY-A.y;k>-56||Math.abs(k)<=Math.abs(m)*1.15||w()}function y(_){const A=a.current;if(a.current=null,!A||_.changedTouches.length!==1||!f)return;const P=_.changedTouches[0],k=P.clientX-A.x,m=P.clientY-A.y;k<56||Math.abs(k)<=Math.abs(m)*1.15||v()}return{activePanel:h,closePanel:v,isOpen:f,mainGestureHandlers:{onTouchStart:M,onTouchMove:()=>{},onTouchEnd:j,onTouchCancel:()=>{a.current=null}},openPanel:w,panelGestureHandlers:{onTouchStart:M,onTouchMove:()=>{},onTouchEnd:y,onTouchCancel:()=>{a.current=null}},selectPanel:x}}function _i(e){const t=c.useRef(null);if(!e.open)return null;function s(r){if(r.changedTouches.length!==1){t.current=null;return}if(Ic(r.target)){t.current=null;return}const a=r.changedTouches[0];t.current={x:a.clientX,y:a.clientY}}function n(r){const a=t.current;if(t.current=null,!a||r.changedTouches.length!==1)return;const o=r.changedTouches[0],u=o.clientX-a.x,d=o.clientY-a.y;if(Math.abs(u)<56||Math.abs(u)<=Math.abs(d)*1.15)return;const h=["files","git","processes"],f=h.indexOf(e.activePanel);if(u<0){e.onSelectPanelBySwipe(h[Math.min(h.length-1,f+1)]??e.activePanel);return}if(f===0){e.onSelectPanelBySwipe(null);return}e.onSelectPanelBySwipe(h[Math.max(0,f-1)]??e.activePanel)}return i.jsxs("section",{className:"mobile-conversation-tool-panel","data-panel":e.activePanel,onTouchStartCapture:s,onTouchEndCapture:n,onTouchCancel:()=>{t.current=null},children:[i.jsxs("header",{className:"mobile-conversation-tool-panel-header","data-preview-gesture":"ignore",children:[i.jsx("button",{type:"button",className:"mobile-conversation-tool-panel-back","aria-label":l("shell.mobileConversationToolCloseAction"),title:l("shell.mobileConversationToolCloseAction"),onClick:e.onClose,children:i.jsx("span",{"aria-hidden":"true",children:"‹"})}),i.jsx("div",{className:"mobile-conversation-tool-panel-tabs",role:"tablist","aria-label":l("shell.mobileConversationToolTabsLabel"),children:["files","git","processes"].map(r=>i.jsx("button",{type:"button",role:"tab","aria-selected":e.activePanel===r,className:"mobile-conversation-tool-panel-tab",onClick:()=>{e.onSelectPanel(r)},children:r==="files"?l("shell.filesEntry"):r==="git"?l("shell.gitEntry"):l("shell.mobileConversationToolProcessesTab")},r))})]}),i.jsx("div",{className:"mobile-conversation-tool-panel-body",children:e.activePanel==="files"?i.jsx(Dr,{className:"mobile-conversation-tool-surface",hideHeading:!0,sessionId:e.sessionId,workspaceId:e.workspaceId}):e.activePanel==="git"?i.jsx(qr,{className:"mobile-conversation-tool-surface",panelActive:!0,workspaceId:e.workspaceId}):i.jsx(Hr,{className:"mobile-conversation-tool-surface mobile-tool-native-panel mobile-tool-process-panel",currentWorkspaceId:e.workspaceId,navigationGroups:e.navigationGroups})})]})}function Mc(e){return typeof e=="object"&&e!==null&&"mobileToolPanelRouteRedirect"in e&&e.mobileToolPanelRouteRedirect===!0}function Sc(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, button, a, [contenteditable='true'], [data-preview-gesture='ignore']"):!1}function Ic(e){return e instanceof Element?!!e.closest("input, textarea, select, option, [contenteditable='true']"):!1}function Ni(e){const t=nn(),[s,n]=c.useState(()=>e?xs():"immersive"),[r,a]=c.useState(()=>pr()),[o,u]=c.useState(()=>e&&xs()==="preview"?"default":"closed"),d=c.useRef(o),h=c.useRef(null);c.useEffect(()=>{d.current=o},[o]),c.useEffect(()=>{if(!e){h.current=null,d.current="closed",u("closed"),n("immersive");return}const m=xs();n(m),u(m==="preview"?"default":"closed")},[e]),c.useEffect(()=>{e&&Nt(s)},[e,s]),c.useEffect(()=>{if(typeof window>"u")return;function m(){a(pr())}return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[]);function f(m){d.current=m,u(m)}function p(m="default"){f(m),n("preview")}function x(){f("closed"),n("immersive")}function v(){f("expanded"),n("preview")}function w(){if(d.current!=="closed"){t.trigger("gesture"),x();return}t.trigger("gesture"),p()}function M(m,b){const L=b.touches[0]??b.changedTouches[0];if(!e||!L){h.current=null;return}if(xc(b.target)){h.current=null;return}if(m==="main"){if(d.current==="closed"&&L.clientX>hc){h.current=null;return}}else if(d.current==="closed"){h.current=null;return}h.current={source:m,intent:m==="rail"?"rail":d.current==="closed"?"open":"close",startX:L.clientX,startY:L.clientY,lastX:L.clientX,lastY:L.clientY,horizontalLocked:!1}}function j(m){const b=h.current,L=m.touches[0];if(!e||!b||!L)return;const G=L.clientX-b.startX,X=L.clientY-b.startY;if(b.lastX=L.clientX,b.lastY=L.clientY,!b.horizontalLocked){if(Math.abs(G)<fr&&Math.abs(X)<fr)return;if(Math.abs(G)<=Math.abs(X)){h.current=null;return}if(b.intent==="open"&&G<=0){h.current=null;return}if(b.intent==="close"&&G>=0){h.current=null;return}b.horizontalLocked=!0}}function y(m){var X;const b=h.current;if(h.current=null,!(b!=null&&b.horizontalLocked))return;const L=(X=m==null?void 0:m.changedTouches)==null?void 0:X[0];L&&(b.lastX=L.clientX,b.lastY=L.clientY);const G=b.lastX-b.startX;if(b.intent==="open"){G>=uc&&(t.trigger("gesture"),p("default"));return}if(b.intent==="close"){G<=-34&&(t.trigger("gesture"),x());return}if(G<=-34){t.trigger("gesture"),x();return}G>=dc&&d.current==="default"&&(t.trigger("gesture"),v())}const O=o==="expanded"?Bs:o==="default"?hr:0,C=Math.round(r*O*100)/100,_=O===0?0:O/Bs,A={"--mobile-conversation-preview-default-width":`${Math.round(r*hr*100)/100}px`,"--mobile-conversation-preview-max-width":`${Math.round(r*Bs*100)/100}px`,"--mobile-conversation-preview-width":`${C}px`,"--mobile-conversation-preview-progress":_.toFixed(4)};return{closePreview:x,displayMode:o==="closed"?"immersive":"preview",isDragging:!1,isVisible:o!=="closed",mainGestureHandlers:{onTouchStart:m=>M("main",m),onTouchMove:j,onTouchEnd:y,onTouchCancel:y},pageStyle:A,previewWidthPx:C,railGestureHandlers:{onTouchStart:m=>M("rail",m),onTouchMove:j,onTouchEnd:y,onTouchCancel:y},togglePreview:w}}function Oi({visible:e,widthPx:t,isDragging:s,gestureHandlers:n,activeSessionId:r,createSessionActionLabel:a,favoriteItems:o,items:u,expandedRootIds:d,workspaceSectionLabel:h,onCreateSession:f,archiveCurrentActionLabel:p,archiveFolderActionLabel:x,onArchiveActiveSession:v,onOpenArchiveFolder:w,onToggleSubsessions:M,onActivate:j}){if(!e)return null;function y(O,C){const{workspaceName:_,ancestorExpanded:A=!1,ancestorHasNextSiblings:P=[],hasNextSibling:k=!1,isFirstSibling:m=!1}=C??{},b=O.item.session.sessionId,L=O.children,G=O.depth===0&&L.length>0,X=A||G&&d.includes(b),Z=O.depth>0?[...P,k]:[...P];return i.jsxs("div",{className:"mobile-conversation-preview-tree-node",children:[i.jsxs("div",{className:"mobile-conversation-preview-tree-row",style:{"--mobile-preview-tree-depth":O.depth},children:[O.depth>0?i.jsxs("div",{className:"mobile-conversation-preview-guides","aria-hidden":"true",children:[P.map((te,D)=>te?i.jsx("span",{className:"mobile-conversation-preview-guide-column",style:{"--mobile-preview-tree-level":D+1}},`${b}:ancestor:${D}`):null),i.jsx("span",{className:"mobile-conversation-preview-guide-branch","data-continue":k,"data-first":m,style:{"--mobile-preview-tree-level":O.depth},children:i.jsx("span",{className:"mobile-conversation-preview-guide-branch-horizontal"})})]}):null,i.jsx(yc,{entry:O.item,activeSessionId:r,hasSubsessions:G,subsessionsExpanded:X,workspaceName:_,onToggleSubsessions:G?()=>{M(b)}:void 0,onActivate:j})]}),L.length>0&&X?i.jsx("div",{className:"mobile-conversation-preview-children",children:L.map((te,D)=>y(te,{workspaceName:_,ancestorExpanded:!0,ancestorHasNextSiblings:Z,hasNextSibling:D<L.length-1,isFirstSibling:D===0}))}):null]},`${O.item.workspace.id}:${b}`)}return i.jsxs("aside",{className:"mobile-conversation-preview-rail terminal-mobile-list-rail surface-card","data-dragging":s,style:{width:`${t}px`,maxWidth:`${t}px`},...n,children:[a&&f?i.jsx("div",{className:"mobile-conversation-preview-topbar terminal-mobile-list-footer",children:i.jsxs("button",{type:"button",className:"mobile-conversation-preview-create-button workbench-import-toggle terminal-mobile-list-create",onClick:f,children:[i.jsx("span",{className:"workbench-import-toggle-symbol","aria-hidden":"true",children:"+"}),i.jsx("span",{className:"workbench-import-toggle-label",children:a})]})}):null,i.jsxs("div",{className:"mobile-conversation-preview-body terminal-mobile-list-body",children:[o.length>0?i.jsxs("section",{className:"mobile-conversation-preview-group mobile-conversation-preview-list-favorites terminal-mobile-list-group terminal-mobile-list-group-pinned",children:[i.jsxs("div",{className:"mobile-conversation-preview-group-heading terminal-mobile-list-group-heading",children:[i.jsx("span",{children:l("shell.favoriteSectionTitle")}),i.jsx("span",{className:"workbench-section-counter",children:o.length})]}),i.jsx("div",{className:"mobile-conversation-preview-list mobile-conversation-preview-list-static terminal-mobile-session-list",children:o.map(O=>i.jsx("div",{children:y(O,{workspaceName:O.item.workspace.name})},`favorite:${O.item.workspace.id}:${O.item.session.sessionId}`))})]}):null,i.jsxs("section",{className:"mobile-conversation-preview-group mobile-conversation-preview-group-workspace terminal-mobile-list-group terminal-mobile-list-group-workspace",children:[i.jsxs("div",{className:"mobile-conversation-preview-group-heading terminal-mobile-list-group-heading",children:[i.jsx("span",{children:h}),i.jsx("span",{className:"workbench-section-counter",children:u.length})]}),u.length===0?i.jsx("div",{className:"workbench-session-empty",children:l("shell.emptyWorkspaceSessions")}):i.jsx("div",{className:"mobile-conversation-preview-list terminal-mobile-session-list","data-preview-gesture":"ignore",children:u.map(O=>y(O))})]})]}),p&&v||x&&w?i.jsxs("div",{className:"mobile-conversation-preview-actions terminal-mobile-list-footer",children:[p&&v?i.jsx("button",{type:"button",className:"mobile-conversation-preview-archive-button workbench-import-toggle",onClick:()=>{v()},children:p}):null,x&&w?i.jsx("button",{type:"button",className:"mobile-conversation-preview-archive-button workbench-import-toggle",onClick:w,children:x}):null]}):null]})}function yc({entry:e,activeSessionId:t,hasSubsessions:s=!1,subsessionsExpanded:n=!1,onActivate:r,onToggleSubsessions:a,workspaceName:o}){const u=e.session.sessionId===t;return i.jsxs("article",{className:"mobile-conversation-preview-entry terminal-mobile-session-card","data-active":u,children:[s?i.jsx("button",{type:"button",className:"mobile-conversation-preview-toggle","aria-label":n?l("shell.subagentCollapse"):l("shell.subagentExpand"),title:n?l("shell.subagentCollapse"):l("shell.subagentExpand"),"aria-expanded":n,onClick:d=>{d.stopPropagation(),a==null||a()},children:i.jsx("span",{className:mr(e.session,{isActive:u,hasSubsessions:s}),"aria-hidden":"true"})}):i.jsx("span",{className:mr(e.session,{isActive:u,hasSubsessions:s}),"aria-hidden":"true"}),i.jsx("button",{type:"button",className:"mobile-conversation-preview-item terminal-mobile-session-primary","data-active":u,onClick:()=>r(e),children:i.jsxs("div",{className:"mobile-conversation-preview-item-body",children:[i.jsx("span",{className:"mobile-conversation-preview-item-title",children:e.session.title||l("common.unknown")}),i.jsx("span",{className:"mobile-conversation-preview-item-meta",children:Li(e.session,o)})]})})]})}function pr(){return typeof window>"u"?390:Math.max(window.innerWidth||390,320)}function xc(e){return e instanceof Element?!!e.closest("input, textarea, select, option, label, [contenteditable='true'], [data-preview-gesture='ignore']"):!1}function mr(e,t){const s=Qo("mobile-conversation-preview-indicator",e,{hasSubagents:t.hasSubsessions});return s.endsWith(" is-idle")&&t.isActive?"mobile-conversation-preview-indicator is-active":s}function Li(e,t){const s=_r(e);return[t??null,Lt(e.provider),Pc(e.lastMessageAt??e.updatedAt),s].filter(Boolean).join(" · ")}function Pc(e){return e?new Date(e).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"}):l("common.unknown")}function Rc({open:e,busy:t,onClose:s,onConfirm:n}){return i.jsx(fs,{open:e,title:l("shell.archiveConfirmTitle"),description:l("shell.archiveConfirmDescription"),size:"narrow",layout:"confirm",dismissible:!t,showCloseButton:!1,footer:i.jsxs(ps,{children:[i.jsx("button",{type:"button",className:"secondary-button",disabled:t,onClick:s,children:l("common.cancel")}),i.jsx("button",{type:"button",className:"secondary-button workbench-danger-button",disabled:t,onClick:()=>{n()},children:l("shell.archiveAction")})]}),onClose:s,children:i.jsx(i.Fragment,{})})}function Di({open:e,workspaceName:t,sessions:s,restoringSessionId:n,onClose:r,onRestore:a}){const{searchOpen:o,searchKeyword:u,filteredSessions:d,summaryLoading:h,summaryError:f,summaryBySessionId:p,setSearchKeyword:x,toggleSearch:v}=Xo(e,s),w=c.useId(),M=s.length>0&&u.trim().length>0?l("shell.archiveSearchEmpty"):l("shell.archiveEmpty");return i.jsxs(fs,{open:e,title:l("shell.archiveModalTitle"),description:t?`${t} · ${l("shell.archiveModalDescription")}`:l("shell.archiveModalDescription"),size:"regular",layout:"list",dismissible:!n,headerActions:s.length>0?i.jsx("button",{type:"button",className:"secondary-button","aria-pressed":o,onClick:v,children:l("shell.archiveSearchAction")}):void 0,showCloseButton:!1,onClose:r,children:[o?i.jsxs("div",{className:"workbench-archive-search-panel",children:[i.jsx(Jt,{label:l("shell.archiveSearchLabel"),htmlFor:w,children:i.jsx("input",{id:w,type:"text",value:u,placeholder:l("shell.archiveSearchPlaceholder"),autoFocus:!0,onChange:j=>x(j.target.value)})}),h?i.jsx("p",{className:"workbench-archive-search-status",children:l("shell.archiveSearchSummaryLoading")}):null,f?i.jsx("p",{className:"workbench-archive-search-status status-text","data-tone":"warning",children:f}):null]}):null,d.length>0?i.jsx(mo,{className:"workbench-archive-list",children:d.map(j=>{var C;const y=Pt(j.title,l("common.unknown")),O=((C=p[j.sessionId])==null?void 0:C.trim())??"";return i.jsx(go,{className:"workbench-archive-item",trailing:i.jsx("button",{type:"button",className:"secondary-button",disabled:n===j.sessionId,onClick:()=>{a(j.sessionId)},children:l("shell.unarchiveAction")}),children:i.jsxs("div",{className:"workbench-archive-item-main",children:[i.jsx("strong",{title:y.fullTitle,children:y.displayTitle}),i.jsx("p",{children:Li(j)}),o&&O?i.jsx("p",{className:"workbench-archive-item-summary",children:O}):null]})},j.sessionId)})}):i.jsx(vo,{title:M,compact:!0,className:"workbench-section-empty"})]})}function Tc(e){return i.jsx("button",{type:"button",className:"conversation-header-ai-button","aria-label":l("conversation.branchTreeAction"),title:l("conversation.branchTreeAction"),onClick:e.onOpenBranchTree,children:i.jsx("span",{className:"conversation-header-ai-button-label","aria-hidden":"true",children:i.jsx(zo,{})})})}function Cc(){return i.jsxs("svg",{viewBox:"0 0 16 16","aria-hidden":"true",children:[i.jsx("path",{d:"M4 3.25a1.75 1.75 0 1 1 0 3.5a1.75 1.75 0 0 1 0-3.5Zm0 6a1.75 1.75 0 1 1 0 3.5a1.75 1.75 0 0 1 0-3.5Zm8-3a1.75 1.75 0 1 1 0 3.5a1.75 1.75 0 0 1 0-3.5Z",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),i.jsx("path",{d:"M5.75 5h2.15c1.35 0 2.45 1.1 2.45 2.45v.1M5.75 11h2.15c1.35 0 2.45-1.1 2.45-2.45V8.4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.4"})]})}function kc(e){return e.startsWith("draft-")}function Ec(e){var a,o,u,d,h,f;const t=((o=(a=e.created.message)==null?void 0:a.providerSessionId)==null?void 0:o.trim())||e.created.providerSessionId.trim()||`draft-bootstrap-${e.created.sessionId}`,s=`synthetic-user-${e.clientRequestId}`,n=Number.isFinite((u=e.created.message)==null?void 0:u.sequence)?Math.max(1,((d=e.created.message)==null?void 0:d.sequence)??1):1,r=((f=(h=e.created.message)==null?void 0:h.timestamp)==null?void 0:f.trim())||e.created.acceptedAt.trim()||new Date().toISOString();return{messageId:s,provider:e.provider,providerSessionId:t,role:"user",kind:"text",content:e.content,attachments:e.attachments,timestamp:r,sequence:n,rawRef:`synthetic://${e.provider}/${e.created.sessionId}/${e.clientRequestId}`}}function Ac(e,t){if(!t||typeof t!="object")return[];const s=t.bootstrap;if(!s||typeof s!="object")return[];const n=s.sessionId,r=s.messages;return n!==e||!Array.isArray(r)?[]:r.filter(_c)}function jc(e,t){if(!t||typeof t!="object")return{initialModel:null,providerConfigMode:"global-default",providerPresetId:null};const s=t.composer;if(!s||typeof s!="object")return{initialModel:null,providerConfigMode:"global-default",providerPresetId:null};const n=s.sessionId,r=s.initialModel,a=s.providerConfigMode,o=s.providerPresetId;if(n!==e)return{initialModel:null,providerConfigMode:"global-default",providerPresetId:null};const u=typeof r=="string"&&r.trim()||null,d=typeof o=="string"&&o.trim()||null,h=a==="cc-switch-preset"&&d?"cc-switch-preset":"global-default";return{initialModel:u,providerConfigMode:h,providerPresetId:h==="cc-switch-preset"?d:null}}function _c(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.messageId=="string"&&typeof t.provider=="string"&&typeof t.providerSessionId=="string"&&typeof t.role=="string"&&typeof t.content=="string"&&typeof t.timestamp=="string"&&typeof t.sequence=="number"&&typeof t.rawRef=="string"}function Nc(){const e=globalThis.crypto;return e&&typeof e.randomUUID=="function"?e.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`}export{tu as ConversationPage};
@@ -1 +1 @@
1
- import{b as d,j as e}from"./index-DvkfRpBe.js";function c(){return d.useEffect(()=>{const t=document.documentElement.style.background,s=document.body.style.background;return document.documentElement.style.background="transparent",document.body.style.background="transparent",()=>{document.documentElement.style.background=t,document.body.style.background=s}},[]),e.jsx("main",{className:"desktop-detach-preview-page","aria-hidden":"true",children:e.jsxs("section",{className:"desktop-detach-preview-card",children:[e.jsx("header",{className:"desktop-detach-preview-bar",children:e.jsx("strong",{className:"desktop-detach-preview-title",children:"小窗口"})}),e.jsx("div",{className:"desktop-detach-preview-body",children:e.jsx("span",{className:"desktop-detach-preview-badge"})})]})})}export{c as DesktopDetachPreviewPage};
1
+ import{b as d,j as e}from"./index-NGxWr8Ix.js";function c(){return d.useEffect(()=>{const t=document.documentElement.style.background,s=document.body.style.background;return document.documentElement.style.background="transparent",document.body.style.background="transparent",()=>{document.documentElement.style.background=t,document.body.style.background=s}},[]),e.jsx("main",{className:"desktop-detach-preview-page","aria-hidden":"true",children:e.jsxs("section",{className:"desktop-detach-preview-card",children:[e.jsx("header",{className:"desktop-detach-preview-bar",children:e.jsx("strong",{className:"desktop-detach-preview-title",children:"小窗口"})}),e.jsx("div",{className:"desktop-detach-preview-body",children:e.jsx("span",{className:"desktop-detach-preview-badge"})})]})})}export{c as DesktopDetachPreviewPage};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/window-BVUB8gMK.js","assets/event-DvH9tcej.js"])))=>i.map(i=>d[i]);
2
- import{b as a,m as E,_ as y,j as t,t as c}from"./index-DvkfRpBe.js";import{u as q,g as O}from"./model-switch-api-Dps4yN2t.js";import{FileContextPanel as F}from"./FileContextPanel-h0kvRbSR.js";import{GitSidebar as C}from"./GitSidebar-TlaPNhxG.js";import{TerminalManagerPanel as P}from"./TerminalManagerPanel-Bkgr9ZNV.js";import{TerminalPage as _}from"./TerminalPage-BpFpA3My.js";import{r as $,W as U,m as W}from"./WorkbenchLayout-Cht6Un5X.js";import{c as z,u as A,e as H,N as K}from"./App-BRupl2Ul.js";import"./WorkbenchModal-CAj_TqWW.js";import"./file-tree-icon-CLfk31E7.js";import"./terminal-runtime-meta-C3Mr0zW5.js";import"./TerminalRuntimeFallbackModal-D_BUt6HD.js";import"./MobileWorkspaceSwitcherHeader-CWPXAMoX.js";import"./MobileTopHeaderFrame-BawK1vUE.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-WiotM2TL.js";function V(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function B(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function J(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function Q(n,u){return{navigationGroups:u,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function x(n){return n.kind==="files"?c("shell.filesEntry"):n.kind==="git"?c("shell.gitEntry"):n.kind==="processes"?c("shell.terminalManagerEntry"):n.kind==="terminals"?c("shell.terminalsEntry"):n.kind}function M(n,u){var s;return n.workspaceName??(n.workspaceId?((s=u.find(d=>d.workspace.id===n.workspaceId))==null?void 0:s.workspace.name)??null:null)}function X(n,u){const s=M(n,u),d=x(n);return s?`CodingNS - ${d}(${s})`:`CodingNS - ${d}`}function we(){const{windowId:n}=z(),u=A(),s=H(),d=$(s),h=q(i=>i.sessionDisplaySortMode),[e,b]=a.useState(null),[N,w]=a.useState(!0),[T,v]=a.useState(null),[o,k]=a.useState([]),[r,S]=a.useState(null);a.useEffect(()=>{let i=!1;async function l(){if(!n){b(null),w(!1),v(c("desktopWindow.invalidWindowId"));return}w(!0),v(null);const p=await s.bridge.getWindowDescriptor(n),g=p.ok?p.value??null:s.windows.getDescriptor(n);if(!i){if(!g){b(null),w(!1),v(p.detail??c("desktopWindow.loadDescriptorFailed"));return}s.windows.registerDescriptor(g),s.windows.markWindowOpen(g.windowId),b(g),w(!1)}}return l(),()=>{i=!0}},[s,n]),a.useEffect(()=>{if(!(e!=null&&e.workspaceId)){k([]);return}let i=!1;async function l(){try{const p=await O();if(i)return;k(W(p,h))}catch{if(i)return;k([])}}return l(),()=>{i=!0}},[e==null?void 0:e.workspaceId,h]),a.useEffect(()=>{if(!e){S(null);return}const i=new U({onConnectionChange:()=>{},onSnapshot:l=>{k(W(l,h))},onUnauthorized:()=>{E.clear(),u(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return S(i),i.start(),()=>{i.close(),S(null)}},[e,u,h]),a.useEffect(()=>{if(!s.isDesktop||!s.bridge.supported||!e||e.mode!=="external")return;const i=X(e,o);document.title=i,y(async()=>{const{getCurrentWindow:l}=await import("./window-BVUB8gMK.js").then(p=>p.w);return{getCurrentWindow:l}},__vite__mapDeps([0,1])).then(({getCurrentWindow:l})=>l().setTitle(i)).catch(()=>{})},[e,o,s.bridge.supported,s.isDesktop]);const D=a.useMemo(()=>r?{navigationGroups:o,subscribeFileTree:r.subscribeFileTree.bind(r),requestFileTreeRefresh:r.requestFileTreeRefresh.bind(r),addFileTreeSnapshotListener:r.addFileTreeSnapshotListener.bind(r),subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:V(o),[o,r]),I=a.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:B(),[r]),R=a.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:J(),[r]),G=a.useMemo(()=>r?{navigationGroups:o,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:Q((e==null?void 0:e.workspaceId)??null,o),[e==null?void 0:e.workspaceId,o,r]);if(!s.isDesktop)return t.jsx(K,{to:"/",replace:!0});if(N)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:c("common.loading")})});if(T)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:T})});if(!e)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:c("desktopWindow.loadDescriptorFailed")})});let m=null;if(e.kind==="files"?m=t.jsx(F,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:D}):e.kind==="git"?m=t.jsx(C,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:I}):e.kind==="processes"?m=t.jsx(P,{currentWorkspaceId:e.workspaceId,navigationGroups:o,externalWindowMode:!0,workbenchShellOverrides:R}):e.kind==="terminals"&&(m=t.jsx(_,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:G})),!m)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:c("desktopWindow.unsupportedKind",{kind:e.kind})})});const f=x(e),j=M(e,o),L=e.mode==="external"&&e.kind==="processes";return t.jsxs("main",{className:"desktop-window-page",children:[L?t.jsx("header",{className:"desktop-window-drag-header","data-window-kind":e.kind,"data-window-drag-handle":"desktop-window-drag-header","data-tauri-drag-region":d,"aria-label":f,children:t.jsxs("div",{className:"desktop-window-drag-header-copy","data-tauri-drag-region":d,children:[t.jsx("span",{className:"desktop-window-drag-header-tag","data-tauri-drag-region":d,children:f}),t.jsx("strong",{"data-tauri-drag-region":d,children:j??f})]})}):null,t.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":f,children:m})]})}export{we as DesktopWindowPage};
2
+ import{b as a,m as E,_ as y,j as t,t as c}from"./index-NGxWr8Ix.js";import{u as q,g as O}from"./model-switch-api-CPtou49j.js";import{FileContextPanel as F}from"./FileContextPanel-xGTYDclT.js";import{GitSidebar as C}from"./GitSidebar-Cr3Z9OUI.js";import{TerminalManagerPanel as P}from"./TerminalManagerPanel-2bi9wVhT.js";import{TerminalPage as _}from"./TerminalPage-DayZz2Tf.js";import{r as $,W as U,m as W}from"./WorkbenchLayout-DScHaza9.js";import{c as z,u as A,e as H,N as K}from"./App-tXOqoHNl.js";import"./WorkbenchModal-BWXYSXmC.js";import"./file-tree-icon-lfU9Ag77.js";import"./terminal-runtime-meta-C-Lbyx2i.js";import"./TerminalRuntimeFallbackModal-DgwYcp-Y.js";import"./MobileWorkspaceSwitcherHeader-KIbqBYJN.js";import"./MobileTopHeaderFrame-CkdnZ_MU.js";import"./window-BVUB8gMK.js";import"./event-DvH9tcej.js";import"./relay-entry-BwE5nw0l.js";function V(n){return{navigationGroups:n,subscribeFileTree:()=>{},requestFileTreeRefresh:()=>{},addFileTreeSnapshotListener:()=>()=>{},subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function B(){return{subscribeGitSnapshot:()=>{},requestGitRefresh:()=>{},addGitSnapshotListener:()=>()=>{}}}function J(){return{subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function Q(n,u){return{navigationGroups:u,currentWorkspaceId:n,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:()=>{},requestTerminalManagerRefresh:()=>{},addTerminalManagerSnapshotListener:()=>()=>{}}}function x(n){return n.kind==="files"?c("shell.filesEntry"):n.kind==="git"?c("shell.gitEntry"):n.kind==="processes"?c("shell.terminalManagerEntry"):n.kind==="terminals"?c("shell.terminalsEntry"):n.kind}function M(n,u){var s;return n.workspaceName??(n.workspaceId?((s=u.find(d=>d.workspace.id===n.workspaceId))==null?void 0:s.workspace.name)??null:null)}function X(n,u){const s=M(n,u),d=x(n);return s?`CodingNS - ${d}(${s})`:`CodingNS - ${d}`}function we(){const{windowId:n}=z(),u=A(),s=H(),d=$(s),h=q(i=>i.sessionDisplaySortMode),[e,b]=a.useState(null),[N,w]=a.useState(!0),[T,v]=a.useState(null),[o,k]=a.useState([]),[r,S]=a.useState(null);a.useEffect(()=>{let i=!1;async function l(){if(!n){b(null),w(!1),v(c("desktopWindow.invalidWindowId"));return}w(!0),v(null);const p=await s.bridge.getWindowDescriptor(n),g=p.ok?p.value??null:s.windows.getDescriptor(n);if(!i){if(!g){b(null),w(!1),v(p.detail??c("desktopWindow.loadDescriptorFailed"));return}s.windows.registerDescriptor(g),s.windows.markWindowOpen(g.windowId),b(g),w(!1)}}return l(),()=>{i=!0}},[s,n]),a.useEffect(()=>{if(!(e!=null&&e.workspaceId)){k([]);return}let i=!1;async function l(){try{const p=await O();if(i)return;k(W(p,h))}catch{if(i)return;k([])}}return l(),()=>{i=!0}},[e==null?void 0:e.workspaceId,h]),a.useEffect(()=>{if(!e){S(null);return}const i=new U({onConnectionChange:()=>{},onSnapshot:l=>{k(W(l,h))},onUnauthorized:()=>{E.clear(),u(`/login?returnTo=${encodeURIComponent(`/desktop-window/${e.windowId}`)}`,{replace:!0})}});return S(i),i.start(),()=>{i.close(),S(null)}},[e,u,h]),a.useEffect(()=>{if(!s.isDesktop||!s.bridge.supported||!e||e.mode!=="external")return;const i=X(e,o);document.title=i,y(async()=>{const{getCurrentWindow:l}=await import("./window-BVUB8gMK.js").then(p=>p.w);return{getCurrentWindow:l}},__vite__mapDeps([0,1])).then(({getCurrentWindow:l})=>l().setTitle(i)).catch(()=>{})},[e,o,s.bridge.supported,s.isDesktop]);const D=a.useMemo(()=>r?{navigationGroups:o,subscribeFileTree:r.subscribeFileTree.bind(r),requestFileTreeRefresh:r.requestFileTreeRefresh.bind(r),addFileTreeSnapshotListener:r.addFileTreeSnapshotListener.bind(r),subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:V(o),[o,r]),I=a.useMemo(()=>r?{subscribeGitSnapshot:r.subscribeGit.bind(r),requestGitRefresh:r.requestGitRefresh.bind(r),addGitSnapshotListener:r.addGitSnapshotListener.bind(r)}:B(),[r]),R=a.useMemo(()=>r?{subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:J(),[r]),G=a.useMemo(()=>r?{navigationGroups:o,currentWorkspaceId:(e==null?void 0:e.workspaceId)??null,selectWorkspace:()=>{},subscribeTerminalManagerSnapshot:r.subscribeTerminalManager.bind(r),requestTerminalManagerRefresh:r.requestTerminalManagerRefresh.bind(r),addTerminalManagerSnapshotListener:r.addTerminalManagerSnapshotListener.bind(r)}:Q((e==null?void 0:e.workspaceId)??null,o),[e==null?void 0:e.workspaceId,o,r]);if(!s.isDesktop)return t.jsx(K,{to:"/",replace:!0});if(N)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:c("common.loading")})});if(T)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:T})});if(!e)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:c("desktopWindow.loadDescriptorFailed")})});let m=null;if(e.kind==="files"?m=t.jsx(F,{sessionId:e.sessionId,workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:D}):e.kind==="git"?m=t.jsx(C,{workspaceId:e.workspaceId,externalWindowMode:!0,workbenchShellOverrides:I}):e.kind==="processes"?m=t.jsx(P,{currentWorkspaceId:e.workspaceId,navigationGroups:o,externalWindowMode:!0,workbenchShellOverrides:R}):e.kind==="terminals"&&(m=t.jsx(_,{externalWindowMode:!0,externalWindowWorkspaceId:e.workspaceId,workbenchShellOverrides:G})),!m)return t.jsx("main",{className:"desktop-window-page",children:t.jsx("p",{className:"status-text",children:c("desktopWindow.unsupportedKind",{kind:e.kind})})});const f=x(e),j=M(e,o),L=e.mode==="external"&&e.kind==="processes";return t.jsxs("main",{className:"desktop-window-page",children:[L?t.jsx("header",{className:"desktop-window-drag-header","data-window-kind":e.kind,"data-window-drag-handle":"desktop-window-drag-header","data-tauri-drag-region":d,"aria-label":f,children:t.jsxs("div",{className:"desktop-window-drag-header-copy","data-tauri-drag-region":d,children:[t.jsx("span",{className:"desktop-window-drag-header-tag","data-tauri-drag-region":d,children:f}),t.jsx("strong",{"data-tauri-drag-region":d,children:j??f})]})}):null,t.jsx("div",{className:"desktop-window-body","data-window-kind":e.kind,"aria-label":f,children:m})]})}export{we as DesktopWindowPage};