@pi-chamber/web 0.3.0 → 0.3.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.
Files changed (65) hide show
  1. package/bin/lib/cli-startup.js +53 -10
  2. package/bin/lib/cli-startup.test.js +42 -0
  3. package/dist/assets/{CommitSection-BpbMC0et.js → CommitSection-DLIvjYbM.js} +1 -1
  4. package/dist/assets/{DiagramEditor-dFTMKHuO.js → DiagramEditor-Tw3ZWHML.js} +1 -1
  5. package/dist/assets/{DiagramView-DVw_8Px1.js → DiagramView-CK6R7taL.js} +1 -1
  6. package/dist/assets/{DiffView-CkoY1oAM.js → DiffView-vrxi5oWp.js} +2 -2
  7. package/dist/assets/{FilesView-C0hyg2pa.js → FilesView-BD_h3EVr.js} +6 -6
  8. package/dist/assets/{GitView-D36hpDsb.js → GitView-BwNKqK0K.js} +4 -4
  9. package/dist/assets/{JsonTreeView-BF8S-bPN.js → JsonTreeView-CmY7QgEX.js} +1 -1
  10. package/dist/assets/{MarkdownRendererImpl-BVNChdig.js → MarkdownRendererImpl-CpI-25Xk.js} +1 -1
  11. package/dist/assets/{PatchDiff-B--OaNB1.js → PatchDiff-CrIWbYj7.js} +1 -1
  12. package/dist/assets/{PierreDiffViewer-0Qkp9ICt.js → PierreDiffViewer-B410mdbq.js} +2 -2
  13. package/dist/assets/{SessionSwitcherDropdown-cFWgy1td.js → SessionSwitcherDropdown-DROjbyIu.js} +100 -100
  14. package/dist/assets/SettingsView-CsJItYZh.js +4 -0
  15. package/dist/assets/{SettingsWindow-BuJCvYoR.js → SettingsWindow-C9s4AX72.js} +1 -1
  16. package/dist/assets/{ToolOutputDialog-Bi9BoEe7.js → ToolOutputDialog-b_R4tAZu.js} +5 -5
  17. package/dist/assets/{ToolPartDiffPreview-DGX7N4zr.js → ToolPartDiffPreview-CfnliaE9.js} +1 -1
  18. package/dist/assets/{VirtualizedFileDiff-CxraYoDZ.js → VirtualizedFileDiff-CQz2fSZI.js} +4 -4
  19. package/dist/assets/{collapsible-d4-HChej.js → collapsible-CR4U9tjw.js} +1 -1
  20. package/dist/assets/{computeVirtualFileMetrics-BuD14qFL.js → computeVirtualFileMetrics-C7vXPUYT.js} +2 -2
  21. package/dist/assets/{contextFileOpenGuard-DirV-hCs.js → contextFileOpenGuard-DtTHRnq1.js} +1 -1
  22. package/dist/assets/{index-DEYblXCW.js → index-BAqpUCjs.js} +5 -5
  23. package/dist/assets/{index-BWmmf5yJ.js → index-DZG82DE1.js} +1 -1
  24. package/dist/assets/{index-DLKBsLKY.css → index-riABQmQ_.css} +1 -1
  25. package/dist/assets/{isDiffPlainText-LoMmNzmX.js → isDiffPlainText-zTq-4A04.js} +1 -1
  26. package/dist/assets/{isFilePlainText-3Hj9i02t.js → isFilePlainText-CLgIdzE5.js} +1 -1
  27. package/dist/assets/{main-BsszlAdQ.js → main-BVWtJYSk.js} +2 -2
  28. package/dist/assets/main-DXYHsqzA.js +133 -0
  29. package/dist/assets/{markdownCore-sGxk8jrc.js → markdownCore-CN0pApQE.js} +2 -2
  30. package/dist/assets/{miniChat-C6SDQL4G.js → miniChat-BrbRq5NQ.js} +2 -2
  31. package/dist/assets/{mobile-DBW3XDmZ.js → mobile-DTPtCn5N.js} +2 -2
  32. package/dist/assets/{renderElectronMiniChatApp-B1_fTdN-.js → renderElectronMiniChatApp-CM8qBaye.js} +1 -1
  33. package/dist/assets/{renderMobileApp-CFxZc_1a.js → renderMobileApp-KS_pt-qc.js} +4 -4
  34. package/dist/assets/{runtimeSurface-9aJdtQbh.js → runtimeSurface-CkHYYg0E.js} +1 -1
  35. package/dist/assets/{useInlineCommentController-Cl--s6vE.js → useInlineCommentController-CwNNjgc7.js} +2 -2
  36. package/dist/assets/usePanelSlide-DkorgQJ5.js +56 -0
  37. package/dist/assets/{useWindowTitle-C-AZD713.js → useWindowTitle-B9wt_3ZQ.js} +3 -3
  38. package/dist/assets/{vendor-codemirror-language-data-HC9JT4I3.js → vendor-codemirror-language-data-x89A7Wy0.js} +2 -2
  39. package/dist/assets/{vendor-sonner-dWA7qvjr.js → vendor-sonner-CW8w438f.js} +1 -1
  40. package/dist/assets/{web-components-skJ_VpnT.js → web-components-BEPfE4kU.js} +2 -2
  41. package/dist/index.html +4 -4
  42. package/dist/mini-chat.html +3 -3
  43. package/dist/mobile.html +3 -3
  44. package/package.json +1 -1
  45. package/server/index.js +33 -0
  46. package/server/lib/pi/routes.js +24 -2
  47. package/server/lib/pi/routes.test.js +14 -6
  48. package/server/lib/pi/session-daemon/DOCUMENTATION.md +4 -3
  49. package/server/lib/pi/session-daemon/message-entry-aliases.js +100 -0
  50. package/server/lib/pi/session-daemon/session-daemon.js +176 -46
  51. package/server/lib/pi/session-daemon/session-daemon.test.js +364 -6
  52. package/server/lib/pi/session-daemon/supervisor.js +20 -1
  53. package/server/lib/pi/session-daemon/supervisor.test.js +43 -0
  54. package/server/lib/pi/settings-store.js +17 -0
  55. package/server/lib/pi/settings-store.test.js +33 -0
  56. package/server/lib/server/core-routes.js +36 -4
  57. package/server/lib/server/tunnel-service.DOCUMENTATION.md +74 -0
  58. package/server/lib/server/tunnel-service.js +228 -0
  59. package/server/lib/server/tunnel-service.test.js +61 -0
  60. package/server/lib/ui-auth/DOCUMENTATION.md +2 -0
  61. package/server/lib/ui-auth/ui-auth.js +5 -1
  62. package/server/lib/ui-auth/ui-auth.test.js +17 -0
  63. package/dist/assets/SettingsView-D3ZZyjU3.js +0 -4
  64. package/dist/assets/main-CUvZIN16.js +0 -133
  65. package/dist/assets/usePanelSlide-D5ffPTGM.js +0 -56
