@pi-chamber/web 1.0.8-rc.1 → 1.0.8-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentsSurface-BmHImX8m.js → AgentsSurface-CcWBqAWV.js} +1 -1
- package/dist/assets/{ChoicesArtifact-C71fGOm2.js → ChoicesArtifact-Kk-qvrSB.js} +1 -1
- package/dist/assets/{DiagramView-BZQxoiZu.js → DiagramView-DZUBo1uP.js} +1 -1
- package/dist/assets/{DiffView-C70pbgk-.js → DiffView-CiZy4jFA.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-Cu8c3gBV.js → FileSaveConflictDialog-DZ9NDwOO.js} +1 -1
- package/dist/assets/{FilesView-nFJYEdRw.js → FilesView-DqiZ9kw9.js} +1 -1
- package/dist/assets/{GitHubDetailScaffold-Jvv_tgbl.js → GitHubDetailScaffold-DM2DH7o8.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-BXD2ODRi.js → GitHubLinkPicker-ChB8NZ1h.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-BWI706F0.js → GitHubListPrimitives-CibDiJGq.js} +1 -1
- package/dist/assets/{GitView-MIDG5RYW.js → GitView--EaZQrBr.js} +5 -5
- package/dist/assets/{IssuesSurface-uNlozeu0.js → IssuesSurface-CySTpaD1.js} +3 -3
- package/dist/assets/{JsonTreeView-CSLsTriz.js → JsonTreeView-_yMHKKQZ.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cs-7BfWi.js → MarkdownRendererImpl-D_-2fQw0.js} +1 -1
- package/dist/assets/{PatchDiff-axbsnbTJ.js → PatchDiff-bHObDlhD.js} +1 -1
- package/dist/assets/{PierreDiffViewer-lwn6w_5w.js → PierreDiffViewer-UY7Cse-s.js} +1 -1
- package/dist/assets/{PullRequestsSurface-o_AXDjbO.js → PullRequestsSurface-iXy6chwc.js} +2 -2
- package/dist/assets/{SessionSwitcherContent-C4CMlcbv.js → SessionSwitcherContent-DJGCa_wN.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-DCBVuCoo.js → SessionSwitcherDropdown-CDOX-5Y2.js} +2 -2
- package/dist/assets/{SessionUnreadDot-DyeIrsro.js → SessionUnreadDot-Dwc3MdvA.js} +1 -1
- package/dist/assets/SettingsView-DA-U9lsj.js +11 -0
- package/dist/assets/{SettingsWindow-Cb4st5y5.js → SettingsWindow-CUg49Mfh.js} +1 -1
- package/dist/assets/{SubagentsArtifact-BzeMEoFP.js → SubagentsArtifact-DUZX9tDe.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BP2mOWdV.js → ToolOutputDialog-BuZZaRw4.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-D49XBR9b.js → ToolPartDiffPreview-CKncG6i2.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-CLgDONEQ.js → VirtualizedFileDiff-BGZiLPe_.js} +1 -1
- package/dist/assets/VisualFrame-DBZkHFnG.js +22 -0
- package/dist/assets/VisualsArtifact-Bq0vMO-i.js +1 -0
- package/dist/assets/{collapsible-BeyKtQGB.js → collapsible-Bro9KrfM.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DmO6H8u6.js → computeVirtualFileMetrics-DJQqK49u.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-DOK251YW.js → contextFileOpenGuard-ByWK3Sru.js} +1 -1
- package/dist/assets/{fileTreeStatus-CnzR7kxA.js → fileTreeStatus-CyJ3TOYD.js} +1 -1
- package/dist/assets/{gitStatusPredicates-4kPg2t6j.js → gitStatusPredicates-BsXrwngT.js} +1 -1
- package/dist/assets/{githubLink-QvaLfNNT.js → githubLink-g2bmC0qi.js} +1 -1
- package/dist/assets/index-B_L9GVYw.css +1 -0
- package/dist/assets/{index-DMX9wT1Z.js → index-C9rUUQ_Y.js} +1 -1
- package/dist/assets/index-CKKWVoND.js +11 -0
- package/dist/assets/{main-BW9J3Y72.js → main-DT-4_fhe.js} +2 -2
- package/dist/assets/{main-BirYxac2.js → main-DsLMU9CT.js} +4 -4
- package/dist/assets/{markdownCore-CxmcPur8.js → markdownCore-QmM_aOnZ.js} +1 -1
- package/dist/assets/{miniChat-BRB11eEs.js → miniChat-BqGslD2z.js} +2 -2
- package/dist/assets/{mobile-DJZYYCuB.js → mobile-C5JOcDIC.js} +2 -2
- package/dist/assets/{nativeFileSave-B6QpoPRn.js → nativeFileSave-DSMsJqXM.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-PWoh3LNA.js → pi-session-focus-preference-Cc_S4zi1.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-C48T6YFJ.js → renderDiffWithHighlighter-BXhnIAHg.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-N-BQdJl0.js → renderElectronMiniChatApp-CiSkecEE.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-8Kt2MyTN.js → renderFileWithHighlighter-CK29YZtC.js} +1 -1
- package/dist/assets/renderMobileApp-C4JuoxsZ.js +11 -0
- package/dist/assets/runtimeEndpointReset-Dwj-jCDS.js +66 -0
- package/dist/assets/{runtimeSurface-kIEoYsPP.js → runtimeSurface-0K7vuUpd.js} +1 -1
- package/dist/assets/{selection-BTEdLRVK.js → selection-CnYkEsu_.js} +1 -1
- package/dist/assets/useAppFontEffects-CV5UyTRw.js +226 -0
- package/dist/assets/{useGitHubRemoteSearch-DIBHNu8r.js → useGitHubRemoteSearch-CgP-zEBj.js} +1 -1
- package/dist/assets/{useSwitcherItems-DfLbfX37.js → useSwitcherItems-C8G5F0hs.js} +1 -1
- package/dist/assets/{web-components-C_DsTJis.js → web-components-BpncHjnV.js} +1 -1
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/plugins/featured.json +12 -0
- package/plugins/subagents/package.json +1 -1
- package/plugins/visuals/extension.js +7 -4
- package/plugins/visuals/package.json +1 -1
- package/server/index.js +86 -27
- package/server/lib/git/DOCUMENTATION.md +4 -0
- package/server/lib/git/service.js +70 -5
- package/server/lib/git/service.test.js +179 -0
- package/server/lib/github/DOCUMENTATION.md +2 -0
- package/server/lib/marketplace/DOCUMENTATION.md +95 -0
- package/server/lib/marketplace/featured.js +176 -0
- package/server/lib/marketplace/featured.test.js +207 -0
- package/server/lib/marketplace/npm-registry.js +255 -0
- package/server/lib/marketplace/npm-registry.test.js +227 -0
- package/server/lib/marketplace/routes.js +64 -0
- package/server/lib/marketplace/routes.test.js +119 -0
- package/server/lib/marketplace/service.js +225 -0
- package/server/lib/marketplace/service.test.js +174 -0
- package/server/lib/notifications/DOCUMENTATION.md +10 -4
- package/server/lib/notifications/pi-notification-watcher.js +92 -33
- package/server/lib/notifications/pi-notification-watcher.test.js +79 -0
- package/server/lib/open-url/DOCUMENTATION.md +1 -0
- package/server/lib/pi/merged-event-stream.js +316 -0
- package/server/lib/pi/merged-event-stream.test.js +95 -0
- package/server/lib/pi/routes-daemon-pool.test.js +348 -0
- package/server/lib/pi/routes-merged-events.test.js +327 -0
- package/server/lib/pi/routes-sandbox.test.js +1684 -0
- package/server/lib/pi/routes.js +491 -90
- package/server/lib/pi/routes.test.js +87 -2
- package/server/lib/pi/sandbox/DOCUMENTATION.md +68 -0
- package/server/lib/pi/sandbox/launcher.js +122 -0
- package/server/lib/pi/sandbox/launcher.test.js +91 -0
- package/server/lib/pi/sandbox/nono-launcher.js +455 -0
- package/server/lib/pi/sandbox/nono-launcher.test.js +371 -0
- package/server/lib/pi/sandbox/nono-profile-macos.json +20 -0
- package/server/lib/pi/sandbox/nono-profile-wsl2.json +21 -0
- package/server/lib/pi/sandbox/nono-profile.json +22 -0
- package/server/lib/pi/sandbox/project-sandbox-manager.js +1461 -0
- package/server/lib/pi/sandbox/project-sandbox-setting.js +166 -0
- package/server/lib/pi/sandbox/project-sandbox.js +207 -0
- package/server/lib/pi/sandbox/sandbox-routes.js +110 -0
- package/server/lib/pi/sandbox/sandboxed-folders.js +100 -0
- package/server/lib/pi/sandbox/sandboxed-folders.test.js +65 -0
- package/server/lib/pi/sandbox/trust-ask.js +135 -0
- package/server/lib/pi/sandbox/trust-ask.test.js +54 -0
- package/server/lib/pi/sandbox/worktree-ids.js +96 -0
- package/server/lib/pi/sandbox/worktree-ids.test.js +73 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +26 -6
- package/server/lib/pi/session-daemon/daemon-pool.js +157 -0
- package/server/lib/pi/session-daemon/daemon-process.js +10 -1
- package/server/lib/pi/session-daemon/extension-config.js +206 -23
- package/server/lib/pi/session-daemon/extension-config.test.js +180 -0
- package/server/lib/pi/session-daemon/session-daemon-read-persisted.test.js +167 -0
- package/server/lib/pi/session-daemon/session-daemon.js +368 -56
- package/server/lib/pi/session-daemon/session-daemon.test.js +227 -0
- package/server/lib/pi/session-daemon/session-idle-residency.test.js +98 -1
- package/server/lib/pi/session-daemon/session-jsonl.js +49 -10
- package/server/lib/pi/session-daemon/session-jsonl.test.js +11 -0
- package/server/lib/pi/session-daemon/session-lease.js +93 -15
- package/server/lib/pi/session-daemon/session-lease.test.js +107 -1
- package/server/lib/pi/session-daemon/supervisor-launcher-stop.test.js +295 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox-nono.e2e.test.js +301 -0
- package/server/lib/pi/session-daemon/supervisor-sandbox.test.js +444 -0
- package/server/lib/pi/session-daemon/supervisor.js +386 -35
- package/server/lib/pi/session-daemon/supervisor.test.js +28 -0
- package/server/lib/pi/ui-settings-store.js +88 -2
- package/server/lib/pi/ui-settings-store.test.js +118 -0
- package/server/lib/plugins/DOCUMENTATION.md +17 -5
- package/server/lib/plugins/daemon-sync.js +16 -6
- package/server/lib/plugins/daemon-sync.test.js +12 -0
- package/server/lib/plugins/impact.test.js +2 -1
- package/server/lib/plugins/manifest.js +25 -0
- package/server/lib/plugins/manifest.test.js +9 -0
- package/server/lib/plugins/routes.test.js +28 -0
- package/server/lib/plugins/service.js +24 -2
- package/server/lib/server/cross-process-lock.js +28 -3
- package/dist/assets/SettingsView-BHBpt2Um.js +0 -7
- package/dist/assets/VisualFrame-CJrAvWSo.js +0 -22
- package/dist/assets/VisualsArtifact-DqLGgU-Q.js +0 -1
- package/dist/assets/index-B2v0_mez.js +0 -11
- package/dist/assets/index-D3F4JrPN.css +0 -1
- package/dist/assets/renderMobileApp-B7cT7m5b.js +0 -11
- package/dist/assets/runtimeEndpointReset-BC6yGnxN.js +0 -62
- package/dist/assets/useAppFontEffects-EcTZ_I_I.js +0 -225
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-
|
|
2
|
-
import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{d as f,h as v}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-C4JuoxsZ.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/index-CKKWVoND.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-B_L9GVYw.css","assets/pi-session-focus-preference-Cc_S4zi1.js","assets/useAppFontEffects-CV5UyTRw.js","assets/runtimeSurface-0K7vuUpd.js","assets/nativeFileSave-DSMsJqXM.js","assets/runtimeEndpointReset-Dwj-jCDS.js","assets/SessionUnreadDot-Dwc3MdvA.js","assets/permissionStore-zIpxq9Pq.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/SettingsView-DA-U9lsj.js","assets/vendor-qrcode-gzL9QFkg.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js","assets/collapsible-Bro9KrfM.js","assets/vendor-base-ui-DE6jnTiC.js","assets/useSwitcherItems-C8G5F0hs.js","assets/vendor-katex-css-Cp579UoJ.css","assets/main-DsLMU9CT.js","assets/fileTreeStatus-CyJ3TOYD.js","assets/contextFileOpenGuard-ByWK3Sru.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as m}from"./vendor-vite-runtime-DD1OZmLC.js";import{d as f,h as v}from"./index-CKKWVoND.js";import{r as h}from"./runtimeSurface-0K7vuUpd.js";/* empty css */import"./vendor-zustand-CXhN0IMY.js";import"./vendor-react-Bz1tRBxM.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";function g(e={}){const{immediate:t=!1,onNeedReload:r,onNeedRefresh:i,onOfflineReady:s,onRegistered:a,onRegisteredSW:d,onRegisterError:c}=e;let o,l;const p=async(n=!0)=>{await l};async function u(){if("serviceWorker"in navigator){if(o=await m(async()=>{const{Workbox:n}=await import("./vendor-workbox-window-BBnX5xw4.js");return{Workbox:n}},[]).then(({Workbox:n})=>new n("/sw.js",{scope:"/",type:"classic"})).catch(n=>{c?.(n)}),!o)return;o.addEventListener("activated",n=>{(n.isUpdate||n.isExternal)&&(r?r():window.location.reload())}),o.addEventListener("installed",n=>{n.isUpdate||s?.()}),o.register({immediate:t}).then(n=>{d?d("/sw.js",n):a?.(n)}).catch(n=>{c?.(n)})}}return l=u(),p}const w="--oc-viewport-bottom-strip";function y(e){const{innerWidth:t,innerHeight:r,screenWidth:i,screenHeight:s,safeAreaTop:a}=e;if(![t,r,i,s,a].every(Number.isFinite)||t<=0||r<=0||i<=0||s<=0)return null;if(a<=0)return 0;const d=r>=t,c=Math.max(i,s),o=Math.min(i,s),l=d?o:c,p=d?c:o;if(Math.abs(t-l)>1)return 0;const u=p-r;return u<=1?0:Math.abs(u-a)<=1?Math.round(u):null}const E=()=>{const e=document.createElement("div");e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;top:0;left:0;width:0;height:0;visibility:hidden;pointer-events:none;padding-top:env(safe-area-inset-top,0px)",document.body.appendChild(e);try{return Number.parseFloat(window.getComputedStyle(e).paddingTop)||0}finally{e.remove()}},S=()=>document.documentElement.classList.contains("oc-capacitor-app")||!window.CSS?.supports?.("-webkit-touch-callout","none")?!1:navigator.standalone===!0||window.matchMedia?.("(display-mode: standalone)")?.matches===!0;function _(){if(typeof window>"u"||typeof document>"u")return()=>{};if(!S())return()=>{};const e=document.documentElement,t=()=>{if(!document.body)return;const r=y({innerWidth:window.innerWidth,innerHeight:window.innerHeight,screenWidth:window.screen.width,screenHeight:window.screen.height,safeAreaTop:E()});r!==null&&(r>0?e.style.setProperty(w,`${r}px`):e.style.removeProperty(w))};return t(),document.body||document.addEventListener("DOMContentLoaded",t,{once:!0}),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),window.addEventListener("pageshow",t),window.visualViewport?.addEventListener("resize",t),()=>{document.removeEventListener("DOMContentLoaded",t),window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t),window.removeEventListener("pageshow",t),window.visualViewport?.removeEventListener("resize",t),e.style.removeProperty(w)}}const b=h();_();const L=()=>!(!("serviceWorker"in navigator)||!window.isSecureContext||window.location.protocol!=="http:"&&window.location.protocol!=="https:"||document.prerendering||String(document.visibilityState)==="prerender"),W=e=>{let t=!1;const r=()=>{t||L()&&(t=!0,e())},i=()=>{setTimeout(r,0)};document.readyState==="complete"?i():window.addEventListener("load",i,{once:!0}),(document.prerendering||String(document.visibilityState)==="prerender")&&document.addEventListener("visibilitychange",r,{once:!0})},R=()=>{W(()=>{try{g({onRegisterError(e){console.warn("[PWA] service worker registration skipped:",e)}})}catch(e){console.warn("[PWA] service worker registration skipped:",e)}})},P=async()=>{if(window.__PICHAMBER_RUNTIME_APIS__=f(),b==="mobile"){const{renderMobileApp:e}=await m(async()=>{const{renderMobileApp:t}=await import("./renderMobileApp-C4JuoxsZ.js");return{renderMobileApp:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]));e();return}await v(),await m(()=>import("./main-DsLMU9CT.js"),__vite__mapDeps([27,1,2,3,4,5,6,7,8,9,14,11,12,13,15,16,17,18,28,29,26]))};P();R();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentsSurface-
|
|
2
|
-
import{bi as $s,bj as Bt,bk as Pn,j as e,bl as Fs,bm as Ws,bn as zs,bo as Rn,bp as En,bq as Hs,br as Us,bs as Tn,bt as Dn,bu as An,bv as _n,bw as rs,bx as wt,b3 as os,aX as Mn}from"./vendor-boot-D-KEJjsM.js";import{R as n,a as Fe}from"./vendor-react-Bz1tRBxM.js";/* empty css */import{u as K,c as fe,r as Ot,a0 as In,q as Vs,a1 as Ln,b as Bn,f as Ks,B as On,N as $n,R as Ue,V as Fn,A as Be,W as Wn,T as zn,P as Hn,I as Xs,Z as Un,a2 as Vn,a3 as Kn,a4 as as,a5 as ft,k as is,z as Xn,v as qn,a6 as Yn,a7 as qs,w as Ys,a8 as Gn,a9 as Jn,aa as Qn,s as Zn,ab as er,y as tr,l as Gs,x as sr}from"./index-B2v0_mez.js";import{_ as Oe}from"./vendor-vite-runtime-DD1OZmLC.js";import{X as nr,ak as ls,al as rr,am as or,an as ar,ao as ir,ap as lr,aq as cr,ar as dr,as as ur,at as hr,au as fr,av as dt,aw as pr,ax as mr,ay as gr,az as xr,aA as br,aB as wr,aC as yr,aD as vr,aE as Js,aF as jr,aa as Sr,ab as kr,ac as Cr,ad as Nr,ae as Pr,aG as Qs,aH as Zs,aI as $t,Q as en,aJ as Rr,aK as Er,aL as Tr,Y as Dr,a9 as Ar,a6 as _r,a7 as Mr,_ as cs,a0 as ds,$ as us,S as hs,Z as Ir,a2 as Lr,a3 as Br,a5 as Or,a4 as $r,a8 as Fr}from"./runtimeEndpointReset-BC6yGnxN.js";import{ai as kt,I as W,aE as ze,N as xt,B as Q,aW as Ct,a0 as ct,t as xe,bY as Xt,x as Me,af as at,cS as Et,cT as Wr,D as Ft,ap as et,aq as tt,h as Wt,ar as st,i as zt,a1 as Qe,aY as tn,j as Nt,aZ as bt,bP as qt,f as fs,aj as zr,m as Yt,n as Gt,o as Jt,p as Qt,q as Zt,U as Hr,$ as Ur,cu as Vr,av as Kr,bR as sn,ak as Ze,cU as pt,C as nn,bn as Xr,cK as qr,cN as Ke,bO as rn,cV as Yr,cW as Gr,cM as es,cX as Jr,ax as on,k as ps,cY as Qr,w as ms,cZ as Zr,c_ as eo,c$ as to,d0 as gs,u as so,b as no,c as ro,d1 as oo,a as xs,aV as ao,r as Tt,bS as io,d2 as lo,d as co,cB as uo,cC as ho,cD as fo,cE as po,cF as ut,cG as ht,d3 as mo,g as go,d4 as xo,cA as bo,d5 as wo,d6 as yo,aP as vo,aQ as jo,aR as So,aG as ko,aF as Co,aI as No,aD as Po,cm as Ro,aH as Eo,cj as To,ck as Do,cl as Ao,aJ as _o,aK as Mo,aN as Io,aO as Lo}from"./useAppFontEffects-EcTZ_I_I.js";import{g as an,F as Bo,a as Oo,q as $o,f as Fo,h as Wo,j as zo,k as Ho,u as Uo,w as bs,m as ln,y as Vo}from"./fileTreeStatus-CnzR7kxA.js";import{v as cn,g as dn}from"./contextFileOpenGuard-DOK251YW.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./nativeFileSave-B6QpoPRn.js";import"./SessionUnreadDot-DyeIrsro.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./runtimeSurface-kIEoYsPP.js";const Ko=280,ws=4,Xo=({transform:t})=>({...t,y:0}),qo=({id:t,children:s,className:r})=>{const{attributes:a,listeners:i,setNodeRef:o,transform:u,transition:l,isDragging:c}=Hs({id:t});return e.jsx("div",{ref:o,"data-sortable-tab-id":t,style:{transform:Us.Transform.toString(u),transition:l},className:fe("h-full rounded-md",r,c&&"opacity-50"),...a,...i,children:s})},Yo=({id:t,children:s,className:r})=>e.jsx("div",{className:fe("h-full",r),"data-sortable-tab-id":t,children:s}),un=({items:t,activeId:s,onSelect:r,onClose:a,onReorder:i,layoutMode:o="scrollable",variant:u="default",activePillInsetClassName:l,activePillButtonClassName:c,inactiveTabsIconOnly:h=!1,animateActivePill:f,activePillLowercase:y=!0,nonCompositedIndicator:d=!1,className:b})=>{const p=K(B=>B.isMobile),{isTablet:C}=kt(),x=p||C,P=n.useRef(null),[_,U]=n.useState({left:!1,right:!1}),w=n.useMemo(()=>t.map(B=>B.id),[t]),E=o==="scrollable",S=u==="default",M=u==="active-pill",T=M||u==="animated",Y=S,X=T||Y,z=M&&E,Z=T,le=f??T,H=typeof i=="function",ne=H?qo:Yo,N=n.useRef(new Map),[F,oe]=n.useState(null),[D,O]=n.useState(!1),[G,ue]=n.useState(null),ge=n.useRef(!1),he=n.useRef(0),be=n.useRef(s),je=n.useRef(null),Ce=n.useMemo(()=>{if(!X||!G||!s||G===s)return 0;const B=t.findIndex(re=>re.id===G),J=t.findIndex(re=>re.id===s);return B<0||J<0?0:B>J?ws:-ws},[s,t,G,X]),ve=$s(Bt(Pn,{activationConstraint:{distance:8}})),ye=n.useCallback((B,J)=>!B||!J?B===J:Math.abs(B.left-J.left)<.5&&Math.abs(B.top-J.top)<.5&&Math.abs(B.width-J.width)<.5&&Math.abs(B.height-J.height)<.5,[]),Re=n.useCallback((B,J)=>{if(J){N.current.set(B,J);return}N.current.delete(B)},[]),Te=n.useCallback(()=>{if(!X||!s){oe(g=>g===null?g:null);return}const B=P.current,J=N.current.get(s);if(!B||!J){oe(g=>g===null?g:null);return}let re=0,L=0,ee=J;for(;ee&&ee!==B;)re+=ee.offsetLeft,L+=ee.offsetTop,ee=ee.offsetParent;const ae={left:re,top:L,width:J.offsetWidth,height:J.offsetHeight};oe(g=>ye(g,ae)?g:ae)},[s,ye,X]),Se=n.useCallback(()=>{if(!E){U({left:!1,right:!1});return}const B=P.current;if(!B){U({left:!1,right:!1});return}U({left:B.scrollLeft>2,right:B.scrollLeft+B.clientWidth<B.scrollWidth-2})},[E]);n.useEffect(()=>{if(!E){U({left:!1,right:!1});return}const B=P.current;if(!B)return;Se(),B.addEventListener("scroll",Se,{passive:!0});const J=new ResizeObserver(Se);return J.observe(B),()=>{B.removeEventListener("scroll",Se),J.disconnect()}},[E,t.length,Se]),n.useEffect(()=>{if(!E)return;const B=P.current;if(!B)return;const J=re=>{if(re.ctrlKey||Math.abs(re.deltaY)<=Math.abs(re.deltaX))return;const L=B.scrollWidth-B.clientWidth;if(L<=0)return;const ee=re.deltaMode===WheelEvent.DOM_DELTA_LINE?re.deltaY*16:re.deltaMode===WheelEvent.DOM_DELTA_PAGE?re.deltaY*B.clientWidth:re.deltaY;re.preventDefault(),B.scrollLeft=Math.min(L,Math.max(0,B.scrollLeft+ee))};return B.addEventListener("wheel",J,{passive:!1}),()=>{B.removeEventListener("wheel",J)}},[E]),n.useEffect(()=>{if(!X){oe(null);return}Te();const B=P.current;if(!B)return;const J=new ResizeObserver(()=>{performance.now()-he.current>Ko&&O(!1),Te()});if(J.observe(B),s){const re=N.current.get(s);re&&J.observe(re)}return()=>{J.disconnect()}},[s,t.length,Te,X]),n.useLayoutEffect(()=>{Te()});const ke=w.join("\0");n.useLayoutEffect(()=>{if(!X){ge.current=!1,O(!1);return}const B=je.current!==ke;if(je.current=ke,!ge.current){ge.current=!0,be.current=s;return}const J=be.current!==s;if(be.current=s,!J||B){O(!1);return}he.current=performance.now(),O(!0)},[s,ke,X]),n.useEffect(()=>{if(!E||!s)return;const B=P.current;if(!B)return;const J=window.requestAnimationFrame(()=>{const re=typeof window.CSS?.escape=="function"?window.CSS.escape(s):s.replace(/"/g,'\\"'),L=B.querySelector(`[data-sortable-tab-id="${re}"]`);L&&(L.scrollIntoView({block:"nearest",inline:"nearest"}),Se())});return()=>{window.cancelAnimationFrame(J)}},[s,E,t.length,Se]);const Ne=n.useCallback(B=>{if(!i)return;const{active:J,over:re}=B;!re||J.id===re.id||i(String(J.id),String(re.id))},[i]),De=e.jsxs("div",{className:fe("relative flex h-full min-w-0 flex-1",b),children:[E&&_.left?e.jsx("div",{className:fe("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",T?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,E&&_.right?e.jsx("div",{className:fe("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",T?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e.jsxs("div",{ref:P,className:fe("relative flex h-full min-w-0 flex-1",T?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",T&&"@container/pill-tabs",T&&"pill-tabs__track",T&&(l??"gap-0.5 py-0.5"),Y&&"items-center overflow-y-hidden",Z&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",E?"overflow-x-auto scrollbar-none":"overflow-x-hidden"),style:E?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,role:"tablist","aria-label":"Tabs",children:[T&&F?e.jsx("div",{className:fe("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",le&&D&&(d?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:d?{left:`${F.left+Ce}px`,top:`${F.top}px`,width:`${F.width}px`,height:`${F.height}px`}:{transform:`translate3d(${F.left+Ce}px, ${F.top}px, 0)`,width:`${F.width}px`,height:`${F.height}px`}}):null,Y&&F?e.jsx("div",{className:fe("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",D&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${F.left+Ce}px, 0, 0)`,width:`${F.width}px`},"aria-hidden":!0}):null,t.map(B=>{const J=B.id===s,re=h&&T&&!J&&!!B.icon,L=!re,ee=!!B.icon,ae=h&&T&&J&&!E&&!z,g=B.closable!==!1&&!!a,A=g&&!!B.icon,te=E||z?void 0:T?ae?"flex-none basis-auto":p?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",de=g?V=>{V.button===1&&(V.preventDefault(),V.stopPropagation(),a?.(B.id))}:void 0,m=g?V=>{V.button===1&&V.preventDefault()}:void 0,I=V=>ee?e.jsxs("span",{className:V,children:[e.jsx("span",{className:fe("flex items-center justify-center transition-opacity",A&&(x?"opacity-0":"group-hover:opacity-0")),children:B.icon}),A?e.jsx("span",{role:"button",tabIndex:-1,className:fe("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",x?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:pe=>pe.stopPropagation(),onClick:pe=>{pe.stopPropagation(),a?.(B.id)},"aria-label":B.closeLabel??`Close ${B.label} tab`,title:B.closeLabel??`Close ${B.label} tab`,children:e.jsx(W,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null;return e.jsx(ne,{id:B.id,className:te,children:e.jsxs("div",{ref:V=>Re(B.id,V),onAuxClick:de,onMouseDown:m,className:fe("group flex h-full min-w-0 flex-nowrap items-center",E||z?"shrink-0":T?"w-full":"w-full min-w-0",T?"relative z-10 bg-transparent":J?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx("button",{type:"button",role:"tab","aria-selected":J,"aria-label":re?B.title??B.label:void 0,onClick:()=>r(B.id),onPointerDown:X?()=>{O(!0),ue(B.id)}:void 0,onPointerUp:X?()=>ue(null):void 0,onPointerLeave:X?()=>ue(null):void 0,onPointerCancel:X?()=>ue(null):void 0,className:fe(T?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",T&&y?"lowercase":null,T&&(re?"gap-0":"gap-1.5"),T?z?"shrink-0 whitespace-nowrap px-3 text-center":E?"max-w-56 shrink-0 px-3 text-center":re?"px-2 !min-w-0 text-center":ae?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":E?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",T?c??(M?p?"h-[38px]":"h-[31px]":"h-7"):null,T?J?"text-foreground":"text-muted-foreground hover:text-foreground":null,T?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:B.title??B.label,children:T?e.jsxs(e.Fragment,{children:[I("relative flex h-4 w-4 shrink-0 items-center justify-center"),L?e.jsx("span",{className:"animated-tabs__label truncate",children:B.label}):null]}):e.jsxs("span",{className:fe("flex min-w-0 flex-nowrap items-center gap-1.5",!E&&"justify-center"),children:[I(fe("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",J?"text-[var(--primary-base)]":"text-muted-foreground")),e.jsx("span",{className:"truncate leading-[1.2]",children:B.label})]})}),g&&!A?e.jsx("button",{type:"button",onPointerDown:V=>{V.stopPropagation()},onClick:V=>{V.stopPropagation(),a?.(B.id)},className:fe("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",T?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",T?J?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":J?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":B.closeLabel??`Close ${B.label} tab`,title:B.closeLabel??`Close ${B.label} tab`,children:e.jsx(W,{name:"close",className:"h-3 w-3"})}):null]})},B.id)})]})]});return H?e.jsxs(Fs,{sensors:ve,collisionDetection:Ws,onDragEnd:Ne,modifiers:[Xo],children:[e.jsx(zs,{items:w,strategy:Rn,children:De}),e.jsx(En,{dropAnimation:null})]}):De},ys=280,vs=280,js=500,Go=({isOpen:t,isMobile:s,children:r,className:a,topBar:i})=>{const o=K(j=>j.sidebarWidth),u=K(j=>j.setSidebarWidth),[l,c]=n.useState(!1),h=n.useRef(0),f=n.useRef(o||ys),y=n.useRef(null),d=n.useRef(null),b=n.useRef(null),p=n.useCallback(j=>Math.min(js,Math.max(vs,j)),[]),C=n.useCallback(j=>{const T=b.current;T&&(T.style.width=`${j}px`,T.style.minWidth=`${j}px`,T.style.maxWidth=`${j}px`,T.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);n.useEffect(()=>{s&&l&&c(!1)},[s,l]),n.useEffect(()=>{l||(y.current=null,d.current=null)},[l]);const x=nr(t);if(s)return null;const P=Math.min(js,Math.max(vs,o||ys)),_=x.layoutVisible?P:0,U=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}d.current=j.pointerId,c(!0),h.current=j.clientX,f.current=_,y.current=_,C(_),j.preventDefault()}},w=j=>{if(s||!l||d.current!==j.pointerId)return;const T=j.clientX-h.current,Y=p(f.current+T);y.current!==Y&&(y.current=Y,C(Y))},E=j=>{if(d.current!==j.pointerId||s)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const T=p(y.current??_);d.current=null,y.current=null,c(!1),u(T)},S=l?y.current??_:_,M=l?S:_;return e.jsxs("aside",{ref:b,className:fe("relative flex h-full overflow-hidden motion-reduce:transition-none","bg-sidebar",a),style:{width:`${M}px`,minWidth:`${M}px`,maxWidth:`${M}px`,"--oc-left-sidebar-width":`${l?S:P}px`,overflowX:"clip",transform:l||x.slidIn?"translateX(0)":"translateX(-100%)",transition:l?"none":x.transition},"aria-hidden":!t||M===0,children:[t&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&e.jsx("div",{className:fe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",l&&"bg-[var(--interactive-border)]"),onPointerDown:U,onPointerMove:w,onPointerUp:E,onPointerCancel:E,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:fe("relative z-10 flex h-full shrink-0 flex-col",l&&"pointer-events-none",!t&&"pointer-events-none select-none"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(ze,{children:r})})]})]})},Jo=t=>{if(!t||typeof t!="object")return!1;const s=t;return typeof s.x=="number"&&typeof s.y=="number"},Ss=t=>!t||typeof t!="object"?!1:Object.values(t).every(s=>typeof s=="string"),it=t=>{if(!t||typeof t!="object")return!1;const s=t,r=s.bounds;return typeof s.tag=="string"&&typeof s.text=="string"&&typeof s.selector=="string"&&typeof s.path=="string"&&!!r&&typeof r?.x=="number"&&typeof r?.y=="number"&&typeof r?.width=="number"&&typeof r?.height=="number"&&Jo(s.center)&&Ss(s.attributes)&&Ss(s.computedStyle)&&Array.isArray(s.ancestry)},Pt=({pageUrl:t,viewport:s,devicePixelRatio:r,target:a,screenshotAttached:i,intro:o})=>{const u=a.text.trim(),l=Object.entries(a.attributes).map(([b,p])=>`${b}="${p}"`).join(" "),c=a.computedStyle,h=a.bounds,f=a.center,y=o.replace(/[.:]+$/g,""),d=a.ancestry.map(b=>b.selectorPart).join(" > ");return[`${y}:`,`Page: ${t||"preview"}`,`Viewport: ${s.width}x${s.height}, DPR ${r}`,`Screenshot: ${i?"attached":"not attached"}`,`Element: ${a.tag}`,u?`Text: ${u}`:null,`- Selector: ${a.selector}`,`- Path: ${a.path}`,d?`- Ancestry: ${d}`:null,l?`- Attributes: ${l}`:null,`- Bounds: x=${Math.round(h.x)}, y=${Math.round(h.y)}, width=${Math.round(h.width)}, height=${Math.round(h.height)}`,`- Center: x=${Math.round(f.x)}, y=${Math.round(f.y)}`,`Styles: display=${c.display}; position=${c.position}; font=${c.fontWeight} ${c.fontSize} / ${c.lineHeight} ${c.fontFamily}; color=${c.color}; background=${c.backgroundColor}; z-index=${c.zIndex}`].filter(b=>typeof b=="string").join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/AgentsSurface-CcWBqAWV.js","assets/vendor-boot-D-KEJjsM.js","assets/vendor-react-Bz1tRBxM.js","assets/vendor-clsx-B-dksMZM.js","assets/useAppFontEffects-CV5UyTRw.js","assets/index-CKKWVoND.js","assets/vendor-zustand-CXhN0IMY.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-BKkUfl9q.js","assets/vendor-fuse.js-t_7AcMTv.js","assets/index-B_L9GVYw.css","assets/runtimeSurface-0K7vuUpd.js","assets/nativeFileSave-DSMsJqXM.js","assets/selection-CnYkEsu_.js","assets/DiffView-CiZy4jFA.js","assets/gitStatusPredicates-BsXrwngT.js","assets/VirtualizedFileDiff-BGZiLPe_.js","assets/web-components-BpncHjnV.js","assets/computeVirtualFileMetrics-DJQqK49u.js","assets/vendor-shiki-BEwTOAFg.js","assets/vendor-shikijs-core-Ck_OPM_T.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-DPFxvYtK.js","assets/vendor-hast-util-to-html-O3stl53j.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-C40bX6nM.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-DrfmQi8i.js","assets/vendor-pierre-theming-BO6EPniU.js","assets/vendor-shikijs-engine-javascript-DL394yyj.js","assets/vendor-oniguruma-to-es-DgwFOwdE.js","assets/vendor-oniguruma-parser-BrbMHgHx.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/renderDiffWithHighlighter-BXhnIAHg.js","assets/vendor-diff-C3JhlQdm.js","assets/PierreDiffViewer-UY7Cse-s.js","assets/StickyHorizontalScrollbar-CMbTn5WQ.js","assets/runtimeEndpointReset-Dwj-jCDS.js","assets/SessionUnreadDot-Dwc3MdvA.js","assets/permissionStore-zIpxq9Pq.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/appThemeRegistry-Ca8eGRB9.js","assets/registerCustomTheme-C-h6lsYW.js","assets/contextFileOpenGuard-ByWK3Sru.js","assets/FilesView-DqiZ9kw9.js","assets/vendor-codemirror-lang-javascript-DF3GDYje.js","assets/vendor-lezer-javascript-CUdJ0VGA.js","assets/vendor-lezer-lr-DluApmOX.js","assets/vendor-codemirror-autocomplete-BKvJ8PfM.js","assets/vendor-codemirror-lang-json-DCqvG1nE.js","assets/vendor-lezer-json-BKYAA8Hu.js","assets/vendor-codemirror-lang-css-DoEEdEpW.js","assets/vendor-lezer-css-DRxDmhcy.js","assets/vendor-codemirror-lang-html-h25V-Hp5.js","assets/vendor-lezer-html-qr9pUPmM.js","assets/vendor-codemirror-lang-markdown-6BNbCEPe.js","assets/vendor-lezer-markdown-B-uzYzYT.js","assets/vendor-codemirror-language-data-BUZIlm3G.js","assets/vendor-codemirror-lang-python-DQym-8Tx.js","assets/vendor-lezer-python-Bj232yb5.js","assets/shell-CjFT_Tl9.js","assets/FileSaveConflictDialog-DZ9NDwOO.js","assets/vendor-react-drawio-IYnLUY5N.js","assets/fileTreeStatus-CyJ3TOYD.js","assets/JsonTreeView-_yMHKKQZ.js","assets/Virtualizer-PxblpQn6.js","assets/renderFileWithHighlighter-CK29YZtC.js","assets/vendor-codemirror-search-BlDCaCMK.js","assets/vendor-replit-codemirror-vim-Cvk64got.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/GitView--EaZQrBr.js","assets/GitHubDetailScaffold-DM2DH7o8.js","assets/vendor-dompurify-BGCr_sdL.js","assets/collapsible-Bro9KrfM.js","assets/vendor-base-ui-DE6jnTiC.js","assets/PullRequestsSurface-iXy6chwc.js","assets/useGitHubRemoteSearch-CgP-zEBj.js","assets/GitHubListPrimitives-CibDiJGq.js","assets/IssuesSurface-CySTpaD1.js","assets/githubLink-g2bmC0qi.js","assets/DiagramView-DZUBo1uP.js","assets/SettingsView-DA-U9lsj.js","assets/vendor-qrcode-gzL9QFkg.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/vendor-aparajita-capacitor-secure-storage-DUoR8t1G.js","assets/SettingsWindow-CUg49Mfh.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{bi as $s,bj as Bt,bk as Pn,j as e,bl as Fs,bm as Ws,bn as zs,bo as Rn,bp as En,bq as Hs,br as Us,bs as Tn,bt as Dn,bu as An,bv as _n,bw as rs,bx as wt,b3 as os,aX as Mn}from"./vendor-boot-D-KEJjsM.js";import{R as n,a as Fe}from"./vendor-react-Bz1tRBxM.js";/* empty css */import{u as K,c as fe,r as Ot,a0 as In,q as Vs,a1 as Ln,b as Bn,f as Ks,B as On,N as $n,R as Ue,V as Fn,A as Be,W as Wn,T as zn,P as Hn,I as Xs,Z as Un,a2 as Vn,a3 as Kn,a4 as as,a5 as ft,k as is,z as Xn,v as qn,a6 as Yn,a7 as qs,w as Ys,a8 as Gn,a9 as Jn,aa as Qn,s as Zn,ab as er,y as tr,l as Gs,x as sr}from"./index-CKKWVoND.js";import{_ as Oe}from"./vendor-vite-runtime-DD1OZmLC.js";import{Y as nr,al as ls,am as rr,an as or,ao as ar,ap as ir,aq as lr,ar as cr,as as dr,at as ur,au as hr,av as fr,aw as dt,ax as pr,ay as mr,az as gr,aA as xr,aB as br,aC as wr,aD as yr,aE as vr,aF as Js,aG as jr,ab as Sr,ac as kr,ad as Cr,ae as Nr,af as Pr,aH as Qs,aI as Zs,aJ as $t,R as en,aK as Rr,aL as Er,aM as Tr,Z as Dr,aa as Ar,a7 as _r,a8 as Mr,$ as cs,a1 as ds,a0 as us,P as hs,_ as Ir,a3 as Lr,a4 as Br,a6 as Or,a5 as $r,a9 as Fr}from"./runtimeEndpointReset-Dwj-jCDS.js";import{ai as kt,I as W,aE as ze,N as xt,B as Q,aW as Ct,a2 as ct,t as xe,bY as Xt,x as Me,af as at,cS as Et,cT as Wr,D as Ft,ap as et,aq as tt,h as Wt,ar as st,i as zt,a0 as Qe,aY as tn,j as Nt,aZ as bt,bP as qt,f as fs,aj as zr,m as Yt,n as Gt,o as Jt,p as Qt,q as Zt,U as Hr,$ as Ur,cu as Vr,av as Kr,bR as sn,ak as Ze,cU as pt,C as nn,bn as Xr,cK as qr,cN as Ke,bO as rn,cV as Yr,cW as Gr,cM as es,cX as Jr,ax as on,k as ps,cY as Qr,w as ms,cZ as Zr,c_ as eo,c$ as to,d0 as gs,u as so,b as no,c as ro,d1 as oo,a as xs,aV as ao,r as Tt,bS as io,d2 as lo,d as co,cB as uo,cC as ho,cD as fo,cE as po,cF as ut,cG as ht,d3 as mo,g as go,d4 as xo,cA as bo,d5 as wo,d6 as yo,aP as vo,aQ as jo,aR as So,aG as ko,aF as Co,aI as No,aD as Po,cm as Ro,aH as Eo,cj as To,ck as Do,cl as Ao,aJ as _o,aK as Mo,aN as Io,aO as Lo}from"./useAppFontEffects-CV5UyTRw.js";import{g as an,F as Bo,a as Oo,q as $o,f as Fo,h as Wo,j as zo,k as Ho,u as Uo,w as bs,m as ln,y as Vo}from"./fileTreeStatus-CyJ3TOYD.js";import{v as cn,g as dn}from"./contextFileOpenGuard-ByWK3Sru.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./nativeFileSave-DSMsJqXM.js";import"./SessionUnreadDot-Dwc3MdvA.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./runtimeSurface-0K7vuUpd.js";const Ko=280,ws=4,Xo=({transform:t})=>({...t,y:0}),qo=({id:t,children:s,className:r})=>{const{attributes:a,listeners:i,setNodeRef:o,transform:u,transition:l,isDragging:c}=Hs({id:t});return e.jsx("div",{ref:o,"data-sortable-tab-id":t,style:{transform:Us.Transform.toString(u),transition:l},className:fe("h-full rounded-md",r,c&&"opacity-50"),...a,...i,children:s})},Yo=({id:t,children:s,className:r})=>e.jsx("div",{className:fe("h-full",r),"data-sortable-tab-id":t,children:s}),un=({items:t,activeId:s,onSelect:r,onClose:a,onReorder:i,layoutMode:o="scrollable",variant:u="default",activePillInsetClassName:l,activePillButtonClassName:c,inactiveTabsIconOnly:h=!1,animateActivePill:f,activePillLowercase:y=!0,nonCompositedIndicator:d=!1,className:b})=>{const p=K(B=>B.isMobile),{isTablet:C}=kt(),x=p||C,P=n.useRef(null),[_,U]=n.useState({left:!1,right:!1}),w=n.useMemo(()=>t.map(B=>B.id),[t]),E=o==="scrollable",S=u==="default",M=u==="active-pill",T=M||u==="animated",Y=S,X=T||Y,z=M&&E,Z=T,le=f??T,H=typeof i=="function",ne=H?qo:Yo,N=n.useRef(new Map),[F,oe]=n.useState(null),[D,O]=n.useState(!1),[G,ue]=n.useState(null),ge=n.useRef(!1),he=n.useRef(0),be=n.useRef(s),je=n.useRef(null),Ce=n.useMemo(()=>{if(!X||!G||!s||G===s)return 0;const B=t.findIndex(re=>re.id===G),J=t.findIndex(re=>re.id===s);return B<0||J<0?0:B>J?ws:-ws},[s,t,G,X]),ve=$s(Bt(Pn,{activationConstraint:{distance:8}})),ye=n.useCallback((B,J)=>!B||!J?B===J:Math.abs(B.left-J.left)<.5&&Math.abs(B.top-J.top)<.5&&Math.abs(B.width-J.width)<.5&&Math.abs(B.height-J.height)<.5,[]),Re=n.useCallback((B,J)=>{if(J){N.current.set(B,J);return}N.current.delete(B)},[]),Te=n.useCallback(()=>{if(!X||!s){oe(g=>g===null?g:null);return}const B=P.current,J=N.current.get(s);if(!B||!J){oe(g=>g===null?g:null);return}let re=0,L=0,ee=J;for(;ee&&ee!==B;)re+=ee.offsetLeft,L+=ee.offsetTop,ee=ee.offsetParent;const ae={left:re,top:L,width:J.offsetWidth,height:J.offsetHeight};oe(g=>ye(g,ae)?g:ae)},[s,ye,X]),Se=n.useCallback(()=>{if(!E){U({left:!1,right:!1});return}const B=P.current;if(!B){U({left:!1,right:!1});return}U({left:B.scrollLeft>2,right:B.scrollLeft+B.clientWidth<B.scrollWidth-2})},[E]);n.useEffect(()=>{if(!E){U({left:!1,right:!1});return}const B=P.current;if(!B)return;Se(),B.addEventListener("scroll",Se,{passive:!0});const J=new ResizeObserver(Se);return J.observe(B),()=>{B.removeEventListener("scroll",Se),J.disconnect()}},[E,t.length,Se]),n.useEffect(()=>{if(!E)return;const B=P.current;if(!B)return;const J=re=>{if(re.ctrlKey||Math.abs(re.deltaY)<=Math.abs(re.deltaX))return;const L=B.scrollWidth-B.clientWidth;if(L<=0)return;const ee=re.deltaMode===WheelEvent.DOM_DELTA_LINE?re.deltaY*16:re.deltaMode===WheelEvent.DOM_DELTA_PAGE?re.deltaY*B.clientWidth:re.deltaY;re.preventDefault(),B.scrollLeft=Math.min(L,Math.max(0,B.scrollLeft+ee))};return B.addEventListener("wheel",J,{passive:!1}),()=>{B.removeEventListener("wheel",J)}},[E]),n.useEffect(()=>{if(!X){oe(null);return}Te();const B=P.current;if(!B)return;const J=new ResizeObserver(()=>{performance.now()-he.current>Ko&&O(!1),Te()});if(J.observe(B),s){const re=N.current.get(s);re&&J.observe(re)}return()=>{J.disconnect()}},[s,t.length,Te,X]),n.useLayoutEffect(()=>{Te()});const ke=w.join("\0");n.useLayoutEffect(()=>{if(!X){ge.current=!1,O(!1);return}const B=je.current!==ke;if(je.current=ke,!ge.current){ge.current=!0,be.current=s;return}const J=be.current!==s;if(be.current=s,!J||B){O(!1);return}he.current=performance.now(),O(!0)},[s,ke,X]),n.useEffect(()=>{if(!E||!s)return;const B=P.current;if(!B)return;const J=window.requestAnimationFrame(()=>{const re=typeof window.CSS?.escape=="function"?window.CSS.escape(s):s.replace(/"/g,'\\"'),L=B.querySelector(`[data-sortable-tab-id="${re}"]`);L&&(L.scrollIntoView({block:"nearest",inline:"nearest"}),Se())});return()=>{window.cancelAnimationFrame(J)}},[s,E,t.length,Se]);const Ne=n.useCallback(B=>{if(!i)return;const{active:J,over:re}=B;!re||J.id===re.id||i(String(J.id),String(re.id))},[i]),De=e.jsxs("div",{className:fe("relative flex h-full min-w-0 flex-1",b),children:[E&&_.left?e.jsx("div",{className:fe("pointer-events-none absolute inset-y-0 left-0 z-20 bg-gradient-to-r to-transparent",T?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,E&&_.right?e.jsx("div",{className:fe("pointer-events-none absolute inset-y-0 right-0 z-20 bg-gradient-to-l to-transparent",T?"w-8 from-[var(--surface-background)]":"w-6 from-background")}):null,e.jsxs("div",{ref:P,className:fe("relative flex h-full min-w-0 flex-1",T?"items-center overflow-x-hidden overflow-y-hidden":"items-stretch",T&&"@container/pill-tabs",T&&"pill-tabs__track",T&&(l??"gap-0.5 py-0.5"),Y&&"items-center overflow-y-hidden",Z&&"rounded-[10px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[color-mix(in_srgb,var(--foreground)_4%,transparent)] p-0.5 gap-0.5",E?"overflow-x-auto scrollbar-none":"overflow-x-hidden"),style:E?{scrollbarWidth:"none",msOverflowStyle:"none"}:void 0,role:"tablist","aria-label":"Tabs",children:[T&&F?e.jsx("div",{className:fe("pointer-events-none absolute left-0 top-0 z-0 rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] bg-[var(--surface-elevated)]","border border-[color-mix(in_srgb,var(--foreground)_7%,transparent)]","shadow-[0_1px_2px_color-mix(in_srgb,var(--foreground)_10%,transparent),0_2px_6px_color-mix(in_srgb,var(--foreground)_6%,transparent)]",le&&D&&(d?"pill-tabs__indicator--is-animated-layout":"pill-tabs__indicator--is-animated")),style:d?{left:`${F.left+Ce}px`,top:`${F.top}px`,width:`${F.width}px`,height:`${F.height}px`}:{transform:`translate3d(${F.left+Ce}px, ${F.top}px, 0)`,width:`${F.width}px`,height:`${F.height}px`}}):null,Y&&F?e.jsx("div",{className:fe("pointer-events-none absolute left-0 -bottom-px z-10 h-[3px] rounded-t-[2px] bg-[var(--primary-base)]",D&&"underline-tabs__indicator--is-animated"),style:{transform:`translate3d(${F.left+Ce}px, 0, 0)`,width:`${F.width}px`},"aria-hidden":!0}):null,t.map(B=>{const J=B.id===s,re=h&&T&&!J&&!!B.icon,L=!re,ee=!!B.icon,ae=h&&T&&J&&!E&&!z,g=B.closable!==!1&&!!a,A=g&&!!B.icon,te=E||z?void 0:T?ae?"flex-none basis-auto":p?"flex-1 basis-0 min-w-0":"flex-1 basis-0 min-w-fit":"min-w-0 flex-1 basis-0",de=g?V=>{V.button===1&&(V.preventDefault(),V.stopPropagation(),a?.(B.id))}:void 0,m=g?V=>{V.button===1&&V.preventDefault()}:void 0,I=V=>ee?e.jsxs("span",{className:V,children:[e.jsx("span",{className:fe("flex items-center justify-center transition-opacity",A&&(x?"opacity-0":"group-hover:opacity-0")),children:B.icon}),A?e.jsx("span",{role:"button",tabIndex:-1,className:fe("absolute inset-0 z-20 flex !min-h-0 !min-w-0 items-center justify-center rounded-sm text-muted-foreground transition-opacity hover:text-foreground",x?"opacity-100":"opacity-0 group-hover:opacity-100"),onPointerDown:pe=>pe.stopPropagation(),onClick:pe=>{pe.stopPropagation(),a?.(B.id)},"aria-label":B.closeLabel??`Close ${B.label} tab`,title:B.closeLabel??`Close ${B.label} tab`,children:e.jsx(W,{name:"close",className:"h-3.5 w-3.5"})}):null]}):null;return e.jsx(ne,{id:B.id,className:te,children:e.jsxs("div",{ref:V=>Re(B.id,V),onAuxClick:de,onMouseDown:m,className:fe("group flex h-full min-w-0 flex-nowrap items-center",E||z?"shrink-0":T?"w-full":"w-full min-w-0",T?"relative z-10 bg-transparent":J?"relative z-10 bg-transparent text-foreground":"relative z-10 bg-transparent text-muted-foreground hover:text-foreground"),children:[e.jsx("button",{type:"button",role:"tab","aria-selected":J,"aria-label":re?B.title??B.label:void 0,onClick:()=>r(B.id),onPointerDown:X?()=>{O(!0),ue(B.id)}:void 0,onPointerUp:X?()=>ue(null):void 0,onPointerLeave:X?()=>ue(null):void 0,onPointerCancel:X?()=>ue(null):void 0,className:fe(T?"animated-tabs__button pill-tabs__button relative z-10 flex flex-1 min-w-0 flex-nowrap items-center justify-center rounded-[9px] [corner-shape:squircle] supports-[corner-shape:squircle]:rounded-[50px] text-sm font-medium transition-colors duration-150 !min-h-0":"flex h-full min-w-0 flex-nowrap items-center typography-micro",T&&y?"lowercase":null,T&&(re?"gap-0":"gap-1.5"),T?z?"shrink-0 whitespace-nowrap px-3 text-center":E?"max-w-56 shrink-0 px-3 text-center":re?"px-2 !min-w-0 text-center":ae?"shrink-0 whitespace-nowrap px-3 text-center":"px-3 text-center":E?"max-w-56 justify-start truncate px-3 text-left":"w-full justify-center truncate px-3 text-center",T?c??(M?p?"h-[38px]":"h-[31px]":"h-7"):null,T?J?"text-foreground":"text-muted-foreground hover:text-foreground":null,T?"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background":null),title:B.title??B.label,children:T?e.jsxs(e.Fragment,{children:[I("relative flex h-4 w-4 shrink-0 items-center justify-center"),L?e.jsx("span",{className:"animated-tabs__label truncate",children:B.label}):null]}):e.jsxs("span",{className:fe("flex min-w-0 flex-nowrap items-center gap-1.5",!E&&"justify-center"),children:[I(fe("relative flex h-4 w-4 shrink-0 items-center justify-center transition-colors duration-200 ease-out",J?"text-[var(--primary-base)]":"text-muted-foreground")),e.jsx("span",{className:"truncate leading-[1.2]",children:B.label})]})}),g&&!A?e.jsx("button",{type:"button",onPointerDown:V=>{V.stopPropagation()},onClick:V=>{V.stopPropagation(),a?.(B.id)},className:fe("relative z-20 inline-flex !min-h-0 !min-w-0 items-center justify-center transition-opacity",T?"-ml-2.5 mr-1 h-[88%] w-5 self-center !aspect-auto rounded-md":"aspect-square h-[65%] min-h-4 max-h-5 rounded-sm mr-1",T?J?"text-muted-foreground hover:bg-transparent hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-transparent hover:text-foreground group-hover:opacity-100":J?"text-muted-foreground hover:bg-interactive-hover/60 hover:text-foreground":"text-muted-foreground opacity-0 hover:bg-interactive-hover/80 hover:text-foreground group-hover:opacity-100"),"aria-label":B.closeLabel??`Close ${B.label} tab`,title:B.closeLabel??`Close ${B.label} tab`,children:e.jsx(W,{name:"close",className:"h-3 w-3"})}):null]})},B.id)})]})]});return H?e.jsxs(Fs,{sensors:ve,collisionDetection:Ws,onDragEnd:Ne,modifiers:[Xo],children:[e.jsx(zs,{items:w,strategy:Rn,children:De}),e.jsx(En,{dropAnimation:null})]}):De},ys=280,vs=280,js=500,Go=({isOpen:t,isMobile:s,children:r,className:a,topBar:i})=>{const o=K(j=>j.sidebarWidth),u=K(j=>j.setSidebarWidth),[l,c]=n.useState(!1),h=n.useRef(0),f=n.useRef(o||ys),y=n.useRef(null),d=n.useRef(null),b=n.useRef(null),p=n.useCallback(j=>Math.min(js,Math.max(vs,j)),[]),C=n.useCallback(j=>{const T=b.current;T&&(T.style.width=`${j}px`,T.style.minWidth=`${j}px`,T.style.maxWidth=`${j}px`,T.style.setProperty("--oc-left-sidebar-width",`${j}px`))},[]);n.useEffect(()=>{s&&l&&c(!1)},[s,l]),n.useEffect(()=>{l||(y.current=null,d.current=null)},[l]);const x=nr(t);if(s)return null;const P=Math.min(js,Math.max(vs,o||ys)),_=x.layoutVisible?P:0,U=j=>{if(t){try{j.currentTarget.setPointerCapture(j.pointerId)}catch{}d.current=j.pointerId,c(!0),h.current=j.clientX,f.current=_,y.current=_,C(_),j.preventDefault()}},w=j=>{if(s||!l||d.current!==j.pointerId)return;const T=j.clientX-h.current,Y=p(f.current+T);y.current!==Y&&(y.current=Y,C(Y))},E=j=>{if(d.current!==j.pointerId||s)return;try{j.currentTarget.releasePointerCapture(j.pointerId)}catch{}const T=p(y.current??_);d.current=null,y.current=null,c(!1),u(T)},S=l?y.current??_:_,M=l?S:_;return e.jsxs("aside",{ref:b,className:fe("relative flex h-full overflow-hidden motion-reduce:transition-none","bg-sidebar",a),style:{width:`${M}px`,minWidth:`${M}px`,maxWidth:`${M}px`,"--oc-left-sidebar-width":`${l?S:P}px`,overflowX:"clip",transform:l||x.slidIn?"translateX(0)":"translateX(-100%)",transition:l?"none":x.transition},"aria-hidden":!t||M===0,children:[t&&e.jsx("div",{className:"pointer-events-none absolute inset-0 z-30 shadow-[inset_-2px_0_10px_-2px_rgb(0_0_0_/_0.06)]","aria-hidden":"true"}),t&&e.jsx("div",{className:fe("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",l&&"bg-[var(--interactive-border)]"),onPointerDown:U,onPointerMove:w,onPointerUp:E,onPointerCancel:E,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:fe("relative z-10 flex h-full shrink-0 flex-col",l&&"pointer-events-none",!t&&"pointer-events-none select-none"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[i,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(ze,{children:r})})]})]})},Jo=t=>{if(!t||typeof t!="object")return!1;const s=t;return typeof s.x=="number"&&typeof s.y=="number"},Ss=t=>!t||typeof t!="object"?!1:Object.values(t).every(s=>typeof s=="string"),it=t=>{if(!t||typeof t!="object")return!1;const s=t,r=s.bounds;return typeof s.tag=="string"&&typeof s.text=="string"&&typeof s.selector=="string"&&typeof s.path=="string"&&!!r&&typeof r?.x=="number"&&typeof r?.y=="number"&&typeof r?.width=="number"&&typeof r?.height=="number"&&Jo(s.center)&&Ss(s.attributes)&&Ss(s.computedStyle)&&Array.isArray(s.ancestry)},Pt=({pageUrl:t,viewport:s,devicePixelRatio:r,target:a,screenshotAttached:i,intro:o})=>{const u=a.text.trim(),l=Object.entries(a.attributes).map(([b,p])=>`${b}="${p}"`).join(" "),c=a.computedStyle,h=a.bounds,f=a.center,y=o.replace(/[.:]+$/g,""),d=a.ancestry.map(b=>b.selectorPart).join(" > ");return[`${y}:`,`Page: ${t||"preview"}`,`Viewport: ${s.width}x${s.height}, DPR ${r}`,`Screenshot: ${i?"attached":"not attached"}`,`Element: ${a.tag}`,u?`Text: ${u}`:null,`- Selector: ${a.selector}`,`- Path: ${a.path}`,d?`- Ancestry: ${d}`:null,l?`- Attributes: ${l}`:null,`- Bounds: x=${Math.round(h.x)}, y=${Math.round(h.y)}, width=${Math.round(h.width)}, height=${Math.round(h.height)}`,`- Center: x=${Math.round(f.x)}, y=${Math.round(f.y)}`,`Styles: display=${c.display}; position=${c.position}; font=${c.fontWeight} ${c.fontSize} / ${c.lineHeight} ${c.fontFamily}; color=${c.color}; background=${c.backgroundColor}; z-index=${c.zIndex}`].filter(b=>typeof b=="string").join(`
|
|
3
3
|
`)},Ve=new Map,Qo=3e4,hn=t=>{const s=Ve.get(t);return s?s.expiresAt-Date.now()<=Qo?(Ve.delete(t),null):s:null},ot="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=",Dt=new Map;function fn(t){const s="#ffffff",r=t.defaultView??window;try{const a=t.body?r.getComputedStyle(t.body).backgroundColor:"";if(a&&a!=="rgba(0, 0, 0, 0)"&&a!=="transparent")return a;const i=r.getComputedStyle(t.documentElement).backgroundColor;if(i&&i!=="rgba(0, 0, 0, 0)"&&i!=="transparent")return i}catch{}return s}const pn=t=>new Promise((s,r)=>{const a=new FileReader;a.onloadend=()=>s(typeof a.result=="string"?a.result:ot),a.onerror=()=>r(a.error??new Error("Failed to read image blob")),a.readAsDataURL(t)}),Zo=async(t,s=.82)=>{const r=await new Promise(a=>t.toBlob(a,"image/jpeg",s));return r&&(await pn(r)).split(",",2)[1]||""},At=async(t,s)=>{try{const r=await fetch(t,{credentials:s});return r.ok?await pn(await r.blob()):null}catch{return null}},ea=async t=>{if(t.protocol!=="http:"&&t.protocol!=="https:")return"";const s=t.origin,r=hn(s);if(r)return`${r.proxyBasePath}${t.pathname}${t.search}${t.hash}`;const a=Dt.get(s),i=a??(async()=>{try{const u=await Ot("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:t.toString(),allowExternal:!0})});if(!u.ok)return Ve.delete(s),null;const l=await u.json(),c=typeof l.proxyBasePath=="string"?l.proxyBasePath:"",h=typeof l.expiresAt=="number"?l.expiresAt:0;if(!c)return Ve.delete(s),null;const f={proxyBasePath:c,expiresAt:h};return Ve.set(s,f),f}catch{return Ve.delete(s),null}finally{Dt.delete(s)}})();a||Dt.set(s,i);const o=await i;return o?`${o.proxyBasePath}${t.pathname}${t.search}${t.hash}`:""},mn=async(t,s)=>{if(!t||t.startsWith("data:"))return t;try{const r=new URL(t,s.baseURI);if(r.origin===window.location.origin||r.protocol!=="http:"&&r.protocol!=="https:")return await At(r.toString(),"include")??ot;const a=await ea(r),i=a?await At(a,"include"):null;return i||(await At(r.toString(),"omit")??ot)}catch{return ot}},ta=async(t,s)=>{if(!t||t==="none"||!t.includes("url("))return t;const r=Array.from(t.matchAll(/url\((['"]?)(.*?)\1\)/g));let a=t;for(const i of r){const o=i[2]||"";if(!o||o.startsWith("data:"))continue;const u=await mn(o,s);a=a.replace(i[0],`url("${u}")`)}return a},ks=t=>t.complete?Promise.resolve():new Promise(s=>{t.addEventListener("load",()=>s(),{once:!0}),t.addEventListener("error",()=>s(),{once:!0})}),gn=t=>{const s=t.style.cssText;return()=>{t.style.cssText=s}},sa=t=>{const s=Number.parseFloat(t.lineHeight);if(Number.isFinite(s)&&s>0)return s;const r=Number.parseFloat(t.fontSize);return Number.isFinite(r)&&r>0?r*1.2:16},na=(t,s,r)=>{const a=[],i=t.defaultView??window,u=Array.from(t.querySelectorAll('button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *'));for(const l of u){const c=l.textContent?.replace(/\s+/g," ").trim()??"";if(!c||!c.includes(" "))continue;const h=l.getBoundingClientRect();if(h.width<=0||h.height<=0||h.right<0||h.bottom<0||h.left>s||h.top>r)continue;const f=i.getComputedStyle(l);if(f.display==="none"||f.visibility==="hidden"||Number(f.opacity)===0)continue;const y=f.getPropertyValue("text-wrap"),d=f.getPropertyValue("text-wrap-mode"),b=f.whiteSpace.includes("nowrap")||y==="nowrap"||d==="nowrap",p=h.height<=sa(f)*1.7;!b&&(!p||h.width>s*.72)||(a.push(gn(l)),l.style.whiteSpace="nowrap",l.style.overflowWrap="normal",l.style.wordBreak="normal",l.style.setProperty("text-wrap","nowrap"),l.style.setProperty("text-wrap-mode","nowrap"))}return()=>{for(let l=a.length-1;l>=0;l-=1)a[l]?.()}},ra=(t,s,r,a)=>{const i=[],o=t.defaultView??window,u=o.scrollX||t.documentElement.scrollLeft||t.body?.scrollLeft||0,l=o.scrollY||t.documentElement.scrollTop||t.body?.scrollTop||0,c=Array.from(t.querySelectorAll("*")).filter(h=>{const f=o.getComputedStyle(h);if(f.position!=="fixed"||f.display==="none"||f.visibility==="hidden"||Number(f.opacity)===0)return!1;const y=h.getBoundingClientRect();return y.width>0&&y.height>0&&y.right>=0&&y.bottom>=0&&y.left<=s&&y.top<=r}).filter((h,f,y)=>!y.some((d,b)=>b<f&&d.contains(h)));for(const h of c){const f=h.getBoundingClientRect(),y=o.getComputedStyle(h),d=Math.ceil(f.width)+8,b=Math.ceil(f.height)+2;a?.add(h),i.push(gn(h)),h.style.position="absolute",h.style.top=`${f.top+l}px`,h.style.left=`${f.left+u}px`,h.style.right="auto",h.style.bottom="auto",h.style.width=`${d}px`,h.style.minWidth=`${d}px`,h.style.height=`${b}px`,h.style.minHeight=`${b}px`,h.style.margin="0",h.style.boxSizing="border-box",h.style.transform="none",y.zIndex!=="auto"&&(h.style.zIndex=y.zIndex)}return()=>{for(let h=i.length-1;h>=0;h-=1)i[h]?.()}},xn=async(t,s,r,a={})=>{const i=[],o=t.defaultView??window,u=y=>{if(y===t.documentElement||y===t.body)return!0;try{const d=y.getBoundingClientRect();return d.width>0&&d.height>0&&d.right>=0&&d.bottom>=0&&d.left<=s&&d.top<=r}catch{return!1}};if(a.applyLayoutWorkarounds){const y=new WeakSet;i.push(ra(t,s,r,y)),i.push(na(t,s,r))}const l=new Map;for(const y of Array.from(t.images))l.set(y,y.currentSrc||y.src||y.getAttribute("src")||"");const c=Array.from(t.querySelectorAll("picture"));for(const y of c){const d=Array.from(y.querySelectorAll("source"));if(d.length===0)continue;const b=d.map(p=>({source:p,srcset:p.getAttribute("srcset"),sizes:p.getAttribute("sizes")}));i.push(()=>{for(const p of b)p.srcset===null?p.source.removeAttribute("srcset"):p.source.setAttribute("srcset",p.srcset),p.sizes===null?p.source.removeAttribute("sizes"):p.source.setAttribute("sizes",p.sizes)});for(const p of d)p.removeAttribute("srcset"),p.removeAttribute("sizes")}const h=Array.from(t.images).filter(y=>u(y));await Promise.all(h.map(async y=>{const d=l.get(y)||y.currentSrc||y.src||y.getAttribute("src")||"";if(!d)return;await ks(y);const b=await mn(d,t),p={src:y.getAttribute("src"),srcset:y.getAttribute("srcset"),sizes:y.getAttribute("sizes")};i.push(()=>{p.src===null?y.removeAttribute("src"):y.setAttribute("src",p.src),p.srcset===null?y.removeAttribute("srcset"):y.setAttribute("srcset",p.srcset),p.sizes===null?y.removeAttribute("sizes"):y.setAttribute("sizes",p.sizes)}),y.removeAttribute("srcset"),y.removeAttribute("sizes"),y.setAttribute("src",b||ot),await ks(y)}));const f=Array.from(t.querySelectorAll("*")).filter(u);return await Promise.all(f.map(async y=>{const d=o.getComputedStyle(y).backgroundImage;if(!d||d==="none"||!d.includes("url("))return;const b=await ta(d,t);if(b===d)return;const p=y.style.backgroundImage;i.push(()=>{y.style.backgroundImage=p}),y.style.backgroundImage=b})),()=>{for(let y=i.length-1;y>=0;y-=1)try{i[y]?.()}catch{}}},oa=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},vt=(...t)=>{oa()&&console.info("[preview-capture]",...t)},bn=(t,s=8)=>{const r=[];try{const a=t.querySelectorAll("*");for(const i of a){const o=i.scrollTop||0,u=i.scrollLeft||0;if(o<=0&&u<=0)continue;const l=i.tagName.toLowerCase(),c=i.id?`#${i.id}`:"",h=typeof i.className=="string"&&i.className?`.${i.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";if(r.push({selector:`${l}${c}${h}`,scrollTop:o,scrollLeft:u,clientWidth:i.clientWidth,clientHeight:i.clientHeight,scrollWidth:i.scrollWidth,scrollHeight:i.scrollHeight}),r.length>=s)break}}catch{}return r},mt="data-oc-fixed-pin",aa=(t,s,r)=>{if(s<=0&&r<=0)return()=>{};const a=t.defaultView;if(!a)return()=>{};const i=[],o=[];try{for(const u of t.querySelectorAll("*")){if(a.getComputedStyle(u).position!=="fixed")continue;const l=u.getBoundingClientRect();if(!(l.width>0&&l.height>0))continue;u.setAttribute(mt,JSON.stringify({top:l.top+r,left:l.left+s,width:l.width,height:l.height})),i.push(u);const c=u.tagName.toLowerCase(),h=typeof u.className=="string"&&u.className?`.${u.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";o.push({selector:`${c}${h}`,top:Math.round(l.top),left:Math.round(l.left),width:Math.round(l.width),height:Math.round(l.height)})}}catch{}return vt("tagged fixed elements",o),()=>{for(const u of i)try{u.removeAttribute(mt)}catch{}}},ia={name:"oc-fixed-pin",afterClone(t){const s=t?.clone;if(!(!s||typeof s.querySelectorAll!="function"))for(const r of s.querySelectorAll(`[${mt}]`)){let a;try{a=JSON.parse(r.getAttribute(mt)||"")}catch{continue}r.style.setProperty("position","absolute","important"),r.style.setProperty("top",`${a.top}px`,"important"),r.style.setProperty("left",`${a.left}px`,"important"),r.style.setProperty("right","auto","important"),r.style.setProperty("bottom","auto","important"),r.style.setProperty("width",`${a.width}px`,"important"),r.style.setProperty("height",`${a.height}px`,"important"),r.removeAttribute(mt)}}},nt="data-oc-scroll-pin",la=t=>{const s=[],r=bn(t,64);try{const o=t.documentElement,u=t.body;for(const l of t.querySelectorAll("*")){const c=l.scrollTop||0,h=l.scrollLeft||0;if(c<=0&&h<=0)continue;const f=l!==o&&l!==u;f&&l.setAttribute(nt,JSON.stringify({top:c,left:h})),s.push({el:l,top:c,left:h,tagged:f})}}catch{}return{reapply:()=>{for(const o of s)try{o.el.scrollHeight,o.el.scrollTop!==o.top&&(o.el.scrollTop=o.top),o.el.scrollLeft!==o.left&&(o.el.scrollLeft=o.left)}catch{}},cleanup:()=>{for(const o of s)if(o.tagged)try{o.el.removeAttribute(nt)}catch{}},snapshot:r}},ca={name:"oc-nested-scroll",afterClone(t){const s=t?.clone;if(!s||typeof s.querySelectorAll!="function")return;const r=s.ownerDocument;if(r)for(const a of s.querySelectorAll(`[${nt}]`)){let i;try{i=JSON.parse(a.getAttribute(nt)||"")}catch{a.removeAttribute(nt);continue}const o=`translate(${-i.left}px, ${-i.top}px)`,u=a.children.length===1&&a.firstElementChild instanceof HTMLElement&&a.firstElementChild.style.willChange==="transform"?a.firstElementChild:null;if(u)u.style.transform=o;else{a.style.overflow="hidden";const l=r.createElement("div");for(l.style.transform=o,l.style.willChange="transform",l.style.display="inline-block",l.style.width="100%";a.firstChild;)l.appendChild(a.firstChild);a.appendChild(l)}a.removeAttribute(nt)}}},wn=async(t,s)=>{if(In())try{const r=t.getBoundingClientRect(),a=await Vs("desktop_capture_page_rect",{x:r.left,y:r.top,width:r.width,height:r.height});if(!a)throw new Error("Desktop screenshot capture is not available");const i=new Image;await new Promise((p,C)=>{i.onload=()=>p(),i.onerror=()=>C(new Error("Failed to load desktop preview screenshot")),i.src=`data:${a.mime};base64,${a.base64}`});const o=Math.max(1,i.naturalWidth||a.width||Math.floor(r.width)),u=Math.max(1,i.naturalHeight||a.height||Math.floor(r.height)),c=Math.min(1,1200/o),h=document.createElement("canvas");h.width=Math.floor(o*c),h.height=Math.floor(u*c);const f=h.getContext("2d");if(!f)return null;f.scale(c,c),f.drawImage(i,0,0,o,u);const y=o/Math.max(1,r.width),d=u/Math.max(1,r.height);f.fillStyle="rgba(37, 99, 235, 0.28)",f.strokeStyle="rgb(37, 99, 235)",f.lineWidth=Math.max(2,2*y),f.fillRect(s.bounds.x*y,s.bounds.y*d,s.bounds.width*y,s.bounds.height*d),f.strokeRect(s.bounds.x*y,s.bounds.y*d,s.bounds.width*y,s.bounds.height*d);const b=await new Promise(p=>h.toBlob(p,"image/jpeg",.82));return b?new File([b],`preview-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch(r){console.warn("[preview] failed to capture annotation screenshot:",r)}return await ua(t,s)},Rt=async(t,s,r,a,i,o)=>{if(!t)return null;try{const u=new Image;await new Promise((x,P)=>{u.onload=()=>x(),u.onerror=()=>P(new Error("Failed to load desktop browser screenshot")),u.src=`data:image/jpeg;base64,${t}`});const l=Math.max(1,u.naturalWidth||s),c=Math.max(1,u.naturalHeight||r),f=Math.min(1,1200/l),y=document.createElement("canvas");y.width=Math.floor(l*f),y.height=Math.floor(c*f);const d=y.getContext("2d");if(!d)return null;d.scale(f,f),d.drawImage(u,0,0,l,c);const b=l/Math.max(1,a||l),p=c/Math.max(1,i||c);d.fillStyle="rgba(37, 99, 235, 0.14)",d.strokeStyle="rgb(37, 99, 235)",d.lineWidth=Math.max(2,2*b),d.fillRect(o.bounds.x*b,o.bounds.y*p,o.bounds.width*b,o.bounds.height*p),d.strokeRect(o.bounds.x*b,o.bounds.y*p,o.bounds.width*b,o.bounds.height*p);const C=await new Promise(x=>y.toBlob(x,"image/jpeg",.82));return C?new File([C],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}};async function da(t,s){try{const r=t.contentWindow,a=t.contentDocument??r?.document,i=a?.documentElement;if(!r||!a||!i)return null;const o=t.getBoundingClientRect(),u=Math.max(1,Math.ceil(r.innerWidth||t.clientWidth||o.width)),l=Math.max(1,Math.ceil(r.innerHeight||t.clientHeight||o.height)),c=a.body,h=a.scrollingElement instanceof HTMLElement?a.scrollingElement:null,f=r.scrollX||0,y=r.scrollY||0,d=r.pageXOffset||0,b=r.pageYOffset||0,p=r.visualViewport?.pageLeft||r.visualViewport?.offsetLeft||0,C=r.visualViewport?.pageTop||r.visualViewport?.offsetTop||0,x=i.scrollLeft||0,P=i.scrollTop||0,_=c?.scrollLeft||0,U=c?.scrollTop||0,w=h?.scrollLeft||0,E=h?.scrollTop||0,S=Math.max(f,d,p,x,_,w),M=Math.max(y,b,C,P,U,E);vt("scroll sources",{windowScrollX:f,windowScrollY:y,pageScrollX:d,pageScrollY:b,visualViewportScrollX:p,visualViewportScrollY:C,rootScrollX:x,rootScrollY:P,bodyScrollX:_,bodyScrollY:U,scrollingElementScrollX:w,scrollingElementScrollY:E,scrollingElementTag:h?.tagName?.toLowerCase()??null,resolvedScrollX:S,resolvedScrollY:M,nestedScrolledElements:bn(a)});const j=Math.max(u,i.scrollWidth||0,c?.scrollWidth||0,Math.ceil(i.getBoundingClientRect().width||0)),T=Math.max(l,i.scrollHeight||0,c?.scrollHeight||0,Math.ceil(i.getBoundingClientRect().height||0)),Y=Math.min(2,Math.max(1,window.devicePixelRatio||1)),X=i.style.scrollBehavior,z=c?.style.scrollBehavior??"";i.style.scrollBehavior="auto",c&&(c.style.scrollBehavior="auto");const Z=la(a);vt("nested scroll snapshot",Z.snapshot);let le=()=>{},H=()=>{};try{await a.fonts?.ready.catch(()=>{}),le=await xn(a,u,l,{applyLayoutWorkarounds:!1}),r.scrollTo(S,M),H=aa(a,S,M),Z.reapply();const{snapdom:ne}=await Oe(async()=>{const{snapdom:Re}=await import("./vendor-zumer-snapdom-SJzqoCHV.js");return{snapdom:Re}},[]),N={backgroundColor:fn(a),cache:"disabled",dpr:Y,embedFonts:!0,fast:!1,height:T,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[ia,ca],quality:.82,width:j},oe=await(await ne(i,N)).toCanvas();if(!oe.width||!oe.height)return null;const D=oe.width/Math.max(1,j),O=oe.height/Math.max(1,T),G=Math.min(oe.width,Math.max(1,Math.round(u*D))),ue=Math.min(oe.height,Math.max(1,Math.round(l*O))),ge=Math.max(0,oe.width-G),he=Math.max(0,oe.height-ue),be=Math.min(ge,Math.max(0,Math.round(S*D))),je=Math.min(he,Math.max(0,Math.round(M*O)));vt("capture geometry",{viewportWidth:u,viewportHeight:l,captureWidth:j,captureHeight:T,canvasWidth:oe.width,canvasHeight:oe.height,xScale:D,yScale:O,sourceX:be,sourceY:je,sourceWidth:G,sourceHeight:ue});const Ce=a.createElement("canvas");Ce.width=G,Ce.height=ue;const ve=Ce.getContext("2d");if(!ve)return null;ve.drawImage(oe,be,je,G,ue,0,0,G,ue);const ye=await Zo(Ce,.82);return ye?await Rt(ye,u,l,u,l,s):null}finally{H(),Z.cleanup(),le(),r.scrollTo(S,M),Z.reapply(),i.style.scrollBehavior=X,c&&(c.style.scrollBehavior=z)}}catch(r){return console.warn("[preview] failed to capture iframe DOM screenshot with snapDOM:",r),null}}async function ua(t,s){const r=await da(t,s);if(r)return r;try{const a=t.contentWindow,i=t.contentDocument??a?.document,o=i?.documentElement;if(!a||!i||!o)return null;const u=t.getBoundingClientRect(),l=Math.max(1,Math.ceil(a.innerWidth||t.clientWidth||u.width)),c=Math.max(1,Math.ceil(a.innerHeight||t.clientHeight||u.height)),h=a.scrollX||i.documentElement.scrollLeft||i.body?.scrollLeft||0,f=a.scrollY||i.documentElement.scrollTop||i.body?.scrollTop||0,y=i.body,d=Math.max(c,o.scrollHeight||0,y?.scrollHeight||0),b=Math.min(2,Math.max(1,window.devicePixelRatio||1)),p=o.style.scrollBehavior,C=y?.style.scrollBehavior??"";o.style.scrollBehavior="auto",y&&(y.style.scrollBehavior="auto");let x="",P=()=>{};try{await i.fonts?.ready.catch(()=>{}),P=await xn(i,l,c,{applyLayoutWorkarounds:!0}),a.scrollTo(h,f);const{getFontEmbedCSS:U,toJpeg:w}=await Oe(async()=>{const{getFontEmbedCSS:S,toJpeg:M}=await import("./vendor-html-to-image-BeoRn2gJ.js");return{getFontEmbedCSS:S,toJpeg:M}},[]),E=await U(o).catch(()=>"");x=await w(o,{quality:.82,pixelRatio:b,width:l,height:c,backgroundColor:fn(i),imagePlaceholder:ot,fontEmbedCSS:E||void 0,style:{transform:`translate(${-h}px, ${-f}px)`,transformOrigin:"top left",minWidth:`${l}px`,minHeight:`${d}px`},cacheBust:!0})}finally{P(),a.scrollTo(h,f),o.style.scrollBehavior=p,y&&(y.style.scrollBehavior=C)}const _=x.split(",",2)[1]||"";return _?await Rt(_,l,c,l,c,s):null}catch(a){return console.warn("[preview] failed to capture iframe DOM screenshot:",a),null}}const Cs=200,ha=(t,s)=>s==="all"?!0:s==="errors"?t.level==="error"||t.level==="runtime"||t.level==="resource":s==="warnings"?t.level==="warn":t.level==="log"||t.level==="info"||t.level==="debug",gt=t=>{const s=xt.getState();s.setPendingSyntheticParts([...s.pendingSyntheticParts??[],{text:t,synthetic:!0}])},fa=async t=>{const s=await t.json().catch(()=>({}));if(!t.ok)return{ok:!1,message:typeof s.error=="string"?s.error:`HTTP ${t.status}`};const r=typeof s.proxyBasePath=="string"?s.proxyBasePath:"",a=typeof s.previewToken=="string"?s.previewToken:"";return!r||!a?{ok:!1,message:"Could not start preview proxy."}:{ok:!0,target:{proxyBasePath:r,previewToken:a,expiresAt:typeof s.expiresAt=="number"?s.expiresAt:0}}},yn=t=>{if(typeof window>"u")return"";try{return new URL(t||window.location.href,window.location.href).origin}catch{return window.location.origin}},Ns=(t,s,r)=>{t.postMessage(r,yn(s))},pa=t=>{if(!t)return t;try{const s=new URL(t);return s.searchParams.delete("oc_preview_token"),s.searchParams.delete("oc_client_token"),s.searchParams.delete("oc_url_token"),s.toString()}catch{return t}},vn=`new Promise((resolve) => {
|
|
4
4
|
const existing = document.getElementById('__pichamber_desktop_browser_overlay');
|
|
5
5
|
if (existing) existing.remove();
|
|
@@ -133,5 +133,5 @@ ${ae.details}`:"";return`[${g}] [${ae.level}] ${ae.message}${A}`}).join(`
|
|
|
133
133
|
${g.details}`:"";return`[${A}] [${g.level}] ${g.message}${te}`}).join(`
|
|
134
134
|
`);gt(`These are browser console logs from the dev server running for this project.
|
|
135
135
|
|
|
136
|
-
${ee}${ae}`),xe.success("Preview console attached to chat")},[P,M,T,O,j,t]),[ye,Re]=n.useState("unknown"),Te=n.useRef(0),Se=n.useRef(0),ke=n.useRef(""),Ne=n.useRef(""),De=15e3;n.useEffect(()=>{if(!D){Re("unknown"),ke.current="",Te.current=0,Se.current=0;return}let L=!1,ee=null;ke.current!==H&&(ke.current=H,Te.current=Date.now(),Se.current=0);const ae=g=>{ee=setTimeout(()=>{L||i()},g)};return Re("unknown"),(async()=>{const A=await(async()=>{try{return await Ot(D,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(L)return;if(!A){Re("unreachable"),ae(5e3);return}const te=pi(A.headers,Ne.current===H);if(te!=="none"){if(Ve.delete(H),te==="retry-registration")Ne.current=H,c({status:"loading"}),u();else{const I=await A.json().catch(()=>({}));if(L)return;const V=typeof I?.error=="string"?I.error:`HTTP ${A.status}`;c({status:"error",message:V})}return}if(A.status!==502){Ne.current="",Re("reachable");return}const de=Te.current||Date.now();if(Date.now()-de<De){Re("starting"),Se.current+=1;const I=Se.current,V=Math.min(2e3,250*Math.pow(2,Math.min(4,I)));ae(V);return}Re("unreachable"),ae(5e3)})(),()=>{L=!0,ee&&clearTimeout(ee)}},[H,D,a]);const B=z&&l.status==="ready"&&(ye==="unknown"||ye==="starting"),J=z&&l.status==="ready"&&ye==="unreachable",re=n.useCallback(L=>{if(!z||l.status!=="ready"||typeof window>"u")return;const ee=L.currentTarget.contentWindow;if(ee)try{const ae=ee.location,g=yn(D);if(ae.origin!==g||ae.pathname.startsWith(l.proxyBasePath))return;const A=`${l.proxyBasePath}${ae.pathname}${ae.search}${ae.hash}`;ee.location.replace(A)}catch{}},[z,D,l]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",title:G||t,children:G||t||"No preview URL"}),e.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>i(),title:"Reload preview","aria-label":"Reload preview",disabled:!O,children:e.jsx(W,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{N&&at(N)},title:"Open in browser","aria-label":"Open in browser",disabled:!N,children:e.jsx(W,{name:"external-link",className:"h-3.5 w-3.5"})}),z?e.jsx(Q,{type:"button",size:"sm",variant:U?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>w(L=>!L),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!y,children:e.jsx(W,{name:"cursor",className:"h-3.5 w-3.5"})}):null,z?e.jsxs(Q,{type:"button",size:"sm",variant:b?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>p(L=>!L),title:y?"Open preview console":"Waiting for preview console","aria-label":y?"Open preview console":"Waiting for preview console",disabled:!y&&P.length===0,children:[e.jsx(W,{name:"terminal-box",className:"h-3.5 w-3.5"}),be>0?e.jsx("span",{className:"typography-micro text-status-error",children:be}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[B?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Starting dev server..."}),e.jsx("div",{className:"text-xs opacity-70",children:"Waiting for the server to accept connections."})]}):J?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Dev server is not responding."}),e.jsx("div",{className:"text-xs opacity-70",children:"Make sure your dev server is still running, then retry."}),e.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>i(),children:"Retry"})]}):O&&(!z||ye==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:h,src:O,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:ne},onLoad:re,sandbox:z?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${O}:${a}`),U&&E?e.jsx("div",{className:"pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35",style:{left:E.bounds.x,top:E.bounds.y,width:E.bounds.width,height:E.bounds.height},children:e.jsxs("div",{className:"absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow",children:[E.tag,E.text?` · ${E.text}`:""]})}):null]}):ue?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):ge?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Could not start preview proxy."}),l.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:l.message}):null]}):e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Preview needs a valid http(s) URL."}),b?e.jsxs("div",{className:"absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 px-3 py-2",children:[e.jsx("div",{className:"typography-ui-label text-foreground",children:"Preview console"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:ve,disabled:P.length===0,children:"Attach"}),e.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:Ce,disabled:P.length===0,children:"Copy"}),e.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:()=>_([]),disabled:P.length===0,children:"Clear"})]})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-border/30 px-3 py-1.5",children:["all","errors","warnings","logs"].map(L=>e.jsx(Q,{type:"button",size:"xs",variant:C===L?"secondary":"ghost",onClick:()=>x(L),children:L==="all"?"All":L==="errors"?"Errors":L==="warnings"?"Warnings":"Logs"},L))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:P.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No preview console events yet."}):je.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No events match this filter."}):je.map(L=>e.jsx("div",{className:"border-b border-border/30 px-2 py-1 last:border-b-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:fe("shrink-0 uppercase",L.level==="error"||L.level==="runtime"||L.level==="resource"?"text-status-error":L.level==="warn"?"text-status-warning":"text-muted-foreground"),children:L.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:L.message})]})},L.id))})]}):null]})]})},ss=t=>t,Vt=t=>{const s=ss(t).type;return typeof s=="string"?s:""},xi=t=>{const s=ss(t).tool;return typeof s=="string"?s:""},bi=t=>{const s=ss(t).text;return typeof s=="string"?s:""},wi=t=>{const s=Vt(t);return s==="tool"?xi(t).trim().toLowerCase()||"tool":s||"unknown"},yi=t=>{if(t.length===0)return"";const s=[];for(const r of t){const a=wi(r);s.includes(a)||s.push(a)}return s.join(" + ")},vi=t=>t.replace(/\s+/g," ").trim(),ji=t=>{for(const r of t)if(Vt(r)==="text"){const a=vi(bi(r));if(a.length===0)continue;return a}const s=t.filter(r=>Vt(r)!=="text").length;return s===0?"":`${s} attachment${s===1?"":"s"}`},Si=(t,s,r)=>`${r(t)} / ${r(s)}`,ki=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ci=(t,s)=>{if(!t||!Number.isFinite(t))return"-";const r=ki(s);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:r===!1?"2-digit":"numeric",minute:"2-digit",...r===void 0?{}:{hour12:r}})},Ni={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},St={user:0,assistant:0,tool:0,other:0},Pi=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Mt=t=>$t(t),Ri=(...t)=>{for(const s of t)if(typeof s=="string"&&s.trim().length>0)return s;return""},We=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((s,r)=>s+We(r),0):t&&typeof t=="object"?Object.values(t).reduce((s,r)=>s+We(r),0):0,Ei=(t,s)=>{const r=t,a=typeof r.type=="string"?r.type:"";if(a==="reasoning")return{...St,assistant:We(r.text)+We(r.content)};const i=Ri(r.text,r.content,r.value,r.source?.value,r.source?.text?.value);return a==="tool"||s==="tool"?{user:0,assistant:0,tool:We(r.input)+We(r.output)+We(r.error)+We(r.call?.input)+We(r.call?.output)+We(r.call?.error)+We(r.raw)+Math.round(We(r.metadata)*.25)+Math.round(We(r.state)*.1),other:0}:s==="user"?{user:i.length,assistant:0,tool:0,other:0}:s==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Is=(t,s)=>({user:t.user+s.user,assistant:t.assistant+s.assistant,tool:t.tool+s.tool,other:t.other+s.other}),Ti=t=>{const s=pt(t.info);return s.isUser?"user":s.role==="assistant"?"assistant":s.role==="tool"?"tool":"other"},Di=(t,s)=>{if(t.length===0)return{...St};const r=t.reduce((a,i)=>{const o=Ti(i);let u={...St};for(const l of i.parts)u=Is(u,Ei(l,o));return Is(a,u)},{...St});return r.user+=s.length,{user:Math.ceil(r.user/4),assistant:Math.ceil(r.assistant/4),tool:Math.ceil(r.tool/4),other:Math.ceil(r.other/4)}},Ge=t=>t.toLocaleString("en-US"),Ai=t=>!Number.isFinite(t)||t<=0?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:t<.01?4:2,maximumFractionDigits:t<.01?4:2}).format(t),_i=(t,s)=>!t||!Number.isFinite(t)?"-":qr(t,s,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Mi=(t,s,r)=>{const a=t.find(o=>o.id===s),i=a?.models?.find(o=>o.id===r);return{providerName:a?.name||s||"-",modelName:i?.name||r||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},Ii=()=>{const t=K(p=>p.timeFormatPreference),[s,r]=n.useState({}),{value:a,show:i,clear:o}=Vr(null,2e3),u=Me(p=>p.currentSessionId),l=Me(p=>p.currentSessionDirectory),c=Kr(),h=sn(u??""),f=Ze(p=>p.providers);n.useEffect(()=>{r(p=>Object.keys(p).length>0?{}:p),o()},[o,l,u]);const y=n.useCallback(async(p,C)=>{(await ct(C)).ok?i(p):o()},[o,i]),d=n.useMemo(()=>{const p=u?c.find(D=>D.id===u)??null:null,C=h.filter(D=>pt(D.info).role==="assistant"),x=h.filter(D=>pt(D.info).isUser);let P=null;for(let D=C.length-1;D>=0;D-=1){const O=C[D];if(Mt(O).total>0){P=O;break}}const _=P?Mt(P):Ni,U=P?.info?.usage,w=Qs({input:_.input,cache:{read:_.cacheRead,write:_.cacheWrite}}),E=C.reduce((D,O)=>{const G=Pi(O.info.cost);return D+G},0),S=P?.info?.model??null,M=Mi(f,S?.providerID||"",S?.modelID||""),j=M.contextLimit,T=U?Zs(U):_.total,Y=j&&j>0?Math.min(999,T/j*100):0,X=[...h].reverse().find(D=>pt(D.info).isUser&&typeof D.info.system=="string")?.info?.system||"",z=Di(h,X),Z=z.user,le=z.assistant,H=z.tool,ne=U?0:Math.max(0,_.input-Z-le-H),N=Z+le+H+ne,F=h[0]?.info?.time?.created,oe=h.length>0?h[h.length-1]?.info?.time?.created:null;return{sessionTitle:nn(p),messagesCount:h.length,userMessagesCount:x.length,assistantMessagesCount:C.length,createdAt:p?.time?.created??F??null,lastActivityAt:oe??p?.time?.created??null,providerModel:M,tokenBreakdown:_,usagePercent:Y,cacheHitRate:w,totalAssistantCost:E,contextLimit:j,contextWindowTokens:T,hasUsage:U!==void 0,breakdown:{user:Z,assistant:le,tool:H,other:ne},breakdownTotal:N}},[u,f,h,c]);if(!u)return e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:"Open a session to inspect context."});const b=[{key:"user",label:"User",value:d.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:d.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool calls",value:d.breakdown.tool,color:"var(--status-warning)"},...d.hasUsage?[]:[{key:"other",label:"Other",value:d.breakdown.other,color:"var(--surface-muted-foreground)"}]];return e.jsx("div",{className:"h-full overflow-y-auto bg-background",children:e.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:d.sessionTitle}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-subtle-foreground",children:[e.jsxs("span",{children:[d.providerModel.providerName," / ",d.providerModel.modelName]}),d.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:_i(d.createdAt,t)})]})]})]}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Context"}),e.jsxs("span",{className:"typography-micro tabular-nums text-subtle-foreground",children:[Ge(d.contextWindowTokens),d.contextLimit?` / ${Ge(d.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:d.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,d.usagePercent)}%`,backgroundColor:d.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}})}),e.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:`${d.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:Ge(d.messagesCount)},{label:"User",value:Ge(d.userMessagesCount)},{label:"Assistant",value:Ge(d.assistantMessagesCount)},{label:"Cost",value:Ai(d.totalAssistantCost)}].map(p=>e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[e.jsx("div",{className:"typography-micro text-subtle-foreground",children:p.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:p.value})]},p.label))}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:"Last assistant message"}),e.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:"Input",value:d.tokenBreakdown.input,format:"count"},{label:"Output",value:d.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:d.tokenBreakdown.reasoning,format:"count"},{label:"Cache read",value:d.tokenBreakdown.cacheRead,format:"count"},{label:"Cache write",value:d.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache hit",value:d.cacheHitRate.hasInput?d.cacheHitRate.percent:null,format:"percent"}].map(p=>e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-subtle-foreground",children:p.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:p.value!==null&&p.value!==void 0?p.format==="percent"?`${p.value.toFixed(1)}%`:Ge(p.value):"—"})]},p.label))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:b.map(p=>p.value<=0||d.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${p.value/d.breakdownTotal*100}%`,backgroundColor:p.color}},p.key))}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:b.map(p=>{const C=d.breakdownTotal>0?p.value/d.breakdownTotal*100:0;return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:p.color}}),e.jsxs("span",{className:"typography-micro text-subtle-foreground",children:[p.label," ",e.jsxs("span",{className:"tabular-nums",children:[C.toFixed(0),"%"]})]})]},p.key)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground",children:"Raw messages"}),e.jsx("div",{className:"mt-2.5 space-y-1",children:[...h].reverse().map(p=>{const x=pt(p.info).role,P=x==="assistant",_=x==="user",U=s[p.info.id]===!0,w=a===p.info.id,E=p.info.time?.created??null,S=yi(p.parts),M=P?Mt({info:p.info,parts:p.parts}):null,j=_?ji(p.parts):"",T=Ci(E,t),Y=S||"—",X=M?Si(M.input,M.output,Ge):"",z=x||"unknown",Z=S?`${z}: ${S}`:z,le=U?JSON.stringify({info:p.info,parts:p.parts},null,2):"";return e.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[e.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":U,onClick:()=>{r(H=>({...H,[p.info.id]:H[p.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:P?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[_?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",j]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:P?Y:Z}),P&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:X})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:T})]})}),U&&e.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:e.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[e.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:H=>{H.stopPropagation(),y(p.info.id,le)},"aria-label":w?"Copied":"Copy JSON",title:w?"Copied":"Copy",children:w?e.jsx(W,{name:"check",className:"size-3.5"}):e.jsx(W,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Xr,{language:"json",code:le,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},p.info.id)})})]})]})})},Li=n.lazy(()=>Oe(()=>import("./AgentsSurface-BmHImX8m.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.AgentsSurface}))),Bi=Ke(()=>Oe(()=>import("./DiffView-C70pbgk-.js"),__vite__mapDeps([14,1,2,3,5,6,7,8,9,10,4,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(t=>({default:t.DiffView}))),Oi=Ke(()=>Oe(()=>import("./FilesView-nFJYEdRw.js"),__vite__mapDeps([56,1,2,3,5,6,7,8,9,10,4,11,12,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,53,54,35,36,20,21,22,23,24,25,26,27,28,29,30,31,32,33,73,74,48,49,50,51,52,75,76,17,18,19,34,37,38,39,40,41,42,43,77,78,79,80,81,47])).then(t=>({default:t.FilesView}))),$i=Ke(()=>Oe(()=>import("./GitView-MIDG5RYW.js"),__vite__mapDeps([82,7,1,2,3,4,5,6,8,9,10,11,12,48,49,50,51,52,15,83,84,85,86,46,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,47,53,54])).then(t=>({default:t.GitView}))),Fi=Ke(()=>Oe(()=>import("./PullRequestsSurface-o_AXDjbO.js"),__vite__mapDeps([87,7,1,2,3,88,5,6,8,9,10,4,11,12,48,49,50,51,52,89,83,84,46,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,47,53,54])).then(t=>({default:t.PullRequestsSurface}))),Wi=Ke(()=>Oe(()=>import("./IssuesSurface-uNlozeu0.js"),__vite__mapDeps([90,1,2,3,88,5,6,7,8,9,10,4,11,12,48,49,50,51,52,89,83,84,91])).then(t=>({default:t.IssuesSurface}))),zi=380,Hi=1400,Sn=600,Ui=100,Vi=24,Ls=720,Bs=t=>Number.isFinite(t)?Math.min(Hi,Math.max(zi,Math.round(t))):Sn,Ki=t=>{const s=t?.parentElement?.clientWidth;return!s||s<=0?null:s},Xi=(t,s)=>{if(!t)return"";const r=t.replace(/\\/g,"/"),a=s.replace(/\\/g,"/").replace(/\/+$/,"");return a&&r.startsWith(a+"/")?r.slice(a.length+1):r},Kt=(t,s=null)=>t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?es(s).label:t==="terminal"?"Terminal":t==="pull-requests"?"Pull requests":t==="issues"?"Issues":t==="extensions"?"Extensions":t==="agents"?"Agents":"Context",kn=t=>{if(!t)return null;const s=t.replace(/\\/g,"/").trim();if(!s)return null;const r=s.split("/").filter(Boolean);return r.length===0?s:r[r.length-1]||null},qi=(t,s=null)=>{if(t.label)return t.label;if(t.mode==="file")return kn(t.targetPath)||"Files";if(t.mode==="preview"){const r=t.targetPath;if(r)try{const a=new URL(r);return a.host||a.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":Kt(t.mode,s)},It=(t,s=null)=>{if(t.mode==="file")return t.targetPath?e.jsx(Ct,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return e.jsx(Rr,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(W,{name:es(s).icon,className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(W,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(W,{name:"pie-chart",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(W,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(W,{name:"global",className:"h-3.5 w-3.5"});if(t.mode==="pull-requests")return e.jsx(W,{name:"git-pull-request",className:"h-3.5 w-3.5"});if(t.mode==="issues")return e.jsx(W,{name:"task",className:"h-3.5 w-3.5"});if(t.mode==="extensions")return e.jsx(W,{name:"plug-2",className:"h-3.5 w-3.5"});if(t.mode==="agents")return e.jsx(W,{name:"robot-2",className:"h-3.5 w-3.5"})},Yi=(t,s)=>t.length<=s?t:`${t.slice(0,s-3)}...`,Gi=()=>{const t=bt()??"",s=n.useMemo(()=>Be(t),[t]),r=K(v=>s?v.contextPanelByDirectory[s]:void 0),a=K(v=>v.closeContextPanel),i=K(v=>v.closeContextPanelTab),o=K(v=>v.openContextPanelTab),u=K(v=>v.toggleContextPanelExpanded),l=K(v=>v.setContextPanelWidth),c=K(v=>v.setActiveContextPanelTab),h=K(v=>v.reorderContextPanelTabs),f=Ue(v=>v.setSelectedPath),y=K(v=>v.openContextPreview),d=K(v=>v.contextEditorTreeVisible),b=K(v=>v.toggleContextEditorTree),p=Me(v=>v.currentSessionId),C=n.useMemo(()=>r?.tabs??[],[r?.tabs]),x=C.find(v=>v.id===r?.activeTabId)??C[C.length-1]??null,P=!!(r?.isOpen&&x),_=!!(P&&r?.expanded),[U,w]=n.useState(null),E=r?.width,S=Jr,M=U??(typeof window<"u"?window.innerWidth:Sn*2),j=Bs(E??Math.round(S*M)),T=rn(s||null),[Y,X]=n.useState(!1),[z,Z]=n.useState(null),[le,H]=n.useState(null),[ne,N]=n.useState(null),[F,oe]=n.useState(null),D=n.useRef(0),O=n.useRef(j),G=n.useRef(null),ue=n.useRef(null),ge=n.useRef(null),he=n.useRef(!1);n.useLayoutEffect(()=>{const v=ge.current?.parentElement;if(!v||typeof ResizeObserver>"u")return;const me=new ResizeObserver(()=>{w(v.clientWidth||null)});return me.observe(v),w(v.clientWidth||null),()=>me.disconnect()},[]),n.useEffect(()=>{if(!P||he.current){he.current=P;return}const v=window.requestAnimationFrame(()=>{ge.current?.focus({preventScroll:!0})});return he.current=!0,()=>window.cancelAnimationFrame(v)},[P]);const be=n.useRef(null),je=n.useRef(null),Ce=n.useCallback(()=>{je.current=null;const v=ge.current,me=G.current;!v||me===null||v.style.setProperty("--oc-context-panel-width",`${me}px`)},[]);n.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const ve=n.useCallback(v=>{const me=Bs(v),Ae=be.current;return Ae===null?me:Math.min(me,Math.max(1,Ae))},[]),ye=n.useCallback(v=>{!P||_||!s||(ue.current=v.pointerId,X(!0),D.current=v.clientX,O.current=j,G.current=j,be.current=Ki(ge.current),document.documentElement.style.cursor="col-resize",v.preventDefault())},[s,_,P,j]),Re=n.useCallback(()=>{const v=ve(G.current??j);G.current=null,be.current=null,je.current!==null&&(clearTimeout(je.current),je.current=null),document.documentElement.style.cursor="",s&&l(s,v),X(!1),ue.current=null},[ve,s,l,j]);n.useEffect(()=>{if(!Y)return;const v=$e=>{if(ue.current!==$e.pointerId)return;const Nn=D.current-$e.clientX,ns=ve(O.current+Nn);G.current!==ns&&(G.current=ns,je.current===null&&(je.current=setTimeout(Ce,Ui)))},me=$e=>{ue.current===$e.pointerId&&Re()},Ae=()=>{Re()};return window.addEventListener("pointermove",v),window.addEventListener("pointerup",me),window.addEventListener("pointercancel",me),window.addEventListener("blur",Ae),()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",me),window.removeEventListener("pointercancel",me),window.removeEventListener("blur",Ae)}},[Ce,ve,Re,Y]),n.useEffect(()=>{Y||(G.current=null,document.documentElement.style.cursor="")},[Y]);const Te=n.useCallback(()=>{s&&a(s)},[a,s]),Se=n.useCallback(()=>{s&&u(s)},[s,u]),ke=n.useCallback(v=>{v.key==="Escape"&&(Yr(v.target)||(v.preventDefault(),v.stopPropagation(),Te()))},[Te]);n.useEffect(()=>{if(!(!s||!x)&&x.mode==="file"&&x.targetPath){f(s,x.targetPath,{allowOutsideRoot:!0});return}},[x,s,f]);const Ne=n.useCallback(v=>{!s||x?.mode!=="diff"||o(s,{mode:"diff",targetPath:x.targetPath,stagedDiff:v==="staged",diffScope:v})},[x,s,o]),De=x?.mode==="file"||x?.mode==="preview",B=n.useMemo(()=>x?C.filter(v=>v.mode===x.mode):[],[x,C]),J=n.useMemo(()=>B.map(v=>{const me=qi(v,T),Ae=Yi(me,Vi),$e=Xi(v.targetPath,t);return{id:v.id,label:Ae,icon:It(v,T),title:$e?`${me}: ${$e}`:me,closeLabel:`Close ${Ae} tab`}}),[B,t,T]),re=x?.mode==="pull-requests",L=x?.mode==="issues",ee=K(v=>v.gitReturnToFile?.directory===s?v.gitReturnToFile.focusPath:null),ae=x?.mode==="context"?e.jsx(Ii,{}):x?.mode==="extensions"?e.jsx(Gr,{sessionId:p}):x?.mode==="agents"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Li,{sessionId:p})}):x?.mode==="git"?e.jsx(n.Suspense,{fallback:null,children:e.jsx($i,{isActive:P,gitHeaderSlot:x?.mode==="git"?le:null,onlyFilePath:ee})}):x?.mode==="pull-requests"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Fi,{headerActionsSlot:re?F:null,headerActionsPresentation:"desktop"},`pull-requests:${s}`)}):x?.mode==="issues"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Wi,{headerActionsSlot:L?F:null,headerActionsPresentation:"desktop"},`issues:${s}`)}):x?.mode==="preview"?e.jsx(gi,{rawUrl:x.targetPath??"",onNavigate:v=>y(t,v)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(W,{name:"global",className:"h-12 w-12 text-subtle-foreground"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"Preview"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Use Project Actions or a terminal Preview button to open a preview."})]}),g=n.useMemo(()=>C.filter(v=>v.mode==="browser"),[C]),A=n.useMemo(()=>C.filter(v=>v.mode==="diff"),[C]),te=n.useMemo(()=>C.some(v=>v.mode==="terminal"),[C]),de=n.useMemo(()=>C.some(v=>v.mode==="file"),[C]),m=n.useMemo(()=>C.some(v=>v.mode==="file"&&v.targetPath),[C]),I=x?.mode==="file"?x.targetPath??null:null,V=_?U:j,pe=!!(m&&V!==null&&V<Ls),[Ee,Ie]=n.useState(!1);n.useEffect(()=>{Ie(!1)},[I]);const Le=!m&&V!==null&&V<Ls,Xe=Le?!0:pe?Ee:d,Ye=K(v=>v.fileTreeReveal);n.useEffect(()=>{Ye&&(pe?Ie(!0):K.getState().contextEditorTreeVisible||b())},[Ye,b,pe]);const k=n.useCallback(()=>{if(pe){Ie(v=>!v);return}b()},[b,pe]),q=x?.mode==="file",ce=K(v=>v.gitReturnToFile),ie=K(v=>v.clearGitReturnToFile),we=K(v=>v.showAllGitChanges),se=ce&&ce.directory===s&&x?.mode==="git"?C.find(v=>v.id===ce.tabId&&v.mode==="file"&&v.targetPath)??null:null;n.useEffect(()=>{ce&&(!P||x?.mode!=="git"||ce.directory!==s)&&ie()},[x?.mode,ie,s,ce,P]);const Pe=x?.mode==="terminal",_e=x?.mode==="git",He=x?.mode==="diff",R=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[De?e.jsx(un,{items:J,activeId:x?.id??null,onSelect:v=>{s&&c(s,v)},onClose:v=>{if(s){for(const me of C.find(Ae=>Ae.id===v)?.browser?.pages??[])Js(s,me.id);i(s,v)}},onReorder:(v,me)=>{s&&h(s,v,me)},layoutMode:"scrollable",variant:"default"}):Pe?e.jsx("div",{ref:v=>{Z(v)},className:"flex min-w-0 flex-1 items-center px-1"}):_e?e.jsx("div",{ref:v=>{H(v)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):He?e.jsx("div",{ref:v=>{N(v)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):re||L?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[x?It(x,T):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:x?Kt(x.mode,T):null}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx("div",{ref:v=>{oe(v)},className:"flex shrink-0 items-center gap-1"})]}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[x?It(x,T):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:x?Kt(x.mode,T):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[q&&!Le?e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:k,className:fe("h-8 w-8 p-0",Xe&&"bg-interactive-selection text-foreground"),title:Xe?"Hide file tree":"Show file tree","aria-label":"Toggle file tree","aria-pressed":Xe,children:e.jsx(W,{name:"node-tree",className:"size-4"})}):null,e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:Se,className:"h-8 w-8 p-0",title:_?"Collapse panel":"Expand panel","aria-label":_?"Collapse panel":"Expand panel",children:_?e.jsx(W,{name:"fullscreen-exit",className:"size-4"}):e.jsx(W,{name:"fullscreen",className:"size-4"})}),e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:Te,className:"h-8 w-8 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(W,{name:"close",className:"size-4"})})]})]}),$=P?_?{"--oc-context-panel-width":U!==null?`${U}px`:"100%",width:U!==null?`${U}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${j}px`}:{"--oc-context-panel-width":`${j}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:ge,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:fe("flex min-h-0 flex-col overflow-hidden bg-background",_?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:ke,style:$,children:[P&&!_&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!_&&e.jsx("div",{className:fe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Y&&"bg-[var(--interactive-border)]"),onPointerDown:ye,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:fe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!P&&"pointer-events-none select-none opacity-0"),style:{width:_?U!==null?`${U}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[R,e.jsxs("div",{className:fe("relative min-h-0 flex-1 overflow-hidden",Y&&"pointer-events-none"),children:[de?e.jsxs("div",{className:fe("absolute inset-0 flex",q?"flex":"hidden"),children:[e.jsx("div",{className:"relative h-full min-w-0 flex-1",children:m?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Oi,{mode:"editor-only",isVisible:P&&q})}):Le?null:e.jsx(ui,{directory:t})}),e.jsx(di,{visible:Xe,overlay:pe||Le,onDismissOverlay:pe?()=>Ie(!1):void 0})]}):null,g.map(v=>e.jsx("div",{className:fe("absolute inset-0",x?.id!==v.id&&"hidden"),children:e.jsx(Ja,{directory:s,browser:v.browser,onScreen:P&&x?.id===v.id})},v.id)),P?A.filter(v=>x?.id===v.id).map(v=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(Bi,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:v.diffScope??(v.stagedDiff?"staged":"working"),onDiffScopeChange:Ne,targetFilePath:v.targetPath,flushContent:!0,toolbarSlot:He?ne:null})})},v.id)):null,te?e.jsx("div",{className:fe("absolute inset-0",x?.mode==="terminal"?"block":"hidden"),children:e.jsx(en,{visible:P&&x?.mode==="terminal",terminalHeaderSlot:Pe?z:null})}):null,P&&x?.mode==="git"?e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[se?e.jsxs("div",{className:"flex h-9 shrink-0 items-center border-b border-border/60 pl-1.5 pr-1",children:[e.jsxs(Q,{variant:"ghost",size:"xs",onClick:()=>{ie(),c(s,se.id)},className:"min-w-0 text-muted-foreground hover:text-foreground",children:[e.jsx(W,{name:"arrow-left",className:"size-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:`Back to ${kn(se.targetPath)??"file"}`})]}),ce?.focusPath?e.jsx(Q,{variant:"ghost",size:"xs",onClick:we,className:"ml-auto shrink-0 text-muted-foreground hover:text-foreground",children:"Show all changes"}):null]}):null,e.jsx("div",{className:"relative min-h-0 flex-1",children:ae})]}):P&&!q&&x?.mode!=="browser"&&x?.mode!=="diff"&&x?.mode!=="terminal"?ae:null]})]})]})},Ji=150,Qi=500,Zi=[],Je=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),yt=(t,s)=>{if(!t||typeof t!="object")return;const r=t[s];return typeof r=="number"&&Number.isFinite(r)?r:void 0},el=t=>t>99?"99+":String(t),tl=t=>t>=90?"text-[var(--status-error)]":t>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",sl=({surface:t,isActive:s,showActivityDot:r,label:a,description:i,badgeCount:o,badgeAriaLabel:u,badgeDescription:l,orderNumber:c,showOrderNumber:h,onSelect:f,chartPercentage:y,chartDetails:d})=>{const{attributes:b,listeners:p,setNodeRef:C,transform:x,transition:P,isDragging:_}=Hs({id:t.id}),U=o!=null&&o>0?el(o):null;return e.jsx("div",{ref:C,style:{transform:Us.Translate.toString(x),transition:P},className:fe("relative",_&&"z-10 opacity-70"),children:e.jsxs(et,{delayDuration:Ji,children:[e.jsx(tt,{asChild:!0,children:e.jsxs("button",{type:"button",...b,...p,onClick:()=>f(t),"aria-label":u??a,"aria-pressed":s,className:fe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",s?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.id==="context"&&typeof y=="number"?e.jsx(gs,{percentage:y,className:"size-[18px] -rotate-90"}):e.jsx(W,{name:t.icon,className:"h-[18px] w-[18px]"}),h&&c!=null?e.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:c===10?"0":c}):U?e.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:U}):r?e.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null]})}),e.jsx(st,{side:"left",sideOffset:8,className:t.id==="context"&&d?"p-0 border-0 bg-transparent shadow-none":void 0,children:t.id==="context"&&d?e.jsx("div",{className:"w-[300px] overflow-hidden rounded-lg border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_8px_24px_rgb(0_0_0_/_0.18)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:e.jsx(gs,{percentage:d.percentage,className:"size-[18px] -rotate-90"})}),e.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:a}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:d.hasData?e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[e.jsxs("span",{className:fe("font-semibold",tl(d.percentage)),children:[d.percentage.toFixed(1),"%"]}),e.jsx("span",{className:"text-muted-foreground",children:`${Je(d.totalTokens)}/${Je(d.contextLimit)}`})]}):e.jsx("span",{className:"typography-micro text-muted-foreground",children:"No data yet"})})]}),d.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.totalTokens)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.contextLimit)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.outputLimit)})]}),typeof d.cacheRead=="number"&&typeof d.cacheWrite=="number"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.cacheRead)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.cacheWrite)})]})]}):null,typeof d.cacheHitPercent=="number"?e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache hit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:`${d.cacheHitPercent.toFixed(1)}%`})]}):null]}):e.jsx("div",{className:"px-2.5 py-2 typography-micro text-muted-foreground",children:i})]})}):e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:a}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:i}),l?e.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null]})})]})})},nl=()=>{const t=bt(),s=t?Vn(t):"",r=K(g=>s?g.contextPanelByDirectory[s]:void 0),a=K(g=>g.contextRailOrder),i=K(g=>g.setContextRailOrder),o=K(g=>g.openContextSurface),u=K(g=>g.shortcutOverrides),{screenWidth:l}=kt(),{git:c,github:h}=Nt(),f=qt(s||null),y=rn(s||null),d=on(g=>g.ensureStatus),b=ps(g=>g.ensureScope);n.useEffect(()=>{s&&d(s,c)},[s,d,c]),n.useEffect(()=>{!s||!h||b(s,h)},[s,b,h]);const p=n.useMemo(()=>Kn("switch_context_surface",u),[u]),[C,x]=n.useState(!1);n.useEffect(()=>{const g=new Set;let A=null,te=!1;const de=Ee=>Ee.length===1&&Ee>="0"&&Ee<="9",m=()=>{as(p,g)?!te&&A===null&&(A=setTimeout(()=>x(!0),Qi)):(te=!1,A!==null&&(clearTimeout(A),A=null),x(!1))},I=Ee=>{if(g.add(Ee.key.toLowerCase()),de(Ee.key)&&as(p,g)){te=!0,A!==null&&(clearTimeout(A),A=null),x(!1);return}m()},V=Ee=>{g.delete(Ee.key.toLowerCase()),m()},pe=()=>{g.clear(),te=!1,A!==null&&(clearTimeout(A),A=null),x(!1)};return window.addEventListener("keydown",I,!0),window.addEventListener("keyup",V,!0),window.addEventListener("blur",pe),()=>{window.removeEventListener("keydown",I,!0),window.removeEventListener("keyup",V,!0),window.removeEventListener("blur",pe),A!==null&&clearTimeout(A)}},[p]);const P=$s(Bt(Dn,{activationConstraint:{distance:8}}),Bt(Tn,{activationConstraint:{delay:200,tolerance:6}})),_=r?.tabs??Zi,U=_.find(g=>g.id===r?.activeTabId)??null,w=r?.isOpen?U?.mode??null:null,E=f?.files.length??0,S=Me(g=>g.currentSessionId),M=Me(g=>!!g.newSessionDraft?.open),j=Ze(g=>g.providers),T=Ze(g=>g.currentProviderId),Y=Ze(g=>g.currentModelId),X=Ze(g=>g.getCurrentModel()),z=Ze(g=>g.getModelMetadata);Ze(g=>g.modelsMetadata.size);const Z=Qr(n.useCallback(g=>S?g.sessionModelSelections.get(S)??null:null,[S])),le=sn(S??""),H=n.useMemo(()=>{for(let g=le.length-1;g>=0;g-=1){const A=le[g];if(A?.info.role==="assistant")try{if($t(A).total>0)return A}catch{continue}}return null},[le]),N=n.useMemo(()=>{for(let g=le.length-1;g>=0;g-=1){const A=le[g]?.info;if(A.role!=="user")continue;const te=A.model,de=te?.providerID??te?.providerId,m=te?.modelID??te?.modelId;if(typeof de=="string"&&de.trim()&&typeof m=="string"&&m.trim())return{providerID:de,modelID:m}}return null},[le])??(()=>{const g=H?.info.model,A=g?.providerID??g?.providerId,te=g?.modelID??g?.modelId;return A&&te?{providerID:A,modelID:te}:null})()??(Z?{providerID:Z.providerId,modelID:Z.modelId}:null)??(T&&Y?{providerID:T,modelID:Y}:null),oe=(N?j.find(g=>g.id===N.providerID):void 0)?.models.find(g=>g.id===N?.modelID),D=N?z(N.providerID,N.modelID):void 0,O=yt(oe?.limit,"context")??D?.limit?.context??yt(X?.limit,"context")??0,G=yt(oe?.limit,"output")??D?.limit?.output??yt(X?.limit,"output")??0,ue=H?(()=>{try{return $t(H)}catch{return null}})():null,ge=H?.info?.usage,he=ge?Zs(ge):ue?.total??0,be=!M&&he>0&&O>0?Math.min(he/O*100,999):0,Ce=!M&&!!H&&he>0&&O>0?be:null,ve=ue?Qs({input:ue.input,cache:{read:ue.cacheRead,write:ue.cacheWrite}}):null,ye=ve?.hasInput?ve.percent:null,Re=n.useMemo(()=>{const g=!!H&&he>0&&O>0;return{percentage:be,totalTokens:he,contextLimit:O,outputLimit:G,cacheRead:ue?.cacheRead??null,cacheWrite:ue?.cacheWrite??null,cacheHitPercent:ye,hasData:g}},[ue,ye,O,H,G,be,he]),Te=ms(g=>S?g.reducer.bySession.get(S)?.extensionWidgets:void 0,(g,A)=>g===A,S?`session:${S}`:"chrome"),Se=n.useMemo(()=>Te?.size?[...Te.entries()].map(([g,A])=>`${g}:${A.lines.join(`
|
|
137
|
-
`)}`).join(";"):"",[Te]),ke=Se!=="",Ne=n.useRef({});n.useEffect(()=>{w==="extensions"&&S&&Se&&(Ne.current[S]=Se)},[w,S,Se]);const De=S?Ne.current[S]??"":"",B=w!=="extensions"&&Se!==""&&De!==Se,J=ms(g=>S?Zr(g.reducer.bySession.get(S)):!1,void 0,S?`session:${S}`:"chrome"),re=ps(g=>s?g.entriesByDirectory[s]??null:null),L=n.useMemo(()=>{if(!re)return{isLoading:!0,hasResult:!1,hasGitHubRepo:!1,hasError:!1};const g=re.scope?.repositories??[];return{isLoading:re.isLoading,hasResult:!!(re.scope||re.error),hasGitHubRepo:g.some(A=>!!(A.host&&A.owner&&A.repo&&!A.disabledReason)),hasError:!!(re.error&&!re.scope)}},[re]),ee=n.useMemo(()=>eo({railOrder:a,tabs:_,githubScope:L,hasExtensionContent:ke,hasAgentContent:J}),[a,l,_,L,ke,J]),ae=n.useCallback(g=>{const{active:A,over:te}=g;if(!te||A.id===te.id)return;const de=to(K.getState().contextRailOrder).map(V=>V.id),m=de.indexOf(A.id),I=de.indexOf(te.id);m===-1||I===-1||i(An(de,m,I))},[i]);return s?e.jsx("nav",{"aria-label":"Panel surfaces",className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:e.jsx(Fs,{sensors:P,collisionDetection:Ws,onDragEnd:ae,children:e.jsx(zs,{items:ee.map(g=>g.id),strategy:_n,children:ee.map((g,A)=>{const te=g.id==="git"?es(y):null,de=te?{...g,...te}:g,m=de.label,I=g.id==="git"&&y===!0?E:0,V=I>0?I:null,pe=g.id==="context",Ee=g.id==="extensions"?B:!1;return e.jsx(sl,{surface:de,isActive:w===g.mode,showActivityDot:Ee,label:m,description:de.description,badgeCount:V,badgeAriaLabel:V!==null?V===1?`${m}, ${V} changed file`:`${m}, ${V} changed files`:null,badgeDescription:V!==null?V===1?`${V} changed file`:`${V} changed files`:null,chartPercentage:pe?Ce:void 0,chartDetails:pe?Re:void 0,orderNumber:A+1,showOrderNumber:C,onSelect:Ie=>o(s,Ie.mode)},g.id)})})})}):null},rl=(t,s)=>!t||s.length===0?"":JSON.stringify([t,s]),ol=(t,s,r,a)=>!r||a!==r||t.length===0?[]:ft(t,s,i=>i.name,{limit:10,threshold:.4}),al=new Set,il=[{keys:["↑","↓"],label:"Navigate"},{keys:["↵"],label:"Open"},{keys:["Esc"],label:"Close"}],Lt=t=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=s.startsWith("//");let a=s.replace(/\/+/g,"/");r&&!a.startsWith("//")&&(a=`/${a}`);const i=a==="/",o=/^[A-Za-z]:\/$/.test(a);return!i&&!o&&(a=a.replace(/\/+$/,"")),a},ll=()=>{const t=K(m=>m.isCommandPaletteOpen),s=K(m=>m.setCommandPaletteOpen),r=K(m=>m.setActiveMainTab),a=K(m=>m.setSettingsDialogOpen),i=K(m=>m.setSettingsPage),o=K(m=>m.setSessionSwitcherOpen),u=K(m=>m.toggleSidebar),l=K(m=>m.openContextOverview),c=K(m=>m.openContextSurface),h=K(m=>m.openContextFile),f=K(m=>m.shortcutOverrides),y=Me(m=>m.openNewSessionDraft),d=Me(m=>m.setCurrentSession),b=so({archived:!1}),p=no(n.useCallback(m=>t?m.ids:al,[t])),C=ro(n.useCallback(m=>t?m.rankById:oo,[t])),x=is(m=>m.currentDirectory),P=is(m=>m.homeDirectory),_=xs(m=>m.getActiveProject()),U=xs(m=>m.projects),w=bt(),E=Xn(m=>m.searchFiles),{files:S,git:M}=Nt(),j=on(m=>m.ensureStatus),{isMobile:T}=kt(),Y=n.useMemo(()=>w?Lt(w):null,[w]),[X,z]=n.useState(""),le=ao(X,200).trim(),H=X.trim();n.useEffect(()=>{t&&z("")},[t]),n.useEffect(()=>{if(!t||!M)return;const m=setTimeout(()=>{const I=new Set;for(const V of b){const pe=Tt(V);!pe||I.has(pe)||(I.add(pe),j(pe,M))}},0);return()=>clearTimeout(m)},[t,b,M,j]);const ne=n.useCallback(()=>s(!1),[s]),N=n.useCallback(m=>()=>{ne(),m()},[ne]),F=n.useMemo(()=>{const m=[{id:"new-session",title:"New session",icon:e.jsx(W,{name:"chat-new",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New session",onSelect:N(()=>{r("chat"),o(!1),y()})},{id:"add-project",title:"Add folder",icon:e.jsx(W,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add folder",onSelect:N(()=>{io.requestDirectoryDialog()})},{id:"toggle-sidebar",title:T?"Show session switcher":"Toggle sidebar",icon:e.jsx(W,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:T?"Show session switcher":"Toggle sidebar",onSelect:N(()=>{if(T){const{isSessionSwitcherOpen:I}=K.getState();o(!I)}else u()})},{id:"toggle-terminal",title:"Toggle terminal",icon:e.jsx(W,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:"Toggle terminal",onSelect:N(()=>{x&&c(x,"terminal")})},{id:"context-usage",title:"Show context usage",icon:e.jsx(W,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show context usage",onSelect:N(()=>{x&&l(x)})},{id:"open-settings",title:"Open settings…",icon:e.jsx(W,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open settings…",onSelect:N(()=>a(!0))}];return qn()&&m.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat window",icon:e.jsx(W,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat window",onSelect:N(()=>{Vs("desktop_open_draft_mini_chat_window",{directory:Lt(x||_?.path||""),projectId:_?.id??null}).catch(I=>{console.warn("[command-palette] failed to open draft mini chat window",I)})})}),m},[N,T,r,o,y,u,c,x,l,a,_?.id,_?.path]),oe=n.useMemo(()=>{const m=Ks();return{isWeb:!m&&Yn(),isDesktop:m,isMobile:T}},[T]),D=n.useMemo(()=>Er.filter(m=>m.slug!=="home").filter(m=>m.isAvailable?m.isAvailable(oe):!0).map(m=>{const I=Tr(m.slug)??"settings-3",V=(m.keywords??[]).join(" ");return{id:`settings:${m.slug}`,title:m.title,icon:e.jsx(W,{name:I,className:"mr-2 h-4 w-4"}),searchText:`${m.title} ${m.group} ${V}`,onSelect:N(()=>{i(m.slug),a(!0)})}}),[oe,N,i,a]),O=n.useMemo(()=>lo(b,p,C),[b,p,C]),G=co(),ue=n.useCallback(m=>{if(!m)return null;let I=null;for(const V of U){const pe=V.path.replace(/\/+$/,"");(m===pe||m.startsWith(`${pe}/`))&&(!I||pe.length>I.path.length)&&(I=V)}return I},[U]),ge=n.useCallback((m,I)=>{if(!m)return null;const V=G.get(m)?.trim()||null;if(!V||V==="HEAD"||!I)return V;const pe=I.path.replace(/\/+$/,"");return m===pe||V===G.get(pe)?.trim()?null:V},[G]),[he,be]=n.useState([]),[je,Ce]=n.useState(""),ve=rl(Y,le);n.useEffect(()=>{if(!t){be([]),Ce("");return}if(!ve){be([]),Ce("");return}if(!Y){be([]),Ce("");return}let m=!1;return E(Y,le,10,{type:"file"}).then(I=>{m||(be(I.map(V=>({path:Lt(V.path),name:V.name,relativePath:V.relativePath}))),Ce(ve))}).catch(()=>{m||(be([]),Ce(ve))}),()=>{m=!0}},[t,Y,le,ve,E]);const ye=H.length>0,Re=n.useMemo(()=>ye?ft(F,H,m=>m.searchText,{limit:7,noFuzzy:!0}):F.map(m=>({item:m,score:0})),[F,H,ye]),Te=n.useMemo(()=>ye?ft(D,H,m=>m.searchText,{limit:7,noFuzzy:!0}):[],[D,H,ye]),Se=n.useMemo(()=>ye?ft(O,H,m=>m.title||"",{limit:7,threshold:.2}):O.slice(0,5).map(m=>({item:m,score:0})),[O,H,ye]),ke=n.useMemo(()=>t?ol(he,le,ve,je):[],[t,he,je,ve,le]),Ne=t&&ve.length>0&&je!==ve,De=n.useMemo(()=>{if(!ye)return[];const m=U.map(I=>({...I,displayName:I.label||I.path.split("/").pop()||I.path,searchText:`${I.label||""} ${I.path}`}));return ft(m,H,I=>I.searchText,{limit:7,threshold:.4})},[U,H,ye]),B=Re.map(m=>m.item),J=Te.map(m=>m.item),re=Se.map(m=>m.item),L=ye?ke.map(m=>m.item):[],ee=ye?De.map(m=>m.item):[],ae=n.useMemo(()=>{if(!ye)return["commands","sessions"];const m=V=>V.length?V[0].score:1/0,I=[{key:"commands",score:m(Re)},{key:"settings",score:m(Te)},{key:"sessions",score:m(Se)},{key:"files",score:m(ke)},{key:"projects",score:m(De)}];return I.sort((V,pe)=>V.score-pe.score),I.map(V=>V.key)},[ye,Re,Te,Se,ke,De]),g=n.useCallback(m=>{ne(),d(m.id,Tt(m))},[ne,d]),A=n.useCallback(async m=>{if(!Y)return;const I=await cn(S,m,{directory:Y});if(!I.ok){xe.error(dn(I.reason));return}h(Y,m),ne()},[Y,S,h,ne]),te=n.useCallback((m,I)=>{ne(),y({selectedProjectId:m,directoryOverride:I})},[ne,y]),de=n.useCallback(m=>qs(Ys(m,f)),[f]);return e.jsxs(Yt,{open:t,onOpenChange:s,children:[e.jsxs(Jt,{className:"sr-only",children:[e.jsx(Qt,{children:"Command palette"}),e.jsx(Zt,{children:"Search files, sessions, and commands."})]}),e.jsxs(Gt,{showCloseButton:!1,className:fe("w-full max-w-xl gap-0 self-start overflow-hidden rounded-2xl p-0","mt-[max(env(safe-area-inset-top),0.25rem)] max-h-[calc(100%-0.5rem)] sm:mt-[10vh] sm:max-h-[80vh]"),children:[e.jsxs(uo,{shouldFilter:!1,className:fe("rounded-none","[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input-wrapper]]:border-border/60 [&_[data-slot=command-input-wrapper]]:px-3.5","[&_[cmdk-input]]:h-12 [&_[cmdk-input]]:text-[length:var(--text-markdown)] md:[&_[cmdk-input]]:text-[length:var(--text-ui-label)]","[&_[cmdk-list]]:p-1.5 [&_[cmdk-group]]:p-0 [&_[cmdk-group]+[cmdk-group]]:mt-1","[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-1.5 [&_[cmdk-group-heading]]:text-[length:var(--text-micro)]","[&_[cmdk-item]]:gap-2.5 [&_[cmdk-item]]:px-2.5 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]]:text-[length:var(--text-ui-label)]"),children:[e.jsx(ho,{value:X,onValueChange:z,placeholder:"Search files, sessions, commands..."}),e.jsxs(fo,{children:[e.jsx(po,{children:"No results found."}),ae.map(m=>m==="commands"&&B.length>0?e.jsx(ut,{heading:"Commands",children:B.map(I=>e.jsxs(ht,{value:I.id,onSelect:I.onSelect,children:[I.icon,e.jsx("span",{children:I.title}),I.shortcutId?e.jsx(mo,{children:de(I.shortcutId)}):null]},I.id))},"commands"):m==="settings"&&J.length>0?e.jsx(ut,{heading:"Settings",children:J.map(I=>e.jsxs(ht,{value:I.id,onSelect:I.onSelect,children:[I.icon,e.jsx("span",{children:I.title})]},I.id))},"settings"):m==="sessions"&&re.length>0?e.jsx(ut,{heading:"Sessions",children:re.map(I=>{const V=nn(I),pe=Tt(I),Ee=ue(pe),Ie=ge(pe,Ee),Le=Ee?go(Ee):xo(pe,P)?"No folder":null;return e.jsxs(ht,{value:`session:${I.id}`,onSelect:()=>g(I),children:[e.jsx(W,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:V}),Le||Ie?e.jsxs("span",{className:"ml-auto inline-flex min-w-0 max-w-[45%] shrink items-center gap-1.5 text-muted-foreground typography-meta",children:[Le?e.jsx("span",{className:"min-w-0 max-w-[140px] shrink-0 truncate",children:Le}):null,Ie?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[e.jsx(W,{name:"git-branch",className:"h-3 w-3 shrink-0"}),e.jsx(bo,{value:Ie,className:"min-w-0 max-w-[120px]"})]}):null]}):null]},I.id)})},"sessions"):m==="files"&&L.length>0?e.jsx(ut,{heading:"Files",children:L.map(I=>{const V=Gn(I.relativePath||I.name,{maxLength:80});return e.jsxs(ht,{value:`file:${I.path}`,onSelect:()=>{A(I.path)},children:[e.jsx(Ct,{filePath:I.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":I.relativePath,children:V})]},`file:${I.path}`)})},"files"):m==="projects"&&ee.length>0?e.jsx(ut,{heading:"Projects",children:ee.map(I=>{const V=I.displayName;return e.jsxs(ht,{value:`project:${I.id}`,onSelect:()=>te(I.id,I.path),children:[e.jsx(wo,{directory:I.path,label:V,className:"mr-2 size-4"}),e.jsx("span",{className:"truncate",children:V}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:I.path})]},`project:${I.id}`)})},"projects"):null),Ne?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]}),T?null:e.jsx("div",{className:"flex min-h-10 shrink-0 items-center border-t border-border/60 bg-[var(--surface-muted)]/40 px-3 py-2 typography-micro text-muted-foreground",children:e.jsx(yo,{hints:il.map(m=>m.label==="Close"?{...m,onSelect:()=>s(!1)}:m)})})]})]})},cl=(t,s,r)=>Qn(t)?qs(Ys(t,r)):s,dl=()=>{const t=K(o=>o.isHelpDialogOpen),s=K(o=>o.setHelpDialogOpen),r=K(o=>o.shortcutOverrides),a=Jn(),i=[{categoryKey:"Navigation & commands",items:[{id:"open_command_palette",descriptionKey:"Open command palette",icon:"command",keys:""},{id:"open_help",descriptionKey:"Show Keyboard Shortcuts (this dialog)",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"Toggle session sidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"Add selection to chat",icon:"add",keys:""},{id:"open_model_selector",descriptionKey:"Open model selector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"Navigate Models (in picker)",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"Adjust Thinking Mode (in picker, when supported)",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"Cycle thinking (global shortcut)",icon:"brain-ai-3",keys:""},{keys:[`Shift + Alt + ${a} + N`],descriptionKey:"New Window (desktop only)",icon:"window"}]},{categoryKey:"Session management",items:[{id:"new_chat",descriptionKey:"Create new session",icon:"add",keys:""},{id:"focus_input",descriptionKey:"Focus chat input",icon:"text",keys:""},{id:"cycle_session_folder",descriptionKey:"Cycle session folder",icon:"folder-open",keys:""},{id:"cycle_draft_folder",descriptionKey:"Cycle draft folder",icon:"folder-3",keys:""},{id:"open_timeline_dialog",descriptionKey:"Open conversation timeline",icon:"history",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"open_right_sidebar",descriptionKey:"Open right sidebar",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{keys:[`${a} + 1...0`],descriptionKey:"Switch Context Panel Surface (number key)",icon:"layout-right"}]},{categoryKey:"Interface",items:[{id:"cycle_theme",descriptionKey:"Cycle Theme (Light → Dark → System)",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"Open settings",icon:"settings-3",keys:""}]}];return e.jsx(Yt,{open:t,onOpenChange:s,children:e.jsxs(Gt,{className:"w-[92vw] max-w-[1120px] h-[84vh] max-h-[900px] flex flex-col overflow-hidden",children:[e.jsxs(Jt,{children:[e.jsxs(Qt,{className:"flex items-center gap-2",children:[e.jsx(W,{name:"command",className:"h-5 w-5"}),"Keyboard shortcuts"]}),e.jsx(Zt,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-x-10",children:i.map(o=>e.jsxs("div",{className:"min-w-0 break-inside-avoid",children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:o.categoryKey}),e.jsx("div",{className:"space-y-1",children:o.items.map(u=>{const l=u.id?cl(u.id,Array.isArray(u.keys)?u.keys[0]:u.keys,r):Array.isArray(u.keys)?u.keys:u.keys.split(" / ");return e.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u.icon&&e.jsx(W,{name:u.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:u.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(l)?l:[l]).map((c,h)=>e.jsxs(n.Fragment,{children:[h>0&&e.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:"or"}),e.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:c})]},`${c}-${h}`))})]},u.id||u.descriptionKey)})})]},o.categoryKey))})})]})})},ul=n.createContext(null),hl=({children:t,value:s})=>e.jsx(ul.Provider,{value:s,children:t}),Os=Ke(()=>Oe(()=>import("./GitView-MIDG5RYW.js"),__vite__mapDeps([82,7,1,2,3,4,5,6,8,9,10,11,12,48,49,50,51,52,15,83,84,85,86,46,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,47,53,54])).then(t=>({default:t.GitView}))),fl=Ke(()=>Oe(()=>import("./DiffView-C70pbgk-.js"),__vite__mapDeps([14,1,2,3,5,6,7,8,9,10,4,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(t=>({default:t.DiffView}))),pl=Ke(()=>Oe(()=>import("./FilesView-nFJYEdRw.js"),__vite__mapDeps([56,1,2,3,5,6,7,8,9,10,4,11,12,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,53,54,35,36,20,21,22,23,24,25,26,27,28,29,30,31,32,33,73,74,48,49,50,51,52,75,76,17,18,19,34,37,38,39,40,41,42,43,77,78,79,80,81,47])).then(t=>({default:t.FilesView}))),ml=Ke(()=>Oe(()=>import("./DiagramView-BZQxoiZu.js"),__vite__mapDeps([92,1,2,3,4,5,6,7,8,9,10,11,12,73,74])).then(t=>({default:t.DiagramView}))),gl=Ke(()=>Oe(()=>import("./SettingsView-BHBpt2Um.js").then(t=>t.h),__vite__mapDeps([93,1,2,3,5,6,7,8,9,10,4,11,12,48,49,50,51,52,94,95,96,85,86])).then(t=>({default:t.SettingsView}))),xl=Ke(()=>Oe(()=>import("./SettingsWindow-Cb4st5y5.js"),__vite__mapDeps([97,1,2,3,5,6,7,8,9,10,4,11,12,93,48,49,50,51,52,94,95,96,85,86])).then(t=>({default:t.SettingsWindow}))),bl=()=>{const t=K(N=>N.isSidebarOpen),s=K(N=>N.activeMainTab),r=K(N=>N.setIsMobile),a=K(N=>N.isSessionSwitcherOpen),i=K(N=>N.isSettingsDialogOpen),o=K(N=>N.setSettingsDialogOpen),[u,l]=n.useState(!1);n.useEffect(()=>{i&&l(!0)},[i]),n.useEffect(()=>{const N=()=>K.getState().closeMainSurfaces(),F=Me.subscribe((D,O)=>{const G=!!D.currentSessionId&&D.currentSessionId!==O.currentSessionId,ue=!!D.newSessionDraft?.open&&D.newSessionDraft!==O.newSessionDraft;(G||ue)&&N()}),oe=K.subscribe((D,O)=>{D.activeMainTab!==O.activeMainTab&&N()});return()=>{F(),oe()}},[]);const{isMobile:c}=kt(),h=n.useRef(!1),[f,y]=n.useState(!1),[d,b]=n.useState(!1),[p,C]=n.useState(!1),[x,P]=n.useState(!1),_=n.useCallback(N=>{y(N),K.getState().setSessionSwitcherOpen(N)},[]),U=n.useRef(typeof window>"u"?0:window.innerWidth),w=n.useRef(null),E=n.useRef(!1),S=n.useRef(!1),M=n.useRef(!1),j=n.useRef(null),T=n.useRef(null),Y=rs(-U.current),X=Fe.useRef(0),z=rs(U.current),Z=Fe.useRef(0);Fe.useEffect(()=>{c&&(X.current=window.innerWidth,Z.current=window.innerWidth)},[c]),Fe.useEffect(()=>{if(!c)return;const N=()=>{const F=window.innerWidth;X.current=F,Z.current=F,f||Y.get()<-10&&Y.set(-F),d||z.get()>10&&z.set(F)};return window.addEventListener("resize",N),window.addEventListener("orientationchange",N),()=>{window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N)}},[c,Y,z,f,d]),Fe.useEffect(()=>{if(!c){C(!1);return}f&&C(!0);const N=X.current||U.current||(typeof window<"u"?window.innerWidth:0),F=wt(Y,f?0:-N,{type:"spring",stiffness:400,damping:35,mass:.8});return j.current=F,()=>F.stop()},[f,c,Y]),Fe.useEffect(()=>{if(!c){P(!1);return}d&&P(!0);const N=Z.current||U.current||(typeof window<"u"?window.innerWidth:0),F=wt(z,d?0:N,{type:"spring",stiffness:400,damping:35,mass:.8});return T.current=F,()=>F.stop()},[c,d,z]),Fe.useEffect(()=>{if(c)return Y.on("change",N=>{const F=X.current||U.current,oe=f||N>-F+.5;C(D=>D===oe?D:oe)})},[c,Y,f]),Fe.useEffect(()=>{if(c)return z.on("change",N=>{const F=Z.current||U.current,oe=d||N<F-.5;P(D=>D===oe?D:oe)})},[c,d,z]),Fe.useEffect(()=>{c&&!a&&f&&_(!1)},[a,c,f,_]),Fe.useEffect(()=>{if(!c){h.current=!1;return}h.current||(h.current=!0,_(!1),b(!1))},[c,_]),Fe.useEffect(()=>{if(!c||s!=="chat"||f||d||i)return;let N=!1,F;return(D=>{F=window.setTimeout(()=>{if(N)return;const O=Me.getState(),G=K.getState();G.activeMainTab!=="chat"||G.isSettingsDialogOpen||O.currentSessionId||O.newSessionDraft?.open||O.openNewSessionDraft({automatic:!0})},D)})(500),()=>{N=!0,F!==void 0&&window.clearTimeout(F)}},[s,c,i,f,d]),Fe.useEffect(()=>{!c||!i||(_(!1),b(!1))},[c,i,_]),n.useEffect(()=>{K.getState().isMobile!==c&&r(c)},[c,r]);const le=n.useCallback(()=>{f&&_(!1),b(!d)},[f,d,_]);Dr(w,{enabled:c,leftOpen:f,rightOpen:d,leftWidth:()=>X.current||U.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>Z.current||U.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:N=>{const F=X.current||U.current||(typeof window<"u"?window.innerWidth:0);Y.set(F*(N-1))},onRightProgress:N=>{const F=Z.current||U.current||(typeof window<"u"?window.innerWidth:0);z.set(F*(1-N))},onLeftOpen:()=>{d&&b(!1),_(!0)},onLeftClose:()=>_(!1),onRightOpen:()=>{f&&_(!1),b(!0)},onRightClose:()=>b(!1),onDragStart:N=>{E.current=!0,N==="left"?(S.current=f,j.current?.stop(),p||C(!0)):(M.current=d,T.current?.stop(),x||P(!0))},onDragEnd:(N,F)=>{if(E.current=!1,N==="left"&&typeof F=="boolean"){const oe=S.current;if(F===oe){const D=X.current||U.current||(typeof window<"u"?window.innerWidth:0),O=wt(Y,oe?0:-D,{type:"spring",stiffness:400,damping:35,mass:.8});j.current=O}}if(N==="right"&&typeof F=="boolean"){const oe=M.current;if(F===oe){const D=Z.current||U.current||(typeof window<"u"?window.innerWidth:0),O=wt(z,oe?0:D,{type:"spring",stiffness:400,damping:35,mass:.8});T.current=O}}}});const H=n.useMemo(()=>{if(!c&&s!=="terminal"&&s!=="diagram"||c&&s==="git"&&(d||x))return null;switch(s){case"git":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(Os,{isActive:!0})});case"diff":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(fl,{})});case"terminal":return e.jsx(en,{onCloseView:()=>K.getState().setActiveMainTab("chat")});case"files":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(pl,{})});case"diagram":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(ml,{})});default:return null}},[s,c,x,d]),ne=s==="chat";return e.jsxs(Ar,{children:[e.jsx(_r,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:fe("main-content-safe-area",c?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(ll,{}),e.jsx(dl,{}),e.jsx(Mr,{}),c?e.jsxs(hl,{value:{leftDrawerOpen:f,rightDrawerOpen:d,toggleLeftDrawer:()=>{const N=!f;d&&b(!1),_(N)},toggleRightDrawer:le,leftDrawerX:Y,rightDrawerX:z,leftDrawerWidth:X,rightDrawerWidth:Z,setMobileLeftDrawerOpen:_,setRightSidebarOpen:b},children:[!i&&e.jsx(cs,{onToggleLeftDrawer:()=>{const N=!f;d&&b(!1),_(N)},onToggleRightDrawer:()=>{le()},leftDrawerOpen:f,rightDrawerOpen:d}),e.jsx("div",{"data-page-scroll-lock":"true",className:fe("flex flex-1 overflow-hidden relative",i&&"hidden"),children:e.jsxs("main",{ref:w,className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:[e.jsx("div",{className:fe("absolute inset-0",!ne&&"invisible"),children:e.jsx(ze,{children:e.jsx(ds,{active:ne&&!i})})}),H&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(ze,{children:H})}),e.jsx(ze,{children:e.jsx(us,{})}),e.jsx(os.div,{className:fe("absolute inset-0 z-20 bg-sidebar",!p&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:Y},"aria-hidden":!f,children:e.jsx(ze,{children:e.jsx(hs,{mobileVariant:!0,isVisible:p})})}),e.jsx(os.div,{className:fe("absolute inset-0 z-20 bg-sidebar",!x&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:z},"aria-hidden":!d,children:e.jsx(ze,{children:d||x?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Os,{isActive:d})}):null})})]})}),i&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(ze,{children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(gl,{onClose:()=>o(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ir,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(Go,{isOpen:t,isMobile:c,children:e.jsx(hs,{isVisible:t})}),e.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx(cs,{}),e.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:e.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:e.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[e.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[e.jsx("div",{className:fe("absolute inset-0",!ne&&"invisible"),children:e.jsx(ze,{children:e.jsx(ds,{active:ne&&!i})})}),H&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(ze,{children:H})}),e.jsx(ze,{children:e.jsx(us,{})})]}),e.jsx(Gi,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(ze,{children:e.jsx(nl,{})})})]})]})]}),u?e.jsx(n.Suspense,{fallback:null,children:e.jsx(xl,{open:i,onOpenChange:o})}):null]})]})]})},wl=()=>(Po(),Br(),e.jsxs(Or,{children:[e.jsx(Ro,{embeddedBackgroundWorkEnabled:!0}),e.jsx(Eo,{}),e.jsx(To,{}),e.jsx($r,{}),e.jsx(Do,{}),e.jsx(Ao,{}),e.jsx(bl,{}),e.jsx(Fr,{}),e.jsx(_o,{}),e.jsx(Mo,{})]}));function yl({apis:t}){const s=t??Gs(),[r,a]=n.useState(0);return n.useEffect(()=>Zn(i=>{if(i.runtimeKey===i.previousRuntimeKey){er();return}Lr(i),a(o=>o+1)}),[]),n.useEffect(()=>{let i=!0,o=null,u=null,l=null;return tr().then(()=>{i&&(o=vo(),u=jo(),l=So())}),()=>{i=!1,o?.(),u?.(),l?.()}},[r]),n.useEffect(()=>{s&&sr(s)},[s]),s?e.jsx(ze,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(ko,{apis:s,children:e.jsx(Co,{children:e.jsx(No,{children:e.jsx(wl,{})})},r)})})}):e.jsx(ze,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const Cn=document.getElementById("root");if(!Cn)throw new Error("Root element not found");Mn.createRoot(Cn).render(e.jsx(Fe.StrictMode,{children:e.jsx(Io,{children:e.jsx(Lo,{children:e.jsx(yl,{apis:Gs()??void 0})})})}));
|
|
136
|
+
${ee}${ae}`),xe.success("Preview console attached to chat")},[P,M,T,O,j,t]),[ye,Re]=n.useState("unknown"),Te=n.useRef(0),Se=n.useRef(0),ke=n.useRef(""),Ne=n.useRef(""),De=15e3;n.useEffect(()=>{if(!D){Re("unknown"),ke.current="",Te.current=0,Se.current=0;return}let L=!1,ee=null;ke.current!==H&&(ke.current=H,Te.current=Date.now(),Se.current=0);const ae=g=>{ee=setTimeout(()=>{L||i()},g)};return Re("unknown"),(async()=>{const A=await(async()=>{try{return await Ot(D,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(L)return;if(!A){Re("unreachable"),ae(5e3);return}const te=pi(A.headers,Ne.current===H);if(te!=="none"){if(Ve.delete(H),te==="retry-registration")Ne.current=H,c({status:"loading"}),u();else{const I=await A.json().catch(()=>({}));if(L)return;const V=typeof I?.error=="string"?I.error:`HTTP ${A.status}`;c({status:"error",message:V})}return}if(A.status!==502){Ne.current="",Re("reachable");return}const de=Te.current||Date.now();if(Date.now()-de<De){Re("starting"),Se.current+=1;const I=Se.current,V=Math.min(2e3,250*Math.pow(2,Math.min(4,I)));ae(V);return}Re("unreachable"),ae(5e3)})(),()=>{L=!0,ee&&clearTimeout(ee)}},[H,D,a]);const B=z&&l.status==="ready"&&(ye==="unknown"||ye==="starting"),J=z&&l.status==="ready"&&ye==="unreachable",re=n.useCallback(L=>{if(!z||l.status!=="ready"||typeof window>"u")return;const ee=L.currentTarget.contentWindow;if(ee)try{const ae=ee.location,g=yn(D);if(ae.origin!==g||ae.pathname.startsWith(l.proxyBasePath))return;const A=`${l.proxyBasePath}${ae.pathname}${ae.search}${ae.hash}`;ee.location.replace(A)}catch{}},[z,D,l]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-1 border-b border-border bg-[var(--surface-background)] px-2 py-1",children:[e.jsx("div",{className:"min-w-0 flex-1 truncate typography-micro text-muted-foreground",title:G||t,children:G||t||"No preview URL"}),e.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>i(),title:"Reload preview","aria-label":"Reload preview",disabled:!O,children:e.jsx(W,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(Q,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{N&&at(N)},title:"Open in browser","aria-label":"Open in browser",disabled:!N,children:e.jsx(W,{name:"external-link",className:"h-3.5 w-3.5"})}),z?e.jsx(Q,{type:"button",size:"sm",variant:U?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>w(L=>!L),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!y,children:e.jsx(W,{name:"cursor",className:"h-3.5 w-3.5"})}):null,z?e.jsxs(Q,{type:"button",size:"sm",variant:b?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>p(L=>!L),title:y?"Open preview console":"Waiting for preview console","aria-label":y?"Open preview console":"Waiting for preview console",disabled:!y&&P.length===0,children:[e.jsx(W,{name:"terminal-box",className:"h-3.5 w-3.5"}),be>0?e.jsx("span",{className:"typography-micro text-status-error",children:be}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[B?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Starting dev server..."}),e.jsx("div",{className:"text-xs opacity-70",children:"Waiting for the server to accept connections."})]}):J?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center text-sm text-muted-foreground",children:[e.jsx("div",{children:"Dev server is not responding."}),e.jsx("div",{className:"text-xs opacity-70",children:"Make sure your dev server is still running, then retry."}),e.jsx(Q,{type:"button",size:"sm",variant:"outline",onClick:()=>i(),children:"Retry"})]}):O&&(!z||ye==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:h,src:O,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:ne},onLoad:re,sandbox:z?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${O}:${a}`),U&&E?e.jsx("div",{className:"pointer-events-none absolute rounded-sm border-2 border-[var(--interactive-focus-ring)] bg-[var(--interactive-focus-ring)]/35",style:{left:E.bounds.x,top:E.bounds.y,width:E.bounds.width,height:E.bounds.height},children:e.jsxs("div",{className:"absolute -top-6 left-0 max-w-64 truncate rounded bg-[var(--surface-elevated)] px-2 py-0.5 typography-micro text-foreground shadow",children:[E.tag,E.text?` · ${E.text}`:""]})}):null]}):ue?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):ge?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-sm text-muted-foreground",children:[e.jsx("div",{children:"Could not start preview proxy."}),l.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:l.message}):null]}):e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Preview needs a valid http(s) URL."}),b?e.jsxs("div",{className:"absolute inset-x-3 bottom-3 z-10 max-h-[45%] overflow-hidden rounded-xl border border-border/70 bg-[var(--surface-elevated)] shadow-lg",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border/50 px-3 py-2",children:[e.jsx("div",{className:"typography-ui-label text-foreground",children:"Preview console"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:ve,disabled:P.length===0,children:"Attach"}),e.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:Ce,disabled:P.length===0,children:"Copy"}),e.jsx(Q,{type:"button",size:"xs",variant:"ghost",onClick:()=>_([]),disabled:P.length===0,children:"Clear"})]})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-border/30 px-3 py-1.5",children:["all","errors","warnings","logs"].map(L=>e.jsx(Q,{type:"button",size:"xs",variant:C===L?"secondary":"ghost",onClick:()=>x(L),children:L==="all"?"All":L==="errors"?"Errors":L==="warnings"?"Warnings":"Logs"},L))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:P.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No preview console events yet."}):je.length===0?e.jsx("div",{className:"px-2 py-3 text-muted-foreground",children:"No events match this filter."}):je.map(L=>e.jsx("div",{className:"border-b border-border/30 px-2 py-1 last:border-b-0",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:fe("shrink-0 uppercase",L.level==="error"||L.level==="runtime"||L.level==="resource"?"text-status-error":L.level==="warn"?"text-status-warning":"text-muted-foreground"),children:L.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:L.message})]})},L.id))})]}):null]})]})},ss=t=>t,Vt=t=>{const s=ss(t).type;return typeof s=="string"?s:""},xi=t=>{const s=ss(t).tool;return typeof s=="string"?s:""},bi=t=>{const s=ss(t).text;return typeof s=="string"?s:""},wi=t=>{const s=Vt(t);return s==="tool"?xi(t).trim().toLowerCase()||"tool":s||"unknown"},yi=t=>{if(t.length===0)return"";const s=[];for(const r of t){const a=wi(r);s.includes(a)||s.push(a)}return s.join(" + ")},vi=t=>t.replace(/\s+/g," ").trim(),ji=t=>{for(const r of t)if(Vt(r)==="text"){const a=vi(bi(r));if(a.length===0)continue;return a}const s=t.filter(r=>Vt(r)!=="text").length;return s===0?"":`${s} attachment${s===1?"":"s"}`},Si=(t,s,r)=>`${r(t)} / ${r(s)}`,ki=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Ci=(t,s)=>{if(!t||!Number.isFinite(t))return"-";const r=ki(s);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:r===!1?"2-digit":"numeric",minute:"2-digit",...r===void 0?{}:{hour12:r}})},Ni={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},St={user:0,assistant:0,tool:0,other:0},Pi=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,Mt=t=>$t(t),Ri=(...t)=>{for(const s of t)if(typeof s=="string"&&s.trim().length>0)return s;return""},We=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((s,r)=>s+We(r),0):t&&typeof t=="object"?Object.values(t).reduce((s,r)=>s+We(r),0):0,Ei=(t,s)=>{const r=t,a=typeof r.type=="string"?r.type:"";if(a==="reasoning")return{...St,assistant:We(r.text)+We(r.content)};const i=Ri(r.text,r.content,r.value,r.source?.value,r.source?.text?.value);return a==="tool"||s==="tool"?{user:0,assistant:0,tool:We(r.input)+We(r.output)+We(r.error)+We(r.call?.input)+We(r.call?.output)+We(r.call?.error)+We(r.raw)+Math.round(We(r.metadata)*.25)+Math.round(We(r.state)*.1),other:0}:s==="user"?{user:i.length,assistant:0,tool:0,other:0}:s==="assistant"?{user:0,assistant:i.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:i.length}},Is=(t,s)=>({user:t.user+s.user,assistant:t.assistant+s.assistant,tool:t.tool+s.tool,other:t.other+s.other}),Ti=t=>{const s=pt(t.info);return s.isUser?"user":s.role==="assistant"?"assistant":s.role==="tool"?"tool":"other"},Di=(t,s)=>{if(t.length===0)return{...St};const r=t.reduce((a,i)=>{const o=Ti(i);let u={...St};for(const l of i.parts)u=Is(u,Ei(l,o));return Is(a,u)},{...St});return r.user+=s.length,{user:Math.ceil(r.user/4),assistant:Math.ceil(r.assistant/4),tool:Math.ceil(r.tool/4),other:Math.ceil(r.other/4)}},Ge=t=>t.toLocaleString("en-US"),Ai=t=>!Number.isFinite(t)||t<=0?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(0):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:t<.01?4:2,maximumFractionDigits:t<.01?4:2}).format(t),_i=(t,s)=>!t||!Number.isFinite(t)?"-":qr(t,s,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Mi=(t,s,r)=>{const a=t.find(o=>o.id===s),i=a?.models?.find(o=>o.id===r);return{providerName:a?.name||s||"-",modelName:i?.name||r||"-",contextLimit:typeof i?.limit?.context=="number"?i.limit.context:null}},Ii=()=>{const t=K(p=>p.timeFormatPreference),[s,r]=n.useState({}),{value:a,show:i,clear:o}=Vr(null,2e3),u=Me(p=>p.currentSessionId),l=Me(p=>p.currentSessionDirectory),c=Kr(),h=sn(u??""),f=Ze(p=>p.providers);n.useEffect(()=>{r(p=>Object.keys(p).length>0?{}:p),o()},[o,l,u]);const y=n.useCallback(async(p,C)=>{(await ct(C)).ok?i(p):o()},[o,i]),d=n.useMemo(()=>{const p=u?c.find(D=>D.id===u)??null:null,C=h.filter(D=>pt(D.info).role==="assistant"),x=h.filter(D=>pt(D.info).isUser);let P=null;for(let D=C.length-1;D>=0;D-=1){const O=C[D];if(Mt(O).total>0){P=O;break}}const _=P?Mt(P):Ni,U=P?.info?.usage,w=Qs({input:_.input,cache:{read:_.cacheRead,write:_.cacheWrite}}),E=C.reduce((D,O)=>{const G=Pi(O.info.cost);return D+G},0),S=P?.info?.model??null,M=Mi(f,S?.providerID||"",S?.modelID||""),j=M.contextLimit,T=U?Zs(U):_.total,Y=j&&j>0?Math.min(999,T/j*100):0,X=[...h].reverse().find(D=>pt(D.info).isUser&&typeof D.info.system=="string")?.info?.system||"",z=Di(h,X),Z=z.user,le=z.assistant,H=z.tool,ne=U?0:Math.max(0,_.input-Z-le-H),N=Z+le+H+ne,F=h[0]?.info?.time?.created,oe=h.length>0?h[h.length-1]?.info?.time?.created:null;return{sessionTitle:nn(p),messagesCount:h.length,userMessagesCount:x.length,assistantMessagesCount:C.length,createdAt:p?.time?.created??F??null,lastActivityAt:oe??p?.time?.created??null,providerModel:M,tokenBreakdown:_,usagePercent:Y,cacheHitRate:w,totalAssistantCost:E,contextLimit:j,contextWindowTokens:T,hasUsage:U!==void 0,breakdown:{user:Z,assistant:le,tool:H,other:ne},breakdownTotal:N}},[u,f,h,c]);if(!u)return e.jsx("div",{className:"flex h-full items-center justify-center p-6 text-center typography-ui-label text-muted-foreground",children:"Open a session to inspect context."});const b=[{key:"user",label:"User",value:d.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:d.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool calls",value:d.breakdown.tool,color:"var(--status-warning)"},...d.hasUsage?[]:[{key:"other",label:"Other",value:d.breakdown.other,color:"var(--surface-muted-foreground)"}]];return e.jsx("div",{className:"h-full overflow-y-auto bg-background",children:e.jsxs("div",{className:"mx-auto w-full max-w-[52rem] px-5 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h2",{className:"typography-ui-header font-semibold text-foreground truncate",children:d.sessionTitle}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-subtle-foreground",children:[e.jsxs("span",{children:[d.providerModel.providerName," / ",d.providerModel.modelName]}),d.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:_i(d.createdAt,t)})]})]})]}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Context"}),e.jsxs("span",{className:"typography-micro tabular-nums text-subtle-foreground",children:[Ge(d.contextWindowTokens),d.contextLimit?` / ${Ge(d.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:d.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,d.usagePercent)}%`,backgroundColor:d.usagePercent>80?"var(--status-warning)":"var(--primary-base)"}})}),e.jsx("div",{className:"mt-1.5 typography-micro font-medium tabular-nums text-foreground/80",children:`${d.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:Ge(d.messagesCount)},{label:"User",value:Ge(d.userMessagesCount)},{label:"Assistant",value:Ge(d.assistantMessagesCount)},{label:"Cost",value:Ai(d.totalAssistantCost)}].map(p=>e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[e.jsx("div",{className:"typography-micro text-subtle-foreground",children:p.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:p.value})]},p.label))}),e.jsxs("div",{className:"mb-5 rounded-lg bg-[var(--surface-elevated)]/70 px-4 py-3.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground mb-2.5",children:"Last assistant message"}),e.jsx("div",{className:"grid grid-cols-3 gap-x-4 gap-y-2.5",children:[{label:"Input",value:d.tokenBreakdown.input,format:"count"},{label:"Output",value:d.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:d.tokenBreakdown.reasoning,format:"count"},{label:"Cache read",value:d.tokenBreakdown.cacheRead,format:"count"},{label:"Cache write",value:d.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache hit",value:d.cacheHitRate.hasInput?d.cacheHitRate.percent:null,format:"percent"}].map(p=>e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-subtle-foreground",children:p.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:p.value!==null&&p.value!==void 0?p.format==="percent"?`${p.value.toFixed(1)}%`:Ge(p.value):"—"})]},p.label))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:b.map(p=>p.value<=0||d.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${p.value/d.breakdownTotal*100}%`,backgroundColor:p.color}},p.key))}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:b.map(p=>{const C=d.breakdownTotal>0?p.value/d.breakdownTotal*100:0;return e.jsxs("div",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full",style:{backgroundColor:p.color}}),e.jsxs("span",{className:"typography-micro text-subtle-foreground",children:[p.label," ",e.jsxs("span",{className:"tabular-nums",children:[C.toFixed(0),"%"]})]})]},p.key)})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground",children:"Raw messages"}),e.jsx("div",{className:"mt-2.5 space-y-1",children:[...h].reverse().map(p=>{const x=pt(p.info).role,P=x==="assistant",_=x==="user",U=s[p.info.id]===!0,w=a===p.info.id,E=p.info.time?.created??null,S=yi(p.parts),M=P?Mt({info:p.info,parts:p.parts}):null,j=_?ji(p.parts):"",T=Ci(E,t),Y=S||"—",X=M?Si(M.input,M.output,Ge):"",z=x||"unknown",Z=S?`${z}: ${S}`:z,le=U?JSON.stringify({info:p.info,parts:p.parts},null,2):"";return e.jsxs("div",{className:"overflow-hidden rounded-lg bg-[var(--surface-elevated)]/70",children:[e.jsx("button",{type:"button",className:"w-full cursor-pointer px-3 py-1.5 text-left hover:bg-[var(--interactive-hover)]","aria-expanded":U,onClick:()=>{r(H=>({...H,[p.info.id]:H[p.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:P?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[_?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",j]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:P?Y:Z}),P&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:X})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:T})]})}),U&&e.jsx("div",{className:"border-t border-[var(--surface-subtle)] p-0",children:e.jsxs("div",{className:"group relative max-h-[26rem] w-full overflow-auto bg-[var(--surface-background)]",children:[e.jsx("div",{className:"absolute top-1 right-2 z-10 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx("button",{type:"button",className:"rounded p-1 text-muted-foreground transition-colors hover:bg-interactive-hover/60 hover:text-foreground",onClick:H=>{H.stopPropagation(),y(p.info.id,le)},"aria-label":w?"Copied":"Copy JSON",title:w?"Copied":"Copy",children:w?e.jsx(W,{name:"check",className:"size-3.5"}):e.jsx(W,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Xr,{language:"json",code:le,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},p.info.id)})})]})]})})},Li=n.lazy(()=>Oe(()=>import("./AgentsSurface-CcWBqAWV.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13])).then(t=>({default:t.AgentsSurface}))),Bi=Ke(()=>Oe(()=>import("./DiffView-CiZy4jFA.js"),__vite__mapDeps([14,1,2,3,5,6,7,8,9,10,4,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(t=>({default:t.DiffView}))),Oi=Ke(()=>Oe(()=>import("./FilesView-DqiZ9kw9.js"),__vite__mapDeps([56,1,2,3,5,6,7,8,9,10,4,11,12,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,53,54,35,36,20,21,22,23,24,25,26,27,28,29,30,31,32,33,73,74,48,49,50,51,52,75,76,17,18,19,34,37,38,39,40,41,42,43,77,78,79,80,81,47])).then(t=>({default:t.FilesView}))),$i=Ke(()=>Oe(()=>import("./GitView--EaZQrBr.js"),__vite__mapDeps([82,7,1,2,3,4,5,6,8,9,10,11,12,48,49,50,51,52,15,83,84,85,86,46,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,47,53,54])).then(t=>({default:t.GitView}))),Fi=Ke(()=>Oe(()=>import("./PullRequestsSurface-iXy6chwc.js"),__vite__mapDeps([87,7,1,2,3,88,5,6,8,9,10,4,11,12,48,49,50,51,52,89,83,84,46,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,47,53,54])).then(t=>({default:t.PullRequestsSurface}))),Wi=Ke(()=>Oe(()=>import("./IssuesSurface-CySTpaD1.js"),__vite__mapDeps([90,1,2,3,88,5,6,7,8,9,10,4,11,12,48,49,50,51,52,89,83,84,91])).then(t=>({default:t.IssuesSurface}))),zi=380,Hi=1400,Sn=600,Ui=100,Vi=24,Ls=720,Bs=t=>Number.isFinite(t)?Math.min(Hi,Math.max(zi,Math.round(t))):Sn,Ki=t=>{const s=t?.parentElement?.clientWidth;return!s||s<=0?null:s},Xi=(t,s)=>{if(!t)return"";const r=t.replace(/\\/g,"/"),a=s.replace(/\\/g,"/").replace(/\/+$/,"");return a&&r.startsWith(a+"/")?r.slice(a.length+1):r},Kt=(t,s=null)=>t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?es(s).label:t==="terminal"?"Terminal":t==="pull-requests"?"Pull requests":t==="issues"?"Issues":t==="extensions"?"Extensions":t==="agents"?"Agents":"Context",kn=t=>{if(!t)return null;const s=t.replace(/\\/g,"/").trim();if(!s)return null;const r=s.split("/").filter(Boolean);return r.length===0?s:r[r.length-1]||null},qi=(t,s=null)=>{if(t.label)return t.label;if(t.mode==="file")return kn(t.targetPath)||"Files";if(t.mode==="preview"){const r=t.targetPath;if(r)try{const a=new URL(r);return a.host||a.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":Kt(t.mode,s)},It=(t,s=null)=>{if(t.mode==="file")return t.targetPath?e.jsx(Ct,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return e.jsx(Rr,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(W,{name:es(s).icon,className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(W,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(W,{name:"pie-chart",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(W,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(W,{name:"global",className:"h-3.5 w-3.5"});if(t.mode==="pull-requests")return e.jsx(W,{name:"git-pull-request",className:"h-3.5 w-3.5"});if(t.mode==="issues")return e.jsx(W,{name:"task",className:"h-3.5 w-3.5"});if(t.mode==="extensions")return e.jsx(W,{name:"plug-2",className:"h-3.5 w-3.5"});if(t.mode==="agents")return e.jsx(W,{name:"robot-2",className:"h-3.5 w-3.5"})},Yi=(t,s)=>t.length<=s?t:`${t.slice(0,s-3)}...`,Gi=()=>{const t=bt()??"",s=n.useMemo(()=>Be(t),[t]),r=K(v=>s?v.contextPanelByDirectory[s]:void 0),a=K(v=>v.closeContextPanel),i=K(v=>v.closeContextPanelTab),o=K(v=>v.openContextPanelTab),u=K(v=>v.toggleContextPanelExpanded),l=K(v=>v.setContextPanelWidth),c=K(v=>v.setActiveContextPanelTab),h=K(v=>v.reorderContextPanelTabs),f=Ue(v=>v.setSelectedPath),y=K(v=>v.openContextPreview),d=K(v=>v.contextEditorTreeVisible),b=K(v=>v.toggleContextEditorTree),p=Me(v=>v.currentSessionId),C=n.useMemo(()=>r?.tabs??[],[r?.tabs]),x=C.find(v=>v.id===r?.activeTabId)??C[C.length-1]??null,P=!!(r?.isOpen&&x),_=!!(P&&r?.expanded),[U,w]=n.useState(null),E=r?.width,S=Jr,M=U??(typeof window<"u"?window.innerWidth:Sn*2),j=Bs(E??Math.round(S*M)),T=rn(s||null),[Y,X]=n.useState(!1),[z,Z]=n.useState(null),[le,H]=n.useState(null),[ne,N]=n.useState(null),[F,oe]=n.useState(null),D=n.useRef(0),O=n.useRef(j),G=n.useRef(null),ue=n.useRef(null),ge=n.useRef(null),he=n.useRef(!1);n.useLayoutEffect(()=>{const v=ge.current?.parentElement;if(!v||typeof ResizeObserver>"u")return;const me=new ResizeObserver(()=>{w(v.clientWidth||null)});return me.observe(v),w(v.clientWidth||null),()=>me.disconnect()},[]),n.useEffect(()=>{if(!P||he.current){he.current=P;return}const v=window.requestAnimationFrame(()=>{ge.current?.focus({preventScroll:!0})});return he.current=!0,()=>window.cancelAnimationFrame(v)},[P]);const be=n.useRef(null),je=n.useRef(null),Ce=n.useCallback(()=>{je.current=null;const v=ge.current,me=G.current;!v||me===null||v.style.setProperty("--oc-context-panel-width",`${me}px`)},[]);n.useEffect(()=>()=>{je.current!==null&&clearTimeout(je.current)},[]);const ve=n.useCallback(v=>{const me=Bs(v),Ae=be.current;return Ae===null?me:Math.min(me,Math.max(1,Ae))},[]),ye=n.useCallback(v=>{!P||_||!s||(ue.current=v.pointerId,X(!0),D.current=v.clientX,O.current=j,G.current=j,be.current=Ki(ge.current),document.documentElement.style.cursor="col-resize",v.preventDefault())},[s,_,P,j]),Re=n.useCallback(()=>{const v=ve(G.current??j);G.current=null,be.current=null,je.current!==null&&(clearTimeout(je.current),je.current=null),document.documentElement.style.cursor="",s&&l(s,v),X(!1),ue.current=null},[ve,s,l,j]);n.useEffect(()=>{if(!Y)return;const v=$e=>{if(ue.current!==$e.pointerId)return;const Nn=D.current-$e.clientX,ns=ve(O.current+Nn);G.current!==ns&&(G.current=ns,je.current===null&&(je.current=setTimeout(Ce,Ui)))},me=$e=>{ue.current===$e.pointerId&&Re()},Ae=()=>{Re()};return window.addEventListener("pointermove",v),window.addEventListener("pointerup",me),window.addEventListener("pointercancel",me),window.addEventListener("blur",Ae),()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",me),window.removeEventListener("pointercancel",me),window.removeEventListener("blur",Ae)}},[Ce,ve,Re,Y]),n.useEffect(()=>{Y||(G.current=null,document.documentElement.style.cursor="")},[Y]);const Te=n.useCallback(()=>{s&&a(s)},[a,s]),Se=n.useCallback(()=>{s&&u(s)},[s,u]),ke=n.useCallback(v=>{v.key==="Escape"&&(Yr(v.target)||(v.preventDefault(),v.stopPropagation(),Te()))},[Te]);n.useEffect(()=>{if(!(!s||!x)&&x.mode==="file"&&x.targetPath){f(s,x.targetPath,{allowOutsideRoot:!0});return}},[x,s,f]);const Ne=n.useCallback(v=>{!s||x?.mode!=="diff"||o(s,{mode:"diff",targetPath:x.targetPath,stagedDiff:v==="staged",diffScope:v})},[x,s,o]),De=x?.mode==="file"||x?.mode==="preview",B=n.useMemo(()=>x?C.filter(v=>v.mode===x.mode):[],[x,C]),J=n.useMemo(()=>B.map(v=>{const me=qi(v,T),Ae=Yi(me,Vi),$e=Xi(v.targetPath,t);return{id:v.id,label:Ae,icon:It(v,T),title:$e?`${me}: ${$e}`:me,closeLabel:`Close ${Ae} tab`}}),[B,t,T]),re=x?.mode==="pull-requests",L=x?.mode==="issues",ee=K(v=>v.gitReturnToFile?.directory===s?v.gitReturnToFile.focusPath:null),ae=x?.mode==="context"?e.jsx(Ii,{}):x?.mode==="extensions"?e.jsx(Gr,{sessionId:p}):x?.mode==="agents"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Li,{sessionId:p})}):x?.mode==="git"?e.jsx(n.Suspense,{fallback:null,children:e.jsx($i,{isActive:P,gitHeaderSlot:x?.mode==="git"?le:null,onlyFilePath:ee})}):x?.mode==="pull-requests"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Fi,{headerActionsSlot:re?F:null,headerActionsPresentation:"desktop"},`pull-requests:${s}`)}):x?.mode==="issues"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Wi,{headerActionsSlot:L?F:null,headerActionsPresentation:"desktop"},`issues:${s}`)}):x?.mode==="preview"?e.jsx(gi,{rawUrl:x.targetPath??"",onNavigate:v=>y(t,v)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(W,{name:"global",className:"h-12 w-12 text-subtle-foreground"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"Preview"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Use Project Actions or a terminal Preview button to open a preview."})]}),g=n.useMemo(()=>C.filter(v=>v.mode==="browser"),[C]),A=n.useMemo(()=>C.filter(v=>v.mode==="diff"),[C]),te=n.useMemo(()=>C.some(v=>v.mode==="terminal"),[C]),de=n.useMemo(()=>C.some(v=>v.mode==="file"),[C]),m=n.useMemo(()=>C.some(v=>v.mode==="file"&&v.targetPath),[C]),I=x?.mode==="file"?x.targetPath??null:null,V=_?U:j,pe=!!(m&&V!==null&&V<Ls),[Ee,Ie]=n.useState(!1);n.useEffect(()=>{Ie(!1)},[I]);const Le=!m&&V!==null&&V<Ls,Xe=Le?!0:pe?Ee:d,Ye=K(v=>v.fileTreeReveal);n.useEffect(()=>{Ye&&(pe?Ie(!0):K.getState().contextEditorTreeVisible||b())},[Ye,b,pe]);const k=n.useCallback(()=>{if(pe){Ie(v=>!v);return}b()},[b,pe]),q=x?.mode==="file",ce=K(v=>v.gitReturnToFile),ie=K(v=>v.clearGitReturnToFile),we=K(v=>v.showAllGitChanges),se=ce&&ce.directory===s&&x?.mode==="git"?C.find(v=>v.id===ce.tabId&&v.mode==="file"&&v.targetPath)??null:null;n.useEffect(()=>{ce&&(!P||x?.mode!=="git"||ce.directory!==s)&&ie()},[x?.mode,ie,s,ce,P]);const Pe=x?.mode==="terminal",_e=x?.mode==="git",He=x?.mode==="diff",R=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[De?e.jsx(un,{items:J,activeId:x?.id??null,onSelect:v=>{s&&c(s,v)},onClose:v=>{if(s){for(const me of C.find(Ae=>Ae.id===v)?.browser?.pages??[])Js(s,me.id);i(s,v)}},onReorder:(v,me)=>{s&&h(s,v,me)},layoutMode:"scrollable",variant:"default"}):Pe?e.jsx("div",{ref:v=>{Z(v)},className:"flex min-w-0 flex-1 items-center px-1"}):_e?e.jsx("div",{ref:v=>{H(v)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):He?e.jsx("div",{ref:v=>{N(v)},className:"flex min-w-0 flex-1 items-center overflow-hidden px-1"}):re||L?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[x?It(x,T):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:x?Kt(x.mode,T):null}),e.jsx("span",{className:"min-w-0 flex-1"}),e.jsx("div",{ref:v=>{oe(v)},className:"flex shrink-0 items-center gap-1"})]}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[x?It(x,T):null,e.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:x?Kt(x.mode,T):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[q&&!Le?e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:k,className:fe("h-8 w-8 p-0",Xe&&"bg-interactive-selection text-foreground"),title:Xe?"Hide file tree":"Show file tree","aria-label":"Toggle file tree","aria-pressed":Xe,children:e.jsx(W,{name:"node-tree",className:"size-4"})}):null,e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:Se,className:"h-8 w-8 p-0",title:_?"Collapse panel":"Expand panel","aria-label":_?"Collapse panel":"Expand panel",children:_?e.jsx(W,{name:"fullscreen-exit",className:"size-4"}):e.jsx(W,{name:"fullscreen",className:"size-4"})}),e.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:Te,className:"h-8 w-8 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(W,{name:"close",className:"size-4"})})]})]}),$=P?_?{"--oc-context-panel-width":U!==null?`${U}px`:"100%",width:U!==null?`${U}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${j}px`}:{"--oc-context-panel-width":`${j}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:ge,"data-context-panel":"true",tabIndex:-1,inert:!P||void 0,className:fe("flex min-h-0 flex-col overflow-hidden bg-background",_?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!P&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:ke,style:$,children:[P&&!_&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),P&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!_&&e.jsx("div",{className:fe("absolute left-0 top-0 z-50 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",Y&&"bg-[var(--interactive-border)]"),onPointerDown:ye,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:fe("relative z-10 flex h-full min-h-0 shrink-0 flex-col duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none","transition-[width,opacity]",!P&&"pointer-events-none select-none opacity-0"),style:{width:_?U!==null?`${U}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!P,children:[R,e.jsxs("div",{className:fe("relative min-h-0 flex-1 overflow-hidden",Y&&"pointer-events-none"),children:[de?e.jsxs("div",{className:fe("absolute inset-0 flex",q?"flex":"hidden"),children:[e.jsx("div",{className:"relative h-full min-w-0 flex-1",children:m?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Oi,{mode:"editor-only",isVisible:P&&q})}):Le?null:e.jsx(ui,{directory:t})}),e.jsx(di,{visible:Xe,overlay:pe||Le,onDismissOverlay:pe?()=>Ie(!1):void 0})]}):null,g.map(v=>e.jsx("div",{className:fe("absolute inset-0",x?.id!==v.id&&"hidden"),children:e.jsx(Ja,{directory:s,browser:v.browser,onScreen:P&&x?.id===v.id})},v.id)),P?A.filter(v=>x?.id===v.id).map(v=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(Bi,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:v.diffScope??(v.stagedDiff?"staged":"working"),onDiffScopeChange:Ne,targetFilePath:v.targetPath,flushContent:!0,toolbarSlot:He?ne:null})})},v.id)):null,te?e.jsx("div",{className:fe("absolute inset-0",x?.mode==="terminal"?"block":"hidden"),children:e.jsx(en,{visible:P&&x?.mode==="terminal",terminalHeaderSlot:Pe?z:null})}):null,P&&x?.mode==="git"?e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[se?e.jsxs("div",{className:"flex h-9 shrink-0 items-center border-b border-border/60 pl-1.5 pr-1",children:[e.jsxs(Q,{variant:"ghost",size:"xs",onClick:()=>{ie(),c(s,se.id)},className:"min-w-0 text-muted-foreground hover:text-foreground",children:[e.jsx(W,{name:"arrow-left",className:"size-3.5 shrink-0"}),e.jsx("span",{className:"truncate",children:`Back to ${kn(se.targetPath)??"file"}`})]}),ce?.focusPath?e.jsx(Q,{variant:"ghost",size:"xs",onClick:we,className:"ml-auto shrink-0 text-muted-foreground hover:text-foreground",children:"Show all changes"}):null]}):null,e.jsx("div",{className:"relative min-h-0 flex-1",children:ae})]}):P&&!q&&x?.mode!=="browser"&&x?.mode!=="diff"&&x?.mode!=="terminal"?ae:null]})]})]})},Ji=150,Qi=500,Zi=[],Je=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),yt=(t,s)=>{if(!t||typeof t!="object")return;const r=t[s];return typeof r=="number"&&Number.isFinite(r)?r:void 0},el=t=>t>99?"99+":String(t),tl=t=>t>=90?"text-[var(--status-error)]":t>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",sl=({surface:t,isActive:s,showActivityDot:r,label:a,description:i,badgeCount:o,badgeAriaLabel:u,badgeDescription:l,orderNumber:c,showOrderNumber:h,onSelect:f,chartPercentage:y,chartDetails:d})=>{const{attributes:b,listeners:p,setNodeRef:C,transform:x,transition:P,isDragging:_}=Hs({id:t.id}),U=o!=null&&o>0?el(o):null;return e.jsx("div",{ref:C,style:{transform:Us.Translate.toString(x),transition:P},className:fe("relative",_&&"z-10 opacity-70"),children:e.jsxs(et,{delayDuration:Ji,children:[e.jsx(tt,{asChild:!0,children:e.jsxs("button",{type:"button",...b,...p,onClick:()=>f(t),"aria-label":u??a,"aria-pressed":s,className:fe("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",s?"bg-interactive-selection text-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[t.id==="context"&&typeof y=="number"?e.jsx(gs,{percentage:y,className:"size-[18px] -rotate-90"}):e.jsx(W,{name:t.icon,className:"h-[18px] w-[18px]"}),h&&c!=null?e.jsx("span",{"aria-hidden":"true",className:"absolute right-0 top-0 flex h-4 min-w-4 items-center justify-center rounded-full bg-surface-muted px-1 text-[0.625rem] font-medium leading-none text-muted-foreground",children:c===10?"0":c}):U?e.jsx("span",{"aria-hidden":"true",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[0.625rem] font-semibold leading-none",style:{backgroundColor:"var(--status-info-background)",color:"var(--status-info)"},children:U}):r?e.jsx("span",{"aria-hidden":"true",className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-[var(--status-info)]"}):null]})}),e.jsx(st,{side:"left",sideOffset:8,className:t.id==="context"&&d?"p-0 border-0 bg-transparent shadow-none":void 0,children:t.id==="context"&&d?e.jsx("div",{className:"w-[300px] overflow-hidden rounded-lg border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_8px_24px_rgb(0_0_0_/_0.18)]",children:e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[e.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:e.jsx(gs,{percentage:d.percentage,className:"size-[18px] -rotate-90"})}),e.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:a}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:d.hasData?e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[e.jsxs("span",{className:fe("font-semibold",tl(d.percentage)),children:[d.percentage.toFixed(1),"%"]}),e.jsx("span",{className:"text-muted-foreground",children:`${Je(d.totalTokens)}/${Je(d.contextLimit)}`})]}):e.jsx("span",{className:"typography-micro text-muted-foreground",children:"No data yet"})})]}),d.hasData?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.totalTokens)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.contextLimit)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.outputLimit)})]}),typeof d.cacheRead=="number"&&typeof d.cacheWrite=="number"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.cacheRead)})]}),e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:Je(d.cacheWrite)})]})]}):null,typeof d.cacheHitPercent=="number"?e.jsxs("div",{className:"flex justify-between rounded-xl px-2.5 py-1.5 typography-micro",children:[e.jsx("span",{className:"text-muted-foreground",children:"Cache hit"}),e.jsx("span",{className:"font-medium text-foreground tabular-nums",children:`${d.cacheHitPercent.toFixed(1)}%`})]}):null]}):e.jsx("div",{className:"px-2.5 py-2 typography-micro text-muted-foreground",children:i})]})}):e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:a}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:i}),l?e.jsx("span",{className:"typography-micro text-muted-foreground",children:l}):null]})})]})})},nl=()=>{const t=bt(),s=t?Vn(t):"",r=K(g=>s?g.contextPanelByDirectory[s]:void 0),a=K(g=>g.contextRailOrder),i=K(g=>g.setContextRailOrder),o=K(g=>g.openContextSurface),u=K(g=>g.shortcutOverrides),{screenWidth:l}=kt(),{git:c,github:h}=Nt(),f=qt(s||null),y=rn(s||null),d=on(g=>g.ensureStatus),b=ps(g=>g.ensureScope);n.useEffect(()=>{s&&d(s,c)},[s,d,c]),n.useEffect(()=>{!s||!h||b(s,h)},[s,b,h]);const p=n.useMemo(()=>Kn("switch_context_surface",u),[u]),[C,x]=n.useState(!1);n.useEffect(()=>{const g=new Set;let A=null,te=!1;const de=Ee=>Ee.length===1&&Ee>="0"&&Ee<="9",m=()=>{as(p,g)?!te&&A===null&&(A=setTimeout(()=>x(!0),Qi)):(te=!1,A!==null&&(clearTimeout(A),A=null),x(!1))},I=Ee=>{if(g.add(Ee.key.toLowerCase()),de(Ee.key)&&as(p,g)){te=!0,A!==null&&(clearTimeout(A),A=null),x(!1);return}m()},V=Ee=>{g.delete(Ee.key.toLowerCase()),m()},pe=()=>{g.clear(),te=!1,A!==null&&(clearTimeout(A),A=null),x(!1)};return window.addEventListener("keydown",I,!0),window.addEventListener("keyup",V,!0),window.addEventListener("blur",pe),()=>{window.removeEventListener("keydown",I,!0),window.removeEventListener("keyup",V,!0),window.removeEventListener("blur",pe),A!==null&&clearTimeout(A)}},[p]);const P=$s(Bt(Dn,{activationConstraint:{distance:8}}),Bt(Tn,{activationConstraint:{delay:200,tolerance:6}})),_=r?.tabs??Zi,U=_.find(g=>g.id===r?.activeTabId)??null,w=r?.isOpen?U?.mode??null:null,E=f?.files.length??0,S=Me(g=>g.currentSessionId),M=Me(g=>!!g.newSessionDraft?.open),j=Ze(g=>g.providers),T=Ze(g=>g.currentProviderId),Y=Ze(g=>g.currentModelId),X=Ze(g=>g.getCurrentModel()),z=Ze(g=>g.getModelMetadata);Ze(g=>g.modelsMetadata.size);const Z=Qr(n.useCallback(g=>S?g.sessionModelSelections.get(S)??null:null,[S])),le=sn(S??""),H=n.useMemo(()=>{for(let g=le.length-1;g>=0;g-=1){const A=le[g];if(A?.info.role==="assistant")try{if($t(A).total>0)return A}catch{continue}}return null},[le]),N=n.useMemo(()=>{for(let g=le.length-1;g>=0;g-=1){const A=le[g]?.info;if(A.role!=="user")continue;const te=A.model,de=te?.providerID??te?.providerId,m=te?.modelID??te?.modelId;if(typeof de=="string"&&de.trim()&&typeof m=="string"&&m.trim())return{providerID:de,modelID:m}}return null},[le])??(()=>{const g=H?.info.model,A=g?.providerID??g?.providerId,te=g?.modelID??g?.modelId;return A&&te?{providerID:A,modelID:te}:null})()??(Z?{providerID:Z.providerId,modelID:Z.modelId}:null)??(T&&Y?{providerID:T,modelID:Y}:null),oe=(N?j.find(g=>g.id===N.providerID):void 0)?.models.find(g=>g.id===N?.modelID),D=N?z(N.providerID,N.modelID):void 0,O=yt(oe?.limit,"context")??D?.limit?.context??yt(X?.limit,"context")??0,G=yt(oe?.limit,"output")??D?.limit?.output??yt(X?.limit,"output")??0,ue=H?(()=>{try{return $t(H)}catch{return null}})():null,ge=H?.info?.usage,he=ge?Zs(ge):ue?.total??0,be=!M&&he>0&&O>0?Math.min(he/O*100,999):0,Ce=!M&&!!H&&he>0&&O>0?be:null,ve=ue?Qs({input:ue.input,cache:{read:ue.cacheRead,write:ue.cacheWrite}}):null,ye=ve?.hasInput?ve.percent:null,Re=n.useMemo(()=>{const g=!!H&&he>0&&O>0;return{percentage:be,totalTokens:he,contextLimit:O,outputLimit:G,cacheRead:ue?.cacheRead??null,cacheWrite:ue?.cacheWrite??null,cacheHitPercent:ye,hasData:g}},[ue,ye,O,H,G,be,he]),Te=ms(g=>S?g.reducer.bySession.get(S)?.extensionWidgets:void 0,(g,A)=>g===A,S?`session:${S}`:"chrome"),Se=n.useMemo(()=>Te?.size?[...Te.entries()].map(([g,A])=>`${g}:${A.lines.join(`
|
|
137
|
+
`)}`).join(";"):"",[Te]),ke=Se!=="",Ne=n.useRef({});n.useEffect(()=>{w==="extensions"&&S&&Se&&(Ne.current[S]=Se)},[w,S,Se]);const De=S?Ne.current[S]??"":"",B=w!=="extensions"&&Se!==""&&De!==Se,J=ms(g=>S?Zr(g.reducer.bySession.get(S)):!1,void 0,S?`session:${S}`:"chrome"),re=ps(g=>s?g.entriesByDirectory[s]??null:null),L=n.useMemo(()=>{if(!re)return{isLoading:!0,hasResult:!1,hasGitHubRepo:!1,hasError:!1};const g=re.scope?.repositories??[];return{isLoading:re.isLoading,hasResult:!!(re.scope||re.error),hasGitHubRepo:g.some(A=>!!(A.host&&A.owner&&A.repo&&!A.disabledReason)),hasError:!!(re.error&&!re.scope)}},[re]),ee=n.useMemo(()=>eo({railOrder:a,tabs:_,githubScope:L,hasExtensionContent:ke,hasAgentContent:J}),[a,l,_,L,ke,J]),ae=n.useCallback(g=>{const{active:A,over:te}=g;if(!te||A.id===te.id)return;const de=to(K.getState().contextRailOrder).map(V=>V.id),m=de.indexOf(A.id),I=de.indexOf(te.id);m===-1||I===-1||i(An(de,m,I))},[i]);return s?e.jsx("nav",{"aria-label":"Panel surfaces",className:"flex h-full w-11 flex-shrink-0 flex-col items-center gap-1 bg-background py-2",children:e.jsx(Fs,{sensors:P,collisionDetection:Ws,onDragEnd:ae,children:e.jsx(zs,{items:ee.map(g=>g.id),strategy:_n,children:ee.map((g,A)=>{const te=g.id==="git"?es(y):null,de=te?{...g,...te}:g,m=de.label,I=g.id==="git"&&y===!0?E:0,V=I>0?I:null,pe=g.id==="context",Ee=g.id==="extensions"?B:!1;return e.jsx(sl,{surface:de,isActive:w===g.mode,showActivityDot:Ee,label:m,description:de.description,badgeCount:V,badgeAriaLabel:V!==null?V===1?`${m}, ${V} changed file`:`${m}, ${V} changed files`:null,badgeDescription:V!==null?V===1?`${V} changed file`:`${V} changed files`:null,chartPercentage:pe?Ce:void 0,chartDetails:pe?Re:void 0,orderNumber:A+1,showOrderNumber:C,onSelect:Ie=>o(s,Ie.mode)},g.id)})})})}):null},rl=(t,s)=>!t||s.length===0?"":JSON.stringify([t,s]),ol=(t,s,r,a)=>!r||a!==r||t.length===0?[]:ft(t,s,i=>i.name,{limit:10,threshold:.4}),al=new Set,il=[{keys:["↑","↓"],label:"Navigate"},{keys:["↵"],label:"Open"},{keys:["Esc"],label:"Close"}],Lt=t=>{if(!t)return"";const s=t.replace(/\\/g,"/"),r=s.startsWith("//");let a=s.replace(/\/+/g,"/");r&&!a.startsWith("//")&&(a=`/${a}`);const i=a==="/",o=/^[A-Za-z]:\/$/.test(a);return!i&&!o&&(a=a.replace(/\/+$/,"")),a},ll=()=>{const t=K(m=>m.isCommandPaletteOpen),s=K(m=>m.setCommandPaletteOpen),r=K(m=>m.setActiveMainTab),a=K(m=>m.setSettingsDialogOpen),i=K(m=>m.setSettingsPage),o=K(m=>m.setSessionSwitcherOpen),u=K(m=>m.toggleSidebar),l=K(m=>m.openContextOverview),c=K(m=>m.openContextSurface),h=K(m=>m.openContextFile),f=K(m=>m.shortcutOverrides),y=Me(m=>m.openNewSessionDraft),d=Me(m=>m.setCurrentSession),b=so({archived:!1}),p=no(n.useCallback(m=>t?m.ids:al,[t])),C=ro(n.useCallback(m=>t?m.rankById:oo,[t])),x=is(m=>m.currentDirectory),P=is(m=>m.homeDirectory),_=xs(m=>m.getActiveProject()),U=xs(m=>m.projects),w=bt(),E=Xn(m=>m.searchFiles),{files:S,git:M}=Nt(),j=on(m=>m.ensureStatus),{isMobile:T}=kt(),Y=n.useMemo(()=>w?Lt(w):null,[w]),[X,z]=n.useState(""),le=ao(X,200).trim(),H=X.trim();n.useEffect(()=>{t&&z("")},[t]),n.useEffect(()=>{if(!t||!M)return;const m=setTimeout(()=>{const I=new Set;for(const V of b){const pe=Tt(V);!pe||I.has(pe)||(I.add(pe),j(pe,M))}},0);return()=>clearTimeout(m)},[t,b,M,j]);const ne=n.useCallback(()=>s(!1),[s]),N=n.useCallback(m=>()=>{ne(),m()},[ne]),F=n.useMemo(()=>{const m=[{id:"new-session",title:"New session",icon:e.jsx(W,{name:"chat-new",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New session",onSelect:N(()=>{r("chat"),o(!1),y()})},{id:"add-project",title:"Add folder",icon:e.jsx(W,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add folder",onSelect:N(()=>{io.requestDirectoryDialog()})},{id:"toggle-sidebar",title:T?"Show session switcher":"Toggle sidebar",icon:e.jsx(W,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:T?"Show session switcher":"Toggle sidebar",onSelect:N(()=>{if(T){const{isSessionSwitcherOpen:I}=K.getState();o(!I)}else u()})},{id:"toggle-terminal",title:"Toggle terminal",icon:e.jsx(W,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:"Toggle terminal",onSelect:N(()=>{x&&c(x,"terminal")})},{id:"context-usage",title:"Show context usage",icon:e.jsx(W,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show context usage",onSelect:N(()=>{x&&l(x)})},{id:"open-settings",title:"Open settings…",icon:e.jsx(W,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open settings…",onSelect:N(()=>a(!0))}];return qn()&&m.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat window",icon:e.jsx(W,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat window",onSelect:N(()=>{Vs("desktop_open_draft_mini_chat_window",{directory:Lt(x||_?.path||""),projectId:_?.id??null}).catch(I=>{console.warn("[command-palette] failed to open draft mini chat window",I)})})}),m},[N,T,r,o,y,u,c,x,l,a,_?.id,_?.path]),oe=n.useMemo(()=>{const m=Ks();return{isWeb:!m&&Yn(),isDesktop:m,isMobile:T}},[T]),D=n.useMemo(()=>Er.filter(m=>m.slug!=="home").filter(m=>m.isAvailable?m.isAvailable(oe):!0).map(m=>{const I=Tr(m.slug)??"settings-3",V=(m.keywords??[]).join(" ");return{id:`settings:${m.slug}`,title:m.title,icon:e.jsx(W,{name:I,className:"mr-2 h-4 w-4"}),searchText:`${m.title} ${m.group} ${V}`,onSelect:N(()=>{i(m.slug),a(!0)})}}),[oe,N,i,a]),O=n.useMemo(()=>lo(b,p,C),[b,p,C]),G=co(),ue=n.useCallback(m=>{if(!m)return null;let I=null;for(const V of U){const pe=V.path.replace(/\/+$/,"");(m===pe||m.startsWith(`${pe}/`))&&(!I||pe.length>I.path.length)&&(I=V)}return I},[U]),ge=n.useCallback((m,I)=>{if(!m)return null;const V=G.get(m)?.trim()||null;if(!V||V==="HEAD"||!I)return V;const pe=I.path.replace(/\/+$/,"");return m===pe||V===G.get(pe)?.trim()?null:V},[G]),[he,be]=n.useState([]),[je,Ce]=n.useState(""),ve=rl(Y,le);n.useEffect(()=>{if(!t){be([]),Ce("");return}if(!ve){be([]),Ce("");return}if(!Y){be([]),Ce("");return}let m=!1;return E(Y,le,10,{type:"file"}).then(I=>{m||(be(I.map(V=>({path:Lt(V.path),name:V.name,relativePath:V.relativePath}))),Ce(ve))}).catch(()=>{m||(be([]),Ce(ve))}),()=>{m=!0}},[t,Y,le,ve,E]);const ye=H.length>0,Re=n.useMemo(()=>ye?ft(F,H,m=>m.searchText,{limit:7,noFuzzy:!0}):F.map(m=>({item:m,score:0})),[F,H,ye]),Te=n.useMemo(()=>ye?ft(D,H,m=>m.searchText,{limit:7,noFuzzy:!0}):[],[D,H,ye]),Se=n.useMemo(()=>ye?ft(O,H,m=>m.title||"",{limit:7,threshold:.2}):O.slice(0,5).map(m=>({item:m,score:0})),[O,H,ye]),ke=n.useMemo(()=>t?ol(he,le,ve,je):[],[t,he,je,ve,le]),Ne=t&&ve.length>0&&je!==ve,De=n.useMemo(()=>{if(!ye)return[];const m=U.map(I=>({...I,displayName:I.label||I.path.split("/").pop()||I.path,searchText:`${I.label||""} ${I.path}`}));return ft(m,H,I=>I.searchText,{limit:7,threshold:.4})},[U,H,ye]),B=Re.map(m=>m.item),J=Te.map(m=>m.item),re=Se.map(m=>m.item),L=ye?ke.map(m=>m.item):[],ee=ye?De.map(m=>m.item):[],ae=n.useMemo(()=>{if(!ye)return["commands","sessions"];const m=V=>V.length?V[0].score:1/0,I=[{key:"commands",score:m(Re)},{key:"settings",score:m(Te)},{key:"sessions",score:m(Se)},{key:"files",score:m(ke)},{key:"projects",score:m(De)}];return I.sort((V,pe)=>V.score-pe.score),I.map(V=>V.key)},[ye,Re,Te,Se,ke,De]),g=n.useCallback(m=>{ne(),d(m.id,Tt(m))},[ne,d]),A=n.useCallback(async m=>{if(!Y)return;const I=await cn(S,m,{directory:Y});if(!I.ok){xe.error(dn(I.reason));return}h(Y,m),ne()},[Y,S,h,ne]),te=n.useCallback((m,I)=>{ne(),y({selectedProjectId:m,directoryOverride:I})},[ne,y]),de=n.useCallback(m=>qs(Ys(m,f)),[f]);return e.jsxs(Yt,{open:t,onOpenChange:s,children:[e.jsxs(Jt,{className:"sr-only",children:[e.jsx(Qt,{children:"Command palette"}),e.jsx(Zt,{children:"Search files, sessions, and commands."})]}),e.jsxs(Gt,{showCloseButton:!1,className:fe("w-full max-w-xl gap-0 self-start overflow-hidden rounded-2xl p-0","mt-[max(env(safe-area-inset-top),0.25rem)] max-h-[calc(100%-0.5rem)] sm:mt-[10vh] sm:max-h-[80vh]"),children:[e.jsxs(uo,{shouldFilter:!1,className:fe("rounded-none","[&_[data-slot=command-input-wrapper]]:h-12 [&_[data-slot=command-input-wrapper]]:border-border/60 [&_[data-slot=command-input-wrapper]]:px-3.5","[&_[cmdk-input]]:h-12 [&_[cmdk-input]]:text-[length:var(--text-markdown)] md:[&_[cmdk-input]]:text-[length:var(--text-ui-label)]","[&_[cmdk-list]]:p-1.5 [&_[cmdk-group]]:p-0 [&_[cmdk-group]+[cmdk-group]]:mt-1","[&_[cmdk-group-heading]]:px-2.5 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-1.5 [&_[cmdk-group-heading]]:text-[length:var(--text-micro)]","[&_[cmdk-item]]:gap-2.5 [&_[cmdk-item]]:px-2.5 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]]:text-[length:var(--text-ui-label)]"),children:[e.jsx(ho,{value:X,onValueChange:z,placeholder:"Search files, sessions, commands..."}),e.jsxs(fo,{children:[e.jsx(po,{children:"No results found."}),ae.map(m=>m==="commands"&&B.length>0?e.jsx(ut,{heading:"Commands",children:B.map(I=>e.jsxs(ht,{value:I.id,onSelect:I.onSelect,children:[I.icon,e.jsx("span",{children:I.title}),I.shortcutId?e.jsx(mo,{children:de(I.shortcutId)}):null]},I.id))},"commands"):m==="settings"&&J.length>0?e.jsx(ut,{heading:"Settings",children:J.map(I=>e.jsxs(ht,{value:I.id,onSelect:I.onSelect,children:[I.icon,e.jsx("span",{children:I.title})]},I.id))},"settings"):m==="sessions"&&re.length>0?e.jsx(ut,{heading:"Sessions",children:re.map(I=>{const V=nn(I),pe=Tt(I),Ee=ue(pe),Ie=ge(pe,Ee),Le=Ee?go(Ee):xo(pe,P)?"No folder":null;return e.jsxs(ht,{value:`session:${I.id}`,onSelect:()=>g(I),children:[e.jsx(W,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:V}),Le||Ie?e.jsxs("span",{className:"ml-auto inline-flex min-w-0 max-w-[45%] shrink items-center gap-1.5 text-muted-foreground typography-meta",children:[Le?e.jsx("span",{className:"min-w-0 max-w-[140px] shrink-0 truncate",children:Le}):null,Ie?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1",children:[e.jsx(W,{name:"git-branch",className:"h-3 w-3 shrink-0"}),e.jsx(bo,{value:Ie,className:"min-w-0 max-w-[120px]"})]}):null]}):null]},I.id)})},"sessions"):m==="files"&&L.length>0?e.jsx(ut,{heading:"Files",children:L.map(I=>{const V=Gn(I.relativePath||I.name,{maxLength:80});return e.jsxs(ht,{value:`file:${I.path}`,onSelect:()=>{A(I.path)},children:[e.jsx(Ct,{filePath:I.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":I.relativePath,children:V})]},`file:${I.path}`)})},"files"):m==="projects"&&ee.length>0?e.jsx(ut,{heading:"Projects",children:ee.map(I=>{const V=I.displayName;return e.jsxs(ht,{value:`project:${I.id}`,onSelect:()=>te(I.id,I.path),children:[e.jsx(wo,{directory:I.path,label:V,className:"mr-2 size-4"}),e.jsx("span",{className:"truncate",children:V}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:I.path})]},`project:${I.id}`)})},"projects"):null),Ne?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]}),T?null:e.jsx("div",{className:"flex min-h-10 shrink-0 items-center border-t border-border/60 bg-[var(--surface-muted)]/40 px-3 py-2 typography-micro text-muted-foreground",children:e.jsx(yo,{hints:il.map(m=>m.label==="Close"?{...m,onSelect:()=>s(!1)}:m)})})]})]})},cl=(t,s,r)=>Qn(t)?qs(Ys(t,r)):s,dl=()=>{const t=K(o=>o.isHelpDialogOpen),s=K(o=>o.setHelpDialogOpen),r=K(o=>o.shortcutOverrides),a=Jn(),i=[{categoryKey:"Navigation & commands",items:[{id:"open_command_palette",descriptionKey:"Open command palette",icon:"command",keys:""},{id:"open_help",descriptionKey:"Show Keyboard Shortcuts (this dialog)",icon:"question",keys:""},{id:"toggle_sidebar",descriptionKey:"Toggle session sidebar",icon:"layout-left",keys:""},{id:"add_selection_to_chat",descriptionKey:"Add selection to chat",icon:"add",keys:""},{id:"open_model_selector",descriptionKey:"Open model selector",icon:"ai-generate-2",keys:""},{keys:["↑↓"],descriptionKey:"Navigate Models (in picker)",icon:"ai-generate-2"},{keys:["←→"],descriptionKey:"Adjust Thinking Mode (in picker, when supported)",icon:"brain-ai-3"},{id:"cycle_thinking_variant",descriptionKey:"Cycle thinking (global shortcut)",icon:"brain-ai-3",keys:""},{keys:[`Shift + Alt + ${a} + N`],descriptionKey:"New Window (desktop only)",icon:"window"}]},{categoryKey:"Session management",items:[{id:"new_chat",descriptionKey:"Create new session",icon:"add",keys:""},{id:"focus_input",descriptionKey:"Focus chat input",icon:"text",keys:""},{id:"cycle_session_folder",descriptionKey:"Cycle session folder",icon:"folder-open",keys:""},{id:"cycle_draft_folder",descriptionKey:"Cycle draft folder",icon:"folder-3",keys:""},{id:"open_timeline_dialog",descriptionKey:"Open conversation timeline",icon:"history",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"open_right_sidebar",descriptionKey:"Open right sidebar",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{keys:[`${a} + 1...0`],descriptionKey:"Switch Context Panel Surface (number key)",icon:"layout-right"}]},{categoryKey:"Interface",items:[{id:"cycle_theme",descriptionKey:"Cycle Theme (Light → Dark → System)",icon:"palette",keys:""},{id:"toggle_services_menu",descriptionKey:"helpDialog.item.toggleServicesMenu",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"Open settings",icon:"settings-3",keys:""}]}];return e.jsx(Yt,{open:t,onOpenChange:s,children:e.jsxs(Gt,{className:"w-[92vw] max-w-[1120px] h-[84vh] max-h-[900px] flex flex-col overflow-hidden",children:[e.jsxs(Jt,{children:[e.jsxs(Qt,{className:"flex items-center gap-2",children:[e.jsx(W,{name:"command",className:"h-5 w-5"}),"Keyboard shortcuts"]}),e.jsx(Zt,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:e.jsx("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 md:gap-x-10",children:i.map(o=>e.jsxs("div",{className:"min-w-0 break-inside-avoid",children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:o.categoryKey}),e.jsx("div",{className:"space-y-1",children:o.items.map(u=>{const l=u.id?cl(u.id,Array.isArray(u.keys)?u.keys[0]:u.keys,r):Array.isArray(u.keys)?u.keys:u.keys.split(" / ");return e.jsxs("div",{className:"flex items-center justify-between py-1 px-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[u.icon&&e.jsx(W,{name:u.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:u.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(l)?l:[l]).map((c,h)=>e.jsxs(n.Fragment,{children:[h>0&&e.jsx("span",{className:"typography-meta text-muted-foreground mx-1",children:"or"}),e.jsx("kbd",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 typography-meta font-mono bg-muted rounded border border-border/20",children:c})]},`${c}-${h}`))})]},u.id||u.descriptionKey)})})]},o.categoryKey))})})]})})},ul=n.createContext(null),hl=({children:t,value:s})=>e.jsx(ul.Provider,{value:s,children:t}),Os=Ke(()=>Oe(()=>import("./GitView--EaZQrBr.js"),__vite__mapDeps([82,7,1,2,3,4,5,6,8,9,10,11,12,48,49,50,51,52,15,83,84,85,86,46,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,16,44,45,47,53,54])).then(t=>({default:t.GitView}))),fl=Ke(()=>Oe(()=>import("./DiffView-CiZy4jFA.js"),__vite__mapDeps([14,1,2,3,5,6,7,8,9,10,4,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55])).then(t=>({default:t.DiffView}))),pl=Ke(()=>Oe(()=>import("./FilesView-DqiZ9kw9.js"),__vite__mapDeps([56,1,2,3,5,6,7,8,9,10,4,11,12,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,53,54,35,36,20,21,22,23,24,25,26,27,28,29,30,31,32,33,73,74,48,49,50,51,52,75,76,17,18,19,34,37,38,39,40,41,42,43,77,78,79,80,81,47])).then(t=>({default:t.FilesView}))),ml=Ke(()=>Oe(()=>import("./DiagramView-DZUBo1uP.js"),__vite__mapDeps([92,1,2,3,4,5,6,7,8,9,10,11,12,73,74])).then(t=>({default:t.DiagramView}))),gl=Ke(()=>Oe(()=>import("./SettingsView-DA-U9lsj.js").then(t=>t.h),__vite__mapDeps([93,1,2,3,5,6,7,8,9,10,4,11,12,48,49,50,51,52,94,95,96,85,86])).then(t=>({default:t.SettingsView}))),xl=Ke(()=>Oe(()=>import("./SettingsWindow-CUg49Mfh.js"),__vite__mapDeps([97,1,2,3,5,6,7,8,9,10,4,11,12,93,48,49,50,51,52,94,95,96,85,86])).then(t=>({default:t.SettingsWindow}))),bl=()=>{const t=K(N=>N.isSidebarOpen),s=K(N=>N.activeMainTab),r=K(N=>N.setIsMobile),a=K(N=>N.isSessionSwitcherOpen),i=K(N=>N.isSettingsDialogOpen),o=K(N=>N.setSettingsDialogOpen),[u,l]=n.useState(!1);n.useEffect(()=>{i&&l(!0)},[i]),n.useEffect(()=>{const N=()=>K.getState().closeMainSurfaces(),F=Me.subscribe((D,O)=>{const G=!!D.currentSessionId&&D.currentSessionId!==O.currentSessionId,ue=!!D.newSessionDraft?.open&&D.newSessionDraft!==O.newSessionDraft;(G||ue)&&N()}),oe=K.subscribe((D,O)=>{D.activeMainTab!==O.activeMainTab&&N()});return()=>{F(),oe()}},[]);const{isMobile:c}=kt(),h=n.useRef(!1),[f,y]=n.useState(!1),[d,b]=n.useState(!1),[p,C]=n.useState(!1),[x,P]=n.useState(!1),_=n.useCallback(N=>{y(N),K.getState().setSessionSwitcherOpen(N)},[]),U=n.useRef(typeof window>"u"?0:window.innerWidth),w=n.useRef(null),E=n.useRef(!1),S=n.useRef(!1),M=n.useRef(!1),j=n.useRef(null),T=n.useRef(null),Y=rs(-U.current),X=Fe.useRef(0),z=rs(U.current),Z=Fe.useRef(0);Fe.useEffect(()=>{c&&(X.current=window.innerWidth,Z.current=window.innerWidth)},[c]),Fe.useEffect(()=>{if(!c)return;const N=()=>{const F=window.innerWidth;X.current=F,Z.current=F,f||Y.get()<-10&&Y.set(-F),d||z.get()>10&&z.set(F)};return window.addEventListener("resize",N),window.addEventListener("orientationchange",N),()=>{window.removeEventListener("resize",N),window.removeEventListener("orientationchange",N)}},[c,Y,z,f,d]),Fe.useEffect(()=>{if(!c){C(!1);return}f&&C(!0);const N=X.current||U.current||(typeof window<"u"?window.innerWidth:0),F=wt(Y,f?0:-N,{type:"spring",stiffness:400,damping:35,mass:.8});return j.current=F,()=>F.stop()},[f,c,Y]),Fe.useEffect(()=>{if(!c){P(!1);return}d&&P(!0);const N=Z.current||U.current||(typeof window<"u"?window.innerWidth:0),F=wt(z,d?0:N,{type:"spring",stiffness:400,damping:35,mass:.8});return T.current=F,()=>F.stop()},[c,d,z]),Fe.useEffect(()=>{if(c)return Y.on("change",N=>{const F=X.current||U.current,oe=f||N>-F+.5;C(D=>D===oe?D:oe)})},[c,Y,f]),Fe.useEffect(()=>{if(c)return z.on("change",N=>{const F=Z.current||U.current,oe=d||N<F-.5;P(D=>D===oe?D:oe)})},[c,d,z]),Fe.useEffect(()=>{c&&!a&&f&&_(!1)},[a,c,f,_]),Fe.useEffect(()=>{if(!c){h.current=!1;return}h.current||(h.current=!0,_(!1),b(!1))},[c,_]),Fe.useEffect(()=>{if(!c||s!=="chat"||f||d||i)return;let N=!1,F;return(D=>{F=window.setTimeout(()=>{if(N)return;const O=Me.getState(),G=K.getState();G.activeMainTab!=="chat"||G.isSettingsDialogOpen||O.currentSessionId||O.newSessionDraft?.open||O.openNewSessionDraft({automatic:!0})},D)})(500),()=>{N=!0,F!==void 0&&window.clearTimeout(F)}},[s,c,i,f,d]),Fe.useEffect(()=>{!c||!i||(_(!1),b(!1))},[c,i,_]),n.useEffect(()=>{K.getState().isMobile!==c&&r(c)},[c,r]);const le=n.useCallback(()=>{f&&_(!1),b(!d)},[f,d,_]);Dr(w,{enabled:c,leftOpen:f,rightOpen:d,leftWidth:()=>X.current||U.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>Z.current||U.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:N=>{const F=X.current||U.current||(typeof window<"u"?window.innerWidth:0);Y.set(F*(N-1))},onRightProgress:N=>{const F=Z.current||U.current||(typeof window<"u"?window.innerWidth:0);z.set(F*(1-N))},onLeftOpen:()=>{d&&b(!1),_(!0)},onLeftClose:()=>_(!1),onRightOpen:()=>{f&&_(!1),b(!0)},onRightClose:()=>b(!1),onDragStart:N=>{E.current=!0,N==="left"?(S.current=f,j.current?.stop(),p||C(!0)):(M.current=d,T.current?.stop(),x||P(!0))},onDragEnd:(N,F)=>{if(E.current=!1,N==="left"&&typeof F=="boolean"){const oe=S.current;if(F===oe){const D=X.current||U.current||(typeof window<"u"?window.innerWidth:0),O=wt(Y,oe?0:-D,{type:"spring",stiffness:400,damping:35,mass:.8});j.current=O}}if(N==="right"&&typeof F=="boolean"){const oe=M.current;if(F===oe){const D=Z.current||U.current||(typeof window<"u"?window.innerWidth:0),O=wt(z,oe?0:D,{type:"spring",stiffness:400,damping:35,mass:.8});T.current=O}}}});const H=n.useMemo(()=>{if(!c&&s!=="terminal"&&s!=="diagram"||c&&s==="git"&&(d||x))return null;switch(s){case"git":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(Os,{isActive:!0})});case"diff":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(fl,{})});case"terminal":return e.jsx(en,{onCloseView:()=>K.getState().setActiveMainTab("chat")});case"files":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(pl,{})});case"diagram":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(ml,{})});default:return null}},[s,c,x,d]),ne=s==="chat";return e.jsxs(Ar,{children:[e.jsx(_r,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:fe("main-content-safe-area",c?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(ll,{}),e.jsx(dl,{}),e.jsx(Mr,{}),c?e.jsxs(hl,{value:{leftDrawerOpen:f,rightDrawerOpen:d,toggleLeftDrawer:()=>{const N=!f;d&&b(!1),_(N)},toggleRightDrawer:le,leftDrawerX:Y,rightDrawerX:z,leftDrawerWidth:X,rightDrawerWidth:Z,setMobileLeftDrawerOpen:_,setRightSidebarOpen:b},children:[!i&&e.jsx(cs,{onToggleLeftDrawer:()=>{const N=!f;d&&b(!1),_(N)},onToggleRightDrawer:()=>{le()},leftDrawerOpen:f,rightDrawerOpen:d}),e.jsx("div",{"data-page-scroll-lock":"true",className:fe("flex flex-1 overflow-hidden relative",i&&"hidden"),children:e.jsxs("main",{ref:w,className:"w-full h-full overflow-hidden bg-background relative","data-page-scroll-lock":"true",style:{touchAction:"pan-x pan-y"},children:[e.jsx("div",{className:fe("absolute inset-0",!ne&&"invisible"),children:e.jsx(ze,{children:e.jsx(ds,{active:ne&&!i})})}),H&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(ze,{children:H})}),e.jsx(ze,{children:e.jsx(us,{})}),e.jsx(os.div,{className:fe("absolute inset-0 z-20 bg-sidebar",!p&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:Y},"aria-hidden":!f,children:e.jsx(ze,{children:e.jsx(hs,{mobileVariant:!0,isVisible:p})})}),e.jsx(os.div,{className:fe("absolute inset-0 z-20 bg-sidebar",!x&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:z},"aria-hidden":!d,children:e.jsx(ze,{children:d||x?e.jsx(n.Suspense,{fallback:null,children:e.jsx(Os,{isActive:d})}):null})})]})}),i&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(ze,{children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(gl,{onClose:()=>o(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ir,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(Go,{isOpen:t,isMobile:c,children:e.jsx(hs,{isVisible:t})}),e.jsxs("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx(cs,{}),e.jsxs("div",{className:"relative flex flex-1 min-h-0 overflow-hidden bg-background","data-page-scroll-lock":"true",children:[e.jsx("div",{className:"relative flex flex-1 min-w-0 flex-col overflow-hidden border-t border-border bg-background","data-page-scroll-lock":"true",children:e.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden","data-page-scroll-lock":"true",children:e.jsxs("div",{className:"relative flex flex-1 min-h-0 min-w-0 overflow-hidden","data-page-scroll-lock":"true","data-chat-area":"true",children:[e.jsxs("main",{className:"flex-1 overflow-hidden bg-background relative","data-page-scroll-lock":"true",children:[e.jsx("div",{className:fe("absolute inset-0",!ne&&"invisible"),children:e.jsx(ze,{children:e.jsx(ds,{active:ne&&!i})})}),H&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(ze,{children:H})}),e.jsx(ze,{children:e.jsx(us,{})})]}),e.jsx(Gi,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(ze,{children:e.jsx(nl,{})})})]})]})]}),u?e.jsx(n.Suspense,{fallback:null,children:e.jsx(xl,{open:i,onOpenChange:o})}):null]})]})]})},wl=()=>(Po(),Br(),e.jsxs(Or,{children:[e.jsx(Ro,{embeddedBackgroundWorkEnabled:!0}),e.jsx(Eo,{}),e.jsx(To,{}),e.jsx($r,{}),e.jsx(Do,{}),e.jsx(Ao,{}),e.jsx(bl,{}),e.jsx(Fr,{}),e.jsx(_o,{}),e.jsx(Mo,{})]}));function yl({apis:t}){const s=t??Gs(),[r,a]=n.useState(0);return n.useEffect(()=>Zn(i=>{if(i.runtimeKey===i.previousRuntimeKey){er();return}Lr(i),a(o=>o+1)}),[]),n.useEffect(()=>{let i=!0,o=null,u=null,l=null;return tr().then(()=>{i&&(o=vo(),u=jo(),l=So())}),()=>{i=!1,o?.(),u?.(),l?.()}},[r]),n.useEffect(()=>{s&&sr(s)},[s]),s?e.jsx(ze,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(ko,{apis:s,children:e.jsx(Co,{children:e.jsx(No,{children:e.jsx(wl,{})})},r)})})}):e.jsx(ze,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const Cn=document.getElementById("root");if(!Cn)throw new Error("Root element not found");Mn.createRoot(Cn).render(e.jsx(Fe.StrictMode,{children:e.jsx(Io,{children:e.jsx(Lo,{children:e.jsx(yl,{apis:Gs()??void 0})})})}));
|