@pi-chamber/web 1.0.4-rc.1 → 1.0.4-rc.4

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 (168) hide show
  1. package/dist/assets/DiagramView--BGR3PRZ.js +1 -0
  2. package/dist/assets/{DiffView-BjWUdbL5.js → DiffView-hz90_htv.js} +5 -5
  3. package/dist/assets/FileSaveConflictDialog-CcrWHRvd.js +3 -0
  4. package/dist/assets/{FilesView-qP1ypN9J.js → FilesView-DaqkPMqx.js} +4 -4
  5. package/dist/assets/{GitHubDetailScaffold-zCKCy5OJ.js → GitHubDetailScaffold-BZhP67Va.js} +2 -2
  6. package/dist/assets/GitHubLinkPicker-CJZmDljp.js +1 -0
  7. package/dist/assets/{GitHubListPrimitives-Ck3zllel.js → GitHubListPrimitives-DhF42guB.js} +1 -1
  8. package/dist/assets/{GitView-y2k2i4gR.js → GitView-JK-QCK9R.js} +4 -4
  9. package/dist/assets/{IssuesSurface-HWgR87N3.js → IssuesSurface-CAqQzrsv.js} +3 -3
  10. package/dist/assets/{JsonTreeView-DSuC4naV.js → JsonTreeView-CKTqB1CD.js} +1 -1
  11. package/dist/assets/MarkdownRendererImpl-B5kJy9Nt.js +12 -0
  12. package/dist/assets/{PatchDiff-DArTeWeK.js → PatchDiff-BQnRFN30.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-DQKujzLb.js → PierreDiffViewer-BeGpdI0x.js} +2 -2
  14. package/dist/assets/PullRequestsSurface-D9beq2x9.js +2 -0
  15. package/dist/assets/SessionSwitcherContent-DElQ_cjm.js +1 -0
  16. package/dist/assets/SessionSwitcherDropdown-JaIDcDIj.js +2 -0
  17. package/dist/assets/SessionUnreadDot-Czfvjbdi.js +1 -0
  18. package/dist/assets/SettingsView-C_GC1Mx3.js +6 -0
  19. package/dist/assets/SettingsWindow-CAxKgYOu.js +1 -0
  20. package/dist/assets/ToolOutputDialog-lz5exVQ4.js +8 -0
  21. package/dist/assets/ToolPartDiffPreview-nIUiNLpP.js +1 -0
  22. package/dist/assets/{VirtualizedFileDiff-D6KbvKc6.js → VirtualizedFileDiff-IWqCJNXu.js} +1 -1
  23. package/dist/assets/{Virtualizer-wpC51ZBQ.js → Virtualizer-Cp_cJWbI.js} +1 -1
  24. package/dist/assets/{collapsible-DhV9d4dT.js → collapsible-C7oyikVm.js} +1 -1
  25. package/dist/assets/{computeVirtualFileMetrics-CeMpF2xC.js → computeVirtualFileMetrics-CyhUKEfv.js} +1 -1
  26. package/dist/assets/{contextFileOpenGuard-Ck5u_kAP.js → contextFileOpenGuard-DkjmJ-NU.js} +1 -1
  27. package/dist/assets/{gitStatusPredicates-DEBSqUNE.js → gitStatusPredicates-DBmUY3kA.js} +1 -1
  28. package/dist/assets/{githubLink-DT7i2NlH.js → githubLink-BdbPMMAK.js} +5 -5
  29. package/dist/assets/index-BnZVqcki.js +11 -0
  30. package/dist/assets/index-BnieExes.css +1 -0
  31. package/dist/assets/index-CKgYIOis.js +1 -0
  32. package/dist/assets/{main-BczEScAA.js → main-6YKi4QM2.js} +2 -2
  33. package/dist/assets/{main-CHLNMYeJ.js → main-CWdWdhdL.js} +8 -8
  34. package/dist/assets/{markdownCore-C4Gk5Zht.js → markdownCore-D7V46WY9.js} +1 -1
  35. package/dist/assets/miniChat-PanPmbEK.js +2 -0
  36. package/dist/assets/mobile-0LY-2fxw.js +2 -0
  37. package/dist/assets/nativeFileSave-BzhtrDoD.js +1 -0
  38. package/dist/assets/{pi-session-focus-preference-LDVCJ_YR.js → pi-session-focus-preference-BC-ze1oC.js} +4 -4
  39. package/dist/assets/{renderDiffWithHighlighter-CDsgOnkH.js → renderDiffWithHighlighter-ByZtK9za.js} +1 -1
  40. package/dist/assets/renderElectronMiniChatApp-DETQLjFi.js +2 -0
  41. package/dist/assets/{renderFileWithHighlighter-TpKRyfCY.js → renderFileWithHighlighter-CnN0Tv_8.js} +1 -1
  42. package/dist/assets/renderMobileApp-DS0FDQLg.js +11 -0
  43. package/dist/assets/runtimeEndpointReset-BqqXMwE9.js +62 -0
  44. package/dist/assets/{runtimeSurface-DW_Ia4q3.js → runtimeSurface-DBiUWYK2.js} +1 -1
  45. package/dist/assets/useAppFontEffects-BisjofNZ.js +212 -0
  46. package/dist/assets/{useFilesViewSearch-C_LzYIgD.js → useFilesViewSearch-BWABG6pS.js} +3 -3
  47. package/dist/assets/{useGitHubRemoteSearch-DsxWOzKZ.js → useGitHubRemoteSearch-Bsf2YeQP.js} +1 -1
  48. package/dist/assets/{useSwitcherItems-BmoCnS9W.js → useSwitcherItems-BSTSev5C.js} +1 -1
  49. package/dist/assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js +1 -0
  50. package/dist/assets/{vendor-base-ui-DIkTOIJS.js → vendor-base-ui-BscvGUFt.js} +1 -1
  51. package/dist/assets/vendor-boot-Dgb9NVFe.js +69 -0
  52. package/dist/assets/vendor-capacitor-app-BjdQVib9.js +1 -0
  53. package/dist/assets/vendor-capacitor-keyboard-eTtI5go3.js +1 -0
  54. package/dist/assets/vendor-capacitor-push-notifications-CBKq2Arn.js +1 -0
  55. package/dist/assets/vendor-capacitor-status-bar-9rNIGxlO.js +1 -0
  56. package/dist/assets/{vendor-codemirror-autocomplete-DsFn4GLp.js → vendor-codemirror-autocomplete-DxS3jwvE.js} +1 -1
  57. package/dist/assets/{vendor-codemirror-lang-angular-B_NMmBbS.js → vendor-codemirror-lang-angular-DdjXl9e2.js} +1 -1
  58. package/dist/assets/vendor-codemirror-lang-cpp--aMr7NVt.js +1 -0
  59. package/dist/assets/vendor-codemirror-lang-css-CZ_qxZY9.js +1 -0
  60. package/dist/assets/{vendor-codemirror-lang-go-C2KHbcll.js → vendor-codemirror-lang-go-Ca-y2Alu.js} +2 -2
  61. package/dist/assets/vendor-codemirror-lang-html-COZ0L5wT.js +1 -0
  62. package/dist/assets/vendor-codemirror-lang-java-D3Rf3QNJ.js +1 -0
  63. package/dist/assets/{vendor-codemirror-lang-javascript-DpTUrvx8.js → vendor-codemirror-lang-javascript-DwJ-IvCs.js} +2 -2
  64. package/dist/assets/vendor-codemirror-lang-jinja-D_5lod6k.js +1 -0
  65. package/dist/assets/vendor-codemirror-lang-json-BG8C7OpC.js +1 -0
  66. package/dist/assets/vendor-codemirror-lang-less-CVEkoaTw.js +1 -0
  67. package/dist/assets/vendor-codemirror-lang-liquid-U9vj0m8w.js +1 -0
  68. package/dist/assets/vendor-codemirror-lang-markdown-DqlYH9gY.js +1 -0
  69. package/dist/assets/vendor-codemirror-lang-php-BFEiEVA1.js +1 -0
  70. package/dist/assets/vendor-codemirror-lang-python-Cz1dQXQd.js +3 -0
  71. package/dist/assets/vendor-codemirror-lang-rust-C_CoD9mj.js +1 -0
  72. package/dist/assets/vendor-codemirror-lang-sass-BuR0aKh5.js +1 -0
  73. package/dist/assets/{vendor-codemirror-lang-sql-C_RazIaB.js → vendor-codemirror-lang-sql-DggNUjdM.js} +2 -2
  74. package/dist/assets/{vendor-codemirror-lang-vue-BYL0r7KR.js → vendor-codemirror-lang-vue-DFZHi2J3.js} +1 -1
  75. package/dist/assets/vendor-codemirror-lang-wast-zuTN3SHT.js +1 -0
  76. package/dist/assets/vendor-codemirror-lang-xml-CrcvhI-k.js +1 -0
  77. package/dist/assets/vendor-codemirror-lang-yaml-DcVWsakb.js +1 -0
  78. package/dist/assets/{vendor-codemirror-language-data-DglcKYWT.js → vendor-codemirror-language-data-CCLITgCF.js} +2 -2
  79. package/dist/assets/{vendor-codemirror-search-DaE6R5gH.js → vendor-codemirror-search-H7NOEdbX.js} +2 -2
  80. package/dist/assets/{vendor-lezer-cpp-Dt99h3WT.js → vendor-lezer-cpp-C8aD2KAr.js} +1 -1
  81. package/dist/assets/{vendor-lezer-css-DNU_fzPI.js → vendor-lezer-css-2lbTJF-Y.js} +1 -1
  82. package/dist/assets/{vendor-lezer-go-BEFtcNyS.js → vendor-lezer-go-Bw6LFTrZ.js} +1 -1
  83. package/dist/assets/{vendor-lezer-html-DDGRhRUz.js → vendor-lezer-html-D7ym2z7S.js} +1 -1
  84. package/dist/assets/{vendor-lezer-java-DmfZtW09.js → vendor-lezer-java-CZhK7w21.js} +1 -1
  85. package/dist/assets/{vendor-lezer-javascript-oje4tdp_.js → vendor-lezer-javascript-rpKeTHZp.js} +1 -1
  86. package/dist/assets/{vendor-lezer-json-BRXb_bDX.js → vendor-lezer-json-C7jwsd2G.js} +1 -1
  87. package/dist/assets/{vendor-lezer-lr-BU2qmu_5.js → vendor-lezer-lr-DR-ylqNN.js} +1 -1
  88. package/dist/assets/{vendor-lezer-markdown-CicYv7V9.js → vendor-lezer-markdown-Bir0m5nB.js} +1 -1
  89. package/dist/assets/{vendor-lezer-php-COORrTpE.js → vendor-lezer-php-y0hIEfo1.js} +1 -1
  90. package/dist/assets/{vendor-lezer-python-Cuvm9X9Y.js → vendor-lezer-python-D64A9lNV.js} +1 -1
  91. package/dist/assets/{vendor-lezer-rust-C_zOfHbX.js → vendor-lezer-rust-E3ZA9T2L.js} +1 -1
  92. package/dist/assets/{vendor-lezer-sass-DWP4w7O1.js → vendor-lezer-sass-C5UFI9SP.js} +1 -1
  93. package/dist/assets/{vendor-lezer-xml-Br6nOYeG.js → vendor-lezer-xml-DOy7FzCR.js} +1 -1
  94. package/dist/assets/{vendor-lezer-yaml-CYQmm6Sb.js → vendor-lezer-yaml-kEjaSCvZ.js} +1 -1
  95. package/dist/assets/{vendor-replit-codemirror-vim-CZy3BUVv.js → vendor-replit-codemirror-vim-BLfh0LPy.js} +1 -1
  96. package/dist/assets/{web-components-CH3-XV-n.js → web-components-CdMfsnXE.js} +1 -1
  97. package/dist/index.html +4 -4
  98. package/dist/mini-chat.html +3 -3
  99. package/dist/mobile.html +3 -3
  100. package/package.json +2 -2
  101. package/server/lib/pi/routes.js +1 -0
  102. package/server/lib/pi/session-daemon/DOCUMENTATION.md +22 -9
  103. package/server/lib/pi/session-daemon/builtin-extensions.js +37 -0
  104. package/server/lib/pi/session-daemon/daemon-process.js +6 -0
  105. package/server/lib/pi/session-daemon/extension-theme.js +75 -0
  106. package/server/lib/pi/session-daemon/extension-theme.test.js +47 -0
  107. package/server/lib/pi/session-daemon/prompt-operations.test.js +3 -3
  108. package/server/lib/pi/session-daemon/prompt-preflight.test.js +12 -14
  109. package/server/lib/pi/session-daemon/sdk-upgrade.test.js +118 -2
  110. package/server/lib/pi/session-daemon/send-operation-dedup.test.js +1 -1
  111. package/server/lib/pi/session-daemon/session-daemon-extensions.test.js +1 -1
  112. package/server/lib/pi/session-daemon/session-daemon-mcp.e2e.test.js +638 -0
  113. package/server/lib/pi/session-daemon/session-daemon-turn.e2e.test.js +437 -0
  114. package/server/lib/pi/session-daemon/session-daemon.js +61 -42
  115. package/server/lib/pi/session-daemon/session-daemon.test.js +53 -5
  116. package/server/lib/pi/session-daemon/session-idle-residency.test.js +1 -1
  117. package/server/lib/pi/session-daemon/session-replay.test.js +1 -1
  118. package/server/lib/pi/session-daemon/supervisor.js +13 -1
  119. package/server/lib/pi/session-daemon/supervisor.test.js +92 -0
  120. package/server/lib/pi/session-persistence-gap.test.js +2 -3
  121. package/server/lib/pi/ui-settings-store.js +1 -0
  122. package/server/lib/pi/ui-settings-store.test.js +27 -0
  123. package/server/lib/relay/DOCUMENTATION.md +4 -0
  124. package/server/lib/terminal/DOCUMENTATION.md +1 -0
  125. package/dist/assets/DiagramView-DfZMQkXY.js +0 -1
  126. package/dist/assets/FileSaveConflictDialog-u5L4k_5k.js +0 -3
  127. package/dist/assets/GitHubLinkPicker-CwxKY3lN.js +0 -1
  128. package/dist/assets/MarkdownRendererImpl-CT5ln9em.js +0 -12
  129. package/dist/assets/PullRequestsSurface-Cfb1wSvC.js +0 -2
  130. package/dist/assets/SessionSwitcherContent-DEGJyZBl.js +0 -1
  131. package/dist/assets/SessionSwitcherDropdown-cC9wVBH7.js +0 -2
  132. package/dist/assets/SessionUnreadDot-CELKNVIM.js +0 -1
  133. package/dist/assets/SettingsView-CZvRRgJe.js +0 -6
  134. package/dist/assets/SettingsWindow-CZM1dmVb.js +0 -1
  135. package/dist/assets/ToolOutputDialog-DClOSbJc.js +0 -8
  136. package/dist/assets/ToolPartDiffPreview-BaFiGUDE.js +0 -1
  137. package/dist/assets/index-6IO1AcJI.js +0 -10
  138. package/dist/assets/index-BAmzAlNx.css +0 -1
  139. package/dist/assets/index-eDf4LKLY.js +0 -1
  140. package/dist/assets/miniChat-Do3hE87Z.js +0 -2
  141. package/dist/assets/mobile-CTnihwfa.js +0 -2
  142. package/dist/assets/renderElectronMiniChatApp-DSa3gYqR.js +0 -2
  143. package/dist/assets/renderMobileApp-CPE-3uMl.js +0 -11
  144. package/dist/assets/runtimeEndpointReset-CzJfovWI.js +0 -62
  145. package/dist/assets/useAppFontEffects-CG3_yteE.js +0 -212
  146. package/dist/assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js +0 -1
  147. package/dist/assets/vendor-boot-DyL2td56.js +0 -69
  148. package/dist/assets/vendor-capacitor-app-BrDJj9I_.js +0 -1
  149. package/dist/assets/vendor-capacitor-core-B4EWRrHz.js +0 -1
  150. package/dist/assets/vendor-capacitor-keyboard-CYccoJjr.js +0 -1
  151. package/dist/assets/vendor-capacitor-push-notifications-KNe1zSBF.js +0 -1
  152. package/dist/assets/vendor-capacitor-status-bar-B-N0EOVk.js +0 -1
  153. package/dist/assets/vendor-codemirror-lang-cpp-GOE7Gjd0.js +0 -1
  154. package/dist/assets/vendor-codemirror-lang-css-Dwf2XpnZ.js +0 -1
  155. package/dist/assets/vendor-codemirror-lang-html-DcKqyeGk.js +0 -1
  156. package/dist/assets/vendor-codemirror-lang-java-6eGbyB2k.js +0 -1
  157. package/dist/assets/vendor-codemirror-lang-jinja-xSUJjXhr.js +0 -1
  158. package/dist/assets/vendor-codemirror-lang-json-CLGxdOCz.js +0 -1
  159. package/dist/assets/vendor-codemirror-lang-less-6nXi1rS9.js +0 -1
  160. package/dist/assets/vendor-codemirror-lang-liquid-B9hmb9P8.js +0 -1
  161. package/dist/assets/vendor-codemirror-lang-markdown-DmFP9s6x.js +0 -1
  162. package/dist/assets/vendor-codemirror-lang-php-DC6To8iX.js +0 -1
  163. package/dist/assets/vendor-codemirror-lang-python-yuxIkjit.js +0 -3
  164. package/dist/assets/vendor-codemirror-lang-rust-di1Sjz-0.js +0 -1
  165. package/dist/assets/vendor-codemirror-lang-sass-BWpV9NPV.js +0 -1
  166. package/dist/assets/vendor-codemirror-lang-wast-BiVarhcz.js +0 -1
  167. package/dist/assets/vendor-codemirror-lang-xml-Cn1lY1ts.js +0 -1
  168. package/dist/assets/vendor-codemirror-lang-yaml-BZ6mZw9L.js +0 -1