@@ -0,0 +1,133 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/DiffView-vrxi5oWp.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-BAqpUCjs.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-riABQmQ_.css","assets/SessionSwitcherDropdown-DROjbyIu.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-base-ui-DL8r2fgQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/runtimeSurface-CkHYYg0E.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-x89A7Wy0.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-CW8w438f.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/PierreDiffViewer-B410mdbq.js","assets/web-components-BEPfE4kU.js","assets/computeVirtualFileMetrics-C7vXPUYT.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.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-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.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/VirtualizedFileDiff-CQz2fSZI.js","assets/isDiffPlainText-zTq-4A04.js","assets/vendor-diff-C3JhlQdm.js","assets/usePanelSlide-DkorgQJ5.js","assets/permissionStore-BRcQ9Jgt.js","assets/usePanelSlide-BV3KOtdA.css","assets/useInlineCommentController-CwNNjgc7.js","assets/collapsible-CR4U9tjw.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/contextFileOpenGuard-DtTHRnq1.js","assets/FilesView-BD_h3EVr.js","assets/vendor-codemirror-search-8kyQdB3f.js","assets/vendor-replit-codemirror-vim-BJY5fGLS.js","assets/JsonTreeView-CmY7QgEX.js","assets/Virtualizer-BxW2CJGB.js","assets/isFilePlainText-CLgIdzE5.js","assets/DiagramEditor-Tw3ZWHML.js","assets/vendor-react-drawio-Boqanm0j.js","assets/GitView-BwNKqK0K.js","assets/CommitSection-DLIvjYbM.js","assets/DiagramView-CK6R7taL.js","assets/SettingsView-CsJItYZh.js","assets/vendor-qrcode-COsmt6jn.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/SettingsWindow-C9s4AX72.js"])))=>i.map(i=>d[i]);
2
+ import{R as n,j as e,r as Te,e as $r}from"./vendor-react-DYyjh7Q0.js";import"./vendor-katex-CHD9BdDO.js";import{u as Z,z as Or,A as Wr,B as Fr,C as sr,o as Ie,D as Br,a as zr,E as or,r as ot,e as pt,F as ar,G as ir,H as Ur,m as Hr,I as Vr,J as Kr,K as Xr,w as Gr,x as Yr,q as lr,v as qr}from"./index-BAqpUCjs.js";import{_ as Ae}from"./vendor-vite-runtime-DD1OZmLC.js";import{l as Jr,p as Qr,q as Zr,t as en,v as tn,w as rn,P as cr,x as nn,T as dr,y as sn,z as on,B as an,m as ln,o as cn,j as dn,k as un,H as At,C as Mt,A as It,S as Lt,n as hn,f as pn,h as mn,F as fn}from"./usePanelSlide-DkorgQJ5.js";import{f as ve,X as _e,I as U,as as gn,T as Be,q as ze,at as xn,B as pe,s as Ue,au as wn,F as gt,av as xt,t as he,aw as yn,C as wt,E as Ze,G as ur,ax as hr,Y as $t,ay as bn,D as yt,w as bt,x as vt,y as jt,z as St,A as vn,az as jn,aA as Sn,h as Ee,aB as Cn,aC as pr,a5 as We,aD as Ye,aE as mr,aF as fr,aG as Nn,aH as mt,aI as kn,U as Le,H as gr,aJ as Pn,aK as Ct,aL as Rn,aM as Nt,aN as kt,o as at,aO as En,P as xr,aP as Tn,aQ as Pt,K as wr,aR as Dn,aS as _n,aT as An,aU as Mn,aV as Ot,aW as Wt,aX as qe,aY as In,c as Ln,d as $n,aZ as On,b as Ft,r as it,a_ as Wn,a$ as Fn,b0 as Bn,b1 as yr,b2 as br,b3 as zn,b4 as Un,b5 as Hn,b6 as Vn,b7 as Xe,b8 as Ge,b9 as Kn,ba as Xn,bb as Gn,bc as Yn,ae as qn,ad as Jn,af as Qn,ab as Zn,ag as es,ah as ts,ai as rs,ap as ns,aq as ss,ar as os}from"./SessionSwitcherDropdown-DROjbyIu.js";import{v as vr,g as jr}from"./contextFileOpenGuard-DtTHRnq1.js";import{c as as,d as Bt,T as is,M as ls,D as cs,e as ds}from"./vendor-dnd-kit-core-GipZW2tY.js";import{a as us,S as hs,v as ps,u as ms}from"./vendor-dnd-kit-sortable-Ct2QxIHb.js";import{C as fs}from"./vendor-dnd-kit-utilities-CrOcp0Bp.js";import{u as zt,a as et,m as Ut}from"./vendor-framer-motion-DJASDzNt.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-base-ui-DL8r2fgQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-sVFnuruh.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-B7OScDIw.js";import"./vendor-tanstack-react-virtual-IrbCBGJ4.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./permissionStore-BRcQ9Jgt.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./runtimeSurface-CkHYYg0E.js";import"./vendor-cmdk-BCEUzcHE.js";import"./vendor-radix-ui-react-dialog-jX3Dld8c.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-D1GnwnP9.js";import"./vendor-radix-ui-react-context-CM4yFQ2I.js";import"./vendor-radix-ui-react-id-BcxRjnbX.js";import"./vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js";import"./vendor-radix-ui-react-use-controllable-state-C_ecoh35.js";import"./vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js";import"./vendor-radix-ui-react-primitive-CfpW6_IT.js";import"./vendor-radix-ui-react-slot-BxUc3Pvz.js";import"./vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js";import"./vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js";import"./vendor-radix-ui-react-focus-scope-C2K7lNPv.js";import"./vendor-radix-ui-react-portal-xlJWBfDg.js";import"./vendor-radix-ui-react-presence-Btn-Dp7L.js";import"./vendor-radix-ui-react-focus-guards-D5MZ0nQs.js";import"./vendor-react-remove-scroll-CfeMe0DL.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-C9YRs2nU.js";import"./vendor-react-style-singleton-B1H4bWSG.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-C-AuTczP.js";import"./vendor-use-callback-ref-CJB0R85I.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-E2vgV9K3.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-DSzLbZiS.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-BUlYhQ3o.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-BS2SpSAZ.js";import"./vendor-codemirror-lang-json-CqayksDf.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-Ba8JZ6fp.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-DK27qQri.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-CvO36Y1p.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-x89A7Wy0.js";import"./vendor-codemirror-lang-python-_2bIYTiJ.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-RrgJ8H_6.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-sonner-CW8w438f.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-dnd-kit-accessibility-Cv52zwWT.js";import"./vendor-motion-dom-DJLgZh4Q.js";import"./vendor-motion-utils-BGh8QBgx.js";const Ht=280,Vt=280,Kt=500,gs=({isOpen:t,isMobile:r,children:s,className:o,topBar:a})=>{const h=Z(L=>L.sidebarWidth),w=Z(L=>L.setSidebarWidth),[d,m]=n.useState(!1),f=n.useRef(0),b=n.useRef(h||Ht),p=n.useRef(null),i=n.useRef(null),N=n.useRef(null),c=n.useCallback(L=>Math.min(Kt,Math.max(Vt,L)),[]),C=n.useCallback(L=>{const y=N.current;y&&(y.style.width=`${L}px`,y.style.minWidth=`${L}px`,y.style.maxWidth=`${L}px`,y.style.setProperty("--oc-left-sidebar-width",`${L}px`))},[]);n.useEffect(()=>{r&&d&&m(!1)},[r,d]),n.useEffect(()=>{d||(p.current=null,i.current=null)},[d]);const S=Jr(t);if(r)return null;const D=Math.min(Kt,Math.max(Vt,h||Ht)),A=t?D:0,O=L=>{if(t){try{L.currentTarget.setPointerCapture(L.pointerId)}catch{}i.current=L.pointerId,m(!0),f.current=L.clientX,b.current=A,p.current=A,C(A),L.preventDefault()}},te=L=>{if(r||!d||i.current!==L.pointerId)return;const y=L.clientX-f.current,W=c(b.current+y);p.current!==W&&(p.current=W,C(W))},Q=L=>{if(i.current!==L.pointerId||r)return;try{L.currentTarget.releasePointerCapture(L.pointerId)}catch{}const y=c(p.current??A);i.current=null,p.current=null,m(!1),w(y)},F=d?p.current??A:A,M=d?F:A;return e.jsxs("aside",{ref:N,className:ve("relative flex h-full overflow-hidden border-r border-border motion-reduce:transition-none","bg-sidebar",!t&&"border-r-0",o),style:{width:`${M}px`,minWidth:`${M}px`,maxWidth:`${M}px`,"--oc-left-sidebar-width":`${d?F:D}px`,overflowX:"clip",transform:d||S.slidIn?"translateX(0)":"translateX(-100%)",transition:d?"none":S.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:ve("absolute right-0 top-0 z-20 h-full w-[3px] cursor-col-resize hover:bg-[var(--interactive-border)]/80 transition-colors",d&&"bg-[var(--interactive-border)]"),onPointerDown:O,onPointerMove:te,onPointerUp:Q,onPointerCancel:Q,role:"separator","aria-orientation":"vertical","aria-label":"Resize left panel"}),e.jsxs("div",{className:ve("relative z-10 flex h-full shrink-0 flex-col",d&&"pointer-events-none",!t&&"pointer-events-none select-none"),style:{width:"var(--oc-left-sidebar-width)",overflowX:"hidden"},"aria-hidden":!t,children:[a,e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:e.jsx(_e,{children:s})})]})]})},xs=t=>t.slice().sort((r,s)=>r.type!==s.type?r.type==="directory"?-1:1:r.name.localeCompare(s.name)),ke=t=>{if(!t)return"";const r=t.replace(/\\/g,"/"),s=r.startsWith("//");let o=r.replace(/\/+$/g,"");return o=o.replace(/\/+/g,"/"),s&&!o.startsWith("//")&&(o=`/${o}`),o===""?r.startsWith("/")?"/":"":o},Sr=(t,r)=>{const s=ke(r),o=ke(t).replace(/\/+$/,"");return s===o?".":!o||!s.startsWith(`${o}/`)?s:s.slice(o.length+1)},ws=t=>t.startsWith("/")||t.startsWith("//")||/^[A-Za-z]:\//.test(t),ys=new Set(["node_modules"]),bs=t=>ys.has(t),vs=t=>{const r=ke(t);return r==="node_modules"||r.endsWith("/node_modules")||r.includes("/node_modules/")},js=8,Me=new Map,Rt=t=>JSON.stringify([zr(),t]),Ss=t=>{const r=Rt(t),s=Me.get(r);return s?(s.touchedAt=Date.now(),Me.delete(r),Me.set(r,s),s):null},lt=t=>{const r=Rt(t),s=Me.get(r);if(s)return s.touchedAt=Date.now(),s;if(Me.size>=js){const a=Me.keys().next().value;a!==void 0&&Me.delete(a)}const o={childrenByDir:{},loadErrorsByDir:{},loadedDirs:new Set,touchedAt:Date.now()};return Me.set(r,o),o},Cs=t=>{Me.delete(Rt(t))},Cr=(t,r)=>e.jsx(gt,{filePath:t,extension:r}),Ns=({status:t})=>{const r={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[t];return e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:r}})},ks=({node:t,root:r,isExpanded:s,isActive:o,isBrowserClient:a,status:h,badge:w,permissions:d,downloadFile:m,onSelect:f,onToggle:b,onRevealPath:p,onOpenDialog:i})=>{const N=t.type==="directory",{canRename:c,canCreateFile:C,canCreateFolder:S,canDelete:D,canReveal:A}=d,O=!N&&!!m,te=A&&!a,Q=c||C||S||D||O||te,[F,M]=n.useState(!1),[L,y]=n.useState(!1),W=n.useCallback(R=>{Q&&(R?.preventDefault(),y(!0))},[Q]),Y=n.useCallback(()=>{N?b(t.path):f(t)},[N,t,f,b]),K=n.useCallback(R=>{R.stopPropagation(),y(!1),M(!0)},[]),B=({Item:R,Separator:z})=>e.jsxs(e.Fragment,{children:[c&&e.jsxs(R,{onClick:v=>{v.stopPropagation(),i("rename",t)},children:[e.jsx(U,{name:"edit",className:"mr-2 h-4 w-4"})," ","Rename"]}),e.jsxs(R,{onClick:v=>{v.stopPropagation(),xt(t.path).then(E=>{if(E.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[e.jsx(U,{name:"file-copy",className:"mr-2 h-4 w-4"})," ","Copy Path"]}),!N&&m&&e.jsxs(R,{onClick:v=>{v.stopPropagation(),m(t.path).catch(E=>{console.error("Download failed:",E),he.error("Operation failed")})},children:[e.jsx(U,{name:"download",className:"mr-2 h-4 w-4"})," ",a?"Download":"Save"]}),te&&e.jsxs(R,{onClick:v=>{v.stopPropagation(),p(t.path)},children:[e.jsx(U,{name:"folder-received",className:"mr-2 h-4 w-4"})," ",yn()]}),N&&(C||S)&&e.jsxs(e.Fragment,{children:[e.jsx(z,{}),C&&e.jsxs(R,{onClick:v=>{v.stopPropagation(),i("createFile",t)},children:[e.jsx(U,{name:"file-add",className:"mr-2 h-4 w-4"})," ","New File"]}),S&&e.jsxs(R,{onClick:v=>{v.stopPropagation(),i("createFolder",t)},children:[e.jsx(U,{name:"folder-add",className:"mr-2 h-4 w-4"})," ","New Folder"]})]}),D&&e.jsxs(e.Fragment,{children:[e.jsx(z,{}),e.jsxs(R,{onClick:v=>{v.stopPropagation(),i("delete",t)},className:"text-destructive focus:text-destructive",children:[e.jsx(U,{name:"delete-bin",className:"mr-2 h-4 w-4"})," ","Delete"]})]})]}),X=n.useCallback(R=>{const z=Sr(r,t.path);!z||z==="."||(R.dataTransfer.setData("application/x-pichamber-file-path",z),R.dataTransfer.effectAllowed="copy")},[t.path,r]);return e.jsxs(Qr,{open:L,onOpenChange:y,children:[e.jsxs(Zr,{render:e.jsx("div",{className:"group relative flex items-center",onContextMenu:W}),children:[e.jsxs("button",{type:"button",onClick:Y,onContextMenu:W,draggable:!0,onDragStart:X,className:ve("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",o?"bg-interactive-selection/70":"hover:bg-interactive-hover/40","cursor-grab active:cursor-grabbing"),children:[N?s?e.jsx(U,{name:"folder-open",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):e.jsx(U,{name:"folder-3",className:"h-4 w-4 flex-shrink-0 text-muted-foreground"}):Cr(t.path,t.extension),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),!N&&h&&e.jsx(Ns,{status:h}),N&&w&&e.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[w.modified>0&&e.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",w.modified]}),w.added>0&&e.jsxs("span",{className:"text-[var(--status-success)]",children:["+",w.added]})]})]}),Q&&e.jsx("div",{className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 focus-within:opacity-100 group-hover:opacity-100",children:e.jsxs(gn,{open:F,onOpenChange:M,children:[e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(xn,{asChild:!0,children:e.jsx(pe,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:K,title:"File menu","aria-label":"File menu",children:e.jsx(U,{name:"more-2-fill",className:"h-4 w-4"})})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"File menu"})]}),e.jsx(wn,{align:"end",side:"bottom",onCloseAutoFocus:()=>M(!1),children:B({Item:jn,Separator:Sn})})]})})]}),e.jsx(en,{className:"min-w-[180px]",children:B({Item:tn,Separator:rn})})]})},Ps=(t,r)=>t.node===r.node&&t.root===r.root&&t.isExpanded===r.isExpanded&&t.isActive===r.isActive&&t.isBrowserClient===r.isBrowserClient&&t.status===r.status&&t.badge===r.badge&&t.permissions===r.permissions&&t.downloadFile===r.downloadFile&&t.onSelect===r.onSelect&&t.onToggle===r.onToggle&&t.onRevealPath===r.onRevealPath&&t.onOpenDialog===r.onOpenDialog,Rs=n.memo(ks,Ps),Es=()=>{const{files:t,runtime:r}=wt(),s=Or(r.platform),o=Ze()??"",a=ke(o.trim()),h=Wr(),w=Fr(),d=sr(x=>x.searchFiles),m=Z(x=>x.openContextFile),f=ur(o),[b,p]=n.useState(""),i=hr(b,200),N=n.useRef(null),[c,C]=n.useState([]),[S,D]=n.useState(!1),[A,O]=n.useState({}),[te,Q]=n.useState({}),F=n.useRef(new Set),M=n.useRef(new Set),L=n.useRef(null);n.useEffect(()=>{if(!a){O({}),Q({}),F.current=new Set;return}const x=Ss(a);x?(O({...x.childrenByDir}),Q({...x.loadErrorsByDir}),F.current=new Set(x.loadedDirs)):(O({}),Q({}),F.current=new Set)},[a]),n.useEffect(()=>{if(!a)return;const x=lt(a);x.childrenByDir=A},[a,A]),n.useEffect(()=>{if(!a)return;const x=lt(a);x.loadErrorsByDir=te},[a,te]),n.useEffect(()=>{if(!a)return;const x=lt(a);x.loadedDirs=new Set(F.current)},[a,A,te]),n.useEffect(()=>()=>{if(!a)return;const x=Me.get(a);x&&x.loadedDirs.size===0&&Object.keys(x.childrenByDir).length===0&&Cs(a)},[a]);const y=n.useMemo(()=>[],[]),W=n.useMemo(()=>[],[]),Y=Ie(x=>a?x.byRoot[a]?.expandedPaths??y:y),K=Ie(x=>a?x.byRoot[a]?.selectedPath??null:null),B=Ie(x=>x.setSelectedPath),X=Ie(x=>x.addOpenPath),R=Ie(x=>x.removeOpenPathsByPrefix),z=Ie(x=>x.toggleExpandedPath),v=Ie(x=>x.collapseAllExpandedPaths),E=Z(x=>a?x.contextPanelByDirectory[a]?.tabs??W:W),G=n.useMemo(()=>new Set(E.map(x=>x.mode==="file"?x.targetPath:null).filter(x=>typeof x=="string"&&x.length>0).map(x=>ke(x))),[E]),[T,q]=n.useState(null),[re,ie]=n.useState(null),[me,Ce]=n.useState(""),[fe,ge]=n.useState(!1),ce=!!t.writeFile,je=!!t.createDirectory,Ne=!!t.rename,u=!!t.delete,k=!!t.revealPath,I=n.useMemo(()=>({canRename:Ne,canCreateFile:ce,canCreateFolder:je,canDelete:u,canReveal:k}),[Ne,ce,je,u,k]),H=n.useCallback(x=>{t.revealPath&&t.revealPath(x).catch(()=>{he.error("Failed to reveal path")})},[t]),J=n.useCallback((x,_)=>{q(x),ie(_),Ce(x==="rename"&&_.name||""),ge(!1)},[]),ue=n.useCallback((x,_)=>{const le=_.filter($=>$&&typeof $.name=="string"&&$.name.length>0).filter($=>h||!$.name.startsWith(".")).filter($=>w||!bs($.name)).map($=>{const ae=$.name,V=ke($.path||""),we=V?ws(V)?V:ke(`${x}/${V}`):ke(`${x}/${ae}`),Se=$.isDirectory?"directory":"file",Fe=Se==="file"&&ae.includes(".")?ae.split(".").pop()?.toLowerCase():void 0;return{name:ae,path:we,type:Se,extension:Fe}});return xs(le)},[w,h]),se=n.useCallback(async(x,_)=>{const le=ke(x.trim());if(!le||F.current.has(le)||M.current.has(le))return;M.current=new Set(M.current),M.current.add(le);const $=t.listDirectory?t.listDirectory(le).then(ae=>ae.entries.map(V=>({name:V.name,path:V.path,isDirectory:V.isDirectory}))):Br(le).then(ae=>ae.map(V=>({name:V.name,path:V.path,isDirectory:V.isDirectory})));try{const ae=await $;if(_?.())return;const V=ue(le,ae);F.current=new Set(F.current),F.current.add(le),Q(we=>{if(!we[le])return we;const Se={...we};return delete Se[le],Se}),O(we=>({...we,[le]:V}))}catch(ae){if(_?.())return;const V=ae instanceof Error?ae.message:String(ae??"");console.error("Failed to load sidebar directory:",ae),Q(we=>({...we,[le]:V}))}finally{M.current=new Set(M.current),M.current.delete(le)}},[t,ue]),be=n.useCallback(async()=>{if(!a)return;L.current?.abort();const x=new AbortController;L.current=x;try{const le=(Ie.getState().byRoot[a]?.expandedPaths??[]).map(V=>ke(V)).filter(V=>!!V&&V!==a&&V.startsWith(`${a}/`)),$=[a,...le];F.current=new Set(F.current);for(const V of $)F.current.delete(V);Q(V=>{if(Object.keys(V).length===0)return V;const we={...V};let Se=!1;for(const Fe of $)Fe in we&&(delete we[Fe],Se=!0);return Se?we:V});const ae=()=>x.signal.aborted;await se(a,ae);for(let V=0;V<le.length&&!x.signal.aborted;V+=3){const we=le.slice(V,V+3);await Promise.all(we.map(Se=>se(Se,ae)))}}catch(_){if(x.signal.aborted)return;console.error("Failed to refresh sidebar tree:",_)}finally{L.current===x&&(L.current=null)}},[se,a]),xe=n.useCallback(async x=>{if(!x){await be();return}const _=ke(x);F.current=new Set(F.current),F.current.delete(_),M.current=new Set(M.current),M.current.delete(_),await se(_)},[se,be]);n.useEffect(()=>{a&&(L.current?.abort(),F.current=new Set,M.current=new Set,Q({}),O(x=>Object.keys(x).length===0?x:{}),se(a))},[se,a,h,w]),n.useEffect(()=>{if(!a||Y.length===0)return;const x=Y.map($=>ke($)).filter($=>!!$&&$!==a&&$.startsWith(`${a}/`)&&!F.current.has($)&&!M.current.has($)).sort(($,ae)=>$.split("/").length-ae.split("/").length);if(x.length===0)return;let _=!1;const le=()=>_;return(async()=>{for(let $=0;$<x.length&&!_;$+=3){const ae=x.slice($,$+3);await Promise.all(ae.map(V=>se(V,le)))}})(),()=>{_=!0}},[Y,se,a]),n.useEffect(()=>{if(!o){C([]),D(!1);return}const x=i.trim();if(!x){C([]),D(!1);return}let _=!1;return D(!0),d(o,x,150,{includeHidden:h,respectGitignore:!w,type:"file"}).then(le=>{if(_)return;const ae=le.filter(V=>w||!vs(V.path)).map(V=>({name:V.name,path:ke(V.path),type:"file",extension:V.extension,relativePath:V.relativePath}));C(ae)}).catch(()=>{_||C([])}).finally(()=>{_||D(!1)}),()=>{_=!0}},[o,i,d,h,w]);const j=n.useMemo(()=>{const x=new Map;if(!f?.files)return x;for(const _ of f.files)_.index==="A"||_.working_dir==="?"?x.set(_.path,"git-added"):_.index==="D"?x.set(_.path,"git-deleted"):(_.index==="M"||_.working_dir==="M")&&x.set(_.path,"git-modified");return x},[f]),ye=n.useMemo(()=>{const x=new Map;if(!f?.files||!a)return x;for(const _ of f.files){const le=_.index==="M"||_.working_dir==="M",$=_.index==="A"||_.working_dir==="?";if(!le&&!$)continue;const ae=_.path.split("/");if(ae.length<=1)continue;let V=a;for(let we=0;we<ae.length-1;we++){V=`${V}/${ae[we]}`;let Se=x.get(V);Se||(Se={modified:0,added:0},x.set(V,Se)),le&&Se.modified++,$&&Se.added++}}return x},[f,a]),P=n.useCallback(x=>{if(G.has(x))return"open";if(j.size===0)return null;const _=x.startsWith(a+"/")?x.slice(a.length+1):x;return j.get(_)??null},[G,j,a]),ne=n.useCallback(x=>{if(ye.size===0)return null;const _=ye.get(x);return _&&_.modified+_.added>0?_:null},[ye]),oe=n.useCallback(async x=>{if(!a)return;const _=await vr(t,x.path,{directory:a});if(!_.ok){he.error(jr(_.reason));return}B(a,x.path),X(a,x.path),m(a,x.path)},[X,t,m,a,B]),l=n.useCallback(async x=>{const _=ke(x);a&&(z(a,_),F.current.has(_)||await se(_))},[se,a,z]),g=n.useCallback(async x=>{if(x?.preventDefault(),!re||!T)return;ge(!0);const _=()=>ge(!1),le=()=>q(null);if(T==="createFile"){if(!me.trim()){he.error("Filename is required"),_();return}if(!t.writeFile){he.error("Write not supported"),_();return}const $=re.path,ae=$?`${$}/`:"",V=ke(`${ae}${me.trim()}`);await t.writeFile(V,"").then(async we=>{we.success&&(he.success("File created"),await xe($)),le()}).catch(()=>he.error("Operation failed")).finally(_);return}if(T==="createFolder"){if(!me.trim()){he.error("Folder name is required"),_();return}const $=re.path,ae=$?`${$}/`:"",V=ke(`${ae}${me.trim()}`);await t.createDirectory(V).then(async we=>{we.success&&(he.success("Folder created"),await xe($)),le()}).catch(()=>he.error("Operation failed")).finally(_);return}if(T==="rename"){if(!me.trim()){he.error("Name is required"),_();return}if(!t.rename){he.error("Rename not supported"),_();return}const $=re.path,ae=$.split("/").slice(0,-1).join("/"),V=ae?`${ae}/`:"",we=ke(`${V}${me.trim()}`);await t.rename($,we).then(async Se=>{Se.success&&(he.success("Renamed successfully"),await xe(ae),a&&R(a,$),(K===$||K&&K.startsWith(`${$}/`))&&B(a,null)),le()}).catch(()=>he.error("Operation failed")).finally(_);return}if(T==="delete"){if(!t.delete){he.error("Delete not supported"),_();return}const $=re.path,ae=$.split("/").slice(0,-1).join("/");await t.delete($).then(async V=>{V.success&&(he.success("Deleted successfully"),await xe(ae),a&&R(a,$),(K===$||K&&K.startsWith($+"/"))&&B(a,null)),le()}).catch(()=>he.error("Operation failed")).finally(_);return}_()},[T,re,me,t,xe,R,a,K,B]);function ee(x,_){const le=A[x]??[];return le.map(($,ae)=>{const V=$.type==="directory",we=V&&Y.includes($.path),Se=K===$.path,Fe=ae===le.length-1;return e.jsxs("li",{className:"relative",children:[_>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),Fe&&e.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-sidebar/50"})]}),e.jsx(Rs,{node:$,root:a,isExpanded:we,isActive:Se,isBrowserClient:s,status:V?void 0:P($.path),badge:V?ne($.path):void 0,permissions:I,downloadFile:t.downloadFile,onSelect:oe,onToggle:l,onRevealPath:H,onOpenDialog:J}),V&&we&&e.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[te[$.path]?e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:te[$.path],children:te[$.path]}),e.jsxs(pe,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{xe($.path)},children:[e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"}),"Refresh"]})]}):null,ee($.path,_+1)]})]},$.path)})}const de=!!(a&&A[a]),Pe=a?te[a]:null;return e.jsxs("section",{className:"flex h-full min-h-0 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[ce&&e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>J("createFile",{path:o,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:e.jsx(U,{name:"file-add",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"New File"})]}),je&&e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>J("createFolder",{path:o,type:"directory"}),className:"h-8 w-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:e.jsx(U,{name:"folder-add",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"New Folder"})]}),e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>{be()},className:"h-8 w-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:e.jsx(U,{name:"refresh",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"Refresh"})]}),e.jsxs(Be,{children:[e.jsx(ze,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(pe,{variant:"ghost",size:"sm",onClick:()=>{a&&v(a)},className:"h-8 w-8 p-0 flex-shrink-0",title:"Collapse all folders","aria-label":"Collapse all folders",children:e.jsx(U,{name:"collapse-vertical",className:"h-4 w-4"})})})}),e.jsx(Ue,{side:"bottom",sideOffset:6,children:"Collapse all folders"})]})]}),e.jsxs("div",{className:"relative min-w-0",children:[e.jsx(U,{name:"search",className:"pointer-events-none absolute left-2 top-2 h-4 w-4 text-muted-foreground"}),e.jsx($t,{ref:N,value:b,onChange:x=>p(x.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),b.trim().length>0?e.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex h-4 w-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{p(""),N.current?.focus()},children:e.jsx(U,{name:"close",className:"h-4 w-4"})}):null]})]}),e.jsx(bn,{outerClassName:"flex-1 min-h-0",className:"p-2",children:e.jsx("ul",{className:"flex flex-col",children:S?e.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx(U,{name:"loader-4",className:"h-4 w-4 animate-spin"}),"Searching..."]}):c.length>0?c.map(x=>{const _=K===x.path;return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>oe(x),draggable:!0,onDragStart:le=>{const $=x.relativePath||Sr(a??"",x.path);!$||$==="."||(le.dataTransfer.setData("application/x-pichamber-file-path",$),le.dataTransfer.effectAllowed="copy")},className:ve("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors cursor-grab active:cursor-grabbing",_?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),title:x.path,children:[Cr(x.path,x.extension),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},children:x.relativePath??x.path})]})},x.path)}):Pe?e.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{children:Pe}),e.jsxs(pe,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{be()},children:[e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"}),"Refresh"]})]}):de&&a?ee(a,0):e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})}),e.jsx(yt,{open:!!T,onOpenChange:x=>!x&&q(null),children:e.jsxs(bt,{children:[e.jsxs(vt,{children:[e.jsxs(jt,{children:[T==="createFile"&&"Create File",T==="createFolder"&&"Create Folder",T==="rename"&&"Rename",T==="delete"&&"Delete"]}),e.jsxs(St,{children:[T==="createFile"&&`Create a new file in ${re?.path??"root"}`,T==="createFolder"&&`Create a new folder in ${re?.path??"root"}`,T==="rename"&&`Rename ${re?.name??""}`,T==="delete"&&`Are you sure you want to delete ${re?.name??""}? This action cannot be undone.`]})]}),T!=="delete"&&e.jsx("div",{className:"py-4",children:e.jsx($t,{value:me,onChange:x=>Ce(x.target.value),placeholder:T==="rename"?"New name":"Name",onKeyDown:x=>{x.key==="Enter"&&g()},autoFocus:!0})}),e.jsxs(vn,{children:[e.jsx(pe,{variant:"outline",onClick:()=>q(null),disabled:fe,children:"Cancel"}),e.jsx(pe,{variant:T==="delete"?"destructive":"default",onClick:()=>{g()},disabled:fe||T!=="delete"&&!me.trim(),children:fe?e.jsx(U,{name:"loader-4",className:"size-4 animate-spin"}):T==="delete"?"Delete":"Confirm"})]})]})})]})},Et=t=>t,ft=t=>{const r=Et(t).type;return typeof r=="string"?r:""},Ts=t=>{const r=Et(t).tool;return typeof r=="string"?r:""},Ds=t=>{const r=Et(t).text;return typeof r=="string"?r:""},_s=t=>{const r=ft(t);return r==="tool"?Ts(t).trim().toLowerCase()||"tool":r||"unknown"},As=t=>{if(t.length===0)return"";const r=[];for(const s of t){const o=_s(s);r.includes(o)||r.push(o)}return r.join(" + ")},Ms=t=>t.replace(/\s+/g," ").trim(),Is=t=>{for(const s of t)if(ft(s)==="text"){const o=Ms(Ds(s));if(o.length===0)continue;return o}const r=t.filter(s=>ft(s)!=="text").length;return r===0?"":`${r} attachment${r===1?"":"s"}`},Ls=(t,r,s)=>`${s(t)} / ${s(r)}`,$s=t=>{if(t==="12h")return!0;if(t==="24h")return!1},Os=(t,r)=>{if(!t||!Number.isFinite(t))return"-";const s=$s(r);return new Date(t).toLocaleString(void 0,{month:"numeric",day:"numeric",hour:s===!1?"2-digit":"numeric",minute:"2-digit",...s===void 0?{}:{hour12:s}})},Ws={input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,total:0},rt={user:0,assistant:0,tool:0,other:0},Fs=t=>typeof t!="number"||!Number.isFinite(t)||t<0?0:t,ct=t=>mt(t),Bs=(...t)=>{for(const r of t)if(typeof r=="string"&&r.trim().length>0)return r;return""},De=t=>typeof t=="string"?t.length:typeof t=="number"||typeof t=="boolean"?String(t).length:Array.isArray(t)?t.reduce((r,s)=>r+De(s),0):t&&typeof t=="object"?Object.values(t).reduce((r,s)=>r+De(s),0):0,zs=(t,r)=>{const s=t,o=typeof s.type=="string"?s.type:"";if(o==="reasoning")return{...rt,assistant:De(s.text)+De(s.content)};const a=Bs(s.text,s.content,s.value,s.source?.value,s.source?.text?.value);return o==="tool"||r==="tool"?{user:0,assistant:0,tool:De(s.input)+De(s.output)+De(s.error)+De(s.call?.input)+De(s.call?.output)+De(s.call?.error)+De(s.raw)+Math.round(De(s.metadata)*.25)+Math.round(De(s.state)*.1),other:0}:r==="user"?{user:a.length,assistant:0,tool:0,other:0}:r==="assistant"?{user:0,assistant:a.length,tool:0,other:0}:{user:0,assistant:0,tool:0,other:a.length}},Xt=(t,r)=>({user:t.user+r.user,assistant:t.assistant+r.assistant,tool:t.tool+r.tool,other:t.other+r.other}),Us=t=>{const r=Ye(t.info);return r.isUser?"user":r.role==="assistant"?"assistant":r.role==="tool"?"tool":"other"},Hs=(t,r)=>{if(t.length===0)return{...rt};const s=t.reduce((o,a)=>{const h=Us(a);let w={...rt};for(const d of a.parts)w=Xt(w,zs(d,h));return Xt(o,w)},{...rt});return s.user+=r.length,{user:Math.ceil(s.user/4),assistant:Math.ceil(s.assistant/4),tool:Math.ceil(s.tool/4),other:Math.ceil(s.other/4)}},$e=t=>t.toLocaleString("en-US"),Vs=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),Ks=(t,r)=>!t||!Number.isFinite(t)?"-":kn(t,r,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}),Xs=(t,r,s)=>{const o=t.find(h=>h.id===r),a=o?.models?.find(h=>h.id===s);return{providerName:o?.name||r||"-",modelName:a?.name||s||"-",contextLimit:typeof a?.limit?.context=="number"?a.limit.context:null}},Gs=()=>{const t=Z(c=>c.timeFormatPreference),[r,s]=n.useState({}),[o,a]=n.useState(null),h=n.useRef(null),w=Ee(c=>c.currentSessionId),d=Ee(c=>c.currentSessionDirectory),m=Cn(),f=pr(w??""),b=We(c=>c.providers);n.useEffect(()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null),s(c=>Object.keys(c).length>0?{}:c),a(null)},[d,w]),n.useEffect(()=>()=>{h.current!==null&&(window.clearTimeout(h.current),h.current=null)},[]);const p=n.useCallback(async(c,C)=>{(await xt(C)).ok?(a(c),h.current!==null&&window.clearTimeout(h.current),h.current=window.setTimeout(()=>{a(D=>D===c?null:D),h.current=null},2e3)):a(null)},[]),i=n.useMemo(()=>{const c=w?m.find(T=>T.id===w)??null:null,C=f.filter(T=>Ye(T.info).role==="assistant"),S=f.filter(T=>Ye(T.info).isUser);let D=null;for(let T=C.length-1;T>=0;T-=1){const q=C[T];if(ct(q).total>0){D=q;break}}const A=D?ct(D):Ws,O=D?.info?.usage,te=mr({input:A.input,cache:{read:A.cacheRead,write:A.cacheWrite}}),Q=C.reduce((T,q)=>{const re=Fs(q.info.cost);return T+re},0),F=D?.info?.model??null,M=Xs(b,F?.providerID||"",F?.modelID||""),L=M.contextLimit,y=O?fr(O):A.total,W=L&&L>0?Math.min(999,y/L*100):0,Y=[...f].reverse().find(T=>Ye(T.info).isUser&&typeof T.info.system=="string")?.info?.system||"",K=Hs(f,Y),B=K.user,X=K.assistant,R=K.tool,z=O?0:Math.max(0,A.input-B-X-R),v=B+X+R+z,E=f[0]?.info?.time?.created,G=f.length>0?f[f.length-1]?.info?.time?.created:null;return{sessionTitle:c?.title||"Untitled Session",messagesCount:f.length,userMessagesCount:S.length,assistantMessagesCount:C.length,createdAt:c?.time?.created??E??null,lastActivityAt:G??c?.time?.created??null,providerModel:M,tokenBreakdown:A,usagePercent:W,cacheHitRate:te,totalAssistantCost:Q,contextLimit:L,contextWindowTokens:y,hasUsage:O!==void 0,breakdown:{user:B,assistant:X,tool:R,other:z},breakdownTotal:v}},[w,b,f,m]);if(!w)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 N=[{key:"user",label:"User",value:i.breakdown.user,color:"var(--status-success)"},{key:"assistant",label:"Assistant",value:i.breakdown.assistant,color:"var(--primary-base)"},{key:"tool",label:"Tool Calls",value:i.breakdown.tool,color:"var(--status-warning)"},...i.hasUsage?[]:[{key:"other",label:"Other",value:i.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:i.sessionTitle}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 typography-micro text-muted-foreground/70",children:[e.jsxs("span",{children:[i.providerModel.providerName," / ",i.providerModel.modelName]}),i.createdAt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:Ks(i.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-muted-foreground/70",children:[$e(i.contextWindowTokens),i.contextLimit?` / ${$e(i.contextLimit)}`:""]})]}),e.jsx("div",{className:"mt-2.5 flex h-1 w-full overflow-hidden rounded-full bg-[var(--surface-subtle)]",children:i.usagePercent>0&&e.jsx("div",{className:"rounded-full transition-all duration-300",style:{width:`${Math.max(.5,i.usagePercent)}%`,backgroundColor:i.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:`${i.usagePercent.toFixed(1)}% used`})]}),e.jsx("div",{className:"mb-5 grid grid-cols-2 gap-2",children:[{label:"Messages",value:$e(i.messagesCount)},{label:"User",value:$e(i.userMessagesCount)},{label:"Assistant",value:$e(i.assistantMessagesCount)},{label:"Cost",value:Vs(i.totalAssistantCost)}].map(c=>e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 px-3 py-2.5",children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:c.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:c.value})]},c.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:i.tokenBreakdown.input,format:"count"},{label:"Output",value:i.tokenBreakdown.output,format:"count"},{label:"Reasoning",value:i.tokenBreakdown.reasoning,format:"count"},{label:"Cache Read",value:i.tokenBreakdown.cacheRead,format:"count"},{label:"Cache Write",value:i.tokenBreakdown.cacheWrite,format:"count"},{label:"Cache Hit",value:i.cacheHitRate.hasInput?i.cacheHitRate.percent:null,format:"percent"}].map(c=>e.jsxs("div",{children:[e.jsx("div",{className:"typography-micro text-muted-foreground/70",children:c.label}),e.jsx("div",{className:"mt-0.5 typography-ui-label tabular-nums text-foreground",children:c.value!==null&&c.value!==void 0?c.format==="percent"?`${c.value.toFixed(1)}%`:$e(c.value):"—"})]},c.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:N.map(c=>c.value<=0||i.breakdownTotal<=0?null:e.jsx("div",{style:{width:`${c.value/i.breakdownTotal*100}%`,backgroundColor:c.color}},c.key))}),e.jsx("div",{className:"mt-2 flex flex-wrap items-center gap-x-4 gap-y-1",children:N.map(c=>{const C=i.breakdownTotal>0?c.value/i.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:c.color}}),e.jsxs("span",{className:"typography-micro text-muted-foreground/70",children:[c.label," ",e.jsxs("span",{className:"tabular-nums",children:[C.toFixed(0),"%"]})]})]},c.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:[...f].reverse().map(c=>{const S=Ye(c.info).role,D=S==="assistant",A=S==="user",O=r[c.info.id]===!0,te=o===c.info.id,Q=c.info.time?.created??null,F=As(c.parts),M=D?ct({info:c.info,parts:c.parts}):null,L=A?Is(c.parts):"",y=Os(Q,t),W=F||"—",Y=M?Ls(M.input,M.output,$e):"",K=S||"unknown",B=F?`${K}: ${F}`:K,X=O?JSON.stringify({info:c.info,parts:c.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":O,onClick:()=>{s(R=>({...R,[c.info.id]:R[c.info.id]!==!0}))},children:e.jsxs("div",{className:"grid items-center gap-x-2 whitespace-nowrap typography-micro",style:{gridTemplateColumns:D?"minmax(0, 1fr) 7.5rem max-content":"minmax(0, 1fr) max-content"},children:[A?e.jsxs("span",{className:"min-w-0 truncate text-muted-foreground",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"user:"})," ",L]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"min-w-0 truncate text-muted-foreground",children:D?W:B}),D&&e.jsx("span",{className:"text-right text-muted-foreground tabular-nums",children:Y})]}),e.jsx("span",{className:"text-right text-muted-foreground",children:y})]})}),O&&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:R=>{R.stopPropagation(),p(c.info.id,X)},"aria-label":te?"Copied":"Copy JSON",title:te?"Copied":"Copy",children:te?e.jsx(U,{name:"check",className:"size-3.5"}):e.jsx(U,{name:"file-copy",className:"size-3.5"})})}),e.jsx(Nn,{language:"json",code:X,style:{margin:0,padding:"0.75rem",background:"transparent",fontSize:"var(--text-micro)",lineHeight:"1.35"},wrap:!0})]})})]},c.info.id)})})]})]})})},Ys="x-pichamber-preview-target-error",qs=t=>{const r=t.get(Ys);return r==="missing"||r==="expired"||r==="invalid-token"?r:null},Js=(t,r)=>qs(t)?r?"stop-retrying":"retry-registration":"none",Qs=t=>{if(!t||typeof t!="object")return!1;const r=t;return typeof r.x=="number"&&typeof r.y=="number"},Gt=t=>!t||typeof t!="object"?!1:Object.values(t).every(r=>typeof r=="string"),Ve=t=>{if(!t||typeof t!="object")return!1;const r=t,s=r.bounds;return typeof r.tag=="string"&&typeof r.text=="string"&&typeof r.selector=="string"&&typeof r.path=="string"&&!!s&&typeof s?.x=="number"&&typeof s?.y=="number"&&typeof s?.width=="number"&&typeof s?.height=="number"&&Qs(r.center)&&Gt(r.attributes)&&Gt(r.computedStyle)&&Array.isArray(r.ancestry)},Tt=({pageUrl:t,viewport:r,devicePixelRatio:s,target:o,screenshotAttached:a,intro:h})=>{const w=o.text.trim(),d=Object.entries(o.attributes).map(([N,c])=>`${N}="${c}"`).join(" "),m=o.computedStyle,f=o.bounds,b=o.center,p=h.replace(/[.:]+$/g,""),i=o.ancestry.map(N=>N.selectorPart).join(" > ");return[`${p}:`,`Page: ${t||"preview"}`,`Viewport: ${r.width}x${r.height}, DPR ${s}`,`Screenshot: ${a?"attached":"not attached"}`,`Element: ${o.tag}`,w?`Text: ${w}`:null,`- Selector: ${o.selector}`,`- Path: ${o.path}`,i?`- Ancestry: ${i}`:null,d?`- Attributes: ${d}`:null,`- Bounds: x=${Math.round(f.x)}, y=${Math.round(f.y)}, width=${Math.round(f.width)}, height=${Math.round(f.height)}`,`- Center: x=${Math.round(b.x)}, y=${Math.round(b.y)}`,`Styles: display=${m.display}; position=${m.position}; font=${m.fontWeight} ${m.fontSize} / ${m.lineHeight} ${m.fontFamily}; color=${m.color}; background=${m.backgroundColor}; z-index=${m.zIndex}`].filter(N=>typeof N=="string").join(`
3
+ `)},Nr=async(t,r)=>{if(typeof window<"u")try{const s=t.getBoundingClientRect(),o=await or("desktop_capture_page_rect",{x:s.left,y:s.top,width:s.width,height:s.height});if(!o)throw new Error("Desktop screenshot capture is not available");const a=new Image;await new Promise((c,C)=>{a.onload=()=>c(),a.onerror=()=>C(new Error("Failed to load desktop preview screenshot")),a.src=`data:${o.mime};base64,${o.base64}`});const h=Math.max(1,a.naturalWidth||o.width||Math.floor(s.width)),w=Math.max(1,a.naturalHeight||o.height||Math.floor(s.height)),m=Math.min(1,1200/h),f=document.createElement("canvas");f.width=Math.floor(h*m),f.height=Math.floor(w*m);const b=f.getContext("2d");if(!b)return null;b.scale(m,m),b.drawImage(a,0,0,h,w);const p=h/Math.max(1,s.width),i=w/Math.max(1,s.height);b.fillStyle="rgba(37, 99, 235, 0.28)",b.strokeStyle="rgb(37, 99, 235)",b.lineWidth=Math.max(2,2*p),b.fillRect(r.bounds.x*p,r.bounds.y*i,r.bounds.width*p,r.bounds.height*i),b.strokeRect(r.bounds.x*p,r.bounds.y*i,r.bounds.width*p,r.bounds.height*i);const N=await new Promise(c=>f.toBlob(c,"image/jpeg",.82));return N?new File([N],`preview-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch(s){return console.warn("[preview] failed to capture annotation screenshot:",s),null}return await mo(t,r)},Dt=async(t,r,s,o,a,h)=>{if(!t)return null;try{const w=new Image;await new Promise((S,D)=>{w.onload=()=>S(),w.onerror=()=>D(new Error("Failed to load desktop browser screenshot")),w.src=`data:image/jpeg;base64,${t}`});const d=Math.max(1,w.naturalWidth||r),m=Math.max(1,w.naturalHeight||s),b=Math.min(1,1200/d),p=document.createElement("canvas");p.width=Math.floor(d*b),p.height=Math.floor(m*b);const i=p.getContext("2d");if(!i)return null;i.scale(b,b),i.drawImage(w,0,0,d,m);const N=d/Math.max(1,o||d),c=m/Math.max(1,a||m);i.fillStyle="rgba(37, 99, 235, 0.14)",i.strokeStyle="rgb(37, 99, 235)",i.lineWidth=Math.max(2,2*N),i.fillRect(h.bounds.x*N,h.bounds.y*c,h.bounds.width*N,h.bounds.height*c),i.strokeRect(h.bounds.x*N,h.bounds.y*c,h.bounds.width*N,h.bounds.height*c);const C=await new Promise(S=>p.toBlob(S,"image/jpeg",.82));return C?new File([C],`browser-annotation-${Date.now()}.jpg`,{type:"image/jpeg"}):null}catch{return null}},Ke="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=",Re=new Map,dt=new Map,Zs=3e4,_t=t=>{const r=Re.get(t);return r?r.expiresAt-Date.now()<=Zs?(Re.delete(t),null):r:null},eo=t=>{try{return new URL(t).origin}catch{return t}};function kr(t){const r="#ffffff",s=t.defaultView??window;try{const o=t.body?s.getComputedStyle(t.body).backgroundColor:"";if(o&&o!=="rgba(0, 0, 0, 0)"&&o!=="transparent")return o;const a=s.getComputedStyle(t.documentElement).backgroundColor;if(a&&a!=="rgba(0, 0, 0, 0)"&&a!=="transparent")return a}catch{}return r}const Pr=t=>new Promise((r,s)=>{const o=new FileReader;o.onloadend=()=>r(typeof o.result=="string"?o.result:Ke),o.onerror=()=>s(o.error??new Error("Failed to read image blob")),o.readAsDataURL(t)}),to=async(t,r=.82)=>{const s=await new Promise(o=>t.toBlob(o,"image/jpeg",r));return s&&(await Pr(s)).split(",",2)[1]||""},ro=()=>{try{return!!window.__previewCaptureDebug}catch{return!1}},nt=(...t)=>{ro()&&console.info("[preview-capture]",...t)},Rr=(t,r=8)=>{const s=[];try{const o=t.querySelectorAll("*");for(const a of o){const h=a.scrollTop||0,w=a.scrollLeft||0;if(h<=0&&w<=0)continue;const d=a.tagName.toLowerCase(),m=a.id?`#${a.id}`:"",f=typeof a.className=="string"&&a.className?`.${a.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";if(s.push({selector:`${d}${m}${f}`,scrollTop:h,scrollLeft:w,clientWidth:a.clientWidth,clientHeight:a.clientHeight,scrollWidth:a.scrollWidth,scrollHeight:a.scrollHeight}),s.length>=r)break}}catch{}return s},Je="data-oc-fixed-pin",no=(t,r,s)=>{if(r<=0&&s<=0)return()=>{};const o=t.defaultView;if(!o)return()=>{};const a=[],h=[];try{for(const w of t.querySelectorAll("*")){if(o.getComputedStyle(w).position!=="fixed")continue;const d=w.getBoundingClientRect();if(!(d.width>0&&d.height>0))continue;w.setAttribute(Je,JSON.stringify({top:d.top+s,left:d.left+r,width:d.width,height:d.height})),a.push(w);const m=w.tagName.toLowerCase(),f=typeof w.className=="string"&&w.className?`.${w.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";h.push({selector:`${m}${f}`,top:Math.round(d.top),left:Math.round(d.left),width:Math.round(d.width),height:Math.round(d.height)})}}catch{}return nt("tagged fixed elements",h),()=>{for(const w of a)try{w.removeAttribute(Je)}catch{}}},so={name:"oc-fixed-pin",afterClone(t){const r=t?.clone;if(!(!r||typeof r.querySelectorAll!="function"))for(const s of r.querySelectorAll(`[${Je}]`)){let o;try{o=JSON.parse(s.getAttribute(Je)||"")}catch{continue}s.style.setProperty("position","absolute","important"),s.style.setProperty("top",`${o.top}px`,"important"),s.style.setProperty("left",`${o.left}px`,"important"),s.style.setProperty("right","auto","important"),s.style.setProperty("bottom","auto","important"),s.style.setProperty("width",`${o.width}px`,"important"),s.style.setProperty("height",`${o.height}px`,"important"),s.removeAttribute(Je)}}},He="data-oc-scroll-pin",oo=t=>{const r=[],s=Rr(t,64);try{const h=t.documentElement,w=t.body;for(const d of t.querySelectorAll("*")){const m=d.scrollTop||0,f=d.scrollLeft||0;if(m<=0&&f<=0)continue;const b=d!==h&&d!==w;b&&d.setAttribute(He,JSON.stringify({top:m,left:f})),r.push({el:d,top:m,left:f,tagged:b})}}catch{}return{reapply:()=>{for(const h of r)try{h.el.scrollHeight,h.el.scrollTop!==h.top&&(h.el.scrollTop=h.top),h.el.scrollLeft!==h.left&&(h.el.scrollLeft=h.left)}catch{}},cleanup:()=>{for(const h of r)if(h.tagged)try{h.el.removeAttribute(He)}catch{}},snapshot:s}},ao={name:"oc-nested-scroll",afterClone(t){const r=t?.clone;if(!r||typeof r.querySelectorAll!="function")return;const s=r.ownerDocument;if(s)for(const o of r.querySelectorAll(`[${He}]`)){let a;try{a=JSON.parse(o.getAttribute(He)||"")}catch{o.removeAttribute(He);continue}const h=`translate(${-a.left}px, ${-a.top}px)`,w=o.children.length===1&&o.firstElementChild instanceof HTMLElement&&o.firstElementChild.style.willChange==="transform"?o.firstElementChild:null;if(w)w.style.transform=h;else{o.style.overflow="hidden";const d=s.createElement("div");for(d.style.transform=h,d.style.willChange="transform",d.style.display="inline-block",d.style.width="100%";o.firstChild;)d.appendChild(o.firstChild);o.appendChild(d)}o.removeAttribute(He)}}},ut=async(t,r)=>{try{const s=await fetch(t,{credentials:r});return s.ok?await Pr(await s.blob()):null}catch{return null}},io=async t=>{if(t.protocol!=="http:"&&t.protocol!=="https:")return"";const r=t.origin,s=_t(r);if(s)return`${s.proxyBasePath}${t.pathname}${t.search}${t.hash}`;const o=dt.get(r),a=o??(async()=>{try{const w=await ot("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:t.toString(),allowExternal:!0})});if(!w.ok)return Re.delete(r),null;const d=await w.json(),m=typeof d.proxyBasePath=="string"?d.proxyBasePath:"",f=typeof d.expiresAt=="number"?d.expiresAt:0;if(!m)return Re.delete(r),null;const b={proxyBasePath:m,expiresAt:f};return Re.set(r,b),b}catch{return Re.delete(r),null}finally{dt.delete(r)}})();o||dt.set(r,a);const h=await a;return h?`${h.proxyBasePath}${t.pathname}${t.search}${t.hash}`:""},Er=async(t,r)=>{if(!t||t.startsWith("data:"))return t;try{const s=new URL(t,r.baseURI);if(s.origin===window.location.origin||s.protocol!=="http:"&&s.protocol!=="https:")return await ut(s.toString(),"include")??Ke;const o=await io(s),a=o?await ut(o,"include"):null;return a||(await ut(s.toString(),"omit")??Ke)}catch{return Ke}},lo=async(t,r)=>{if(!t||t==="none"||!t.includes("url("))return t;const s=Array.from(t.matchAll(/url\((['"]?)(.*?)\1\)/g));let o=t;for(const a of s){const h=a[2]||"";if(!h||h.startsWith("data:"))continue;const w=await Er(h,r);o=o.replace(a[0],`url("${w}")`)}return o},Yt=t=>t.complete?Promise.resolve():new Promise(r=>{t.addEventListener("load",()=>r(),{once:!0}),t.addEventListener("error",()=>r(),{once:!0})}),Tr=t=>{const r=t.style.cssText;return()=>{t.style.cssText=r}},co=t=>{const r=Number.parseFloat(t.lineHeight);if(Number.isFinite(r)&&r>0)return r;const s=Number.parseFloat(t.fontSize);return Number.isFinite(s)&&s>0?s*1.2:16},uo=(t,r,s)=>{const o=[],a=t.defaultView??window,w=Array.from(t.querySelectorAll('button, a, summary, label, [role="button"], [role="link"], [role="menuitem"], [role="tab"], nav *, header *'));for(const d of w){const m=d.textContent?.replace(/\s+/g," ").trim()??"";if(!m||!m.includes(" "))continue;const f=d.getBoundingClientRect();if(f.width<=0||f.height<=0||f.right<0||f.bottom<0||f.left>r||f.top>s)continue;const b=a.getComputedStyle(d);if(b.display==="none"||b.visibility==="hidden"||Number(b.opacity)===0)continue;const p=b.getPropertyValue("text-wrap"),i=b.getPropertyValue("text-wrap-mode"),N=b.whiteSpace.includes("nowrap")||p==="nowrap"||i==="nowrap",c=f.height<=co(b)*1.7;!N&&(!c||f.width>r*.72)||(o.push(Tr(d)),d.style.whiteSpace="nowrap",d.style.overflowWrap="normal",d.style.wordBreak="normal",d.style.setProperty("text-wrap","nowrap"),d.style.setProperty("text-wrap-mode","nowrap"))}return()=>{for(let d=o.length-1;d>=0;d-=1)o[d]?.()}},ho=(t,r,s,o)=>{const a=[],h=t.defaultView??window,w=h.scrollX||t.documentElement.scrollLeft||t.body?.scrollLeft||0,d=h.scrollY||t.documentElement.scrollTop||t.body?.scrollTop||0,m=Array.from(t.querySelectorAll("*")).filter(f=>{const b=h.getComputedStyle(f);if(b.position!=="fixed"||b.display==="none"||b.visibility==="hidden"||Number(b.opacity)===0)return!1;const p=f.getBoundingClientRect();return p.width>0&&p.height>0&&p.right>=0&&p.bottom>=0&&p.left<=r&&p.top<=s}).filter((f,b,p)=>!p.some((i,N)=>N<b&&i.contains(f)));for(const f of m){const b=f.getBoundingClientRect(),p=h.getComputedStyle(f),i=Math.ceil(b.width)+8,N=Math.ceil(b.height)+2;o?.add(f),a.push(Tr(f)),f.style.position="absolute",f.style.top=`${b.top+d}px`,f.style.left=`${b.left+w}px`,f.style.right="auto",f.style.bottom="auto",f.style.width=`${i}px`,f.style.minWidth=`${i}px`,f.style.height=`${N}px`,f.style.minHeight=`${N}px`,f.style.margin="0",f.style.boxSizing="border-box",f.style.transform="none",p.zIndex!=="auto"&&(f.style.zIndex=p.zIndex)}return()=>{for(let f=a.length-1;f>=0;f-=1)a[f]?.()}},Dr=async(t,r,s,o={})=>{const a=[],h=t.defaultView??window,w=p=>{if(p===t.documentElement||p===t.body)return!0;try{const i=p.getBoundingClientRect();return i.width>0&&i.height>0&&i.right>=0&&i.bottom>=0&&i.left<=r&&i.top<=s}catch{return!1}};if(o.applyLayoutWorkarounds){const p=new WeakSet;a.push(ho(t,r,s,p)),a.push(uo(t,r,s))}const d=new Map;for(const p of Array.from(t.images))d.set(p,p.currentSrc||p.src||p.getAttribute("src")||"");const m=Array.from(t.querySelectorAll("picture"));for(const p of m){const i=Array.from(p.querySelectorAll("source"));if(i.length===0)continue;const N=i.map(c=>({source:c,srcset:c.getAttribute("srcset"),sizes:c.getAttribute("sizes")}));a.push(()=>{for(const c of N)c.srcset===null?c.source.removeAttribute("srcset"):c.source.setAttribute("srcset",c.srcset),c.sizes===null?c.source.removeAttribute("sizes"):c.source.setAttribute("sizes",c.sizes)});for(const c of i)c.removeAttribute("srcset"),c.removeAttribute("sizes")}const f=Array.from(t.images).filter(p=>w(p));await Promise.all(f.map(async p=>{const i=d.get(p)||p.currentSrc||p.src||p.getAttribute("src")||"";if(!i)return;await Yt(p);const N=await Er(i,t),c={src:p.getAttribute("src"),srcset:p.getAttribute("srcset"),sizes:p.getAttribute("sizes")};a.push(()=>{c.src===null?p.removeAttribute("src"):p.setAttribute("src",c.src),c.srcset===null?p.removeAttribute("srcset"):p.setAttribute("srcset",c.srcset),c.sizes===null?p.removeAttribute("sizes"):p.setAttribute("sizes",c.sizes)}),p.removeAttribute("srcset"),p.removeAttribute("sizes"),p.setAttribute("src",N||Ke),await Yt(p)}));const b=Array.from(t.querySelectorAll("*")).filter(w);return await Promise.all(b.map(async p=>{const i=h.getComputedStyle(p).backgroundImage;if(!i||i==="none"||!i.includes("url("))return;const N=await lo(i,t);if(N===i)return;const c=p.style.backgroundImage;a.push(()=>{p.style.backgroundImage=c}),p.style.backgroundImage=N})),()=>{for(let p=a.length-1;p>=0;p-=1)try{a[p]?.()}catch{}}};async function po(t,r){try{const s=t.contentWindow,o=t.contentDocument??s?.document,a=o?.documentElement;if(!s||!o||!a)return null;const h=t.getBoundingClientRect(),w=Math.max(1,Math.ceil(s.innerWidth||t.clientWidth||h.width)),d=Math.max(1,Math.ceil(s.innerHeight||t.clientHeight||h.height)),m=o.body,f=o.scrollingElement instanceof HTMLElement?o.scrollingElement:null,b=s.scrollX||0,p=s.scrollY||0,i=s.pageXOffset||0,N=s.pageYOffset||0,c=s.visualViewport?.pageLeft||s.visualViewport?.offsetLeft||0,C=s.visualViewport?.pageTop||s.visualViewport?.offsetTop||0,S=a.scrollLeft||0,D=a.scrollTop||0,A=m?.scrollLeft||0,O=m?.scrollTop||0,te=f?.scrollLeft||0,Q=f?.scrollTop||0,F=Math.max(b,i,c,S,A,te),M=Math.max(p,N,C,D,O,Q);nt("scroll sources",{windowScrollX:b,windowScrollY:p,pageScrollX:i,pageScrollY:N,visualViewportScrollX:c,visualViewportScrollY:C,rootScrollX:S,rootScrollY:D,bodyScrollX:A,bodyScrollY:O,scrollingElementScrollX:te,scrollingElementScrollY:Q,scrollingElementTag:f?.tagName?.toLowerCase()??null,resolvedScrollX:F,resolvedScrollY:M,nestedScrolledElements:Rr(o)});const L=Math.max(w,a.scrollWidth||0,m?.scrollWidth||0,Math.ceil(a.getBoundingClientRect().width||0)),y=Math.max(d,a.scrollHeight||0,m?.scrollHeight||0,Math.ceil(a.getBoundingClientRect().height||0)),W=Math.min(2,Math.max(1,window.devicePixelRatio||1)),Y=a.style.scrollBehavior,K=m?.style.scrollBehavior??"";a.style.scrollBehavior="auto",m&&(m.style.scrollBehavior="auto");const B=oo(o);nt("nested scroll snapshot",B.snapshot);let X=()=>{},R=()=>{};try{await o.fonts?.ready.catch(()=>{}),X=await Dr(o,w,d,{applyLayoutWorkarounds:!1}),s.scrollTo(F,M),R=no(o,F,M),B.reapply();const{snapdom:z}=await Ae(async()=>{const{snapdom:u}=await import("./vendor-zumer-snapdom-Btyu_Xi2.js");return{snapdom:u}},[]),v={backgroundColor:kr(o),cache:"disabled",dpr:W,embedFonts:!0,fast:!1,height:y,outerShadows:!0,outerTransforms:!0,placeholders:!0,plugins:[so,ao],quality:.82,width:L},G=await(await z(a,v)).toCanvas();if(!G.width||!G.height)return null;const T=G.width/Math.max(1,L),q=G.height/Math.max(1,y),re=Math.min(G.width,Math.max(1,Math.round(w*T))),ie=Math.min(G.height,Math.max(1,Math.round(d*q))),me=Math.max(0,G.width-re),Ce=Math.max(0,G.height-ie),fe=Math.min(me,Math.max(0,Math.round(F*T))),ge=Math.min(Ce,Math.max(0,Math.round(M*q)));nt("capture geometry",{viewportWidth:w,viewportHeight:d,captureWidth:L,captureHeight:y,canvasWidth:G.width,canvasHeight:G.height,xScale:T,yScale:q,sourceX:fe,sourceY:ge,sourceWidth:re,sourceHeight:ie});const ce=o.createElement("canvas");ce.width=re,ce.height=ie;const je=ce.getContext("2d");if(!je)return null;je.drawImage(G,fe,ge,re,ie,0,0,re,ie);const Ne=await to(ce,.82);return Ne?await Dt(Ne,w,d,w,d,r):null}finally{R(),B.cleanup(),X(),s.scrollTo(F,M),B.reapply(),a.style.scrollBehavior=Y,m&&(m.style.scrollBehavior=K)}}catch(s){return console.warn("[preview] failed to capture iframe DOM screenshot with snapDOM:",s),null}}async function mo(t,r){const s=await po(t,r);if(s)return s;try{const o=t.contentWindow,a=t.contentDocument??o?.document,h=a?.documentElement;if(!o||!a||!h)return null;const w=t.getBoundingClientRect(),d=Math.max(1,Math.ceil(o.innerWidth||t.clientWidth||w.width)),m=Math.max(1,Math.ceil(o.innerHeight||t.clientHeight||w.height)),f=o.scrollX||a.documentElement.scrollLeft||a.body?.scrollLeft||0,b=o.scrollY||a.documentElement.scrollTop||a.body?.scrollTop||0,p=a.body,i=Math.max(m,h.scrollHeight||0,p?.scrollHeight||0),N=Math.min(2,Math.max(1,window.devicePixelRatio||1)),c=h.style.scrollBehavior,C=p?.style.scrollBehavior??"";h.style.scrollBehavior="auto",p&&(p.style.scrollBehavior="auto");let S="",D=()=>{};try{await a.fonts?.ready.catch(()=>{}),D=await Dr(a,d,m,{applyLayoutWorkarounds:!0}),o.scrollTo(f,b);const{getFontEmbedCSS:O,toJpeg:te}=await Ae(async()=>{const{getFontEmbedCSS:F,toJpeg:M}=await import("./vendor-html-to-image-BeoRn2gJ.js");return{getFontEmbedCSS:F,toJpeg:M}},[]),Q=await O(h).catch(()=>"");S=await te(h,{quality:.82,pixelRatio:N,width:d,height:m,backgroundColor:kr(a),imagePlaceholder:Ke,fontEmbedCSS:Q||void 0,style:{transform:`translate(${-f}px, ${-b}px)`,transformOrigin:"top left",minWidth:`${d}px`,minHeight:`${i}px`},cacheBust:!0})}finally{D(),o.scrollTo(f,b),h.style.scrollBehavior=c,p&&(p.style.scrollBehavior=C)}const A=S.split(",",2)[1]||"";return A?await Dt(A,d,m,d,m,r):null}catch(o){return console.warn("[preview] failed to capture iframe DOM screenshot:",o),null}}const fo=Le(()=>Ae(()=>import("./DiffView-vrxi5oWp.js"),__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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118])).then(t=>({default:t.DiffView}))),go=Le(()=>Ae(()=>import("./FilesView-BD_h3EVr.js"),__vite__mapDeps([119,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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,120,121,122,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,123,124,116,117,125,126,114,115])).then(t=>({default:t.FilesView}))),xo=Le(()=>Ae(()=>import("./GitView-BwNKqK0K.js"),__vite__mapDeps([127,8,1,2,6,3,4,5,7,9,10,11,12,13,14,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,128,115,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,114,116,117])).then(t=>({default:t.GitView}))),wo=380,yo=1400,_r=600,bo=100,vo=24,qt=200,jo=(t,r)=>r==="all"?!0:r==="errors"?t.level==="error"||t.level==="runtime"||t.level==="resource":r==="warnings"?t.level==="warn":t.level==="log"||t.level==="info"||t.level==="debug",So=t=>{if(!t)return"";const r=t.replace(/\\/g,"/"),s=r.startsWith("//");let o=r.replace(/\/+$/g,"");return o=o.replace(/\/+/g,"/"),s&&!o.startsWith("//")&&(o=`/${o}`),o===""?r.startsWith("/")?"/":"":o},Jt=t=>Number.isFinite(t)?Math.min(yo,Math.max(wo,Math.round(t))):_r,Co=t=>{const r=t?.parentElement?.clientWidth;return!r||r<=0?null:r},No=(t,r)=>{if(!t)return"";const s=t.replace(/\\/g,"/"),o=r.replace(/\\/g,"/").replace(/\/+$/,"");return o&&s.startsWith(o+"/")?s.slice(o.length+1):s},Ar=(t,r=null)=>t==="file"?"Files":t==="diff"?"Changes":t==="preview"?"Preview":t==="browser"?"Browser":t==="git"?Ct(r).label:t==="notes"?"Project notes":t==="terminal"?"Terminal":"Context",ko=t=>{if(!t)return null;const r=t.replace(/\\/g,"/").trim();if(!r)return null;const s=r.split("/").filter(Boolean);return s.length===0?r:s[s.length-1]||null},Po=(t,r=null)=>{if(t.label)return t.label;if(t.mode==="file")return ko(t.targetPath)||"Files";if(t.mode==="preview"){const s=t.targetPath;if(s)try{const o=new URL(s);return o.host||o.hostname||"Preview"}catch{}return"Preview"}return t.mode==="diff"?"Changes":Ar(t.mode,r)},Qt=(t,r=null)=>{if(t.mode==="file")return t.targetPath?e.jsx(gt,{filePath:t.targetPath,className:"h-3.5 w-3.5"}):void 0;if(t.mode==="diff")return e.jsx(sn,{className:"h-3.5 w-3.5"});if(t.mode==="git")return e.jsx(U,{name:Ct(r).icon,className:"h-3.5 w-3.5"});if(t.mode==="notes")return e.jsx(U,{name:"sticky-note",className:"h-3.5 w-3.5"});if(t.mode==="terminal")return e.jsx(U,{name:"terminal-box",className:"h-3.5 w-3.5"});if(t.mode==="context")return e.jsx(U,{name:"donut-chart-fill",className:"h-3.5 w-3.5"});if(t.mode==="preview")return e.jsx(U,{name:"global",className:"h-3.5 w-3.5 text-[var(--status-info)]"});if(t.mode==="browser")return e.jsx(U,{name:"global",className:"h-3.5 w-3.5"})},Ro=200,Eo=480,To=({visible:t})=>{const r=Z(S=>S.contextEditorTreeWidth),s=Z(S=>S.setContextEditorTreeWidth),[o,a]=n.useState(!1),h=n.useRef(0),w=n.useRef(r),d=n.useRef(null),m=n.useRef(null),f=n.useRef(null),b=n.useCallback(S=>Math.min(Eo,Math.max(Ro,Math.round(S))),[]),p=n.useCallback(S=>{const D=f.current;D&&(D.style.width=`${S}px`,D.style.setProperty("--oc-editor-tree-width",`${S}px`))},[]),i=S=>{if(t){try{S.currentTarget.setPointerCapture(S.pointerId)}catch{}m.current=S.pointerId,a(!0),h.current=S.clientX,w.current=r,d.current=r,S.preventDefault()}},N=S=>{if(!o||m.current!==S.pointerId)return;const D=h.current-S.clientX,A=b(w.current+D);d.current!==A&&(d.current=A,p(A))},c=S=>{if(m.current!==S.pointerId)return;try{S.currentTarget.releasePointerCapture(S.pointerId)}catch{}const D=b(d.current??r);m.current=null,d.current=null,a(!1),s(D)},C=t?r:0;return e.jsxs("div",{ref:f,className:ve("relative h-full flex-shrink-0 overflow-hidden border-l border-border bg-background will-change-[width] motion-reduce:transition-none",!t&&"border-l-0"),style:{width:`${o?d.current??C:C}px`,"--oc-editor-tree-width":`${o?d.current??r:r}px`,overflowX:"clip",transitionProperty:o?"none":"width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!t,children:[t&&e.jsx("div",{className:ve("absolute left-0 top-0 z-20 h-full w-[3px] cursor-col-resize transition-colors hover:bg-[var(--interactive-border)]/80",o&&"bg-[var(--interactive-border)]"),onPointerDown:i,onPointerMove:N,onPointerUp:c,onPointerCancel:c,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsx("div",{className:ve("relative z-10 h-full shrink-0 transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",o&&"pointer-events-none",!t&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-editor-tree-width)"},"aria-hidden":!t,children:e.jsx(Es,{})})]})},Mr=`new Promise((resolve) => {
4
+ const existing = document.getElementById('__pichamber_desktop_browser_overlay');
5
+ if (existing) existing.remove();
6
+ if (typeof window.__pichamberDesktopBrowserCancelInspect === 'function') {
7
+ try { window.__pichamberDesktopBrowserCancelInspect(); } catch { /* webview not ready */ }
8
+ }
9
+ const overlay = document.createElement('div');
10
+ overlay.id = '__pichamber_desktop_browser_overlay';
11
+ overlay.style.cssText = 'position:fixed;z-index:2147483647;pointer-events:none;border:2px solid #60a5fa;background:rgba(96,165,250,.24);border-radius:3px;display:none;box-sizing:border-box;';
12
+ document.documentElement.appendChild(overlay);
13
+ const cssEscape = (value) => {
14
+ try { return CSS.escape(value); } catch { return String(value).replace(/[^a-zA-Z0-9_-]/g, '\\\\$&'); }
15
+ };
16
+ const selectorPart = (element) => {
17
+ const tag = element.tagName.toLowerCase();
18
+ if (element.id) return tag + '#' + cssEscape(element.id);
19
+ const className = String(element.className || '').trim().split(/\\s+/).filter(Boolean).slice(0, 3).map((part) => '.' + cssEscape(part)).join('');
20
+ return tag + className;
21
+ };
22
+ const metadata = (element) => {
23
+ const rect = element.getBoundingClientRect();
24
+ const style = getComputedStyle(element);
25
+ const ancestry = [];
26
+ let current = element;
27
+ while (current && current.nodeType === Node.ELEMENT_NODE && ancestry.length < 8) {
28
+ ancestry.unshift({ tag: current.tagName.toLowerCase(), id: current.id || undefined, className: typeof current.className === 'string' ? current.className : undefined, selectorPart: selectorPart(current) });
29
+ current = current.parentElement;
30
+ }
31
+ const attrs = {};
32
+ for (const attr of Array.from(element.attributes || []).slice(0, 16)) attrs[attr.name] = attr.value.slice(0, 300);
33
+ const path = ancestry.map((entry) => entry.selectorPart).join(' > ');
34
+ return {
35
+ frame: 'top',
36
+ tag: element.tagName.toLowerCase(),
37
+ text: String(element.innerText || element.textContent || '').replace(/\\s+/g, ' ').trim().slice(0, 500),
38
+ selector: element.id ? '#' + cssEscape(element.id) : path,
39
+ path,
40
+ bounds: { x: rect.x, y: rect.y, width: rect.width, height: rect.height },
41
+ center: { x: rect.x + rect.width / 2, y: rect.y + rect.height / 2 },
42
+ attributes: attrs,
43
+ computedStyle: { display: style.display, position: style.position, fontWeight: style.fontWeight, fontSize: style.fontSize, lineHeight: style.lineHeight, fontFamily: style.fontFamily, color: style.color, backgroundColor: style.backgroundColor, zIndex: style.zIndex },
44
+ ancestry,
45
+ };
46
+ };
47
+ const move = (event) => {
48
+ const element = document.elementFromPoint(event.clientX, event.clientY);
49
+ if (!element || element === overlay || element === document.documentElement || element === document.body) return;
50
+ const rect = element.getBoundingClientRect();
51
+ overlay.style.display = 'block';
52
+ overlay.style.left = rect.left + 'px';
53
+ overlay.style.top = rect.top + 'px';
54
+ overlay.style.width = rect.width + 'px';
55
+ overlay.style.height = rect.height + 'px';
56
+ };
57
+ const cleanup = () => {
58
+ window.removeEventListener('mousemove', move, true);
59
+ window.removeEventListener('click', click, true);
60
+ window.removeEventListener('keydown', keydown, true);
61
+ if (window.__pichamberDesktopBrowserCancelInspect === cancel) {
62
+ delete window.__pichamberDesktopBrowserCancelInspect;
63
+ }
64
+ };
65
+ const cancel = () => {
66
+ cleanup();
67
+ overlay.remove();
68
+ resolve(null);
69
+ };
70
+ const click = (event) => {
71
+ event.preventDefault();
72
+ event.stopPropagation();
73
+ const element = document.elementFromPoint(event.clientX, event.clientY);
74
+ const result = element ? metadata(element) : null;
75
+ cleanup();
76
+ overlay.remove();
77
+ resolve(result);
78
+ };
79
+ const keydown = (event) => {
80
+ if (event.key !== 'Escape') return;
81
+ cancel();
82
+ };
83
+ window.__pichamberDesktopBrowserCancelInspect = cancel;
84
+ window.addEventListener('mousemove', move, true);
85
+ window.addEventListener('click', click, true);
86
+ window.addEventListener('keydown', keydown, true);
87
+ });`,st=`(() => {
88
+ if (typeof window.__pichamberDesktopBrowserCancelInspect === 'function') {
89
+ window.__pichamberDesktopBrowserCancelInspect();
90
+ return;
91
+ }
92
+ const overlay = document.getElementById('__pichamber_desktop_browser_overlay');
93
+ if (overlay) overlay.remove();
94
+ })()`,Do=`(() => {
95
+ if (window.__pichamberSameWebviewNavigationInstalled) return;
96
+ window.__pichamberSameWebviewNavigationInstalled = true;
97
+
98
+ const navigate = (rawUrl) => {
99
+ if (typeof rawUrl !== 'string' || rawUrl.length === 0) return false;
100
+ try {
101
+ const url = new URL(rawUrl, window.location.href);
102
+ if (url.protocol !== 'http:' && url.protocol !== 'https:') return false;
103
+ window.location.assign(url.href);
104
+ return true;
105
+ } catch (_error) {
106
+ return false;
107
+ }
108
+ };
109
+
110
+ const originalOpen = window.open.bind(window);
111
+ window.open = (url, target, features) => {
112
+ if (navigate(url)) return null;
113
+ return originalOpen(url, target, features);
114
+ };
115
+
116
+ document.addEventListener('click', (event) => {
117
+ if (event.defaultPrevented) return;
118
+ const target = event.target;
119
+ if (!(target instanceof Element)) return;
120
+ const anchor = target.closest('a[target="_blank"][href]');
121
+ if (!(anchor instanceof HTMLAnchorElement)) return;
122
+ if (!navigate(anchor.href)) return;
123
+ event.preventDefault();
124
+ event.stopPropagation();
125
+ }, true);
126
+ })()`,Qe=t=>{const r=t.trim();if(!r)return"about:blank";try{const s=new URL(r.includes("://")?r:`https://${r}`);return s.protocol!=="http:"&&s.protocol!=="https:"?"about:blank":s.toString()}catch{return"about:blank"}},Zt=async(t,r)=>{const s=t.contentWindow;if(!s)throw new Error("Iframe window is not available");const a=s.eval.call(s,r);return await Promise.resolve(a)},_o=(t,r)=>t.length<=r?t:`${t.slice(0,r-3)}...`,Ir=t=>{if(typeof window>"u")return"";try{return new URL(t||window.location.href,window.location.href).origin}catch{return window.location.origin}},er=(t,r,s)=>{const o=Ir(r);t.postMessage(s,o)},Ao=t=>{if(!t)return t;try{const r=new URL(t);return r.searchParams.delete("oc_preview_token"),r.searchParams.delete("oc_client_token"),r.searchParams.delete("oc_url_token"),r.toString()}catch{return t}},tr=t=>{if(!t)return t;try{const r=new URL(t);return r.searchParams.delete("ocPreview"),r.searchParams.delete("oc_preview_token"),r.searchParams.delete("oc_client_token"),r.searchParams.delete("oc_url_token"),r.toString()}catch{return t}},Mo=({rawUrl:t,onNavigate:r})=>{const{currentTheme:s}=Rn(),[o,a]=n.useReducer(P=>P+1,0),[h,w]=n.useReducer(P=>P+1,0),[d,m]=n.useState({status:"idle"}),[f,b]=n.useState(""),p=n.useRef(null),i=n.useRef(1),[N,c]=n.useState(!1),[C,S]=n.useState(!1),[D,A]=n.useState("all"),[O,te]=n.useState([]),[Q,F]=n.useState(!1),[M,L]=n.useState(null),y=Ee(P=>P.currentSessionId),W=Ee(P=>P.newSessionDraft?.open),Y=Ze(),K=Nt(P=>P.addDraft),B=kt(P=>P.addAttachedFile);let X=null;try{X=t?new URL(t):null}catch{X=null}const R=X?X.hostname==="localhost"||X.hostname==="127.0.0.1"||X.hostname==="::1"||X.hostname==="[::1]"||X.hostname==="0.0.0.0":!1,z=X?X.hostname==="0.0.0.0"?new URL(X.toString().replace("0.0.0.0","127.0.0.1")):X:null,v=z?z.toString():"",E=v?`${pt()||"same-origin"}|${v}`:"",G=s.metadata.variant;n.useEffect(()=>{if(!v||!R){m({status:"idle"});return}const P=_t(E);if(P?.previewToken){m({status:"ready",proxyBasePath:P.proxyBasePath,previewToken:P.previewToken,expiresAt:P.expiresAt});return}P&&Re.delete(E);let ne=!1;return m({status:"loading"}),(async()=>{try{const oe=await ot("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:v})});if(!oe.ok){Re.delete(E);const Pe=await oe.json().catch(()=>({})),x=typeof Pe?.error=="string"?Pe.error:`HTTP ${oe.status}`;ne||m({status:"error",message:x});return}const l=await oe.json(),g=typeof l.proxyBasePath=="string"?l.proxyBasePath:"",ee=typeof l.previewToken=="string"?l.previewToken:"",de=typeof l.expiresAt=="number"?l.expiresAt:0;if(!g||!ee){Re.delete(E),ne||m({status:"error",message:"Could not start preview proxy."});return}Re.set(E,{proxyBasePath:g,previewToken:ee,expiresAt:de}),ne||m({status:"ready",proxyBasePath:g,previewToken:ee,expiresAt:de})}catch(oe){if(Re.delete(E),!ne){const l=oe instanceof Error?oe.message:String(oe);m({status:"error",message:l})}}})(),()=>{ne=!0}},[R,E,h,v]);const T=z&&(z.protocol==="http:"||z.protocol==="https:")?z.toString():"",q=R&&d.status==="ready"?`${d.proxyBasePath}|${d.previewToken||""}|${o}`:"";n.useEffect(()=>{if(!q){b("");return}let P=!1;return b(""),ar(pt()).then(ne=>{!P&&ne&&b(q)}).catch(()=>{}),()=>{P=!0}},[q]);const re=R&&d.status==="ready"&&z&&f===q?(()=>{const P=z.pathname||"/",ne=new URLSearchParams(z.search);ne.delete("oc_url_token"),ne.delete("oc_client_token"),ne.set("ocPreview",String(o)),ne.set("oc_preview_token",d.previewToken||"");const oe=ne.toString(),l=z.hash||"";return ir().authenticatedAsset(`${d.proxyBasePath}${P}${oe?`?${oe}`:""}${l}`)})():"",ie=R?re:T,me=R?Ao(re):T,Ce=R&&(d.status==="loading"||d.status==="idle"||f!==q),fe=R&&d.status==="error",ge=n.useCallback(P=>{const ne=y??(W?"draft":null);if(!ne||!Y){he.error("Open a chat session before attaching preview annotations");return}const oe=t||ie||"",l=typeof window<"u"?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},g=typeof window<"u"?window.devicePixelRatio:1;(async()=>{let ee=!1;try{const de=p.current,Pe=de?await Nr(de,P):null;Pe&&(await B(Pe),ee=!0)}catch{ee=!1}K({directory:Y,sessionKey:ne},{source:"preview-annotation",fileLabel:oe||"preview",startLine:1,endLine:1,code:Tt({pageUrl:oe,viewport:l,devicePixelRatio:g,target:P,screenshotAttached:ee,intro:"This is a selected DOM element from the in-app preview."}),language:"markdown",text:""}),he.success("Preview annotation attached to chat")})()},[B,K,y,Y,ie,W,t]);n.useEffect(()=>{c(!1),te([]),S(!1),A("all"),F(!1),L(null),i.current=1},[ie]),n.useEffect(()=>{const P=p.current?.contentWindow;!N||!P||er(P,re,{source:"pichamber-preview-parent",version:1,type:"set-inspect-mode",enabled:Q})},[N,Q,re]),n.useEffect(()=>{const P=p.current?.contentWindow;!N||!P||er(P,re,{source:"pichamber-preview-parent",version:1,type:"set-color-scheme",scheme:G})},[N,G,re]),n.useEffect(()=>{if(!Q||typeof window>"u")return;const P=ne=>{ne.key==="Escape"&&(ne.preventDefault(),ne.stopImmediatePropagation(),F(!1))};return window.addEventListener("keydown",P,!0),()=>window.removeEventListener("keydown",P,!0)},[Q]),n.useEffect(()=>{if(!R||typeof window>"u")return;const P=l=>{if(typeof l=="string")return l;if(l==null)return"";try{return JSON.stringify(l)}catch{return String(l)}},ne=l=>{const g=i.current;i.current+=1,te(ee=>{const de=[...ee,{...l,id:g}];return de.length>qt?de.slice(de.length-qt):de})},oe=l=>{if(l.source!==p.current?.contentWindow)return;const g=l.data;if(!(!g||g.source!=="pichamber-preview-bridge"||g.version!==1)){if(g.type==="ready"){c(!0);return}if(g.type==="console"){const ee=g.level==="error"||g.level==="warn"||g.level==="info"||g.level==="debug"?g.level:"log",de=Array.isArray(g.args)?g.args.map(P).filter(Boolean):[];ne({level:ee,message:de.join(" "),ts:typeof g.ts=="number"?g.ts:Date.now()});return}if(g.type==="runtime-error"){const ee=P(g.filename),de=typeof g.line=="number"?g.line:null,Pe=typeof g.column=="number"?g.column:null,x=ee?`${ee}${de!==null?`:${de}${Pe!==null?`:${Pe}`:""}`:""}`:"",_=P(g.stack);ne({level:"runtime",message:P(g.message)||"Runtime error",details:[x,_].filter(Boolean).join(`
127
+ `),ts:typeof g.ts=="number"?g.ts:Date.now()});return}if(g.type==="resource-error"){const ee=P(g.tag)||"resource",de=P(g.url);ne({level:"resource",message:de?`${ee}: ${de}`:ee,details:P(g.outerHTML),ts:typeof g.ts=="number"?g.ts:Date.now()});return}if(g.type==="hover"){L(Ve(g.target)?g.target:null);return}if(g.type==="select"&&Ve(g.target)){L(g.target),F(!1),ge(g.target);return}if(g.type==="navigate-preview"){const ee=typeof g.url=="string"?g.url:"",de=g.navigation==="external"?"external":"proxy";if(ee&&de==="external"){at(ee);return}ee&&r(ee)}}};return window.addEventListener("message",oe),()=>{window.removeEventListener("message",oe)}},[ge,R,r]);const ce=O.filter(P=>P.level==="error"||P.level==="runtime"||P.level==="resource").length,je=O.filter(P=>jo(P,D)),Ne=n.useCallback(()=>{const P=[`Preview URL: ${t||ie||""}`,`Events: ${O.length}`,""].join(`
128
+ `),ne=O.map(oe=>{const l=new Date(oe.ts).toISOString(),g=oe.details?`
129
+ ${oe.details}`:"";return`[${l}] [${oe.level}] ${oe.message}${g}`}).join(`
130
+ `);xt(`${P}${ne}`).then(oe=>{oe.ok?he.success("Preview console copied"):he.error("Failed to copy preview console")})},[O,ie,t]),u=n.useCallback(()=>{const P=y??(W?"draft":null);if(!P||!Y){he.error("Open a chat session before attaching preview logs");return}const ne=[`Preview URL: ${t||ie||""}`,`Events: ${O.length}`,""].join(`
131
+ `),oe=O.map(l=>{const g=new Date(l.ts).toISOString(),ee=l.details?`
132
+ ${l.details}`:"";return`[${g}] [${l.level}] ${l.message}${ee}`}).join(`
133
+ `);K({directory:Y,sessionKey:P},{source:"preview-console",fileLabel:t||ie||"preview",startLine:1,endLine:Math.max(1,O.length),code:`${ne}${oe}`,language:"text",text:"These are browser console logs from the dev server running for this project."}),he.success("Preview console attached to chat")},[K,O,y,Y,ie,W,t]),[k,I]=n.useState("unknown"),H=n.useRef(0),J=n.useRef(0),ue=n.useRef(""),se=n.useRef(""),be=15e3;n.useEffect(()=>{if(!re){I("unknown"),ue.current="",H.current=0,J.current=0;return}let P=!1,ne=null;ue.current!==E&&(ue.current=E,H.current=Date.now(),J.current=0);const oe=l=>{ne=setTimeout(()=>{P||a()},l)};return I("unknown"),(async()=>{const g=await(async()=>{try{return await ot(re,{method:"GET",credentials:"include",cache:"no-store",redirect:"manual"})}catch{return null}})();if(P)return;if(!g){I("unreachable"),oe(5e3);return}const ee=Js(g.headers,se.current===E);if(ee!=="none"){if(Re.delete(E),ee==="retry-registration")se.current=E,m({status:"loading"}),w();else{const x=await g.json().catch(()=>({}));if(P)return;const _=typeof x?.error=="string"?x.error:`HTTP ${g.status}`;m({status:"error",message:_})}return}if(g.status!==502){se.current="",I("reachable");return}const de=H.current||Date.now();if(Date.now()-de<be){I("starting"),J.current+=1;const x=J.current,_=Math.min(2e3,250*Math.pow(2,Math.min(4,x)));oe(_);return}I("unreachable"),oe(5e3)})(),()=>{P=!0,ne&&clearTimeout(ne)}},[E,re,o]);const xe=R&&d.status==="ready"&&(k==="unknown"||k==="starting"),j=R&&d.status==="ready"&&k==="unreachable",ye=n.useCallback(P=>{if(!R||d.status!=="ready"||typeof window>"u")return;const ne=P.currentTarget.contentWindow;if(ne)try{const oe=ne.location,l=Ir(re);if(oe.origin!==l||oe.pathname.startsWith(d.proxyBasePath))return;const g=`${d.proxyBasePath}${oe.pathname}${oe.search}${oe.hash}`;ne.location.replace(g)}catch{}},[R,re,d]);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:me||t,children:me||t||"No preview URL"}),e.jsx(pe,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>a(),title:"Reload preview","aria-label":"Reload preview",disabled:!ie,children:e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{T&&at(T)},title:"Open in browser","aria-label":"Open in browser",disabled:!T,children:e.jsx(U,{name:"external-link",className:"h-3.5 w-3.5"})}),R?e.jsx(pe,{type:"button",size:"sm",variant:Q?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>F(P=>!P),title:"Inspect preview element","aria-label":"Inspect preview element",disabled:!N,children:e.jsx(U,{name:"cursor",className:"h-3.5 w-3.5"})}):null,R?e.jsxs(pe,{type:"button",size:"sm",variant:C?"secondary":"ghost",className:"h-7 gap-1 px-2",onClick:()=>S(P=>!P),title:N?"Open preview console":"Waiting for preview console","aria-label":N?"Open preview console":"Waiting for preview console",disabled:!N&&O.length===0,children:[e.jsx(U,{name:"terminal-box",className:"h-3.5 w-3.5"}),ce>0?e.jsx("span",{className:"typography-micro text-status-error",children:ce}):null]}):null]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[xe?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(pe,{type:"button",size:"sm",variant:"outline",onClick:()=>a(),children:"Retry"})]}):ie&&(!R||k==="reachable")?e.jsxs("div",{className:"relative h-full w-full",children:[e.jsx("iframe",{ref:p,src:ie,title:"Preview",className:"h-full w-full border-0",style:{colorScheme:G},onLoad:ye,sandbox:R?"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads":"allow-scripts allow-forms"},`${ie}:${o}`),Q&&M?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:M.bounds.x,top:M.bounds.y,width:M.bounds.width,height:M.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:[M.tag,M.text?` · ${M.text}`:""]})}):null]}):Ce?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-sm text-muted-foreground",children:"Connecting preview proxy..."}):fe?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."}),d.status==="error"?e.jsx("div",{className:"text-center text-xs opacity-70",children:d.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."}),C?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(pe,{type:"button",size:"xs",variant:"ghost",onClick:u,disabled:O.length===0,children:"Attach"}),e.jsx(pe,{type:"button",size:"xs",variant:"ghost",onClick:Ne,disabled:O.length===0,children:"Copy"}),e.jsx(pe,{type:"button",size:"xs",variant:"ghost",onClick:()=>te([]),disabled:O.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(P=>e.jsx(pe,{type:"button",size:"xs",variant:D===P?"secondary":"ghost",onClick:()=>A(P),children:P==="all"?"All":P==="errors"?"Errors":P==="warnings"?"Warnings":"Logs"},P))}),e.jsx("div",{className:"max-h-64 overflow-auto p-2 typography-code text-xs",children:O.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(P=>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:ve("shrink-0 uppercase",P.level==="error"||P.level==="runtime"||P.level==="resource"?"text-status-error":P.level==="warn"?"text-status-warning":"text-muted-foreground"),children:P.level}),e.jsx("span",{className:"min-w-0 break-words text-foreground",children:P.message})]})},P.id))})]}):null]})]})},Io=()=>typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,Lo=({initialUrl:t,directory:r,tabID:s})=>{const o=n.useRef(null),a=Z(u=>u.setContextPanelTabTargetPath),h=Qe(t),w=h!=="about:blank"?h:"",[d,m]=n.useState(w),[f,b]=n.useState(w),[p,i]=n.useState(w),[N,c]=n.useState(()=>w?[w]:[]),[C,S]=n.useState(()=>w?0:-1),[D,A]=n.useReducer(u=>u+1,0),[O,te]=n.useState(!!w),[Q,F]=n.useState(!1),[M,L]=n.useState(null),[y,W]=n.useState({status:"idle"}),[Y,K]=n.useState(""),B=Ee(u=>u.currentSessionId),X=Ee(u=>u.newSessionDraft?.open),R=Nt(u=>u.addDraft),z=kt(u=>u.addAttachedFile),v=n.useCallback(u=>{!u||u==="about:blank"||!r||!s||a(r,s,u)},[r,s,a]),E=n.useCallback((u,k)=>{const I=Qe(u),H=I!=="about:blank"?I:"";b(H),m(H),k?.inFrame?te(!1):(i(H),te(!!H)),v(H),c(J=>{if(!H)return S(-1),[];if(k?.replaceHistory)return J;const ue=C>=0?J.slice(0,C+1):[];if(ue[ue.length-1]===H)return S(ue.length-1),ue;const be=[...ue,H];return S(be.length-1),be})},[C,v]),G=n.useCallback(u=>{const k=N[u];k&&(S(u),b(k),i(k),m(k),te(!0),v(k))},[N,v]),T=n.useCallback(()=>{if(f){te(!0);try{o.current?.contentWindow?.location.reload()}catch{A()}}},[f]);n.useEffect(()=>{if(!p){W({status:"idle"});return}const u=eo(p),k=_t(u);if(k?.previewToken){W({status:"ready",proxyBasePath:k.proxyBasePath,previewToken:k.previewToken,expiresAt:k.expiresAt});return}k&&Re.delete(u);let I=!1;return W({status:"loading"}),te(!0),(async()=>{try{const H=await ot("/api/preview/targets",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:p,allowExternal:!0})});if(!H.ok){const xe=await H.json().catch(()=>({})),j=typeof xe?.error=="string"?xe.error:`HTTP ${H.status}`;I||W({status:"error",message:j});return}const J=await H.json(),ue=typeof J.proxyBasePath=="string"?J.proxyBasePath:"",se=typeof J.previewToken=="string"?J.previewToken:"",be=typeof J.expiresAt=="number"?J.expiresAt:0;if(!ue||!se){I||W({status:"error",message:"Could not start preview proxy."});return}Re.set(u,{proxyBasePath:ue,previewToken:se,expiresAt:be}),I||W({status:"ready",proxyBasePath:ue,previewToken:se,expiresAt:be})}catch(H){if(!I){const J=H instanceof Error?H.message:String(H);W({status:"error",message:J})}}})(),()=>{I=!0}},[p]);const q=p&&y.status==="ready"?`${y.proxyBasePath}|${y.previewToken||""}|${D}`:"";n.useEffect(()=>{if(!q){K("");return}let u=!1;return K(""),ar(pt()).then(k=>{!u&&k&&K(q)}).catch(()=>{}),()=>{u=!0}},[q]);const re=n.useMemo(()=>{if(Y!==q||!p||y.status!=="ready")return"";try{const u=new URL(p),k=u.pathname||"/",I=new URLSearchParams(u.search);I.delete("oc_url_token"),I.delete("oc_client_token"),I.set("ocPreview",String(D)),I.set("oc_preview_token",y.previewToken||"");const H=I.toString();return ir().authenticatedAsset(`${y.proxyBasePath}${k}${H?`?${H}`:""}${u.hash}`)}catch{return""}},[p,y,q,D,Y]),ie=re||(y.status==="error"?p:""),me=n.useCallback(u=>{if(!u||!p||y.status!=="ready")return"";try{const k=new URL(u,window.location.origin),I=y.proxyBasePath.endsWith("/")?y.proxyBasePath.slice(0,-1):y.proxyBasePath;if(k.origin!==window.location.origin||!k.pathname.startsWith(I))return"";const H=k.pathname.slice(I.length)||"/",J=new URL(p).origin;return tr(new URL(`${H}${k.search}${k.hash}`,J).toString())}catch{return""}},[p,y]),Ce=n.useCallback(u=>{if(!u||!p||y.status!=="ready")return"";try{const k=new URL(u,window.location.origin),I=new URL(p).origin;if(k.origin!==window.location.origin||I===window.location.origin)return"";const H=y.proxyBasePath.endsWith("/")?y.proxyBasePath.slice(0,-1):y.proxyBasePath;return k.pathname.startsWith(H)?"":tr(new URL(`${k.pathname}${k.search}${k.hash}`,I).toString())}catch{return""}},[p,y]),fe=n.useCallback(u=>{const k=o.current?.contentWindow;k&&k.postMessage({source:"pichamber-preview-parent",version:1,type:"set-inspect-mode",enabled:u},window.location.origin)},[]),ge=n.useCallback(async u=>{const k=B??(X?"draft":null);if(!k){he.error("Open a chat session before attaching preview annotations");return}const I=o.current,H=I?.contentWindow,J=I?.getBoundingClientRect(),ue={width:Number.isFinite(H?.innerWidth)?H?.innerWidth??J?.width??0:J?.width??0,height:Number.isFinite(H?.innerHeight)?H?.innerHeight??J?.height??0:J?.height??0},se=I?await Nr(I,u):null,be=!!se;se&&await z(se),R({directory:r,sessionKey:k},{source:"preview-annotation",fileLabel:f||"browser",startLine:1,endLine:1,code:Tt({pageUrl:f,viewport:ue,devicePixelRatio:window.devicePixelRatio||1,target:u,screenshotAttached:be,intro:be?"This is a selected DOM element from the in-app preview. A screenshot of the visible preview area with the selected element highlighted is attached.":"This is a selected DOM element from the in-app preview."}),language:"markdown",text:""}),he.success("Preview annotation attached to chat")},[z,R,B,f,r,X]),ce=n.useCallback(()=>{const u=o.current;L(null),fe(!1),u&&Zt(u,st).catch(()=>{})},[fe]);n.useEffect(()=>{if(!Q)return;const u=k=>{k.key==="Escape"&&(k.preventDefault(),k.stopImmediatePropagation(),F(!1),ce())};return window.addEventListener("keydown",u,!0),()=>window.removeEventListener("keydown",u,!0)},[ce,Q]),n.useEffect(()=>()=>ce(),[ce]),n.useEffect(()=>{const u=k=>{if(k.source!==o.current?.contentWindow)return;const I=k.data;if(!(!I||I.source!=="pichamber-preview-bridge"||I.version!==1)){if(I.type==="ready"){const H=typeof I.url=="string"?I.url:"",J=me(H);J&&J!==f&&E(J,{inFrame:!0});return}if(I.type==="hover"){L(Ve(I.target)?I.target:null);return}if(I.type==="select"&&Ve(I.target)){L(null),F(!1),fe(!1),ge(I.target);return}if(I.type==="navigate-preview"){const H=typeof I.url=="string"?I.url:"",J=Ce(H);if(J){E(J);return}H&&E(H)}}};return window.addEventListener("message",u),()=>window.removeEventListener("message",u)},[E,ge,f,me,Ce,fe]);const je=n.useCallback(()=>{const u=o.current;if(!(!u||!f)){if(Q){F(!1),ce();return}if(re){L(null),F(!0),fe(!0);return}F(!0),(async()=>{try{const k=await Zt(u,Mr);if(F(!1),!k||!Ve(k))return;await ge(k)}catch{F(!1),he.error("This page cannot be inspected from the browser panel.")}})()}},[ge,ce,f,Q,fe,re]),Ne=n.useCallback(()=>{try{const u=o.current?.contentWindow?.location.href||"",k=Ce(u);if(k){E(k,{inFrame:!0});return}}catch{}te(!1),Q&&re&&fe(!0)},[E,Ce,Q,fe,re]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",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(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:C<=0,onClick:()=>G(C-1),children:e.jsx(U,{name:"arrow-left",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:C<0||C>=N.length-1,onClick:()=>G(C+1),children:e.jsx(U,{name:"arrow-right",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!f,onClick:T,children:e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx("form",{className:"min-w-0 flex-1",onSubmit:u=>{u.preventDefault(),E(d)},children:e.jsx("input",{value:d,onChange:u=>m(u.target.value),className:"h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]","aria-label":"Browser address"})}),e.jsx(pe,{type:"button",variant:Q?"secondary":"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!f,onClick:je,title:"Inspect preview element","aria-label":"Inspect preview element",children:e.jsx(U,{name:"cursor",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",disabled:!f,onClick:()=>{at(f)},children:e.jsx(U,{name:"external-link",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[ie?e.jsxs("div",{className:"absolute inset-0",children:[e.jsx("iframe",{ref:o,src:ie,title:"Web browser",className:"absolute inset-0 h-full w-full border-0 bg-background",allow:"clipboard-read; clipboard-write; fullscreen",allowFullScreen:!0,onLoad:Ne},`${s}:${D}`),Q&&M?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:M.bounds.x,top:M.bounds.y,width:M.bounds.width,height:M.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:[M.tag,M.text?` · ${M.text}`:""]})}):null]}):e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center",children:[e.jsx(xr,{width:140,height:140,className:"opacity-20"}),e.jsx("span",{className:"typography-ui-header text-muted-foreground",children:"Web browser"}),e.jsx("span",{className:"max-w-sm typography-micro text-muted-foreground",children:"Enter an address above to start browsing the web"}),e.jsx("span",{className:"max-w-md typography-micro leading-relaxed text-status-warning/70",children:"Pages opened here run with full access to PiChamber — needed for inspect and screenshots. Only open sites you trust: a malicious page could read your data or act on your behalf."})]}),O?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground",children:"Loading..."}):null]})]})},$o=({initialUrl:t,directory:r,tabID:s})=>{const o=n.useRef(null),a=Z(y=>y.setContextPanelTabTargetPath),h=Qe(t),w=h!=="about:blank"?h:"",d=n.useRef(Qe(t)),[m,f]=n.useState(w),[b,p]=n.useState(w),[i,N]=n.useState(!1),[c,C]=n.useState(!0),S=n.useRef(null),D=c,A=n.useCallback(y=>{!y||y==="about:blank"||!r||!s||a(r,s,y)},[r,s,a]),O=Ee(y=>y.currentSessionId),te=Ee(y=>y.newSessionDraft?.open),Q=Nt(y=>y.addDraft),F=kt(y=>y.addAttachedFile);n.useEffect(()=>{const y=o.current;if(!y)return;const W=()=>{try{const z=y.getURL();z&&z!=="about:blank"&&(p(z),f(z),A(z))}catch{}},Y=z=>{const v=z.detail;typeof v?.url=="string"&&v.url&&(p(v.url),f(v.url),A(v.url))},K=()=>{S.current&&clearTimeout(S.current),S.current=setTimeout(()=>C(!0),200)},B=()=>{S.current&&clearTimeout(S.current),C(!1),W()},X=z=>{const v=z.detail;if(v?.disposition==="new-window"||v?.disposition==="foreground-tab"||v?.disposition==="background-tab"){z.preventDefault();const E=o.current;typeof E?.loadURL=="function"&&v.url&&E.loadURL(v.url)}},R=()=>{try{y.executeJavaScript?.(Do,!0).catch(()=>{})}catch{}};y.addEventListener("did-navigate",Y),y.addEventListener("did-navigate-in-page",Y),y.addEventListener("did-start-loading",K),y.addEventListener("did-stop-loading",B),y.addEventListener("new-window",X),y.addEventListener("dom-ready",R);try{y.isLoading()||(C(!1),W())}catch{}return R(),()=>{S.current&&clearTimeout(S.current),y.removeEventListener("did-navigate",Y),y.removeEventListener("did-navigate-in-page",Y),y.removeEventListener("did-start-loading",K),y.removeEventListener("did-stop-loading",B),y.removeEventListener("new-window",X),y.removeEventListener("dom-ready",R)}},[A]),n.useEffect(()=>{const y=setTimeout(()=>C(!1),3e4);return()=>clearTimeout(y)},[]),n.useEffect(()=>{if(!i)return;const y=W=>{if(W.key!=="Escape")return;W.preventDefault(),W.stopImmediatePropagation(),N(!1);const Y=o.current;try{Y?.executeJavaScript?.(st).catch(()=>{})}catch{}};return window.addEventListener("keydown",y,!0),()=>window.removeEventListener("keydown",y,!0)},[i]),n.useEffect(()=>{const y=o.current;return()=>{try{const W=y?.getURL?.();W&&W!=="about:blank"&&a(r,s,W)}catch{}try{y?.executeJavaScript?.(st).catch(()=>{})}catch{}}},[r,s,a]);const M=n.useCallback(y=>{const W=o.current;if(typeof W?.loadURL!="function")return;const Y=Qe(y);try{W.loadURL(Y)}catch{}},[]),L=n.useCallback(()=>{const y=o.current;if(y){if(i){N(!1);try{y.executeJavaScript?.(st).catch(()=>{})}catch{}return}N(!0),y.executeJavaScript?.(Mr,!0).then(async W=>{if(N(!1),!W||!Ve(W))return;const Y=O??(te?"draft":null);if(!Y){he.error("Open a chat session before attaching preview annotations");return}const K=typeof y.getWebContentsId=="function"?y.getWebContentsId():null;if(K==null)return;const B=await En("desktop_browser_capture_page",{webContentsId:K}),X=await y.executeJavaScript?.("({ width: window.innerWidth, height: window.innerHeight })",!0).catch(()=>null),R=Number.isFinite(X?.width)?X.width:B.width,z=Number.isFinite(X?.height)?X.height:B.height,v=await Dt(B.base64,B.width,B.height,R,z,W),E=!!v;v&&await F(v),Q({directory:r,sessionKey:Y},{source:"preview-annotation",fileLabel:b||"browser",startLine:1,endLine:1,code:Tt({pageUrl:b,viewport:{width:R,height:z},devicePixelRatio:window.devicePixelRatio||1,target:W,screenshotAttached:E,intro:"This is a selected DOM element from the in-app preview. A screenshot of the visible preview area with the selected element highlighted is attached."}),language:"markdown",text:""}),he.success("Preview annotation attached to chat")}).catch(()=>N(!1))}},[F,Q,O,b,r,i,te]);return e.jsxs("div",{className:"absolute inset-0 flex flex-col bg-background",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(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{o.current?.goBack?.()}catch{}},children:e.jsx(U,{name:"arrow-left",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{o.current?.goForward?.()}catch{}},children:e.jsx(U,{name:"arrow-right",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{try{o.current?.reload?.()}catch{}},children:e.jsx(U,{name:"refresh",className:"h-3.5 w-3.5"})}),e.jsx("form",{className:"min-w-0 flex-1",onSubmit:y=>{y.preventDefault(),M(m)},children:e.jsx("input",{value:m,onChange:y=>f(y.target.value),className:"h-7 w-full rounded-md border border-border/50 bg-[var(--surface-elevated)] px-2 typography-micro text-foreground outline-none focus:border-[var(--interactive-focus-ring)]","aria-label":"Browser address"})}),e.jsx(pe,{type:"button",variant:i?"secondary":"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:L,title:"Inspect preview element","aria-label":"Inspect preview element",children:e.jsx(U,{name:"cursor",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:()=>{at(b)},children:e.jsx(U,{name:"external-link",className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"relative min-h-0 flex-1 bg-background",children:[e.jsx("webview",{ref:o,src:d.current,partition:"persist:pichamber-browser",allowpopups:!0,style:{width:"100%",height:"100%",border:"none"}}),(!b||b==="about:blank")&&!c?e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-6 bg-background p-6 text-center",children:[e.jsx(xr,{width:140,height:140,className:"opacity-20"}),e.jsx("span",{className:"typography-ui-header text-muted-foreground",children:"Web browser"})]}):null,D?e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/70 typography-micro text-muted-foreground",children:"Loading..."}):null]})]})},Oo=()=>{const t=Ze()??"",r=n.useMemo(()=>So(t),[t]),s=Z(j=>r?j.contextPanelByDirectory[r]:void 0),o=Z(j=>j.closeContextPanel),a=Z(j=>j.closeContextPanelTab),h=Z(j=>j.openContextPanelTab),w=Z(j=>j.toggleContextPanelExpanded),d=Z(j=>j.setContextPanelWidth),m=Z(j=>j.setActiveContextPanelTab),f=Z(j=>j.reorderContextPanelTabs),b=Ie(j=>j.setSelectedPath),p=Z(j=>j.openContextPreview),i=Z(j=>j.contextEditorTreeVisible),N=Z(j=>j.toggleContextEditorTree),c=n.useMemo(()=>s?.tabs??[],[s?.tabs]),C=c.find(j=>j.id===s?.activeTabId)??c[c.length-1]??null,S=!!(s?.isOpen&&C),D=!!(S&&s?.expanded),[A,O]=n.useState(null),te=s?.width,Q=Tn,F=A??(typeof window<"u"?window.innerWidth:_r*2),M=Jt(te??Math.round(Q*F)),L=gr(r||null),[y,W]=n.useState(!1),Y=n.useRef(0),K=n.useRef(M),B=n.useRef(null),X=n.useRef(null),R=n.useRef(null),z=n.useRef(!1);n.useLayoutEffect(()=>{const j=R.current?.parentElement;if(!j||typeof ResizeObserver>"u")return;const ye=new ResizeObserver(()=>{O(j.clientWidth||null)});return ye.observe(j),O(j.clientWidth||null),()=>ye.disconnect()},[]),n.useEffect(()=>{if(!S||z.current){z.current=S;return}const j=window.requestAnimationFrame(()=>{R.current?.focus({preventScroll:!0})});return z.current=!0,()=>window.cancelAnimationFrame(j)},[S]);const v=n.useRef(null),E=n.useRef(null),G=n.useCallback(()=>{E.current=null;const j=R.current,ye=B.current;!j||ye===null||j.style.setProperty("--oc-context-panel-width",`${ye}px`)},[]);n.useEffect(()=>()=>{E.current!==null&&clearTimeout(E.current)},[]);const T=n.useCallback(j=>{const ye=Jt(j),P=v.current;return P===null?ye:Math.min(ye,Math.max(1,P))},[]),q=n.useCallback(j=>{!S||D||!r||(X.current=j.pointerId,W(!0),Y.current=j.clientX,K.current=M,B.current=M,v.current=Co(R.current),document.documentElement.style.cursor="col-resize",j.preventDefault())},[r,D,S,M]),re=n.useCallback(()=>{const j=T(B.current??M);B.current=null,v.current=null,E.current!==null&&(clearTimeout(E.current),E.current=null),document.documentElement.style.cursor="",r&&d(r,j),W(!1),X.current=null},[T,r,d,M]);n.useEffect(()=>{if(!y)return;const j=ne=>{if(X.current!==ne.pointerId)return;const oe=Y.current-ne.clientX,l=T(K.current+oe);B.current!==l&&(B.current=l,E.current===null&&(E.current=setTimeout(G,bo)))},ye=ne=>{X.current===ne.pointerId&&re()},P=()=>{re()};return window.addEventListener("pointermove",j),window.addEventListener("pointerup",ye),window.addEventListener("pointercancel",ye),window.addEventListener("blur",P),()=>{window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",ye),window.removeEventListener("pointercancel",ye),window.removeEventListener("blur",P)}},[G,T,re,y]),n.useEffect(()=>{y||(B.current=null,document.documentElement.style.cursor="")},[y]);const ie=n.useCallback(()=>{r&&o(r)},[o,r]),me=n.useCallback(()=>{r&&w(r)},[r,w]),Ce=n.useCallback(j=>{j.key==="Escape"&&(Pn(j.target)||(j.preventDefault(),j.stopPropagation(),ie()))},[ie]);n.useEffect(()=>{if(!(!r||!C)&&C.mode==="file"&&C.targetPath){b(r,C.targetPath,{allowOutsideRoot:!0});return}},[C,r,b]);const fe=n.useCallback(j=>{!r||C?.mode!=="diff"||h(r,{mode:"diff",targetPath:C.targetPath,stagedDiff:j==="staged",diffScope:j})},[C,r,h]),ge=C?.mode==="file"||C?.mode==="preview",ce=n.useMemo(()=>C?c.filter(j=>j.mode===C.mode):[],[C,c]),je=n.useMemo(()=>ce.map(j=>{const ye=Po(j,L),P=_o(ye,vo),ne=No(j.targetPath,t);return{id:j.id,label:P,icon:Qt(j,L),title:ne?`${ye}: ${ne}`:ye,closeLabel:`Close ${P} tab`}}),[ce,t,L]),Ne=C?.mode==="context"?e.jsx(Gs,{}):C?.mode==="git"?e.jsx(n.Suspense,{fallback:null,children:e.jsx(xo,{isActive:S})}):C?.mode==="notes"?e.jsx(cr,{}):C?.mode==="preview"?e.jsx(Mo,{rawUrl:C.targetPath??"",onNavigate:j=>p(t,j)}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(U,{name:"global",className:"h-12 w-12 text-muted-foreground/50"}),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."})]}),u=n.useMemo(()=>c.filter(j=>j.mode==="browser"),[c]),k=n.useMemo(()=>c.filter(j=>j.mode==="diff"),[c]),I=n.useMemo(()=>c.some(j=>j.mode==="terminal"),[c]),H=Io()?$o:Lo,J=n.useMemo(()=>c.some(j=>j.mode==="file"),[c]),ue=n.useMemo(()=>c.some(j=>j.mode==="file"&&j.targetPath),[c]),se=C?.mode==="file",be=e.jsxs("header",{className:"flex h-10 items-stretch border-b border-border",children:[ge?e.jsx(nn,{items:je,activeId:C?.id??null,onSelect:j=>{r&&m(r,j)},onClose:j=>{r&&a(r,j)},onReorder:(j,ye)=>{r&&f(r,j,ye)},layoutMode:"scrollable",variant:"default"}):e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 px-3",children:[C?Qt(C,L):null,e.jsx("span",{className:"truncate typography-ui-label text-foreground",children:C?Ar(C.mode,L):null})]}),e.jsxs("div",{className:"flex items-center gap-1 px-1.5",children:[se?e.jsx(pe,{type:"button",variant:"ghost",size:"sm",onClick:N,className:"h-7 w-7 p-0",title:"Toggle file tree","aria-label":"Toggle file tree","aria-pressed":i,children:e.jsx(U,{name:"layout-right",className:"h-3.5 w-3.5"})}):null,e.jsx(pe,{type:"button",variant:"ghost",size:"sm",onClick:me,className:"h-7 w-7 p-0",title:D?"Collapse panel":"Expand panel","aria-label":D?"Collapse panel":"Expand panel",children:D?e.jsx(U,{name:"fullscreen-exit",className:"h-3.5 w-3.5"}):e.jsx(U,{name:"fullscreen",className:"h-3.5 w-3.5"})}),e.jsx(pe,{type:"button",variant:"ghost",size:"sm",onClick:ie,className:"h-7 w-7 p-0",title:"Close panel","aria-label":"Close panel",children:e.jsx(U,{name:"close",className:"h-3.5 w-3.5"})})]})]}),xe=S?D?{"--oc-context-panel-width":A!==null?`${A}px`:"100%",width:A!==null?`${A}px`:"100%",maxWidth:"100%"}:{width:"min(var(--oc-context-panel-width), 100%)",maxWidth:"100%",overflowX:"clip","--oc-context-panel-width":`${M}px`}:{"--oc-context-panel-width":`${M}px`,width:0,maxWidth:"100%",overflowX:"clip"};return e.jsxs("aside",{ref:R,"data-context-panel":"true",tabIndex:-1,inert:!S||void 0,className:ve("flex min-h-0 flex-col overflow-hidden bg-background",D?"absolute inset-y-0 right-0 z-20 min-w-0":"relative h-full flex-shrink-0",!S&&"pointer-events-none","will-change-[width] motion-reduce:transition-none","transition-[width] duration-200 ease-[cubic-bezier(0.22,1,0.36,1)]"),onKeyDownCapture:Ce,style:xe,children:[S&&!D&&e.jsx("div",{"aria-hidden":"true",className:"absolute left-0 top-0 z-40 h-full w-px bg-border"}),S&&e.jsx("div",{"aria-hidden":"true",className:"absolute right-0 top-0 z-40 h-full w-px bg-border"}),!D&&e.jsx("div",{className:ve("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:q,role:"separator","aria-orientation":"vertical","aria-label":"Resize context panel"}),e.jsxs("div",{className:ve("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]",!S&&"pointer-events-none select-none opacity-0"),style:{width:D?A!==null?`${A}px`:"100%":"var(--oc-context-panel-width)"},"aria-hidden":!S,children:[be,e.jsxs("div",{className:ve("relative min-h-0 flex-1 overflow-hidden",y&&"pointer-events-none"),children:[J?e.jsxs("div",{className:ve("absolute inset-0 flex",se?"flex":"hidden"),children:[e.jsx("div",{className:"h-full min-w-0 flex-1",children:ue?e.jsx(n.Suspense,{fallback:null,children:e.jsx(go,{mode:"editor-only"})}):e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx(U,{name:"file-code",className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("div",{className:"typography-ui-header text-foreground",children:"No file open"}),e.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:"Pick a file from the tree to start editing."})]})}),e.jsx(To,{visible:i})]}):null,u.map(j=>e.jsx("div",{className:ve("absolute inset-0",C?.id!==j.id&&"hidden"),children:e.jsx(H,{initialUrl:j.targetPath??"",directory:r,tabID:j.id})},j.id)),S?k.filter(j=>C?.id===j.id).map(j=>e.jsx("div",{className:"absolute inset-0",children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(fo,{hideStackedFileSidebar:!0,stackedDefaultCollapsedAll:!0,pinSelectedFileHeaderToTopOnNavigate:!0,showOpenInEditorAction:!0,diffScope:j.diffScope??(j.stagedDiff?"staged":"working"),onDiffScopeChange:fe,targetFilePath:j.targetPath,flushContent:!0})})},j.id)):null,I?e.jsx("div",{className:ve("absolute inset-0",C?.mode==="terminal"?"block":"hidden"),children:e.jsx(dr,{visible:S&&C?.mode==="terminal"})}):null,S&&!se&&C?.mode!=="browser"&&C?.mode!=="diff"&&C?.mode!=="terminal"?Ne:null]})]})]})},Wo=150,Fo=500,Bo=[],Oe=t=>t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:String(t),tt=(t,r)=>{if(!t||typeof t!="object")return;const s=t[r];return typeof s=="number"&&Number.isFinite(s)?s:void 0},zo=t=>t>99?"99+":String(t),Uo=t=>t>=90?"text-[var(--status-error)]":t>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",Ho=({surface:t,isActive:r,showActivityDot:s,label:o,description:a,badgeCount:h,badgeAriaLabel:w,badgeDescription:d,orderNumber:m,showOrderNumber:f,onSelect:b,chartPercentage:p,chartDetails:i})=>{const{attributes:N,listeners:c,setNodeRef:C,transform:S,transition:D,isDragging:A}=ms({id:t.id}),O=h!=null&&h>0?zo(h):null;return e.jsx("div",{ref:C,style:{transform:fs.Translate.toString(S),transition:D},className:ve("relative",A&&"z-10 opacity-70"),children:e.jsxs(Be,{delayDuration:Wo,children:[e.jsx(ze,{asChild:!0,children:e.jsxs("button",{type:"button",...N,...c,onClick:()=>b(t),"aria-label":w??o,"aria-pressed":r,className:ve("flex h-9 w-9 touch-none select-none items-center justify-center rounded-md transition-colors",r?"text-primary":"text-muted-foreground hover:text-foreground"),children:[t.id==="context"&&typeof p=="number"?e.jsx(Wt,{percentage:p,className:"size-[18px] -rotate-90"}):e.jsx(U,{name:t.icon,className:"h-[18px] w-[18px]"}),f&&m!=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:m===10?"0":m}):O?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:O}):s?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(Ue,{side:"left",sideOffset:8,className:t.id==="context"&&i?"p-0 border-0 bg-transparent shadow-none":void 0,children:t.id==="context"&&i?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(Wt,{percentage:i.percentage,className:"size-[18px] -rotate-90"})}),e.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:o}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:i.hasData?e.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[e.jsxs("span",{className:ve("font-semibold",Uo(i.percentage)),children:[i.percentage.toFixed(1),"%"]}),e.jsx("span",{className:"text-muted-foreground",children:`${Oe(i.totalTokens)}/${Oe(i.contextLimit)}`})]}):e.jsx("span",{className:"typography-micro text-muted-foreground",children:"No data yet"})})]}),i.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:Oe(i.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:Oe(i.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:Oe(i.outputLimit)})]}),typeof i.cacheRead=="number"&&typeof i.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:Oe(i.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:Oe(i.cacheWrite)})]})]}):null,typeof i.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:`${i.cacheHitPercent.toFixed(1)}%`})]}):null]}):e.jsx("div",{className:"px-2.5 py-2 typography-micro text-muted-foreground",children:a})]})}):e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{children:o}),e.jsx("span",{className:"typography-micro text-muted-foreground",children:a}),d?e.jsx("span",{className:"typography-micro text-muted-foreground",children:d}):null]})})]})})},Vo=()=>{const t=Ze(),r=t?Ur(t):"",s=Z(u=>r?u.contextPanelByDirectory[r]:void 0),o=Z(u=>u.contextRailOrder),a=Z(u=>u.setContextRailOrder),h=Z(u=>u.openContextSurface),w=Z(u=>u.shortcutOverrides),{screenWidth:d}=Pt(),{git:m}=wt(),f=ur(r||null),b=gr(r||null),p=wr(u=>u.ensureStatus);n.useEffect(()=>{r&&p(r,m)},[r,p,m]);const i=n.useMemo(()=>Dn("switch_context_surface",w),[w]),[N,c]=n.useState(!1);n.useEffect(()=>{const u=new Set;let k=null,I=!1;const H=xe=>xe.length===1&&xe>="0"&&xe<="9",J=()=>{Ot(i,u)?!I&&k===null&&(k=setTimeout(()=>c(!0),Fo)):(I=!1,k!==null&&(clearTimeout(k),k=null),c(!1))},ue=xe=>{if(u.add(xe.key.toLowerCase()),H(xe.key)&&Ot(i,u)){I=!0,k!==null&&(clearTimeout(k),k=null),c(!1);return}J()},se=xe=>{u.delete(xe.key.toLowerCase()),J()},be=()=>{u.clear(),I=!1,k!==null&&(clearTimeout(k),k=null),c(!1)};return window.addEventListener("keydown",ue,!0),window.addEventListener("keyup",se,!0),window.addEventListener("blur",be),()=>{window.removeEventListener("keydown",ue,!0),window.removeEventListener("keyup",se,!0),window.removeEventListener("blur",be),k!==null&&clearTimeout(k)}},[i]);const C=as(Bt(ls,{activationConstraint:{distance:8}}),Bt(is,{activationConstraint:{delay:200,tolerance:6}})),S=s?.tabs??Bo,D=S.find(u=>u.id===s?.activeTabId)??null,A=s?.isOpen?D?.mode??null:null,O=f?.files.length??0,te=Ee(u=>u.currentSessionId),Q=Ee(u=>!!u.newSessionDraft?.open),F=We(u=>u.providers),M=We(u=>u.currentProviderId),L=We(u=>u.currentModelId),y=We(u=>u.getCurrentModel()),W=We(u=>u.getModelMetadata);We(u=>u.modelsMetadata.size);const Y=_n(n.useCallback(u=>te?u.sessionModelSelections.get(te)??null:null,[te])),K=pr(te??""),B=n.useMemo(()=>{for(let u=K.length-1;u>=0;u-=1){const k=K[u];if(k?.info.role==="assistant")try{if(mt(k).total>0)return k}catch{continue}}return null},[K]),R=n.useMemo(()=>{for(let u=K.length-1;u>=0;u-=1){const k=K[u]?.info;if(k.role!=="user")continue;const I=k.model,H=I?.providerID??I?.providerId,J=I?.modelID??I?.modelId;if(typeof H=="string"&&H.trim()&&typeof J=="string"&&J.trim())return{providerID:H,modelID:J}}return null},[K])??(()=>{const u=B?.info.model,k=u?.providerID??u?.providerId,I=u?.modelID??u?.modelId;return k&&I?{providerID:k,modelID:I}:null})()??(Y?{providerID:Y.providerId,modelID:Y.modelId}:null)??(M&&L?{providerID:M,modelID:L}:null),v=(R?F.find(u=>u.id===R.providerID):void 0)?.models.find(u=>u.id===R?.modelID),E=R?W(R.providerID,R.modelID):void 0,G=tt(v?.limit,"context")??E?.limit?.context??tt(y?.limit,"context")??0,T=tt(v?.limit,"output")??E?.limit?.output??tt(y?.limit,"output")??0,q=B?(()=>{try{return mt(B)}catch{return null}})():null,re=B?.info?.usage,ie=re?fr(re):q?.total??0,me=!Q&&ie>0&&G>0?Math.min(ie/G*100,999):0,Ce=me,fe=q?mr({input:q.input,cache:{read:q.cacheRead,write:q.cacheWrite}}):null,ge=fe?.hasInput?fe.percent:null,ce=n.useMemo(()=>{const u=!!B&&ie>0&&G>0;return{percentage:me,totalTokens:ie,contextLimit:G,outputLimit:T,cacheRead:q?.cacheRead??null,cacheWrite:q?.cacheWrite??null,cacheHitPercent:ge,hasData:u}},[q,ge,G,B,T,me,ie]),je=n.useMemo(()=>An({railOrder:o,tabs:S}),[o,d,S]),Ne=n.useCallback(u=>{const{active:k,over:I}=u;if(!I||k.id===I.id)return;const H=Mn(Z.getState().contextRailOrder).map(se=>se.id),J=H.indexOf(k.id),ue=H.indexOf(I.id);J===-1||ue===-1||a(us(H,J,ue))},[a]);return r?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(cs,{sensors:C,collisionDetection:ds,onDragEnd:Ne,children:e.jsx(hs,{items:je.map(u=>u.id),strategy:ps,children:je.map((u,k)=>{const I=u.id==="git"?Ct(b):null,H=I?{...u,...I}:u,J=H.label,ue=u.id==="git"&&b===!0?O:0,se=ue>0?ue:null,be=u.id==="context";return e.jsx(Ho,{surface:H,isActive:A===u.mode,showActivityDot:!1,label:J,description:H.description,badgeCount:se,badgeAriaLabel:se!==null?se===1?`${J}, ${se} changed file`:`${J}, ${se} changed files`:null,badgeDescription:se!==null?se===1?`${se} changed file`:`${se} changed files`:null,chartPercentage:be?Ce:void 0,chartDetails:be?ce:void 0,orderNumber:k+1,showOrderNumber:N,onSelect:xe=>h(r,xe.mode)},u.id)})})})}):null},Ko=(t,r)=>!t||r.length===0?"":JSON.stringify([t,r]),Xo=(t,r,s,o)=>!s||o!==s||t.length===0?[]:qe(t,r,a=>a.name,{limit:10,threshold:.4}),Go=new Set,ht=t=>{if(!t)return"";const r=t.replace(/\\/g,"/"),s=r.startsWith("//");let o=r.replace(/\/+/g,"/");s&&!o.startsWith("//")&&(o=`/${o}`);const a=o==="/",h=/^[A-Za-z]:\/$/.test(o);return!a&&!h&&(o=o.replace(/\/+$/,"")),o},Yo=()=>{const t=Z(l=>l.isCommandPaletteOpen),r=Z(l=>l.setCommandPaletteOpen),s=Z(l=>l.setActiveMainTab),o=Z(l=>l.setSettingsDialogOpen),a=Z(l=>l.setSettingsPage),h=Z(l=>l.setSessionSwitcherOpen),w=Z(l=>l.toggleSidebar),d=Z(l=>l.openContextOverview),m=Z(l=>l.openContextSurface),f=Z(l=>l.openContextFile),b=Z(l=>l.shortcutOverrides),p=Ee(l=>l.openNewSessionDraft),i=Ee(l=>l.setCurrentSession),N=In({archived:!1}),c=Ln(n.useCallback(l=>t?l.ids:Go,[t])),C=$n(n.useCallback(l=>t?l.rankById:On,[t])),S=Hr(l=>l.currentDirectory),D=Ft(l=>l.getActiveProject()),A=Ft(l=>l.projects),O=Ze(),te=sr(l=>l.searchFiles),{files:Q,git:F}=wt(),M=wr(l=>l.ensureStatus),{isMobile:L}=Pt(),y=n.useMemo(()=>O?ht(O):null,[O]),[W,Y]=n.useState(""),B=hr(W,200).trim(),X=W.trim();n.useEffect(()=>{t&&Y("")},[t]),n.useEffect(()=>{if(!t||!F)return;const l=setTimeout(()=>{const g=new Set;for(const ee of N){const de=it(ee);!de||g.has(de)||(g.add(de),M(de,F))}},0);return()=>clearTimeout(l)},[t,N,F,M]);const R=n.useCallback(()=>r(!1),[r]),z=n.useCallback(l=>()=>{R(),l()},[R]),v=n.useMemo(()=>{const l=[{id:"new-session",title:"New Session",icon:e.jsx(U,{name:"add",className:"mr-2 h-4 w-4"}),shortcutId:"new_chat",searchText:"New Session",onSelect:z(()=>{s("chat"),h(!1),p()})},{id:"add-project",title:"Add Project",icon:e.jsx(U,{name:"folder-add",className:"mr-2 h-4 w-4"}),searchText:"Add Project",onSelect:z(()=>{Wn.requestDirectoryDialog()})},{id:"toggle-sidebar",title:L?"Show Session Switcher":"Toggle Sidebar",icon:e.jsx(U,{name:"layout-left",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_sidebar",searchText:L?"Show Session Switcher":"Toggle Sidebar",onSelect:z(()=>{if(L){const{isSessionSwitcherOpen:g}=Z.getState();h(!g)}else w()})},{id:"toggle-terminal",title:"Toggle Terminal",icon:e.jsx(U,{name:"terminal-box",className:"mr-2 h-4 w-4"}),shortcutId:"toggle_terminal",searchText:"Toggle Terminal",onSelect:z(()=>{S&&m(S,"terminal")})},{id:"context-usage",title:"Show Context Usage",icon:e.jsx(U,{name:"pie-chart",className:"mr-2 h-4 w-4"}),searchText:"Show Context Usage",onSelect:z(()=>{S&&d(S)})},{id:"open-settings",title:"Open Settings...",icon:e.jsx(U,{name:"settings-3",className:"mr-2 h-4 w-4"}),shortcutId:"open_settings",searchText:"Open Settings...",onSelect:z(()=>o(!0))}];return Vr()&&l.splice(1,0,{id:"new-mini-chat",title:"New Mini Chat Window",icon:e.jsx(U,{name:"window",className:"mr-2 h-4 w-4"}),shortcutId:"new_mini_chat",searchText:"New Mini Chat Window",onSelect:z(()=>{or("desktop_open_draft_mini_chat_window",{directory:ht(S||D?.path||""),projectId:D?.id??null}).catch(g=>{console.warn("[command-palette] failed to open draft mini chat window",g)})})}),l},[z,L,s,h,p,w,m,S,d,o,D?.id,D?.path]),E=n.useMemo(()=>{const l=Kr();return{isWeb:!l&&Xr(),isDesktop:l,isMobile:L}},[L]),G=n.useMemo(()=>on.filter(l=>l.slug!=="home").filter(l=>l.isAvailable?l.isAvailable(E):!0).map(l=>{const g=an(l.slug)??"settings-3",ee=(l.keywords??[]).join(" ");return{id:`settings:${l.slug}`,title:l.title,icon:e.jsx(U,{name:g,className:"mr-2 h-4 w-4"}),searchText:`${l.title} ${l.group} ${ee}`,onSelect:z(()=>{a(l.slug),o(!0)})}}),[E,z,a,o]),T=n.useMemo(()=>Fn(N,c,C),[N,c,C]),q=Bn(),re=n.useCallback((l,g)=>g&&q.get(g)?.trim()||null,[q]),[ie,me]=n.useState([]),[Ce,fe]=n.useState(""),ge=Ko(y,B);n.useEffect(()=>{if(!t){me([]),fe("");return}if(!ge){me([]),fe("");return}if(!y){me([]),fe("");return}let l=!1;return te(y,B,10,{type:"file"}).then(g=>{l||(me(g.map(ee=>({path:ht(ee.path),name:ee.name,relativePath:ee.relativePath}))),fe(ge))}).catch(()=>{l||(me([]),fe(ge))}),()=>{l=!0}},[t,y,B,ge,te]);const ce=X.length>0,je=n.useMemo(()=>ce?qe(v,X,l=>l.searchText,{limit:7,noFuzzy:!0}):v.map(l=>({item:l,score:0})),[v,X,ce]),Ne=n.useMemo(()=>ce?qe(G,X,l=>l.searchText,{limit:7,noFuzzy:!0}):[],[G,X,ce]),u=n.useMemo(()=>ce?qe(T,X,l=>l.title||"",{limit:7,threshold:.2}):T.slice(0,5).map(l=>({item:l,score:0})),[T,X,ce]),k=n.useMemo(()=>t?Xo(ie,B,ge,Ce):[],[t,ie,Ce,ge,B]),I=t&&ge.length>0&&Ce!==ge,H=n.useMemo(()=>{if(!ce)return[];const l=A.map(g=>({...g,displayName:g.label||g.path.split("/").pop()||g.path,searchText:`${g.label||""} ${g.path}`}));return qe(l,X,g=>g.searchText,{limit:7,threshold:.4})},[A,X,ce]),J=je.map(l=>l.item),ue=Ne.map(l=>l.item),se=u.map(l=>l.item),be=ce?k.map(l=>l.item):[],xe=ce?H.map(l=>l.item):[],j=n.useMemo(()=>{if(!ce)return["commands","sessions"];const l=ee=>ee.length?ee[0].score:1/0,g=[{key:"commands",score:l(je)},{key:"settings",score:l(Ne)},{key:"sessions",score:l(u)},{key:"files",score:l(k)},{key:"projects",score:l(H)}];return g.sort((ee,de)=>ee.score-de.score),g.map(ee=>ee.key)},[ce,je,Ne,u,k,H]),ye=n.useCallback(l=>{R(),i(l.id,it(l))},[R,i]),P=n.useCallback(async l=>{if(!y)return;const g=await vr(Q,l,{directory:y});if(!g.ok){he.error(jr(g.reason));return}f(y,l),R()},[y,Q,f,R]),ne=n.useCallback((l,g)=>{R(),p({selectedProjectId:l,directoryOverride:g})},[R,p]),oe=n.useCallback(l=>yr(br(l,b)),[b]);return e.jsxs(yt,{open:t,onOpenChange:r,children:[e.jsxs(vt,{className:"sr-only",children:[e.jsx(jt,{children:"Command Palette"}),e.jsx(St,{children:"Search files, sessions, and commands."})]}),e.jsx(bt,{className:"overflow-hidden p-0",showCloseButton:!0,children:e.jsxs(zn,{shouldFilter:!1,className:"[&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-4 [&_[cmdk-input-wrapper]_svg]:w-4 [&_[cmdk-input]]:h-8 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-1.5 [&_[cmdk-item]_svg]:h-4 [&_[cmdk-item]_svg]:w-4 [&_[cmdk-item]]:typography-meta",children:[e.jsx(Un,{value:W,onValueChange:Y,placeholder:"Search files, sessions, commands..."}),e.jsxs(Hn,{children:[e.jsx(Vn,{children:"No results found."}),j.map(l=>l==="commands"&&J.length>0?e.jsx(Xe,{children:J.map(g=>e.jsxs(Ge,{value:g.id,onSelect:g.onSelect,children:[g.icon,e.jsx("span",{children:g.title}),g.shortcutId?e.jsx(Kn,{children:oe(g.shortcutId)}):null]},g.id))},"commands"):l==="settings"&&ue.length>0?e.jsx(Xe,{children:ue.map(g=>e.jsxs(Ge,{value:g.id,onSelect:g.onSelect,children:[g.icon,e.jsx("span",{children:g.title})]},g.id))},"settings"):l==="sessions"&&se.length>0?e.jsx(Xe,{children:se.map(g=>{const ee=g.title||"Untitled Session",de=it(g),Pe=re(g.id,de);return e.jsxs(Ge,{value:`session:${g.id}`,onSelect:()=>ye(g),children:[e.jsx(U,{name:"chat-ai-3",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:ee}),Pe?e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-muted-foreground typography-meta",children:[e.jsx(U,{name:"git-branch",className:"h-3 w-3"}),e.jsx("span",{className:"truncate max-w-[160px]",children:Pe})]}):null]},g.id)})},"sessions"):l==="files"&&be.length>0?e.jsx(Xe,{children:be.map(g=>{const ee=Xn(g.relativePath||g.name,{maxLength:80});return e.jsxs(Ge,{value:`file:${g.path}`,onSelect:()=>{P(g.path)},children:[e.jsx(gt,{filePath:g.path,className:"mr-2 size-4 shrink-0"}),e.jsx("span",{className:"truncate","aria-label":g.relativePath,children:ee})]},`file:${g.path}`)})},"files"):l==="projects"&&xe.length>0?e.jsx(Xe,{children:xe.map(g=>{const ee=g.displayName;return e.jsxs(Ge,{value:`project:${g.id}`,onSelect:()=>ne(g.id,g.path),children:[e.jsx(U,{name:"folder",className:"mr-2 h-4 w-4"}),e.jsx("span",{className:"truncate",children:ee}),e.jsx("span",{className:"ml-auto inline-flex items-center text-muted-foreground typography-meta truncate max-w-[160px]",children:g.path})]},`project:${g.id}`)})},"projects"):null),I?e.jsx("div",{className:"px-3 py-2 typography-meta text-muted-foreground",children:"Searching files..."}):null]})]})})]})},rr=(t,r,s)=>Yn(t)?yr(br(t,s)):r,qo=()=>{const t=Z(h=>h.isHelpDialogOpen),r=Z(h=>h.setHelpDialogOpen),s=Z(h=>h.shortcutOverrides),o=Gn(),a=[{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 + ${o} + 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:"toggle_prompt_navigator",descriptionKey:"Toggle Prompt Navigator",icon:"list-unordered",keys:""},{id:"abort_run",descriptionKey:"Abort active run (double press)",icon:"close-circle",keys:""}]},{categoryKey:"Panels",items:[{id:"toggle_right_sidebar",descriptionKey:"helpDialog.item.toggleRightSidebar",icon:"layout-right",keys:""},{id:"open_right_sidebar_git",descriptionKey:"helpDialog.item.openRightSidebarGitTab",icon:"git-branch",keys:""},{id:"open_right_sidebar_files",descriptionKey:"helpDialog.item.openRightSidebarFilesTab",icon:"layout-right",keys:""},{id:"toggle_terminal",descriptionKey:"helpDialog.item.toggleTerminalDock",icon:"window",keys:""},{id:"toggle_terminal_expanded",descriptionKey:"helpDialog.item.toggleTerminalExpanded",icon:"window",keys:""},{keys:[`${o} + 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:"cycle_services_tab",descriptionKey:"helpDialog.item.cycleServicesTab",icon:"stack",keys:""},{id:"open_settings",descriptionKey:"Open Settings",icon:"settings-3",keys:""}]}];return e.jsx(yt,{open:t,onOpenChange:r,children:e.jsxs(bt,{className:"max-w-2xl w-[min(42rem,calc(100vw-1.5rem))] max-h-[calc(100dvh-2rem)] flex flex-col overflow-hidden",children:[e.jsxs(vt,{children:[e.jsxs(jt,{className:"flex items-center gap-2",children:[e.jsx(U,{name:"command",className:"h-5 w-5"}),"Keyboard Shortcuts"]}),e.jsx(St,{children:"Use these keyboard shortcuts to navigate PiChamber efficiently"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto mt-3 pr-1",children:[e.jsx("div",{className:"space-y-4",children:a.map(h=>e.jsxs("div",{children:[e.jsx("h3",{className:"typography-meta font-semibold text-muted-foreground uppercase tracking-wider mb-2",children:h.categoryKey}),e.jsx("div",{className:"space-y-1",children:h.items.map(w=>{const d=w.id?rr(w.id,Array.isArray(w.keys)?w.keys[0]:w.keys,s):Array.isArray(w.keys)?w.keys:w.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:[w.icon&&e.jsx(U,{name:w.icon,className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"typography-meta",children:w.descriptionKey})]}),e.jsx("div",{className:"flex items-center gap-1",children:(Array.isArray(d)?d:[d]).map((m,f)=>e.jsxs(n.Fragment,{children:[f>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:m})]},`${m}-${f}`))})]},w.id||w.descriptionKey)})})]},h.categoryKey))}),e.jsx("div",{className:"mt-4 p-2 bg-muted/30 rounded-xl",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(U,{name:"question",className:"h-3.5 w-3.5 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"typography-meta text-muted-foreground",children:[e.jsx("p",{className:"font-medium mb-1",children:"Pro Tips:"}),e.jsxs("ul",{className:"space-y-0.5 typography-meta",children:[e.jsxs("li",{children:["• ",`Use Command Palette (${rr("open_command_palette",`${o} P`,s)}) to quickly access all actions`]}),e.jsxs("li",{children:["• ","The 5 most recent sessions appear in the Command Palette"]}),e.jsxs("li",{children:["• ","Theme cycling remembers your preference across sessions"]})]})]})]})})]})]})})},Jo=n.createContext(null),Qo=({children:t,value:r})=>e.jsx(Jo.Provider,{value:r,children:t}),nr=Le(()=>Ae(()=>import("./GitView-BwNKqK0K.js"),__vite__mapDeps([127,8,1,2,6,3,4,5,7,9,10,11,12,13,14,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,128,115,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,114,116,117])).then(t=>({default:t.GitView}))),Zo=Le(()=>Ae(()=>import("./DiffView-vrxi5oWp.js"),__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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118])).then(t=>({default:t.DiffView}))),ea=Le(()=>Ae(()=>import("./FilesView-BD_h3EVr.js"),__vite__mapDeps([119,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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,120,121,122,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,123,124,116,117,125,126,114,115])).then(t=>({default:t.FilesView}))),ta=Le(()=>Ae(()=>import("./DiagramView-CK6R7taL.js"),__vite__mapDeps([129,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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,125,126])).then(t=>({default:t.DiagramView}))),ra=Le(()=>Ae(()=>import("./SettingsView-CsJItYZh.js").then(t=>t.a),__vite__mapDeps([130,8,1,2,6,3,4,5,7,9,10,11,12,13,14,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,111,112,113,131,132,115])).then(t=>({default:t.SettingsView}))),na=Le(()=>Ae(()=>import("./SettingsWindow-C9s4AX72.js"),__vite__mapDeps([133,1,2,6,3,4,5,7,8,9,10,11,12,13,14,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,130,111,112,113,131,132,115])).then(t=>({default:t.SettingsWindow}))),sa=()=>{const t=Z(v=>v.isSidebarOpen),r=Z(v=>v.activeMainTab),s=Z(v=>v.setIsMobile),o=Z(v=>v.isSessionSwitcherOpen),a=Z(v=>v.isSettingsDialogOpen),h=Z(v=>v.setSettingsDialogOpen),[w,d]=n.useState(!1);n.useEffect(()=>{a&&d(!0)},[a]),n.useEffect(()=>{const v=()=>Z.getState().closeMainSurfaces(),E=Ee.subscribe((T,q)=>{const re=!!T.currentSessionId&&T.currentSessionId!==q.currentSessionId,ie=!!T.newSessionDraft?.open&&T.newSessionDraft!==q.newSessionDraft;(re||ie)&&v()}),G=Z.subscribe((T,q)=>{T.activeMainTab!==q.activeMainTab&&v()});return()=>{E(),G()}},[]);const{isMobile:m}=Pt(),f=n.useRef(!1),[b,p]=n.useState(!1),[i,N]=n.useState(!1),[c,C]=n.useState(!1),[S,D]=n.useState(!1),A=n.useCallback(v=>{p(v),Z.getState().setSessionSwitcherOpen(v)},[]),O=n.useRef(typeof window>"u"?0:window.innerWidth),te=n.useRef(null),Q=n.useRef(!1),F=n.useRef(!1),M=n.useRef(!1),L=n.useRef(null),y=n.useRef(null),W=zt(-O.current),Y=Te.useRef(0),K=zt(O.current),B=Te.useRef(0);Te.useEffect(()=>{m&&(Y.current=window.innerWidth,B.current=window.innerWidth)},[m]),Te.useEffect(()=>{if(!m)return;const v=()=>{const E=window.innerWidth;Y.current=E,B.current=E,b||W.get()<-10&&W.set(-E),i||K.get()>10&&K.set(E)};return window.addEventListener("resize",v),window.addEventListener("orientationchange",v),()=>{window.removeEventListener("resize",v),window.removeEventListener("orientationchange",v)}},[m,W,K,b,i]),Te.useEffect(()=>{if(!m){C(!1);return}b&&C(!0);const v=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),E=et(W,b?0:-v,{type:"spring",stiffness:400,damping:35,mass:.8});return L.current=E,()=>E.stop()},[b,m,W]),Te.useEffect(()=>{if(!m){D(!1);return}i&&D(!0);const v=B.current||O.current||(typeof window<"u"?window.innerWidth:0),E=et(K,i?0:v,{type:"spring",stiffness:400,damping:35,mass:.8});return y.current=E,()=>E.stop()},[m,i,K]),Te.useEffect(()=>{if(m)return W.on("change",v=>{const E=Y.current||O.current,G=b||v>-E+.5;C(T=>T===G?T:G)})},[m,W,b]),Te.useEffect(()=>{if(m)return K.on("change",v=>{const E=B.current||O.current,G=i||v<E-.5;D(T=>T===G?T:G)})},[m,i,K]),Te.useEffect(()=>{m&&!o&&b&&A(!1)},[o,m,b,A]),Te.useEffect(()=>{if(!m){f.current=!1;return}f.current||(f.current=!0,A(!1),N(!1))},[m,A]),Te.useEffect(()=>{if(!m||r!=="chat"||b||i||a)return;let v=!1,E;const G=T=>{E=window.setTimeout(()=>{if(v)return;const q=Ee.getState(),re=Z.getState();if(!(re.activeMainTab!=="chat"||re.isSettingsDialogOpen||q.currentSessionId||q.newSessionDraft?.open)){if(q.isLoading){G(250);return}q.openNewSessionDraft({automatic:!0})}},T)};return G(500),()=>{v=!0,E!==void 0&&window.clearTimeout(E)}},[r,m,a,b,i]),Te.useEffect(()=>{!m||!a||(A(!1),N(!1))},[m,a,A]),n.useEffect(()=>{Z.getState().isMobile!==m&&s(m)},[m,s]);const X=n.useCallback(()=>{b&&A(!1),N(!i)},[b,i,A]);ln(te,{enabled:m,leftOpen:b,rightOpen:i,leftWidth:()=>Y.current||O.current||(typeof window<"u"?window.innerWidth:0),rightWidth:()=>B.current||O.current||(typeof window<"u"?window.innerWidth:0),onLeftProgress:v=>{const E=Y.current||O.current||(typeof window<"u"?window.innerWidth:0);W.set(E*(v-1))},onRightProgress:v=>{const E=B.current||O.current||(typeof window<"u"?window.innerWidth:0);K.set(E*(1-v))},onLeftOpen:()=>{i&&N(!1),A(!0)},onLeftClose:()=>A(!1),onRightOpen:()=>{b&&A(!1),N(!0)},onRightClose:()=>N(!1),onDragStart:v=>{Q.current=!0,v==="left"?(F.current=b,L.current?.stop(),c||C(!0)):(M.current=i,y.current?.stop(),S||D(!0))},onDragEnd:(v,E)=>{if(Q.current=!1,v==="left"&&typeof E=="boolean"){const G=F.current;if(E===G){const T=Y.current||O.current||(typeof window<"u"?window.innerWidth:0),q=et(W,G?0:-T,{type:"spring",stiffness:400,damping:35,mass:.8});L.current=q}}if(v==="right"&&typeof E=="boolean"){const G=M.current;if(E===G){const T=B.current||O.current||(typeof window<"u"?window.innerWidth:0),q=et(K,G?0:T,{type:"spring",stiffness:400,damping:35,mass:.8});y.current=q}}}});const R=n.useMemo(()=>{if(!m&&r!=="terminal"&&r!=="diagram"||m&&r==="git"&&(i||S))return null;switch(r){case"git":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(nr,{isActive:!0})});case"diff":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(Zo,{})});case"terminal":return e.jsx(dr,{});case"files":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(ea,{})});case"context":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(cr,{})});case"diagram":return e.jsx(n.Suspense,{fallback:null,children:e.jsx(ta,{})});default:return null}},[r,m,S,i]),z=r==="chat";return e.jsxs(cn,{children:[e.jsx(dn,{}),e.jsxs("div",{"data-page-scroll-lock":"true",className:ve("main-content-safe-area",m?"flex h-[100dvh] flex-col":"relative flex h-[100dvh]","bg-background"),children:[e.jsx(Yo,{}),e.jsx(qo,{}),e.jsx(un,{}),m?e.jsxs(Qo,{value:{leftDrawerOpen:b,rightDrawerOpen:i,toggleLeftDrawer:()=>{const v=!b;i&&N(!1),A(v)},toggleRightDrawer:X,leftDrawerX:W,rightDrawerX:K,leftDrawerWidth:Y,rightDrawerWidth:B,setMobileLeftDrawerOpen:A,setRightSidebarOpen:N},children:[!a&&e.jsx(At,{onToggleLeftDrawer:()=>{const v=!b;i&&N(!1),A(v)},onToggleRightDrawer:()=>{X()},leftDrawerOpen:b,rightDrawerOpen:i}),e.jsx("div",{"data-page-scroll-lock":"true",className:ve("flex flex-1 overflow-hidden relative",a&&"hidden"),children:e.jsxs("main",{ref:te,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:ve("absolute inset-0",!z&&"invisible"),children:e.jsx(_e,{children:e.jsx(Mt,{active:z&&!a})})}),R&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(_e,{children:R})}),e.jsx(_e,{children:e.jsx(It,{})}),e.jsx(Ut.div,{className:ve("absolute inset-0 z-20 bg-sidebar",!c&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:W},"aria-hidden":!b,children:e.jsx(_e,{children:e.jsx(Lt,{mobileVariant:!0,isVisible:c})})}),e.jsx(Ut.div,{className:ve("absolute inset-0 z-20 bg-sidebar",!S&&"pointer-events-none invisible"),"data-page-scroll-lock":"true",style:{x:K},"aria-hidden":!i,children:e.jsx(_e,{children:i||S?e.jsx(n.Suspense,{fallback:null,children:e.jsx(nr,{isActive:i})}):null})})]})}),a&&e.jsx("div",{className:"absolute inset-0 z-10 bg-background",style:{paddingTop:"var(--oc-safe-area-top, 0px)"},children:e.jsx(_e,{children:e.jsx(n.Suspense,{fallback:null,children:e.jsx(ra,{onClose:()=>h(!1)})})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(hn,{}),e.jsxs("div",{className:"flex flex-1 overflow-hidden","data-page-scroll-lock":"true",children:[e.jsx(gs,{isOpen:t,isMobile:m,className:"border-border",children:e.jsx(Lt,{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(At,{}),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:ve("absolute inset-0",!z&&"invisible"),children:e.jsx(_e,{children:e.jsx(Mt,{active:z&&!a})})}),R&&e.jsx("div",{className:"absolute inset-0",children:e.jsx(_e,{children:R})}),e.jsx(_e,{children:e.jsx(It,{})})]}),e.jsx(Oo,{})]})})}),e.jsx("div",{className:"border-t border-border","data-page-scroll-lock":"true",children:e.jsx(_e,{children:e.jsx(Vo,{})})})]})]})]}),w?e.jsx(n.Suspense,{fallback:null,children:e.jsx(na,{open:a,onOpenChange:h})}):null]})]})]})},oa=()=>(Zn(),mn(),e.jsxs(fn,{children:[e.jsx(es,{embeddedBackgroundWorkEnabled:!0}),e.jsx(sa,{}),e.jsx(ts,{}),e.jsx(rs,{})]}));function aa({apis:t}){const r=t??lr(),[s,o]=n.useState(0);return n.useEffect(()=>Gr(a=>{a.runtimeKey!==a.previousRuntimeKey&&(pn(a),o(h=>h+1))}),[]),n.useEffect(()=>{Yr()},[s]),n.useEffect(()=>{r&&qr(r)},[r]),r?e.jsx(_e,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground",children:e.jsx(qn,{apis:r,children:e.jsx(Jn,{children:e.jsx(Qn,{children:e.jsx(oa,{})})},s)})})}):e.jsx(_e,{children:e.jsx("div",{className:"h-full w-full overflow-hidden bg-background text-foreground"})})}const Lr=document.getElementById("root");if(!Lr)throw new Error("Root element not found");$r.createRoot(Lr).render(e.jsx(Te.StrictMode,{children:e.jsx(ns,{children:e.jsx(ss,{children:e.jsx(os,{children:e.jsx(aa,{apis:lr()??void 0})})})})}));
@@ -1,2 +1,2 @@
1
- import{g as z}from"./vendor-marked-i_gIkIP3.js";import{k as $}from"./vendor-katex-CHD9BdDO.js";import{p}from"./vendor-dompurify-r8glNMJW.js";import{ex as T,ey as L,ez as E,eA as C}from"./SessionSwitcherDropdown-cFWgy1td.js";import{p as O}from"./vendor-remend-BWYYytN3.js";const I=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),k=["script","style"],y=e=>z.lexer(e),H=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),R=e=>{const t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;const r=t[1];if(!r)return!1;const n=r[0],s=r.length,a=e.trimEnd().split(`
2
- `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${n}{${s},}[\\t ]*$`).test(a)},le=e=>{const t=e.replace(/^\n+/,"");return!!(/^[ \t]{0,3}(`{3,}|~{3,})/.test(t)||/^[ \t]{0,3}(?:> |[-*+] |\d+[.)] )/.test(t))},D=e=>{try{return O(e,{linkMode:"text-only"})}catch{return e}},g=(e,t)=>[{raw:e,src:e,mode:t?"live":"full",highlight:!t}],w=(e,t)=>{let r=-1;for(let s=e.length-1;s>=0;s-=1)if(e[s]?.type!=="space"){r=s;break}if(r<0)return[];const n=[];for(let s=0;s<e.length;s+=1){const a=e[s];if(!a||a.type==="space")continue;const i=a.raw??"",c=t.markLastLive&&s===r,o=a.type==="code"&&R(i);n.push({raw:i,src:o||c?i:D(i),mode:c?"live":"full",highlight:!t.cheap&&!o})}return n},b=(e,t,r=y)=>[{raw:e,src:e,mode:"full",highlight:!0}],N=2;class P{constructor(t=y){this.lex=t}prevText="";frozenSrc="";frozenBlocks=[];cached=null;update(t){if(this.cached&&t===this.prevText)return this.cached;if(this.prevText&&!t.startsWith(this.prevText)&&(this.frozenSrc="",this.frozenBlocks=[]),this.prevText=t,H(t))return this.frozenSrc="",this.frozenBlocks=[],this.cached=g(t,!0),this.cached;this.frozenSrc&&!t.startsWith(this.frozenSrc)&&(this.frozenSrc="",this.frozenBlocks=[]);const r=t.slice(this.frozenSrc.length);let n;try{n=this.lex(r)}catch{return this.cached=g(t,!0),this.cached}const s=[];for(let o=0;o<n.length;o+=1)n[o]?.type!=="space"&&s.push(o);const a=Math.max(0,s.length-N);if(a>0){const o=(s[a-1]??-1)+1,l=n.slice(0,o),f=w(l,{markLastLive:!1,cheap:!0});this.frozenBlocks=[...this.frozenBlocks,...f],this.frozenSrc+=l.map(m=>m.raw??"").join(""),n=n.slice(o)}const i=w(n,{markLastLive:!0,cheap:!0}),c=i.length>0?[...this.frozenBlocks,...i]:this.frozenBlocks.length>0?this.frozenBlocks:g(t,!0);return this.cached=c,c}}const F=32,h=new Map,G=e=>{const t=h.get(e);if(t)return h.delete(e),h.set(e,t),t;const r=new P;for(h.set(e,r);h.size>F;){const n=h.keys().next().value;if(typeof n!="string")break;h.delete(n)}return r},S=e=>{h.delete(e)},he=(e,t)=>{if(!e||e.length===0||e.length!==t.length||t[t.length-1]?.mode!=="live"||e[e.length-1]?.mode!=="live")return!1;for(let n=0;n<t.length-1;n+=1){const s=e[n],a=t[n];if(!s||!a||s.mode!=="full"||a.mode!=="full"||s.raw!==a.raw)return!1}return!0},d=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),v=(e,t,r)=>{try{return $.renderToString(e,{displayMode:r,throwOnError:!1})}catch{return t}},j={name:"inlineMath",level:"inline",start(e){const t=e.indexOf("\\(");return t<0?void 0:t},tokenizer(e){const t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:"inlineMath",raw:t[0],text:t[1]??""}},renderer(e){const t=e;return v(t.text,t.raw,!1)}},q={name:"blockMath",level:"block",start(e){const t=e.indexOf("\\[");return t<0?void 0:t},tokenizer(e){const t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:"blockMath",raw:t[0],text:t[1]??""}},renderer(e){const t=e;return v(t.text,t.raw,!0)}},A=z.use({gfm:!0,breaks:!1,extensions:[j,q],renderer:{html({text:e}){return I(e)},link({href:e,title:t,text:r}){const n=e??"",s=T(n);if(s)return`<a href="${d(C(s))}" data-pichamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${r}</a>`;const a=L(n);if(a)return`<a href="${d(n)}" data-skill-name="${d(a)}" class="text-primary hover:underline">${r}</a>`;const i=t?` title="${d(t)}"`:"";return`<a href="${d(n)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${r}</a>`}}}),W=e=>e.replace(/\$\$([\s\S]*?)\$\$/g,(t,r)=>{try{return $.renderToString(r,{displayMode:!0,throwOnError:!1})}catch{return`$$${r}$$`}}),_=e=>{if(e.indexOf("$")===-1)return e;const t=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return e.split(t).map((r,n)=>n%2===1?r:W(r)).join("")},U=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,X=1200,Z=(e,t)=>{let r=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&++r>t)return!0;return!1},J=e=>e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),Q=async e=>{const t=[...e.matchAll(U)];if(t.length===0)return e;const r=X;let n=e;for(const s of t){const[a,i,c]=s,o=(i||"text").toLowerCase();if(o==="mermaid")continue;const l=J(c??"");if(Z(l,r)){n=n.replace(a,()=>a.replace("<pre",`<pre data-md-lang="${o}"`));continue}const f=await E(l,o);if(f){const m=f.replace(/^<pre/,`<pre data-md-lang="${o}"`);n=n.replace(a,()=>m)}}return n},V={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:[...k],FORBID_CONTENTS:[...k]};let x=!1;const Y=()=>{x||typeof window>"u"||!p.isSupported||(x=!0,p.addHook("afterSanitizeAttributes",e=>{e instanceof HTMLAnchorElement&&e.target==="_blank"&&e.setAttribute("rel","noopener noreferrer")}))},B=e=>p.isSupported?(Y(),p.sanitize(e,V)):"",K=240,u=new Map,ee=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)},M=(e,t)=>{if(u.delete(e),u.set(e,t),u.size<=K)return;const r=u.keys().next().value;r&&u.delete(r)},te=async e=>{const t=await Promise.resolve(A.parse(e.src)),r=e.highlight?_(t):t,n=e.highlight?await Q(r):r;return B(n)},re=e=>{if(!e)return"";const t=A.parse(e),r=_(t);return B(r)},ne=async(e,t,r)=>{if(!e)return r&&S(r),[];let n;return t?n=G(r).update(e):(S(r),n=b(e)),Promise.all(n.map(async(s,a)=>{if(s.mode==="live")return{id:`live:${a}`,html:"",mode:"live",raw:s.raw};const i=ee(s.raw),c=`${i}:${s.mode}:${s.highlight?1:0}`,o=`${r}:${a}:${s.mode}`,l=u.get(o);if(l&&l.hash===i)return M(o,l),{id:c,html:l.html,mode:s.mode,raw:s.raw};const f=await te(s);return M(o,{hash:i,html:f}),{id:c,html:f,mode:s.mode,raw:s.raw}}))},fe=Object.freeze(Object.defineProperty({__proto__:null,renderMarkdownBlocks:ne,renderMarkdownSync:re},Symbol.toStringTag,{value:"Module"}));export{ne as a,le as b,he as i,fe as m,re as r,G as s};
1
+ import{g as z}from"./vendor-marked-i_gIkIP3.js";import{k as $}from"./vendor-katex-CHD9BdDO.js";import{p}from"./vendor-dompurify-r8glNMJW.js";import{eC as T,eD as E,eE as L,eF as C}from"./SessionSwitcherDropdown-DROjbyIu.js";import{p as O}from"./vendor-remend-BWYYytN3.js";const I=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),k=["script","style"],v=e=>z.lexer(e),H=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),R=e=>{const t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;const r=t[1];if(!r)return!1;const n=r[0],s=r.length,a=e.trimEnd().split(`
2
+ `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${n}{${s},}[\\t ]*$`).test(a)},le=e=>{const t=e.replace(/^\n+/,"");return!!(/^[ \t]{0,3}(`{3,}|~{3,})/.test(t)||/^[ \t]{0,3}(?:> |[-*+] |\d+[.)] )/.test(t))},D=e=>{try{return O(e,{linkMode:"text-only"})}catch{return e}},g=(e,t)=>[{raw:e,src:e,mode:t?"live":"full",highlight:!t}],w=(e,t)=>{let r=-1;for(let s=e.length-1;s>=0;s-=1)if(e[s]?.type!=="space"){r=s;break}if(r<0)return[];const n=[];for(let s=0;s<e.length;s+=1){const a=e[s];if(!a||a.type==="space")continue;const i=a.raw??"",c=t.markLastLive&&s===r,o=a.type==="code"&&R(i);n.push({raw:i,src:o||c?i:D(i),mode:c?"live":"full",highlight:!t.cheap&&!o})}return n},b=(e,t,r=v)=>[{raw:e,src:e,mode:"full",highlight:!0}],F=2;class N{constructor(t=v){this.lex=t}prevText="";frozenSrc="";frozenBlocks=[];cached=null;update(t){if(this.cached&&t===this.prevText)return this.cached;if(this.prevText&&!t.startsWith(this.prevText)&&(this.frozenSrc="",this.frozenBlocks=[]),this.prevText=t,H(t))return this.frozenSrc="",this.frozenBlocks=[],this.cached=g(t,!0),this.cached;this.frozenSrc&&!t.startsWith(this.frozenSrc)&&(this.frozenSrc="",this.frozenBlocks=[]);const r=t.slice(this.frozenSrc.length);let n;try{n=this.lex(r)}catch{return this.cached=g(t,!0),this.cached}const s=[];for(let o=0;o<n.length;o+=1)n[o]?.type!=="space"&&s.push(o);const a=Math.max(0,s.length-F);if(a>0){const o=(s[a-1]??-1)+1,l=n.slice(0,o),f=w(l,{markLastLive:!1,cheap:!0});this.frozenBlocks=[...this.frozenBlocks,...f],this.frozenSrc+=l.map(m=>m.raw??"").join(""),n=n.slice(o)}const i=w(n,{markLastLive:!0,cheap:!0}),c=i.length>0?[...this.frozenBlocks,...i]:this.frozenBlocks.length>0?this.frozenBlocks:g(t,!0);return this.cached=c,c}}const P=32,h=new Map,G=e=>{const t=h.get(e);if(t)return h.delete(e),h.set(e,t),t;const r=new N;for(h.set(e,r);h.size>P;){const n=h.keys().next().value;if(typeof n!="string")break;h.delete(n)}return r},S=e=>{h.delete(e)},he=(e,t)=>{if(!e||e.length===0||e.length!==t.length||t[t.length-1]?.mode!=="live"||e[e.length-1]?.mode!=="live")return!1;for(let n=0;n<t.length-1;n+=1){const s=e[n],a=t[n];if(!s||!a||s.mode!=="full"||a.mode!=="full"||s.raw!==a.raw)return!1}return!0},d=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),y=(e,t,r)=>{try{return $.renderToString(e,{displayMode:r,throwOnError:!1})}catch{return t}},j={name:"inlineMath",level:"inline",start(e){const t=e.indexOf("\\(");return t<0?void 0:t},tokenizer(e){const t=/^\\\(([\s\S]+?)\\\)/.exec(e);if(t)return{type:"inlineMath",raw:t[0],text:t[1]??""}},renderer(e){const t=e;return y(t.text,t.raw,!1)}},q={name:"blockMath",level:"block",start(e){const t=e.indexOf("\\[");return t<0?void 0:t},tokenizer(e){const t=/^\\\[([\s\S]+?)\\\]/.exec(e);if(t)return{type:"blockMath",raw:t[0],text:t[1]??""}},renderer(e){const t=e;return y(t.text,t.raw,!0)}},A=z.use({gfm:!0,breaks:!1,extensions:[j,q],renderer:{html({text:e}){return I(e)},link({href:e,title:t,text:r}){const n=e??"",s=T(n);if(s)return`<a href="${d(C(s))}" data-pichamber-agent-mention="true" class="text-primary hover:underline" target="_blank" rel="noopener noreferrer">${r}</a>`;const a=E(n);if(a)return`<a href="${d(n)}" data-skill-name="${d(a)}" class="text-primary hover:underline">${r}</a>`;const i=t?` title="${d(t)}"`:"";return`<a href="${d(n)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${r}</a>`}}}),W=e=>e.replace(/\$\$([\s\S]*?)\$\$/g,(t,r)=>{try{return $.renderToString(r,{displayMode:!0,throwOnError:!1})}catch{return`$$${r}$$`}}),_=e=>{if(e.indexOf("$")===-1)return e;const t=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi;return e.split(t).map((r,n)=>n%2===1?r:W(r)).join("")},U=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,X=1200,Z=(e,t)=>{let r=1;for(let n=0;n<e.length;n+=1)if(e.charCodeAt(n)===10&&++r>t)return!0;return!1},J=e=>e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),Q=async e=>{const t=[...e.matchAll(U)];if(t.length===0)return e;const r=X;let n=e;for(const s of t){const[a,i,c]=s,o=(i||"text").toLowerCase();if(o==="mermaid")continue;const l=J(c??"");if(Z(l,r)){n=n.replace(a,()=>a.replace("<pre",`<pre data-md-lang="${o}"`));continue}const f=await L(l,o);if(f){const m=f.replace(/^<pre/,`<pre data-md-lang="${o}"`);n=n.replace(a,()=>m)}}return n},V={USE_PROFILES:{html:!0,mathMl:!0,svg:!0},ADD_TAGS:["svg","path","g","rect","line","polygon","polyline","circle","ellipse","text","tspan","defs","marker"],ADD_ATTR:["d","viewBox","preserveAspectRatio","xmlns","target","fill","stroke","stroke-width","transform","points","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","style"],FORBID_TAGS:[...k],FORBID_CONTENTS:[...k]};let M=!1;const Y=()=>{M||typeof window>"u"||!p.isSupported||(M=!0,p.addHook("afterSanitizeAttributes",e=>{e instanceof HTMLAnchorElement&&e.target==="_blank"&&e.setAttribute("rel","noopener noreferrer")}))},B=e=>p.isSupported?(Y(),p.sanitize(e,V)):"",K=240,u=new Map,ee=e=>{let t=2166136261;for(let r=0;r<e.length;r+=1)t^=e.charCodeAt(r),t=Math.imul(t,16777619);return(t>>>0).toString(36)},x=(e,t)=>{if(u.delete(e),u.set(e,t),u.size<=K)return;const r=u.keys().next().value;r&&u.delete(r)},te=async e=>{const t=await Promise.resolve(A.parse(e.src)),r=e.highlight?_(t):t,n=e.highlight?await Q(r):r;return B(n)},re=e=>{if(!e)return"";const t=A.parse(e),r=_(t);return B(r)},ne=async(e,t,r)=>{if(!e)return r&&S(r),[];let n;return t?n=G(r).update(e):(S(r),n=b(e)),Promise.all(n.map(async(s,a)=>{if(s.mode==="live")return{id:`live:${a}`,html:"",mode:"live",raw:s.raw};const i=ee(s.raw),c=`${i}:${s.mode}:${s.highlight?1:0}`,o=`${r}:${a}:${s.mode}`,l=u.get(o);if(l&&l.hash===i)return x(o,l),{id:c,html:l.html,mode:s.mode,raw:s.raw};const f=await te(s);return x(o,{hash:i,html:f}),{id:c,html:f,mode:s.mode,raw:s.raw}}))},fe=Object.freeze(Object.defineProperty({__proto__:null,renderMarkdownBlocks:ne,renderMarkdownSync:re},Symbol.toStringTag,{value:"Module"}));export{ne as a,le as b,he as i,fe as m,re as r,G as s};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-B1_fTdN-.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/index-DEYblXCW.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-DLKBsLKY.css","assets/useWindowTitle-C-AZD713.js","assets/SessionSwitcherDropdown-cFWgy1td.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-base-ui-DL8r2fgQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/runtimeSurface-9aJdtQbh.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-HC9JT4I3.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-dWA7qvjr.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js"])))=>i.map(i=>d[i]);
2
- import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as t}from"./index-DEYblXCW.js";import"./vendor-katex-CHD9BdDO.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-react-DYyjh7Q0.js";import"./vendor-scheduler-7OC5HNn7.js";window.__PICHAMBER_RUNTIME_APIS__=t();o(async()=>{const{renderElectronMiniChatApp:r}=await import("./renderElectronMiniChatApp-B1_fTdN-.js");return{renderElectronMiniChatApp:r}},__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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(({renderElectronMiniChatApp:r})=>{r()});
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-CM8qBaye.js","assets/vendor-react-DYyjh7Q0.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CHD9BdDO.js","assets/vendor-katex-Cp579UoJ.css","assets/index-BAqpUCjs.js","assets/vendor-zustand-CnsBKjP5.js","assets/index-riABQmQ_.css","assets/useWindowTitle-B9wt_3ZQ.js","assets/SessionSwitcherDropdown-DROjbyIu.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-base-ui-DL8r2fgQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-react-dom-sVFnuruh.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-use-sync-external-store-B7OScDIw.js","assets/runtimeSurface-CkHYYg0E.js","assets/vendor-dnd-kit-core-GipZW2tY.js","assets/vendor-dnd-kit-utilities-CrOcp0Bp.js","assets/vendor-dnd-kit-accessibility-Cv52zwWT.js","assets/vendor-dnd-kit-sortable-Ct2QxIHb.js","assets/vendor-cmdk-BCEUzcHE.js","assets/vendor-radix-ui-react-dialog-jX3Dld8c.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js","assets/vendor-radix-ui-react-context-CM4yFQ2I.js","assets/vendor-radix-ui-react-id-BcxRjnbX.js","assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js","assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js","assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js","assets/vendor-radix-ui-react-primitive-CfpW6_IT.js","assets/vendor-radix-ui-react-slot-BxUc3Pvz.js","assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js","assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js","assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js","assets/vendor-radix-ui-react-portal-xlJWBfDg.js","assets/vendor-radix-ui-react-presence-Btn-Dp7L.js","assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js","assets/vendor-react-remove-scroll-CfeMe0DL.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-C9YRs2nU.js","assets/vendor-react-style-singleton-B1H4bWSG.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-C-AuTczP.js","assets/vendor-use-callback-ref-CJB0R85I.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-E2vgV9K3.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-DSzLbZiS.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-BUlYhQ3o.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-BS2SpSAZ.js","assets/vendor-codemirror-lang-json-CqayksDf.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-Ba8JZ6fp.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-DK27qQri.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-CvO36Y1p.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-x89A7Wy0.js","assets/vendor-codemirror-lang-python-_2bIYTiJ.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-RrgJ8H_6.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tanstack-react-virtual-IrbCBGJ4.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-DJASDzNt.js","assets/vendor-motion-dom-DJLgZh4Q.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-sonner-CW8w438f.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js"])))=>i.map(i=>d[i]);
2
+ import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as t}from"./index-BAqpUCjs.js";import"./vendor-katex-CHD9BdDO.js";import"./vendor-zustand-CnsBKjP5.js";import"./vendor-react-DYyjh7Q0.js";import"./vendor-scheduler-7OC5HNn7.js";window.__PICHAMBER_RUNTIME_APIS__=t();o(async()=>{const{renderElectronMiniChatApp:r}=await import("./renderElectronMiniChatApp-CM8qBaye.js");return{renderElectronMiniChatApp:r}},__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,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,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(({renderElectronMiniChatApp:r})=>{r()});