sliccy 6.190.0 → 6.192.0

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 (210) hide show
  1. package/dist/node-server/_shared/tray-sync-protocol.d.ts +22 -1
  2. package/dist/node-server/_shared/tray-sync-protocol.d.ts.map +1 -1
  3. package/dist/node-server/_shared/tray-sync-protocol.js +5 -1
  4. package/dist/node-server/_shared/tray-sync-protocol.js.map +1 -1
  5. package/dist/ui/.vite/manifest.json +202 -200
  6. package/dist/ui/assets/{CLAUDE-BMBoR1hd.js → CLAUDE-Cp-Dty1s.js} +1 -1
  7. package/dist/ui/assets/{MEMORY-Dl8Y_nOo.js → MEMORY-CbB3xjAS.js} +1 -1
  8. package/dist/ui/assets/__vite-browser-external-CnFJWAkm.js +1 -0
  9. package/dist/ui/assets/account-store-Bevys7WL.js +2 -0
  10. package/dist/ui/assets/account-store-irTFXEHq.js +1 -0
  11. package/dist/ui/assets/{adobe-DAk5mRTR.js → adobe-C2Yk0FjU.js} +1 -1
  12. package/dist/ui/assets/{adobe-CMB6BAX8.js → adobe-CxPY_Nvf.js} +1 -1
  13. package/dist/ui/assets/{agent-panels-BLEQfwy2.js → agent-panels-CDAHwcGe.js} +1 -1
  14. package/dist/ui/assets/{almost-bash-shell-headless-B40I6EzY.js → almost-bash-shell-headless-B6lKPYip.js} +41 -38
  15. package/dist/ui/assets/{apply-layout-D4hoY6q2.js → apply-layout-BaPTlEmq.js} +1 -1
  16. package/dist/ui/assets/{apps-oTATee4K.js → apps-CWLDElDt.js} +1 -1
  17. package/dist/ui/assets/{azure-openai-BUzdslaw.js → azure-openai-BrEMU1w0.js} +1 -1
  18. package/dist/ui/assets/{azure-openai-vgxsDn6T.js → azure-openai-CAmcCxYK.js} +1 -1
  19. package/dist/ui/assets/{backend-hostfs-DyW6kRxx.js → backend-hostfs-DVOOQmWO.js} +1 -1
  20. package/dist/ui/assets/bedrock-camp-CMfZujT_.js +1 -0
  21. package/dist/ui/assets/bedrock-camp-Ck_nFSMy.js +1 -0
  22. package/dist/ui/assets/bedrock-camp-compat-Bdpnq7TU.js +1 -0
  23. package/dist/ui/assets/bedrock-camp-compat-Bz7u6y4g.js +1 -0
  24. package/dist/ui/assets/bedrock-camp-extra-models-D5MhCrhJ.js +1 -0
  25. package/dist/ui/assets/bedrock-camp-extra-models-IBZyfEdZ.js +1 -0
  26. package/dist/ui/assets/{browser-BPbYUZ91.js → browser-DL3zbJrM.js} +10 -11
  27. package/dist/ui/assets/{bsh-watchdog-CmaS7wa9.js → bsh-watchdog-CCz8gp5d.js} +1 -1
  28. package/dist/ui/assets/buffer-polyfill-BwLbCySD.js +1 -0
  29. package/dist/ui/assets/{cdp-BBXpHC3W.js → cdp-l5Vq6Mtp.js} +1 -1
  30. package/dist/ui/assets/{cerebras-DUTPWZ3a.js → cerebras-COJ_qkGu.js} +1 -1
  31. package/dist/ui/assets/{cerebras-Bm9kz-h8.js → cerebras-DyJkWRm7.js} +1 -1
  32. package/dist/ui/assets/{composer-speech-D0uHFdYf.js → composer-speech-CYdWOXqF.js} +1 -1
  33. package/dist/ui/assets/{connect-surface-Gme43nbM.js → connect-surface-DnaS1qCD.js} +1 -1
  34. package/dist/ui/assets/{core-BfCKeVcE.js → core-PJsXG3mm.js} +1 -1
  35. package/dist/ui/assets/{cost-command-BQTDpqWV.js → cost-command-DC0JwdLM.js} +1 -1
  36. package/dist/ui/assets/{directed-approval-C-N4Lyz-.js → directed-approval-Bo1zb-ki.js} +1 -1
  37. package/dist/ui/assets/emscripten-vfs-hook-DORb16y9.js +1 -0
  38. package/dist/ui/assets/{emscripten-vfs-hook-DNWfHxzZ.js → emscripten-vfs-hook-jxmK_i72.js} +1 -1
  39. package/dist/ui/assets/{ensure-speech-assets-CslAjHHs.js → ensure-speech-assets-DXQUrOok.js} +1 -1
  40. package/dist/ui/assets/{esbuild-wasm-CeZYVyQ9.js → esbuild-wasm-CbTVjIj0.js} +1 -1
  41. package/dist/ui/assets/{ffmpeg-wasm-CV1BmGNS.js → ffmpeg-wasm-CmLVzRDe.js} +1 -1
  42. package/dist/ui/assets/{frozen-archive-writer-Bzn2q24C.js → frozen-archive-writer-C_qn0GDJ.js} +1 -1
  43. package/dist/ui/assets/{fs-DnLOvvvT.js → fs-D5UZBrBX.js} +1 -1
  44. package/dist/ui/assets/{fs-D1Dp_Ep1.js → fs-DouF0VP9.js} +2 -2
  45. package/dist/ui/assets/{gelatiere-store-BzLpmCkk.js → gelatiere-store-D0SzDyoX.js} +1 -1
  46. package/dist/ui/assets/{gelatiere-unit-CWRGe17z.js → gelatiere-unit-D0eC3q8k.js} +1 -1
  47. package/dist/ui/assets/{github-DWvM7A3I.js → github-CMMdXD7-.js} +1 -1
  48. package/dist/ui/assets/{github-CiP7BlgM.js → github-DrXxnqrr.js} +2 -2
  49. package/dist/ui/assets/{github-auth-Bw46MVyY.js → github-auth-CVs8hOEW.js} +1 -1
  50. package/dist/ui/assets/{github-copilot-Cw6ggpYJ.js → github-copilot-BDW-hvGU.js} +1 -1
  51. package/dist/ui/assets/{github-copilot-DPCFqh6W.js → github-copilot-F_OWE6ig.js} +1 -1
  52. package/dist/ui/assets/{github-install-BMRS10U5.js → github-install-B-rr32FO.js} +1 -1
  53. package/dist/ui/assets/{github-zip-BuNrfmPG.js → github-zip-DA_-VtNu.js} +1 -1
  54. package/dist/ui/assets/{guest-tool-gate-XJ21QL4L.js → guest-tool-gate-CaXA5eEm.js} +1 -1
  55. package/dist/ui/assets/{hear-C9TMsdyp.js → hear-B1QjKHJS.js} +1 -1
  56. package/dist/ui/assets/{help-CT-6K18M.js → help-C3q6Ha5a.js} +1 -1
  57. package/dist/ui/assets/{host-command-AyzKgQLr.js → host-command-DTM6_CU_.js} +1 -1
  58. package/dist/ui/assets/{installer-BqstqF0q.js → installer-BamTBGiN.js} +1 -1
  59. package/dist/ui/assets/{interrupted-work-recovery-DvvxB451.js → interrupted-work-recovery-4r2qWReh.js} +1 -1
  60. package/dist/ui/assets/{js-realm-worker-By6mzrxF.js → js-realm-worker-CIzPgKVU.js} +14 -14
  61. package/dist/ui/assets/{jsh-executor-DkQ_pn3q.js → jsh-executor-8n8-NVRR.js} +4 -4
  62. package/dist/ui/assets/{kernel-worker-Cp4UmRK8.js → kernel-worker-YhNfUQ_y.js} +57 -57
  63. package/dist/ui/assets/{lick-ws-bridge-4OMsthUP.js → lick-ws-bridge-BWmnM4i8.js} +1 -1
  64. package/dist/ui/assets/{lick-ws-bridge-Di__mYYU.js → lick-ws-bridge-CDPuY-EA.js} +1 -1
  65. package/dist/ui/assets/{live-session-curation-Df4vTXXp.js → live-session-curation-eGH4uyM1.js} +1 -1
  66. package/dist/ui/assets/{live-session-snapshot-DMDS-wW3.js → live-session-snapshot-CAY9GlTD.js} +1 -1
  67. package/dist/ui/assets/live-vfs-fs-CX95TogC.js +1 -0
  68. package/dist/ui/assets/{local-llm-DvXzOnVy.js → local-llm-CsIWLXJ2.js} +1 -1
  69. package/dist/ui/assets/{local-llm-w0RCshcM.js → local-llm-dPetWUMs.js} +1 -1
  70. package/dist/ui/assets/{magick-wasm-KFp97Nzb.js → magick-wasm-BATj-KUu.js} +1 -1
  71. package/dist/ui/assets/{main-BZ7qq-Vs.js → main-DUD5pTDH.js} +3 -3
  72. package/dist/ui/assets/{main-cherry-npF7LwF_.js → main-cherry-BoO4BB-J.js} +1 -1
  73. package/dist/ui/assets/{memory-curation-seam-C0BliwwJ.js → memory-curation-seam-DFftwyHh.js} +1 -1
  74. package/dist/ui/assets/{memory-health-C3D8lYLJ.js → memory-health-DF6IEFmt.js} +1 -1
  75. package/dist/ui/assets/{memory-write-execute-DbjHzPlQ.js → memory-write-execute-C7SUGCPF.js} +1 -1
  76. package/dist/ui/assets/{mount-CbM_5jlW.js → mount-BfPgf0TT.js} +1 -1
  77. package/dist/ui/assets/{mount-Cc1ACftx.js → mount-BsWbgqHU.js} +3 -3
  78. package/dist/ui/assets/{new-session-Dhc5HhIU.js → new-session-n4ieWj9Q.js} +2 -2
  79. package/dist/ui/assets/node-builtins-CDetdLPH.js +1 -0
  80. package/dist/ui/assets/{oauth-bootstrap-qAiKs1B_.js → oauth-bootstrap-DEjPbx0S.js} +2 -2
  81. package/dist/ui/assets/{onboarding-orchestrator-hoO7C1AA.js → onboarding-orchestrator-DTq_WzOT.js} +1 -1
  82. package/dist/ui/assets/{openai-codex-COpScXj-.js → openai-codex-CRBPHYXu.js} +1 -1
  83. package/dist/ui/assets/{openai-codex-DG55IJPc.js → openai-codex-CZFJxrdp.js} +1 -1
  84. package/dist/ui/assets/{openrouter-oXd9rfD3.js → openrouter-Bp2hCSj0.js} +1 -1
  85. package/dist/ui/assets/{openrouter-free-CCSSamEo.js → openrouter-free-B1aHr6YX.js} +1 -1
  86. package/dist/ui/assets/{openrouter-free-CcVhLq57.js → openrouter-free-Ciud-jQF.js} +1 -1
  87. package/dist/ui/assets/{openrouter-oauth-2uZjw1ni.js → openrouter-oauth-BShl7mda.js} +1 -1
  88. package/dist/ui/assets/{openrouter-oauth-D79F7soa.js → openrouter-oauth-CBNfp9B7.js} +1 -1
  89. package/dist/ui/assets/{openrouter-CvejhujC.js → openrouter-xrK_Q7tb.js} +1 -1
  90. package/dist/ui/assets/{opfs-mount-DLFtoGv0.js → opfs-mount-DF1_TQm7.js} +1 -1
  91. package/dist/ui/assets/{panel-rpc-handlers-7ANN9krW.js → panel-rpc-handlers-DYotibPR.js} +2 -2
  92. package/dist/ui/assets/{panelize-shell-DvvHjgSE.js → panelize-shell-5hKkbwSl.js} +1 -1
  93. package/dist/ui/assets/{pi-edit-execution-B9ByKtUU.js → pi-edit-execution-CcLt8vSI.js} +1 -1
  94. package/dist/ui/assets/{provider-Dx5FZDvY.js → provider-BLshPMsZ.js} +2 -2
  95. package/dist/ui/assets/{provider-sZNLAM5_.js → provider-DqEfigmv.js} +1 -1
  96. package/dist/ui/assets/{provider-settings-geYZ3XeM.js → provider-settings-BuaTQYid.js} +1 -1
  97. package/dist/ui/assets/provider-store-access-BABW1Cfu.js +1 -0
  98. package/dist/ui/assets/provider-store-access-C2xFS3NU.js +1 -0
  99. package/dist/ui/assets/{providers-Cv9xIHXL.js → providers-B3cOXz1H.js} +1 -1
  100. package/dist/ui/assets/providers-CE4VqQs6.js +2 -0
  101. package/dist/ui/assets/{py-live-vfs-Uud7Qmjl.js → py-live-vfs-9-2YNjh0.js} +1 -1
  102. package/dist/ui/assets/{py-live-vfs-DeChUQwG.js → py-live-vfs-CUJmBBlI.js} +1 -1
  103. package/dist/ui/assets/{py-realm-worker-CpOMOUd5.js → py-realm-worker-DtGB9J_v.js} +1 -1
  104. package/dist/ui/assets/{pyodide-DFCa52VK.js → pyodide-D9Uqa092.js} +2 -2
  105. package/dist/ui/assets/{quick-llm-CpA-UQN0.js → quick-llm-D1wGZooG.js} +1 -1
  106. package/dist/ui/assets/realm-inprocess-Dcn5yLm3.js +33 -0
  107. package/dist/ui/assets/realm-unhandled-rejections-BU76F0PI.js +1 -0
  108. package/dist/ui/assets/realm-unhandled-rejections-BXxVemlU.js +1 -0
  109. package/dist/ui/assets/{recovery-screen-i_JWvRnt.js → recovery-screen-D6HBp0xj.js} +1 -1
  110. package/dist/ui/assets/{remote-terminal-view-g-DPTw6U.js → remote-terminal-view-BDO5t9M_.js} +2 -2
  111. package/dist/ui/assets/{require-guards-DyoCy2Tn.js → require-guards-e8NvgvH_.js} +2 -2
  112. package/dist/ui/assets/{restore-Yho5__FC.js → restore-CdH_ze1C.js} +1 -1
  113. package/dist/ui/assets/{run-BvmSPgsD.js → run-B4snw1GL.js} +2 -2
  114. package/dist/ui/assets/{run-Czj6x4Rv.js → run-C-NU4dPD.js} +1 -1
  115. package/dist/ui/assets/{run-OgGDVYh4.js → run-CK7bQLZ0.js} +3 -3
  116. package/dist/ui/assets/{run-Dc0GjGeK.js → run-C_6GKpBV.js} +1 -1
  117. package/dist/ui/assets/{run-Clez1C47.js → run-CkKb9UWF.js} +2 -2
  118. package/dist/ui/assets/{run-DRsWmRGT.js → run-D2pF2y1_.js} +1 -1
  119. package/dist/ui/assets/{run-CyJBimTl.js → run-DNvbqTbo.js} +1 -1
  120. package/dist/ui/assets/{run-BKoiZyLe.js → run-DsYsM6Yl.js} +1 -1
  121. package/dist/ui/assets/{run-DK9rNW7X.js → run-fHfrubKD.js} +1 -1
  122. package/dist/ui/assets/{run-bWHW0TzP.js → run-xrVX3llR.js} +1 -1
  123. package/dist/ui/assets/{screencapture-run-Dt7lEfIp.js → screencapture-run-jNQom_As.js} +1 -1
  124. package/dist/ui/assets/{session-command-memory-DwQY_-Jn.js → session-command-memory-CGqbKVAE.js} +2 -2
  125. package/dist/ui/assets/{session-jsonl-BPjOpnuv.js → session-jsonl-CbNA3lGB.js} +1 -1
  126. package/dist/ui/assets/{session-jsonl-D5OWzUb8.js → session-jsonl-CgKvYDUr.js} +1 -1
  127. package/dist/ui/assets/{session-search-index-CQCVYWik.js → session-search-index-CKHuYyZd.js} +1 -1
  128. package/dist/ui/assets/{setup-feature-flags-remote-Da98m8-c.js → setup-feature-flags-remote-DU_3gSCe.js} +1 -1
  129. package/dist/ui/assets/{setup-model-catalog-CpN89kS0.js → setup-model-catalog-CQmIQSJ6.js} +1 -1
  130. package/dist/ui/assets/shared-2XhBobrM.js +4 -0
  131. package/dist/ui/assets/{signed-fetch-B9AefGxo.js → signed-fetch-DEi8arT4.js} +1 -1
  132. package/dist/ui/assets/{silent-renew-backoff-D4BkLCku.js → silent-renew-backoff-UU1St8tN.js} +1 -1
  133. package/dist/ui/assets/slicc-version-D8Zbv4vp.js +1 -0
  134. package/dist/ui/assets/{snapshot-BpngInyf.js → snapshot-BPuldVwP.js} +1 -1
  135. package/dist/ui/assets/{snapshot-features-C1KRnKvW.js → snapshot-features-Ddz9jsBd.js} +1 -1
  136. package/dist/ui/assets/{soundscape-55hCbegl.js → soundscape-Uopjnq2I.js} +1 -1
  137. package/dist/ui/assets/{speak-DRjoNxOT.js → speak-D_PLnidz.js} +1 -1
  138. package/dist/ui/assets/{sprinkle-manager-Cj9OtFk7.js → sprinkle-manager-BpNh9Lri.js} +1 -1
  139. package/dist/ui/assets/{sprinkle-renderer-DvisyAbr.js → sprinkle-renderer-BljwWT0g.js} +1 -1
  140. package/dist/ui/assets/src-CUSndb9K.js +1 -0
  141. package/dist/ui/assets/{ssh-hwEw2JDy.js → ssh-DBPFvqmL.js} +1 -1
  142. package/dist/ui/assets/{state-xnCFNcHc.js → state-CHrSe9Ro.js} +1 -1
  143. package/dist/ui/assets/{store-CsgLyaBu.js → store-BikzV66S.js} +1 -1
  144. package/dist/ui/assets/{store-BZUZEii9.js → store-BvFCmAq8.js} +1 -1
  145. package/dist/ui/assets/{sudo-CpM0_7-f.js → sudo-rquT1VWH.js} +1 -1
  146. package/dist/ui/assets/{supervisor-CCtgWHNU.js → supervisor-MXcG8SU6.js} +1 -1
  147. package/dist/ui/assets/{sync-dialog-kfyeJrvC.js → sync-dialog-zmsfROKR.js} +1 -1
  148. package/dist/ui/assets/temperature-support-CIu8ekGh.js +1 -0
  149. package/dist/ui/assets/temperature-support-D3pN575q.js +1 -0
  150. package/dist/ui/assets/{transformers-env-D0Ft5AnW.js → transformers-env-DVU2J7Xd.js} +1 -1
  151. package/dist/ui/assets/tray-leader-5xt9j15D.js +1 -0
  152. package/dist/ui/assets/{tray-leave-runtime-D1kxfPYV.js → tray-leave-runtime-B5LmQl4b.js} +1 -1
  153. package/dist/ui/assets/tray-sidecar-pljn-63X.js +2 -0
  154. package/dist/ui/assets/{turn-journal-C3RmT-4t.js → turn-journal-I2u4GdDj.js} +1 -1
  155. package/dist/ui/assets/{upgrade-detection-CZsbpDf8.js → upgrade-detection-Ta4nIJJR.js} +1 -1
  156. package/dist/ui/assets/{upskill-lick-skip-B1aTWac3.js → upskill-lick-skip-IyN1i0IF.js} +1 -1
  157. package/dist/ui/assets/{voice-reply-Dc0ozuqt.js → voice-reply-aiuvZ8F3.js} +1 -1
  158. package/dist/ui/assets/{wc-attach-6OZlMIwW.js → wc-attach-C1CTfWQ-.js} +2 -2
  159. package/dist/ui/assets/{wc-browser-B2QFEwqe.js → wc-browser-RbezSPht.js} +1 -1
  160. package/dist/ui/assets/{wc-computers-CCdbZdxQ.js → wc-computers-D4IEEM5M.js} +1 -1
  161. package/dist/ui/assets/{wc-detached-CvESCw-O.js → wc-detached-CrVlYV_z.js} +1 -1
  162. package/dist/ui/assets/{wc-extension-D0foV_ib.js → wc-extension-BW5y8hdg.js} +2 -2
  163. package/dist/ui/assets/wc-follower-oauth-BArMqE7c.js +5 -0
  164. package/dist/ui/assets/wc-follower-xchSJ13T.js +17 -0
  165. package/dist/ui/assets/{wc-gelatiere-CJxyMbHo.js → wc-gelatiere-CxGkXDNo.js} +1 -1
  166. package/dist/ui/assets/{wc-live-BoLWLz9Z.js → wc-live-DdOUCb1z.js} +6 -6
  167. package/dist/ui/assets/{wc-nav-C3wn-3dH.js → wc-nav-C-cqoNl9.js} +2 -2
  168. package/dist/ui/assets/{wc-onboarding-DSGTg720.js → wc-onboarding-CId-wqvG.js} +2 -2
  169. package/dist/ui/assets/{wc-permissions-Dt6tAGYb.js → wc-permissions-lj9xrdU-.js} +2 -2
  170. package/dist/ui/assets/{wc-placeholder-tXAR_WLy.js → wc-placeholder-bs83QBxc.js} +3 -3
  171. package/dist/ui/assets/{wc-secret-request-D3oqwar-.js → wc-secret-request-BmVSG3Qe.js} +1 -1
  172. package/dist/ui/assets/{wc-settings-CA4t9KOD.js → wc-settings-CE5aZbkW.js} +3 -3
  173. package/dist/ui/assets/{wc-shell-kYp04Uca.js → wc-shell-DdSbkIp-.js} +3 -3
  174. package/dist/ui/assets/{wc-shortcut-config-t41Zisk5.js → wc-shortcut-config-C2d66GP8.js} +1 -1
  175. package/dist/ui/assets/{wc-sprinkles-Ce0z4QiY.js → wc-sprinkles-ak7XBDCk.js} +2 -2
  176. package/dist/ui/assets/{wc-transcript-export-zUoMikMo.js → wc-transcript-export-DYVbwupj.js} +2 -2
  177. package/dist/ui/assets/wc-tray-CjkC7SwM.js +5 -0
  178. package/dist/ui/assets/welcome-detection-BAQGL8Ld.js +1 -0
  179. package/dist/ui/assets/{whisper-session-Dv9ZtYsN.js → whisper-session-DBea3Pzc.js} +2 -2
  180. package/dist/ui/assets/{xai-grok-Bd2BL4cS.js → xai-grok-B-WV19uN.js} +1 -1
  181. package/dist/ui/assets/{xai-grok-BIYj0ZEJ.js → xai-grok-CAPZiieq.js} +1 -1
  182. package/dist/ui/index.html +5 -5
  183. package/dist/ui/packages/webapp/index.html +5 -5
  184. package/package.json +1 -1
  185. package/dist/ui/assets/__vite-browser-external-DH1K0mQP.js +0 -1
  186. package/dist/ui/assets/account-store-BMyZ1LC1.js +0 -1
  187. package/dist/ui/assets/account-store-ClzKIIMy.js +0 -2
  188. package/dist/ui/assets/bedrock-camp-BQ02i7Bk.js +0 -1
  189. package/dist/ui/assets/bedrock-camp-CMYc0nQP.js +0 -1
  190. package/dist/ui/assets/bedrock-camp-compat-99DjWBHV.js +0 -1
  191. package/dist/ui/assets/bedrock-camp-compat-BeCSBUrZ.js +0 -1
  192. package/dist/ui/assets/bedrock-camp-extra-models-B0WH9IRx.js +0 -1
  193. package/dist/ui/assets/bedrock-camp-extra-models-WTCIjj5a.js +0 -1
  194. package/dist/ui/assets/buffer-polyfill-BccMjOKj.js +0 -1
  195. package/dist/ui/assets/emscripten-vfs-hook-D0g146Sa.js +0 -1
  196. package/dist/ui/assets/live-vfs-fs-DXo5N-ez.js +0 -1
  197. package/dist/ui/assets/provider-store-access-PD8D6Ly5.js +0 -1
  198. package/dist/ui/assets/provider-store-access-tUmVoIgf.js +0 -1
  199. package/dist/ui/assets/providers-CsJ6PgRK.js +0 -2
  200. package/dist/ui/assets/realm-inprocess-BPfc1UTZ.js +0 -33
  201. package/dist/ui/assets/shared-DfMXB1pm.js +0 -4
  202. package/dist/ui/assets/slicc-version-D3PQZH1j.js +0 -1
  203. package/dist/ui/assets/temperature-support-Dd00cuZX.js +0 -1
  204. package/dist/ui/assets/temperature-support-PjwXIa-F.js +0 -1
  205. package/dist/ui/assets/tray-leader-gwAMllRq.js +0 -1
  206. package/dist/ui/assets/tray-sidecar-CF5Qu4Xu.js +0 -2
  207. package/dist/ui/assets/wc-follower-DRG_fFhc.js +0 -17
  208. package/dist/ui/assets/wc-follower-oauth-BNclaglp.js +0 -5
  209. package/dist/ui/assets/wc-tray-D6Q1hPos.js +0 -5
  210. package/dist/ui/assets/welcome-detection-CvTYmIMA.js +0 -1
@@ -33,4 +33,4 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
33
33
  `}}return e?(p+=`
34
34
  `+B(l(e),c),s&&s()):d&&o&&o(),p}function Ye({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(N(i))i.spaceBefore&&d.push(``),Xe(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(A(i)){let e=N(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),Xe(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=N(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Ie(i,c,()=>a=null);l||=d.length>u||o.includes(`