@@ -1,2 +1,2 @@
1
- import{_ as E}from"./vendor-vite-runtime-DD1OZmLC.js";import{g as v,B as $}from"./vendor-marked-CX41MkDF.js";import{p}from"./vendor-dompurify-r8glNMJW.js";import{df as C,dg as O,dh as I}from"./useAppFontEffects-CG3_yteE.js";import{p as P}from"./vendor-remend-BWYYytN3.js";const R=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),x=["script","style"],A=e=>v.lexer(e),H=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),D=e=>{const t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;const n=t[1];if(!n)return!1;const r=n[0],s=n.length,a=e.trimEnd().split(`
1
+ import{_ as E}from"./vendor-vite-runtime-DD1OZmLC.js";import{g as v,B as $}from"./vendor-marked-CX41MkDF.js";import{p}from"./vendor-dompurify-r8glNMJW.js";import{df as C,dg as O,dh as I}from"./useAppFontEffects-BisjofNZ.js";import{p as P}from"./vendor-remend-BWYYytN3.js";const R=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),x=["script","style"],A=e=>v.lexer(e),H=e=>/^\[[^\]]+\]:\s+\S+/m.test(e)||/^\[\^[^\]]+\]:\s+/m.test(e),D=e=>{const t=e.match(/^[ \t]{0,3}(`{3,}|~{3,})/);if(!t)return!1;const n=t[1];if(!n)return!1;const r=n[0],s=n.length,a=e.trimEnd().split(`
2
2
  `).at(-1)?.trim()??"";return!new RegExp(`^[\\t ]{0,3}${r}{${s},}[\\t ]*$`).test(a)},pe=e=>{const t=e.replace(/^\n+/,"");return!!(/^[ \t]{0,3}(`{3,}|~{3,})/.test(t)||/^[ \t]{0,3}(?:> |[-*+] |\d+[.)] )/.test(t))},N=e=>{try{return P(e,{linkMode:"text-only"})}catch{return e}},g=(e,t)=>[{raw:e,src:e,mode:t?"live":"full",highlight:!t}],y=(e,t)=>{let n=-1;for(let s=e.length-1;s>=0;s-=1)if(e[s]?.type!=="space"){n=s;break}if(n<0)return[];const r=[];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===n,o=a.type==="code"&&D(i);r.push({raw:i,src:o||c?i:N(i),mode:c?"live":"full",highlight:!t.cheap&&!o})}return r},b=(e,t,n=A)=>[{raw:e,src:e,mode:"full",highlight:!0}],F=2;class G{constructor(t=A){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 n=t.slice(this.frozenSrc.length);let r;try{r=this.lex(n)}catch{return this.cached=g(t,!0),this.cached}const s=[];for(let o=0;o<r.length;o+=1)r[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=r.slice(0,o),d=y(l,{markLastLive:!1,cheap:!0});this.frozenBlocks=[...this.frozenBlocks,...d],this.frozenSrc+=l.map(m=>m.raw??"").join(""),r=r.slice(o)}const i=y(r,{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 j=32,h=new Map,q=e=>{const t=h.get(e);if(t)return h.delete(e),h.set(e,t),t;const n=new G;for(h.set(e,n);h.size>j;){const r=h.keys().next().value;if(typeof r!="string")break;h.delete(r)}return n},_=e=>{h.delete(e)},me=(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 r=0;r<t.length-1;r+=1){const s=e[r],a=t[r];if(!s||!a||s.mode!=="full"||a.mode!=="full"||s.raw!==a.raw)return!1}return!0},u=e=>e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");let k=null;const W=()=>(k||(k=E(()=>import("./vendor-katex-DZG0Ov6p.js"),[]).then(e=>e.default??e)),k),w=async(e,t,n)=>{try{return(await W()).renderToString(e,{displayMode:n,throwOnError:!1})}catch{return t}},B={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]??""}},async renderer(e){const t=e;return w(t.text,t.raw,!1)}},T={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]??""}},async renderer(e){const t=e;return w(t.text,t.raw,!0)}},U={html({text:e}){return R(e)},link({href:e,title:t,text:n}){const r=e??"";if(C(r))return`<span data-pichamber-agent-mention="true" class="text-primary">${n}</span>`;const a=O(r);if(a)return`<a href="${u(r)}" data-skill-name="${u(a)}" class="text-primary hover:underline">${n}</a>`;const i=t?` title="${u(t)}"`:"";return`<a href="${u(r)}"${i} class="external-link" target="_blank" rel="noopener noreferrer">${n}</a>`}},S={gfm:!0,breaks:!1,renderer:U},X=new $(S),V=new $({...S,async:!0,extensions:[B,T]});v.use({...S,extensions:[B,T]});const Z=async e=>{const t=e.split(/(\$\$[\s\S]*?\$\$)/g);return(await Promise.all(t.map(async r=>{const s=/^\$\$([\s\S]*?)\$\$$/.exec(r)?.[1];return s===void 0?r:w(s,r,!0)}))).join("")},J=async e=>{if(e.indexOf("$")===-1)return e;const t=/(<(?:pre|code|kbd)[^>]*>[\s\S]*?<\/(?:pre|code|kbd)>)/gi,n=e.split(t);return(await Promise.all(n.map(async(s,a)=>a%2===1?s:Z(s)))).join("")},Q=/<pre><code(?:\s+class="language-([^"]*)")?>([\s\S]*?)<\/code><\/pre>/g,Y=1200,K=(e,t)=>{let n=1;for(let r=0;r<e.length;r+=1)if(e.charCodeAt(r)===10&&++n>t)return!0;return!1},ee=e=>e.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&amp;/g,"&"),te=async e=>{const t=[...e.matchAll(Q)];if(t.length===0)return e;const n=Y;let r=e;for(const s of t){const[a,i,c]=s,o=(i||"text").toLowerCase();if(o==="mermaid")continue;const l=ee(c??"");if(K(l,n)){r=r.replace(a,()=>a.replace("<pre",`<pre data-md-lang="${o}"`));continue}const d=await I(l,o);if(d){const m=d.replace(/^<pre/,`<pre data-md-lang="${o}"`);r=r.replace(a,()=>m)}}return r},re={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:[...x],FORBID_CONTENTS:[...x]};let z=!1;const ne=()=>{z||typeof window>"u"||!p.isSupported||(z=!0,p.addHook("afterSanitizeAttributes",e=>{e instanceof HTMLAnchorElement&&e.target==="_blank"&&e.setAttribute("rel","noopener noreferrer")}))},L=e=>p.isSupported?(ne(),p.sanitize(e,re)):"",se=240,f=new Map,ae=e=>{let t=2166136261;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)},M=(e,t)=>{if(f.delete(e),f.set(e,t),f.size<=se)return;const n=f.keys().next().value;n&&f.delete(n)},oe=async e=>{const t=await V.parse(e.src),n=e.highlight?await J(t):t,r=e.highlight?await te(n):n;return L(r)},ie=e=>{if(!e)return"";const t=X.parse(e);return L(t)},ce=async(e,t,n)=>{if(!e)return n&&_(n),[];let r;return t?r=q(n).update(e):(_(n),r=b(e)),Promise.all(r.map(async(s,a)=>{if(s.mode==="live")return{id:`live:${a}`,html:"",mode:"live",raw:s.raw};const i=ae(s.raw),c=`${i}:${s.mode}:${s.highlight?1:0}`,o=`${n}:${a}:${s.mode}`,l=f.get(o);if(l&&l.hash===i)return M(o,l),{id:c,html:l.html,mode:s.mode,raw:s.raw};const d=await oe(s);return M(o,{hash:i,html:d}),{id:c,html:d,mode:s.mode,raw:s.raw}}))},ge=Object.freeze(Object.defineProperty({__proto__:null,renderMarkdownBlocks:ce,renderMarkdownSync:ie},Symbol.toStringTag,{value:"Module"}));export{ce as a,pe as b,me as i,ge as m,ie as r,q as s};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderElectronMiniChatApp-DETQLjFi.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/pi-session-focus-preference-BC-ze1oC.js","assets/useAppFontEffects-BisjofNZ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/vendor-katex-css-Cp579UoJ.css"])))=>i.map(i=>d[i]);
2
+ import{_ as o}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as t}from"./index-BnZVqcki.js";/* empty css */import"./vendor-zustand-CUi8eEds.js";import"./vendor-react-DASdDPIk.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-DETQLjFi.js");return{renderElectronMiniChatApp:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(({renderElectronMiniChatApp:r})=>{r()});
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/renderMobileApp-DS0FDQLg.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/pi-session-focus-preference-BC-ze1oC.js","assets/useAppFontEffects-BisjofNZ.js","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js","assets/runtimeEndpointReset-BqqXMwE9.js","assets/SessionUnreadDot-Czfvjbdi.js","assets/permissionStore-B9Hkrqny.js","assets/runtimeEndpointReset-BV3KOtdA.css","assets/vendor-xterm-xterm-css-DDGTF8rc.css","assets/vendor-aparajita-capacitor-secure-storage-BYohCVY0.js","assets/SettingsView-C_GC1Mx3.js","assets/vendor-qrcode-Dv4uniC1.js","assets/vendor-dijkstrajs-COg3n3zL.js","assets/collapsible-C7oyikVm.js","assets/vendor-base-ui-BscvGUFt.js","assets/useSwitcherItems-BSTSev5C.js","assets/vendor-katex-css-Cp579UoJ.css"])))=>i.map(i=>d[i]);
2
+ import{_ as t}from"./vendor-vite-runtime-DD1OZmLC.js";import{c as i}from"./index-BnZVqcki.js";/* empty css */import"./vendor-zustand-CUi8eEds.js";import"./vendor-react-DASdDPIk.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-DS0FDQLg.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])).then(({renderMobileApp:r})=>{r()});
@@ -0,0 +1 @@
1
+ import{r as l}from"./vendor-boot-Dgb9NVFe.js";import{b as a}from"./index-BnZVqcki.js";import"./vendor-react-DASdDPIk.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";const c=l("PiChamberFiles");function f(t){return t instanceof Error&&(t.name==="AbortError"||t.message.includes("AbortError")||t.message.toLowerCase().includes("cancel"))}const s=async t=>{const e=new Uint8Array(await t.arrayBuffer()),n=32768;let r="";for(let o=0;o<e.length;o+=n)r+=String.fromCharCode(...e.subarray(o,o+n));return btoa(r)},u=async(t,e)=>{if(typeof t=="string"){if(t.startsWith("data:")){const r=t.indexOf(",");if(r!==-1&&t.slice(0,r).includes(";base64"))return t.slice(r+1)}const n=new Blob([t],{type:e??"text/plain;charset=utf-8"});return s(n)}return s(t)},p=async(t,e,n)=>{if(t instanceof File)return t;if(t instanceof Blob)return new File([t],e,{type:n||t.type||"application/octet-stream"});if(typeof t=="string"&&t.startsWith("data:")){const r=await(await fetch(t)).blob();return new File([r],e,{type:n||r.type||"application/octet-stream"})}return new File([t],e,{type:n??"text/plain;charset=utf-8"})},b=(t,e,n)=>{if(typeof document>"u")return;const r=typeof e=="string"&&e.startsWith("data:"),o=r?e:URL.createObjectURL(e instanceof Blob?e:new Blob([e],{type:n||"application/octet-stream"})),i=document.createElement("a");i.href=o,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),r||URL.revokeObjectURL(o)};async function C({filename:t,mimeType:e,data:n}){const r=a();if(r==="android"){const o=await u(n,e);return await c.share({filename:t,mimeType:e,base64:o}),"shared"}if(r==="ios"&&typeof navigator<"u"&&typeof navigator.share=="function"){const o=await p(n,t,e);if(typeof navigator.canShare=="function"&&navigator.canShare({files:[o]}))try{return await navigator.share({files:[o]}),"shared"}catch(i){if(f(i))return"cancelled";throw i}}return b(t,n,e),"downloaded"}async function F(t){if(a()==="android")try{await c.setWebViewBackground({color:t})}catch{}}export{f as isShareCancelledError,C as saveOrShareFile,F as setNativeWebViewBackground};
@@ -1,10 +1,10 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
2
- import{f as R,bY as b,bZ as k,g as _,ae as W,b_ as z,bH as K,b$ as J,c0 as Z,a as q,c1 as Q,c2 as E,c3 as X,c4 as ee}from"./useAppFontEffects-CG3_yteE.js";import{aE as te,u as T,aF as se,a as oe,w as P,aG as ne,m as re,aH as ie,S as Y,i as L,b as ae,C as F}from"./index-6IO1AcJI.js";import{_ as le}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as ce}from"./vendor-react-DASdDPIk.js";const de=[];function G(){return[...de].reverse()}const ge={getLastAssistantMessage(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=E();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.role==="assistant"){const l=(b(n.id)||[]).map(i=>{const g={id:i.id,type:i.type};return i.type==="text"?(g.text=i.text,g.textLength=i.text?.length||0):i.type==="tool"?(g.tool=i.tool,g.state=i.state?.status):(i.type==="step-start"||i.type==="step-finish")&&(g.isStepMarker=!0),g}),u=l.some(i=>i.type==="text"&&i.text&&i.text.trim().length>0),a=l.some(i=>i.type==="tool"),d=l.some(i=>i.type==="step-start"||i.type==="step-finish"),p=l.length===0,y=!u&&!a&&(!p||d),r={messageId:n.id,role:n.role,timestamp:n.time?.created||0,partsCount:l.length,parts:l,isEmpty:p,isEmptyResponse:y,raw:n};return console.log("[INSPECT] Last Assistant Message:",r),console.log("[SUMMARY] Summary:",{messageId:r.messageId,partsCount:r.partsCount,isEmpty:r.isEmpty,isEmptyResponse:r.isEmptyResponse,hasText:u,hasTools:a,hasStepMarkers:d,onlyStepMarkers:d&&!u&&!a}),r.isEmpty&&console.warn("[WARNING] Message has NO parts!"),r.isEmptyResponse&&(console.warn("[WARNING] Message has parts but NO meaningful content (empty text, no tools)!"),d&&!u&&!a&&(console.warn("[CRITICAL] CLAUDE EMPTY RESPONSE BUG: Only step-start/step-finish markers, no actual content!"),console.log("This is a known issue with Claude models (anthropic provider)"),console.log("Recommendation: Send a follow-up message or try a different model"))),r}}return console.log("[ERROR] No assistant messages found in current session"),null},truncateString(e,o=80){return!e||typeof e!="string"||e.length<=o?e:e.substring(0,o)+"…"},truncateMessages(e){return e.map(o=>({...o,parts:(b(o.id)||[]).map(t=>{const s={...t};return"text"in t&&(s.text=this.truncateString(t.text)),"textPreview"in t&&(s.textPreview=this.truncateString(t.textPreview)),t.state&&(s.state={...t.state},"output"in t.state&&(s.state.output=this.truncateString(t.state.output)),"error"in t.state&&(s.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(s.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),s})}))},getAllMessages(e=!1){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=E();return console.log(`[MESSAGES] Total messages in session: ${s.length}`),s.forEach((n,m)=>{const l=b(n.id)||[];console.log(`[${m}] ${n.role} - ${n.id} - ${l.length} parts`)}),e?this.truncateMessages(s):s},async getAppStatus(){const e=T.getState(),o=R.getState(),t=q.getState(),s=e.currentDirectory||null,n=_().getState(),m=n.directory??null,l=Q(),u=new Set,a={};l.forEach(c=>{const f=c.directory;typeof f=="string"&&f.trim().length>0?(u.add(f),a[f]=(a[f]??0)+1):a["(none)"]=(a["(none)"]??0)+1});const d=(()=>{if(typeof window>"u")return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem("lastDirectory"),homeDirectory:window.localStorage.getItem("homeDirectory")}}catch(c){return{available:!1,error:c instanceof Error?c.message:String(c)}}})(),p=P(),y=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,r=async c=>{try{return await c.json()}catch{return null}},g=await(async c=>{try{const f=await re(c);return f.ok?await r(f):{status:f.status}}catch(f){return{error:f instanceof Error?f.message:String(f)}}})("/api/pi/ui-settings");let I=null;try{I=await se.health({runtimeKey:oe()})}catch(c){I={error:c instanceof Error?c.message:String(c)}}let w={isGitRepo:null};if(s)try{const c=P()?.git.checkIsGitRepository??ne;w.isGitRepo=await c(s)}catch(c){w={isGitRepo:null,error:c instanceof Error?c.message:String(c)}}const D=t.projects.map(c=>({id:c.id,path:c.path,label:c.label})),h={runtime:{platform:p?.runtime?.platform??null,isDesktop:y,hasRuntimeApis:!!p,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:s,piDirectory:m,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:D},sessions:{total:l.length,currentSessionId:o.currentSessionId,uniqueDirectories:u.size,directorySamples:Array.from(u).slice(0,5),directoryCounts:a},git:w,localStorage:d,pi:{health:I,connection:n.connection},pichamber:{settingsInfo:g},recentSendFailures:G(),currentSessionDirectoryResolution:o.currentSessionId?this.diagnoseSessionDirectory(o.currentSessionId):null};return console.log("[DEBUG] App status snapshot:",h),h},getRecentSendFailures(){const e=G();return e.length===0?console.log("[OK] No prompt sends were rejected in this session."):(console.warn(`[ALERT] ${e.length} rejected prompt send(s):`),console.table(e)),e},diagnoseSessionDirectory(e){const o=R.getState(),t=e??o.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const s=z(t),n=K().find(g=>g.id===t),m=n?.directory??null,l=t===o.currentSessionId?o.currentSessionDirectory:null,a=J({session:n??null,currentDirectory:l}),d=o.getDirectoryForSession(t),p=Z(t),y=[["owning child store",s],["session record",m],["current selection",l],["runtime memory",p.runtime],["persisted memory",p.persisted]],r=d?y.find(([,g])=>g&&g!==d):void 0,i={sessionId:t,isCurrentSession:t===o.currentSessionId,routedDirectory:d,resolvedFrom:a.source,conflict:r?{source:r[0],directory:r[1]}:null,sources:X(),details:{owningChildStore:s,sessionRecordDirectory:m,sessionIndexed:!!n,currentSessionDirectory:o.currentSessionDirectory,rememberedForRuntime:p.runtime,persistedAcrossRestarts:p.persisted,activeDirectory:T.getState().currentDirectory??null,piSessionDirectory:_().getState().directory??null}};return console.log("[DEBUG] Session directory resolution:",i),r?console.warn(`[ALERT] Directory sources disagree: routing to "${d}" while "${r[1]}" came from ${r[0]}.`):d?console.log("[OK] All known sources agree on the session directory."):console.warn("[ALERT] No directory resolved for this session — sends fall back to the active directory."),i},async buildDiagnosticsReport(){const e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return W(e)},async copyDiagnosticsReport(){const e=await this.buildDiagnosticsReport();return{...await this.copyTextToClipboard(e),report:e}},checkLastMessage(){const e=this.getLastAssistantMessage();if(!e)return!1;const o=e.isEmpty||e.isEmptyResponse;return o?(console.error("[ALERT] PROBLEMATIC MESSAGE DETECTED!"),console.log("Details:",{messageId:e.messageId,isEmpty:e.isEmpty,isEmptyResponse:e.isEmptyResponse,partsCount:e.partsCount}),e.parts.length>0&&console.log("Parts:",e.parts)):console.log("[OK] Last message looks good!"),o},getStreamingState(){const e=R.getState(),o=_().getState().reducer.bySession,t=new Map;for(const[n,m]of o)t.set(n,k(m));const s=e.currentSessionId?t.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:s,streamingMessageIds:Array.from(t.entries())}),{streamingMessageId:s,streamingMessageIds:t}},findEmptyMessages(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=E().filter(n=>n.role==="assistant").filter(n=>{const m=b(n.id)||[],l=m.some(a=>a.type==="text"&&a.text&&a.text.trim().length>0),u=m.some(a=>a.type==="tool");return m.length===0||!l&&!u});return console.log(`[INSPECT] Found ${s.length} empty assistant messages`),s.forEach((n,m)=>{const l=b(n.id)||[];console.log(`[${m}] Empty message:`,{messageId:n.id,partsCount:l.length,provider:n.providerID,model:n.modelID,timestamp:n.time?.created})}),s},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BjdQVib9.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js"])))=>i.map(i=>d[i]);
2
+ import{h as R,bY as b,bZ as k,g as _,ae as W,b_ as z,bH as J,b$ as K,c0 as Z,a as q,c1 as Q,c2 as E,c3 as X,c4 as ee}from"./useAppFontEffects-BisjofNZ.js";import{aG as te,u as A,aH as se,a as oe,w as P,aI as ne,m as re,aJ as ie,T as Y,i as L,b as ae,C as F}from"./index-BnZVqcki.js";import{_ as le}from"./vendor-vite-runtime-DD1OZmLC.js";import{R as ce}from"./vendor-react-DASdDPIk.js";const de=[];function G(){return[...de].reverse()}const ge={getLastAssistantMessage(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const t=E();if(!t||t.length===0)return console.log("[ERROR] No messages in current session"),null;for(let s=t.length-1;s>=0;s--){const n=t[s];if(n.role==="assistant"){const l=(b(n.id)||[]).map(i=>{const g={id:i.id,type:i.type};return i.type==="text"?(g.text=i.text,g.textLength=i.text?.length||0):i.type==="tool"?(g.tool=i.tool,g.state=i.state?.status):(i.type==="step-start"||i.type==="step-finish")&&(g.isStepMarker=!0),g}),u=l.some(i=>i.type==="text"&&i.text&&i.text.trim().length>0),a=l.some(i=>i.type==="tool"),d=l.some(i=>i.type==="step-start"||i.type==="step-finish"),p=l.length===0,y=!u&&!a&&(!p||d),r={messageId:n.id,role:n.role,timestamp:n.time?.created||0,partsCount:l.length,parts:l,isEmpty:p,isEmptyResponse:y,raw:n};return console.log("[INSPECT] Last Assistant Message:",r),console.log("[SUMMARY] Summary:",{messageId:r.messageId,partsCount:r.partsCount,isEmpty:r.isEmpty,isEmptyResponse:r.isEmptyResponse,hasText:u,hasTools:a,hasStepMarkers:d,onlyStepMarkers:d&&!u&&!a}),r.isEmpty&&console.warn("[WARNING] Message has NO parts!"),r.isEmptyResponse&&(console.warn("[WARNING] Message has parts but NO meaningful content (empty text, no tools)!"),d&&!u&&!a&&(console.warn("[CRITICAL] CLAUDE EMPTY RESPONSE BUG: Only step-start/step-finish markers, no actual content!"),console.log("This is a known issue with Claude models (anthropic provider)"),console.log("Recommendation: Send a follow-up message or try a different model"))),r}}return console.log("[ERROR] No assistant messages found in current session"),null},truncateString(e,o=80){return!e||typeof e!="string"||e.length<=o?e:e.substring(0,o)+"…"},truncateMessages(e){return e.map(o=>({...o,parts:(b(o.id)||[]).map(t=>{const s={...t};return"text"in t&&(s.text=this.truncateString(t.text)),"textPreview"in t&&(s.textPreview=this.truncateString(t.textPreview)),t.state&&(s.state={...t.state},"output"in t.state&&(s.state.output=this.truncateString(t.state.output)),"error"in t.state&&(s.state.error=this.truncateString(t.state.error)),t.state.metadata&&"preview"in t.state.metadata&&(s.state.metadata={...t.state.metadata,preview:this.truncateString(t.state.metadata.preview)})),s})}))},getAllMessages(e=!1){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=E();return console.log(`[MESSAGES] Total messages in session: ${s.length}`),s.forEach((n,m)=>{const l=b(n.id)||[];console.log(`[${m}] ${n.role} - ${n.id} - ${l.length} parts`)}),e?this.truncateMessages(s):s},async getAppStatus(){const e=A.getState(),o=R.getState(),t=q.getState(),s=e.currentDirectory||null,n=_().getState(),m=n.directory??null,l=Q(),u=new Set,a={};l.forEach(c=>{const f=c.directory;typeof f=="string"&&f.trim().length>0?(u.add(f),a[f]=(a[f]??0)+1):a["(none)"]=(a["(none)"]??0)+1});const d=(()=>{if(typeof window>"u")return{available:!1};try{return{available:!0,lastDirectory:window.localStorage.getItem("lastDirectory"),homeDirectory:window.localStorage.getItem("homeDirectory")}}catch(c){return{available:!1,error:c instanceof Error?c.message:String(c)}}})(),p=P(),y=typeof window<"u"&&!!window.__PICHAMBER_ELECTRON__,r=async c=>{try{return await c.json()}catch{return null}},g=await(async c=>{try{const f=await re(c);return f.ok?await r(f):{status:f.status}}catch(f){return{error:f instanceof Error?f.message:String(f)}}})("/api/pi/ui-settings");let I=null;try{I=await se.health({runtimeKey:oe()})}catch(c){I={error:c instanceof Error?c.message:String(c)}}let w={isGitRepo:null};if(s)try{const c=P()?.git.checkIsGitRepository??ne;w.isGitRepo=await c(s)}catch(c){w={isGitRepo:null,error:c instanceof Error?c.message:String(c)}}const D=t.projects.map(c=>({id:c.id,path:c.path,label:c.label})),S={runtime:{platform:p?.runtime?.platform??null,isDesktop:y,hasRuntimeApis:!!p,desktopServerOrigin:null},location:typeof window<"u"?{href:window.location?.href??null,origin:window.location?.origin??null}:null,directories:{currentDirectory:s,piDirectory:m,homeDirectory:e.homeDirectory||null,isHomeReady:e.isHomeReady,hasPersistedDirectory:e.hasPersistedDirectory,isSwitchingDirectory:e.isSwitchingDirectory},projects:{total:t.projects.length,activeProjectId:t.activeProjectId,samples:D},sessions:{total:l.length,currentSessionId:o.currentSessionId,uniqueDirectories:u.size,directorySamples:Array.from(u).slice(0,5),directoryCounts:a},git:w,localStorage:d,pi:{health:I,connection:n.connection},pichamber:{settingsInfo:g},recentSendFailures:G(),currentSessionDirectoryResolution:o.currentSessionId?this.diagnoseSessionDirectory(o.currentSessionId):null};return console.log("[DEBUG] App status snapshot:",S),S},getRecentSendFailures(){const e=G();return e.length===0?console.log("[OK] No prompt sends were rejected in this session."):(console.warn(`[ALERT] ${e.length} rejected prompt send(s):`),console.table(e)),e},diagnoseSessionDirectory(e){const o=R.getState(),t=e??o.currentSessionId;if(!t)return console.log("[ERROR] No session selected and no session id passed"),null;const s=z(t),n=J().find(g=>g.id===t),m=n?.directory??null,l=t===o.currentSessionId?o.currentSessionDirectory:null,a=K({session:n??null,currentDirectory:l}),d=o.getDirectoryForSession(t),p=Z(t),y=[["owning child store",s],["session record",m],["current selection",l],["runtime memory",p.runtime],["persisted memory",p.persisted]],r=d?y.find(([,g])=>g&&g!==d):void 0,i={sessionId:t,isCurrentSession:t===o.currentSessionId,routedDirectory:d,resolvedFrom:a.source,conflict:r?{source:r[0],directory:r[1]}:null,sources:X(),details:{owningChildStore:s,sessionRecordDirectory:m,sessionIndexed:!!n,currentSessionDirectory:o.currentSessionDirectory,rememberedForRuntime:p.runtime,persistedAcrossRestarts:p.persisted,activeDirectory:A.getState().currentDirectory??null,piSessionDirectory:_().getState().directory??null}};return console.log("[DEBUG] Session directory resolution:",i),r?console.warn(`[ALERT] Directory sources disagree: routing to "${d}" while "${r[1]}" came from ${r[0]}.`):d?console.log("[OK] All known sources agree on the session directory."):console.warn("[ALERT] No directory resolved for this session — sends fall back to the active directory."),i},async buildDiagnosticsReport(){const e=await this.getAppStatus();return JSON.stringify(e,null,2)},async copyTextToClipboard(e){return W(e)},async copyDiagnosticsReport(){const e=await this.buildDiagnosticsReport();return{...await this.copyTextToClipboard(e),report:e}},checkLastMessage(){const e=this.getLastAssistantMessage();if(!e)return!1;const o=e.isEmpty||e.isEmptyResponse;return o?(console.error("[ALERT] PROBLEMATIC MESSAGE DETECTED!"),console.log("Details:",{messageId:e.messageId,isEmpty:e.isEmpty,isEmptyResponse:e.isEmptyResponse,partsCount:e.partsCount}),e.parts.length>0&&console.log("Parts:",e.parts)):console.log("[OK] Last message looks good!"),o},getStreamingState(){const e=R.getState(),o=_().getState().reducer.bySession,t=new Map;for(const[n,m]of o)t.set(n,k(m));const s=e.currentSessionId?t.get(e.currentSessionId)??null:null;return console.log("[STREAM] Streaming State:",{streamingMessageId:s,streamingMessageIds:Array.from(t.entries())}),{streamingMessageId:s,streamingMessageIds:t}},findEmptyMessages(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),[];const s=E().filter(n=>n.role==="assistant").filter(n=>{const m=b(n.id)||[],l=m.some(a=>a.type==="text"&&a.text&&a.text.trim().length>0),u=m.some(a=>a.type==="tool");return m.length===0||!l&&!u});return console.log(`[INSPECT] Found ${s.length} empty assistant messages`),s.forEach((n,m)=>{const l=b(n.id)||[];console.log(`[${m}] Empty message:`,{messageId:n.id,partsCount:l.length,provider:n.providerID,model:n.modelID,timestamp:n.time?.created})}),s},showRetryHelp(){console.log(`[DEBUG] How to handle empty Claude responses:
3
3
  `),console.log("1. Check the last message:"),console.log(` __piDebug.getLastAssistantMessage()
4
4
  `),console.log("2. Find all empty messages in session:"),console.log(` __piDebug.findEmptyMessages()
5
5
  `),console.log("3. To retry, you can:"),console.log(" - Edit your last user message and resend"),console.log(' - Send a follow-up message like "Please provide the response"'),console.log(` - Try a different model (OpenAI models tend to be more reliable)
6
- `),console.log("[TIP] Empty responses are usually due to:"),console.log(" - Model rate limits"),console.log(" - Context length issues"),console.log(" - Model refusing to respond to certain prompts"),console.log(" - API errors from provider")},analyzeMessageCompletionConsistency(e={}){const{includeNonAssistant:o=!1,verbose:t=!0,maxTableRows:s=25}=e;if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),{summary:null,rows:[]};const l=E(),u=o?l:l.filter(r=>r.role==="assistant"),a={totalMessages:l.length,analyzedMessages:u.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},d=r=>typeof r=="number"&&Number.isFinite(r)?r:null,p=r=>{const i=r.filter(g=>typeof g=="number");return i.length>0?Math.max(...i):null},y=u.map((r,i)=>{const g=r,I=b(r.id)||[],w=g.time??{},D=d(w.completed),h=D!==null,c=I.filter(S=>S.type==="tool"),f=I.filter(S=>S.type==="reasoning"),C=p(c.map(S=>d(S.state?.time?.end??S.state?.time?.start))),M=p(f.map(S=>d(S.time?.end??S.time?.start))),V=p([C,M].filter(S=>S!==null)),x=c.some(S=>["pending","running","started"].includes(S.state?.status)),O=f.some(S=>typeof S.time?.end!="number");c.length>0&&(a.withTools+=1),f.length>0&&(a.withReasoning+=1),h||(a.completedMissing+=1);const N=!!(h&&typeof C=="number"&&D<C);N&&(a.completedBeforeTool+=1);const B=!!(h&&typeof M=="number"&&D<M);return B&&(a.completedBeforeReasoning+=1),h&&x&&(a.runningToolsWhenCompleted+=1),h&&O&&(a.reasoningOpenWhenCompleted+=1),{index:i,messageId:g.id,role:g.role,completedAt:D,latestToolTimestamp:C,latestReasoningTimestamp:M,latestPartTimestamp:V,completed_missing:!h,completed_before_tool:N,completed_before_reasoning:B,running_tools_when_completed:!!(h&&x),reasoning_open_when_completed:!!(h&&O),has_tools:c.length>0,has_reasoning:f.length>0}});return t&&(console.table(y.slice(0,s)),y.length>s&&console.log(`Displayed first ${s} rows out of ${y.length}.`),console.log("[SUMMARY] Message completion timing:",a)),{summary:a,rows:y}},checkCompletionStatus(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const s=E().filter(w=>w.role==="assistant");if(s.length===0)return console.log("[ERROR] No assistant messages"),null;const n=s[s.length-1],l=(b(n.id)||[]).filter(w=>w.type==="step-finish"),u=n.finish==="stop",d=n.time?.completed,p=n.status,y=typeof d=="number"&&d>0||p==="completed",r=!!(y&&u),i=n.sessionID,g=i?k(_().getState().reducer.bySession.get(i)??null):null,I=n.id===g;return console.log("[SUMMARY] Completion Status:"),console.log("Message ID:",n.id),console.log("time.completed:",d,"(type:",typeof d,")"),console.log("status:",p),console.log("hasCompletedFlag:",y),console.log("hasStopReason:",u),console.log("messageIsComplete:",r),console.log("isStreamingCandidate:",I),console.log("streamingMessageId:",g),console.log("Step-finish parts:",l),{messageId:n.id,completed:d,status:p,hasCompletedFlag:y,hasStopReason:u,messageIsComplete:r,stepFinishParts:l,raw:n}}};typeof window<"u"&&(window.__piDebug=ge,te()&&(console.log("[DEBUG] Pi debug utilities loaded. Use window.__piDebug in the console."),console.log("Available commands:"),console.log(" __piDebug.getLastAssistantMessage() - Get last assistant message details"),console.log(" __piDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)"),console.log(" __piDebug.truncateMessages(messages) - Truncate long fields in messages array"),console.log(" __piDebug.getAppStatus() - Show app status snapshot"),console.log(" __piDebug.diagnoseSessionDirectory(sessionId?) - Show how the session directory is resolved"),console.log(" __piDebug.getRecentSendFailures() - List prompt sends that were rejected and rolled back"),console.log(" __piDebug.checkLastMessage() - Check if last message is problematic"),console.log(" __piDebug.findEmptyMessages() - Find all empty assistant messages"),console.log(" __piDebug.showRetryHelp() - Show instructions for handling empty responses"),console.log(" __piDebug.getStreamingState() - Get streaming state info"),console.log(" __piDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings"),console.log(" __piDebug.checkCompletionStatus() - Check completion status of last message")),window.addEventListener("error",e=>{try{const o=e.message||"",t=e.filename||"";typeof o=="string"&&o.includes("this._renderer.value.dimensions")&&/xterm/i.test(String(t))&&e.preventDefault()}catch{}}));const Se=async()=>{if(typeof window>"u")return;let e=null;try{e=window.localStorage.getItem("lastDirectory")}catch(o){console.warn("Failed to read saved directory preferences:",o)}e&&T.getState().setDirectory(e,{showOverlay:!1})};let $=!1;const H="pichamber-typography-base",ue=()=>{if(typeof document>"u")return;const o=`:root {
6
+ `),console.log("[TIP] Empty responses are usually due to:"),console.log(" - Model rate limits"),console.log(" - Context length issues"),console.log(" - Model refusing to respond to certain prompts"),console.log(" - API errors from provider")},analyzeMessageCompletionConsistency(e={}){const{includeNonAssistant:o=!1,verbose:t=!0,maxTableRows:s=25}=e;if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),{summary:null,rows:[]};const l=E(),u=o?l:l.filter(r=>r.role==="assistant"),a={totalMessages:l.length,analyzedMessages:u.length,completedMissing:0,completedBeforeTool:0,completedBeforeReasoning:0,runningToolsWhenCompleted:0,reasoningOpenWhenCompleted:0,withTools:0,withReasoning:0},d=r=>typeof r=="number"&&Number.isFinite(r)?r:null,p=r=>{const i=r.filter(g=>typeof g=="number");return i.length>0?Math.max(...i):null},y=u.map((r,i)=>{const g=r,I=b(r.id)||[],w=g.time??{},D=d(w.completed),S=D!==null,c=I.filter(h=>h.type==="tool"),f=I.filter(h=>h.type==="reasoning"),C=p(c.map(h=>d(h.state?.time?.end??h.state?.time?.start))),M=p(f.map(h=>d(h.time?.end??h.time?.start))),V=p([C,M].filter(h=>h!==null)),x=c.some(h=>["pending","running","started"].includes(h.state?.status)),O=f.some(h=>typeof h.time?.end!="number");c.length>0&&(a.withTools+=1),f.length>0&&(a.withReasoning+=1),S||(a.completedMissing+=1);const N=!!(S&&typeof C=="number"&&D<C);N&&(a.completedBeforeTool+=1);const B=!!(S&&typeof M=="number"&&D<M);return B&&(a.completedBeforeReasoning+=1),S&&x&&(a.runningToolsWhenCompleted+=1),S&&O&&(a.reasoningOpenWhenCompleted+=1),{index:i,messageId:g.id,role:g.role,completedAt:D,latestToolTimestamp:C,latestReasoningTimestamp:M,latestPartTimestamp:V,completed_missing:!S,completed_before_tool:N,completed_before_reasoning:B,running_tools_when_completed:!!(S&&x),reasoning_open_when_completed:!!(S&&O),has_tools:c.length>0,has_reasoning:f.length>0}});return t&&(console.table(y.slice(0,s)),y.length>s&&console.log(`Displayed first ${s} rows out of ${y.length}.`),console.log("[SUMMARY] Message completion timing:",a)),{summary:a,rows:y}},checkCompletionStatus(){if(!R.getState().currentSessionId)return console.log("[ERROR] No active session"),null;const s=E().filter(w=>w.role==="assistant");if(s.length===0)return console.log("[ERROR] No assistant messages"),null;const n=s[s.length-1],l=(b(n.id)||[]).filter(w=>w.type==="step-finish"),u=n.finish==="stop",d=n.time?.completed,p=n.status,y=typeof d=="number"&&d>0||p==="completed",r=!!(y&&u),i=n.sessionID,g=i?k(_().getState().reducer.bySession.get(i)??null):null,I=n.id===g;return console.log("[SUMMARY] Completion Status:"),console.log("Message ID:",n.id),console.log("time.completed:",d,"(type:",typeof d,")"),console.log("status:",p),console.log("hasCompletedFlag:",y),console.log("hasStopReason:",u),console.log("messageIsComplete:",r),console.log("isStreamingCandidate:",I),console.log("streamingMessageId:",g),console.log("Step-finish parts:",l),{messageId:n.id,completed:d,status:p,hasCompletedFlag:y,hasStopReason:u,messageIsComplete:r,stepFinishParts:l,raw:n}}};typeof window<"u"&&(window.__piDebug=ge,te()&&(console.log("[DEBUG] Pi debug utilities loaded. Use window.__piDebug in the console."),console.log("Available commands:"),console.log(" __piDebug.getLastAssistantMessage() - Get last assistant message details"),console.log(" __piDebug.getAllMessages(truncate?) - List all messages (truncate=true for short preview)"),console.log(" __piDebug.truncateMessages(messages) - Truncate long fields in messages array"),console.log(" __piDebug.getAppStatus() - Show app status snapshot"),console.log(" __piDebug.diagnoseSessionDirectory(sessionId?) - Show how the session directory is resolved"),console.log(" __piDebug.getRecentSendFailures() - List prompt sends that were rejected and rolled back"),console.log(" __piDebug.checkLastMessage() - Check if last message is problematic"),console.log(" __piDebug.findEmptyMessages() - Find all empty assistant messages"),console.log(" __piDebug.showRetryHelp() - Show instructions for handling empty responses"),console.log(" __piDebug.getStreamingState() - Get streaming state info"),console.log(" __piDebug.analyzeMessageCompletionConsistency(opts?) - Compare time.completed vs part timings"),console.log(" __piDebug.checkCompletionStatus() - Check completion status of last message")),window.addEventListener("error",e=>{try{const o=e.message||"",t=e.filename||"";typeof o=="string"&&o.includes("this._renderer.value.dimensions")&&/xterm/i.test(String(t))&&e.preventDefault()}catch{}}));const he=async()=>{if(typeof window>"u")return;let e=null;try{e=window.localStorage.getItem("lastDirectory")}catch(o){console.warn("Failed to read saved directory preferences:",o)}e&&A.getState().setDirectory(e,{showOverlay:!1})};let $=!1;const H="pichamber-typography-base",ue=()=>{if(typeof document>"u")return;const o=`:root {
7
7
  ${Object.entries(ie).map(([n,m])=>` --text-${n.replace(/([A-Z])/g,"-$1").toLowerCase()}: ${m};`).join(`
8
8
  `)}
9
9
  }
10
- `,t=document.getElementById(H);if(t){t.textContent=o;return}const s=document.createElement("style");s.id=H,s.textContent=o,document.head.appendChild(s)},he=()=>{$||typeof window>"u"||($=!0,ue())},j=2e4,U=()=>typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()?"visible":"hidden",v=e=>{if(!Y()&&!L())return;const o=P();o?.push?.setVisibility&&o.push.setVisibility({visible:e,platform:ae()})},we=e=>{const o=e?.enabled??!0;ce.useEffect(()=>{if(!o||!Y()&&!L()||typeof window>"u")return;if(L()){let l=!0,u=!1,a=null;const d=()=>v(l);le(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([0,1,2])).then(async({App:y})=>{if(u)return;const r=await y.getState().catch(()=>null);r&&(l=r.isActive===!0),d();const i=await y.addListener("appStateChange",({isActive:g})=>{l=g===!0,d()});if(u){i.remove();return}a=()=>{i.remove()}}).catch(()=>{});const p=window.setInterval(()=>{l&&v(!0)},j);return()=>{u=!0,window.clearInterval(p),a?.()}}if(typeof document>"u")return;const t=()=>{v(U()==="visible")},s=()=>{U()==="visible"&&v(!0)},n=()=>{v(!1)};t();const m=window.setInterval(s,j);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",n),window.addEventListener("pageshow",t),window.addEventListener("focus",t),window.addEventListener("blur",t),()=>{window.clearInterval(m),document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",n),window.removeEventListener("pageshow",t),window.removeEventListener("focus",t),window.removeEventListener("blur",t)}},[o])},A=(e,o)=>!!(e&&o)&&F(e??null)===F(o??null);function Re(e,o){if(!e)return null;const t=_();if(A(t.getState().directory,e))return null;const s=R.getState();return ee(s.newSessionDraft,s.currentSessionId)?null:s.currentSessionId&&A(s.currentSessionDirectory,e)?s.currentSessionId:o?.sessionId&&A(o.directory,e)?o.sessionId:t.lastSelectedSessionForDirectory(e)}export{Se as a,Re as f,he as s,we as u};
10
+ `,t=document.getElementById(H);if(t){t.textContent=o;return}const s=document.createElement("style");s.id=H,s.textContent=o,document.head.appendChild(s)},Se=()=>{$||typeof window>"u"||($=!0,ue())},j=2e4,U=()=>typeof document>"u"||document.visibilityState==="visible"&&document.hasFocus()?"visible":"hidden",v=e=>{if(!Y()&&!L())return;const o=P();o?.push?.setVisibility&&o.push.setVisibility({visible:e,platform:ae()})},we=e=>{const o=e?.enabled??!0;ce.useEffect(()=>{if(!o||!Y()&&!L()||typeof window>"u")return;if(L()){let l=!0,u=!1,a=null;const d=()=>v(l);le(()=>import("./vendor-capacitor-app-BjdQVib9.js"),__vite__mapDeps([0,1,2,3,4])).then(async({App:y})=>{if(u)return;const r=await y.getState().catch(()=>null);r&&(l=r.isActive===!0),d();const i=await y.addListener("appStateChange",({isActive:g})=>{l=g===!0,d()});if(u){i.remove();return}a=()=>{i.remove()}}).catch(()=>{});const p=window.setInterval(()=>{l&&v(!0)},j);return()=>{u=!0,window.clearInterval(p),a?.()}}if(typeof document>"u")return;const t=()=>{v(U()==="visible")},s=()=>{U()==="visible"&&v(!0)},n=()=>{v(!1)};t();const m=window.setInterval(s,j);return document.addEventListener("visibilitychange",t),window.addEventListener("pagehide",n),window.addEventListener("pageshow",t),window.addEventListener("focus",t),window.addEventListener("blur",t),()=>{window.clearInterval(m),document.removeEventListener("visibilitychange",t),window.removeEventListener("pagehide",n),window.removeEventListener("pageshow",t),window.removeEventListener("focus",t),window.removeEventListener("blur",t)}},[o])},T=(e,o)=>!!(e&&o)&&F(e??null)===F(o??null);function Re(e,o){if(!e)return null;const t=_();if(T(t.getState().directory,e))return null;const s=R.getState();return ee(s.newSessionDraft,s.currentSessionId)?null:s.currentSessionId&&T(s.currentSessionDirectory,e)?s.currentSessionId:o?.sessionId&&T(o.directory,e)?o.sessionId:t.lastSelectedSessionForDirectory(e)}export{he as a,Re as f,Se as s,we as u};
@@ -1 +1 @@
1
- import{b as q,i as M,n as K,k as j,j as G,m as W,l as P}from"./computeVirtualFileMetrics-CeMpF2xC.js";import{c5 as J,de as z}from"./useAppFontEffects-CG3_yteE.js";import{d as X,a as Q}from"./vendor-diff-C3JhlQdm.js";function gn(n,e){return n===e||n?.cacheKey!=null&&n.cacheKey===e?.cacheKey}function mn(n,e){return q(n.theme,e.theme)&&n.useTokenTransformer===e.useTokenTransformer&&n.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&n.lineDiffType===e.lineDiffType&&n.maxLineDiffLength===e.maxLineDiffLength}function pn(n){const e=n.lang??M(n.name),r=n.lang??(n.prevName!=null?M(n.prevName):"text");return e==="text"&&r==="text"}function B({isPartial:n,rangeSize:e,expandedHunks:r,hunkIndex:l,collapsedContextThreshold:f}){const t=Math.max(e,0);if(t===0||n)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:t,renderAll:!1};if(r===!0||t<=f)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(l),d=Math.min(Math.max(h?.fromStart??0,0),t),i=Math.min(Math.max(h?.fromEnd??0,0),t),u=d+i,o=u>=t;return{fromStart:o?t:d,fromEnd:o?0:i,rangeSize:t,collapsedLines:Math.max(t-u,0),renderAll:o}}function In(n){const e=n.hunks[n.hunks.length-1];if(e==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return!1;const r=n.additionLines.length-(e.additionLineIndex+e.additionCount),l=n.deletionLines.length-(e.deletionLineIndex+e.deletionCount);return r<=0&&l<=0?!1:r!==l}function Y({fileDiff:n,errorPrefix:e}){const r=n.hunks[n.hunks.length-1];if(r==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return 0;const l=n.additionLines.length-(r.additionLineIndex+r.additionCount),f=n.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(l<=0&&f<=0)return 0;if(l!==f)throw new Error(`${e}: trailing context mismatch (additions=${l}, deletions=${f}) for ${n.name}`);return Math.min(l,f)}function V({fileDiff:n,hunkIndex:e,expandedHunks:r,collapsedContextThreshold:l,errorPrefix:f}){if(e!==n.hunks.length-1)return;const t=Y({fileDiff:n,errorPrefix:f});if(t<=0)return;if(r===!0||t<=l)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(n.hunks.length),d=Math.min(Math.max(h?.fromStart??0,0),t);return{fromStart:d,fromEnd:0,rangeSize:t,collapsedLines:t-d,renderAll:d>=t}}function $({type:n,metrics:e}){return e.hunkSeparatorHeight??K(n)}function U({type:n,metrics:e}){return n==="simple"||n==="metadata"||n==="line-info-basic"?0:e.spacing}function Z({type:n,hunkIndex:e,hunkSpecs:r}){switch(n){case"simple":return e>0;case"metadata":return r!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function y(n){return n!=="simple"&&n!=="metadata"}function Cn({type:n,metrics:e,hunkIndex:r,hunkSpecs:l}){if(!Z({type:n,hunkIndex:r,hunkSpecs:l}))return;const f=$({type:n,metrics:e}),t=U({type:n,metrics:e}),h=r>0?t:0,d=t;return{height:f,gapBefore:h,gapAfter:d,totalHeight:h+f+d}}function Ln({type:n,metrics:e}){if(!y(n))return;const r=$({type:n,metrics:e}),l=U({type:n,metrics:e});return{height:r,gapBefore:l,gapAfter:0,totalHeight:l+r}}function nn({diff:n,diffStyle:e,startingLine:r=0,totalLines:l=1/0,expandedHunks:f,collapsedContextThreshold:t=1,callback:h}){const d=en({diff:n,diffStyle:e,startingLine:r,expandedHunks:f,collapsedContextThreshold:t}),i={viewportStart:r,viewportEnd:r+l,isWindowedHighlight:r>0||l<1/0,splitCount:d.splitCount,unifiedCount:d.unifiedCount,finalHunkIndex:n.hunks.length-1,shouldBreak(){if(!i.isWindowedHighlight)return!1;const u=i.unifiedCount>=r+l,o=i.splitCount>=r+l;return e==="unified"?u:(e==="split"||u)&&o},shouldSkip(u,o){if(!i.isWindowedHighlight)return!1;const s=i.unifiedCount+u<r,a=i.splitCount+o<r;return e==="unified"?s:(e==="split"||s)&&a},incrementCounts(u,o){(e==="unified"||e==="both")&&(i.unifiedCount+=u),(e==="split"||e==="both")&&(i.splitCount+=o)},isInWindow(u,o){if(!i.isWindowedHighlight)return!0;const s=i.isInUnifiedWindow(u),a=i.isInSplitWindow(o);return e==="unified"?s:e==="split"?a:s||a},isInUnifiedWindow(u){return!i.isWindowedHighlight||i.unifiedCount>=r-u&&i.unifiedCount<r+l},isInSplitWindow(u){return!i.isWindowedHighlight||i.splitCount>=r-u&&i.splitCount<r+l},emit(u,o=!1){return o||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),h(u)??!1}};n:for(let u=d.hunkIndex;u<n.hunks.length;u++){let g=function(c,p){return a==null||a.collapsedLines<=0||a.fromStart+a.fromEnd>0?0:e==="unified"?c===o.unifiedLineStart+o.unifiedLineCount-1?a.collapsedLines:0:p===o.splitLineStart+o.splitLineCount-1?a.collapsedLines:0},b=function(){return O?0:(O=!0,s.collapsedLines)};const o=n.hunks[u];if(o==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;const s=B({isPartial:n.isPartial,rangeSize:o.collapsedBefore,expandedHunks:f,hunkIndex:u,collapsedContextThreshold:t}),a=u===i.finalHunkIndex?V({fileDiff:n,hunkIndex:u,expandedHunks:f,collapsedContextThreshold:t,errorPrefix:"iterateOverDiff"}):void 0,m=s.fromStart+s.fromEnd;let O=s.collapsedLines===0;if(i.shouldSkip(m,m))i.incrementCounts(m,m),b();else{let c=o.unifiedLineStart-s.rangeSize,p=o.splitLineStart-s.rangeSize,k=o.deletionLineIndex-s.rangeSize,R=o.additionLineIndex-s.rangeSize,S=o.deletionStart-s.rangeSize,H=o.additionStart-s.rangeSize;if(T(i,s.fromStart,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}))||(c=o.unifiedLineStart-s.fromEnd,p=o.splitLineStart-s.fromEnd,k=o.deletionLineIndex-s.fromEnd,R=o.additionLineIndex-s.fromEnd,S=o.deletionStart-s.fromEnd,H=o.additionStart-s.fromEnd,T(i,s.fromEnd,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}),()=>{b()})))break n}let N=o.unifiedLineStart,w=o.splitLineStart,I=o.deletionLineIndex,C=o.additionLineIndex,L=o.deletionStart,v=o.additionStart;const x=o.hunkContent.at(-1);for(const c of o.hunkContent){if(i.shouldBreak())break n;const p=c===x;if(c.type==="context"){if(i.shouldSkip(c.lines,c.lines))i.incrementCounts(c.lines,c.lines),b();else if(T(i,c.lines,e,k=>{const R=p&&k===c.lines-1,S=N+k,H=w+k;return i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:g(S,H),type:"context",deletionLine:{lineNumber:L+k,lineIndex:I+k,noEOFCR:R&&o.noEOFCRDeletions,unifiedLineIndex:S,splitLineIndex:H},additionLine:{unifiedLineIndex:S,splitLineIndex:H,lineIndex:C+k,lineNumber:v+k,noEOFCR:R&&o.noEOFCRAdditions}})},()=>{b()}))break n;N+=c.lines,w+=c.lines,I+=c.lines,C+=c.lines,L+=c.lines,v+=c.lines}else{const k=Math.max(c.deletions,c.additions),R=c.deletions+c.additions;if(!i.shouldSkip(R,k)){const S=rn(i,c,e);(S[0]?.[0]??0)>0&&b();for(const[H,E]of S)for(let D=H;D<E;D++){const _=g(N+D,e==="unified"?w+(D<c.deletions?D:D-c.deletions):w+D);if(i.emit(sn({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:_,diffStyle:e,index:D,unifiedLineIndex:N,splitLineIndex:w,additionLineIndex:C,deletionLineIndex:I,additionLineNumber:v,deletionLineNumber:L,content:c,isLastContent:p,unifiedCount:R,splitCount:k}),!0))break n}}b(),i.incrementCounts(R,k),N+=R,w+=k,I+=c.deletions,C+=c.additions,L+=c.deletions,v+=c.additions}}if(a!=null){const{collapsedLines:c,fromStart:p,fromEnd:k}=a,R=p+k;if(T(i,R,e,S=>{const H=S===R-1;return i.emit({hunkIndex:n.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:H?c:0,type:"context-expanded",deletionLine:{lineNumber:L+S,lineIndex:I+S,noEOFCR:!1,unifiedLineIndex:N+S,splitLineIndex:w+S},additionLine:{unifiedLineIndex:N+S,splitLineIndex:w+S,lineIndex:C+S,lineNumber:v+S,noEOFCR:!1}})},void 0,()=>i.shouldBreak()))break n}}}function en({diff:n,diffStyle:e,startingLine:r,expandedHunks:l,collapsedContextThreshold:f}){if(r<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const t=tn({diff:n,expandedHunks:l,collapsedContextThreshold:f});let h=0,d=n.hunks.length-1,i=n.hunks.length;for(;h<=d;){const o=h+d>>1,s=t[o+1];if(s==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?s.unifiedCount:s.splitCount)>r?(i=o,d=o-1):h=o+1}if(i>=n.hunks.length){const o=t[n.hunks.length];if(o==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:n.hunks.length,splitCount:o.splitCount,unifiedCount:o.unifiedCount}}const u=t[i];if(u==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:u.splitCount,unifiedCount:u.unifiedCount}}function tn({diff:n,expandedHunks:e,collapsedContextThreshold:r}){let l=0,f=0;const t=n.hunks.length-1,h=[{splitCount:0,unifiedCount:0}];for(let d=0;d<n.hunks.length;d++){const i=n.hunks[d];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");const u=B({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:d,collapsedContextThreshold:r}),o=u.fromStart+u.fromEnd;l+=o+i.splitLineCount,f+=o+i.unifiedLineCount;const s=d===t?V({fileDiff:n,hunkIndex:d,expandedHunks:e,collapsedContextThreshold:r,errorPrefix:"iterateOverDiff"}):void 0;if(s!=null){const a=s.fromStart+s.fromEnd;l+=a,f+=a}h.push({splitCount:l,unifiedCount:f})}return h}function on(n,e,r){if(!n.isWindowedHighlight||e<=0)return[0,e];const l=[];function f(d){const i=Math.max(0,n.viewportStart-d),u=Math.min(e,n.viewportEnd-d);u>i&&l.push([i,u])}if(r!=="split"&&f(n.unifiedCount),r!=="unified"&&f(n.splitCount),l.length===0)return[0,0];let t=l[0][0],h=l[0][1];for(let d=1;d<l.length;d++){const i=l[d];t=Math.min(t,i[0]),h=Math.max(h,i[1])}return[t,h]}function T(n,e,r,l,f,t){const[h,d]=on(n,e,r);h>0&&(n.incrementCounts(h,h),f?.());let i=h;for(;i<e;){if(t?.()===!0)return!0;if(i>=d){n.incrementCounts(e-i,e-i);break}if(n.isInWindow(0,0)){if(l(i)===!0)return!0}else n.incrementCounts(1,1);i++}return!1}function rn(n,e,r){if(!n.isWindowedHighlight)return[[0,r==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const l=r!=="split",f=r!=="unified",t=r==="unified"?"unified":"split",h=[];function d(s,a){if(s+a<=n.viewportStart||s>=n.viewportEnd)return;const m=Math.max(0,n.viewportStart-s),g=Math.min(a,n.viewportEnd-s);return g>m?[m,g]:void 0}function i(s,a){return t==="split"?s:a==="additions"?[s[0]+e.deletions,s[1]+e.deletions]:s}function u(s,a){if(s==null)return;const[m,g]=i(s,a);g>m&&h.push([m,g])}if(l&&(u(d(n.unifiedCount,e.deletions),"deletions"),u(d(n.unifiedCount+e.deletions,e.additions),"additions")),f&&(u(d(n.splitCount,e.deletions),"deletions"),u(d(n.splitCount,e.additions),"additions")),h.length===0)return h;h.sort((s,a)=>s[0]-a[0]);const o=[h[0]];for(const[s,a]of h.slice(1)){const m=o[o.length-1];s<=m[1]?m[1]=Math.max(m[1],a):o.push([s,a])}return o}function sn({hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,diffStyle:f,index:t,unifiedLineIndex:h,splitLineIndex:d,additionLineIndex:i,deletionLineIndex:u,additionLineNumber:o,deletionLineNumber:s,content:a,isLastContent:m,unifiedCount:g,splitCount:O}){const b=t<a.deletions?h+t:void 0,N=f==="unified"?t>=a.deletions?h+t:void 0:t<a.additions?h+a.deletions+t:void 0,w=f==="unified"?d+(t<a.deletions?t:t-a.deletions):d+t,I=t<a.deletions?u+t:void 0,C=t<a.deletions?s+t:void 0,L=f==="unified"?t>=a.deletions?i+(t-a.deletions):void 0:t<a.additions?i+t:void 0,v=f==="unified"?t>=a.deletions?o+(t-a.deletions):void 0:t<a.additions?o+t:void 0,x=f==="unified"?m&&t===a.deletions-1&&e.noEOFCRDeletions:m&&t===O-1&&e.noEOFCRDeletions,c=f==="unified"?m&&t===g-1&&e.noEOFCRAdditions:m&&t===O-1&&e.noEOFCRAdditions,p=I!=null&&C!=null&&b!=null?{lineNumber:C,lineIndex:I,noEOFCR:x,unifiedLineIndex:b,splitLineIndex:w}:void 0,k=L!=null&&v!=null&&N!=null?{unifiedLineIndex:N,splitLineIndex:w,lineIndex:L,lineNumber:v,noEOFCR:c}:void 0;if(p==null&&k!=null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:void 0,additionLine:k};if(p!=null&&k==null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:void 0};if(p==null||k==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:k}}function A({line:n,spanStart:e,spanLength:r}){return{start:{line:n,character:e},end:{line:n,character:e+r},properties:{"data-diff-span":""},alwaysWrap:!0}}function F({item:n,arr:e,enableJoin:r,isNeutral:l=!1,isLastItem:f=!1}){const t=e[e.length-1];if(t==null||f||!r){e.push([l?0:1,n.value]);return}const h=t[0]===0;if(l===h||l&&n.value.length===1&&!h){t[1]+=n.value;return}e.push([l?0:1,n.value])}const ln={forcePlainText:!1};function xn(n,e,r,{forcePlainText:l,startingLine:f,totalLines:t,expandedHunks:h,collapsedContextThreshold:d=1}=ln){l?(f??=0,t??=1/0):(f=0,t=1/0);const i=f>0||t<1/0,u=typeof r.theme=="string"?e.getTheme(r.theme).type:void 0,o=j({theme:r.theme,highlighter:e}),s=l&&!i&&(n.unifiedLineCount>1e3||n.splitLineCount>1e3)?"none":r.lineDiffType,a={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=r,g=!l&&!n.isPartial,O=l?h:void 0,b=new Map;function N(I){const C=g?0:I,L=b.get(C)??un();return b.set(C,L),L}function w(I,C,L,v){if(i){let x=L.at(-1);(x==null||x.targetIndex+x.count!==C)&&(x={targetIndex:C,originalOffset:v.length,count:0},L.push(x)),x.count++}v.push(I)}nn({diff:n,diffStyle:"both",startingLine:f,totalLines:t,expandedHunks:i?O:!0,collapsedContextThreshold:d,callback:({hunkIndex:I,additionLine:C,deletionLine:L,type:v})=>{const x=N(I),c=C!=null?C.splitLineIndex:L.splitLineIndex;v==="change"&&C!=null&&L!=null&&an({additionLine:n.additionLines[C.lineIndex],deletionLine:n.deletionLines[L.lineIndex],deletionLineIndex:x.deletionContent.length,additionLineIndex:x.additionContent.length,deletionDecorations:x.deletionDecorations,additionDecorations:x.additionDecorations,lineDiffType:s,maxLineDiffLength:m}),L!=null&&(w(n.deletionLines[L.lineIndex],L.lineIndex,x.deletionSegments,x.deletionContent),x.deletionInfo.push({type:v==="change"?"change-deletion":v,lineNumber:L.lineNumber,altLineNumber:v==="change"?void 0:C.lineNumber??void 0,lineIndex:`${L.unifiedLineIndex},${c}`})),C!=null&&(w(n.additionLines[C.lineIndex],C.lineIndex,x.additionSegments,x.additionContent),x.additionInfo.push({type:v==="change"?"change-addition":v,lineNumber:C.lineNumber,altLineNumber:v==="change"?void 0:L.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${c}`}))}});for(const I of b.values()){if(I.deletionContent.length===0&&I.additionContent.length===0)continue;const C={name:n.prevName??n.name,contents:I.deletionContent.value},L={name:n.name,contents:I.additionContent.value},{deletionLines:v,additionLines:x}=dn({deletionFile:C,deletionInfo:I.deletionInfo,deletionDecorations:I.deletionDecorations,additionFile:L,additionInfo:I.additionInfo,additionDecorations:I.additionDecorations,highlighter:e,options:r,languageOverride:l?"text":n.lang});if(g){a.deletionLines=v,a.additionLines=x;continue}if(I.deletionSegments.length>0)for(const c of I.deletionSegments)for(let p=0;p<c.count;p++)a.deletionLines[c.targetIndex+p]=v[c.originalOffset+p];else a.deletionLines.push(...v);if(I.additionSegments.length>0)for(const c of I.additionSegments)for(let p=0;p<c.count;p++)a.additionLines[c.targetIndex+p]=x[c.originalOffset+p];else a.additionLines.push(...x)}return{code:a,themeStyles:o,baseThemeType:u}}function an({deletionLine:n,additionLine:e,deletionLineIndex:r,additionLineIndex:l,deletionDecorations:f,additionDecorations:t,lineDiffType:h,maxLineDiffLength:d}){if(n==null||e==null||h==="none"||(n=z(n),e=z(e),n.length>d||e.length>d))return;const i=h==="char"?X(n,e):Q(n,e),u=[],o=[],s=h==="word-alt",a=i.at(-1);for(const g of i){const O=g===a;!g.added&&!g.removed?(F({item:g,arr:u,enableJoin:s,isNeutral:!0,isLastItem:O}),F({item:g,arr:o,enableJoin:s,isNeutral:!0,isLastItem:O})):g.removed?F({item:g,arr:u,enableJoin:s,isLastItem:O}):F({item:g,arr:o,enableJoin:s,isLastItem:O})}let m=0;for(const g of u)g[0]===1&&f.push(A({line:r,spanStart:m,spanLength:g[1].length})),m+=g[1].length;m=0;for(const g of o)g[0]===1&&t.push(A({line:l,spanStart:m,spanLength:g[1].length})),m+=g[1].length}function un(){return{deletionContent:{push(n){this.value+=n,this.length++},value:"",length:0},additionContent:{push(n){this.value+=n,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function dn({deletionFile:n,additionFile:e,deletionInfo:r,additionInfo:l,highlighter:f,deletionDecorations:t,additionDecorations:h,languageOverride:d,options:{theme:i=J,...u}}){const o=d??M(n.name),s=d??M(e.name),{state:a,transformers:m}=G(u.useTokenTransformer),g=typeof i=="string"?{...u,lang:"text",theme:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0}:{...u,lang:"text",themes:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0};return{deletionLines:n.contents===""?[]:(g.lang=o,a.lineInfo=r,g.decorations=t,P(f.codeToHast(z(n.contents),g))),additionLines:e.contents===""?[]:(g.lang=s,g.decorations=h,a.lineInfo=l,P(f.codeToHast(z(e.contents),g)))}}export{mn as a,gn as b,nn as c,B as d,Cn as e,V as f,Y as g,In as h,pn as i,Ln as j,xn as r};
1
+ import{b as q,i as M,n as K,k as j,j as G,m as W,l as P}from"./computeVirtualFileMetrics-CyhUKEfv.js";import{c5 as J,de as z}from"./useAppFontEffects-BisjofNZ.js";import{d as X,a as Q}from"./vendor-diff-C3JhlQdm.js";function gn(n,e){return n===e||n?.cacheKey!=null&&n.cacheKey===e?.cacheKey}function mn(n,e){return q(n.theme,e.theme)&&n.useTokenTransformer===e.useTokenTransformer&&n.tokenizeMaxLineLength===e.tokenizeMaxLineLength&&n.lineDiffType===e.lineDiffType&&n.maxLineDiffLength===e.maxLineDiffLength}function pn(n){const e=n.lang??M(n.name),r=n.lang??(n.prevName!=null?M(n.prevName):"text");return e==="text"&&r==="text"}function B({isPartial:n,rangeSize:e,expandedHunks:r,hunkIndex:l,collapsedContextThreshold:f}){const t=Math.max(e,0);if(t===0||n)return{fromStart:0,fromEnd:0,rangeSize:t,collapsedLines:t,renderAll:!1};if(r===!0||t<=f)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(l),d=Math.min(Math.max(h?.fromStart??0,0),t),i=Math.min(Math.max(h?.fromEnd??0,0),t),u=d+i,o=u>=t;return{fromStart:o?t:d,fromEnd:o?0:i,rangeSize:t,collapsedLines:Math.max(t-u,0),renderAll:o}}function In(n){const e=n.hunks[n.hunks.length-1];if(e==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return!1;const r=n.additionLines.length-(e.additionLineIndex+e.additionCount),l=n.deletionLines.length-(e.deletionLineIndex+e.deletionCount);return r<=0&&l<=0?!1:r!==l}function Y({fileDiff:n,errorPrefix:e}){const r=n.hunks[n.hunks.length-1];if(r==null||n.isPartial||n.additionLines.length===0||n.deletionLines.length===0)return 0;const l=n.additionLines.length-(r.additionLineIndex+r.additionCount),f=n.deletionLines.length-(r.deletionLineIndex+r.deletionCount);if(l<=0&&f<=0)return 0;if(l!==f)throw new Error(`${e}: trailing context mismatch (additions=${l}, deletions=${f}) for ${n.name}`);return Math.min(l,f)}function V({fileDiff:n,hunkIndex:e,expandedHunks:r,collapsedContextThreshold:l,errorPrefix:f}){if(e!==n.hunks.length-1)return;const t=Y({fileDiff:n,errorPrefix:f});if(t<=0)return;if(r===!0||t<=l)return{fromStart:t,fromEnd:0,rangeSize:t,collapsedLines:0,renderAll:!0};const h=r?.get(n.hunks.length),d=Math.min(Math.max(h?.fromStart??0,0),t);return{fromStart:d,fromEnd:0,rangeSize:t,collapsedLines:t-d,renderAll:d>=t}}function $({type:n,metrics:e}){return e.hunkSeparatorHeight??K(n)}function U({type:n,metrics:e}){return n==="simple"||n==="metadata"||n==="line-info-basic"?0:e.spacing}function Z({type:n,hunkIndex:e,hunkSpecs:r}){switch(n){case"simple":return e>0;case"metadata":return r!=null;case"line-info":case"line-info-basic":case"custom":return!0}}function y(n){return n!=="simple"&&n!=="metadata"}function Cn({type:n,metrics:e,hunkIndex:r,hunkSpecs:l}){if(!Z({type:n,hunkIndex:r,hunkSpecs:l}))return;const f=$({type:n,metrics:e}),t=U({type:n,metrics:e}),h=r>0?t:0,d=t;return{height:f,gapBefore:h,gapAfter:d,totalHeight:h+f+d}}function Ln({type:n,metrics:e}){if(!y(n))return;const r=$({type:n,metrics:e}),l=U({type:n,metrics:e});return{height:r,gapBefore:l,gapAfter:0,totalHeight:l+r}}function nn({diff:n,diffStyle:e,startingLine:r=0,totalLines:l=1/0,expandedHunks:f,collapsedContextThreshold:t=1,callback:h}){const d=en({diff:n,diffStyle:e,startingLine:r,expandedHunks:f,collapsedContextThreshold:t}),i={viewportStart:r,viewportEnd:r+l,isWindowedHighlight:r>0||l<1/0,splitCount:d.splitCount,unifiedCount:d.unifiedCount,finalHunkIndex:n.hunks.length-1,shouldBreak(){if(!i.isWindowedHighlight)return!1;const u=i.unifiedCount>=r+l,o=i.splitCount>=r+l;return e==="unified"?u:(e==="split"||u)&&o},shouldSkip(u,o){if(!i.isWindowedHighlight)return!1;const s=i.unifiedCount+u<r,a=i.splitCount+o<r;return e==="unified"?s:(e==="split"||s)&&a},incrementCounts(u,o){(e==="unified"||e==="both")&&(i.unifiedCount+=u),(e==="split"||e==="both")&&(i.splitCount+=o)},isInWindow(u,o){if(!i.isWindowedHighlight)return!0;const s=i.isInUnifiedWindow(u),a=i.isInSplitWindow(o);return e==="unified"?s:e==="split"?a:s||a},isInUnifiedWindow(u){return!i.isWindowedHighlight||i.unifiedCount>=r-u&&i.unifiedCount<r+l},isInSplitWindow(u){return!i.isWindowedHighlight||i.splitCount>=r-u&&i.splitCount<r+l},emit(u,o=!1){return o||(e==="unified"?i.incrementCounts(1,0):e==="split"?i.incrementCounts(0,1):i.incrementCounts(1,1)),h(u)??!1}};n:for(let u=d.hunkIndex;u<n.hunks.length;u++){let g=function(c,p){return a==null||a.collapsedLines<=0||a.fromStart+a.fromEnd>0?0:e==="unified"?c===o.unifiedLineStart+o.unifiedLineCount-1?a.collapsedLines:0:p===o.splitLineStart+o.splitLineCount-1?a.collapsedLines:0},b=function(){return O?0:(O=!0,s.collapsedLines)};const o=n.hunks[u];if(o==null)throw new Error("iterateOverDiff: invalid hunk index");if(i.shouldBreak())break;const s=B({isPartial:n.isPartial,rangeSize:o.collapsedBefore,expandedHunks:f,hunkIndex:u,collapsedContextThreshold:t}),a=u===i.finalHunkIndex?V({fileDiff:n,hunkIndex:u,expandedHunks:f,collapsedContextThreshold:t,errorPrefix:"iterateOverDiff"}):void 0,m=s.fromStart+s.fromEnd;let O=s.collapsedLines===0;if(i.shouldSkip(m,m))i.incrementCounts(m,m),b();else{let c=o.unifiedLineStart-s.rangeSize,p=o.splitLineStart-s.rangeSize,k=o.deletionLineIndex-s.rangeSize,R=o.additionLineIndex-s.rangeSize,S=o.deletionStart-s.rangeSize,H=o.additionStart-s.rangeSize;if(T(i,s.fromStart,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:0,collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}))||(c=o.unifiedLineStart-s.fromEnd,p=o.splitLineStart-s.fromEnd,k=o.deletionLineIndex-s.fromEnd,R=o.additionLineIndex-s.fromEnd,S=o.deletionStart-s.fromEnd,H=o.additionStart-s.fromEnd,T(i,s.fromEnd,e,E=>i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:0,type:"context-expanded",deletionLine:{lineNumber:S+E,lineIndex:k+E,noEOFCR:!1,unifiedLineIndex:c+E,splitLineIndex:p+E},additionLine:{unifiedLineIndex:c+E,splitLineIndex:p+E,lineIndex:R+E,lineNumber:H+E,noEOFCR:!1}}),()=>{b()})))break n}let N=o.unifiedLineStart,w=o.splitLineStart,I=o.deletionLineIndex,C=o.additionLineIndex,L=o.deletionStart,v=o.additionStart;const x=o.hunkContent.at(-1);for(const c of o.hunkContent){if(i.shouldBreak())break n;const p=c===x;if(c.type==="context"){if(i.shouldSkip(c.lines,c.lines))i.incrementCounts(c.lines,c.lines),b();else if(T(i,c.lines,e,k=>{const R=p&&k===c.lines-1,S=N+k,H=w+k;return i.emit({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:g(S,H),type:"context",deletionLine:{lineNumber:L+k,lineIndex:I+k,noEOFCR:R&&o.noEOFCRDeletions,unifiedLineIndex:S,splitLineIndex:H},additionLine:{unifiedLineIndex:S,splitLineIndex:H,lineIndex:C+k,lineNumber:v+k,noEOFCR:R&&o.noEOFCRAdditions}})},()=>{b()}))break n;N+=c.lines,w+=c.lines,I+=c.lines,C+=c.lines,L+=c.lines,v+=c.lines}else{const k=Math.max(c.deletions,c.additions),R=c.deletions+c.additions;if(!i.shouldSkip(R,k)){const S=rn(i,c,e);(S[0]?.[0]??0)>0&&b();for(const[H,E]of S)for(let D=H;D<E;D++){const _=g(N+D,e==="unified"?w+(D<c.deletions?D:D-c.deletions):w+D);if(i.emit(sn({hunkIndex:u,hunk:o,collapsedBefore:b(),collapsedAfter:_,diffStyle:e,index:D,unifiedLineIndex:N,splitLineIndex:w,additionLineIndex:C,deletionLineIndex:I,additionLineNumber:v,deletionLineNumber:L,content:c,isLastContent:p,unifiedCount:R,splitCount:k}),!0))break n}}b(),i.incrementCounts(R,k),N+=R,w+=k,I+=c.deletions,C+=c.additions,L+=c.deletions,v+=c.additions}}if(a!=null){const{collapsedLines:c,fromStart:p,fromEnd:k}=a,R=p+k;if(T(i,R,e,S=>{const H=S===R-1;return i.emit({hunkIndex:n.hunks.length,hunk:void 0,collapsedBefore:0,collapsedAfter:H?c:0,type:"context-expanded",deletionLine:{lineNumber:L+S,lineIndex:I+S,noEOFCR:!1,unifiedLineIndex:N+S,splitLineIndex:w+S},additionLine:{unifiedLineIndex:N+S,splitLineIndex:w+S,lineIndex:C+S,lineNumber:v+S,noEOFCR:!1}})},void 0,()=>i.shouldBreak()))break n}}}function en({diff:n,diffStyle:e,startingLine:r,expandedHunks:l,collapsedContextThreshold:f}){if(r<=0||e==="both")return{hunkIndex:0,splitCount:0,unifiedCount:0};const t=tn({diff:n,expandedHunks:l,collapsedContextThreshold:f});let h=0,d=n.hunks.length-1,i=n.hunks.length;for(;h<=d;){const o=h+d>>1,s=t[o+1];if(s==null)throw new Error("iterateOverDiff: invalid hunk prefix index");(e==="unified"?s.unifiedCount:s.splitCount)>r?(i=o,d=o-1):h=o+1}if(i>=n.hunks.length){const o=t[n.hunks.length];if(o==null)throw new Error("iterateOverDiff: invalid terminal hunk prefix index");return{hunkIndex:n.hunks.length,splitCount:o.splitCount,unifiedCount:o.unifiedCount}}const u=t[i];if(u==null)throw new Error("iterateOverDiff: invalid selected hunk prefix index");return{hunkIndex:i,splitCount:u.splitCount,unifiedCount:u.unifiedCount}}function tn({diff:n,expandedHunks:e,collapsedContextThreshold:r}){let l=0,f=0;const t=n.hunks.length-1,h=[{splitCount:0,unifiedCount:0}];for(let d=0;d<n.hunks.length;d++){const i=n.hunks[d];if(i==null)throw new Error("iterateOverDiff: invalid hunk summary index");const u=B({isPartial:n.isPartial,rangeSize:i.collapsedBefore,expandedHunks:e,hunkIndex:d,collapsedContextThreshold:r}),o=u.fromStart+u.fromEnd;l+=o+i.splitLineCount,f+=o+i.unifiedLineCount;const s=d===t?V({fileDiff:n,hunkIndex:d,expandedHunks:e,collapsedContextThreshold:r,errorPrefix:"iterateOverDiff"}):void 0;if(s!=null){const a=s.fromStart+s.fromEnd;l+=a,f+=a}h.push({splitCount:l,unifiedCount:f})}return h}function on(n,e,r){if(!n.isWindowedHighlight||e<=0)return[0,e];const l=[];function f(d){const i=Math.max(0,n.viewportStart-d),u=Math.min(e,n.viewportEnd-d);u>i&&l.push([i,u])}if(r!=="split"&&f(n.unifiedCount),r!=="unified"&&f(n.splitCount),l.length===0)return[0,0];let t=l[0][0],h=l[0][1];for(let d=1;d<l.length;d++){const i=l[d];t=Math.min(t,i[0]),h=Math.max(h,i[1])}return[t,h]}function T(n,e,r,l,f,t){const[h,d]=on(n,e,r);h>0&&(n.incrementCounts(h,h),f?.());let i=h;for(;i<e;){if(t?.()===!0)return!0;if(i>=d){n.incrementCounts(e-i,e-i);break}if(n.isInWindow(0,0)){if(l(i)===!0)return!0}else n.incrementCounts(1,1);i++}return!1}function rn(n,e,r){if(!n.isWindowedHighlight)return[[0,r==="unified"?e.deletions+e.additions:Math.max(e.deletions,e.additions)]];const l=r!=="split",f=r!=="unified",t=r==="unified"?"unified":"split",h=[];function d(s,a){if(s+a<=n.viewportStart||s>=n.viewportEnd)return;const m=Math.max(0,n.viewportStart-s),g=Math.min(a,n.viewportEnd-s);return g>m?[m,g]:void 0}function i(s,a){return t==="split"?s:a==="additions"?[s[0]+e.deletions,s[1]+e.deletions]:s}function u(s,a){if(s==null)return;const[m,g]=i(s,a);g>m&&h.push([m,g])}if(l&&(u(d(n.unifiedCount,e.deletions),"deletions"),u(d(n.unifiedCount+e.deletions,e.additions),"additions")),f&&(u(d(n.splitCount,e.deletions),"deletions"),u(d(n.splitCount,e.additions),"additions")),h.length===0)return h;h.sort((s,a)=>s[0]-a[0]);const o=[h[0]];for(const[s,a]of h.slice(1)){const m=o[o.length-1];s<=m[1]?m[1]=Math.max(m[1],a):o.push([s,a])}return o}function sn({hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,diffStyle:f,index:t,unifiedLineIndex:h,splitLineIndex:d,additionLineIndex:i,deletionLineIndex:u,additionLineNumber:o,deletionLineNumber:s,content:a,isLastContent:m,unifiedCount:g,splitCount:O}){const b=t<a.deletions?h+t:void 0,N=f==="unified"?t>=a.deletions?h+t:void 0:t<a.additions?h+a.deletions+t:void 0,w=f==="unified"?d+(t<a.deletions?t:t-a.deletions):d+t,I=t<a.deletions?u+t:void 0,C=t<a.deletions?s+t:void 0,L=f==="unified"?t>=a.deletions?i+(t-a.deletions):void 0:t<a.additions?i+t:void 0,v=f==="unified"?t>=a.deletions?o+(t-a.deletions):void 0:t<a.additions?o+t:void 0,x=f==="unified"?m&&t===a.deletions-1&&e.noEOFCRDeletions:m&&t===O-1&&e.noEOFCRDeletions,c=f==="unified"?m&&t===g-1&&e.noEOFCRAdditions:m&&t===O-1&&e.noEOFCRAdditions,p=I!=null&&C!=null&&b!=null?{lineNumber:C,lineIndex:I,noEOFCR:x,unifiedLineIndex:b,splitLineIndex:w}:void 0,k=L!=null&&v!=null&&N!=null?{unifiedLineIndex:N,splitLineIndex:w,lineIndex:L,lineNumber:v,noEOFCR:c}:void 0;if(p==null&&k!=null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:void 0,additionLine:k};if(p!=null&&k==null)return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:void 0};if(p==null||k==null)throw new Error("iterateOverDiff: missing change line data");return{type:"change",hunkIndex:n,hunk:e,collapsedAfter:r,collapsedBefore:l,deletionLine:p,additionLine:k}}function A({line:n,spanStart:e,spanLength:r}){return{start:{line:n,character:e},end:{line:n,character:e+r},properties:{"data-diff-span":""},alwaysWrap:!0}}function F({item:n,arr:e,enableJoin:r,isNeutral:l=!1,isLastItem:f=!1}){const t=e[e.length-1];if(t==null||f||!r){e.push([l?0:1,n.value]);return}const h=t[0]===0;if(l===h||l&&n.value.length===1&&!h){t[1]+=n.value;return}e.push([l?0:1,n.value])}const ln={forcePlainText:!1};function xn(n,e,r,{forcePlainText:l,startingLine:f,totalLines:t,expandedHunks:h,collapsedContextThreshold:d=1}=ln){l?(f??=0,t??=1/0):(f=0,t=1/0);const i=f>0||t<1/0,u=typeof r.theme=="string"?e.getTheme(r.theme).type:void 0,o=j({theme:r.theme,highlighter:e}),s=l&&!i&&(n.unifiedLineCount>1e3||n.splitLineCount>1e3)?"none":r.lineDiffType,a={deletionLines:[],additionLines:[]},{maxLineDiffLength:m}=r,g=!l&&!n.isPartial,O=l?h:void 0,b=new Map;function N(I){const C=g?0:I,L=b.get(C)??un();return b.set(C,L),L}function w(I,C,L,v){if(i){let x=L.at(-1);(x==null||x.targetIndex+x.count!==C)&&(x={targetIndex:C,originalOffset:v.length,count:0},L.push(x)),x.count++}v.push(I)}nn({diff:n,diffStyle:"both",startingLine:f,totalLines:t,expandedHunks:i?O:!0,collapsedContextThreshold:d,callback:({hunkIndex:I,additionLine:C,deletionLine:L,type:v})=>{const x=N(I),c=C!=null?C.splitLineIndex:L.splitLineIndex;v==="change"&&C!=null&&L!=null&&an({additionLine:n.additionLines[C.lineIndex],deletionLine:n.deletionLines[L.lineIndex],deletionLineIndex:x.deletionContent.length,additionLineIndex:x.additionContent.length,deletionDecorations:x.deletionDecorations,additionDecorations:x.additionDecorations,lineDiffType:s,maxLineDiffLength:m}),L!=null&&(w(n.deletionLines[L.lineIndex],L.lineIndex,x.deletionSegments,x.deletionContent),x.deletionInfo.push({type:v==="change"?"change-deletion":v,lineNumber:L.lineNumber,altLineNumber:v==="change"?void 0:C.lineNumber??void 0,lineIndex:`${L.unifiedLineIndex},${c}`})),C!=null&&(w(n.additionLines[C.lineIndex],C.lineIndex,x.additionSegments,x.additionContent),x.additionInfo.push({type:v==="change"?"change-addition":v,lineNumber:C.lineNumber,altLineNumber:v==="change"?void 0:L.lineNumber??void 0,lineIndex:`${C.unifiedLineIndex},${c}`}))}});for(const I of b.values()){if(I.deletionContent.length===0&&I.additionContent.length===0)continue;const C={name:n.prevName??n.name,contents:I.deletionContent.value},L={name:n.name,contents:I.additionContent.value},{deletionLines:v,additionLines:x}=dn({deletionFile:C,deletionInfo:I.deletionInfo,deletionDecorations:I.deletionDecorations,additionFile:L,additionInfo:I.additionInfo,additionDecorations:I.additionDecorations,highlighter:e,options:r,languageOverride:l?"text":n.lang});if(g){a.deletionLines=v,a.additionLines=x;continue}if(I.deletionSegments.length>0)for(const c of I.deletionSegments)for(let p=0;p<c.count;p++)a.deletionLines[c.targetIndex+p]=v[c.originalOffset+p];else a.deletionLines.push(...v);if(I.additionSegments.length>0)for(const c of I.additionSegments)for(let p=0;p<c.count;p++)a.additionLines[c.targetIndex+p]=x[c.originalOffset+p];else a.additionLines.push(...x)}return{code:a,themeStyles:o,baseThemeType:u}}function an({deletionLine:n,additionLine:e,deletionLineIndex:r,additionLineIndex:l,deletionDecorations:f,additionDecorations:t,lineDiffType:h,maxLineDiffLength:d}){if(n==null||e==null||h==="none"||(n=z(n),e=z(e),n.length>d||e.length>d))return;const i=h==="char"?X(n,e):Q(n,e),u=[],o=[],s=h==="word-alt",a=i.at(-1);for(const g of i){const O=g===a;!g.added&&!g.removed?(F({item:g,arr:u,enableJoin:s,isNeutral:!0,isLastItem:O}),F({item:g,arr:o,enableJoin:s,isNeutral:!0,isLastItem:O})):g.removed?F({item:g,arr:u,enableJoin:s,isLastItem:O}):F({item:g,arr:o,enableJoin:s,isLastItem:O})}let m=0;for(const g of u)g[0]===1&&f.push(A({line:r,spanStart:m,spanLength:g[1].length})),m+=g[1].length;m=0;for(const g of o)g[0]===1&&t.push(A({line:l,spanStart:m,spanLength:g[1].length})),m+=g[1].length}function un(){return{deletionContent:{push(n){this.value+=n,this.length++},value:"",length:0},additionContent:{push(n){this.value+=n,this.length++},value:"",length:0},deletionInfo:[],additionInfo:[],deletionDecorations:[],additionDecorations:[],deletionSegments:[],additionSegments:[]}}function dn({deletionFile:n,additionFile:e,deletionInfo:r,additionInfo:l,highlighter:f,deletionDecorations:t,additionDecorations:h,languageOverride:d,options:{theme:i=J,...u}}){const o=d??M(n.name),s=d??M(e.name),{state:a,transformers:m}=G(u.useTokenTransformer),g=typeof i=="string"?{...u,lang:"text",theme:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0}:{...u,lang:"text",themes:i,transformers:m,decorations:void 0,defaultColor:!1,cssVariablePrefix:W("token"),tokenizeTimeLimit:0};return{deletionLines:n.contents===""?[]:(g.lang=o,a.lineInfo=r,g.decorations=t,P(f.codeToHast(z(n.contents),g))),additionLines:e.contents===""?[]:(g.lang=s,g.decorations=h,a.lineInfo=l,P(f.codeToHast(z(e.contents),g)))}}export{mn as a,gn as b,nn as c,B as d,Cn as e,V as f,Y as g,In as h,pn as i,Ln as j,xn as r};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionSwitcherDropdown-JaIDcDIj.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-boot-Dgb9NVFe.js","assets/vendor-react-DASdDPIk.js","assets/vendor-clsx-B-dksMZM.js","assets/useAppFontEffects-BisjofNZ.js","assets/index-BnZVqcki.js","assets/vendor-zustand-CUi8eEds.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/index-BnieExes.css","assets/runtimeSurface-DBiUWYK2.js","assets/nativeFileSave-BzhtrDoD.js"])))=>i.map(i=>d[i]);
2
+ import{k as e,aN as ye}from"./vendor-boot-Dgb9NVFe.js";import{R as c,a as me}from"./vendor-react-DASdDPIk.js";/* empty css */import{o as G,u as J,aF as ge,E as Z,t as ie,aB as U,R as we,V as ve,z as le,w as je,B as be}from"./index-BnZVqcki.js";import{f as Se,u as Ie,a as Ce,s as Ne}from"./pi-session-focus-preference-BC-ze1oC.js";import{bR as De,I as K,aY as Pe,a9 as Me,aa as ke,ac as Ee,bS as _e,bT as Le,h as j,b8 as Oe,a as ae,H as P,as as ce,bU as Te,q as Re,aD as Ae,bF as Be,bu as Fe,B as de,bJ as ze,bV as ue,bW as Ue,t as $e,g as We,R as He,E as Ve,T as Ge,U as Ke,W as Je,V as Ye,Y as qe,Z as Xe,bX as Ze,bG as Qe,a0 as et,a1 as tt,a2 as st,a3 as rt}from"./useAppFontEffects-BisjofNZ.js";import{_ as nt}from"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-DBiUWYK2.js";import"./nativeFileSave-BzhtrDoD.js";const ot=({mode:t,children:r})=>e.jsx(De.Provider,{value:t,children:r}),it=_e,at=Le,ct=({totalTokens:t,percentage:r,colorPercentage:n,contextLimit:a,outputLimit:o,size:u="default",isMobile:l=!1,hideIcon:D=!1,showPercentIcon:E=!1,className:p,valueClassName:f,percentIconClassName:_,onClick:M,pressed:O=!1,cacheRead:x,cacheWrite:C,cacheHitPercent:h})=>{const[b,i]=c.useState(!1),g=typeof n=="number"?n:r,m=it(r)??0,y=at(g),Y=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",k=20,$=3,W=(k-$)/2,re=2*Math.PI*W,q=re*(1-m/100),R=typeof o=="number"?Math.max(o,0):0,A=typeof x=="number"&&typeof C=="number",Q=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(a)}`,`Output limit: ${w(R)}`,...A?[`Cache read: ${w(Q)}`,`Cache write: ${w(B)}`]:[],...L?[`Cache hit: ${h.toFixed(1)}%`]:[],`${Math.min(r,999).toFixed(1)}% used`],F=!l&&typeof M=="function",v=e.jsxs(e.Fragment,{children:[!l&&!D&&e.jsx(K,{name:"donut-chart",className:"h-4 w-4 flex-shrink-0"}),e.jsx("span",{className:G("font-medium inline-flex items-center gap-1.5",f),children:E?e.jsxs(e.Fragment,{children:[e.jsxs("svg",{viewBox:`0 0 ${k} ${k}`,className:G("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:k/2,cy:k/2,r:W,fill:"none",stroke:"var(--interactive-border)",strokeWidth:$}),e.jsx("circle",{cx:k/2,cy:k/2,r:W,fill:"none",stroke:Y,strokeWidth:$,strokeLinecap:"round",strokeDasharray:re,strokeDashoffset:q,className:"transition-[stroke-dashoffset,stroke] duration-300"})]}),e.jsxs("span",{className:"text-foreground",children:[Math.min(r,999).toFixed(1),"%"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:N(g),children:Math.min(r,999).toFixed(1)}),"%"]})})]}),S=G("app-region-no-drag flex items-center gap-1.5 select-none",u==="compact"?"typography-micro":"typography-meta",F?G("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",p),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?()=>i(!0):void 0,children:v});return l?e.jsxs(e.Fragment,{children:[H,e.jsx(Pe,{open:b,onClose:()=>i(!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(a)})]}),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(Q)})]}),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:G("typography-meta font-semibold",N(g)),children:[Math.min(r,999).toFixed(1),"%"]})]})]})})})]}):e.jsxs(Me,{children:[e.jsx(ke,{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))})})]})},lt=c.lazy(()=>nt(()=>import("./SessionSwitcherDropdown-JaIDcDIj.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(t=>({default:t.SessionSwitcherDropdown}))),dt=t=>{const r=typeof t=="string"?t.trim():"";if(!r)return"";const n=typeof window<"u"?window.__PICHAMBER_HOME__:"";if(n&&r===n)return"~";if(n&&r.startsWith(`${n}/`))return`~/${r.slice(n.length+1)}`;const a=r.split("/").filter(Boolean);return a.length<=3?r:`.../${a.slice(-3).join("/")}`},se=t=>{const r=typeof t=="string"?t.trim():"";if(!r)return"";const n=r.replace(/\\/g,"/");return n==="/"?"/":n.replace(/\/+$/,"")},ut=({mode:t})=>{const r=j(s=>s.currentSessionId),n=j(s=>!!s.newSessionDraft?.open),a=j(s=>s.newSessionDraft?.selectedProjectId??null),o=J(s=>s.currentDirectory),u=ae(s=>s.projects),l=ae(s=>s.getActiveProject()),D=P(s=>s.getCurrentModel),E=P(s=>s.providers),p=ce(),f=Te(r??""),_=Re(),M=Ae(s=>s.ensureStatus),O=j(s=>s.newSessionDraft?.open?se(s.newSessionDraft.directoryOverride??""):""),[x,C]=c.useState(!1),h=typeof window<"u"?window.__PICHAMBER_MACOS_MAJOR__??0:0,b=Number.isFinite(h)&&h>0,i=Be(),g=b?h>=26?"h-12":h<=15?"h-14":"":"",m=c.useMemo(()=>r?p.find(s=>s.id===r)??null:null,[r,p]);c.useEffect(()=>{ge()&&Z("desktop_get_window_pinned").then(s=>{typeof s?.pinned=="boolean"&&C(s.pinned)})},[]);const y=m?.title?.trim()||(n||t==="draft"?"New session":"Session"),Y=se(m?.directory??null),w=se(o),N=Y||O||w,k=dt(N);c.useEffect(()=>{N&&M(N,_.git).catch(()=>{})},[M,N,_.git]);const $=c.useMemo(()=>{const s=N;return s?u.map(d=>({...d,normalizedPath:se(d.path)})).filter(d=>d.normalizedPath&&(d.normalizedPath===s||s.startsWith(`${d.normalizedPath}/`))).sort((d,V)=>V.path.length-d.path.length)[0]??null:null},[N,u]),W=c.useMemo(()=>{const s=$??l;if(!s)return k||"PiChamber";const d=s.label?.trim();return d||(s.path.split(/[\\/]/).filter(Boolean).at(-1)??s.path)},[l,k,$]),q=Fe(N||null),R=q&&q!=="HEAD"?q:null,A=D(),Q=c.useMemo(()=>{for(let s=f.length-1;s>=0;s-=1){const d=f[s];if(d.role!=="assistant"||typeof d.providerID!="string"||typeof d.modelID!="string")continue;const te=E.find(X=>X.id===d.providerID)?.models.find(X=>X.id===d.modelID);if(te)return te}},[f,E]),B=A?.limit?A:Q,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=c.useMemo(()=>{if(!r||f.length===0)return null;let s,d;for(let ne=f.length-1;ne>=0;ne-=1){const oe=f[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){s=z,d=oe.id;break}}if(!s)return null;const V=s.input+s.output+s.reasoning+(s.cache?.read??0)+(s.cache?.write??0),te=T>0?T:2e5,X=T>0?Math.round(V/T*100):0,xe=F>0?Math.round(s.output/F*100):void 0;return{totalTokens:V,percentage:X,contextLimit:T||0,outputLimit:F||void 0,normalizedOutput:xe,thresholdLimit:te,lastMessageId:d}},[T,r,f,F]),[S,H]=c.useState(null),I={WebkitAppRegion:"drag"},ee={WebkitAppRegion:"no-drag"};c.useEffect(()=>{if(!r){H(s=>s===null?s:null);return}if(v&&v.totalTokens>0){H(s=>s&&s.totalTokens===v.totalTokens&&s.percentage===v.percentage&&s.contextLimit===v.contextLimit&&(s.outputLimit??0)===(v.outputLimit??0)&&(s.normalizedOutput??0)===(v.normalizedOutput??0)&&s.thresholdLimit===v.thresholdLimit&&s.lastMessageId===v.lastMessageId?s:v);return}H(s=>s===null?s:null)},[v,r]);const fe=S&&S.contextLimit>0?Math.min(999,S.totalTokens/S.contextLimit*100):0,pe=c.useCallback(()=>{const s=!x;C(s),Z("desktop_set_window_pinned",{pinned:s}).catch(()=>{C(!s)})},[x]),he=c.useCallback(()=>{const s=r?{sessionId:r,directory:m?.directory??o??""}:{mode:"draft",directory:N||o||"",projectId:a};Z("desktop_focus_main_window",s).then(d=>d?.focused===!0?Z("desktop_close_current_window"):null)},[o,r,a,N,m]);return e.jsxs("header",{className:G("flex items-center gap-3 bg-background pr-3",b?"pl-[5.5rem]":"pl-3",i?"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(K,{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(lt,{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(K,{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(ct,{totalTokens:S.totalTokens,percentage:fe,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:pe,"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(K,{name:"pushpin-2-fill",className:"h-4 w-4"}):e.jsx(K,{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(K,{name:"external-link",className:"h-4 w-4"})}),e.jsx(ze,{visible:i})]})},mt=({mode:t,autoOpenDraft:r=!1,unavailable:n=!1})=>{const a=j(o=>o.currentSessionId);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[e.jsx(ut,{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(ot,{mode:"mini-chat",children:e.jsx(Oe,{autoOpenDraft:r},a??"no-session")})})]})},ft=()=>{const t=ie(o=>o.shortcutOverrides),r=J(o=>o.currentDirectory),n=ae(o=>o.getActiveProject()),a=j(o=>o.openNewSessionDraft);c.useEffect(()=>{const o=l=>ve(l,t),u=l=>{if(U(l,o("focus_input"))){l.preventDefault(),ue();return}if(we()&&U(l,o("new_mini_chat"))){l.preventDefault(),Z("desktop_open_draft_mini_chat_window",{directory:r||n?.path||"",projectId:n?.id??null})?.catch(p=>{console.warn("[mini-chat-shortcuts] failed to open draft mini chat window",p)});return}if(U(l,o("new_chat"))){l.preventDefault(),a({selectedProjectId:n?.id??null,directoryOverride:r||n?.path||null,preserveDirectoryOverride:!!(r||n?.path)}),ue();return}if(U(l,o("open_model_selector"))){l.preventDefault();const{isModelSelectorOpen:p,setModelSelectorOpen:f}=ie.getState();f(!p);return}if(U(l,o("cycle_thinking_variant"))){if(P.getState().getCurrentModelVariants().length===0)return;l.preventDefault(),Ue(1).catch(()=>{$e.error("Couldn't update thinking")});return}const D=U(l,o("cycle_favorite_model_forward")),E=U(l,o("cycle_favorite_model_backward"));if(D||E){const{favoriteModels:p,addRecentModel:f}=ie.getState();if(p.length===0)return;l.preventDefault();const{currentProviderId:_,currentModelId:M,setProvider:O,setModel:x}=P.getState(),C=p.findIndex(i=>i.providerID===_&&i.modelID===M),b=p[(C+(D?1:-1)+p.length)%p.length];O(b.providerID),x(b.modelID),f(b.providerID,b.modelID)}};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[n?.id,n?.path,r,a,t])},pt="pichamber:mini-chat-presence",ht=()=>{const t=typeof window<"u"?new URLSearchParams(window.location.search):new URLSearchParams,r=t.get("mode")==="session"?"session":"draft",n=t.get("sessionId")?.trim()||null,a=t.get("directory")?.trim()||null,o=t.get("projectId")?.trim()||null;return{mode:r,sessionId:n,directory:a,projectId:o}},xt=({config:t})=>{const r=ce(),n=J(i=>i.currentDirectory),a=J(i=>i.setDirectory),o=j(i=>i.currentSessionId),u=j(i=>!!i.newSessionDraft?.open),l=j(i=>i.newSessionDraft?.open?i.newSessionDraft.bootstrapPendingDirectory??i.newSessionDraft.directoryOverride??"":""),D=j(i=>i.setCurrentSession),E=j(i=>i.openNewSessionDraft),p=P(i=>i.initializeApp),f=P(i=>i.isInitialized),_=P(i=>i.isConnected),M=P(i=>i.loadProviders),O=P(i=>i.providers.length),x=Qe();c.useEffect(()=>{p()},[p]),c.useEffect(()=>{if(f)return;let i=!0,g=0;const m=window.setInterval(()=>{if(i){if(g+=1,g>10){window.clearInterval(m);return}P.getState().isInitialized||P.getState().initializeApp()}},1e3);return()=>{i=!1,window.clearInterval(m)}},[f]);const C=c.useRef(!1);c.useEffect(()=>{if(!C.current&&t.mode==="session"&&t.directory){if(n===t.directory){C.current=!0;return}a(t.directory,{showOverlay:!1}),C.current=!0}},[t.directory,t.mode,n,a]),c.useEffect(()=>{t.mode!=="draft"||!u||o||!l||n===l||a(l,{showOverlay:!1})},[t.mode,n,o,l,u,a]),c.useEffect(()=>{_&&O===0&&M({source:"electronMiniChat:recovery"})},[_,M,O]);const h=c.useRef(!1);c.useEffect(()=>{if(h.current||t.mode!=="session"||!t.sessionId)return;if(o===t.sessionId){h.current=!0;return}if(o){h.current=!0;return}const i=r.find(m=>m.id===t.sessionId);if(!i){x.ensureSessionRenderable(t.sessionId);return}const g=i.directory??t.directory;D(t.sessionId,g),h.current=!0},[t,o,r,D,x]),c.useEffect(()=>{const i=g=>{const m=g.detail,y=typeof m?.sessionId=="string"?m.sessionId.trim():"";if(!y||j.getState().currentSessionId===y)return;const Y=typeof m?.directory=="string"&&m.directory.trim().length>0?m.directory.trim():r.find(w=>w.id===y)?.directory??null;x.ensureSessionRenderable(y),D(y,Y),h.current=!0};return window.addEventListener("pichamber:open-session",i),()=>window.removeEventListener("pichamber:open-session",i)},[r,D,x]),c.useEffect(()=>{t.mode!=="draft"||u||o||E({selectedProjectId:t.projectId,directoryOverride:t.directory,preserveDirectoryOverride:!!t.directory})},[t,o,u,E]);const b=c.useRef(!1);return c.useEffect(()=>{if(b.current||!f)return;const i=()=>{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"?o===t.sessionId:u,m=window.setTimeout(i,g?100:1500);return()=>window.clearTimeout(m)},[f,t.mode,t.sessionId,o,u]),null},yt=()=>{const t=j(n=>n.currentSessionId),r=J(n=>n.currentDirectory);return c.useEffect(()=>{if(!t||!r||typeof BroadcastChannel>"u")return;const n=new BroadcastChannel(pt),a=l=>{n.postMessage({type:"mini-chat-session-presence",sessionId:t,directory:r,viewed:l})};a(!0);const o=window.setInterval(()=>a(!0),5e3),u=()=>a(!1);return window.addEventListener("beforeunload",u),()=>{window.clearInterval(o),window.removeEventListener("beforeunload",u),a(!1),n.close()}},[r,t]),null},gt=t=>{const r=ce(),n=j(u=>u.currentSessionId),[a,o]=c.useState(!1);return c.useEffect(()=>{if(t.mode!=="session"||!t.sessionId||n===t.sessionId){o(!1);return}if(r.some(l=>l.id===t.sessionId)){o(!1);return}const u=window.setTimeout(()=>o(!0),5e3);return()=>window.clearTimeout(u)},[t.mode,t.sessionId,n,r]),a};function wt({apis:t}){const r=c.useMemo(()=>ht(),[]),n=J(a=>a.currentDirectory);return c.useEffect(()=>{const a=n||r.directory;if(!a)return;const o=r.mode==="session"?{sessionId:r.sessionId,directory:r.directory}:null;We().focusProject(a,Se(a,o))},[r.directory,r.mode,r.sessionId,n]),c.useEffect(()=>(le(t),()=>le(null)),[t]),He(),ft(),Ie({enabled:!0}),e.jsx(Ve,{children:e.jsx(Ge,{directory:n||r.directory,children:e.jsxs(Ke,{apis:t,children:[e.jsx(Je,{}),e.jsx(Ye,{delayDuration:300,skipDelayDuration:150,children:e.jsxs("div",{className:"h-full text-foreground bg-background",children:[e.jsx(vt,{config:r}),e.jsx(qe,{}),e.jsx(Xe,{})]})})]})})})}const vt=({config:t})=>{const r=gt(t);return e.jsxs(e.Fragment,{children:[e.jsx(xt,{config:t}),e.jsx(yt,{}),e.jsx(Ze,{embeddedBackgroundWorkEnabled:!0}),e.jsx(mt,{mode:t.mode,autoOpenDraft:t.mode==="draft",unavailable:r})]})},jt=()=>{(async()=>{try{await Promise.all([be(),Ce()])}catch(t){console.error("[mini-chat-main] settings init failed:",t)}st(),rt(),Ne()})()};function Rt(t){const r=t??je();if(!r)throw new Error("Runtime APIs not registered");jt();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(et,{children:e.jsx(tt,{children:e.jsx(wt,{apis:r})})})}))}export{Rt as renderElectronMiniChatApp};
@@ -1 +1 @@
1
- import{t as I}from"./themeResolver-yJ9XpNMI.js";import{b as R,i as y,j as k,k as A,l as S,m as T}from"./computeVirtualFileMetrics-CeMpF2xC.js";import{c5 as _}from"./useAppFontEffects-CG3_yteE.js";function w(e){return I.hasResolvedThemes(e)}function z(e,t){return R(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function D(e){return(e.lang??y(e.name))==="text"}const d=10,g=13;function N(e){const t=[0];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);(r===d||r===g)&&(r===g&&n+1<e.length&&e.charCodeAt(n+1)===d&&n++,t.push(n+1))}return t}function P(e){const t=N(e);return Array.from({length:t.length},(n,r)=>{const i=t[r],s=t[r+1]??e.length;return e.slice(i,s)})}const b={forcePlainText:!1};function M(e,t,{theme:n=_,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:s,startingLine:o,totalLines:a,lines:E}=b){s?(o??=0,a??=1/0):(o=0,a=1/0);const f=o>0||a<1/0,{state:F,transformers:l}=k(i),c=s?"text":e.lang??y(e.name),x=typeof n=="string"?t.getTheme(n).type:void 0,p=A({theme:n,highlighter:t});F.lineInfo=u=>({type:"context",lineIndex:u-1+o,lineNumber:u+o});const C=typeof n=="string"?{lang:c,theme:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:c,themes:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},m=S(t.codeToHast(f?H(E??P(e.contents),o,a):e.contents,C)),h=f?new Array(o):m;return f&&h.push(...m),{code:h,themeStyles:p,baseThemeType:x}}function H(e,t,n){if(e.length===0)return"";const r=Math.min(t+n,e.length);return e.slice(t,r).join("")}export{z as a,w as h,D as i,P as l,M as r};
1
+ import{t as I}from"./themeResolver-yJ9XpNMI.js";import{b as R,i as y,j as k,k as A,l as S,m as T}from"./computeVirtualFileMetrics-CyhUKEfv.js";import{c5 as _}from"./useAppFontEffects-BisjofNZ.js";function w(e){return I.hasResolvedThemes(e)}function z(e,t){return R(e.theme,t.theme)&&e.useTokenTransformer===t.useTokenTransformer&&e.tokenizeMaxLineLength===t.tokenizeMaxLineLength}function D(e){return(e.lang??y(e.name))==="text"}const d=10,g=13;function N(e){const t=[0];for(let n=0;n<e.length;n++){const r=e.charCodeAt(n);(r===d||r===g)&&(r===g&&n+1<e.length&&e.charCodeAt(n+1)===d&&n++,t.push(n+1))}return t}function P(e){const t=N(e);return Array.from({length:t.length},(n,r)=>{const i=t[r],s=t[r+1]??e.length;return e.slice(i,s)})}const b={forcePlainText:!1};function M(e,t,{theme:n=_,tokenizeMaxLineLength:r,useTokenTransformer:i},{forcePlainText:s,startingLine:o,totalLines:a,lines:E}=b){s?(o??=0,a??=1/0):(o=0,a=1/0);const f=o>0||a<1/0,{state:F,transformers:l}=k(i),c=s?"text":e.lang??y(e.name),x=typeof n=="string"?t.getTheme(n).type:void 0,p=A({theme:n,highlighter:t});F.lineInfo=u=>({type:"context",lineIndex:u-1+o,lineNumber:u+o});const C=typeof n=="string"?{lang:c,theme:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0}:{lang:c,themes:n,transformers:l,defaultColor:!1,cssVariablePrefix:T("token"),tokenizeMaxLineLength:r,tokenizeTimeLimit:0},m=S(t.codeToHast(f?H(E??P(e.contents),o,a):e.contents,C)),h=f?new Array(o):m;return f&&h.push(...m),{code:h,themeStyles:p,baseThemeType:x}}function H(e,t,n){if(e.length===0)return"";const r=Math.min(t+n,e.length);return e.slice(t,r).join("")}export{z as a,w as h,D as i,P as l,M as r};