@pi-chamber/web 0.9.8 → 0.9.9-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +8 -6
  2. package/bin/cli.test.js +7 -0
  3. package/bin/lib/DOCUMENTATION.md +1 -1
  4. package/bin/lib/cli-args.js +44 -1
  5. package/bin/lib/cli-startup.js +4 -0
  6. package/bin/lib/commands-update.js +177 -77
  7. package/bin/lib/commands-update.test.js +203 -8
  8. package/dist/assets/{DiagramView-vaGEmGJn.js → DiagramView-BCSuO0vQ.js} +1 -1
  9. package/dist/assets/{DiffView-BUOaq70P.js → DiffView-CztvzY4T.js} +1 -1
  10. package/dist/assets/{FileSaveConflictDialog-B3wIsdE1.js → FileSaveConflictDialog-DaOy8774.js} +1 -1
  11. package/dist/assets/{FilesView-DPwCE-XA.js → FilesView-e_ocd6LL.js} +1 -1
  12. package/dist/assets/{GitView-CGk98LhV.js → GitView-C2A84zfY.js} +3 -3
  13. package/dist/assets/{JsonTreeView-HNtRoqVA.js → JsonTreeView-nFCKn3bk.js} +1 -1
  14. package/dist/assets/{MarkdownRendererImpl-DUYL-Wn3.js → MarkdownRendererImpl-0nbCRN9F.js} +1 -1
  15. package/dist/assets/{PatchDiff-Bluz53zj.js → PatchDiff-TSvJHd8z.js} +1 -1
  16. package/dist/assets/{SessionSwitcherContent-DDncCwpE.js → SessionSwitcherContent-p0GEx1or.js} +1 -1
  17. package/dist/assets/{SessionSwitcherDropdown-Cw_g3ai3.js → SessionSwitcherDropdown-D1K-Lc7X.js} +2 -2
  18. package/dist/assets/{SessionUnreadDot-CT5M3-qK.js → SessionUnreadDot-kMo29jr2.js} +1 -1
  19. package/dist/assets/SettingsView-BpkV0dfi.js +2 -0
  20. package/dist/assets/{SettingsWindow-B_oA1yV4.js → SettingsWindow-CZNBrUqU.js} +1 -1
  21. package/dist/assets/{ToolOutputDialog-C3xiVDyE.js → ToolOutputDialog-B9_ymjpZ.js} +1 -1
  22. package/dist/assets/{ToolPartDiffPreview-xrxYTK3l.js → ToolPartDiffPreview-47UtQBCn.js} +1 -1
  23. package/dist/assets/{VirtualizedFileDiff-Bpgyk3yt.js → VirtualizedFileDiff-BCbGwRPY.js} +1 -1
  24. package/dist/assets/{collapsible-_urywMu5.js → collapsible-B6bVtxgp.js} +1 -1
  25. package/dist/assets/{computeVirtualFileMetrics-DPPmLfoR.js → computeVirtualFileMetrics-DbKH9gNm.js} +1 -1
  26. package/dist/assets/{contextFileOpenGuard-CV7L_UMk.js → contextFileOpenGuard-GAHxagrv.js} +1 -1
  27. package/dist/assets/{gitStatusPredicates-BTkHRMCD.js → gitStatusPredicates-D9AQuzXM.js} +1 -1
  28. package/dist/assets/{index-C3PSe3Mq.js → index-6aQ1In_D.js} +1 -1
  29. package/dist/assets/{index-CrqlVJXp.js → index-BOtRfXre.js} +3 -3
  30. package/dist/assets/{isDiffPlainText-Djb-erNZ.js → isDiffPlainText-C8SQJqjX.js} +1 -1
  31. package/dist/assets/{isFilePlainText-BQ-Wnk8C.js → isFilePlainText-YbZGouYK.js} +1 -1
  32. package/dist/assets/{main-Dpqrd5dA.js → main-CULeQoKT.js} +2 -2
  33. package/dist/assets/{main-7I7_paNp.js → main-DQPe4vbe.js} +3 -3
  34. package/dist/assets/{markdownCore-DOQQqV2i.js → markdownCore-DZMIS_FB.js} +1 -1
  35. package/dist/assets/{miniChat-b1O4Yu1o.js → miniChat-Efo5qEoa.js} +2 -2
  36. package/dist/assets/{mobile-BTpbHrim.js → mobile-CwVpqlGB.js} +2 -2
  37. package/dist/assets/{renderElectronMiniChatApp-Cisrg0Iv.js → renderElectronMiniChatApp-COsbP106.js} +2 -2
  38. package/dist/assets/{renderMobileApp-CSBtWiZ2.js → renderMobileApp-aLM7KW0X.js} +3 -3
  39. package/dist/assets/runtimeEndpointReset-DDY4b0u9.js +53 -0
  40. package/dist/assets/{runtimeSurface-C9kx2zfD.js → runtimeSurface-CPm7KWaN.js} +1 -1
  41. package/dist/assets/{useAppFontEffects-BH5qeSfx.js → useAppFontEffects-DVk3fjRp.js} +7 -7
  42. package/dist/assets/{useFilesViewSearch-Bdxwr4SZ.js → useFilesViewSearch-Chw61crV.js} +1 -1
  43. package/dist/assets/{usePushVisibilityBeacon-Czfhm8lw.js → usePushVisibilityBeacon-DfYl_CdQ.js} +1 -1
  44. package/dist/assets/{useSwitcherItems-CiTeIjW3.js → useSwitcherItems-BonWORYM.js} +1 -1
  45. package/dist/assets/{vendor-base-ui-C60wdVnS.js → vendor-base-ui-DXSHfszQ.js} +1 -1
  46. package/dist/assets/{vendor-codemirror-language-data-BhPKX-r-.js → vendor-codemirror-language-data-CpwyVWiC.js} +2 -2
  47. package/dist/assets/{vendor-floating-ui-dom-Bkw82kL9.js → vendor-floating-ui-dom-WyXykhNi.js} +1 -1
  48. package/dist/assets/{vendor-floating-ui-react-dom-KLmnYDaG.js → vendor-floating-ui-react-dom-BZOGXAGe.js} +1 -1
  49. package/dist/assets/{web-components-CuVJfuw8.js → web-components-D_W34-Mr.js} +1 -1
  50. package/dist/index.html +3 -3
  51. package/dist/mini-chat.html +2 -2
  52. package/dist/mobile.html +2 -2
  53. package/package.json +1 -1
  54. package/server/lib/package-manager.js +317 -49
  55. package/server/lib/package-manager.test.js +321 -12
  56. package/server/lib/pi/routes.js +76 -12
  57. package/server/lib/pi/routes.test.js +73 -12
  58. package/server/lib/pi/ui-settings-store.js +7 -5
  59. package/server/lib/pi/ui-settings-store.test.js +6 -4
  60. package/server/lib/terminal/DOCUMENTATION.md +1 -1
  61. package/server/lib/terminal/runtime.js +1 -1
  62. package/server/lib/terminal/runtime.test.js +1 -0
  63. package/server/lib/update-job-store.js +173 -0
  64. package/server/lib/update-job-store.test.js +179 -0
  65. package/dist/assets/SettingsView-C26Mwkzp.js +0 -2
  66. package/dist/assets/runtimeEndpointReset-sDOkJ0dT.js +0 -53
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-Cisrg0Iv.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CNckGUMB.js","assets/vendor-katex-Cp579UoJ.css","assets/index-CrqlVJXp.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BXgR2dKM.css","assets/usePushVisibilityBeacon-Czfhm8lw.js","assets/useAppFontEffects-BH5qeSfx.js","assets/vendor-base-ui-C60wdVnS.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-KLmnYDaG.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-C9kx2zfD.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BhPKX-r-.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js"])))=>i.map(i=>d[i]);
2
- import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as t}from"./index-CrqlVJXp.js";import"./vendor-katex-CNckGUMB.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-react-B5Z1Mdn3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";window.__PICHAMBER_RUNTIME_APIS__=t();o(async()=>{const{renderElectronMiniChatApp:r}=await import("./renderElectronMiniChatApp-Cisrg0Iv.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-COsbP106.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CNckGUMB.js","assets/vendor-katex-Cp579UoJ.css","assets/index-BOtRfXre.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BXgR2dKM.css","assets/usePushVisibilityBeacon-DfYl_CdQ.js","assets/useAppFontEffects-DVk3fjRp.js","assets/vendor-base-ui-DXSHfszQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-CPm7KWaN.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CpwyVWiC.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js"])))=>i.map(i=>d[i]);
2
+ import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as t}from"./index-BOtRfXre.js";import"./vendor-katex-CNckGUMB.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-react-B5Z1Mdn3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";window.__PICHAMBER_RUNTIME_APIS__=t();o(async()=>{const{renderElectronMiniChatApp:r}=await import("./renderElectronMiniChatApp-COsbP106.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,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-CSBtWiZ2.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CNckGUMB.js","assets/vendor-katex-Cp579UoJ.css","assets/index-CrqlVJXp.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BXgR2dKM.css","assets/usePushVisibilityBeacon-Czfhm8lw.js","assets/useAppFontEffects-BH5qeSfx.js","assets/vendor-base-ui-C60wdVnS.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-KLmnYDaG.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-C9kx2zfD.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BhPKX-r-.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js","assets/runtimeEndpointReset-sDOkJ0dT.js","assets/SessionUnreadDot-CT5M3-qK.js","assets/vendor-xterm-xterm-CrXqRur4.js","assets/vendor-xterm-xterm-DDGTF8rc.css","assets/permissionStore-iKN1K2_x.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js","assets/SettingsView-C26Mwkzp.js","assets/vendor-qrcode-B0KNSajT.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-_urywMu5.js","assets/useSwitcherItems-CiTeIjW3.js"])))=>i.map(i=>d[i]);
2
- import{_ as t}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as i}from"./index-CrqlVJXp.js";import"./vendor-katex-CNckGUMB.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-react-B5Z1Mdn3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";window.__PICHAMBER_RUNTIME_APIS__=i();t(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-CSBtWiZ2.js").then(o=>o.r);return{renderMobileApp: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,83,84,85,86,87,88,89,90,91,92,93,94,95])).then(({renderMobileApp:r})=>{r()});
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-aLM7KW0X.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/vendor-katex-CNckGUMB.js","assets/vendor-katex-Cp579UoJ.css","assets/index-BOtRfXre.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BXgR2dKM.css","assets/usePushVisibilityBeacon-DfYl_CdQ.js","assets/useAppFontEffects-DVk3fjRp.js","assets/vendor-base-ui-DXSHfszQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-CPm7KWaN.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CpwyVWiC.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js","assets/runtimeEndpointReset-DDY4b0u9.js","assets/SessionUnreadDot-kMo29jr2.js","assets/vendor-xterm-xterm-CrXqRur4.js","assets/vendor-xterm-xterm-DDGTF8rc.css","assets/permissionStore-iKN1K2_x.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js","assets/SettingsView-BpkV0dfi.js","assets/vendor-qrcode-B0KNSajT.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-B6bVtxgp.js","assets/useSwitcherItems-BonWORYM.js"])))=>i.map(i=>d[i]);
2
+ import{_ as t}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as i}from"./index-BOtRfXre.js";import"./vendor-katex-CNckGUMB.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-react-B5Z1Mdn3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";window.__PICHAMBER_RUNTIME_APIS__=i();t(async()=>{const{renderMobileApp:r}=await import("./renderMobileApp-aLM7KW0X.js").then(o=>o.r);return{renderMobileApp: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,83,84,85,86,87,88,89,90,91,92,93,94,95])).then(({renderMobileApp:r})=>{r()});
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherDropdown-Cw_g3ai3.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-BH5qeSfx.js","assets/index-CrqlVJXp.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BXgR2dKM.css","assets/vendor-base-ui-C60wdVnS.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-Bkw82kL9.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-KLmnYDaG.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-C9kx2zfD.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-BhPKX-r-.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js"])))=>i.map(i=>d[i]);
2
- import{j as e,R as a,r as me,e as ye}from"./vendor-react-B5Z1Mdn3.js";import"./vendor-katex-CNckGUMB.js";import{o as V,q as K,a1 as ge,C as Y,u as ie,aL as U,Q as we,U as ve,y as le,v as je,A as be}from"./index-CrqlVJXp.js";import{u as Se,a as Ie,s as Ce}from"./usePushVisibilityBeacon-Czfhm8lw.js";import{bD as Ne,I as J,aR as De,a2 as Pe,a3 as Me,a5 as Ee,bE as ke,bF as _e,e as j,b1 as Le,a as ae,x as P,an as ce,bG as Oe,aa as Te,ax as Re,bs as Ae,bg as Be,B as de,bw as Fe,bH as ue,bI as ze,t as Ue,g as $e,J as We,E as He,L as Ge,R as Ve,W as Je,T as Ke,M as qe,N as Qe,bJ as Xe,bt as Ye,U as Ze,V as et,X as tt,Y as rt}from"./useAppFontEffects-BH5qeSfx.js";import{_ as st}from"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-C60wdVnS.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-Bkw82kL9.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-KLmnYDaG.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./runtimeSurface-C9kx2zfD.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-BhPKX-r-.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";const nt=({mode:t,children:s})=>e.jsx(Ne.Provider,{value:t,children:s}),ot=ke,it=_e,at=({totalTokens:t,percentage:s,colorPercentage:n,contextLimit:c,outputLimit:i,size:u="default",isMobile:l=!1,hideIcon:D=!1,showPercentIcon:k=!1,className:f,valueClassName:p,percentIconClassName:_,onClick:M,pressed:O=!1,cacheRead:x,cacheWrite:C,cacheHitPercent:h})=>{const[b,o]=a.useState(!1),g=typeof n=="number"?n:s,m=ot(s)??0,y=it(g),q=y==="critical"?"var(--status-error)":y==="warn"?"var(--status-warning)":"var(--status-success)",w=I=>I>=1e6?`${(I/1e6).toFixed(1)}M`:I>=1e3?`${(I/1e3).toFixed(1)}K`:I.toFixed(1).replace(/\.0$/,""),N=I=>I>=90?"text-status-error":I>=75?"text-status-warning":"text-status-success",E=20,$=3,W=(E-$)/2,se=2*Math.PI*W,Q=se*(1-m/100),R=typeof i=="number"?Math.max(i,0):0,A=typeof x=="number"&&typeof C=="number",Z=A?Math.max(0,x):0,B=A?Math.max(0,C):0,L=typeof h=="number"&&Number.isFinite(h),T=[`Used tokens: ${w(t)}`,`Context limit: ${w(c)}`,`Output limit: ${w(R)}`,...A?[`Cache read: ${w(Z)}`,`Cache write: ${w(B)}`]:[],...L?[`Cache hit: ${h.toFixed(1)}%`]:[],`${Math.min(s,999).toFixed(1)}% used`],F=!l&&typeof M=="function",v=e.jsxs(e.Fragment,{children:[!l&&!D&&e.jsx(J,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:V("font-medium inline-flex items-center gap-1.5",p),children:k?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{viewBox:`0 0 ${E} ${E}`,className:V("h-3.5 w-3.5 -rotate-90",_),role:"progressbar","aria-valuenow":Math.round(m),"aria-valuemin":0,"aria-valuemax":100,children:[e.jsx("circle",{cx:E/2,cy:E/2,r:W,fill:"none",stroke:"var(--interactive-border)",strokeWidth:$}),e.jsx("circle",{cx:E/2,cy:E/2,r:W,fill:"none",stroke:q,strokeWidth:$,strokeLinecap:"round",strokeDasharray:se,strokeDashoffset:Q,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),e.jsxs("span",{className:"text-foreground",children:[Math.min(s,999).toFixed(1),"%"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:N(g),children:Math.min(s,999).toFixed(1)}),"%"]})})]}),S=V("app-region-no-drag flex items-center gap-1.5 select-none",u==="compact"?"typography-micro":"typography-meta",F?V("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",f),H=F?e.jsx("button",{type:"button",className:S,"aria-label":"Context usage","aria-pressed":O,onClick:M,children:v}):e.jsx("div",{className:S,"aria-label":"Context usage",onClick:l?()=>o(!0):void 0,children:v});return l?e.jsxs(e.Fragment,{children:[H,e.jsx(De,{open:b,onClose:()=>o(!1),title:"Context Usage",children:e.jsx("div",{className:"flex flex-col gap-1.5",children:e.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(t)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(c)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(R)})]}),A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(Z)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(B)})]})]}):null,L?e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Cache hit"}),e.jsxs("span",{className:"typography-meta text-foreground font-medium",children:[h.toFixed(1),"%"]})]}):null,e.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Usage"}),e.jsxs("span",{className:V("typography-meta font-semibold",N(g)),children:[Math.min(s,999).toFixed(1),"%"]})]})]})})})]}):e.jsxs(Pe,{children:[e.jsx(Me,{asChild:!0,children:H}),e.jsx(Ee,{children:e.jsx("div",{className:"space-y-0.5",children:T.map(I=>e.jsx("p",{className:"typography-micro leading-tight",children:I},I))})})]})},ct=a.lazy(()=>st(()=>import("./SessionSwitcherDropdown-Cw_g3ai3.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])).then(t=>({default:t.SessionSwitcherDropdown}))),lt=t=>{const s=typeof t=="string"?t.trim():"";if(!s)return"";const n=typeof window<"u"?window.__PICHAMBER_HOME__:"";if(n&&s===n)return"~";if(n&&s.startsWith(`${n}/`))return`~/${s.slice(n.length+1)}`;const c=s.split("/").filter(Boolean);return c.length<=3?s:`.../${c.slice(-3).join("/")}`},re=t=>{const s=typeof t=="string"?t.trim():"";if(!s)return"";const n=s.replace(/\\/g,"/");return n==="/"?"/":n.replace(/\/+$/,"")},dt=({mode:t})=>{const s=j(r=>r.currentSessionId),n=j(r=>!!r.newSessionDraft?.open),c=j(r=>r.newSessionDraft?.selectedProjectId??null),i=K(r=>r.currentDirectory),u=ae(r=>r.projects),l=ae(r=>r.getActiveProject()),D=P(r=>r.getCurrentModel),k=P(r=>r.providers),f=ce(),p=Oe(s??""),_=Te(),M=Re(r=>r.ensureStatus),O=j(r=>r.newSessionDraft?.open?re(r.newSessionDraft.directoryOverride??""):""),[x,C]=a.useState(!1),h=typeof window<"u"?window.__PICHAMBER_MACOS_MAJOR__??0:0,b=Number.isFinite(h)&&h>0,o=Ae(),g=b?h>=26?"h-12":h<=15?"h-14":"":"",m=a.useMemo(()=>s?f.find(r=>r.id===s)??null:null,[s,f]);a.useEffect(()=>{ge()&&Y("desktop_get_window_pinned").then(r=>{typeof r?.pinned=="boolean"&&C(r.pinned)})},[]);const y=m?.title?.trim()||(n||t==="draft"?"New session":"Session"),q=re(m?.directory??null),w=re(i),N=q||O||w,E=lt(N);a.useEffect(()=>{N&&M(N,_.git).catch(()=>{})},[M,N,_.git]);const $=a.useMemo(()=>{const r=N;return r?u.map(d=>({...d,normalizedPath:re(d.path)})).filter(d=>d.normalizedPath&&(d.normalizedPath===r||r.startsWith(`${d.normalizedPath}/`))).sort((d,G)=>G.path.length-d.path.length)[0]??null:null},[N,u]),W=a.useMemo(()=>{const r=$??l;if(!r)return E||"PiChamber";const d=r.label?.trim();return d||(r.path.split(/[\\/]/).filter(Boolean).at(-1)??r.path)},[l,E,$]),Q=Be(N||null),R=Q&&Q!=="HEAD"?Q:null,A=D(),Z=a.useMemo(()=>{for(let r=p.length-1;r>=0;r-=1){const d=p[r];if(d.role!=="assistant"||typeof d.providerID!="string"||typeof d.modelID!="string")continue;const te=k.find(X=>X.id===d.providerID)?.models.find(X=>X.id===d.modelID);if(te)return te}},[p,k]),B=A?.limit?A:Z,L=B&&typeof B.limit=="object"&&B.limit!==null?B.limit:null,T=L&&typeof L.context=="number"?L.context:0,F=L&&typeof L.output=="number"?L.output:0,v=a.useMemo(()=>{if(!s||p.length===0)return null;let r,d;for(let ne=p.length-1;ne>=0;ne-=1){const oe=p[ne];if(oe.role!=="assistant")continue;const z=oe.tokens;if(!z)continue;if(z.input+z.output+z.reasoning+(z.cache?.read??0)+(z.cache?.write??0)>0){r=z,d=oe.id;break}}if(!r)return null;const G=r.input+r.output+r.reasoning+(r.cache?.read??0)+(r.cache?.write??0),te=T>0?T:2e5,X=T>0?Math.round(G/T*100):0,xe=F>0?Math.round(r.output/F*100):void 0;return{totalTokens:G,percentage:X,contextLimit:T||0,outputLimit:F||void 0,normalizedOutput:xe,thresholdLimit:te,lastMessageId:d}},[T,s,p,F]),[S,H]=a.useState(null),I={WebkitAppRegion:"drag"},ee={WebkitAppRegion:"no-drag"};a.useEffect(()=>{if(!s){H(r=>r===null?r:null);return}if(v&&v.totalTokens>0){H(r=>r&&r.totalTokens===v.totalTokens&&r.percentage===v.percentage&&r.contextLimit===v.contextLimit&&(r.outputLimit??0)===(v.outputLimit??0)&&(r.normalizedOutput??0)===(v.normalizedOutput??0)&&r.thresholdLimit===v.thresholdLimit&&r.lastMessageId===v.lastMessageId?r:v);return}H(r=>r===null?r:null)},[v,s]);const pe=S&&S.contextLimit>0?Math.min(999,S.totalTokens/S.contextLimit*100):0,fe=a.useCallback(()=>{const r=!x;C(r),Y("desktop_set_window_pinned",{pinned:r}).catch(()=>{C(!r)})},[x]),he=a.useCallback(()=>{const r=s?{sessionId:s,directory:m?.directory??i??""}:{mode:"draft",directory:N||i||"",projectId:c};Y("desktop_focus_main_window",r).then(d=>d?.focused===!0?Y("desktop_close_current_window"):null)},[i,s,c,N,m]);return e.jsxs("header",{className:V("flex items-center gap-3 bg-background pr-3",b?"pl-[5.5rem]":"pl-3",o?"h-12":g||"min-h-14"),style:I,children:[e.jsx(me.Suspense,{fallback:e.jsxs("button",{type:"button","aria-label":"Open session switcher",style:ee,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[e.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:y}),e.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[e.jsx("span",{className:"truncate",children:W}),R?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(J,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:R})]}):null]})]}),children:e.jsx(ct,{children:e.jsxs("button",{type:"button","aria-label":"Open session switcher",style:ee,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[e.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:y}),e.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[e.jsx("span",{className:"truncate",children:W}),R?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(J,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:R})]}):null]})]})})}),e.jsx("div",{className:"min-w-0 flex-1"}),S&&S.totalTokens>0?e.jsx(at,{totalTokens:S.totalTokens,percentage:pe,colorPercentage:S.percentage,contextLimit:S.contextLimit,outputLimit:S.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-4.5 w-4.5"}):null,e.jsx(de,{type:"button",variant:"ghost",size:"icon",onClick:fe,"aria-label":x?"Unpin Mini Chat window":"Pin Mini Chat window",title:x?"Unpin window":"Pin above other windows",style:ee,children:x?e.jsx(J,{name:"pushpin-2-fill",className:"h-4 w-4"}):e.jsx(J,{name:"pushpin-2",className:"h-4 w-4"})}),e.jsx(de,{type:"button",variant:"ghost",size:"icon",onClick:he,"aria-label":"Open session in main window",title:"Open in main window",style:ee,children:e.jsx(J,{name:"external-link",className:"h-4 w-4"})}),e.jsx(Fe,{visible:o})]})},ut=({mode:t,autoOpenDraft:s=!1,unavailable:n=!1})=>{const c=j(i=>i.currentSessionId);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[e.jsx(dt,{mode:t}),e.jsx("main",{className:"min-h-0 flex-1",children:n?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:e.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Session unavailable"}),e.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:"This session could not be loaded. It may have been deleted, archived, or opened from a different project context."})]})}):e.jsx(nt,{mode:"mini-chat",children:e.jsx(Le,{autoOpenDraft:s},c??"no-session")})})]})},mt=()=>{const t=ie(i=>i.shortcutOverrides),s=K(i=>i.currentDirectory),n=ae(i=>i.getActiveProject()),c=j(i=>i.openNewSessionDraft);a.useEffect(()=>{const i=l=>ve(l,t),u=l=>{if(U(l,i("focus_input"))){l.preventDefault(),ue();return}if(we()&&U(l,i("new_mini_chat"))){l.preventDefault(),Y("desktop_open_draft_mini_chat_window",{directory:s||n?.path||"",projectId:n?.id??null})?.catch(f=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",f)});return}if(U(l,i("new_chat"))){l.preventDefault(),c({selectedProjectId:n?.id??null,directoryOverride:s||n?.path||null,preserveDirectoryOverride:!!(s||n?.path)}),ue();return}if(U(l,i("open_model_selector"))){l.preventDefault();const{isModelSelectorOpen:f,setModelSelectorOpen:p}=ie.getState();p(!f);return}if(U(l,i("cycle_thinking_variant"))){if(P.getState().getCurrentModelVariants().length===0)return;l.preventDefault(),ze(1).catch(()=>{Ue.error("Couldn't update thinking")});return}const D=U(l,i("cycle_favorite_model_forward")),k=U(l,i("cycle_favorite_model_backward"));if(D||k){const{favoriteModels:f,addRecentModel:p}=ie.getState();if(f.length===0)return;l.preventDefault();const{currentProviderId:_,currentModelId:M,setProvider:O,setModel:x}=P.getState(),C=f.findIndex(o=>o.providerID===_&&o.modelID===M),b=f[(C+(D?1:-1)+f.length)%f.length];O(b.providerID),x(b.modelID),p(b.providerID,b.modelID)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n?.id,n?.path,s,c,t])},pt="pichamber:mini-chat-presence",ft=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,s=t.get("mode")==="session"?"session":"draft",n=t.get("sessionId")?.trim()||null,c=t.get("directory")?.trim()||null,i=t.get("projectId")?.trim()||null;return{mode:s,sessionId:n,directory:c,projectId:i}},ht=({config:t})=>{const s=ce(),n=K(o=>o.currentDirectory),c=K(o=>o.setDirectory),i=j(o=>o.currentSessionId),u=j(o=>!!o.newSessionDraft?.open),l=j(o=>o.newSessionDraft?.open?o.newSessionDraft.bootstrapPendingDirectory??o.newSessionDraft.directoryOverride??"":""),D=j(o=>o.setCurrentSession),k=j(o=>o.openNewSessionDraft),f=P(o=>o.initializeApp),p=P(o=>o.isInitialized),_=P(o=>o.isConnected),M=P(o=>o.loadProviders),O=P(o=>o.providers.length),x=Ye();a.useEffect(()=>{f()},[f]),a.useEffect(()=>{if(p)return;let o=!0,g=0;const m=window.setInterval(()=>{if(o){if(g+=1,g>10){window.clearInterval(m);return}P.getState().isInitialized||P.getState().initializeApp()}},1e3);return()=>{o=!1,window.clearInterval(m)}},[p]);const C=a.useRef(!1);a.useEffect(()=>{if(!C.current&&t.mode==="session"&&t.directory){if(n===t.directory){C.current=!0;return}c(t.directory,{showOverlay:!1}),C.current=!0}},[t.directory,t.mode,n,c]),a.useEffect(()=>{t.mode!=="draft"||!u||i||!l||n===l||c(l,{showOverlay:!1})},[t.mode,n,i,l,u,c]),a.useEffect(()=>{_&&O===0&&M({source:"electronMiniChat:recovery"})},[_,M,O]);const h=a.useRef(!1);a.useEffect(()=>{if(h.current||t.mode!=="session"||!t.sessionId)return;if(i===t.sessionId){h.current=!0;return}if(i){h.current=!0;return}const o=s.find(m=>m.id===t.sessionId);if(!o){x.ensureSessionRenderable(t.sessionId);return}const g=o.directory??t.directory;D(t.sessionId,g),h.current=!0},[t,i,s,D,x]),a.useEffect(()=>{const o=g=>{const m=g.detail,y=typeof m?.sessionId=="string"?m.sessionId.trim():"";if(!y||j.getState().currentSessionId===y)return;const q=typeof m?.directory=="string"&&m.directory.trim().length>0?m.directory.trim():s.find(w=>w.id===y)?.directory??null;x.ensureSessionRenderable(y),D(y,q),h.current=!0};return window.addEventListener("pichamber:open-session",o),()=>window.removeEventListener("pichamber:open-session",o)},[s,D,x]),a.useEffect(()=>{t.mode!=="draft"||u||i||k({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,i,u,k]);const b=a.useRef(!1);return a.useEffect(()=>{if(b.current||!p)return;const o=()=>{if(b.current)return;b.current=!0;const y=typeof document<"u"?document.getElementById("initial-loading"):null;y&&(y.classList.add("fade-out"),window.setTimeout(()=>y.remove(),300))},g=t.mode==="session"?i===t.sessionId:u,m=window.setTimeout(o,g?100:1500);return()=>window.clearTimeout(m)},[p,t.mode,t.sessionId,i,u]),null},xt=()=>{const t=j(n=>n.currentSessionId),s=K(n=>n.currentDirectory);return a.useEffect(()=>{if(!t||!s||typeof BroadcastChannel>"u")return;const n=new BroadcastChannel(pt),c=l=>{n.postMessage({type:"mini-chat-session-presence",sessionId:t,directory:s,viewed:l})};c(!0);const i=window.setInterval(()=>c(!0),5e3),u=()=>c(!1);return window.addEventListener("beforeunload",u),()=>{window.clearInterval(i),window.removeEventListener("beforeunload",u),c(!1),n.close()}},[s,t]),null},yt=t=>{const s=ce(),n=j(u=>u.currentSessionId),[c,i]=a.useState(!1);return a.useEffect(()=>{if(t.mode!=="session"||!t.sessionId||n===t.sessionId){i(!1);return}if(s.some(l=>l.id===t.sessionId)){i(!1);return}const u=window.setTimeout(()=>i(!0),5e3);return()=>window.clearTimeout(u)},[t.mode,t.sessionId,n,s]),c};function gt({apis:t}){const s=a.useMemo(()=>ft(),[]),n=K(c=>c.currentDirectory);return a.useEffect(()=>{const c=n||s.directory;c&&$e().focusProject(c,null)},[s.directory,n]),a.useEffect(()=>(le(t),()=>le(null)),[t]),We(),mt(),Se({enabled:!0}),e.jsx(He,{children:e.jsx(Ge,{directory:n||s.directory,children:e.jsxs(Ve,{apis:t,children:[e.jsx(Je,{}),e.jsx(Ke,{delayDuration:300,skipDelayDuration:150,children:e.jsxs("div",{className:"h-full text-foreground bg-background",children:[e.jsx(wt,{config:s}),e.jsx(qe,{}),e.jsx(Qe,{})]})})]})})})}const wt=({config:t})=>{const s=yt(t);return e.jsxs(e.Fragment,{children:[e.jsx(ht,{config:t}),e.jsx(xt,{}),e.jsx(Xe,{embeddedBackgroundWorkEnabled:!0}),e.jsx(ut,{mode:t.mode,autoOpenDraft:t.mode==="draft",unavailable:s})]})},vt=()=>{(async()=>{try{await Promise.all([be(),Ie()])}catch(t){console.error("[mini-chat-main] settings init failed:",t)}tt(),rt(),Ce()})()};function Kr(t){const s=t??je();if(!s)throw new Error("Runtime APIs not registered");vt();const n=document.getElementById("root");if(!n)throw new Error("Root element not found");ye.createRoot(n).render(e.jsx(me.StrictMode,{children:e.jsx(Ze,{children:e.jsx(et,{children:e.jsx(gt,{apis:s})})})}))}export{Kr as renderElectronMiniChatApp};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherDropdown-D1K-Lc7X.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-react-B5Z1Mdn3.js","assets/vendor-scheduler-7OC5HNn7.js","assets/useAppFontEffects-DVk3fjRp.js","assets/index-BOtRfXre.js","assets/vendor-zustand-GVb4H8HE.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BXgR2dKM.css","assets/vendor-base-ui-DXSHfszQ.js","assets/vendor-floating-ui-utils-BzXdqYpP.js","assets/vendor-floating-ui-dom-WyXykhNi.js","assets/vendor-floating-ui-core-CXmKXOXc.js","assets/vendor-floating-ui-react-dom-BZOGXAGe.js","assets/vendor-use-sync-external-store-D0AXkdQC.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-sonner-BDtm25td.js","assets/vendor-codemirror-view-Ct4T37Ue.js","assets/vendor-codemirror-state-CNWM3Q8V.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/runtimeSurface-CPm7KWaN.js","assets/vendor-dnd-kit-core-C9qcAm_1.js","assets/vendor-dnd-kit-utilities-DTY1C6ST.js","assets/vendor-dnd-kit-accessibility-DZKKhs9S.js","assets/vendor-dnd-kit-sortable-D8ozj8M-.js","assets/vendor-cmdk-zXx6sGnS.js","assets/vendor-radix-ui-react-dialog-D2yhEu2p.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-8xy6TJML.js","assets/vendor-radix-ui-react-context-CFsX-AUC.js","assets/vendor-radix-ui-react-id-D2kS9K1j.js","assets/vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js","assets/vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js","assets/vendor-radix-ui-react-dismissable-layer-DrorBNg9.js","assets/vendor-radix-ui-react-primitive-DkH8dMOR.js","assets/vendor-radix-ui-react-slot-BIDFZX0-.js","assets/vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js","assets/vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js","assets/vendor-radix-ui-react-focus-scope-D2BkImwt.js","assets/vendor-radix-ui-react-portal-YgCRIyi7.js","assets/vendor-radix-ui-react-presence-D432pCMB.js","assets/vendor-radix-ui-react-focus-guards-BfdFmL7c.js","assets/vendor-react-remove-scroll-vR1dy1aP.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-CSAHp1YF.js","assets/vendor-react-style-singleton-Ctw6HnYx.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-Vv4V8Nd1.js","assets/vendor-use-callback-ref-CVVuCyLj.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BByA_dGF.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-DuOEwJ3f.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-wd6iRebq.js","assets/vendor-codemirror-lang-json-CZ07HmNC.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-djiuoTi8.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CKHqhW5R.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-DtcZDGqe.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CpwyVWiC.js","assets/vendor-codemirror-lang-python-DzzokVau.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-CNlncqrr.js","assets/vendor-tanstack-react-virtual-2skouoFw.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/vendor-framer-motion-CfplGuM0.js","assets/vendor-motion-dom-DhJ-sYS5.js","assets/vendor-motion-utils-CKEGc_YG.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,R as a,r as me,e as ye}from"./vendor-react-B5Z1Mdn3.js";import"./vendor-katex-CNckGUMB.js";import{o as V,q as K,a1 as ge,C as Y,u as ie,aL as U,Q as we,U as ve,y as le,v as je,A as be}from"./index-BOtRfXre.js";import{u as Se,a as Ie,s as Ce}from"./usePushVisibilityBeacon-DfYl_CdQ.js";import{bD as Ne,I as J,aR as De,a2 as Pe,a3 as Me,a5 as Ee,bE as ke,bF as _e,e as j,b1 as Le,a as ae,x as P,an as ce,bG as Oe,aa as Te,ax as Re,bs as Ae,bg as Be,B as de,bw as Fe,bH as ue,bI as ze,t as Ue,g as $e,J as We,E as He,L as Ge,R as Ve,W as Je,T as Ke,M as qe,N as Qe,bJ as Xe,bt as Ye,U as Ze,V as et,X as tt,Y as rt}from"./useAppFontEffects-DVk3fjRp.js";import{_ as st}from"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zustand-GVb4H8HE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-base-ui-DXSHfszQ.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-floating-ui-react-dom-BZOGXAGe.js";import"./vendor-use-sync-external-store-D0AXkdQC.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-sonner-BDtm25td.js";import"./vendor-codemirror-view-Ct4T37Ue.js";import"./vendor-codemirror-state-CNWM3Q8V.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./runtimeSurface-CPm7KWaN.js";import"./vendor-dnd-kit-core-C9qcAm_1.js";import"./vendor-dnd-kit-utilities-DTY1C6ST.js";import"./vendor-dnd-kit-accessibility-DZKKhs9S.js";import"./vendor-dnd-kit-sortable-D8ozj8M-.js";import"./vendor-cmdk-zXx6sGnS.js";import"./vendor-radix-ui-react-dialog-D2yhEu2p.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-8xy6TJML.js";import"./vendor-radix-ui-react-context-CFsX-AUC.js";import"./vendor-radix-ui-react-id-D2kS9K1j.js";import"./vendor-radix-ui-react-use-layout-effect-C8Yrsaph.js";import"./vendor-radix-ui-react-use-controllable-state-LiqmKSXO.js";import"./vendor-radix-ui-react-dismissable-layer-DrorBNg9.js";import"./vendor-radix-ui-react-primitive-DkH8dMOR.js";import"./vendor-radix-ui-react-slot-BIDFZX0-.js";import"./vendor-radix-ui-react-use-callback-ref-BwDcSoGV.js";import"./vendor-radix-ui-react-use-escape-keydown-DTkqjenV.js";import"./vendor-radix-ui-react-focus-scope-D2BkImwt.js";import"./vendor-radix-ui-react-portal-YgCRIyi7.js";import"./vendor-radix-ui-react-presence-D432pCMB.js";import"./vendor-radix-ui-react-focus-guards-BfdFmL7c.js";import"./vendor-react-remove-scroll-vR1dy1aP.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-CSAHp1YF.js";import"./vendor-react-style-singleton-Ctw6HnYx.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-Vv4V8Nd1.js";import"./vendor-use-callback-ref-CVVuCyLj.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BByA_dGF.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-DuOEwJ3f.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-wd6iRebq.js";import"./vendor-codemirror-lang-json-CZ07HmNC.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-djiuoTi8.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CKHqhW5R.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-DtcZDGqe.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CpwyVWiC.js";import"./vendor-codemirror-lang-python-DzzokVau.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-CNlncqrr.js";import"./vendor-tanstack-react-virtual-2skouoFw.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-framer-motion-CfplGuM0.js";import"./vendor-motion-dom-DhJ-sYS5.js";import"./vendor-motion-utils-CKEGc_YG.js";const nt=({mode:t,children:s})=>e.jsx(Ne.Provider,{value:t,children:s}),ot=ke,it=_e,at=({totalTokens:t,percentage:s,colorPercentage:n,contextLimit:c,outputLimit:i,size:u="default",isMobile:l=!1,hideIcon:D=!1,showPercentIcon:k=!1,className:f,valueClassName:p,percentIconClassName:_,onClick:M,pressed:O=!1,cacheRead:x,cacheWrite:C,cacheHitPercent:h})=>{const[b,o]=a.useState(!1),g=typeof n=="number"?n:s,m=ot(s)??0,y=it(g),q=y==="critical"?"var(--status-error)":y==="warn"?"var(--status-warning)":"var(--status-success)",w=I=>I>=1e6?`${(I/1e6).toFixed(1)}M`:I>=1e3?`${(I/1e3).toFixed(1)}K`:I.toFixed(1).replace(/\.0$/,""),N=I=>I>=90?"text-status-error":I>=75?"text-status-warning":"text-status-success",E=20,$=3,W=(E-$)/2,se=2*Math.PI*W,Q=se*(1-m/100),R=typeof i=="number"?Math.max(i,0):0,A=typeof x=="number"&&typeof C=="number",Z=A?Math.max(0,x):0,B=A?Math.max(0,C):0,L=typeof h=="number"&&Number.isFinite(h),T=[`Used tokens: ${w(t)}`,`Context limit: ${w(c)}`,`Output limit: ${w(R)}`,...A?[`Cache read: ${w(Z)}`,`Cache write: ${w(B)}`]:[],...L?[`Cache hit: ${h.toFixed(1)}%`]:[],`${Math.min(s,999).toFixed(1)}% used`],F=!l&&typeof M=="function",v=e.jsxs(e.Fragment,{children:[!l&&!D&&e.jsx(J,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:V("font-medium inline-flex items-center gap-1.5",p),children:k?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{viewBox:`0 0 ${E} ${E}`,className:V("h-3.5 w-3.5 -rotate-90",_),role:"progressbar","aria-valuenow":Math.round(m),"aria-valuemin":0,"aria-valuemax":100,children:[e.jsx("circle",{cx:E/2,cy:E/2,r:W,fill:"none",stroke:"var(--interactive-border)",strokeWidth:$}),e.jsx("circle",{cx:E/2,cy:E/2,r:W,fill:"none",stroke:q,strokeWidth:$,strokeLinecap:"round",strokeDasharray:se,strokeDashoffset:Q,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),e.jsxs("span",{className:"text-foreground",children:[Math.min(s,999).toFixed(1),"%"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:N(g),children:Math.min(s,999).toFixed(1)}),"%"]})})]}),S=V("app-region-no-drag flex items-center gap-1.5 select-none",u==="compact"?"typography-micro":"typography-meta",F?V("rounded-md px-2 py-1.5 text-foreground transition-colors","hover:bg-interactive-hover","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"):"text-muted-foreground/60",f),H=F?e.jsx("button",{type:"button",className:S,"aria-label":"Context usage","aria-pressed":O,onClick:M,children:v}):e.jsx("div",{className:S,"aria-label":"Context usage",onClick:l?()=>o(!0):void 0,children:v});return l?e.jsxs(e.Fragment,{children:[H,e.jsx(De,{open:b,onClose:()=>o(!1),title:"Context Usage",children:e.jsx("div",{className:"flex flex-col gap-1.5",children:e.jsxs("div",{className:"rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Used tokens"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(t)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Context limit"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(c)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Output limit"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(R)})]}),A?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Cache read"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(Z)})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Cache write"}),e.jsx("span",{className:"typography-meta text-foreground font-medium",children:w(B)})]})]}):null,L?e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Cache hit"}),e.jsxs("span",{className:"typography-meta text-foreground font-medium",children:[h.toFixed(1),"%"]})]}):null,e.jsxs("div",{className:"flex justify-between items-center pt-1 border-t border-border/40",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Usage"}),e.jsxs("span",{className:V("typography-meta font-semibold",N(g)),children:[Math.min(s,999).toFixed(1),"%"]})]})]})})})]}):e.jsxs(Pe,{children:[e.jsx(Me,{asChild:!0,children:H}),e.jsx(Ee,{children:e.jsx("div",{className:"space-y-0.5",children:T.map(I=>e.jsx("p",{className:"typography-micro leading-tight",children:I},I))})})]})},ct=a.lazy(()=>st(()=>import("./SessionSwitcherDropdown-D1K-Lc7X.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])).then(t=>({default:t.SessionSwitcherDropdown}))),lt=t=>{const s=typeof t=="string"?t.trim():"";if(!s)return"";const n=typeof window<"u"?window.__PICHAMBER_HOME__:"";if(n&&s===n)return"~";if(n&&s.startsWith(`${n}/`))return`~/${s.slice(n.length+1)}`;const c=s.split("/").filter(Boolean);return c.length<=3?s:`.../${c.slice(-3).join("/")}`},re=t=>{const s=typeof t=="string"?t.trim():"";if(!s)return"";const n=s.replace(/\\/g,"/");return n==="/"?"/":n.replace(/\/+$/,"")},dt=({mode:t})=>{const s=j(r=>r.currentSessionId),n=j(r=>!!r.newSessionDraft?.open),c=j(r=>r.newSessionDraft?.selectedProjectId??null),i=K(r=>r.currentDirectory),u=ae(r=>r.projects),l=ae(r=>r.getActiveProject()),D=P(r=>r.getCurrentModel),k=P(r=>r.providers),f=ce(),p=Oe(s??""),_=Te(),M=Re(r=>r.ensureStatus),O=j(r=>r.newSessionDraft?.open?re(r.newSessionDraft.directoryOverride??""):""),[x,C]=a.useState(!1),h=typeof window<"u"?window.__PICHAMBER_MACOS_MAJOR__??0:0,b=Number.isFinite(h)&&h>0,o=Ae(),g=b?h>=26?"h-12":h<=15?"h-14":"":"",m=a.useMemo(()=>s?f.find(r=>r.id===s)??null:null,[s,f]);a.useEffect(()=>{ge()&&Y("desktop_get_window_pinned").then(r=>{typeof r?.pinned=="boolean"&&C(r.pinned)})},[]);const y=m?.title?.trim()||(n||t==="draft"?"New session":"Session"),q=re(m?.directory??null),w=re(i),N=q||O||w,E=lt(N);a.useEffect(()=>{N&&M(N,_.git).catch(()=>{})},[M,N,_.git]);const $=a.useMemo(()=>{const r=N;return r?u.map(d=>({...d,normalizedPath:re(d.path)})).filter(d=>d.normalizedPath&&(d.normalizedPath===r||r.startsWith(`${d.normalizedPath}/`))).sort((d,G)=>G.path.length-d.path.length)[0]??null:null},[N,u]),W=a.useMemo(()=>{const r=$??l;if(!r)return E||"PiChamber";const d=r.label?.trim();return d||(r.path.split(/[\\/]/).filter(Boolean).at(-1)??r.path)},[l,E,$]),Q=Be(N||null),R=Q&&Q!=="HEAD"?Q:null,A=D(),Z=a.useMemo(()=>{for(let r=p.length-1;r>=0;r-=1){const d=p[r];if(d.role!=="assistant"||typeof d.providerID!="string"||typeof d.modelID!="string")continue;const te=k.find(X=>X.id===d.providerID)?.models.find(X=>X.id===d.modelID);if(te)return te}},[p,k]),B=A?.limit?A:Z,L=B&&typeof B.limit=="object"&&B.limit!==null?B.limit:null,T=L&&typeof L.context=="number"?L.context:0,F=L&&typeof L.output=="number"?L.output:0,v=a.useMemo(()=>{if(!s||p.length===0)return null;let r,d;for(let ne=p.length-1;ne>=0;ne-=1){const oe=p[ne];if(oe.role!=="assistant")continue;const z=oe.tokens;if(!z)continue;if(z.input+z.output+z.reasoning+(z.cache?.read??0)+(z.cache?.write??0)>0){r=z,d=oe.id;break}}if(!r)return null;const G=r.input+r.output+r.reasoning+(r.cache?.read??0)+(r.cache?.write??0),te=T>0?T:2e5,X=T>0?Math.round(G/T*100):0,xe=F>0?Math.round(r.output/F*100):void 0;return{totalTokens:G,percentage:X,contextLimit:T||0,outputLimit:F||void 0,normalizedOutput:xe,thresholdLimit:te,lastMessageId:d}},[T,s,p,F]),[S,H]=a.useState(null),I={WebkitAppRegion:"drag"},ee={WebkitAppRegion:"no-drag"};a.useEffect(()=>{if(!s){H(r=>r===null?r:null);return}if(v&&v.totalTokens>0){H(r=>r&&r.totalTokens===v.totalTokens&&r.percentage===v.percentage&&r.contextLimit===v.contextLimit&&(r.outputLimit??0)===(v.outputLimit??0)&&(r.normalizedOutput??0)===(v.normalizedOutput??0)&&r.thresholdLimit===v.thresholdLimit&&r.lastMessageId===v.lastMessageId?r:v);return}H(r=>r===null?r:null)},[v,s]);const pe=S&&S.contextLimit>0?Math.min(999,S.totalTokens/S.contextLimit*100):0,fe=a.useCallback(()=>{const r=!x;C(r),Y("desktop_set_window_pinned",{pinned:r}).catch(()=>{C(!r)})},[x]),he=a.useCallback(()=>{const r=s?{sessionId:s,directory:m?.directory??i??""}:{mode:"draft",directory:N||i||"",projectId:c};Y("desktop_focus_main_window",r).then(d=>d?.focused===!0?Y("desktop_close_current_window"):null)},[i,s,c,N,m]);return e.jsxs("header",{className:V("flex items-center gap-3 bg-background pr-3",b?"pl-[5.5rem]":"pl-3",o?"h-12":g||"min-h-14"),style:I,children:[e.jsx(me.Suspense,{fallback:e.jsxs("button",{type:"button","aria-label":"Open session switcher",style:ee,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[e.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:y}),e.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[e.jsx("span",{className:"truncate",children:W}),R?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(J,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:R})]}):null]})]}),children:e.jsx(ct,{children:e.jsxs("button",{type:"button","aria-label":"Open session switcher",style:ee,className:"flex min-w-0 max-w-full flex-col items-start rounded-md px-1 py-0.5 text-left transition-colors hover:bg-interactive-hover/60 focus-visible:outline-none focus-visible:bg-interactive-hover/60",children:[e.jsx("span",{className:"truncate typography-ui-label text-[14px] font-normal leading-tight text-foreground max-w-full",children:y}),e.jsxs("span",{className:"flex min-w-0 max-w-full items-center gap-1.5 truncate typography-micro text-[10.5px] font-normal leading-tight text-muted-foreground/75",children:[e.jsx("span",{className:"truncate",children:W}),R?e.jsxs("span",{className:"inline-flex min-w-0 items-center gap-0.5",children:[e.jsx(J,{name:"git-branch",className:"h-3 w-3 flex-shrink-0 text-muted-foreground/70"}),e.jsx("span",{className:"truncate",children:R})]}):null]})]})})}),e.jsx("div",{className:"min-w-0 flex-1"}),S&&S.totalTokens>0?e.jsx(at,{totalTokens:S.totalTokens,percentage:pe,colorPercentage:S.percentage,contextLimit:S.contextLimit,outputLimit:S.outputLimit??0,className:"h-9 shrink-0 pl-1 pr-1 typography-ui-label",valueClassName:"font-semibold leading-none",hideIcon:!0,showPercentIcon:!0,percentIconClassName:"h-4.5 w-4.5"}):null,e.jsx(de,{type:"button",variant:"ghost",size:"icon",onClick:fe,"aria-label":x?"Unpin Mini Chat window":"Pin Mini Chat window",title:x?"Unpin window":"Pin above other windows",style:ee,children:x?e.jsx(J,{name:"pushpin-2-fill",className:"h-4 w-4"}):e.jsx(J,{name:"pushpin-2",className:"h-4 w-4"})}),e.jsx(de,{type:"button",variant:"ghost",size:"icon",onClick:he,"aria-label":"Open session in main window",title:"Open in main window",style:ee,children:e.jsx(J,{name:"external-link",className:"h-4 w-4"})}),e.jsx(Fe,{visible:o})]})},ut=({mode:t,autoOpenDraft:s=!1,unavailable:n=!1})=>{const c=j(i=>i.currentSessionId);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[e.jsx(dt,{mode:t}),e.jsx("main",{className:"min-h-0 flex-1",children:n?e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center typography-ui-label text-muted-foreground",children:e.jsxs("div",{className:"max-w-sm rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] px-4 py-3",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Session unavailable"}),e.jsx("div",{className:"mt-1 typography-small text-muted-foreground",children:"This session could not be loaded. It may have been deleted, archived, or opened from a different project context."})]})}):e.jsx(nt,{mode:"mini-chat",children:e.jsx(Le,{autoOpenDraft:s},c??"no-session")})})]})},mt=()=>{const t=ie(i=>i.shortcutOverrides),s=K(i=>i.currentDirectory),n=ae(i=>i.getActiveProject()),c=j(i=>i.openNewSessionDraft);a.useEffect(()=>{const i=l=>ve(l,t),u=l=>{if(U(l,i("focus_input"))){l.preventDefault(),ue();return}if(we()&&U(l,i("new_mini_chat"))){l.preventDefault(),Y("desktop_open_draft_mini_chat_window",{directory:s||n?.path||"",projectId:n?.id??null})?.catch(f=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",f)});return}if(U(l,i("new_chat"))){l.preventDefault(),c({selectedProjectId:n?.id??null,directoryOverride:s||n?.path||null,preserveDirectoryOverride:!!(s||n?.path)}),ue();return}if(U(l,i("open_model_selector"))){l.preventDefault();const{isModelSelectorOpen:f,setModelSelectorOpen:p}=ie.getState();p(!f);return}if(U(l,i("cycle_thinking_variant"))){if(P.getState().getCurrentModelVariants().length===0)return;l.preventDefault(),ze(1).catch(()=>{Ue.error("Couldn't update thinking")});return}const D=U(l,i("cycle_favorite_model_forward")),k=U(l,i("cycle_favorite_model_backward"));if(D||k){const{favoriteModels:f,addRecentModel:p}=ie.getState();if(f.length===0)return;l.preventDefault();const{currentProviderId:_,currentModelId:M,setProvider:O,setModel:x}=P.getState(),C=f.findIndex(o=>o.providerID===_&&o.modelID===M),b=f[(C+(D?1:-1)+f.length)%f.length];O(b.providerID),x(b.modelID),p(b.providerID,b.modelID)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n?.id,n?.path,s,c,t])},pt="pichamber:mini-chat-presence",ft=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,s=t.get("mode")==="session"?"session":"draft",n=t.get("sessionId")?.trim()||null,c=t.get("directory")?.trim()||null,i=t.get("projectId")?.trim()||null;return{mode:s,sessionId:n,directory:c,projectId:i}},ht=({config:t})=>{const s=ce(),n=K(o=>o.currentDirectory),c=K(o=>o.setDirectory),i=j(o=>o.currentSessionId),u=j(o=>!!o.newSessionDraft?.open),l=j(o=>o.newSessionDraft?.open?o.newSessionDraft.bootstrapPendingDirectory??o.newSessionDraft.directoryOverride??"":""),D=j(o=>o.setCurrentSession),k=j(o=>o.openNewSessionDraft),f=P(o=>o.initializeApp),p=P(o=>o.isInitialized),_=P(o=>o.isConnected),M=P(o=>o.loadProviders),O=P(o=>o.providers.length),x=Ye();a.useEffect(()=>{f()},[f]),a.useEffect(()=>{if(p)return;let o=!0,g=0;const m=window.setInterval(()=>{if(o){if(g+=1,g>10){window.clearInterval(m);return}P.getState().isInitialized||P.getState().initializeApp()}},1e3);return()=>{o=!1,window.clearInterval(m)}},[p]);const C=a.useRef(!1);a.useEffect(()=>{if(!C.current&&t.mode==="session"&&t.directory){if(n===t.directory){C.current=!0;return}c(t.directory,{showOverlay:!1}),C.current=!0}},[t.directory,t.mode,n,c]),a.useEffect(()=>{t.mode!=="draft"||!u||i||!l||n===l||c(l,{showOverlay:!1})},[t.mode,n,i,l,u,c]),a.useEffect(()=>{_&&O===0&&M({source:"electronMiniChat:recovery"})},[_,M,O]);const h=a.useRef(!1);a.useEffect(()=>{if(h.current||t.mode!=="session"||!t.sessionId)return;if(i===t.sessionId){h.current=!0;return}if(i){h.current=!0;return}const o=s.find(m=>m.id===t.sessionId);if(!o){x.ensureSessionRenderable(t.sessionId);return}const g=o.directory??t.directory;D(t.sessionId,g),h.current=!0},[t,i,s,D,x]),a.useEffect(()=>{const o=g=>{const m=g.detail,y=typeof m?.sessionId=="string"?m.sessionId.trim():"";if(!y||j.getState().currentSessionId===y)return;const q=typeof m?.directory=="string"&&m.directory.trim().length>0?m.directory.trim():s.find(w=>w.id===y)?.directory??null;x.ensureSessionRenderable(y),D(y,q),h.current=!0};return window.addEventListener("pichamber:open-session",o),()=>window.removeEventListener("pichamber:open-session",o)},[s,D,x]),a.useEffect(()=>{t.mode!=="draft"||u||i||k({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,i,u,k]);const b=a.useRef(!1);return a.useEffect(()=>{if(b.current||!p)return;const o=()=>{if(b.current)return;b.current=!0;const y=typeof document<"u"?document.getElementById("initial-loading"):null;y&&(y.classList.add("fade-out"),window.setTimeout(()=>y.remove(),300))},g=t.mode==="session"?i===t.sessionId:u,m=window.setTimeout(o,g?100:1500);return()=>window.clearTimeout(m)},[p,t.mode,t.sessionId,i,u]),null},xt=()=>{const t=j(n=>n.currentSessionId),s=K(n=>n.currentDirectory);return a.useEffect(()=>{if(!t||!s||typeof BroadcastChannel>"u")return;const n=new BroadcastChannel(pt),c=l=>{n.postMessage({type:"mini-chat-session-presence",sessionId:t,directory:s,viewed:l})};c(!0);const i=window.setInterval(()=>c(!0),5e3),u=()=>c(!1);return window.addEventListener("beforeunload",u),()=>{window.clearInterval(i),window.removeEventListener("beforeunload",u),c(!1),n.close()}},[s,t]),null},yt=t=>{const s=ce(),n=j(u=>u.currentSessionId),[c,i]=a.useState(!1);return a.useEffect(()=>{if(t.mode!=="session"||!t.sessionId||n===t.sessionId){i(!1);return}if(s.some(l=>l.id===t.sessionId)){i(!1);return}const u=window.setTimeout(()=>i(!0),5e3);return()=>window.clearTimeout(u)},[t.mode,t.sessionId,n,s]),c};function gt({apis:t}){const s=a.useMemo(()=>ft(),[]),n=K(c=>c.currentDirectory);return a.useEffect(()=>{const c=n||s.directory;c&&$e().focusProject(c,null)},[s.directory,n]),a.useEffect(()=>(le(t),()=>le(null)),[t]),We(),mt(),Se({enabled:!0}),e.jsx(He,{children:e.jsx(Ge,{directory:n||s.directory,children:e.jsxs(Ve,{apis:t,children:[e.jsx(Je,{}),e.jsx(Ke,{delayDuration:300,skipDelayDuration:150,children:e.jsxs("div",{className:"h-full text-foreground bg-background",children:[e.jsx(wt,{config:s}),e.jsx(qe,{}),e.jsx(Qe,{})]})})]})})})}const wt=({config:t})=>{const s=yt(t);return e.jsxs(e.Fragment,{children:[e.jsx(ht,{config:t}),e.jsx(xt,{}),e.jsx(Xe,{embeddedBackgroundWorkEnabled:!0}),e.jsx(ut,{mode:t.mode,autoOpenDraft:t.mode==="draft",unavailable:s})]})},vt=()=>{(async()=>{try{await Promise.all([be(),Ie()])}catch(t){console.error("[mini-chat-main] settings init failed:",t)}tt(),rt(),Ce()})()};function Kr(t){const s=t??je();if(!s)throw new Error("Runtime APIs not registered");vt();const n=document.getElementById("root");if(!n)throw new Error("Root element not found");ye.createRoot(n).render(e.jsx(me.StrictMode,{children:e.jsx(Ze,{children:e.jsx(et,{children:e.jsx(gt,{apis:s})})})}))}export{Kr as renderElectronMiniChatApp};