35
35
  `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=V(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
36
- `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Xe({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=B(t(r),e);n.push(i.trimStart())}}function G(e,t){let n=j(t)?t.value:t;for(let r of e)if(A(r)&&(r.key===t||r.key===n||j(r.key)&&r.key.value===n))return r}var K=class extends be{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(w,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Ke(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=A(e)?e:!e||typeof e!=`object`||!(`key`in e)?new W(e,e?.value):new W(e.key,e.value);let r=G(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);j(r.value)&&he(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=G(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=G(this.items,e)?.value;return(!t&&j(n)?n.value:n)??void 0}has(e){return!!G(this.items,e)}set(e,t){this.add(new W(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)We(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!A(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),qe(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Ze={collection:`map`,default:!0,nodeClass:K,tag:`tag:yaml.org,2002:map`,resolve(e,t){return k(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>K.from(e,t,n)};var Qe=class extends be{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(T,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=$e(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=$e(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&j(r)?r.value:r}has(e){let t=$e(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=$e(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];j(r)&&he(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(R(e,String(r++),t));return n}toString(e,t,n){return e?qe(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(_e(a,void 0,n))}}return i}};function $e(e){let t=j(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const et={collection:`seq`,default:!0,nodeClass:Qe,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return ie(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Qe.from(e,t,n)};function tt(e){return typeof e==`bigint`||Number.isInteger(e)}const nt=({value:e})=>JSON.stringify(e),rt=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:nt},{identify:e=>e==null,createNode:()=>new z(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:nt},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:nt},{identify:tt,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>tt(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:nt}];[Ze,et].concat(rt,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function it(e,t,n){let{replacer:r}=n,i=new Qe(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Ke(o,s,n))}return i}var at=class e extends Qe{constructor(){super(),this.add=K.prototype.add.bind(this),this.delete=K.prototype.delete.bind(this),this.get=K.prototype.get.bind(this),this.has=K.prototype.has.bind(this),this.set=K.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(A(e)?(r=R(e.key,``,t),i=R(e.value,r,t)):r=R(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=it(e,t,n),i=new this;return i.items=r.items,i}};at.tag=`tag:yaml.org,2002:omap`;var ot=class e extends K{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=A(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new W(e.key,null):new W(e,null),G(this.items,t.key)||this.items.push(t)}get(e,t){let n=G(this.items,e);return!t&&A(n)?j(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=G(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new W(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Ke(e,null,n));return i}};ot.tag=`tag:yaml.org,2002:set`;const st=Symbol(`break visit`),ct=Symbol(`skip children`),lt=Symbol(`remove item`);function q(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ut(Object.freeze([]),e,t)}q.BREAK=st,q.SKIP=ct,q.REMOVE=lt,q.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},q.parentCollection=(e,t)=>{let n=q.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function ut(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=ut(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===st)return st;else r===lt&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}e(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,ee=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,te=e=>e.split(s).filter(Boolean);var w=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ne=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new w(e,t,i,n,r,s)};var re=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),ee(e.pattern)){let t=ne(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?te(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let T=(e,t)=>{throw new t(e)},E=(e,t,n)=>C(e)?e?!E.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),D=e=>c.test(e);E.isNotRelative=D,E.convert=e=>e;var O=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new re(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&E.convert(e);return E(i,e,this._strictPathCheck?T:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let k=e=>new O(e),A=e=>E(e&&E.convert(e),e,m),j=()=>{E.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;E.isNotRelative=t=>e.test(t)||D(t)};typeof process<`u`&&process.platform===`win32`&&j(),t.exports=k,k.default=k,t.exports.isPathValid=A,f(t.exports,Symbol.for(`setupWindows`),j)}))();const dt={"pi.session.id":{type:`string`,required:!0,cardinality:`high`,description:`Session id`},"pi.lane.name":{type:`string`,required:!0,cardinality:`high`,description:`Lane name`},"pi.operation.id":{type:`string`,required:!0,cardinality:`high`,description:`Durable operation id`},"pi.operation.recovery":{type:`boolean`,required:!0,description:`Whether this invocation resumes durable work`}},ft={"pi.error.code":{type:`string`,cardinality:`low`,description:`Stable operation error code`},"pi.error.type":{type:`string`,cardinality:`low`,description:`Low-cardinality operation error class`}};({...dt}),{...ft},{...dt},{...ft},{...dt},{...ft},globalThis.Buffer,f({command:p({description:`Bash command to execute`}),timeout:u(d({description:`Timeout in seconds (optional, no default timeout)`}))});const pt=f({oldText:p({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:p({description:`Replacement text for this targeted edit.`})},{});f({path:p({description:`Path to the file to edit (relative or absolute)`}),edits:l(pt,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),f({path:p({description:`Path to the file to read (relative or absolute)`}),offset:u(d({description:`Line number to start reading from (1-indexed)`})),limit:u(d({description:`Maximum number of lines to read`}))}),f({path:p({description:`Path to the file to write (relative or absolute)`}),content:p({description:`Content to write to the file`})});function mt(){try{return globalThis.localStorage??null}catch{return null}}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e,t){return Reflect.get(e,t)}function ht(e){let t=null;try{t=e?.getItem(`slicc_model_catalog`)??null}catch{return{raw:null,store:{}}}if(!t)return{raw:t,store:{}};try{let e=JSON.parse(t);return{raw:t,store:J(e)?e:{}}}catch{return{raw:t,store:{}}}}function X(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function gt(e){if(!J(e))return null;let t=Y(e,`input`),n=Y(e,`output`),r=Y(e,`cacheRead`),i=Y(e,`cacheWrite`);return!X(t)||!X(n)||!X(r)||!X(i)?null:{input:t,output:n,cacheRead:r,cacheWrite:i}}function _t(e){return!Array.isArray(e)||e.length===0||!e.every(e=>e===`text`||e===`image`)?null:[...e]}function vt(e){if(e===void 0)return;if(!J(e))return null;let t=Object.entries(e);return t.every(([,e])=>e===null||typeof e==`string`)?Object.fromEntries(t):null}function yt(e){return{apis:new Set(e.map(e=>e.api)),baseUrls:new Set(e.map(e=>e.baseUrl))}}function bt(e,t,n){if(!J(t))return null;let r=Y(t,`id`),i=Y(t,`name`),a=Y(t,`api`),o=Y(t,`baseUrl`),s=Y(t,`reasoning`),c=Y(t,`contextWindow`),l=Y(t,`maxTokens`);if(typeof r!=`string`||r.length===0||r.length>200||typeof i!=`string`||i.length===0||typeof a!=`string`||!n.apis.has(a)||typeof o!=`string`||!n.baseUrls.has(o)||typeof s!=`boolean`||!X(c)||c===0||!X(l)||l===0)return null;let u=gt(Y(t,`cost`)),d=_t(Y(t,`input`)),f=vt(Y(t,`thinkingLevelMap`));if(!u||!d||f===null)return null;let p=Y(t,`compat`),m={id:r,name:i,api:a,provider:e,baseUrl:o,reasoning:s,input:d,cost:u,contextWindow:c,maxTokens:l};return f&&(m.thinkingLevelMap=f),J(p)&&(m.compat={...p}),m}function xt(){return 1787954402569}let St,Ct=new Map;function wt(e){try{return g(e)}catch{return[]}}function Tt(e){if(!e||!Array.isArray(e.models)||e.models.length===0)return!1;let t=xt();return t===null||typeof e.lastModified==`number`&&e.lastModified>t}const Et=new Set([`id`,`name`,`api`,`provider`,`baseUrl`,`reasoning`,`input`,`cost`,`contextWindow`,`maxTokens`,`thinkingLevelMap`,`compat`]);function Dt(e,t,n){if(t)return{...Object.fromEntries(Object.entries(t).filter(([e])=>!Et.has(e))),...e};let r=n.find(t=>t.headers&&t.api===e.api&&t.baseUrl===e.baseUrl);return r?.headers?{...e,headers:{...r.headers}}:e}function Ot(e,t){let n=wt(e);if(n.length===0)return n;let r=yt(n),i=[...n],a=new Map(i.map((e,t)=>[e.id,t])),o=new Map(n.map(e=>[e.id,e]));for(let s of t.models){let t=bt(e,s,r);if(!t)continue;let c=a.get(t.id),l=Dt(t,o.get(t.id),n);c===void 0?(a.set(l.id,i.length),i.push(l)):i[c]=l}return i}function kt(e,t){if(!a(`live-model-catalog`))return wt(e);let{raw:n,store:r}=ht(t),i=r[e];if(!Tt(i))return wt(e);n!==St&&(St=n,Ct=new Map);let o=Ct.get(e);return o||(o=Ot(e,i),Ct.set(e,o)),o}function At(e){return[...kt(e,mt())]}function jt(e,t){return kt(e,mt()).find(e=>e.id===t)||h(e,t)}const Mt=m;function Nt(){return i()?`extension-direct`:o()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function Pt(){return Nt()===`node-rest`}const Z=t(`secret-scrub`),Q=`[tool output withheld: secret scrub unavailable]`,Ft=async e=>e;function It(){let e=Nt();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(Z.debug(`SW scrub-tool-result returned error`),Q):typeof t.text==`string`?t.text:Q}catch{return Z.debug(`SW scrub-tool-result failed`),Q}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await _(`secrets.scrub-tool-result`,{text:e});return t?.error?(Z.debug(`Bridge scrub-tool-result returned error`),Q):typeof t?.text==`string`?t.text:Q}catch{return Z.debug(`Bridge scrub-tool-result failed`),Q}}:e===`connect`?Ft:async e=>{if(!e)return e;try{let t=await fetch(s(`/api/secrets/scrub`),{method:`POST`,headers:c({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return Z.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return Z.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const $=t(`image-processor`),Lt=3932160;function Rt(e){let t=e.replace(/[\t\n\f\r ]/g,``),n=t.length%4;return n===2?`${t}==`:n===3?`${t}=`:t}function zt(e,t){let n=r(Rt(e.slice(0,t)));return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Bt(e,t){return e>0&&t>0?{width:e,height:t}:null}function Vt(e){if(e.length<32)return null;let t=zt(e,32);return Bt(t.getUint32(16,!1),t.getUint32(20,!1))}function Ht(e){if(e.length<16)return null;let t=zt(e,16);return Bt(t.getUint16(6,!0),t.getUint16(8,!0))}function Ut(e){let t=zt(e,Math.min(87384,e.length));for(let e=0;e<t.byteLength-8;e++){if(t.getUint8(e)!==255)continue;let n=t.getUint8(e+1);if(n===192||n===194)return Bt(t.getUint16(e+7,!1),t.getUint16(e+5,!1))}return null}function Wt(e,t){try{let n=Rt(e);if(t===`image/png`)return Vt(n);if(t===`image/gif`)return Ht(n);if(t===`image/jpeg`)return Ut(n)}catch{}return null}async function Gt(e){if(!v(e.mimeType))return $.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,i=Wt(e.data,e.mimeType);if(!(t>5242880||i!==null&&(i.width>8e3||i.height>8e3)||i!==null&&Math.max(i.width,i.height)>1568))return e;$.info(`Image needs processing`,{base64Size:t,dimensions:i?`${i.width}x${i.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let a,o;try{let e=await import(`./magick-wasm-KFp97Nzb.js`).then(e=>e.r);a=e.getMagick,o=e.MIME_TO_MAGICK_FORMAT}catch(e){return $.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let s;try{s=await a()}catch(e){return $.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let i=r(Rt(e.data)),a={data:null,mime:e.mimeType};if(await s.ImageMagick.read(i,async t=>{let n=t.width,r=t.height,i=Math.max(n,r);if(i>1568){let e=1568/i,a=Math.round(n*e),o=Math.round(r*e);t.resize(a,o),$.info(`Resized image`,{from:`${n}x${r}`,to:`${a}x${o}`})}let s=o[e.mimeType]||`JPEG`;t.write(s,e=>{a.data=new Uint8Array(e)}),a.data&&a.data.length>Lt&&s!==`JPEG`?($.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}),a.mime=`image/jpeg`):a.data&&a.data.length>Lt&&($.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}))}),!a.data)return $.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(a.data.length>Lt)return $.warn(`Image still over 5MB after resize+compress`,{size:a.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(a.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let c=n(a.data);return $.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:a.mime}),{type:`image`,data:c,mimeType:a.mime}}catch(n){return $.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const Kt=t(`tool-adapter`);function qt(e){let t=[],n=0;for(let r of y(e)){if(r.kind===`inert`||!r.parsed)continue;let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r.parsed.mimeType,data:r.parsed.data}),n=r.index+r.marker.length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function Jt(e){let t=qt(e),n=[];for(let e of t)e.type===`image`?n.push(await Gt(e)):n.push(e);return n}function Yt(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...nn(t)],owner:r.owner,ppid:r.getParentPid?.()});n?.aborted?r.processManager.signal(i.pid,`SIGINT`):n&&n.addEventListener(`abort`,()=>r.processManager.signal(i.pid,`SIGINT`),{once:!0});let a=r.processManager.onSignal((e,t)=>{e.pid===i.pid&&t===`SIGKILL`&&r.processManager.exit(i.pid,null)});return{tracked:{record:i,manager:r.processManager,unsubscribeKill:a},effectiveSignal:i.abort.signal}}function Xt(e,t){e&&e.manager.exit(e.record.pid,t)}async function Zt(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return Kt.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function Qt(e,t){try{return await Jt(e)}catch(n){return Kt.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),qt(e)}}async function $t(e,t,n,r){let i=n?.currentGate();if(!i)return!0;if(r?.aborted)return!1;try{return await i.approve(e.name,t)&&r?.aborted!==!0}catch(t){return Kt.warn(`Tool-call gate threw — refusing the call`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),!1}}function en(e,t,n,r){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,prepareArguments:e.prepareArguments,async execute(i,a,o,s){let c;if(s&&(c=x({onUpdate:s,toolName:e.name,toolCallId:i})),!await $t(e,a,r,o))return c&&b(c),{content:[{type:`text`,text:`${e.name}: not approved (guest-caused turn).`}],details:{isError:!0}};let l=Yt(e,a,o,t);try{let t=await e.execute(a??{},l.effectiveSignal),r=await Qt(await Zt(t.content,e.name,n),e.name);return Xt(l.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw Xt(l.tracked,l.tracked?.record.abort.signal.aborted?null:1),e}finally{c&&b(c),l.tracked?.unsubscribeKill()}}}}function tn(e,t,n,r){return e.map(e=>en(e,t,n,r))}function nn(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}export{Nt as a,Mt as c,Pt as i,nn as n,jt as o,It as r,At as s,tn as t};
36
+ `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Xe({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=B(t(r),e);n.push(i.trimStart())}}function G(e,t){let n=j(t)?t.value:t;for(let r of e)if(A(r)&&(r.key===t||r.key===n||j(r.key)&&r.key.value===n))return r}var K=class extends be{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(w,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Ke(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=A(e)?e:!e||typeof e!=`object`||!(`key`in e)?new W(e,e?.value):new W(e.key,e.value);let r=G(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);j(r.value)&&he(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=G(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=G(this.items,e)?.value;return(!t&&j(n)?n.value:n)??void 0}has(e){return!!G(this.items,e)}set(e,t){this.add(new W(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)We(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!A(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),qe(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}};const Ze={collection:`map`,default:!0,nodeClass:K,tag:`tag:yaml.org,2002:map`,resolve(e,t){return k(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>K.from(e,t,n)};var Qe=class extends be{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(T,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=$e(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=$e(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&j(r)?r.value:r}has(e){let t=$e(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=$e(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];j(r)&&he(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(R(e,String(r++),t));return n}toString(e,t,n){return e?qe(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(_e(a,void 0,n))}}return i}};function $e(e){let t=j(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}const et={collection:`seq`,default:!0,nodeClass:Qe,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return ie(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Qe.from(e,t,n)};function tt(e){return typeof e==`bigint`||Number.isInteger(e)}const nt=({value:e})=>JSON.stringify(e),rt=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:nt},{identify:e=>e==null,createNode:()=>new z(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:nt},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:nt},{identify:tt,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>tt(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:nt}];[Ze,et].concat(rt,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}});function it(e,t,n){let{replacer:r}=n,i=new Qe(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Ke(o,s,n))}return i}var at=class e extends Qe{constructor(){super(),this.add=K.prototype.add.bind(this),this.delete=K.prototype.delete.bind(this),this.get=K.prototype.get.bind(this),this.has=K.prototype.has.bind(this),this.set=K.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(A(e)?(r=R(e.key,``,t),i=R(e.value,r,t)):r=R(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=it(e,t,n),i=new this;return i.items=r.items,i}};at.tag=`tag:yaml.org,2002:omap`;var ot=class e extends K{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=A(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new W(e.key,null):new W(e,null),G(this.items,t.key)||this.items.push(t)}get(e,t){let n=G(this.items,e);return!t&&A(n)?j(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=G(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new W(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Ke(e,null,n));return i}};ot.tag=`tag:yaml.org,2002:set`;const st=Symbol(`break visit`),ct=Symbol(`skip children`),lt=Symbol(`remove item`);function q(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),ut(Object.freeze([]),e,t)}q.BREAK=st,q.SKIP=ct,q.REMOVE=lt,q.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},q.parentCollection=(e,t)=>{let n=q.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function ut(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=ut(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===st)return st;else r===lt&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}e(((e,t)=>{function n(e){return Array.isArray(e)?e:[e]}let r=/^\s+$/,i=/(?:[^\\]|^)\\$/,a=/^\\!/,o=/^\\#/,s=/\r?\n/g,c=/^\.{0,2}\/|^\.{1,2}$/,l=/\/$/,u=`node-ignore`;typeof Symbol<`u`&&(u=Symbol.for(`node-ignore`));let d=u,f=(e,t,n)=>(Object.defineProperty(e,t,{value:n}),n),p=/([0-z])-([0-z])/g,m=()=>!1,h=e=>e.replace(p,(e,t,n)=>t.charCodeAt(0)<=n.charCodeAt(0)?e:``),g=e=>{let{length:t}=e;return e.slice(0,t-t%2)},_=[[/^\uFEFF/,()=>``],[/((?:\\\\)*?)(\\?\s+)$/,(e,t,n)=>t+(n.indexOf(`\\`)===0?` `:``)],[/(\\+?)\s/g,(e,t)=>{let{length:n}=t;return t.slice(0,n-n%2)+` `}],[/[\\$.|*+(){^]/g,e=>`\\${e}`],[/(?!\\)\?/g,()=>`[^/]`],[/^\//,()=>`^`],[/\//g,()=>`\\/`],[/^\^*\\\*\\\*\\\//,()=>`^(?:.*\\/)?`],[/^(?=[^^])/,function(){return/\/(?!$)/.test(this)?`^`:`(?:^|\\/)`}],[/\\\/\\\*\\\*(?=\\\/|$)/g,(e,t,n)=>t+6<n.length?`(?:\\/[^\\/]+)*`:`\\/.+`],[/(^|[^\\]+)(\\\*)+(?=.+)/g,(e,t,n)=>t+n.replace(/\\\*/g,`[^\\/]*`)],[/\\\\\\(?=[$.|*+(){^])/g,()=>`\\`],[/\\\\/g,()=>`\\`],[/(\\)?\[([^\]/]*?)(\\*)($|\])/g,(e,t,n,r,i)=>t===`\\`?`\\[${n}${g(r)}${i}`:i===`]`&&r.length%2==0?`[${h(n)}${r}]`:`[]`],[/(?:[^*])$/,e=>/\/$/.test(e)?`${e}$`:`${e}(?=$|\\/$)`]],v=/(^|\\\/)?\\\*$/,y=`regex`,b=`checkRegex`,x={[y](e,t){return`${t?`${t}[^/]+`:`[^/]*`}(?=$|\\/$)`},[b](e,t){return`${t?`${t}[^/]*`:`[^/]*`}(?=$|\\/$)`}},S=e=>_.reduce((t,[n,r])=>t.replace(n,r.bind(e)),e),C=e=>typeof e==`string`,ee=e=>e&&C(e)&&!r.test(e)&&!i.test(e)&&e.indexOf(`#`)!==0,te=e=>e.split(s).filter(Boolean);var w=class{constructor(e,t,n,r,i,a){this.pattern=e,this.mark=t,this.negative=i,f(this,`body`,n),f(this,`ignoreCase`,r),f(this,`regexPrefix`,a)}get regex(){let e=`_regex`;return this[e]?this[e]:this._make(y,e)}get checkRegex(){let e=`_checkRegex`;return this[e]?this[e]:this._make(b,e)}_make(e,t){let n=this.regexPrefix.replace(v,x[e]),r=this.ignoreCase?new RegExp(n,`i`):new RegExp(n);return f(this,t,r)}};let ne=({pattern:e,mark:t},n)=>{let r=!1,i=e;i.indexOf(`!`)===0&&(r=!0,i=i.substr(1)),i=i.replace(a,`!`).replace(o,`#`);let s=S(i);return new w(e,t,i,n,r,s)};var re=class{constructor(e){this._ignoreCase=e,this._rules=[]}_add(e){if(e&&e[d]){this._rules=this._rules.concat(e._rules._rules),this._added=!0;return}if(C(e)&&(e={pattern:e}),ee(e.pattern)){let t=ne(e,this._ignoreCase);this._added=!0,this._rules.push(t)}}add(e){return this._added=!1,n(C(e)?te(e):e).forEach(this._add,this),this._added}test(e,t,n){let r=!1,i=!1,a;this._rules.forEach(o=>{let{negative:s}=o;i===s&&r!==i||s&&!r&&!i&&!t||o[n].test(e)&&(r=!s,i=s,a=s?void 0:o)});let o={ignored:r,unignored:i};return a&&(o.rule=a),o}};let T=(e,t)=>{throw new t(e)},E=(e,t,n)=>C(e)?e?!E.isNotRelative(e)||n(`path should be a \`path.relative()\`d string, but got "${t}"`,RangeError):n(`path must not be empty`,TypeError):n(`path must be a string, but got \`${t}\``,TypeError),D=e=>c.test(e);E.isNotRelative=D,E.convert=e=>e;var O=class{constructor({ignorecase:e=!0,ignoreCase:t=e,allowRelativePaths:n=!1}={}){f(this,d,!0),this._rules=new re(t),this._strictPathCheck=!n,this._initCache()}_initCache(){this._ignoreCache=Object.create(null),this._testCache=Object.create(null)}add(e){return this._rules.add(e)&&this._initCache(),this}addPattern(e){return this.add(e)}_test(e,t,n,r){let i=e&&E.convert(e);return E(i,e,this._strictPathCheck?T:m),this._t(i,t,n,r)}checkIgnore(e){if(!l.test(e))return this.test(e);let t=e.split(`/`).filter(Boolean);if(t.pop(),t.length){let e=this._t(t.join(`/`)+`/`,this._testCache,!0,t);if(e.ignored)return e}return this._rules.test(e,!1,b)}_t(e,t,n,r){if(e in t)return t[e];if(r||=e.split(`/`).filter(Boolean),r.pop(),!r.length)return t[e]=this._rules.test(e,n,y);let i=this._t(r.join(`/`)+`/`,t,n,r);return t[e]=i.ignored?i:this._rules.test(e,n,y)}ignores(e){return this._test(e,this._ignoreCache,!1).ignored}createFilter(){return e=>!this.ignores(e)}filter(e){return n(e).filter(this.createFilter())}test(e){return this._test(e,this._testCache,!0)}};let k=e=>new O(e),A=e=>E(e&&E.convert(e),e,m),j=()=>{E.convert=e=>/^\\\\\?\\/.test(e)||/["<>|\u0000-\u001F]+/u.test(e)?e:e.replace(/\\/g,`/`);let e=/^[a-z]:\//i;E.isNotRelative=t=>e.test(t)||D(t)};typeof process<`u`&&process.platform===`win32`&&j(),t.exports=k,k.default=k,t.exports.isPathValid=A,f(t.exports,Symbol.for(`setupWindows`),j)}))();const dt={"pi.session.id":{type:`string`,required:!0,cardinality:`high`,description:`Session id`},"pi.lane.name":{type:`string`,required:!0,cardinality:`high`,description:`Lane name`},"pi.operation.id":{type:`string`,required:!0,cardinality:`high`,description:`Durable operation id`},"pi.operation.recovery":{type:`boolean`,required:!0,description:`Whether this invocation resumes durable work`}},ft={"pi.error.code":{type:`string`,cardinality:`low`,description:`Stable operation error code`},"pi.error.type":{type:`string`,cardinality:`low`,description:`Low-cardinality operation error class`}};({...dt}),{...ft},{...dt},{...ft},{...dt},{...ft},globalThis.Buffer,f({command:p({description:`Bash command to execute`}),timeout:u(d({description:`Timeout in seconds (optional, no default timeout)`}))});const pt=f({oldText:p({description:`Exact text for one targeted replacement. It must be unique in the original file and must not overlap with any other edits[].oldText in the same call.`}),newText:p({description:`Replacement text for this targeted edit.`})},{});f({path:p({description:`Path to the file to edit (relative or absolute)`}),edits:l(pt,{description:`One or more targeted replacements. Each edit is matched against the original file, not incrementally. Do not include overlapping or nested edits. If two changes touch the same block or nearby lines, merge them into one edit instead.`})},{}),f({path:p({description:`Path to the file to read (relative or absolute)`}),offset:u(d({description:`Line number to start reading from (1-indexed)`})),limit:u(d({description:`Maximum number of lines to read`}))}),f({path:p({description:`Path to the file to write (relative or absolute)`}),content:p({description:`Content to write to the file`})});function mt(){try{return globalThis.localStorage??null}catch{return null}}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e,t){return Reflect.get(e,t)}function ht(e){let t=null;try{t=e?.getItem(`slicc_model_catalog`)??null}catch{return{raw:null,store:{}}}if(!t)return{raw:t,store:{}};try{let e=JSON.parse(t);return{raw:t,store:J(e)?e:{}}}catch{return{raw:t,store:{}}}}function X(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function gt(e){if(!J(e))return null;let t=Y(e,`input`),n=Y(e,`output`),r=Y(e,`cacheRead`),i=Y(e,`cacheWrite`);return!X(t)||!X(n)||!X(r)||!X(i)?null:{input:t,output:n,cacheRead:r,cacheWrite:i}}function _t(e){return!Array.isArray(e)||e.length===0||!e.every(e=>e===`text`||e===`image`)?null:[...e]}function vt(e){if(e===void 0)return;if(!J(e))return null;let t=Object.entries(e);return t.every(([,e])=>e===null||typeof e==`string`)?Object.fromEntries(t):null}function yt(e){return{apis:new Set(e.map(e=>e.api)),baseUrls:new Set(e.map(e=>e.baseUrl))}}function bt(e,t,n){if(!J(t))return null;let r=Y(t,`id`),i=Y(t,`name`),a=Y(t,`api`),o=Y(t,`baseUrl`),s=Y(t,`reasoning`),c=Y(t,`contextWindow`),l=Y(t,`maxTokens`);if(typeof r!=`string`||r.length===0||r.length>200||typeof i!=`string`||i.length===0||typeof a!=`string`||!n.apis.has(a)||typeof o!=`string`||!n.baseUrls.has(o)||typeof s!=`boolean`||!X(c)||c===0||!X(l)||l===0)return null;let u=gt(Y(t,`cost`)),d=_t(Y(t,`input`)),f=vt(Y(t,`thinkingLevelMap`));if(!u||!d||f===null)return null;let p=Y(t,`compat`),m={id:r,name:i,api:a,provider:e,baseUrl:o,reasoning:s,input:d,cost:u,contextWindow:c,maxTokens:l};return f&&(m.thinkingLevelMap=f),J(p)&&(m.compat={...p}),m}function xt(){return 1787954402569}let St,Ct=new Map;function wt(e){try{return g(e)}catch{return[]}}function Tt(e){if(!e||!Array.isArray(e.models)||e.models.length===0)return!1;let t=xt();return t===null||typeof e.lastModified==`number`&&e.lastModified>t}const Et=new Set([`id`,`name`,`api`,`provider`,`baseUrl`,`reasoning`,`input`,`cost`,`contextWindow`,`maxTokens`,`thinkingLevelMap`,`compat`]);function Dt(e,t,n){if(t)return{...Object.fromEntries(Object.entries(t).filter(([e])=>!Et.has(e))),...e};let r=n.find(t=>t.headers&&t.api===e.api&&t.baseUrl===e.baseUrl);return r?.headers?{...e,headers:{...r.headers}}:e}function Ot(e,t){let n=wt(e);if(n.length===0)return n;let r=yt(n),i=[...n],a=new Map(i.map((e,t)=>[e.id,t])),o=new Map(n.map(e=>[e.id,e]));for(let s of t.models){let t=bt(e,s,r);if(!t)continue;let c=a.get(t.id),l=Dt(t,o.get(t.id),n);c===void 0?(a.set(l.id,i.length),i.push(l)):i[c]=l}return i}function kt(e,t){if(!a(`live-model-catalog`))return wt(e);let{raw:n,store:r}=ht(t),i=r[e];if(!Tt(i))return wt(e);n!==St&&(St=n,Ct=new Map);let o=Ct.get(e);return o||(o=Ot(e,i),Ct.set(e,o)),o}function At(e){return[...kt(e,mt())]}function jt(e,t){return kt(e,mt()).find(e=>e.id===t)||h(e,t)}const Mt=m;function Nt(){return i()?`extension-direct`:o()?`extension-delegate`:globalThis.__slicc_connect_mode?`connect`:`node-rest`}function Pt(){return Nt()===`node-rest`}const Z=t(`secret-scrub`),Q=`[tool output withheld: secret scrub unavailable]`,Ft=async e=>e;function It(){let e=Nt();return e===`extension-direct`?async e=>{if(!e)return e;try{let t=await new Promise(t=>{chrome.runtime.sendMessage({type:`secrets.scrub-tool-result`,text:e},e=>t(e??{}))});return t.error?(Z.debug(`SW scrub-tool-result returned error`),Q):typeof t.text==`string`?t.text:Q}catch{return Z.debug(`SW scrub-tool-result failed`),Q}}:e===`extension-delegate`?async e=>{if(!e)return e;try{let t=await _(`secrets.scrub-tool-result`,{text:e});return t?.error?(Z.debug(`Bridge scrub-tool-result returned error`),Q):typeof t?.text==`string`?t.text:Q}catch{return Z.debug(`Bridge scrub-tool-result failed`),Q}}:e===`connect`?Ft:async e=>{if(!e)return e;try{let t=await fetch(s(`/api/secrets/scrub`),{method:`POST`,headers:c({"content-type":`application/json`}),body:JSON.stringify({text:e})});if(!t.ok)return Z.debug(`Server scrub-tool-result returned non-ok`,{status:t.status}),e;let n=await t.json();return typeof n.text==`string`?n.text:e}catch(t){return Z.debug(`Server scrub-tool-result failed`,{error:t instanceof Error?t.message:String(t)}),e}}}const $=t(`image-processor`),Lt=3932160;function Rt(e){let t=e.replace(/[\t\n\f\r ]/g,``),n=t.length%4;return n===2?`${t}==`:n===3?`${t}=`:t}function zt(e,t){let n=r(Rt(e.slice(0,t)));return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Bt(e,t){return e>0&&t>0?{width:e,height:t}:null}function Vt(e){if(e.length<32)return null;let t=zt(e,32);return Bt(t.getUint32(16,!1),t.getUint32(20,!1))}function Ht(e){if(e.length<16)return null;let t=zt(e,16);return Bt(t.getUint16(6,!0),t.getUint16(8,!0))}function Ut(e){let t=zt(e,Math.min(87384,e.length));for(let e=0;e<t.byteLength-8;e++){if(t.getUint8(e)!==255)continue;let n=t.getUint8(e+1);if(n===192||n===194)return Bt(t.getUint16(e+7,!1),t.getUint16(e+5,!1))}return null}function Wt(e,t){try{let n=Rt(e);if(t===`image/png`)return Vt(n);if(t===`image/gif`)return Ht(n);if(t===`image/jpeg`)return Ut(n)}catch{}return null}async function Gt(e){if(!v(e.mimeType))return $.warn(`Unsupported image format`,{mimeType:e.mimeType}),{type:`text`,text:`[Image removed: unsupported format "${e.mimeType}". Supported: JPEG, PNG, GIF, WebP]`};let t=e.data.length,i=Wt(e.data,e.mimeType);if(!(t>5242880||i!==null&&(i.width>8e3||i.height>8e3)||i!==null&&Math.max(i.width,i.height)>1568))return e;$.info(`Image needs processing`,{base64Size:t,dimensions:i?`${i.width}x${i.height}`:`unknown`,reason:t>5242880?`size`:`dimensions`});let a,o;try{let e=await import(`./magick-wasm-BATj-KUu.js`).then(e=>e.r);a=e.getMagick,o=e.MIME_TO_MAGICK_FORMAT}catch(e){return $.error(`ImageMagick WASM module unavailable`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (ImageMagick WASM could not be loaded)]`}}let s;try{s=await a()}catch(e){return $.error(`ImageMagick WASM initialization failed`,{error:e instanceof Error?e.message:String(e)}),{type:`text`,text:`[Image removed: resize service unavailable (WASM init failed)]`}}try{let i=r(Rt(e.data)),a={data:null,mime:e.mimeType};if(await s.ImageMagick.read(i,async t=>{let n=t.width,r=t.height,i=Math.max(n,r);if(i>1568){let e=1568/i,a=Math.round(n*e),o=Math.round(r*e);t.resize(a,o),$.info(`Resized image`,{from:`${n}x${r}`,to:`${a}x${o}`})}let s=o[e.mimeType]||`JPEG`;t.write(s,e=>{a.data=new Uint8Array(e)}),a.data&&a.data.length>Lt&&s!==`JPEG`?($.info(`Still over 5MB, compressing to JPEG q80`),t.quality=80,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}),a.mime=`image/jpeg`):a.data&&a.data.length>Lt&&($.info(`Still over 5MB as JPEG, reducing quality to 60`),t.quality=60,t.write(`JPEG`,e=>{a.data=new Uint8Array(e)}))}),!a.data)return $.warn(`ImageMagick produced no output`),{type:`text`,text:`[Image removed: could not be processed (empty output from resize)]`};if(a.data.length>Lt)return $.warn(`Image still over 5MB after resize+compress`,{size:a.data.length}),{type:`text`,text:`[Image removed: still ${Math.round(a.data.length/1024/1024*10)/10}MB after resize and compression, exceeds 5MB API limit]`};let c=n(a.data);return $.info(`Image processed successfully`,{originalBase64:t,newBase64:c.length,mimeType:a.mime}),{type:`image`,data:c,mimeType:a.mime}}catch(n){return $.error(`Image data processing failed (corrupt or unreadable)`,{mimeType:e.mimeType,estimatedBytes:t,error:n instanceof Error?n.message:String(n)}),{type:`text`,text:`[Image removed: image data could not be processed (${n instanceof Error?n.message:`corrupt or unreadable`})]`}}}const Kt=t(`tool-adapter`);function qt(e){let t=[],n=0;for(let r of y(e)){if(r.kind===`inert`||!r.parsed)continue;let i=e.slice(n,r.index);i.trim()&&t.push({type:`text`,text:i.trimEnd()}),t.push({type:`image`,mimeType:r.parsed.mimeType,data:r.parsed.data}),n=r.index+r.marker.length}let r=e.slice(n);return(r.trim()||t.length===0)&&t.push({type:`text`,text:r||e}),t}async function Jt(e){let t=qt(e),n=[];for(let e of t)e.type===`image`?n.push(await Gt(e)):n.push(e);return n}function Yt(e,t,n,r){if(!r)return{tracked:null,effectiveSignal:n};let i=r.processManager.spawn({kind:`tool`,argv:[e.name,...nn(t)],owner:r.owner,ppid:r.getParentPid?.()});n?.aborted?r.processManager.signal(i.pid,`SIGINT`):n&&n.addEventListener(`abort`,()=>r.processManager.signal(i.pid,`SIGINT`),{once:!0});let a=r.processManager.onSignal((e,t)=>{e.pid===i.pid&&t===`SIGKILL`&&r.processManager.exit(i.pid,null)});return{tracked:{record:i,manager:r.processManager,unsubscribeKill:a},effectiveSignal:i.abort.signal}}function Xt(e,t){e&&e.manager.exit(e.record.pid,t)}async function Zt(e,t,n){if(!n||typeof e!=`string`||e.length===0)return e;try{return await n.scrubToolResult(e)}catch(n){return Kt.warn(`Tool-result scrub failed, falling back to unscrubbed content`,{tool:t,error:n instanceof Error?n.message:String(n)}),e}}async function Qt(e,t){try{return await Jt(e)}catch(n){return Kt.warn(`Image processing failed, falling back to raw content`,{tool:t,error:n instanceof Error?n.message:String(n)}),qt(e)}}async function $t(e,t,n,r){let i=n?.currentGate();if(!i)return!0;if(r?.aborted)return!1;try{return await i.approve(e.name,t)&&r?.aborted!==!0}catch(t){return Kt.warn(`Tool-call gate threw — refusing the call`,{tool:e.name,error:t instanceof Error?t.message:String(t)}),!1}}function en(e,t,n,r){return{name:e.name,label:e.name,description:e.description,parameters:e.inputSchema,prepareArguments:e.prepareArguments,async execute(i,a,o,s){let c;if(s&&(c=x({onUpdate:s,toolName:e.name,toolCallId:i})),!await $t(e,a,r,o))return c&&b(c),{content:[{type:`text`,text:`${e.name}: not approved (guest-caused turn).`}],details:{isError:!0}};let l=Yt(e,a,o,t);try{let t=await e.execute(a??{},l.effectiveSignal),r=await Qt(await Zt(t.content,e.name,n),e.name);return Xt(l.tracked,+!!t.isError),{content:r,details:{isError:t.isError}}}catch(e){throw Xt(l.tracked,l.tracked?.record.abort.signal.aborted?null:1),e}finally{c&&b(c),l.tracked?.unsubscribeKill()}}}}function tn(e,t,n,r){return e.map(e=>en(e,t,n,r))}function nn(e){if(typeof e!=`object`||!e)return[];let t=e;for(let e of[`command`,`file_path`,`path`,`pattern`,`url`,`key`,`name`,`query`,`message`]){let n=t[e];if(typeof n==`string`&&n.length>0)return[n]}for(let e of Object.values(t))if(typeof e==`string`&&e.length>0)return[e];return[]}export{Nt as a,Mt as c,Pt as i,nn as n,jt as o,It as r,At as s,tn as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{c as t,t as n}from"./claude-model-version-ceOteQ2f.js";import{r}from"./browser-BPbYUZ91.js";import{n as i,t as a}from"./provider-budget-DbHWq3j6.js";import{t as o}from"./subcommand-flags-BZi7j78Q.js";import{t as s}from"./subcommand-help-CgO7wRS5.js";var c=e({createCostCommand:()=>C,frozenSessionToCostData:()=>h,registerSessionBudgetProvider:()=>p,registerSessionCostsProvider:()=>f});const l=[`--all`,`--json`];let u=null,d=null;function f(e){u=e}function p(e){d=e}function m(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function h(e){let r=Array.isArray(e.models)?e.models:[],i=new Map;for(let e of r){let t=typeof e?.model==`string`?e.model:``;if(!t)continue;let r=n(t),a=i.get(r),o=m(e?.cost);if(!a){i.set(r,{ids:[t],cost:o});continue}a.ids.includes(t)||a.ids.push(t),a.cost+=o}let a=[...i.values()].sort((e,t)=>t.cost-e.cost||(e.ids[0]??``).localeCompare(t.ids[0]??``)).map(e=>t(e.ids)),o=Number.isFinite(e.cost?.total);return{name:typeof e.title==`string`&&e.title.length>0?e.title:e.filename,type:`cone`,model:a[0]??`-`,models:a,source:`frozen`,costAvailable:o,usage:{input:null,output:null,cacheRead:null,cacheWrite:null,totalTokens:r.reduce((e,t)=>e+m(t?.tokens),0),cost:{input:m(e.cost?.input),output:m(e.cost?.output),cacheRead:m(e.cost?.cacheRead),cacheWrite:m(e.cost?.cacheWrite),total:m(e.cost?.total)}},turns:r.reduce((e,t)=>e+m(t?.turns),0)}}function g(){return`cost - show session cost breakdown
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{c as t,t as n}from"./claude-model-version-ceOteQ2f.js";import{r}from"./browser-DL3zbJrM.js";import{n as i,t as a}from"./provider-budget-DbHWq3j6.js";import{t as o}from"./subcommand-flags-BZi7j78Q.js";import{t as s}from"./subcommand-help-CgO7wRS5.js";var c=e({createCostCommand:()=>C,frozenSessionToCostData:()=>h,registerSessionBudgetProvider:()=>p,registerSessionCostsProvider:()=>f});const l=[`--all`,`--json`];let u=null,d=null;function f(e){u=e}function p(e){d=e}function m(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function h(e){let r=Array.isArray(e.models)?e.models:[],i=new Map;for(let e of r){let t=typeof e?.model==`string`?e.model:``;if(!t)continue;let r=n(t),a=i.get(r),o=m(e?.cost);if(!a){i.set(r,{ids:[t],cost:o});continue}a.ids.includes(t)||a.ids.push(t),a.cost+=o}let a=[...i.values()].sort((e,t)=>t.cost-e.cost||(e.ids[0]??``).localeCompare(t.ids[0]??``)).map(e=>t(e.ids)),o=Number.isFinite(e.cost?.total);return{name:typeof e.title==`string`&&e.title.length>0?e.title:e.filename,type:`cone`,model:a[0]??`-`,models:a,source:`frozen`,costAvailable:o,usage:{input:null,output:null,cacheRead:null,cacheWrite:null,totalTokens:r.reduce((e,t)=>e+m(t?.tokens),0),cost:{input:m(e.cost?.input),output:m(e.cost?.output),cacheRead:m(e.cost?.cacheRead),cacheWrite:m(e.cost?.cacheWrite),total:m(e.cost?.total)}},turns:r.reduce((e,t)=>e+m(t?.turns),0)}}function g(){return`cost - show session cost breakdown
2
2
 
3
3
  Usage: cost [options]
4
4
 
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import{S as t}from"./record-ChU1ND2B.js";import{h as n}from"./kernel-worker-Cp4UmRK8.js";const r=e(`directed-approval`);function i(e,n){if(e.kind===`user`)return a(`the user tier is not a directed approval`);if(e.kind===`agent`)return a(`agent approvals are not enqueued to a unit`);let r=e.unitJid;if(!n.scoops.has(r))return a(`the requesting unit is not registered`);let i=n.ownerRootOf(r);if(!i)return a(`no owning cone for the requesting unit`);let o=e.kind===`cone`?i:[...n.scoops.values()].find(t=>t.parentJid===i.jid&&(t.name===e.scoopName||t.folder===e.scoopName));return o?t(o).canResolveApprovals?{ok:!0,requesterJid:r,approver:o}:a(`the named approver cannot resolve approvals`):a(`delegated approver not found under this cone`)}function a(e){return r.warn(`Directed approval failing closed`,{reason:e}),{ok:!1,reason:e}}const o={decision:`deny`};async function s(e,t){let a=e.approver;if(a?.kind===`agent`){let i=globalThis[n];if(!i)return r.warn(`No agent bridge available for an approver agent — denying`),o;let{approverRunnerFor:s}=await import(`./approver-agent-CvnFt_s6.js`),c=t.getSharedFs(),l=await s({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!c)return null;try{let t=await c.readFile(e,{encoding:`utf-8`});return typeof t==`string`?t:null}catch{return null}},findUnit:e=>{let n=t.scoops.get(e);return n?{workspace:t.workspaceFor(n),folder:n.folder}:void 0}})({kind:e.kind===`guest-tool`?`guest-tool`:`guest-message`,requester:e.requester??`an unidentified requester`,detail:e.detail},a.unitJid);return r.info(`Approver agent verdict`,{decision:l.decision,reason:l.reason}),l.decision===`allow`?{decision:`allow`}:o}if(a&&a.kind!==`user`){let n=i(a,t);return n.ok?t.enqueue(n.requesterJid,e,{approver:n.approver}):o}return t.approveAsUser(e)}export{s as runDirectedApproval};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import{S as t}from"./record-ChU1ND2B.js";import{h as n}from"./kernel-worker-YhNfUQ_y.js";const r=e(`directed-approval`);function i(e,n){if(e.kind===`user`)return a(`the user tier is not a directed approval`);if(e.kind===`agent`)return a(`agent approvals are not enqueued to a unit`);let r=e.unitJid;if(!n.scoops.has(r))return a(`the requesting unit is not registered`);let i=n.ownerRootOf(r);if(!i)return a(`no owning cone for the requesting unit`);let o=e.kind===`cone`?i:[...n.scoops.values()].find(t=>t.parentJid===i.jid&&(t.name===e.scoopName||t.folder===e.scoopName));return o?t(o).canResolveApprovals?{ok:!0,requesterJid:r,approver:o}:a(`the named approver cannot resolve approvals`):a(`delegated approver not found under this cone`)}function a(e){return r.warn(`Directed approval failing closed`,{reason:e}),{ok:!1,reason:e}}const o={decision:`deny`};async function s(e,t){let a=e.approver;if(a?.kind===`agent`){let i=globalThis[n];if(!i)return r.warn(`No agent bridge available for an approver agent — denying`),o;let{approverRunnerFor:s}=await import(`./approver-agent-CvnFt_s6.js`),c=t.getSharedFs(),l=await s({spawn:e=>i.spawn(e),readSharedFile:async e=>{if(!c)return null;try{let t=await c.readFile(e,{encoding:`utf-8`});return typeof t==`string`?t:null}catch{return null}},findUnit:e=>{let n=t.scoops.get(e);return n?{workspace:t.workspaceFor(n),folder:n.folder}:void 0}})({kind:e.kind===`guest-tool`?`guest-tool`:`guest-message`,requester:e.requester??`an unidentified requester`,detail:e.detail},a.unitJid);return r.info(`Approver agent verdict`,{decision:l.decision,reason:l.reason}),l.decision===`allow`?{decision:`allow`}:o}if(a&&a.kind!==`user`){let n=i(a,t);return n.ok?t.enqueue(n.requesterJid,e,{approver:n.approver}):o}return t.approveAsUser(e)}export{s as runDirectedApproval};
@@ -0,0 +1 @@
1
+ import{t as e}from"./js-realm-worker-CIzPgKVU.js";const t={EACCES:2,EBADF:8,EBUSY:10,EEXIST:20,EINVAL:28,EIO:29,EISDIR:31,ELOOP:32,ENAMETOOLONG:37,ENOENT:44,ENOSPC:51,ENOSYS:52,ENOTDIR:54,ENOTEMPTY:55,EPERM:63,EROFS:69,ETIMEDOUT:73,EXDEV:75},n=4095;function r(e,n){if(n?.errno!==void 0&&n instanceof e.ErrnoError)return n;let r=n?.code,i=typeof r==`string`?t[r]??29:29;return new e.ErrnoError(i)}function i(e){let t=[],n=e;for(;n!==n.mount.root;)t.push(n.name),n=n.parent;let r=e.mount.opts.root.replace(/\/+$/,``);return t.length===0?r||`/`:`${r}/${t.reverse().join(`/`)}`}function a(e){let t=e.isSymbolicLink?40960:e.isDirectory?16384:32768,r=e.isDirectory||e.isSymbolicLink?511:438;return t|((e.mode??r)&n||r)}function o(e){if(e!=null)return e instanceof Date?e.getTime():e}function s(e,n){let o=e=>e.mount.opts.bridge;function s(t){try{return t()}catch(t){throw r(e,t)}}function c(e){try{s(e)}catch(e){if(e.errno!==t.ENOSYS)throw e}}function l(e){return{...e?{stat:e}:{},len:0,loaded:!1,dirty:!1,openCount:0}}function u(t,r,i){let o=e.createNode(t,r,a(i),0);return o.node_ops=n.node,o.stream_ops=n.stream,o.live=l(i),o}function d(e){if(!e.live.stat){let t=s(()=>o(e).lstat(i(e)));e.live.stat=t,e.mode=a(t)}return e.live.stat}function f(e,t){let n=i(e);return n===`/`?`/${t}`:`${n}/${t}`}function p(e){let t=e.live;if(t.loaded)return;let n=s(()=>o(e).readFile(i(e)));t.data=n,t.len=n.length,t.loaded=!0}function m(e,t){let n=e.live,r=n.data??new Uint8Array;if(r.length>=t)return r;let i=new Uint8Array(Math.max(t,r.length*2,256));return i.set(r.subarray(0,n.len)),n.data=i,i}function h(e){let t=e.live;if(!t.dirty||!t.data)return;let n=t.data.slice(0,t.len);s(()=>o(e).writeFile(i(e),n)),t.dirty=!1,t.stat=void 0}function g(e,t){let n=e.live;if(n.openCount>0){t>0?p(e):n.loaded=!0;let r=m(e,t);t>n.len&&r.fill(0,n.len,t),n.len=t,n.dirty=!0;return}let r=i(e),a=new Uint8Array(t);if(t>0){let n=s(()=>o(e).readFile(r));a.set(n.subarray(0,Math.min(t,n.length)))}s(()=>o(e).writeFile(r,a)),n.stat=void 0}return{Fs:e,bridgeOf:o,call:s,metadataCall:c,makeNode:u,statOf:d,childPath:f,ensureLoaded:p,ensureCapacity:m,flushNode:h,truncate:g}}function c(e){let{Fs:r,bridgeOf:a,call:s,metadataCall:c,makeNode:l,statOf:u,childPath:d,flushNode:f,truncate:p}=e;return{getattr(e){let t=u(e),n=e.live,i=r.isDir(e.mode)?4096:n.loaded?n.len:t.size,a=new Date(t.mtimeMs??0);return{dev:1,ino:e.id,mode:e.mode,nlink:1,uid:0,gid:0,rdev:0,size:i,atime:a,mtime:a,ctime:a,blksize:4096,blocks:Math.ceil(i/4096)}},setattr(e,t){let s=i(e);if(t.mode!==void 0&&t.mode!==null){let r=t.mode&n;r!==(e.mode&n)&&(c(()=>a(e).chmod(s,r)),e.mode=e.mode&-4096|r)}t.size!==void 0&&t.size!==null&&r.isFile(e.mode)&&p(e,t.size);let l=o(t.mtime)??t.timestamp;if(l!==void 0){let n=o(t.atime)??l;f(e),c(()=>a(e).utimes(s,n,l))}e.live.stat=void 0},lookup(e,t){let n=s(()=>a(e).lstat(d(e,t)));return l(e,t,n)},mknod(e,n,i){let o=d(e,n);if(r.isDir(i))s(()=>a(e).mkdir(o));else if(r.isFile(i))s(()=>a(e).writeFile(o,new Uint8Array));else throw new r.ErrnoError(t.EPERM);let c=l(e,n,{isFile:r.isFile(i),isDirectory:r.isDir(i),isSymbolicLink:!1,size:0,mode:i,mtimeMs:Date.now()});return c.live.stat=void 0,c},rename(e,t,n){let o=i(e),c=d(t,n);f(e),s(()=>a(e).rename(o,c));try{let i=r.lookupNode?.(t,n);i&&i!==e&&r.hashRemoveNode?.(i)}catch{}e.name=n,e.live.stat=void 0},unlink(e,t){s(()=>a(e).unlink(d(e,t)))},rmdir(e,t){s(()=>a(e).rmdir(d(e,t)))},readdir(e){return[`.`,`..`,...s(()=>a(e).readdir(i(e)))]},symlink(e,t,n){let r=d(e,t);return s(()=>a(e).symlink(n,r)),l(e,t,{isFile:!1,isDirectory:!1,isSymbolicLink:!0,size:n.length})},readlink(e){if(!r.isLink(e.mode))throw new r.ErrnoError(t.EINVAL);return s(()=>a(e).readlink(i(e)))}}}function l(e){let{Fs:n,statOf:r,ensureLoaded:i,ensureCapacity:a,flushNode:o}=e;return{open(e){n.isFile(e.node.mode)&&e.node.live.openCount++},close(e){let t=e.node;if(!n.isFile(t.mode))return;let r=t.live;if(r.openCount=Math.max(0,r.openCount-1),!(r.openCount>0))try{o(t)}finally{r.data=void 0,r.len=0,r.loaded=!1}},read(e,r,a,o,s){let c=e.node;if(n.isDir(c.mode))throw new n.ErrnoError(t.EISDIR);i(c);let l=c.live;if(s>=l.len||o<=0)return 0;let u=Math.min(o,l.len-s);return new Uint8Array(r.buffer,r.byteOffset+a,u).set(l.data.subarray(s,s+u)),u},write(e,r,o,s,c){let l=e.node;if(n.isDir(l.mode))throw new n.ErrnoError(t.EISDIR);if(s<=0)return 0;i(l);let u=l.live,d=c+s,f=a(l,d);return c>u.len&&f.fill(0,u.len,c),f.set(new Uint8Array(r.buffer,r.byteOffset+o,s),c),u.len=Math.max(u.len,d),u.dirty=!0,s},llseek(e,i,a){let o=i;if(a===1)o+=e.position;else if(a===2&&n.isFile(e.node.mode)){let t=e.node.live;o+=t.loaded?t.len:r(e.node).size}if(o<0)throw new n.ErrnoError(t.EINVAL);return o},fsync(e){o(e.node)}}}function u(e){let n=new Set,r={},i=s(e,r),a=c(i),o=l(i);return r.node=a,r.stream=o,{mounts:n,node_ops:a,stream_ops:o,mount(r){let a=i.call(()=>r.opts.bridge.stat(r.opts.root));if(!a.isDirectory)throw new e.ErrnoError(t.ENOTDIR);let o=i.makeNode(null,`/`,a);return n.add(r),o}}}function d(e,t){return!!t&&e.mounts.has(t.mount)}function f(e,t){for(let n of e.nameTable??[])for(let a=n;a;a=a.name_next??null)if(!(!d(t,a)||!a.live.dirty||!a.live.data))try{let e=a.live.data.slice(0,a.live.len);a.mount.opts.bridge.writeFile(i(a),e),a.live.dirty=!1}catch(t){throw r(e,t)}}function p(e,t){let n=e.nameTable??[],r=[];for(let e of n)for(let n=e;n;n=n.name_next??null){if(!d(t,n))continue;let e=n.live;e.stat=void 0,e.openCount===0?n!==n.mount.root&&r.push(n):e.loaded&&!e.dirty&&(e.data=void 0,e.len=0,e.loaded=!1)}if(e.hashRemoveNode)for(let t of r)e.hashRemoveNode(t)}function m(e){let t=[...new Set(e.map(e=>e.replace(/\/+$/,``)||`/`))].sort();return t.filter(e=>!t.some(t=>t!==e&&(t===`/`||e.startsWith(`${t}/`))))}function h(e,t,n,r){let i=e.filesystems.SLICC_LIVE_FS??u(e);e.filesystems.SLICC_LIVE_FS=i;let a=[];for(let o of m(n))if(o!==`/`)try{e.mkdirTree(o),e.mount(i,{root:o,bridge:t},o),a.push(o)}catch(e){r(`live VFS mount of ${o} failed: ${e instanceof Error?e.message:String(e)}`)}return{plugin:i,mounted:a}}const g=new Set([`dev`,`proc`]),_=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function v(t,n){let r={...t};for(let i of _){let a=t[i];r[i]=(...r)=>{n.wasUsed()&&e(n,t);try{a.apply(t,r)}finally{n.invalidate()}}}return r}function y(e,t){let n;try{n=e.readdir(`/`)}catch(e){return t(`cannot list the VFS root, nothing mounted: ${String(e)}`),[]}let r=[];for(let t of n)if(!(!t||t.includes(`/`)||g.has(t)))try{e.stat(`/${t}`).isDirectory&&r.push(`/${t}`)}catch{}return r}function b(t,n,r={}){let{bridge:i,syncFs:a,warn:o}=n;a.wasUsed()&&e(a,i);let{plugin:s,mounted:c}=h(t,v(i,a),y(i,o),o);try{t.chdir(r.cwd??n.cwd)}catch(e){o(`cannot chdir to ${r.cwd??n.cwd}: ${String(e)}`)}return{mounted:c,flush:()=>f(t,s),invalidate:()=>p(t,s)}}export{b as mountVfsIntoEmscripten};
@@ -1 +1 @@
1
- import{n as e,r as t,t as n}from"./live-vfs-fs-DXo5N-ez.js";import{a as r}from"./realm-sync-transport-CuihwLFz.js";const i=new Set([`dev`,`proc`]),a=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function o(e,t){let n={...e};for(let i of a){let a=e[i];n[i]=(...n)=>{t.wasUsed()&&r(t,e);try{a.apply(e,n)}finally{t.invalidate()}}}return n}function s(e,t){let n;try{n=e.readdir(`/`)}catch(e){return t(`cannot list the VFS root, nothing mounted: ${String(e)}`),[]}let r=[];for(let t of n)if(!(!t||t.includes(`/`)||i.has(t)))try{e.stat(`/${t}`).isDirectory&&r.push(`/${t}`)}catch{}return r}function c(i,a,c={}){let{bridge:l,syncFs:u,warn:d}=a;u.wasUsed()&&r(u,l);let{plugin:f,mounted:p}=t(i,o(l,u),s(l,d),d);try{i.chdir(c.cwd??a.cwd)}catch(e){d(`cannot chdir to ${c.cwd??a.cwd}: ${String(e)}`)}return{mounted:p,flush:()=>n(i,f),invalidate:()=>e(i,f)}}export{c as mountVfsIntoEmscripten};
1
+ import{n as e,r as t,t as n}from"./live-vfs-fs-CX95TogC.js";import{a as r}from"./realm-sync-transport-CuihwLFz.js";const i=new Set([`dev`,`proc`]),a=[`writeFile`,`mkdir`,`rm`,`rename`,`unlink`,`rmdir`,`symlink`,`chmod`,`utimes`];function o(e,t){let n={...e};for(let i of a){let a=e[i];n[i]=(...n)=>{t.wasUsed()&&r(t,e);try{a.apply(e,n)}finally{t.invalidate()}}}return n}function s(e,t){let n;try{n=e.readdir(`/`)}catch(e){return t(`cannot list the VFS root, nothing mounted: ${String(e)}`),[]}let r=[];for(let t of n)if(!(!t||t.includes(`/`)||i.has(t)))try{e.stat(`/${t}`).isDirectory&&r.push(`/${t}`)}catch{}return r}function c(i,a,c={}){let{bridge:l,syncFs:u,warn:d}=a;u.wasUsed()&&r(u,l);let{plugin:f,mounted:p}=t(i,o(l,u),s(l,d),d);try{i.chdir(c.cwd??a.cwd)}catch(e){d(`cannot chdir to ${c.cwd??a.cwd}: ${String(e)}`)}return{mounted:p,flush:()=>n(i,f),invalidate:()=>e(i,f)}}export{c as mountVfsIntoEmscripten};
@@ -1 +1 @@
1
- import{t as e}from"./logger-LESFN7Hj.js";import"./proxied-fetch-DXaTHROw.js";import{t}from"./runtime-env-DadgceZk.js";import"./shared-DfMXB1pm.js";import{n}from"./hf-defaults-BwJdGLgk.js";import{r}from"./installer-BqstqF0q.js";import{downloadHfRepo as i}from"./hf-download-CNg2vD63.js";e(`speech:espeak`);const a=[`ort-wasm-simd-threaded.jsep.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jsep.wasm`,`ort-wasm-simd-threaded.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort.wasm`,`ort-wasm-simd-threaded.asyncify.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.asyncify.wasm`,`ort-wasm-simd-threaded.jspi.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jspi.wasm`],o=e(`speech:ensure-assets`),s=`onnxruntime-web`,c=`${s}@1.31.0-dev.20260914-8d85527a0`,l=`espeak-ng`,u=[`espeak-ng.js`,`espeak-ng.wasm`],d=`/workspace`,f=t,p=a.filter(e=>!/\.(asyncify|jspi)\./.test(e));async function m(e){try{let t=await e.readFile(`/workspace/node_modules/onnxruntime-web/package.json`,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);if(r&&typeof r==`object`&&`version`in r&&typeof r.version==`string`)return r.version}catch{}return null}async function h(e,t){let n=await Promise.all(p.map(t=>e.fs.exists(`/workspace/node_modules/onnxruntime-web/dist/${t}`))),i=await m(e.fs);if(n.every(Boolean)&&i===`1.31.0-dev.20260914-8d85527a0`)return t?.({asset:s,phase:`present`}),!1;t?.({asset:s,phase:`staging`});let{errors:a}=await r([c],{fs:e.fs,fetch:e.fetch,cwd:d});if(a.length>0)throw Error(`failed to stage ${s} wasm runtime: ${a[0].error.message}`);return t?.({asset:s,phase:`done`}),!0}async function g(e,t){if((await Promise.all(u.map(t=>e.fs.exists(`/workspace/node_modules/espeak-ng/dist/${t}`)))).every(Boolean))return t?.({asset:l,phase:`present`}),!1;t?.({asset:l,phase:`staging`});let{errors:n}=await r([l],{fs:e.fs,fetch:e.fetch,cwd:d});if(n.length>0)throw Error(`failed to stage ${l} wasm: ${n[0].error.message}`);return t?.({asset:l,phase:`done`}),!0}async function _(e,t){try{return await g(e,t)}catch(e){return o.warn(`optional espeak-ng staging failed; non-English Kokoro voices may fall back`,e),!1}}async function v(e,t,r){let a=n(t,null,d),o=0,s=await i({fetch:e.fetch,fs:e.fs,repo:t,targetDir:a,progress:{onListed:({files:e,totalBytes:n})=>r?.({asset:t,phase:`listing`,filesLoaded:0,filesTotal:e.length,bytesLoaded:0,bytesTotal:n}),onFile:e=>{o+=e.bytes,r?.({asset:t,phase:e.status,file:e.file,filesLoaded:e.index,filesTotal:e.total,bytesLoaded:o})}}});return r?.({asset:t,phase:`done`,filesLoaded:s.files.length,filesTotal:s.files.length,bytesLoaded:o,bytesTotal:o}),{repo:t,downloaded:s.downloaded,skipped:s.skipped}}async function y(e,t){if(f())return{skipped:!0,ortStaged:!1,espeakStaged:!1,repos:[]};let n=await h(e,t),r=e.repos??[`onnx-community/whisper-tiny`,`onnx-community/Kokoro-82M-v1.0-ONNX`],i=[];for(let n of r)i.push(await v(e,n,t));let a=await _(e,t);return o.info(`speech assets staged`,{ortStaged:n,espeakStaged:a,repos:i.length}),{skipped:!1,ortStaged:n,espeakStaged:a,repos:i}}export{y as ensureSpeechAssetsStaged};
1
+ import{t as e}from"./logger-LESFN7Hj.js";import"./proxied-fetch-DXaTHROw.js";import{t}from"./runtime-env-DadgceZk.js";import"./shared-2XhBobrM.js";import{n}from"./hf-defaults-BwJdGLgk.js";import{r}from"./installer-BamTBGiN.js";import{downloadHfRepo as i}from"./hf-download-CNg2vD63.js";e(`speech:espeak`);const a=[`ort-wasm-simd-threaded.jsep.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jsep.wasm`,`ort-wasm-simd-threaded.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort.wasm`,`ort-wasm-simd-threaded.asyncify.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.asyncify.wasm`,`ort-wasm-simd-threaded.jspi.mjs`,`https://${["cdn","jsdelivr","net"].join(".")}/npm/onnxruntime-web@1.31.0-dev.20260914-8d85527a0/dist/ort-wasm-simd-threaded.jspi.wasm`],o=e(`speech:ensure-assets`),s=`onnxruntime-web`,c=`${s}@1.31.0-dev.20260914-8d85527a0`,l=`espeak-ng`,u=[`espeak-ng.js`,`espeak-ng.wasm`],d=`/workspace`,f=t,p=a.filter(e=>!/\.(asyncify|jspi)\./.test(e));async function m(e){try{let t=await e.readFile(`/workspace/node_modules/onnxruntime-web/package.json`,{encoding:`utf-8`}),n=typeof t==`string`?t:new TextDecoder().decode(t),r=JSON.parse(n);if(r&&typeof r==`object`&&`version`in r&&typeof r.version==`string`)return r.version}catch{}return null}async function h(e,t){let n=await Promise.all(p.map(t=>e.fs.exists(`/workspace/node_modules/onnxruntime-web/dist/${t}`))),i=await m(e.fs);if(n.every(Boolean)&&i===`1.31.0-dev.20260914-8d85527a0`)return t?.({asset:s,phase:`present`}),!1;t?.({asset:s,phase:`staging`});let{errors:a}=await r([c],{fs:e.fs,fetch:e.fetch,cwd:d});if(a.length>0)throw Error(`failed to stage ${s} wasm runtime: ${a[0].error.message}`);return t?.({asset:s,phase:`done`}),!0}async function g(e,t){if((await Promise.all(u.map(t=>e.fs.exists(`/workspace/node_modules/espeak-ng/dist/${t}`)))).every(Boolean))return t?.({asset:l,phase:`present`}),!1;t?.({asset:l,phase:`staging`});let{errors:n}=await r([l],{fs:e.fs,fetch:e.fetch,cwd:d});if(n.length>0)throw Error(`failed to stage ${l} wasm: ${n[0].error.message}`);return t?.({asset:l,phase:`done`}),!0}async function _(e,t){try{return await g(e,t)}catch(e){return o.warn(`optional espeak-ng staging failed; non-English Kokoro voices may fall back`,e),!1}}async function v(e,t,r){let a=n(t,null,d),o=0,s=await i({fetch:e.fetch,fs:e.fs,repo:t,targetDir:a,progress:{onListed:({files:e,totalBytes:n})=>r?.({asset:t,phase:`listing`,filesLoaded:0,filesTotal:e.length,bytesLoaded:0,bytesTotal:n}),onFile:e=>{o+=e.bytes,r?.({asset:t,phase:e.status,file:e.file,filesLoaded:e.index,filesTotal:e.total,bytesLoaded:o})}}});return r?.({asset:t,phase:`done`,filesLoaded:s.files.length,filesTotal:s.files.length,bytesLoaded:o,bytesTotal:o}),{repo:t,downloaded:s.downloaded,skipped:s.skipped}}async function y(e,t){if(f())return{skipped:!0,ortStaged:!1,espeakStaged:!1,repos:[]};let n=await h(e,t),r=e.repos??[`onnx-community/whisper-tiny`,`onnx-community/Kokoro-82M-v1.0-ONNX`],i=[];for(let n of r)i.push(await v(e,n,t));let a=await _(e,t);return o.info(`speech assets staged`,{ortStaged:n,espeakStaged:a,repos:i.length}),{skipped:!1,ortStaged:n,espeakStaged:a,repos:i}}export{y as ensureSpeechAssetsStaged};
@@ -1,4 +1,4 @@
1
- import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{a as n}from"./path-utils-DNJG-zQf.js";import{C as r,S as i,p as a,t as o}from"./shared-DfMXB1pm.js";import{n as s}from"./wasm-compiler-Ct7QZURL.js";var c=e(t(((e,t)=>{(e=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},o=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},s=e=>o(t({},`__esModule`,{value:!0}),e),c=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),l={};a(l,{analyzeMetafile:()=>xe,analyzeMetafileSync:()=>Te,build:()=>_e,buildSync:()=>Se,context:()=>ve,default:()=>je,formatMessages:()=>be,formatMessagesSync:()=>we,initialize:()=>ke,stop:()=>Ee,transform:()=>ye,transformSync:()=>Ce,version:()=>ge}),e.exports=s(l);function u(e){let t=e=>{if(e===null)n.write8(0);else if(typeof e==`boolean`)n.write8(1),n.write8(+e);else if(typeof e==`number`)n.write8(2),n.write32(e|0);else if(typeof e==`string`)n.write8(3),n.write(p(e));else if(e instanceof Uint8Array)n.write8(4),n.write(e);else if(e instanceof Array){n.write8(5),n.write32(e.length);for(let n of e)t(n)}else{let r=Object.keys(e);n.write8(6),n.write32(r.length);for(let i of r)n.write(p(i)),t(e[i])}},n=new f;return n.write32(0),n.write32(e.id<<1|!e.isRequest),t(e.value),_(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function d(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return m(n.read());case 4:return n.read();case 5:{let e=n.read32(),r=[];for(let n=0;n<e;n++)r.push(t());return r}case 6:{let e=n.read32(),r={};for(let i=0;i<e;i++)r[m(n.read())]=t();return r}default:throw Error(`Invalid packet`)}},n=new f(e),r=n.read32(),i=!(r&1);r>>>=1;let a=t();if(n.ptr!==e.length)throw Error(`Invalid packet`);return{id:r,isRequest:i,value:a}}var f=class{constructor(e=new Uint8Array(1024)){this.buf=e,this.len=0,this.ptr=0}_write(e){if(this.len+e>this.buf.length){let t=new Uint8Array((this.len+e)*2);t.set(this.buf),this.buf=t}return this.len+=e,this.len-e}write8(e){let t=this._write(1);this.buf[t]=e}write32(e){let t=this._write(4);_(this.buf,e,t)}write(e){let t=this._write(4+e.length);_(this.buf,e.length,t),this.buf.set(e,t+4)}_read(e){if(this.ptr+e>this.buf.length)throw Error(`Invalid packet`);return this.ptr+=e,this.ptr-e}read8(){return this.buf[this._read(1)]}read32(){return g(this.buf,this._read(4))}read(){let e=this.read32(),t=new Uint8Array(e),n=this._read(t.length);return t.set(this.buf.subarray(n,n+e)),t}},p,m,h;if(typeof TextEncoder<`u`&&typeof TextDecoder<`u`){let e=new TextEncoder,t=new TextDecoder;p=t=>e.encode(t),m=e=>t.decode(e),h=`new TextEncoder().encode("")`}else if(typeof Buffer<`u`)p=e=>Buffer.from(e),m=e=>{let{buffer:t,byteOffset:n,byteLength:r}=e;return Buffer.from(t,n,r).toString()},h=`Buffer.from("")`;else throw Error(`No UTF-8 codec found`);if(!(p(``)instanceof Uint8Array))throw Error(`Invariant violation: "${h} instanceof Uint8Array" is incorrectly false
1
+ import{i as e,t}from"./rolldown-runtime-Dd_uD5pT.js";import{a as n}from"./path-utils-DNJG-zQf.js";import{C as r,S as i,p as a,t as o}from"./shared-2XhBobrM.js";import{n as s}from"./wasm-compiler-Ct7QZURL.js";var c=e(t(((e,t)=>{(e=>{var t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.prototype.hasOwnProperty,a=(e,n)=>{for(var r in n)t(e,r,{get:n[r],enumerable:!0})},o=(e,a,o,s)=>{if(a&&typeof a==`object`||typeof a==`function`)for(let c of r(a))!i.call(e,c)&&c!==o&&t(e,c,{get:()=>a[c],enumerable:!(s=n(a,c))||s.enumerable});return e},s=e=>o(t({},`__esModule`,{value:!0}),e),c=(e,t,n)=>new Promise((r,i)=>{var a=e=>{try{s(n.next(e))}catch(e){i(e)}},o=e=>{try{s(n.throw(e))}catch(e){i(e)}},s=e=>e.done?r(e.value):Promise.resolve(e.value).then(a,o);s((n=n.apply(e,t)).next())}),l={};a(l,{analyzeMetafile:()=>xe,analyzeMetafileSync:()=>Te,build:()=>_e,buildSync:()=>Se,context:()=>ve,default:()=>je,formatMessages:()=>be,formatMessagesSync:()=>we,initialize:()=>ke,stop:()=>Ee,transform:()=>ye,transformSync:()=>Ce,version:()=>ge}),e.exports=s(l);function u(e){let t=e=>{if(e===null)n.write8(0);else if(typeof e==`boolean`)n.write8(1),n.write8(+e);else if(typeof e==`number`)n.write8(2),n.write32(e|0);else if(typeof e==`string`)n.write8(3),n.write(p(e));else if(e instanceof Uint8Array)n.write8(4),n.write(e);else if(e instanceof Array){n.write8(5),n.write32(e.length);for(let n of e)t(n)}else{let r=Object.keys(e);n.write8(6),n.write32(r.length);for(let i of r)n.write(p(i)),t(e[i])}},n=new f;return n.write32(0),n.write32(e.id<<1|!e.isRequest),t(e.value),_(n.buf,n.len-4,0),n.buf.subarray(0,n.len)}function d(e){let t=()=>{switch(n.read8()){case 0:return null;case 1:return!!n.read8();case 2:return n.read32();case 3:return m(n.read());case 4:return n.read();case 5:{let e=n.read32(),r=[];for(let n=0;n<e;n++)r.push(t());return r}case 6:{let e=n.read32(),r={};for(let i=0;i<e;i++)r[m(n.read())]=t();return r}default:throw Error(`Invalid packet`)}},n=new f(e),r=n.read32(),i=!(r&1);r>>>=1;let a=t();if(n.ptr!==e.length)throw Error(`Invalid packet`);return{id:r,isRequest:i,value:a}}var f=class{constructor(e=new Uint8Array(1024)){this.buf=e,this.len=0,this.ptr=0}_write(e){if(this.len+e>this.buf.length){let t=new Uint8Array((this.len+e)*2);t.set(this.buf),this.buf=t}return this.len+=e,this.len-e}write8(e){let t=this._write(1);this.buf[t]=e}write32(e){let t=this._write(4);_(this.buf,e,t)}write(e){let t=this._write(4+e.length);_(this.buf,e.length,t),this.buf.set(e,t+4)}_read(e){if(this.ptr+e>this.buf.length)throw Error(`Invalid packet`);return this.ptr+=e,this.ptr-e}read8(){return this.buf[this._read(1)]}read32(){return g(this.buf,this._read(4))}read(){let e=this.read32(),t=new Uint8Array(e),n=this._read(t.length);return t.set(this.buf.subarray(n,n+e)),t}},p,m,h;if(typeof TextEncoder<`u`&&typeof TextDecoder<`u`){let e=new TextEncoder,t=new TextDecoder;p=t=>e.encode(t),m=e=>t.decode(e),h=`new TextEncoder().encode("")`}else if(typeof Buffer<`u`)p=e=>Buffer.from(e),m=e=>{let{buffer:t,byteOffset:n,byteLength:r}=e;return Buffer.from(t,n,r).toString()},h=`Buffer.from("")`;else throw Error(`No UTF-8 codec found`);if(!(p(``)instanceof Uint8Array))throw Error(`Invariant violation: "${h} instanceof Uint8Array" is incorrectly false
2
2
 
3
3
  This indicates that your JavaScript environment is broken. You cannot use
4
4
  esbuild in this environment because esbuild relies on this invariant. This
@@ -1 +1 @@
1
- import{a as e}from"./path-utils-DNJG-zQf.js";import{C as t,p as n,t as r}from"./shared-DfMXB1pm.js";var i;(function(e){e.LOAD=`LOAD`,e.EXEC=`EXEC`,e.FFPROBE=`FFPROBE`,e.WRITE_FILE=`WRITE_FILE`,e.READ_FILE=`READ_FILE`,e.DELETE_FILE=`DELETE_FILE`,e.RENAME=`RENAME`,e.CREATE_DIR=`CREATE_DIR`,e.LIST_DIR=`LIST_DIR`,e.DELETE_DIR=`DELETE_DIR`,e.ERROR=`ERROR`,e.DOWNLOAD=`DOWNLOAD`,e.PROGRESS=`PROGRESS`,e.LOG=`LOG`,e.MOUNT=`MOUNT`,e.UNMOUNT=`UNMOUNT`})(i||={});const a=(()=>{let e=0;return()=>e++})(),o=Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),s=Error(`called FFmpeg.terminate()`);var c=class{#e=null;#t={};#n={};#r=[];#i=[];loaded=!1;#a=()=>{this.#e&&(this.#e.onmessage=({data:{id:e,type:t,data:n}})=>{switch(t){case i.LOAD:this.loaded=!0,this.#t[e](n);break;case i.MOUNT:case i.UNMOUNT:case i.EXEC:case i.FFPROBE:case i.WRITE_FILE:case i.READ_FILE:case i.DELETE_FILE:case i.RENAME:case i.CREATE_DIR:case i.LIST_DIR:case i.DELETE_DIR:this.#t[e](n);break;case i.LOG:this.#r.forEach(e=>e(n));break;case i.PROGRESS:this.#i.forEach(e=>e(n));break;case i.ERROR:this.#n[e](n)}delete this.#t[e],delete this.#n[e]})};#o=({type:e,data:t},n=[],r)=>this.#e?new Promise((i,o)=>{let s=a();this.#e&&this.#e.postMessage({id:s,type:e,data:t},n),this.#t[s]=i,this.#n[s]=o,r?.addEventListener(`abort`,()=>{o(new DOMException(`Message # ${s} was aborted`,`AbortError`))},{once:!0})}):Promise.reject(o);on(e,t){e===`log`?this.#r.push(t):e===`progress`&&this.#i.push(t)}off(e,t){e===`log`?this.#r=this.#r.filter(e=>e!==t):e===`progress`&&(this.#i=this.#i.filter(e=>e!==t))}load=({classWorkerURL:e,...t}={},{signal:n}={})=>(this.#e||(this.#e=e?new Worker(new URL(e,import.meta.url),{type:`module`}):new Worker(new URL(`/assets/worker-D1KsWRGg.js`,``+import.meta.url),{type:`module`}),this.#a()),this.#o({type:i.LOAD,data:t},void 0,n));exec=(e,t=-1,{signal:n}={})=>this.#o({type:i.EXEC,data:{args:e,timeout:t}},void 0,n);ffprobe=(e,t=-1,{signal:n}={})=>this.#o({type:i.FFPROBE,data:{args:e,timeout:t}},void 0,n);terminate=()=>{let e=Object.keys(this.#n);for(let t of e)this.#n[t](s),delete this.#n[t],delete this.#t[t];this.#e&&(this.#e.terminate(),this.#e=null,this.loaded=!1)};writeFile=(e,t,{signal:n}={})=>{let r=[];return t instanceof Uint8Array&&r.push(t.buffer),this.#o({type:i.WRITE_FILE,data:{path:e,data:t}},r,n)};mount=(e,t,n)=>this.#o({type:i.MOUNT,data:{fsType:e,options:t,mountPoint:n}},[]);unmount=e=>this.#o({type:i.UNMOUNT,data:{mountPoint:e}},[]);readFile=(e,t=`binary`,{signal:n}={})=>this.#o({type:i.READ_FILE,data:{path:e,encoding:t}},void 0,n);deleteFile=(e,{signal:t}={})=>this.#o({type:i.DELETE_FILE,data:{path:e}},void 0,t);rename=(e,t,{signal:n}={})=>this.#o({type:i.RENAME,data:{oldPath:e,newPath:t}},void 0,n);createDir=(e,{signal:t}={})=>this.#o({type:i.CREATE_DIR,data:{path:e}},void 0,t);listDir=(e,{signal:t}={})=>this.#o({type:i.LIST_DIR,data:{path:e}},void 0,t);deleteDir=(e,{signal:t}={})=>this.#o({type:i.DELETE_DIR,data:{path:e}},void 0,t)},l;(function(e){e.MEMFS=`MEMFS`,e.NODEFS=`NODEFS`,e.NODERAWFS=`NODERAWFS`,e.IDBFS=`IDBFS`,e.WORKERFS=`WORKERFS`,e.PROXYFS=`PROXYFS`})(l||={});const u=`0.12.10`,d=`@ffmpeg/core is not installed in node_modules: run \`${r} @ffmpeg/core@${u}\` (no network fallback)`,f=`@ffmpeg/core-mt`,p=`@ffmpeg/core-mt is not installed in node_modules (FFMPEG_CORE=mt asked for the multi-threaded core): run \`${r} ${f}@${u}\`, or unset FFMPEG_CORE and run \`${r} @ffmpeg/core@${u}\` (no network fallback)`;function m(){return globalThis.crossOriginIsolated===!0}function h(e=!1){return e&&m()?p:d}function g(e,t=m(),n=typeof navigator<`u`?navigator.hardwareConcurrency:void 0){let i=`${e.pkg} ${u}`;return e.pkg===`@ffmpeg/core-mt`?`${i} (multi-threaded${typeof n==`number`&&n>0?`, ${n} threads`:``}; single-input jobs only)`:t?`${i} (single-threaded; the multi-threaded core is opt-in on this isolated runtime: \`${r} ${f}@${u}\` then FFMPEG_CORE=mt, single-input jobs only)`:`${i} (single-threaded; runtime is not cross-origin isolated)`}const _=[`dist/esm`];async function v(e,t,n){for(let r of _){let i=`${e}/${r}`,a={core:`${i}/ffmpeg-core.js`,wasm:`${i}/ffmpeg-core.wasm`,worker:t===`@ffmpeg/core-mt`?`${i}/ffmpeg-core.worker.js`:null};if(await n.exists(a.core)&&await n.exists(a.wasm)&&!(a.worker&&!await n.exists(a.worker)))return a}return null}let y=null,b=null,x=[],S=null;function C(){return S}function w(e){for(let t of e)try{URL.revokeObjectURL(t)}catch{}}async function T(e={}){return y||=E(e.onProgress,e.ipk,e.preferMt===!0).catch(e=>{throw y=null,e}),y}async function E(e,t,n){let r=e??(()=>{}),i=new c,a=await k(t,r,n),o=[a.coreURL,a.wasmURL,a.workerURL,a.classWorkerURL].filter(e=>typeof e==`string`);r(`initializing ffmpeg-core...`);try{await i.load({coreURL:a.coreURL,wasmURL:a.wasmURL,...a.workerURL?{workerURL:a.workerURL}:{},...a.classWorkerURL?{classWorkerURL:a.classWorkerURL}:{}})}catch(e){throw w(o),e}return r(`ffmpeg ready`),b=i,x=o,S=a.pkg,i}async function D(n,r,i=!1){if(r===void 0)return O(n,i&&m());let a;try{a=await t(`${r}/package.json`,n.fromDir,n.reader)}catch{return null}if(a.type!==`file`)return null;let o=await v(e(a.path).dir,r,n.reader);if(!o)return null;try{let e=await n.reader.readFile(o.core),t=await n.readBytes(o.wasm),i=o.worker?await n.reader.readFile(o.worker):void 0;return{pkg:r,coreSource:e,wasmBytes:t,...i===void 0?{}:{workerSource:i}}}catch{return null}}async function O(e,t){if(t){let t=await D(e,f);if(t)return t}return D(e,`@ffmpeg/core`)}async function k(e,t,r){if(n())throw Error(`ffmpeg-wasm is not available in Node runtime`);let i=r&&m();if(!e)throw Error(h(i));let a=await O(e,i);if(!a)throw Error(h(i));t(`${a.pkg} loaded from ipk node_modules (js: ${a.coreSource.length} chars, wasm: ${a.wasmBytes.byteLength} bytes${a.workerSource?`, multi-threaded`:``})`);let o=A(a.wasmBytes,`application/wasm`);return{pkg:a.pkg,coreURL:j(a.coreSource,`text/javascript`),wasmURL:o,...a.workerSource===void 0?{}:{workerURL:j(a.workerSource,`text/javascript`)}}}function A(e,t){let n=new ArrayBuffer(e.byteLength);return new Uint8Array(n).set(e),URL.createObjectURL(new Blob([n],{type:t}))}function j(e,t){return URL.createObjectURL(new Blob([e],{type:t}))}function M(e){if(typeof WebAssembly<`u`&&e instanceof WebAssembly.RuntimeError||e instanceof RangeError)return!0;let t=e instanceof Error?e.message:String(e);return/RuntimeError|memory access out of bounds|unreachable|Aborted|out of memory|allocation failed|table index is out of bounds|function signature mismatch/i.test(t)}function N(e){if(e!==void 0&&b!==e)return;let t=b,n=x;if(y=null,b=null,x=[],S=null,t)try{t.terminate()}catch{}w(n)}export{T as a,N as c,h as i,D as l,f as n,M as o,g as r,C as s,u as t};
1
+ import{a as e}from"./path-utils-DNJG-zQf.js";import{C as t,p as n,t as r}from"./shared-2XhBobrM.js";var i;(function(e){e.LOAD=`LOAD`,e.EXEC=`EXEC`,e.FFPROBE=`FFPROBE`,e.WRITE_FILE=`WRITE_FILE`,e.READ_FILE=`READ_FILE`,e.DELETE_FILE=`DELETE_FILE`,e.RENAME=`RENAME`,e.CREATE_DIR=`CREATE_DIR`,e.LIST_DIR=`LIST_DIR`,e.DELETE_DIR=`DELETE_DIR`,e.ERROR=`ERROR`,e.DOWNLOAD=`DOWNLOAD`,e.PROGRESS=`PROGRESS`,e.LOG=`LOG`,e.MOUNT=`MOUNT`,e.UNMOUNT=`UNMOUNT`})(i||={});const a=(()=>{let e=0;return()=>e++})(),o=Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),s=Error(`called FFmpeg.terminate()`);var c=class{#e=null;#t={};#n={};#r=[];#i=[];loaded=!1;#a=()=>{this.#e&&(this.#e.onmessage=({data:{id:e,type:t,data:n}})=>{switch(t){case i.LOAD:this.loaded=!0,this.#t[e](n);break;case i.MOUNT:case i.UNMOUNT:case i.EXEC:case i.FFPROBE:case i.WRITE_FILE:case i.READ_FILE:case i.DELETE_FILE:case i.RENAME:case i.CREATE_DIR:case i.LIST_DIR:case i.DELETE_DIR:this.#t[e](n);break;case i.LOG:this.#r.forEach(e=>e(n));break;case i.PROGRESS:this.#i.forEach(e=>e(n));break;case i.ERROR:this.#n[e](n)}delete this.#t[e],delete this.#n[e]})};#o=({type:e,data:t},n=[],r)=>this.#e?new Promise((i,o)=>{let s=a();this.#e&&this.#e.postMessage({id:s,type:e,data:t},n),this.#t[s]=i,this.#n[s]=o,r?.addEventListener(`abort`,()=>{o(new DOMException(`Message # ${s} was aborted`,`AbortError`))},{once:!0})}):Promise.reject(o);on(e,t){e===`log`?this.#r.push(t):e===`progress`&&this.#i.push(t)}off(e,t){e===`log`?this.#r=this.#r.filter(e=>e!==t):e===`progress`&&(this.#i=this.#i.filter(e=>e!==t))}load=({classWorkerURL:e,...t}={},{signal:n}={})=>(this.#e||(this.#e=e?new Worker(new URL(e,import.meta.url),{type:`module`}):new Worker(new URL(`/assets/worker-D1KsWRGg.js`,``+import.meta.url),{type:`module`}),this.#a()),this.#o({type:i.LOAD,data:t},void 0,n));exec=(e,t=-1,{signal:n}={})=>this.#o({type:i.EXEC,data:{args:e,timeout:t}},void 0,n);ffprobe=(e,t=-1,{signal:n}={})=>this.#o({type:i.FFPROBE,data:{args:e,timeout:t}},void 0,n);terminate=()=>{let e=Object.keys(this.#n);for(let t of e)this.#n[t](s),delete this.#n[t],delete this.#t[t];this.#e&&(this.#e.terminate(),this.#e=null,this.loaded=!1)};writeFile=(e,t,{signal:n}={})=>{let r=[];return t instanceof Uint8Array&&r.push(t.buffer),this.#o({type:i.WRITE_FILE,data:{path:e,data:t}},r,n)};mount=(e,t,n)=>this.#o({type:i.MOUNT,data:{fsType:e,options:t,mountPoint:n}},[]);unmount=e=>this.#o({type:i.UNMOUNT,data:{mountPoint:e}},[]);readFile=(e,t=`binary`,{signal:n}={})=>this.#o({type:i.READ_FILE,data:{path:e,encoding:t}},void 0,n);deleteFile=(e,{signal:t}={})=>this.#o({type:i.DELETE_FILE,data:{path:e}},void 0,t);rename=(e,t,{signal:n}={})=>this.#o({type:i.RENAME,data:{oldPath:e,newPath:t}},void 0,n);createDir=(e,{signal:t}={})=>this.#o({type:i.CREATE_DIR,data:{path:e}},void 0,t);listDir=(e,{signal:t}={})=>this.#o({type:i.LIST_DIR,data:{path:e}},void 0,t);deleteDir=(e,{signal:t}={})=>this.#o({type:i.DELETE_DIR,data:{path:e}},void 0,t)},l;(function(e){e.MEMFS=`MEMFS`,e.NODEFS=`NODEFS`,e.NODERAWFS=`NODERAWFS`,e.IDBFS=`IDBFS`,e.WORKERFS=`WORKERFS`,e.PROXYFS=`PROXYFS`})(l||={});const u=`0.12.10`,d=`@ffmpeg/core is not installed in node_modules: run \`${r} @ffmpeg/core@${u}\` (no network fallback)`,f=`@ffmpeg/core-mt`,p=`@ffmpeg/core-mt is not installed in node_modules (FFMPEG_CORE=mt asked for the multi-threaded core): run \`${r} ${f}@${u}\`, or unset FFMPEG_CORE and run \`${r} @ffmpeg/core@${u}\` (no network fallback)`;function m(){return globalThis.crossOriginIsolated===!0}function h(e=!1){return e&&m()?p:d}function g(e,t=m(),n=typeof navigator<`u`?navigator.hardwareConcurrency:void 0){let i=`${e.pkg} ${u}`;return e.pkg===`@ffmpeg/core-mt`?`${i} (multi-threaded${typeof n==`number`&&n>0?`, ${n} threads`:``}; single-input jobs only)`:t?`${i} (single-threaded; the multi-threaded core is opt-in on this isolated runtime: \`${r} ${f}@${u}\` then FFMPEG_CORE=mt, single-input jobs only)`:`${i} (single-threaded; runtime is not cross-origin isolated)`}const _=[`dist/esm`];async function v(e,t,n){for(let r of _){let i=`${e}/${r}`,a={core:`${i}/ffmpeg-core.js`,wasm:`${i}/ffmpeg-core.wasm`,worker:t===`@ffmpeg/core-mt`?`${i}/ffmpeg-core.worker.js`:null};if(await n.exists(a.core)&&await n.exists(a.wasm)&&!(a.worker&&!await n.exists(a.worker)))return a}return null}let y=null,b=null,x=[],S=null;function C(){return S}function w(e){for(let t of e)try{URL.revokeObjectURL(t)}catch{}}async function T(e={}){return y||=E(e.onProgress,e.ipk,e.preferMt===!0).catch(e=>{throw y=null,e}),y}async function E(e,t,n){let r=e??(()=>{}),i=new c,a=await k(t,r,n),o=[a.coreURL,a.wasmURL,a.workerURL,a.classWorkerURL].filter(e=>typeof e==`string`);r(`initializing ffmpeg-core...`);try{await i.load({coreURL:a.coreURL,wasmURL:a.wasmURL,...a.workerURL?{workerURL:a.workerURL}:{},...a.classWorkerURL?{classWorkerURL:a.classWorkerURL}:{}})}catch(e){throw w(o),e}return r(`ffmpeg ready`),b=i,x=o,S=a.pkg,i}async function D(n,r,i=!1){if(r===void 0)return O(n,i&&m());let a;try{a=await t(`${r}/package.json`,n.fromDir,n.reader)}catch{return null}if(a.type!==`file`)return null;let o=await v(e(a.path).dir,r,n.reader);if(!o)return null;try{let e=await n.reader.readFile(o.core),t=await n.readBytes(o.wasm),i=o.worker?await n.reader.readFile(o.worker):void 0;return{pkg:r,coreSource:e,wasmBytes:t,...i===void 0?{}:{workerSource:i}}}catch{return null}}async function O(e,t){if(t){let t=await D(e,f);if(t)return t}return D(e,`@ffmpeg/core`)}async function k(e,t,r){if(n())throw Error(`ffmpeg-wasm is not available in Node runtime`);let i=r&&m();if(!e)throw Error(h(i));let a=await O(e,i);if(!a)throw Error(h(i));t(`${a.pkg} loaded from ipk node_modules (js: ${a.coreSource.length} chars, wasm: ${a.wasmBytes.byteLength} bytes${a.workerSource?`, multi-threaded`:``})`);let o=A(a.wasmBytes,`application/wasm`);return{pkg:a.pkg,coreURL:j(a.coreSource,`text/javascript`),wasmURL:o,...a.workerSource===void 0?{}:{workerURL:j(a.workerSource,`text/javascript`)}}}function A(e,t){let n=new ArrayBuffer(e.byteLength);return new Uint8Array(n).set(e),URL.createObjectURL(new Blob([n],{type:t}))}function j(e,t){return URL.createObjectURL(new Blob([e],{type:t}))}function M(e){if(typeof WebAssembly<`u`&&e instanceof WebAssembly.RuntimeError||e instanceof RangeError)return!0;let t=e instanceof Error?e.message:String(e);return/RuntimeError|memory access out of bounds|unreachable|Aborted|out of memory|allocation failed|table index is out of bounds|function signature mismatch/i.test(t)}function N(e){if(e!==void 0&&b!==e)return;let t=b,n=x;if(y=null,b=null,x=[],S=null,t)try{t.terminate()}catch{}w(n)}export{T as a,N as c,h as i,D as l,f as n,M as o,g as r,C as s,u as t};
@@ -1,4 +1,4 @@
1
- import{t as e}from"./slugify-BYJ6QVAt.js";import{n as t,r as n,t as r}from"./archive-redaction-ByV7X5fs.js";import{t as i}from"./types-D8gIX-W-.js";import{i as a,r as o,y as s}from"./kernel-worker-Cp4UmRK8.js";const c=/\uD83C\uDF99\uFE0F?/g,l=/\u25C1[\s\S]*?\u25B7/g;function u(e){return e.replace(l,``).replace(c,``).replace(/[ \t]+$/g,``).trimEnd()}function d(e){let t=``;for(let n of e){let e=n.role===`user`?`User`:`Assistant`,r=n.role===`user`?u(n.content):n.content;if(t+=`## ${e}\n${r}\n\n`,n.attachments?.length&&(t+=`Attachments:\n${n.attachments.map(e=>`- ${s(e)}`).join(`
1
+ import{t as e}from"./slugify-BYJ6QVAt.js";import{n as t,r as n,t as r}from"./archive-redaction-ByV7X5fs.js";import{t as i}from"./types-D8gIX-W-.js";import{i as a,r as o,y as s}from"./kernel-worker-YhNfUQ_y.js";const c=/\uD83C\uDF99\uFE0F?/g,l=/\u25C1[\s\S]*?\u25B7/g;function u(e){return e.replace(l,``).replace(c,``).replace(/[ \t]+$/g,``).trimEnd()}function d(e){let t=``;for(let n of e){let e=n.role===`user`?`User`:`Assistant`,r=n.role===`user`?u(n.content):n.content;if(t+=`## ${e}\n${r}\n\n`,n.attachments?.length&&(t+=`Attachments:\n${n.attachments.map(e=>`- ${s(e)}`).join(`
2
2
  `)}\n\n`),n.toolCalls)for(let e of n.toolCalls)t+=`### Tool: ${e.name}\nInput: ${JSON.stringify(e.input,null,2)}\nResult: ${e.result??``}\n\n`}return t}function f(e){return`live-${h(e)}-${m()}.md`}function p(e,t){return e.find(e=>e.live===!0&&(e.cone??`cone`)===t)}function m(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`}function h(t){return e(t,{maxLen:48,fallback:`session`})}const g=`untitled-session`,_=RegExp(`^(?:_Forwarded from .+?\\._\\s*)*(?:\\[@\\S+ (?:completed|idle|sudo-request|FAILED)\\b|\\[scoop_wait\\b|\\[(?:${[`Webhook Event`,`Sprinkle Event`,`File Watch Event`,`Session Reload`,`Navigate Event`,`Upgrade Event`,`Cherry Event`,`Workflow Event`,`Background Command`,`jshd Unit`,`Cron Event`,`Scoop Access Request`,`Preview Event`,`Preview event`,`Discovery Event`].join(`|`)})\\b|Preview tab (?:connected|disconnected) from |<context-summary\\b)`);function v(e){return e.slice(0,480).trim().replace(/\s+/g,` `).slice(0,240)}function y(e){let t=v(e);return t.length>0&&_.test(t)}function b(e){return e===g||y(e)}function x(e){return e.role!==`user`||!e.content?.trim()||e.source===`lick`||e.channel?!1:!y(e.content)}function S(e){let t=e.find(x);if(!t?.content)return g;let n=t.content.trim().replace(/\s+/g,` `);return n.length>60?`${n.slice(0,60)}…`:n||g}function C(e){return e.map(e=>{let t={id:e.id,role:e.role,content:e.content,timestamp:e.timestamp};return e.attachments?.length&&(t.attachments=e.attachments),e.toolCalls?.length&&(t.toolCalls=e.toolCalls.map(e=>({id:e.id,name:e.name,input:e.input,...e.result===void 0?{}:{result:e.result},...e.isError?{isError:e.isError}:{}}))),e.source&&(t.source=e.source),e.channel&&(t.channel=e.channel),e.compaction&&(t.compaction=e.compaction),t})}function w(e){let i=r(),a={...e,title:t(e.title,i),messages:n(e.messages,i)},o=(a.cost?`cost: ${JSON.stringify(a.cost)}\n`:``)+(a.models?`models: ${JSON.stringify(a.models)}\n`:``),s=(a.cone?`cone: ${a.cone}\n`:``)+(a.coneLabel?`coneLabel: ${JSON.stringify(a.coneLabel)}\n`:``)+(a.memorySkipped?`memorySkipped: true
3
3
  `:``)+(a.live?`live: true
4
4
  `:``)+(a.live&&a.liveThrough?`liveThrough: ${a.liveThrough}\n`:``)+(a.live&&a.compactions?`compactions: ${a.compactions}\n`:``)+(a.curatedThrough?`curatedThrough: ${a.curatedThrough}\n`:``),c=`---\nid: ${a.id}\ntitle: ${JSON.stringify(a.title)}\nfrozenAt: ${a.frozenAt}\ncreatedAt: ${a.createdAt}\nupdatedAt: ${a.updatedAt}\nmessageCount: ${a.messageCount}\n`+o+s+`---
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{a as n,i as r,n as i,r as a,t as o}from"./path-utils-DNJG-zQf.js";import{n as s,t as c}from"./types-D8gIX-W-.js";import{i as l,r as u,t as d}from"./mount-index-CQfmUPuZ.js";import{a as f,i as p,n as m,t as h}from"./mount-table-store-DrF_Ifaz.js";import{n as g,t as _}from"./virtual-device-paths-CS5o4QVz.js";import{t as v}from"./same-file-identity-DuEcSmPX.js";import{a as y,i as b,o as x,r as S}from"./sidecar-repair-BTU4PjlG.js";import{t as C}from"./stat-identity-BaU9yoai.js";function w(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function T(e,t){try{return await e(t)}catch{return t}}async function*E(e,t,n,r=0){let a=i(t);if(w(e.mountPoints,e.mountIndex,a)){let t=e.mountIndex.getFiles(a);if(t){for(let e of t)yield e;return}}let o=n??new Set;if(r>64||o.size>=1e5)return;let s=await T(t=>e.realpath(t),a);if(o.has(s))return;o.add(s);let c=await e.readDir(a);for(let t of c)yield*D(e,t,a===`/`?`/${t.name}`:`${a}/${t.name}`,o,r+1)}async function*D(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*O(e,n,r,i);return}yield*E(e,n,r,i)}async function*O(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*E(e,t,n,r))}catch{}}const k=t(`fs-watcher`);let A=0;function ee(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var j=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++A}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),k.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),k.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>ee(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){k.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),k.debug(`All watchers disposed`)}get size(){return this.registrations.size}};const M=new TextEncoder,N=new TextDecoder(`utf-8`,{fatal:!1});var P=class{entries=new Map;static handles(e){return g(i(e))}has(e){return this.entries.has(i(e))}write(e,t){let n=i(e),r=typeof t==`string`?M.encode(t):new Uint8Array(t),a=Date.now(),o=this.entries.get(n);this.entries.set(n,{bytes:r,mtime:a,ctime:o?.ctime??a})}append(e,t){let n=this.entries.get(i(e))?.bytes??new Uint8Array,r=typeof t==`string`?M.encode(t):t,a=new Uint8Array(n.length+r.length);a.set(n),a.set(r,n.length),this.write(e,a)}read(e,t){let n=this.require(e);return(t?.encoding??`utf-8`)===`utf-8`?N.decode(n.bytes):new Uint8Array(n.bytes)}readText(e){return N.decode(this.require(e).bytes)}stat(e){let t=this.require(e);return{type:`file`,size:t.bytes.length,mtime:t.mtime,ctime:t.ctime}}remove(e){return this.entries.delete(i(e))}require(e){let t=i(e),n=this.entries.get(t);if(!n)throw new c(`ENOENT`,`no such file or directory`,t);return n}};const F={[_]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},I=[`/tmp/`];var L=class{ephemeralFds=new P;vfs;allowedPrefixes;readOnlyPrefixes;readGrantPatterns=[];writeEnforcement;includeMounts;constructor(e,t,n=[],r=`hard`,a={}){this.vfs=e;let o=e=>{let t=i(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(o),this.readOnlyPrefixes=n.map(o),this.writeEnforcement=r,this.includeMounts=a.includeMounts!==!1}getAllPrefixes(){let e=this.includeMounts?this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`):[];return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e,...I]}setReadGrants(e){this.readGrantPatterns=[];for(let t of new Set(e))this.addReadGrant(t)}addReadGrant(e){let t=e.split(`/`),n=[];for(let e=1;e<t.length;e++)n.push(a(t.slice(0,e).join(`/`)||`/`));this.readGrantPatterns.push({pattern:e,regex:a(e),ancestorRegexes:n})}matchesReadGrant(e){return this.readGrantPatterns.some(t=>t.regex.test(e))}leadsToReadGrant(e){return this.readGrantPatterns.some(t=>t.ancestorRegexes.some(t=>t.test(e)))}isAllowed(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||this.leadsToReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=i(e);return[...this.allowedPrefixes,...I].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return P.handles(e)||this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new c(`EACCES`,`permission denied`,i(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new c(`EACCES`,`permission denied`,i(e));return t}catch(t){throw t instanceof c?t:new c(`EACCES`,`permission denied`,i(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),n=this.vfs.basename(e),r;try{r=await this.vfs.realpath(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e;return}let a=r+`/`+n;if(this.isWritable(a))return;let o=i(r)!==i(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new c(`EACCES`,`permission denied`,i(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency()}async flush(){await this.vfs.flush()}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let n=F[i(e)];if(n)return n.read(t);if(P.handles(e))return this.ephemeralFds.read(e,t);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFile(r,t)}async readFileRange(e,t,n){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFileRange(r,t,n)}async getNativeFile(e){if(F[i(e)]||P.handles(e)||!this.isAllowedStrict(e))return null;try{let t=await this.resolveAndCheckRead(e);return await this.vfs.getNativeFile(t)}catch{return null}}async readDir(e,t){if(!this.isAllowed(e))return[];let n=e;if(this.isAllowedStrict(e))try{n=await this.resolveAndCheckRead(e)}catch{return[]}let r=await this.vfs.readDir(n,t);if(!this.isAllowedStrict(e)){let t=i(e);return r.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return r}async stat(e){let t=F[i(e)];if(t)return t.stat();if(P.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=i(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),a=t?r.length:r.length-1,o=``;for(let e=0;e<a;e++){o=o+`/`+r[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=F[i(e)];return t?t.stat():P.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=F[i(e)];return t?t.stat():P.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=i(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){if(P.handles(e)){let t=i(e);if(!this.ephemeralFds.has(t))throw new c(`ENOENT`,`no such file or directory`,t);return t}let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async exists(e){if(F[i(e)])return!0;if(P.handles(e))return this.ephemeralFds.has(e);if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=F[i(e)];if(t)return t.readText();if(P.handles(e))return this.ephemeralFds.readText(e);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(n)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){let r=F[i(e)];if(r){r.write(t);return}if(P.handles(e)){this.ephemeralFds.write(e,t);return}return await this.checkContentWrite(e),this.vfs.writeFile(e,t,n)}async appendFile(e,t){let n=F[i(e)];if(n){n.write(t);return}if(P.handles(e)){this.ephemeralFds.append(e,t);return}return await this.checkContentWrite(e),this.vfs.appendFile(e,t)}async chmod(e,t){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.chmod(e,t)}async utimes(e,t,n){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.utimes(e,t,n)}async checkContentWrite(e){this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}}refuseDescriptorTreeOp(e){if(P.handles(e))throw new c(`EACCES`,`permission denied`,i(e))}async mkdir(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){if(P.handles(e)){if(!this.ephemeralFds.remove(e))throw new c(`ENOENT`,`no such file or directory`,i(e));return}this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.refuseDescriptorTreeOp(e),this.refuseDescriptorTreeOp(t),this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(P.handles(e)){let n=this.ephemeralFds.read(e,{encoding:`binary`});await this.writeFile(t,n);return}if(P.handles(t)){if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);this.ephemeralFds.write(t,await this.vfs.readFile(n,{encoding:`binary`}));return}if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){return this.refuseDescriptorTreeOp(t),this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let t=await this.vfs.readlink(e),n;if(t.startsWith(`/`))n=i(t);else{let r=this.vfs.dirname(e);n=i(r+`/`+t)}if(!this.isAllowedStrict(n))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async lstat(e){let t=F[i(e)];if(t)return t.stat();if(P.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=i(e),r=this.vfs.dirname(n),a=this.vfs.basename(n),o;if(r===n)o=r;else try{o=await this.vfs.realpath(r)}catch{throw new c(`ENOENT`,`no such file or directory`,n)}let s=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(s))throw new c(`ENOENT`,`no such file or directory`,n);return this.vfs.lstat(s)}watch(e,t,n){if(!this.isAllowed(e))throw new c(`EACCES`,`permission denied`,i(e));let r=this.vfs.getWatcher();if(!r)throw new c(`EINVAL`,`no watcher configured`);return r.watch(i(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){let e=this.vfs.listMounts();return this.includeMounts?e:e.filter(e=>this.isAllowedStrict(e))}listMountPoints(){let e=this.vfs.listMountPoints();return this.includeMounts?e:e.filter(e=>this.isAllowed(e.path))}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function R(e,t){if(e instanceof c){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new c(e.code,r,t)}throw e}const z=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`ENOSYS`,`EOPNOTSUPP`,`EXDEV`,`EIO`];function B(e,t){if(e instanceof c)return e;{let n=e instanceof Error?e.message:String(e);if(n.includes(`maximum size exceeded`)||n.includes(`call stack size exceeded`))return new c(`EIO`,`internal overflow, not storage: ${n} — reload the session`,t)}let n=e?.code;if(typeof n==`string`){let r=n;if(z.includes(r)){let n=e instanceof Error?e.message:String(e);return n.startsWith(`${r}: `)&&(n=n.slice(r.length+2),n=n.replace(/, undefined( '[^']*')?$/,``).replace(/ '[^']*'$/,``)),new c(r,n||r,t)}}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new c(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new c(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new c(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new c(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new c(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new c(`ELOOP`,`too many levels of symbolic links`,t):r.includes(`EOPNOTSUPP`)||r.includes(`ENOTSUP`)?new c(`EOPNOTSUPP`,`operation not supported`,t):r.includes(`EXDEV`)?new c(`EXDEV`,`cross-device link`,t):new c(`EINVAL`,r,t)}function V(e){return e===void 0?`absent`:(e&61440)==16384?`directory`:`file`}function H(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function U(e){let t=e?.mode;return typeof t==`number`?t:void 0}function W(e,t,n,r=new Set){let i=new Set(n);if(r.size>0){for(let t of Object.keys(e.entries??{}))for(let e of r)if(t===e||t.startsWith(`${e}/`)){i.add(t);break}}let a=[];for(let n of i){let r=e.entries?.[n],i=t.entries?.[n];if(!r||!i)continue;let o=V(U(r));o!==V(U(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}async function G(e,t){let n=t.split(`/`).filter(Boolean),r=n.pop();if(r===void 0)return null;try{let t=e;for(let e of n)t=await t.getDirectoryHandle(e);return await(await t.getFileHandle(r)).getFile()}catch{return null}}async function K(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=B(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function q(e,t,r){let a;try{a=await e.readlink(t)}catch(e){throw B(e,r)}return a.startsWith(`/`)?i(a):i(o(n(t).dir,a))}async function J(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await K(e,o,r,i);if(t===null||!t.isSymbolicLink())return{resolved:o,hops:a};if(++a>10)throw new c(`ELOOP`,`too many symbolic links encountered`,i);o=await q(e,o,i)}}async function Y(e,t,n){let r=i(n);if(t(r))return r;let a=r.split(`/`).filter(Boolean),o=`/`,s=0;for(let t=0;t<a.length;t++){let n=await J(e,o,a[t],t===a.length-1,r,s);o=n.resolved,s=n.hops}return o}async function X(e,t,n){return t(n)?n:Y(e,t,n)}function Z(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}function Q(e,t){let n=e.kind===`directory`?`directory`:`file`;return t?{name:e.name,type:n,...e.size===void 0?{}:{size:e.size},...e.lastModified===void 0?{}:{mtime:e.lastModified},...e.ctime===void 0?{}:{ctime:e.ctime},...e.ino===void 0?{}:{ino:e.ino},...e.identity===void 0?{}:{identity:e.identity},...e.dev===void 0?{}:{dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},...e.mode===void 0?{}:{mode:e.mode}}:{name:e.name,type:n}}function te(e,t){switch(e.kind){case`local`:case`proc`:return{kind:`local`,mountId:e.mountId,idbHandleKey:t};case`hostfs`:return{kind:`hostfs`,mountId:e.mountId,hostPath:e.getHostPath()};default:return{kind:e.kind===`s3`?`s3`:e.kind===`aem`?`aem`:`da`,mountId:e.mountId,source:e.source,profile:e.profile??`default`}}}var $=class e{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new d;static writeChains=new Map;onRepairProgress;constructor(t,n,r,i,a,o){if(this.dbName=t,this.onRepairProgress=a,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?e.initOpfsBackend(this,i,n===!0,o):e.initMemoryBackend(this,t,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${t}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r,n).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static opfsInitChains=new Map;static async initOpfsBackend(t,n,r,i){let a=(e.opfsInitChains.get(t.dbName)??Promise.resolve()).catch(()=>{}).then(()=>e.resolveOpfsBackend(t,n,r,i));e.opfsInitChains.set(t.dbName,a);try{await a}finally{e.opfsInitChains.get(t.dbName)===a&&e.opfsInitChains.delete(t.dbName)}}static async resolveOpfsBackend(t,n,r,i){let a=e.opfsBackends.get(t.dbName);if(a&&r)throw new c(`EBUSY`,`Cannot wipe an OPFS backend with live holders`,t.dbName);if(a&&i!==void 0&&a.asyncCache!==i)throw new c(`EBUSY`,`OPFS async cache setting conflicts with the live backend`,t.dbName);let o=n??await e.acquireOpfsHandle(t.dbName,r);await t.withWriteLock(()=>e.seedOpfsMetadataSidecarIfMissing(o));let s=await import(`./dist-SZE428w3.js`);await e.ensureRootMount(s);let l=`/__opfs__/${t.dbName}`,u=e.opfsBackends.get(t.dbName);if(!u){let{resolveOpfsMount:n}=await import(`./opfs-mount-DbDiMdyl.js`),r=await n({handle:o,dbName:t.dbName,asyncCache:i,onRepairProgress:t.onRepairProgress,withWriteLock:e=>t.withWriteLock(e)});try{s.mount(l,r)}catch{}u={backendFs:r,refs:0,asyncCache:i!==!1,sidecarDirty:{paths:new Set,prefixes:new Set}},e.opfsBackends.set(t.dbName,u)}u.refs+=1,t.opfsBackendFs=u.backendFs.index?u.backendFs:null,t.opfsHandle=o,t.mountRoot=l,t.rawLfs=s.promises,t.rawLfsSync=s}static async initMemoryBackend(t,n,r){let i=await import(`./dist-SZE428w3.js`);await e.ensureRootMount(i);let a=`/__zenfs__/${n}`,o=e.memoryBackends.get(n);if(o&&r){try{i.umount(a)}catch{}e.memoryBackends.delete(n),o=void 0}o||(o={store:i.InMemory.create({label:n}),refs:0},e.memoryBackends.set(n,o)),o.refs+=1;try{i.mount(a,o.store)}catch{}t.mountRoot=a,t.rawLfs=i.promises,t.rawLfsSync=i,t.opfsBackendFs=null,t.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(t){return e.rootMountReady===null&&(e.rootMountReady=(async()=>{await t.configureSingle({backend:t.InMemory,label:`__vfs_root__`})})()),e.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),appendFile:async(t,r)=>{this._readyResolved||await this._ready,await n().appendFile(e(t),r)},chmod:async(t,r)=>{this._readyResolved||await this._ready,await n().chmod(e(t),r)},utimes:async(t,r,i)=>{this._readyResolved||await this._ready,await n().utimes(e(t),r,i)},readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(t){let n=`.metadata.json`;try{let r=await t.getFileHandle(n);if(e.isUsableMetadataDocument(await e.readSidecarText(r)))return;console.warn(`[virtual-fs] metadata sidecar is unparseable (torn write?); reseeding an empty index`)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await(await t.getFileHandle(n,{create:!0})).createWritable(),i=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await r.write(i),await r.close()}static async readSidecarText(e){let t;for(let n=0;n<3;n++)try{return await(await e.getFile()).text()}catch(e){if(e?.name!==`NotReadableError`)throw e;t=e}throw t}static isUsableMetadataDocument(e){let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=t.entries;return!!n&&typeof n==`object`}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new c(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(t){return new e(t)}static async create(t){let n=t?.dbName??`browser-fs`,r=t?.wipe===!0,i=t?.backend??Z(),a=new e(n,r,i,void 0,t?.onRepairProgress,t?.opfsAsyncCache);try{await a._ready}catch(e){throw a.mountSyncChannel?.close(),e}return r&&await h().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){this.backend===`opfs`&&await this.withWriteLock(()=>this.writeOpfsMetadataSidecarUnlocked())}async writeOpfsMetadataSidecarUnlocked(){if(this.backend!==`opfs`)return;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t||!n)return;let r=t.index.toJSON(),i=e.opfsBackends.get(this.dbName)?.sidecarDirty,a=r;if(i){let e=null;try{let t=await n.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());r&&typeof r==`object`&&r.entries&&(e=r)}catch{}e&&(await this.auditDirtyKindFlips(r,e,i,n),a=y(e,r,i))}let o=JSON.stringify(x(a)),s=await(await n.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await s.write(o),await s.close(),i&&(i.paths.clear(),i.prefixes.clear())}async auditDirtyKindFlips(e,t,n,r){let i=W(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=b(r),o=this.opfsBackendFs;for(let n of i){let r=await a(n.path).catch(()=>null);if(r!==null&&r.kind!==`missing`&&r.kind===`directory`===n.ownIsDirectory)continue;let i=t.entries?.[n.path];e.entries&&i!==void 0&&(e.entries[n.path]=i);let s=r!==null&&r.kind!==`missing`;s&&(o?.index?.delete(n.path),o?._handles?.delete(n.path)),console.warn(`[virtual-fs] refused to flush in-memory kind flip over sidecar record (#2006)`,{path:n.path,reality:r?.kind??`unverifiable`,evicted:s})}}markSidecarDirty(t,r=`path`){if(this.backend!==`opfs`)return;let a=e.opfsBackends.get(this.dbName)?.sidecarDirty;if(!a)return;let o=i(t);(r===`prefix`?a.prefixes:a.paths).add(o);let{dir:s}=n(o);for(;s!==`/`;)a.paths.add(s),s=n(s).dir}async forgetSidecarConsistency(){await this.dropSidecarConsistency()}sidecarConsistencyDrop=null;dropSidecarConsistency(){if(this.backend!==`opfs`||!this.opfsHandle)return Promise.resolve();if(!this.sidecarConsistencyDrop){let e=this.opfsHandle;this.sidecarConsistencyDrop=S(e).catch(e=>{throw this.sidecarConsistencyDrop=null,e})}return this.sidecarConsistencyDrop}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;e.length>0&&this.dropSidecarConsistency().catch(()=>void 0);let t=this.opfsBackendFs;for(let n of e){let e=i(n);t.index.delete(e),t._handles?.delete(e),this.markSidecarDirty(e)}}async withKindMismatchRetry(e,t){return this.withKindMismatchRetryPaths([e],t)}async withKindMismatchRetryPaths(e,t){try{return await t()}catch(n){let r=n?.code;if(r!==`EISDIR`&&r!==`ENOTDIR`&&r!==`EINVAL`)throw n;for(let n of e)if(await this.reconcileKindMismatch(n).catch(()=>!1))return await t();throw n}}async reconcileKindMismatch(e){if(this.backend!==`opfs`)return!1;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t?.index||!n)return!1;let r=i(e),a=r;try{a=await this.resolveSymlinks(r)}catch{}let o=await b(n)(a),s=V(t.index.get(a)?.mode),c=t._handles?.get(a),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=H(o,s),d=H(o,l);if(!u&&!d)return!1;if(t.index.delete(a),t._handles?.delete(a),s===`directory`||l===`directory`){let e=`${a}/`;for(let n of[...t.index.keys()])n.startsWith(e)&&t.index.delete(n);if(t._handles)for(let n of[...t._handles.keys()])n.startsWith(e)&&t._handles.delete(n)}return this.markSidecarDirty(a),console.warn(`[virtual-fs] reconciled in-memory kind mismatch (#2006)`,{path:a,reality:o.kind,indexHeld:s,handleHeld:l}),!0}localIdentity(e){return C(`zenfs:${this.backend}:${this.dbName}`,e)}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async watch(e,t){let n=this.watcher;if(!n)throw new c(`ENOSYS`,`no FsWatcher attached to this VirtualFS`);let r=e.map(e=>n.watch(e,()=>!0,t));return()=>{for(let e of r)e()}}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let t=this.backend===`opfs`?e.opfsBackends:e.memoryBackends,n=t.get(this.dbName);if(n&&(--n.refs,n.refs<=0)){t.delete(this.dbName);try{(await import(`./dist-SZE428w3.js`)).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push(a===`symlink`?{name:i,type:a}:{name:i,type:a,size:t.size,mtime:t.mtimeMs,ctime:t.ctimeMs,...t.ino===void 0?{}:{ino:t.ino,identity:this.localIdentity(t.ino),dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},mode:t.mode})}catch{}}return r}catch{return null}}statSync(e){let t=i(e);if(this.findMount(t))return null;let r=this.lfsSync;if(typeof r.statSync!=`function`||typeof r.lstatSync!=`function`||typeof r.readlinkSync!=`function`)return null;if(t===`/`)try{let e=r.statSync(t);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}let a=t;for(let e=0;e<=10;e++){let e;try{e=r.lstatSync(a)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode};let t;try{t=r.readlinkSync(a)}catch{return null}a=t.startsWith(`/`)?i(t):i(o(n(a).dir,t))}return null}lstatSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;if(t===`/`)return this.statSync(t);try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}}async mount(e,t,r){let a=i(e);if(this.mountPoints.has(a))throw new c(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new c(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new c(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof c)||e.code!==`ENOENT`)throw e}let{dir:o}=n(a);o!==`/`&&await this.mkdir(o,{recursive:!0}),await this.dropSidecarConsistency();try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=r?.limits??u(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let s=te(t,a);try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:s})}catch{}if(this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]),t.kind!==`hostfs`)try{let e={targetPath:a,descriptor:s,createdAt:Date.now()},n=t.kind===`local`?t.getHandle():void 0;await f(e,n)}catch{}}async unmount(e){let t=i(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await p(t)}catch{}}async reconstructBackendFromDescriptor(e,t){switch(e.kind){case`local`:{let t=await m(e.idbHandleKey);if(!t)throw Error(`no handle stored for ${e.idbHandleKey}`);return l.fromHandle(t,{mountId:e.mountId})}case`hostfs`:{let{HostFsMountBackend:n}=await import(`./backend-hostfs-CMj5JyW-.js`);return new n({targetPath:t,hostPath:e.hostPath,mountId:e.mountId})}case`s3`:{let{S3MountBackend:t,RemoteMountCache:n,makeSignedFetchS3:r}=await import(`./mount-CbM_5jlW.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r(e.profile)})}case`da`:{let{DaMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-CbM_5jlW.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}case`aem`:{let{AemMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-CbM_5jlW.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}getMountBackend(e){let t=i(e);return this.mountPoints.get(t)??null}async mountInternal(e,t){let r=i(e);if(this.mountPoints.has(r))throw new c(`EEXIST`,`mount point is already mounted`,r);let{dir:a}=n(r);a!==`/`&&await this.mkdir(a,{recursive:!0}),await this.dropSidecarConsistency();try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=i(e);if(!this.internalMounts.has(t))throw new c(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=i(e),r=this.mountPoints.get(n);if(!r)throw new c(`ENOENT`,`not a mount point`,n);let a=await r.refresh(t);return r.kind===`local`&&await this.mountIndex.refreshMount(n,u(t?.env??{})),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}]),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){return this.withKindMismatchRetry(e,()=>this.readFileInner(e,t))}async readFileInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EISDIR`,`is a directory`,n);let e=r.relParts.join(`/`);try{let n=await r.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){R(e,n)}}let a=await this.resolveSymlinks(n);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw B(e,n)}}async readFileRange(e,t,n){let r=i(e);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<t)throw new c(`EINVAL`,`invalid byte range ${t}-${n}`,r);if(t===n)return new Uint8Array;let a=this.findMount(r),o=a?.backend.readFileRange;if(a&&o){if(a.relParts.length===0)throw new c(`EISDIR`,`is a directory`,r);try{return await o.call(a.backend,a.relParts.join(`/`),t,n)}catch(e){R(e,r)}}let s=await this.sliceNativeFile(r,t,n);if(s)return s;let l=await this.readFile(r,{encoding:`binary`});return new Uint8Array(l.subarray(t,Math.min(n,l.byteLength)))}async sliceNativeFile(e,t,n){try{let r=await this.getNativeFile(e);if(!r)return null;let i=r.slice(t,Math.min(n,r.size));return new Uint8Array(await i.arrayBuffer())}catch{return null}}async getNativeFile(e){let t=i(e),n=this.findMount(t);if(n){let e=n.backend.getNativeFile;if(!e||n.relParts.length===0)return null;try{return await e.call(n.backend,n.relParts.join(`/`))}catch{return null}}let r=this.opfsHandle;if(!r)return null;try{return await G(r,await this.resolveSymlinks(t))}catch{return null}}async writeFile(e,t,n){return this.withKindMismatchRetry(e,()=>this.writeFileInner(e,t,n))}async writeFileInner(e,t,r){let a=i(e),o=this.findMount(a);if(o){if(o.relParts.length===0)throw new c(`EISDIR`,`is a directory`,a);let e=o.relParts.join(`/`),n=!1;try{await this.stat(a),n=!0}catch{}let r=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await o.backend.writeFile(e,r)}catch(e){R(e,a)}this.watcher?.notify([{type:n?`modify`:`create`,path:a,entryType:`file`}]),this.mountIndex.notifyWrite(a);return}let s;try{s=await this.resolveSymlinks(a)}catch{s=a}let l=!1;try{await this.lfs.stat(s),l=!0}catch{}let{dir:u}=n(s);await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),this.markSidecarDirty(s),u!==`/`&&await this.mkdirRecursiveUnlocked(u);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(s,t)}catch(e){if(u!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(u);try{await this.lfs.writeFile(s,t)}catch(e){throw B(e,a)}}else throw B(e,a)}try{await this.lfs.truncate?.(s,e)}catch(e){throw B(e,a)}}),this.watcher?.notify([{type:l?`modify`:`create`,path:s,entryType:`file`}])}async appendFile(e,t){let r=i(e);await this.withKindMismatchRetry(r,()=>this.withWriteLock(async()=>{if(this.findMount(r)){await this.appendMounted(r,t);return}await this.dropSidecarConsistency();let e=r,i=!1;try{if(e=await this.resolveSymlinks(r),(await this.lfs.stat(e)).isDirectory())throw new c(`EISDIR`,`is a directory`,r);i=!0}catch(e){let t=B(e,r);if(t.code!==`ENOENT`)throw t}this.markSidecarDirty(e);let{dir:a}=n(e);await this.mkdirRecursiveUnlocked(a);try{await this.lfs.appendFile(e,t)}catch(e){throw B(e,r)}this.watcher?.notify([{type:i?`modify`:`create`,path:e,entryType:`file`}])}))}async appendMounted(e,t){let n=new Uint8Array;try{let t=await this.readFileInner(e,{encoding:`binary`});n=typeof t==`string`?new TextEncoder().encode(t):new Uint8Array(t)}catch(t){let n=B(t,e);if(n.code!==`ENOENT`)throw n}let r=typeof t==`string`?new TextEncoder().encode(t):t,i=new Uint8Array(n.length+r.length);i.set(n),i.set(r,n.length),await this.writeFileInner(e,i)}async chmod(e,t){if(!Number.isInteger(t)||t<0||t>4095)throw new c(`EINVAL`,`invalid file mode`,i(e));await this.changeMetadata(e,e=>this.lfs.chmod(e,t))}async utimes(e,t,n){if(!Number.isFinite(t.getTime())||!Number.isFinite(n.getTime()))throw new c(`EINVAL`,`invalid file time`,i(e));await this.changeMetadata(e,e=>this.lfs.utimes(e,t,n))}async changeMetadata(e,t){let n=i(e);if(this.findMount(n))throw await this.stat(n),new c(`ENOSYS`,`metadata changes are not supported by this mount`,n);await this.withKindMismatchRetry(n,()=>this.withWriteLock(async()=>{await this.dropSidecarConsistency();let e=await this.resolveSymlinks(n);try{let n=await this.lfs.stat(e);this.markSidecarDirty(e),await t(e),await this.writeOpfsMetadataSidecarUnlocked(),this.watcher?.notify([{type:`modify`,path:e,entryType:n.isDirectory()?`directory`:`file`}])}catch(e){throw B(e,n)}}))}async readDir(e,t){let n=i(e),r=this.findMount(n);return r?this.readDirMounted(n,r,t):this.readDirLocal(n)}async readDirMounted(e,t,n){let r=n?.includeStats===!0?void 0:this.mountIndex.getDirectoryEntries(t.path,e);if(r!==void 0){let t=new Map;for(let e of r)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let i=t.relParts.join(`/`)||`/`,a;try{a=await t.backend.readDir(i,n)}catch(t){R(t,e)}let o=new Map,s=t.backend.listingStatsMatchStat===!0;for(let e of a)o.set(e.name,Q(e,s));return this.addNestedMountEntries(o,e),[...o.values()]}async readDirLocal(e){return this.withKindMismatchRetry(e,()=>this.readDirLocalInner(e))}async readDirLocalInner(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw B(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,...e.ino===void 0?{}:{ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},mode:e.mode}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(t){let n=this.dbName,r,i=new Promise(e=>{r=e}),a=e.writeChains.get(n)??Promise.resolve();e.writeChains.set(n,i),await a;try{let e=globalThis.navigator?.locks;return this.backend!==`opfs`||typeof e?.request!=`function`?await t():await e.request(`slicc-vfs:${n}`,()=>t())}finally{r(),e.writeChains.get(n)===i&&e.writeChains.delete(n)}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t){r+=`/`+e;try{await this.lfs.mkdir(r),n.push(r)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw B(e,r);try{let e=await this.lfs.lstat(r);if(!e.isDirectory()&&!e.isSymbolicLink())throw new c(`ENOTDIR`,`not a directory`,r)}catch(e){if(e instanceof c&&e.code===`ENOTDIR`)throw e}}}return n}async mkdir(e,t){let n=i(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){R(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}if(t?.recursive){let e=await this.withWriteLock(async()=>(await this.dropSidecarConsistency(),this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n)));e.length>0&&this.watcher?.notify(e.map(e=>({type:`create`,path:e,entryType:`directory`})))}else await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw B(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}])}async rm(e,t){return this.withKindMismatchRetry(i(e),()=>this.rmInner(e,t))}async rmInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EINVAL`,`cannot remove a mount point — use unmount`,n);let e;try{e=(await this.stat(n)).type}catch{}let i=r.relParts.join(`/`);try{await r.backend.remove(i,{recursive:t?.recursive})}catch(e){R(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:e}]),this.mountIndex.notifyDelete(n);return}try{let e=await this.lfs.lstat(n);await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),e.isSymbolicLink()?await this.lfs.unlink(n):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(n):await this.lfs.rmdir(n):await this.lfs.unlink(n),this.markSidecarDirty(n,`prefix`),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw B(e,n)}this.watcher?.notify([{type:`delete`,path:n}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){return this.withKindMismatchRetry(e,()=>this.statInner(e))}async statInner(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.ctime??t.mtime,...t.ino===void 0?{}:{ino:t.ino},...t.identity===void 0?{}:{identity:t.identity},...t.dev===void 0?{}:{dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},...t.mode===void 0?{}:{mode:t.mode}}}catch(e){R(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw B(e,t)}}async exists(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){return this.withKindMismatchRetryPaths([i(e),i(t)],()=>this.renameInner(e,t))}async renameInner(e,t){let n=i(e),r=i(t);if(n===r)return;let a;try{a=await this.lstat(n)}catch{}let o=a?.type,s=this.findMount(n);if(s?.backend.rename){let e=this.findMount(r);if(e&&e.backend===s.backend){let t=!1;try{t=(await s.backend.rename(s.relParts.join(`/`),e.relParts.join(`/`)))?.noop===!0}catch(e){R(e,n)}t||(this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r));return}}if(a)try{let e=await this.lstat(r);if(v(a,e))return}catch{}try{await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),this.markSidecarDirty(n,`prefix`),this.markSidecarDirty(r,`prefix`),await this.lfs.rename(n,r),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw B(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*E({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){let n=await this.stat(e);if(n.type===`directory`)throw new c(`EISDIR`,`is a directory`,e);try{let e=await this.stat(t);if(v(n,e))return}catch{}let r=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,r)}dirname(e){return n(i(e)).dir}basename(e){return n(i(e)).base}resolveSymlinkTargetPath(e,t){return e.startsWith(`/`)?i(e):i(o(n(t).dir,e))}assertSymlinkCreateAllowed(e,t){if(this.findMount(t))throw new c(`EINVAL`,`symlinks not supported on mounted filesystems`,t);let n=this.resolveSymlinkTargetPath(e,t);if(this.findMount(n))throw new c(`EXDEV`,`cannot create a symlink across a mount boundary to '${n}'`,t)}async symlink(e,t){let r=i(t);this.assertSymlinkCreateAllowed(e,r);let{dir:a}=n(r);await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),a!==`/`&&await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(t){if(a!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(e){throw B(e,r)}}else throw B(t,r)}this.markSidecarDirty(r),await this.writeOpfsMetadataSidecarUnlocked()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=i(e);try{return await this.lfs.readlink(t)}catch(e){throw B(e,t)}}async lstat(e){let t=i(e);if(this.findMount(t)||t===`/`)return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw B(e,t)}}async realpath(e){return Y(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return X(this.lfs,e=>this.findMount(e)!==null,e)}},ne=e({FsError:()=>c,FsWatcher:()=>j,MountIndex:()=>d,RestrictedFS:()=>L,VirtualFS:()=>$,joinPath:()=>o,normalizePath:()=>i,pathSegments:()=>r,resolveVfsBackendFromEnv:()=>Z,sameFileIdentity:()=>v,splitPath:()=>n,statsFromDirEntry:()=>s});export{j as i,$ as n,L as r,ne as t};
1
+ import{n as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./logger-LESFN7Hj.js";import{a as n,i as r,n as i,r as a,t as o}from"./path-utils-DNJG-zQf.js";import{n as s,t as c}from"./types-D8gIX-W-.js";import{i as l,r as u,t as d}from"./mount-index-CQfmUPuZ.js";import{a as f,i as p,n as m,t as h}from"./mount-table-store-DrF_Ifaz.js";import{n as g,t as _}from"./virtual-device-paths-CS5o4QVz.js";import{t as v}from"./same-file-identity-DuEcSmPX.js";import{a as y,i as b,o as x,r as S}from"./sidecar-repair-BTU4PjlG.js";import{t as C}from"./stat-identity-BaU9yoai.js";function w(e,t,n){return e.size===0||!e.has(n)||!t.isReady(n)?!1:!Array.from(e.keys()).some(e=>e!==n&&e.startsWith(n+`/`))}async function T(e,t){try{return await e(t)}catch{return t}}async function*E(e,t,n,r=0){let a=i(t);if(w(e.mountPoints,e.mountIndex,a)){let t=e.mountIndex.getFiles(a);if(t){for(let e of t)yield e;return}}let o=n??new Set;if(r>64||o.size>=1e5)return;let s=await T(t=>e.realpath(t),a);if(o.has(s))return;o.add(s);let c=await e.readDir(a);for(let t of c)yield*D(e,t,a===`/`?`/${t.name}`:`${a}/${t.name}`,o,r+1)}async function*D(e,t,n,r,i){if(t.type===`file`){yield n;return}if(t.type===`symlink`){yield*O(e,n,r,i);return}yield*E(e,n,r,i)}async function*O(e,t,n,r){try{let i=await e.stat(t);i.type===`file`?yield t:i.type===`directory`&&(yield*E(e,t,n,r))}catch{}}const k=t(`fs-watcher`);let A=0;function ee(e,t){return t===`/`||e===t||e.startsWith(t+`/`)}var j=class{registrations=new Map;watch(e,t,n){let r=`fsw-${++A}`;return this.registrations.set(r,{id:r,basePath:e,filter:t,callback:n}),k.debug(`Watch registered`,{id:r,basePath:e}),()=>{this.registrations.delete(r),k.debug(`Watch unregistered`,{id:r})}}notify(e){if(e.length!==0)for(let[,t]of this.registrations){let n=e.filter(e=>ee(e.path,t.basePath)&&t.filter(e.path));if(n.length>0)try{t.callback(n)}catch(e){k.error(`Watch callback error`,{id:t.id,error:e instanceof Error?e.message:String(e)})}}}dispose(){this.registrations.clear(),k.debug(`All watchers disposed`)}get size(){return this.registrations.size}};const M=new TextEncoder,N=new TextDecoder(`utf-8`,{fatal:!1});var P=class{entries=new Map;static handles(e){return g(i(e))}has(e){return this.entries.has(i(e))}write(e,t){let n=i(e),r=typeof t==`string`?M.encode(t):new Uint8Array(t),a=Date.now(),o=this.entries.get(n);this.entries.set(n,{bytes:r,mtime:a,ctime:o?.ctime??a})}append(e,t){let n=this.entries.get(i(e))?.bytes??new Uint8Array,r=typeof t==`string`?M.encode(t):t,a=new Uint8Array(n.length+r.length);a.set(n),a.set(r,n.length),this.write(e,a)}read(e,t){let n=this.require(e);return(t?.encoding??`utf-8`)===`utf-8`?N.decode(n.bytes):new Uint8Array(n.bytes)}readText(e){return N.decode(this.require(e).bytes)}stat(e){let t=this.require(e);return{type:`file`,size:t.bytes.length,mtime:t.mtime,ctime:t.ctime}}remove(e){return this.entries.delete(i(e))}require(e){let t=i(e),n=this.entries.get(t);if(!n)throw new c(`ENOENT`,`no such file or directory`,t);return n}};const F={[_]:{stat:()=>({type:`file`,size:0,mtime:0,ctime:0}),read:e=>(e?.encoding??`utf-8`)===`utf-8`?``:new Uint8Array,readText:()=>``,write:()=>{}}},I=[`/tmp/`];var L=class{ephemeralFds=new P;vfs;allowedPrefixes;readOnlyPrefixes;readGrantPatterns=[];writeEnforcement;includeMounts;constructor(e,t,n=[],r=`hard`,a={}){this.vfs=e;let o=e=>{let t=i(e);return t.endsWith(`/`)?t:t+`/`};this.allowedPrefixes=t.map(o),this.readOnlyPrefixes=n.map(o),this.writeEnforcement=r,this.includeMounts=a.includeMounts!==!1}getAllPrefixes(){let e=this.includeMounts?this.vfs.listMounts().map(e=>e.endsWith(`/`)?e:e+`/`):[];return[...this.allowedPrefixes,...this.readOnlyPrefixes,...e,...I]}setReadGrants(e){this.readGrantPatterns=[];for(let t of new Set(e))this.addReadGrant(t)}addReadGrant(e){let t=e.split(`/`),n=[];for(let e=1;e<t.length;e++)n.push(a(t.slice(0,e).join(`/`)||`/`));this.readGrantPatterns.push({pattern:e,regex:a(e),ancestorRegexes:n})}matchesReadGrant(e){return this.readGrantPatterns.some(t=>t.regex.test(e))}leadsToReadGrant(e){return this.readGrantPatterns.some(t=>t.ancestorRegexes.some(t=>t.test(e)))}isAllowed(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||this.leadsToReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e)||t===`/`||e.startsWith(t+`/`))}isAllowedStrict(e){let t=i(e),n=this.getAllPrefixes();return this.matchesReadGrant(t)||n.some(e=>t===e.slice(0,-1)||t.startsWith(e))}isWritable(e){let t=i(e);return[...this.allowedPrefixes,...I].some(e=>t===e.slice(0,-1)||t.startsWith(e))}canWrite(e){return P.handles(e)||this.isWritable(e)}checkWrite(e){if(this.writeEnforcement!==`sudo-delegated`&&!this.isWritable(e))throw new c(`EACCES`,`permission denied`,i(e))}async resolveAndCheckRead(e){try{let t=await this.vfs.realpath(e);if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}}async resolveAndCheckWrite(e){try{let t=await this.vfs.realpath(e);if(!this.isWritable(t)&&!this.isSymlinkEscapeAllowed(t))throw new c(`EACCES`,`permission denied`,i(e));return t}catch(t){throw t instanceof c?t:new c(`EACCES`,`permission denied`,i(e))}}isSymlinkEscapeAllowed(e){return!1}async checkParentRealpathEscape(e){let t=this.vfs.dirname(e),n=this.vfs.basename(e),r;try{r=await this.vfs.realpath(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e;return}let a=r+`/`+n;if(this.isWritable(a))return;let o=i(r)!==i(t);if(!(this.writeEnforcement===`sudo-delegated`&&!o))throw new c(`EACCES`,`permission denied`,i(e))}getUnderlyingFS(){return this.vfs}invalidatePaths(e){this.vfs.invalidatePaths(e)}async forgetSidecarConsistency(){await this.vfs.forgetSidecarConsistency()}async flush(){await this.vfs.flush()}isPathUnderMount(e){return this.vfs.isPathUnderMount(e)}async readFile(e,t){let n=F[i(e)];if(n)return n.read(t);if(P.handles(e))return this.ephemeralFds.read(e,t);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFile(r,t)}async readFileRange(e,t,n){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let r=await this.resolveAndCheckRead(e);return this.vfs.readFileRange(r,t,n)}async getNativeFile(e){if(F[i(e)]||P.handles(e)||!this.isAllowedStrict(e))return null;try{let t=await this.resolveAndCheckRead(e);return await this.vfs.getNativeFile(t)}catch{return null}}async readDir(e,t){if(!this.isAllowed(e))return[];let n=e;if(this.isAllowedStrict(e))try{n=await this.resolveAndCheckRead(e)}catch{return[]}let r=await this.vfs.readDir(n,t);if(!this.isAllowedStrict(e)){let t=i(e);return r.filter(e=>{let n=t===`/`?`/${e.name}`:`${t}/${e.name}`;return this.isAllowed(n)})}return r}async stat(e){let t=F[i(e)];if(t)return t.stat();if(P.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));if(this.isAllowedStrict(e)){let t=await this.resolveAndCheckRead(e);return this.vfs.stat(t)}return this.vfs.stat(e)}scanPathForSymlinks(e,t){let n=i(e);if(n===`/`)return!1;let r=n.slice(1).split(`/`),a=t?r.length:r.length-1,o=``;for(let e=0;e<a;e++){o=o+`/`+r[e];let t=this.vfs.lstatSync(o);if(t===null)return null;if(t.type===`symlink`)return!0}return!1}statSync(e){let t=F[i(e)];return t?t.stat():P.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowedStrict(e)||this.scanPathForSymlinks(e,!0)!==!1?null:this.vfs.statSync(e)}lstatSync(e){let t=F[i(e)];return t?t.stat():P.handles(e)?this.ephemeralFds.has(e)?this.ephemeralFds.stat(e):null:!this.isAllowed(e)||this.scanPathForSymlinks(e,!1)!==!1?null:this.vfs.lstatSync(e)}readDirSync(e){if(!this.isAllowed(e)||this.scanPathForSymlinks(e,!0)!==!1)return null;let t=this.vfs.readDirSync(e);if(t===null)return null;if(this.isAllowedStrict(e))return t;let n=i(e);return t.filter(e=>{let t=n===`/`?`/${e.name}`:`${n}/${e.name}`;return this.isAllowed(t)})}async realpath(e){if(P.handles(e)){let t=i(e);if(!this.ephemeralFds.has(t))throw new c(`ENOENT`,`no such file or directory`,t);return t}let t;try{t=await this.vfs.realpath(e)}catch(t){throw t instanceof c?t:new c(`ENOENT`,`no such file or directory`,i(e))}if(!this.isAllowedStrict(t))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async exists(e){if(F[i(e)])return!0;if(P.handles(e))return this.ephemeralFds.has(e);if(!this.isAllowed(e))return!1;if(this.isAllowedStrict(e))try{await this.resolveAndCheckRead(e)}catch{return!1}return this.vfs.exists(e)}async readTextFile(e){let t=F[i(e)];if(t)return t.readText();if(P.handles(e))return this.ephemeralFds.readText(e);if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);return this.vfs.readTextFile(n)}async*walk(e){if(!this.isAllowed(e))return;let t=e;if(this.isAllowedStrict(e))try{t=await this.resolveAndCheckRead(e)}catch{return}for await(let e of this.vfs.walk(t))this.isAllowed(e)&&(yield e)}async writeFile(e,t,n){let r=F[i(e)];if(r){r.write(t);return}if(P.handles(e)){this.ephemeralFds.write(e,t);return}return await this.checkContentWrite(e),this.vfs.writeFile(e,t,n)}async appendFile(e,t){let n=F[i(e)];if(n){n.write(t);return}if(P.handles(e)){this.ephemeralFds.append(e,t);return}return await this.checkContentWrite(e),this.vfs.appendFile(e,t)}async chmod(e,t){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.chmod(e,t)}async utimes(e,t,n){return this.refuseDescriptorTreeOp(e),await this.checkContentWrite(e),this.vfs.utimes(e,t,n)}async checkContentWrite(e){this.checkWrite(e),await this.checkParentRealpathEscape(e);try{(await this.vfs.lstat(e)).type===`symlink`&&await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}}refuseDescriptorTreeOp(e){if(P.handles(e))throw new c(`EACCES`,`permission denied`,i(e))}async mkdir(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mkdir(e,t)}async rm(e,t){if(P.handles(e)){if(!this.ephemeralFds.remove(e))throw new c(`ENOENT`,`no such file or directory`,i(e));return}this.checkWrite(e);try{(await this.vfs.lstat(e)).type===`symlink`||await this.resolveAndCheckWrite(e)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.rm(e,t)}async rename(e,t){return this.refuseDescriptorTreeOp(e),this.refuseDescriptorTreeOp(t),this.checkWrite(e),this.checkWrite(t),await this.resolveAndCheckWrite(e),await this.checkParentRealpathEscape(t),this.vfs.rename(e,t)}async copyFile(e,t){if(P.handles(e)){let n=this.ephemeralFds.read(e,{encoding:`binary`});await this.writeFile(t,n);return}if(P.handles(t)){if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=await this.resolveAndCheckRead(e);this.ephemeralFds.write(t,await this.vfs.readFile(n,{encoding:`binary`}));return}if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));this.checkWrite(t);let n=await this.resolveAndCheckRead(e);await this.checkParentRealpathEscape(t);try{(await this.vfs.lstat(t)).type===`symlink`&&await this.resolveAndCheckWrite(t)}catch(e){if(e instanceof c&&e.code===`EACCES`)throw e}return this.vfs.copyFile(n,t)}async symlink(e,t){return this.refuseDescriptorTreeOp(t),this.checkWrite(t),await this.checkParentRealpathEscape(t),this.vfs.symlink(e,t)}async readlink(e){if(!this.isAllowedStrict(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let t=await this.vfs.readlink(e),n;if(t.startsWith(`/`))n=i(t);else{let r=this.vfs.dirname(e);n=i(r+`/`+t)}if(!this.isAllowedStrict(n))throw new c(`ENOENT`,`no such file or directory`,i(e));return t}async lstat(e){let t=F[i(e)];if(t)return t.stat();if(P.handles(e))return this.ephemeralFds.stat(e);if(!this.isAllowed(e))throw new c(`ENOENT`,`no such file or directory`,i(e));let n=i(e),r=this.vfs.dirname(n),a=this.vfs.basename(n),o;if(r===n)o=r;else try{o=await this.vfs.realpath(r)}catch{throw new c(`ENOENT`,`no such file or directory`,n)}let s=o===`/`?`/${a}`:`${o}/${a}`;if(!this.isAllowed(s))throw new c(`ENOENT`,`no such file or directory`,n);return this.vfs.lstat(s)}watch(e,t,n){if(!this.isAllowed(e))throw new c(`EACCES`,`permission denied`,i(e));let r=this.vfs.getWatcher();if(!r)throw new c(`EINVAL`,`no watcher configured`);return r.watch(i(e),t,n)}dirname(e){return this.vfs.dirname(e)}basename(e){return this.vfs.basename(e)}async mount(e,t,n){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.mount(e,t,n)}async unmount(e){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),await this.checkParentRealpathEscape(e),this.vfs.unmount(e)}listMounts(){let e=this.vfs.listMounts();return this.includeMounts?e:e.filter(e=>this.isAllowedStrict(e))}listMountPoints(){let e=this.vfs.listMountPoints();return this.includeMounts?e:e.filter(e=>this.isAllowed(e.path))}getMountIndex(){return this.vfs.getMountIndex()}async refreshMount(e,t){return this.refuseDescriptorTreeOp(e),this.checkWrite(e),this.vfs.refreshMount(e,t)}async dispose(){await this.vfs.dispose()}};function R(e,t){if(e instanceof c){let n=`${e.code}: `,r=e.message;throw r.startsWith(n)&&(r=r.slice(n.length)),e.path&&r.endsWith(` '${e.path}'`)&&(r=r.slice(0,r.length-` '${e.path}'`.length)),new c(e.code,r,t)}throw e}const z=[`ENOENT`,`EEXIST`,`ENOTDIR`,`EISDIR`,`ENOTEMPTY`,`EINVAL`,`EACCES`,`ELOOP`,`EBUSY`,`EFBIG`,`EBADF`,`ENOSYS`,`EOPNOTSUPP`,`EXDEV`,`EIO`];function B(e,t){if(e instanceof c)return e;{let n=e instanceof Error?e.message:String(e);if(n.includes(`maximum size exceeded`)||n.includes(`call stack size exceeded`))return new c(`EIO`,`internal overflow, not storage: ${n} — reload the session`,t)}let n=e?.code;if(typeof n==`string`){let r=n;if(z.includes(r)){let n=e instanceof Error?e.message:String(e);return n.startsWith(`${r}: `)&&(n=n.slice(r.length+2),n=n.replace(/, undefined( '[^']*')?$/,``).replace(/ '[^']*'$/,``)),new c(r,n||r,t)}}let r=e instanceof Error?e.message:String(e);return r.includes(`ENOENT`)?new c(`ENOENT`,`no such file or directory`,t):r.includes(`EEXIST`)?new c(`EEXIST`,`file already exists`,t):r.includes(`ENOTDIR`)?new c(`ENOTDIR`,`not a directory`,t):r.includes(`EISDIR`)?new c(`EISDIR`,`is a directory`,t):r.includes(`ENOTEMPTY`)?new c(`ENOTEMPTY`,`directory not empty`,t):r.includes(`ELOOP`)?new c(`ELOOP`,`too many levels of symbolic links`,t):r.includes(`EOPNOTSUPP`)||r.includes(`ENOTSUP`)?new c(`EOPNOTSUPP`,`operation not supported`,t):r.includes(`EXDEV`)?new c(`EXDEV`,`cross-device link`,t):new c(`EINVAL`,r,t)}function V(e){return e===void 0?`absent`:(e&61440)==16384?`directory`:`file`}function H(e,t){return t===`absent`?!1:e.kind===`missing`||e.kind!==t}function U(e){let t=e?.mode;return typeof t==`number`?t:void 0}function W(e,t,n,r=new Set){let i=new Set(n);if(r.size>0){for(let t of Object.keys(e.entries??{}))for(let e of r)if(t===e||t.startsWith(`${e}/`)){i.add(t);break}}let a=[];for(let n of i){let r=e.entries?.[n],i=t.entries?.[n];if(!r||!i)continue;let o=V(U(r));o!==V(U(i))&&a.push({path:n,ownIsDirectory:o===`directory`})}return a}async function G(e,t){let n=t.split(`/`).filter(Boolean),r=n.pop();if(r===void 0)return null;try{let t=e;for(let e of n)t=await t.getDirectoryHandle(e);return await(await t.getFileHandle(r)).getFile()}catch{return null}}async function K(e,t,n,r){try{return await e.lstat(t)}catch(e){let t=B(e,r);if(t.code===`ENOENT`&&n)return null;throw t}}async function q(e,t,r){let a;try{a=await e.readlink(t)}catch(e){throw B(e,r)}return a.startsWith(`/`)?i(a):i(o(n(t).dir,a))}async function J(e,t,n,r,i,a){let o=t===`/`?`/${n}`:`${t}/${n}`;for(;;){let t=await K(e,o,r,i);if(t===null||!t.isSymbolicLink())return{resolved:o,hops:a};if(++a>10)throw new c(`ELOOP`,`too many symbolic links encountered`,i);o=await q(e,o,i)}}async function Y(e,t,n){let r=i(n);if(t(r))return r;let a=r.split(`/`).filter(Boolean),o=`/`,s=0;for(let t=0;t<a.length;t++){let n=await J(e,o,a[t],t===a.length-1,r,s);o=n.resolved,s=n.hops}return o}async function X(e,t,n){return t(n)?n:Y(e,t,n)}function Z(){try{if(typeof globalThis.navigator?.storage?.getDirectory==`function`)return`opfs`}catch{}return`memory`}function Q(e,t){let n=e.kind===`directory`?`directory`:`file`;return t?{name:e.name,type:n,...e.size===void 0?{}:{size:e.size},...e.lastModified===void 0?{}:{mtime:e.lastModified},...e.ctime===void 0?{}:{ctime:e.ctime},...e.ino===void 0?{}:{ino:e.ino},...e.identity===void 0?{}:{identity:e.identity},...e.dev===void 0?{}:{dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},...e.mode===void 0?{}:{mode:e.mode}}:{name:e.name,type:n}}function te(e,t){switch(e.kind){case`local`:case`proc`:return{kind:`local`,mountId:e.mountId,idbHandleKey:t};case`hostfs`:return{kind:`hostfs`,mountId:e.mountId,hostPath:e.getHostPath()};default:return{kind:e.kind===`s3`?`s3`:e.kind===`aem`?`aem`:`da`,mountId:e.mountId,source:e.source,profile:e.profile??`default`}}}var $=class e{lfs;lfsSync;rawLfs=null;rawLfsSync=null;_ready;_readyResolved=!1;backend;mountPoints=new Map;opfsBackendFs=null;opfsHandle=null;mountRoot=``;internalMounts=new Set;watcher=null;dbName;mountSyncChannel=null;mountIndex=new d;static writeChains=new Map;onRepairProgress;constructor(t,n,r,i,a,o){if(this.dbName=t,this.onRepairProgress=a,this.backend=r===`opfs`?`opfs`:`memory`,this.lfs=this.makeDeferredLfs(),this.lfsSync=this.makeDeferredLfsSync(),this._ready=this.backend===`opfs`?e.initOpfsBackend(this,i,n===!0,o):e.initMemoryBackend(this,t,n===!0),this._ready.then(()=>{this._readyResolved=!0},()=>{}),typeof BroadcastChannel<`u`)try{this.mountSyncChannel=new BroadcastChannel(`vfs-mount-sync:${t}`),this.mountSyncChannel.onmessage=e=>{let{type:t,path:n,descriptor:r}=e.data??{};if(t===`mount`&&typeof n==`string`&&r)this.reconstructBackendFromDescriptor(r,n).then(e=>{this.mountPoints.set(n,e),e.kind===`local`&&this.mountIndex.registerMount(n,e.getHandle()),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}).catch(()=>{});else if(t===`unmount`&&typeof n==`string`){let e=this.mountPoints.get(n);this.mountPoints.delete(n),this.mountIndex.unregisterMount(n),e?.close(),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}])}}}catch{}}static opfsInitChains=new Map;static async initOpfsBackend(t,n,r,i){let a=(e.opfsInitChains.get(t.dbName)??Promise.resolve()).catch(()=>{}).then(()=>e.resolveOpfsBackend(t,n,r,i));e.opfsInitChains.set(t.dbName,a);try{await a}finally{e.opfsInitChains.get(t.dbName)===a&&e.opfsInitChains.delete(t.dbName)}}static async resolveOpfsBackend(t,n,r,i){let a=e.opfsBackends.get(t.dbName);if(a&&r)throw new c(`EBUSY`,`Cannot wipe an OPFS backend with live holders`,t.dbName);if(a&&i!==void 0&&a.asyncCache!==i)throw new c(`EBUSY`,`OPFS async cache setting conflicts with the live backend`,t.dbName);let o=n??await e.acquireOpfsHandle(t.dbName,r);await t.withWriteLock(()=>e.seedOpfsMetadataSidecarIfMissing(o));let s=await import(`./dist-SZE428w3.js`);await e.ensureRootMount(s);let l=`/__opfs__/${t.dbName}`,u=e.opfsBackends.get(t.dbName);if(!u){let{resolveOpfsMount:n}=await import(`./opfs-mount-DbDiMdyl.js`),r=await n({handle:o,dbName:t.dbName,asyncCache:i,onRepairProgress:t.onRepairProgress,withWriteLock:e=>t.withWriteLock(e)});try{s.mount(l,r)}catch{}u={backendFs:r,refs:0,asyncCache:i!==!1,sidecarDirty:{paths:new Set,prefixes:new Set}},e.opfsBackends.set(t.dbName,u)}u.refs+=1,t.opfsBackendFs=u.backendFs.index?u.backendFs:null,t.opfsHandle=o,t.mountRoot=l,t.rawLfs=s.promises,t.rawLfsSync=s}static async initMemoryBackend(t,n,r){let i=await import(`./dist-SZE428w3.js`);await e.ensureRootMount(i);let a=`/__zenfs__/${n}`,o=e.memoryBackends.get(n);if(o&&r){try{i.umount(a)}catch{}e.memoryBackends.delete(n),o=void 0}o||(o={store:i.InMemory.create({label:n}),refs:0},e.memoryBackends.set(n,o)),o.refs+=1;try{i.mount(a,o.store)}catch{}t.mountRoot=a,t.rawLfs=i.promises,t.rawLfsSync=i,t.opfsBackendFs=null,t.opfsHandle=null}static rootMountReady=null;static memoryBackends=new Map;static opfsBackends=new Map;static async ensureRootMount(t){return e.rootMountReady===null&&(e.rootMountReady=(async()=>{await t.configureSingle({backend:t.InMemory,label:`__vfs_root__`})})()),e.rootMountReady}prefix(e){return this.mountRoot?e===`/`?this.mountRoot:this.mountRoot+e:e}unprefix(e){return!this.mountRoot||!e.startsWith(this.mountRoot)?e:e.slice(this.mountRoot.length)||`/`}makeDeferredLfs(){let e=e=>this.prefix(e),t=e=>this.unprefix(e),n=()=>{if(!this.rawLfs)throw Error(`VirtualFS used before init resolved`);return this.rawLfs};return{readFile:(t,r)=>this._readyResolved?n().readFile(e(t),r):this._ready.then(()=>n().readFile(e(t),r)),writeFile:(t,r,i)=>this._readyResolved?n().writeFile(e(t),r,i):this._ready.then(()=>n().writeFile(e(t),r,i)),appendFile:async(t,r)=>{this._readyResolved||await this._ready,await n().appendFile(e(t),r)},chmod:async(t,r)=>{this._readyResolved||await this._ready,await n().chmod(e(t),r)},utimes:async(t,r,i)=>{this._readyResolved||await this._ready,await n().utimes(e(t),r,i)},readdir:t=>this._readyResolved?n().readdir(e(t)):this._ready.then(()=>n().readdir(e(t))),mkdir:(t,r)=>this._readyResolved?n().mkdir(e(t),r):this._ready.then(()=>n().mkdir(e(t),r)),rmdir:t=>this._readyResolved?n().rmdir(e(t)):this._ready.then(()=>n().rmdir(e(t))),unlink:t=>this._readyResolved?n().unlink(e(t)):this._ready.then(()=>n().unlink(e(t))),rename:(t,r)=>this._readyResolved?n().rename(e(t),e(r)):this._ready.then(()=>n().rename(e(t),e(r))),stat:t=>this._readyResolved?n().stat(e(t)):this._ready.then(()=>n().stat(e(t))),lstat:t=>this._readyResolved?n().lstat(e(t)):this._ready.then(()=>n().lstat(e(t))),symlink:(t,r)=>{let i=t.startsWith(`/`)?e(t):t;return this._readyResolved?n().symlink(i,e(r)):this._ready.then(()=>n().symlink(i,e(r)))},readlink:async r=>(this._readyResolved||await this._ready,t(await n().readlink(e(r)))),truncate:async(t,r)=>{this._readyResolved||await this._ready;let i=n();typeof i.truncate==`function`&&await i.truncate(e(t),r)},realpath:async r=>{this._readyResolved||await this._ready;let i=n();return typeof i.realpath==`function`?t(await i.realpath(e(r))):e(r)}}}makeDeferredLfsSync(){let e=e=>this.prefix(e),t=e=>this.unprefix(e);return{readdirSync:t=>{let n=this.rawLfsSync;return n?.readdirSync?n.readdirSync(e(t)):void 0},statSync:t=>{let n=this.rawLfsSync;return n?.statSync?n.statSync(e(t)):void 0},lstatSync:t=>{let n=this.rawLfsSync;return n?.lstatSync?n.lstatSync(e(t)):void 0},readlinkSync:n=>{let r=this.rawLfsSync;return r?.readlinkSync?t(r.readlinkSync(e(n))):void 0}}}static async seedOpfsMetadataSidecarIfMissing(t){let n=`.metadata.json`;try{let r=await t.getFileHandle(n);if(e.isUsableMetadataDocument(await e.readSidecarText(r)))return;console.warn(`[virtual-fs] metadata sidecar is unparseable (torn write?); reseeding an empty index`)}catch(e){if(e?.name!==`NotFoundError`)throw e}let r=await(await t.getFileHandle(n,{create:!0})).createWritable(),i=JSON.stringify({version:1,maxSize:4294967295,entries:{}});await r.write(i),await r.close()}static async readSidecarText(e){let t;for(let n=0;n<3;n++)try{return await(await e.getFile()).text()}catch(e){if(e?.name!==`NotReadableError`)throw e;t=e}throw t}static isUsableMetadataDocument(e){let t;try{t=JSON.parse(e)}catch{return!1}if(!t||typeof t!=`object`)return!1;let n=t.entries;return!!n&&typeof n==`object`}static async acquireOpfsHandle(e,t){let n=navigator.storage;if(!n?.getDirectory)throw new c(`EINVAL`,`OPFS is not available in this environment`);let r=await n.getDirectory();if(t)try{await r.removeEntry(e,{recursive:!0})}catch{}return r.getDirectoryHandle(e,{create:!0})}static _createSyncForTests(t){return new e(t)}static async create(t){let n=t?.dbName??`browser-fs`,r=t?.wipe===!0,i=t?.backend??Z(),a=new e(n,r,i,void 0,t?.onRepairProgress,t?.opfsAsyncCache);try{await a._ready}catch(e){throw a.mountSyncChannel?.close(),e}return r&&await h().catch(()=>{}),a}async flush(){await this.writeOpfsMetadataSidecar()}async writeOpfsMetadataSidecar(){this.backend===`opfs`&&await this.withWriteLock(()=>this.writeOpfsMetadataSidecarUnlocked())}async writeOpfsMetadataSidecarUnlocked(){if(this.backend!==`opfs`)return;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t||!n)return;let r=t.index.toJSON(),i=e.opfsBackends.get(this.dbName)?.sidecarDirty,a=r;if(i){let e=null;try{let t=await n.getFileHandle(`.metadata.json`),r=JSON.parse(await(await t.getFile()).text());r&&typeof r==`object`&&r.entries&&(e=r)}catch{}e&&(await this.auditDirtyKindFlips(r,e,i,n),a=y(e,r,i))}let o=JSON.stringify(x(a)),s=await(await n.getFileHandle(`.metadata.json`,{create:!0})).createWritable();await s.write(o),await s.close(),i&&(i.paths.clear(),i.prefixes.clear())}async auditDirtyKindFlips(e,t,n,r){let i=W(e,t,n.paths,n.prefixes);if(i.length===0)return;let a=b(r),o=this.opfsBackendFs;for(let n of i){let r=await a(n.path).catch(()=>null);if(r!==null&&r.kind!==`missing`&&r.kind===`directory`===n.ownIsDirectory)continue;let i=t.entries?.[n.path];e.entries&&i!==void 0&&(e.entries[n.path]=i);let s=r!==null&&r.kind!==`missing`;s&&(o?.index?.delete(n.path),o?._handles?.delete(n.path)),console.warn(`[virtual-fs] refused to flush in-memory kind flip over sidecar record (#2006)`,{path:n.path,reality:r?.kind??`unverifiable`,evicted:s})}}markSidecarDirty(t,r=`path`){if(this.backend!==`opfs`)return;let a=e.opfsBackends.get(this.dbName)?.sidecarDirty;if(!a)return;let o=i(t);(r===`prefix`?a.prefixes:a.paths).add(o);let{dir:s}=n(o);for(;s!==`/`;)a.paths.add(s),s=n(s).dir}async forgetSidecarConsistency(){await this.dropSidecarConsistency()}sidecarConsistencyDrop=null;dropSidecarConsistency(){if(this.backend!==`opfs`||!this.opfsHandle)return Promise.resolve();if(!this.sidecarConsistencyDrop){let e=this.opfsHandle;this.sidecarConsistencyDrop=S(e).catch(e=>{throw this.sidecarConsistencyDrop=null,e})}return this.sidecarConsistencyDrop}invalidatePaths(e){if(this.backend!==`opfs`||!this.opfsBackendFs)return;e.length>0&&this.dropSidecarConsistency().catch(()=>void 0);let t=this.opfsBackendFs;for(let n of e){let e=i(n);t.index.delete(e),t._handles?.delete(e),this.markSidecarDirty(e)}}async withKindMismatchRetry(e,t){return this.withKindMismatchRetryPaths([e],t)}async withKindMismatchRetryPaths(e,t){try{return await t()}catch(n){let r=n?.code;if(r!==`EISDIR`&&r!==`ENOTDIR`&&r!==`EINVAL`)throw n;for(let n of e)if(await this.reconcileKindMismatch(n).catch(()=>!1))return await t();throw n}}async reconcileKindMismatch(e){if(this.backend!==`opfs`)return!1;let t=this.opfsBackendFs,n=this.opfsHandle;if(!t?.index||!n)return!1;let r=i(e),a=r;try{a=await this.resolveSymlinks(r)}catch{}let o=await b(n)(a),s=V(t.index.get(a)?.mode),c=t._handles?.get(a),l=c?.kind===`directory`?`directory`:c?.kind===`file`?`file`:`absent`,u=H(o,s),d=H(o,l);if(!u&&!d)return!1;if(t.index.delete(a),t._handles?.delete(a),s===`directory`||l===`directory`){let e=`${a}/`;for(let n of[...t.index.keys()])n.startsWith(e)&&t.index.delete(n);if(t._handles)for(let n of[...t._handles.keys()])n.startsWith(e)&&t._handles.delete(n)}return this.markSidecarDirty(a),console.warn(`[virtual-fs] reconciled in-memory kind mismatch (#2006)`,{path:a,reality:o.kind,indexHeld:s,handleHeld:l}),!0}localIdentity(e){return C(`zenfs:${this.backend}:${this.dbName}`,e)}canWrite(e){return!0}setWatcher(e){this.watcher=e}getWatcher(){return this.watcher}async watch(e,t){let n=this.watcher;if(!n)throw new c(`ENOSYS`,`no FsWatcher attached to this VirtualFS`);let r=e.map(e=>n.watch(e,()=>!0,t));return()=>{for(let e of r)e()}}async dispose(){if(this.mountSyncChannel?.close(),this.mountSyncChannel=null,this.watcher?.dispose(),this.watcher=null,this.mountIndex.dispose(),await this.writeOpfsMetadataSidecar(),this.mountRoot){let t=this.backend===`opfs`?e.opfsBackends:e.memoryBackends,n=t.get(this.dbName);if(n&&(--n.refs,n.refs<=0)){t.delete(this.dbName);try{(await import(`./dist-SZE428w3.js`)).umount(this.mountRoot)}catch{}}}}readDirSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.readdirSync!=`function`||typeof n.lstatSync!=`function`)return null;try{let e=n.readdirSync(t),r=[];for(let i of e){let e=t===`/`?`/${i}`:`${t}/${i}`;try{let t=n.lstatSync(e),a=t.isSymbolicLink()?`symlink`:t.isDirectory()?`directory`:`file`;r.push(a===`symlink`?{name:i,type:a}:{name:i,type:a,size:t.size,mtime:t.mtimeMs,ctime:t.ctimeMs,...t.ino===void 0?{}:{ino:t.ino,identity:this.localIdentity(t.ino),dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},mode:t.mode})}catch{}}return r}catch{return null}}statSync(e){let t=i(e);if(this.findMount(t))return null;let r=this.lfsSync;if(typeof r.statSync!=`function`||typeof r.lstatSync!=`function`||typeof r.readlinkSync!=`function`)return null;if(t===`/`)try{let e=r.statSync(t);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}let a=t;for(let e=0;e<=10;e++){let e;try{e=r.lstatSync(a)}catch{return null}if(!e.isSymbolicLink())return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode};let t;try{t=r.readlinkSync(a)}catch{return null}a=t.startsWith(`/`)?i(t):i(o(n(a).dir,t))}return null}lstatSync(e){let t=i(e);if(this.findMount(t))return null;let n=this.lfsSync;if(typeof n.lstatSync!=`function`)return null;if(t===`/`)return this.statSync(t);try{let e=n.lstatSync(t);if(e.isSymbolicLink()){let r=n.readlinkSync?n.readlinkSync(t):``;return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:r,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev,mode:e.mode}}catch{return null}}async mount(e,t,r){let a=i(e);if(this.mountPoints.has(a))throw new c(`EEXIST`,`mount point is already mounted`,a);try{if((await this.lstat(a)).type!==`directory`)throw new c(`ENOTDIR`,`mount point must be a directory`,a);if((await this.readDir(a)).length>0)throw new c(`ENOTEMPTY`,`mount point must be empty to avoid shadowing existing files`,a)}catch(e){if(!(e instanceof c)||e.code!==`ENOENT`)throw e}let{dir:o}=n(a);o!==`/`&&await this.mkdir(o,{recursive:!0}),await this.dropSidecarConsistency();try{await this.lfs.mkdir(a)}catch{}if(this.mountPoints.set(a,t),t.kind===`local`){let e=r?.limits??u(r?.env??{});this.mountIndex.registerMount(a,t.getHandle(),e)}let s=te(t,a);try{this.mountSyncChannel?.postMessage({type:`mount`,path:a,descriptor:s})}catch{}if(this.watcher?.notify([{type:`modify`,path:a,entryType:`directory`}]),t.kind!==`hostfs`)try{let e={targetPath:a,descriptor:s,createdAt:Date.now()},n=t.kind===`local`?t.getHandle():void 0;await f(e,n)}catch{}}async unmount(e){let t=i(e),n=this.mountPoints.get(t);this.mountPoints.delete(t),this.mountIndex.unregisterMount(t);try{this.mountSyncChannel?.postMessage({type:`unmount`,path:t})}catch{}this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close();try{await p(t)}catch{}}async reconstructBackendFromDescriptor(e,t){switch(e.kind){case`local`:{let t=await m(e.idbHandleKey);if(!t)throw Error(`no handle stored for ${e.idbHandleKey}`);return l.fromHandle(t,{mountId:e.mountId})}case`hostfs`:{let{HostFsMountBackend:n}=await import(`./backend-hostfs-CMj5JyW-.js`);return new n({targetPath:t,hostPath:e.hostPath,mountId:e.mountId})}case`s3`:{let{S3MountBackend:t,RemoteMountCache:n,makeSignedFetchS3:r}=await import(`./mount-BfPgf0TT.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r(e.profile)})}case`da`:{let{DaMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-BfPgf0TT.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}case`aem`:{let{AemMountBackend:t,RemoteMountCache:n,makeSignedFetchDa:r}=await import(`./mount-BfPgf0TT.js`).then(e=>e.t),i=new n({mountId:e.mountId,ttlMs:3e4});return new t({source:e.source,profile:e.profile,cache:i,mountId:e.mountId,signedFetch:r()})}}}listMounts(){let e=[];for(let t of this.mountPoints.keys())this.internalMounts.has(t)||e.push(t);return e}listInternalMounts(){return[...this.internalMounts]}listMountPoints(){let e=[];for(let[t,n]of this.mountPoints)this.internalMounts.has(t)||e.push({path:t,kind:n.kind});return e}getMountBackend(e){let t=i(e);return this.mountPoints.get(t)??null}async mountInternal(e,t){let r=i(e);if(this.mountPoints.has(r))throw new c(`EEXIST`,`mount point is already mounted`,r);let{dir:a}=n(r);a!==`/`&&await this.mkdir(a,{recursive:!0}),await this.dropSidecarConsistency();try{await this.lfs.mkdir(r)}catch{}this.mountPoints.set(r,t),this.internalMounts.add(r),this.watcher?.notify([{type:`modify`,path:r,entryType:`directory`}])}async unmountInternal(e){let t=i(e);if(!this.internalMounts.has(t))throw new c(`ENOENT`,`not an internal mount point`,t);let n=this.mountPoints.get(t);this.mountPoints.delete(t),this.internalMounts.delete(t),this.watcher?.notify([{type:`modify`,path:t,entryType:`directory`}]),await n?.close()}getMountIndex(){return this.mountIndex}async refreshMount(e,t){let n=i(e),r=this.mountPoints.get(n);if(!r)throw new c(`ENOENT`,`not a mount point`,n);let a=await r.refresh(t);return r.kind===`local`&&await this.mountIndex.refreshMount(n,u(t?.env??{})),this.watcher?.notify([{type:`modify`,path:n,entryType:`directory`}]),a}isPathUnderMount(e){for(let t of this.mountPoints.keys())if(e===t||e.startsWith(t+`/`))return!0;return!1}findMount(e){let t=null;for(let[n,r]of this.mountPoints)(e===n||e.startsWith(n+`/`))&&(!t||n.length>t.mountPath.length)&&(t={mountPath:n,backend:r});return t?e===t.mountPath?{path:t.mountPath,backend:t.backend,relParts:[]}:{path:t.mountPath,backend:t.backend,relParts:e.slice(t.mountPath.length+1).split(`/`).filter(Boolean)}:null}async readFile(e,t){return this.withKindMismatchRetry(e,()=>this.readFileInner(e,t))}async readFileInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EISDIR`,`is a directory`,n);let e=r.relParts.join(`/`);try{let n=await r.backend.readFile(e);return(t?.encoding??`utf-8`)===`utf-8`?new TextDecoder(`utf-8`).decode(n):n}catch(e){R(e,n)}}let a=await this.resolveSymlinks(n);try{return(t?.encoding??`utf-8`)===`utf-8`?await this.lfs.readFile(a,{encoding:`utf8`}):await this.lfs.readFile(a)}catch(e){throw B(e,n)}}async readFileRange(e,t,n){let r=i(e);if(!Number.isInteger(t)||!Number.isInteger(n)||t<0||n<t)throw new c(`EINVAL`,`invalid byte range ${t}-${n}`,r);if(t===n)return new Uint8Array;let a=this.findMount(r),o=a?.backend.readFileRange;if(a&&o){if(a.relParts.length===0)throw new c(`EISDIR`,`is a directory`,r);try{return await o.call(a.backend,a.relParts.join(`/`),t,n)}catch(e){R(e,r)}}let s=await this.sliceNativeFile(r,t,n);if(s)return s;let l=await this.readFile(r,{encoding:`binary`});return new Uint8Array(l.subarray(t,Math.min(n,l.byteLength)))}async sliceNativeFile(e,t,n){try{let r=await this.getNativeFile(e);if(!r)return null;let i=r.slice(t,Math.min(n,r.size));return new Uint8Array(await i.arrayBuffer())}catch{return null}}async getNativeFile(e){let t=i(e),n=this.findMount(t);if(n){let e=n.backend.getNativeFile;if(!e||n.relParts.length===0)return null;try{return await e.call(n.backend,n.relParts.join(`/`))}catch{return null}}let r=this.opfsHandle;if(!r)return null;try{return await G(r,await this.resolveSymlinks(t))}catch{return null}}async writeFile(e,t,n){return this.withKindMismatchRetry(e,()=>this.writeFileInner(e,t,n))}async writeFileInner(e,t,r){let a=i(e),o=this.findMount(a);if(o){if(o.relParts.length===0)throw new c(`EISDIR`,`is a directory`,a);let e=o.relParts.join(`/`),n=!1;try{await this.stat(a),n=!0}catch{}let r=typeof t==`string`?new TextEncoder().encode(t):t instanceof Uint8Array?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):new Uint8Array(t);try{await o.backend.writeFile(e,r)}catch(e){R(e,a)}this.watcher?.notify([{type:n?`modify`:`create`,path:a,entryType:`file`}]),this.mountIndex.notifyWrite(a);return}let s;try{s=await this.resolveSymlinks(a)}catch{s=a}let l=!1;try{await this.lfs.stat(s),l=!0}catch{}let{dir:u}=n(s);await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),this.markSidecarDirty(s),u!==`/`&&await this.mkdirRecursiveUnlocked(u);let e=typeof t==`string`?new TextEncoder().encode(t).byteLength:(t instanceof Uint8Array,t.byteLength);try{await this.lfs.writeFile(s,t)}catch(e){if(u!==`/`&&e instanceof Error&&e.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(u);try{await this.lfs.writeFile(s,t)}catch(e){throw B(e,a)}}else throw B(e,a)}try{await this.lfs.truncate?.(s,e)}catch(e){throw B(e,a)}}),this.watcher?.notify([{type:l?`modify`:`create`,path:s,entryType:`file`}])}async appendFile(e,t){let r=i(e);await this.withKindMismatchRetry(r,()=>this.withWriteLock(async()=>{if(this.findMount(r)){await this.appendMounted(r,t);return}await this.dropSidecarConsistency();let e=r,i=!1;try{if(e=await this.resolveSymlinks(r),(await this.lfs.stat(e)).isDirectory())throw new c(`EISDIR`,`is a directory`,r);i=!0}catch(e){let t=B(e,r);if(t.code!==`ENOENT`)throw t}this.markSidecarDirty(e);let{dir:a}=n(e);await this.mkdirRecursiveUnlocked(a);try{await this.lfs.appendFile(e,t)}catch(e){throw B(e,r)}this.watcher?.notify([{type:i?`modify`:`create`,path:e,entryType:`file`}])}))}async appendMounted(e,t){let n=new Uint8Array;try{let t=await this.readFileInner(e,{encoding:`binary`});n=typeof t==`string`?new TextEncoder().encode(t):new Uint8Array(t)}catch(t){let n=B(t,e);if(n.code!==`ENOENT`)throw n}let r=typeof t==`string`?new TextEncoder().encode(t):t,i=new Uint8Array(n.length+r.length);i.set(n),i.set(r,n.length),await this.writeFileInner(e,i)}async chmod(e,t){if(!Number.isInteger(t)||t<0||t>4095)throw new c(`EINVAL`,`invalid file mode`,i(e));await this.changeMetadata(e,e=>this.lfs.chmod(e,t))}async utimes(e,t,n){if(!Number.isFinite(t.getTime())||!Number.isFinite(n.getTime()))throw new c(`EINVAL`,`invalid file time`,i(e));await this.changeMetadata(e,e=>this.lfs.utimes(e,t,n))}async changeMetadata(e,t){let n=i(e);if(this.findMount(n))throw await this.stat(n),new c(`ENOSYS`,`metadata changes are not supported by this mount`,n);await this.withKindMismatchRetry(n,()=>this.withWriteLock(async()=>{await this.dropSidecarConsistency();let e=await this.resolveSymlinks(n);try{let n=await this.lfs.stat(e);this.markSidecarDirty(e),await t(e),await this.writeOpfsMetadataSidecarUnlocked(),this.watcher?.notify([{type:`modify`,path:e,entryType:n.isDirectory()?`directory`:`file`}])}catch(e){throw B(e,n)}}))}async readDir(e,t){let n=i(e),r=this.findMount(n);return r?this.readDirMounted(n,r,t):this.readDirLocal(n)}async readDirMounted(e,t,n){let r=n?.includeStats===!0?void 0:this.mountIndex.getDirectoryEntries(t.path,e);if(r!==void 0){let t=new Map;for(let e of r)t.set(e.name,{name:e.name,type:e.type});return this.addNestedMountEntries(t,e),[...t.values()]}let i=t.relParts.join(`/`)||`/`,a;try{a=await t.backend.readDir(i,n)}catch(t){R(t,e)}let o=new Map,s=t.backend.listingStatsMatchStat===!0;for(let e of a)o.set(e.name,Q(e,s));return this.addNestedMountEntries(o,e),[...o.values()]}async readDirLocal(e){return this.withKindMismatchRetry(e,()=>this.readDirLocalInner(e))}async readDirLocalInner(e){let t=await this.resolveSymlinks(e);try{let e=await this.lfs.readdir(t),n=[];for(let r of e){let e=await this.statDirEntry(t,r);e&&n.push(e)}return n}catch(t){throw B(t,e)}}async statDirEntry(e,t){let n=e===`/`?`/${t}`:`${e}/${t}`;try{let e=await this.lfs.lstat(n);return e.isSymbolicLink()?{name:t,type:`symlink`}:{name:t,type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,...e.ino===void 0?{}:{ino:e.ino,identity:this.localIdentity(e.ino),dev:e.dev},...e.uid===void 0?{}:{uid:e.uid},...e.gid===void 0?{}:{gid:e.gid},mode:e.mode}}catch{return null}}addNestedMountEntries(e,t){let n=t===`/`?`/`:`${t}/`;for(let r of this.mountPoints.keys()){if(r===t||!r.startsWith(n))continue;let i=r.slice(n.length);!i||i.includes(`/`)||e.has(i)||e.set(i,{name:i,type:`directory`})}}async withWriteLock(t){let n=this.dbName,r,i=new Promise(e=>{r=e}),a=e.writeChains.get(n)??Promise.resolve();e.writeChains.set(n,i),await a;try{let e=globalThis.navigator?.locks;return this.backend!==`opfs`||typeof e?.request!=`function`?await t():await e.request(`slicc-vfs:${n}`,()=>t())}finally{r(),e.writeChains.get(n)===i&&e.writeChains.delete(n)}}async mkdirRecursiveUnlocked(e){let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t){r+=`/`+e;try{await this.lfs.mkdir(r),n.push(r)}catch(e){if(e instanceof Error&&!e.message.includes(`EEXIST`))throw B(e,r);try{let e=await this.lfs.lstat(r);if(!e.isDirectory()&&!e.isSymbolicLink())throw new c(`ENOTDIR`,`not a directory`,r)}catch(e){if(e instanceof c&&e.code===`ENOTDIR`)throw e}}}return n}async mkdir(e,t){let n=i(e);if(n===`/`)return;let r=this.findMount(n);if(r){if(r.relParts.length===0)return;let e=r.relParts.join(`/`),t=await this.exists(n);try{await r.backend.mkdir(e)}catch(e){R(e,n)}t||this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}]);return}if(t?.recursive){let e=await this.withWriteLock(async()=>(await this.dropSidecarConsistency(),this.markSidecarDirty(n),this.mkdirRecursiveUnlocked(n)));e.length>0&&this.watcher?.notify(e.map(e=>({type:`create`,path:e,entryType:`directory`})))}else await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),this.markSidecarDirty(n);try{await this.lfs.mkdir(n)}catch(e){throw B(e,n)}}),this.watcher?.notify([{type:`create`,path:n,entryType:`directory`}])}async rm(e,t){return this.withKindMismatchRetry(i(e),()=>this.rmInner(e,t))}async rmInner(e,t){let n=i(e),r=this.findMount(n);if(r){if(r.relParts.length===0)throw new c(`EINVAL`,`cannot remove a mount point — use unmount`,n);let e;try{e=(await this.stat(n)).type}catch{}let i=r.relParts.join(`/`);try{await r.backend.remove(i,{recursive:t?.recursive})}catch(e){R(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:e}]),this.mountIndex.notifyDelete(n);return}try{let e=await this.lfs.lstat(n);await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),e.isSymbolicLink()?await this.lfs.unlink(n):e.isDirectory()?t?.recursive?await this.rmRecursiveUnlocked(n):await this.lfs.rmdir(n):await this.lfs.unlink(n),this.markSidecarDirty(n,`prefix`),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw B(e,n)}this.watcher?.notify([{type:`delete`,path:n}])}async rmRecursiveUnlocked(e){let t=await this.lfs.readdir(e);for(let n of t){let t=e===`/`?`/${n}`:`${e}/${n}`,r=await this.lfs.lstat(t);r.isSymbolicLink()?await this.lfs.unlink(t):r.isDirectory()?await this.rmRecursiveUnlocked(t):await this.lfs.unlink(t)}await this.lfs.rmdir(e)}async stat(e){return this.withKindMismatchRetry(e,()=>this.statInner(e))}async statInner(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)try{let e=await this.lfs.stat(t);return{type:`directory`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs}}catch{return{type:`directory`,size:0,mtime:Date.now(),ctime:Date.now()}}let e=n.relParts.join(`/`);try{let t=await n.backend.stat(e);return{type:t.kind===`directory`?`directory`:`file`,size:t.size,mtime:t.mtime,ctime:t.ctime??t.mtime,...t.ino===void 0?{}:{ino:t.ino},...t.identity===void 0?{}:{identity:t.identity},...t.dev===void 0?{}:{dev:t.dev},...t.uid===void 0?{}:{uid:t.uid},...t.gid===void 0?{}:{gid:t.gid},...t.mode===void 0?{}:{mode:t.mode}}}catch(e){R(e,t)}}let r=await this.resolveSymlinks(t);try{let e=await this.lfs.stat(r);return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw B(e,t)}}async exists(e){let t=i(e),n=this.findMount(t);if(n){if(n.relParts.length===0)return!0;try{return await this.stat(t),!0}catch{return!1}}try{return await this.stat(t),!0}catch{try{return await this.lfs.lstat(t),!0}catch{return!1}}}async rename(e,t){return this.withKindMismatchRetryPaths([i(e),i(t)],()=>this.renameInner(e,t))}async renameInner(e,t){let n=i(e),r=i(t);if(n===r)return;let a;try{a=await this.lstat(n)}catch{}let o=a?.type,s=this.findMount(n);if(s?.backend.rename){let e=this.findMount(r);if(e&&e.backend===s.backend){let t=!1;try{t=(await s.backend.rename(s.relParts.join(`/`),e.relParts.join(`/`)))?.noop===!0}catch(e){R(e,n)}t||(this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r));return}}if(a)try{let e=await this.lstat(r);if(v(a,e))return}catch{}try{await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),this.markSidecarDirty(n,`prefix`),this.markSidecarDirty(r,`prefix`),await this.lfs.rename(n,r),await this.writeOpfsMetadataSidecarUnlocked()})}catch(e){throw B(e,n)}this.watcher?.notify([{type:`delete`,path:n,entryType:o},{type:`create`,path:r,entryType:o}]),this.mountIndex.notifyRename(n,r)}async readTextFile(e){return await this.readFile(e,{encoding:`utf-8`})}async*walk(e,t,n=0){yield*E({mountPoints:this.mountPoints,mountIndex:this.mountIndex,realpath:e=>this.realpath(e),readDir:e=>this.readDir(e),stat:e=>this.stat(e)},e,t,n)}async copyFile(e,t){let n=await this.stat(e);if(n.type===`directory`)throw new c(`EISDIR`,`is a directory`,e);try{let e=await this.stat(t);if(v(n,e))return}catch{}let r=await this.readFile(e,{encoding:`binary`});await this.writeFile(t,r)}dirname(e){return n(i(e)).dir}basename(e){return n(i(e)).base}resolveSymlinkTargetPath(e,t){return e.startsWith(`/`)?i(e):i(o(n(t).dir,e))}assertSymlinkCreateAllowed(e,t){if(this.findMount(t))throw new c(`EINVAL`,`symlinks not supported on mounted filesystems`,t);let n=this.resolveSymlinkTargetPath(e,t);if(this.findMount(n))throw new c(`EXDEV`,`cannot create a symlink across a mount boundary to '${n}'`,t)}async symlink(e,t){let r=i(t);this.assertSymlinkCreateAllowed(e,r);let{dir:a}=n(r);await this.withWriteLock(async()=>{await this.dropSidecarConsistency(),a!==`/`&&await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(t){if(a!==`/`&&t instanceof Error&&t.message.includes(`ENOENT`)){await this.mkdirRecursiveUnlocked(a);try{await this.lfs.symlink(e,r)}catch(e){throw B(e,r)}}else throw B(t,r)}this.markSidecarDirty(r),await this.writeOpfsMetadataSidecarUnlocked()}),this.watcher?.notify([{type:`create`,path:r,entryType:`symlink`}])}async readlink(e){let t=i(e);try{return await this.lfs.readlink(t)}catch(e){throw B(e,t)}}async lstat(e){let t=i(e);if(this.findMount(t)||t===`/`)return this.stat(t);try{let e=await this.lfs.lstat(t);if(e.isSymbolicLink()){let n=await this.lfs.readlink(t);return{type:`symlink`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,isSymlink:!0,symlinkTarget:n,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}return{type:e.isDirectory()?`directory`:`file`,size:e.size,mtime:e.mtimeMs,ctime:e.ctimeMs,ino:e.ino,dev:e.dev,identity:this.localIdentity(e.ino),uid:e.uid,gid:e.gid,mode:e.mode}}catch(e){throw B(e,t)}}async realpath(e){return Y(this.lfs,e=>this.findMount(e)!==null,e)}resolveSymlinks(e){return X(this.lfs,e=>this.findMount(e)!==null,e)}},ne=e({FsError:()=>c,FsWatcher:()=>j,MountIndex:()=>d,RestrictedFS:()=>L,VirtualFS:()=>$,joinPath:()=>o,normalizePath:()=>i,pathSegments:()=>r,resolveVfsBackendFromEnv:()=>Z,sameFileIdentity:()=>v,splitPath:()=>n,statsFromDirEntry:()=>s});export{j as i,$ as n,L as r,ne as t};