@visulima/vis 3.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE.md +5760 -4562
  3. package/dashboard/dist/index.html +12 -12
  4. package/dist/bin.js +1 -1
  5. package/dist/binx.js +2 -2
  6. package/dist/config/index.js +1 -1
  7. package/dist/packem_chunks/CONFIG_FILES.js +6 -6
  8. package/dist/packem_chunks/DEFAULT_CLEAN_KEEP.js +1 -1
  9. package/dist/packem_chunks/agent-instructions.js +7 -7
  10. package/dist/packem_chunks/bloom-status.js +2 -2
  11. package/dist/packem_chunks/bloom-sync.js +2 -2
  12. package/dist/packem_chunks/cache-attestation.js +1 -1
  13. package/dist/packem_chunks/catalog-detector.js +1 -1
  14. package/dist/packem_chunks/catalog.js +87 -111
  15. package/dist/packem_chunks/cli-exec.js +1 -1
  16. package/dist/packem_chunks/cli-main.js +192 -217
  17. package/dist/packem_chunks/defineReleasePlugin.js +3 -3
  18. package/dist/packem_chunks/detect.js +8 -3
  19. package/dist/packem_chunks/devtools.js +1 -1
  20. package/dist/packem_chunks/discord.js +4 -4
  21. package/dist/packem_chunks/dispatch.js +4 -4
  22. package/dist/packem_chunks/doctor-probe.js +2 -2
  23. package/dist/packem_chunks/extra-files.js +3 -3
  24. package/dist/packem_chunks/fix.js +11 -11
  25. package/dist/packem_chunks/git.js +3 -3
  26. package/dist/packem_chunks/group-tags.js +1 -1
  27. package/dist/packem_chunks/handler.js +1 -1
  28. package/dist/packem_chunks/handler10.js +5 -5
  29. package/dist/packem_chunks/handler11.js +1 -1
  30. package/dist/packem_chunks/handler12.js +16 -16
  31. package/dist/packem_chunks/handler13.js +5 -5
  32. package/dist/packem_chunks/handler14.js +1 -1
  33. package/dist/packem_chunks/handler15.js +1 -1
  34. package/dist/packem_chunks/handler16.js +1 -1
  35. package/dist/packem_chunks/handler17.js +1 -1
  36. package/dist/packem_chunks/handler18.js +1 -1
  37. package/dist/packem_chunks/handler19.js +5 -5
  38. package/dist/packem_chunks/handler2.js +1 -1
  39. package/dist/packem_chunks/handler20.js +2 -2
  40. package/dist/packem_chunks/handler21.js +2 -2
  41. package/dist/packem_chunks/handler22.js +8 -8
  42. package/dist/packem_chunks/handler23.js +1 -1
  43. package/dist/packem_chunks/handler24.js +1 -1
  44. package/dist/packem_chunks/handler25.js +1 -1
  45. package/dist/packem_chunks/handler26.js +5 -5
  46. package/dist/packem_chunks/handler27.js +1 -1
  47. package/dist/packem_chunks/handler28.js +3 -3
  48. package/dist/packem_chunks/handler29.js +1 -1
  49. package/dist/packem_chunks/handler3.js +2 -2
  50. package/dist/packem_chunks/handler30.js +1 -1
  51. package/dist/packem_chunks/handler31.js +2 -2
  52. package/dist/packem_chunks/handler32.js +2 -2
  53. package/dist/packem_chunks/handler33.js +2 -2
  54. package/dist/packem_chunks/handler34.js +3 -3
  55. package/dist/packem_chunks/handler35.js +5 -5
  56. package/dist/packem_chunks/handler36.js +1 -1
  57. package/dist/packem_chunks/handler37.js +2 -2
  58. package/dist/packem_chunks/handler38.js +6 -6
  59. package/dist/packem_chunks/handler39.js +8 -8
  60. package/dist/packem_chunks/handler4.js +4 -4
  61. package/dist/packem_chunks/handler40.js +34 -34
  62. package/dist/packem_chunks/handler41.js +5 -5
  63. package/dist/packem_chunks/handler42.js +4 -4
  64. package/dist/packem_chunks/handler43.js +3 -3
  65. package/dist/packem_chunks/handler44.js +2 -2
  66. package/dist/packem_chunks/handler45.js +1 -1
  67. package/dist/packem_chunks/handler46.js +1 -1
  68. package/dist/packem_chunks/handler47.js +1 -1
  69. package/dist/packem_chunks/handler48.js +3 -3
  70. package/dist/packem_chunks/handler49.js +1 -1
  71. package/dist/packem_chunks/handler5.js +6 -6
  72. package/dist/packem_chunks/handler50.js +6 -6
  73. package/dist/packem_chunks/handler51.js +13 -13
  74. package/dist/packem_chunks/handler52.js +3 -3
  75. package/dist/packem_chunks/handler53.js +5 -5
  76. package/dist/packem_chunks/handler54.js +2 -2
  77. package/dist/packem_chunks/handler55.js +1 -1
  78. package/dist/packem_chunks/handler56.js +4 -4
  79. package/dist/packem_chunks/handler57.js +5 -5
  80. package/dist/packem_chunks/handler58.js +5 -5
  81. package/dist/packem_chunks/handler59.js +8 -8
  82. package/dist/packem_chunks/handler6.js +7 -7
  83. package/dist/packem_chunks/handler60.js +3 -3
  84. package/dist/packem_chunks/handler61.js +21 -21
  85. package/dist/packem_chunks/handler62.js +12 -12
  86. package/dist/packem_chunks/handler63.js +3 -3
  87. package/dist/packem_chunks/handler64.js +5 -5
  88. package/dist/packem_chunks/handler65.js +8 -8
  89. package/dist/packem_chunks/handler66.js +2 -2
  90. package/dist/packem_chunks/handler67.js +25 -24
  91. package/dist/packem_chunks/handler68.js +153 -25
  92. package/dist/packem_chunks/handler69.js +10 -153
  93. package/dist/packem_chunks/handler7.js +1 -1
  94. package/dist/packem_chunks/handler70.js +22 -10
  95. package/dist/packem_chunks/handler71.js +17 -17
  96. package/dist/packem_chunks/handler72.js +104 -104
  97. package/dist/packem_chunks/handler73.js +20 -20
  98. package/dist/packem_chunks/handler74.js +45 -45
  99. package/dist/packem_chunks/handler75.js +27 -3
  100. package/dist/packem_chunks/handler76.js +3 -27
  101. package/dist/packem_chunks/handler77.js +68 -68
  102. package/dist/packem_chunks/handler78.js +30 -30
  103. package/dist/packem_chunks/handler8.js +1 -1
  104. package/dist/packem_chunks/handler9.js +1 -1
  105. package/dist/packem_chunks/heal-accept.js +9 -9
  106. package/dist/packem_chunks/heal.js +11 -11
  107. package/dist/packem_chunks/help-command.js +7 -63
  108. package/dist/packem_chunks/index.js +1 -1
  109. package/dist/packem_chunks/index2.js +48 -804
  110. package/dist/packem_chunks/index3.js +3 -7
  111. package/dist/packem_chunks/index4.js +801 -134
  112. package/dist/packem_chunks/index5.js +7 -73
  113. package/dist/packem_chunks/index6.js +73 -0
  114. package/dist/packem_chunks/index7.js +135 -0
  115. package/dist/packem_chunks/interface.js +2 -2
  116. package/dist/packem_chunks/keys-refresh.js +4 -4
  117. package/dist/packem_chunks/lean.js +3 -3
  118. package/dist/packem_chunks/list.js +3 -3
  119. package/dist/packem_chunks/loader.js +4 -4
  120. package/dist/packem_chunks/loader2.js +1 -1
  121. package/dist/packem_chunks/orchestrator.js +27 -27
  122. package/dist/packem_chunks/pre-mode.js +2 -2
  123. package/dist/packem_chunks/print-config.js +1 -1
  124. package/dist/packem_chunks/prompts.js +7 -7
  125. package/dist/packem_chunks/prune.js +3 -3
  126. package/dist/packem_chunks/publish-guards.js +1 -1
  127. package/dist/packem_chunks/resolveFormatter.js +5 -5
  128. package/dist/packem_chunks/run.js +1 -1
  129. package/dist/packem_chunks/security.js +1 -1
  130. package/dist/packem_chunks/shell-runner.js +1 -1
  131. package/dist/packem_chunks/slack.js +2 -2
  132. package/dist/packem_chunks/snapshot.js +2 -2
  133. package/dist/packem_chunks/stage-publisher.js +1 -1
  134. package/dist/packem_chunks/staged-registry.js +2 -2
  135. package/dist/packem_chunks/state.js +3 -3
  136. package/dist/packem_chunks/status.js +2 -2
  137. package/dist/packem_chunks/success-walk.js +4 -4
  138. package/dist/packem_chunks/sync.js +2 -2
  139. package/dist/packem_chunks/sync2.js +2 -2
  140. package/dist/packem_chunks/tar.js +3 -3
  141. package/dist/packem_chunks/tripwire.js +2 -2
  142. package/dist/packem_chunks/ts-loader.js +5 -9
  143. package/dist/packem_chunks/verify-lockfile.js +2 -2
  144. package/dist/packem_chunks/version-resolver.js +2 -2
  145. package/dist/packem_chunks/webhook.js +1 -1
  146. package/dist/packem_chunks/workflow-templates.js +5 -5
  147. package/dist/packem_chunks/workspace.js +2 -2
  148. package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +1 -0
  149. package/dist/packem_shared/Table-DyORjLji-CC9cYgCG.js +11 -0
  150. package/dist/packem_shared/{VisReleaseError-DMGRBTNO.js → VisReleaseError-DZtgcKf8.js} +1 -1
  151. package/dist/packem_shared/_commonjsHelpers-DTfxOvZk.js +1 -0
  152. package/dist/packem_shared/advisories-DZd1uGqa.js +1 -0
  153. package/dist/packem_shared/affected-selection-CoRXp5H4.js +1 -0
  154. package/dist/packem_shared/affected-shas-Dd0P7fGD.js +1 -0
  155. package/dist/packem_shared/ai-analysis-DSQQDFU9.js +68 -0
  156. package/dist/packem_shared/ai-fix-6nXZbecQ.js +43 -0
  157. package/dist/packem_shared/augment-COAiXSIx.js +4 -0
  158. package/dist/packem_shared/bin-C2eYtJ_N.js +1 -0
  159. package/dist/packem_shared/build-scripts-pdVmqXRm.js +1 -0
  160. package/dist/packem_shared/clean-DRiLimTx.js +1 -0
  161. package/dist/packem_shared/command-runtime-CiLVo4ED.js +1 -0
  162. package/dist/packem_shared/{compile-cache-B_Vf_WxT.js → compile-cache-DoMHRsRZ.js} +1 -1
  163. package/dist/packem_shared/createAdapter-F7GidOzU.js +1 -0
  164. package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +1 -0
  165. package/dist/packem_shared/cyclonedx-B1vzerwP.js +4 -0
  166. package/dist/packem_shared/dependency-scan-DBH2Qo4I.js +1 -0
  167. package/dist/packem_shared/docker-Bex05Qcn.js +59 -0
  168. package/dist/packem_shared/failure-log-D92tM0ie.js +2 -0
  169. package/dist/packem_shared/formatBytes-BHAzNIrn-DFIppnY0.js +4 -0
  170. package/dist/packem_shared/getRandomSpinner-4ZEcbTYv-DCyIuj19.js +1 -0
  171. package/dist/packem_shared/giget-D8Kwb0kD.js +2 -0
  172. package/dist/packem_shared/glob-Cyk1H9ZL-ox19CSsT.js +1 -0
  173. package/dist/packem_shared/index-B4AjSxHU.js +1 -0
  174. package/dist/packem_shared/index-BisalDCf.js +39 -0
  175. package/dist/packem_shared/{index-BWl4DbMp.js → index-BjdW45xX.js} +1 -1
  176. package/dist/packem_shared/index-DHD8wb6Z.js +22 -0
  177. package/dist/packem_shared/index-DXPSWMbG.js +1 -0
  178. package/dist/packem_shared/index.server-BAjDJSEu.js +2 -0
  179. package/dist/packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js +1 -0
  180. package/dist/packem_shared/license-DvlYdo6T.js +1 -0
  181. package/dist/packem_shared/lifecycle-CfTZQHOG.js +2 -0
  182. package/dist/packem_shared/lockfile-35RFsJDs.js +1 -0
  183. package/dist/packem_shared/lockfile-DhHAaHN5.js +1 -0
  184. package/dist/packem_shared/main-BP-w-K-6.js +1 -0
  185. package/dist/packem_shared/manifests-BNSmpPF_.js +1 -0
  186. package/dist/packem_shared/min-release-age-ChzTC7_I.js +34 -0
  187. package/dist/packem_shared/missing-package-json-C0keIt78.js +1 -0
  188. package/dist/packem_shared/native-config-sync-BSzU4qUO.js +21 -0
  189. package/dist/packem_shared/osv-bloom-1JS__1or.js +2 -0
  190. package/dist/packem_shared/otelPlugin-D8LL2-4L.js +1 -0
  191. package/dist/packem_shared/package-version-Bb7KGF36.js +4 -0
  192. package/dist/packem_shared/packument-C55kVxcQ.js +1 -0
  193. package/dist/packem_shared/{peer-warnings-BXAzXqY3.js → peer-warnings-CmYSxvql.js} +1 -1
  194. package/dist/packem_shared/pm-runner-de-jCq8q.js +1 -0
  195. package/dist/packem_shared/project-name-filter-DYaIbrXa.js +7 -0
  196. package/dist/packem_shared/{prompt-BSAy8SMH.js → prompt-DMzaQEVa.js} +1 -1
  197. package/dist/packem_shared/provenance-CvfQEJPQ.js +1 -0
  198. package/dist/packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js +1 -0
  199. package/dist/packem_shared/registry-keys-DmBrAlhg.js +1 -0
  200. package/dist/packem_shared/resolve-explicit-DYaHAVDg.js +5 -0
  201. package/dist/packem_shared/resolve-runtime-C7NBCA1C.js +1 -0
  202. package/dist/packem_shared/run-file-jMngGQhs.js +1 -0
  203. package/dist/packem_shared/runtime-check-BklgEMkC.js +1 -0
  204. package/dist/packem_shared/s1ngularity-C8sva2SO.js +1 -0
  205. package/dist/packem_shared/scan-progress-aVHGZYWf.js +2 -0
  206. package/dist/packem_shared/selectors-B7lSFz7l.js +3 -0
  207. package/dist/packem_shared/signatures-oZ_2IneN.js +2 -0
  208. package/dist/packem_shared/{slug-DoueYuLo.js → slug-OBHcH7wV.js} +1 -1
  209. package/dist/packem_shared/spinner-CbJfWYwB.js +1 -0
  210. package/dist/packem_shared/sticky-comment-DjhyCIZt.js +1 -0
  211. package/dist/packem_shared/subtree-DtmcKAJK.js +2 -0
  212. package/dist/packem_shared/symbols-BXDZ_sKt.js +1 -0
  213. package/dist/packem_shared/tabs-BilwonkM.js +1 -0
  214. package/dist/packem_shared/target-merge-DCGow6Kw.js +4 -0
  215. package/dist/packem_shared/target-options-d_rIrLyq.js +1 -0
  216. package/dist/packem_shared/toolchain-DY11tPCw.js +5 -0
  217. package/dist/packem_shared/typosquats-Cdsnf6aN.js +1 -0
  218. package/dist/packem_shared/use-measured-height-BPQg2q_p.js +1 -0
  219. package/dist/packem_shared/utils-DQFHJn72.js +1 -0
  220. package/dist/packem_shared/verify-D8wYvB85.js +1 -0
  221. package/dist/packem_shared/vis-update-app-ngwL2mRv.js +1 -0
  222. package/dist/packem_shared/vis-user-error-CAu9wIbe.js +30 -0
  223. package/dist/packem_shared/watch-Dswvj6Zp.js +1 -0
  224. package/dist/packem_shared/watch-loop-COWvvSbR.js +11 -0
  225. package/dist/packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js +1 -0
  226. package/dist/release/core/changelog/index.d.ts +62 -2
  227. package/dist/release/core/package-managers/index.d.ts +25 -1
  228. package/dist/release/core/package-managers/index.js +1 -1
  229. package/dist/release/core/version-actions/index.d.ts +47 -2
  230. package/dist/release/core/version-actions/index.js +1 -1
  231. package/dist/release/index.d.ts +100 -1
  232. package/dist/release/index.js +1 -1
  233. package/dist/release/plugin-sdk.d.ts +16 -1
  234. package/dist/release/plugin-sdk.js +1 -1
  235. package/dist/release/presets.js +1 -1
  236. package/dist/release/types.js +1 -1
  237. package/dist/runtime/preload.js +1 -1
  238. package/index.js +26 -26
  239. package/package.json +14 -14
  240. package/dist/packem_chunks/detect2.js +0 -8
  241. package/dist/packem_chunks/registry.js +0 -48
  242. package/dist/packem_shared/ReleaseClient-BY4OZNCK.js +0 -1
  243. package/dist/packem_shared/_commonjsHelpers-B5Y90VFO.js +0 -1
  244. package/dist/packem_shared/advisories-DsXRmIA5.js +0 -1
  245. package/dist/packem_shared/affected-selection-BE6VFCDV.js +0 -1
  246. package/dist/packem_shared/affected-shas-BKEu4RZc.js +0 -1
  247. package/dist/packem_shared/ai-analysis-DikAj6rX.js +0 -68
  248. package/dist/packem_shared/ai-fix-bfWo0cZX.js +0 -43
  249. package/dist/packem_shared/augment-BkJxi_GW.js +0 -4
  250. package/dist/packem_shared/bin-B-TytgzW.js +0 -1
  251. package/dist/packem_shared/build-scripts-DWypBQ--.js +0 -1
  252. package/dist/packem_shared/clean-DWjQl14S.js +0 -1
  253. package/dist/packem_shared/command-runtime-DQ7ZpLYL.js +0 -1
  254. package/dist/packem_shared/createAdapter-bU4DIP3F.js +0 -1
  255. package/dist/packem_shared/createVersionActions-BK43SNDH.js +0 -1
  256. package/dist/packem_shared/cyclonedx-DLBi65MV.js +0 -4
  257. package/dist/packem_shared/dependency-scan-ZLOuLkGN.js +0 -1
  258. package/dist/packem_shared/docker-B4zAZCZG.js +0 -59
  259. package/dist/packem_shared/en-BDYMmM2_.js +0 -27
  260. package/dist/packem_shared/failure-log-DyhWPqno.js +0 -2
  261. package/dist/packem_shared/giget-CAxjpwew.js +0 -2
  262. package/dist/packem_shared/glob-BUjyjdE8-Dp_QcayW.js +0 -1
  263. package/dist/packem_shared/index-BAe6e0XE.js +0 -1
  264. package/dist/packem_shared/index-BLtnel38.js +0 -35
  265. package/dist/packem_shared/index-CuKDxOCI.js +0 -1
  266. package/dist/packem_shared/index-tNFGWxc0.js +0 -39
  267. package/dist/packem_shared/index.server-CusjRLCh.js +0 -2
  268. package/dist/packem_shared/license-t5KnNX6v.js +0 -1
  269. package/dist/packem_shared/lifecycle-KY9umOg6.js +0 -2
  270. package/dist/packem_shared/lockfile-YAuZf1gh.js +0 -1
  271. package/dist/packem_shared/main-D_cam4hv.js +0 -1
  272. package/dist/packem_shared/manifests-BwTn_1ad.js +0 -1
  273. package/dist/packem_shared/min-release-age-6avfn81h.js +0 -34
  274. package/dist/packem_shared/missing-package-json-Cl0vdz6K.js +0 -1
  275. package/dist/packem_shared/native-config-sync-CHMCJx7H.js +0 -21
  276. package/dist/packem_shared/osv-bloom-DdqDnLCt.js +0 -2
  277. package/dist/packem_shared/otelPlugin-DmKDBaPo.js +0 -1
  278. package/dist/packem_shared/package-version-BNRJ3o9C.js +0 -4
  279. package/dist/packem_shared/packument-B9-WqReu.js +0 -1
  280. package/dist/packem_shared/pm-runner-DRybtzOV.js +0 -1
  281. package/dist/packem_shared/project-name-filter-Dw0fC6IO.js +0 -7
  282. package/dist/packem_shared/provenance-CLxuqCfL.js +0 -1
  283. package/dist/packem_shared/readJsonSync-DweZd5ZA-CtrDlqpb.js +0 -1
  284. package/dist/packem_shared/registry-keys-cTN24144.js +0 -1
  285. package/dist/packem_shared/resolve-explicit-Uw6WQl9R.js +0 -5
  286. package/dist/packem_shared/resolve-runtime-DztanwkZ.js +0 -1
  287. package/dist/packem_shared/run-file-CaE5_xBY.js +0 -1
  288. package/dist/packem_shared/runtime-check-C32yE57I.js +0 -1
  289. package/dist/packem_shared/s1ngularity-BIYhg82u.js +0 -1
  290. package/dist/packem_shared/scan-progress-DWfY4zkp.js +0 -2
  291. package/dist/packem_shared/selectors-D2j4M9Ul.js +0 -3
  292. package/dist/packem_shared/signatures-C8iQ5fUq.js +0 -2
  293. package/dist/packem_shared/sticky-comment-D6_7-w8T.js +0 -1
  294. package/dist/packem_shared/subtree-DSm0QEoE.js +0 -2
  295. package/dist/packem_shared/symbols-DPTlrJ3B.js +0 -1
  296. package/dist/packem_shared/target-merge-DLxJTcxn.js +0 -11
  297. package/dist/packem_shared/target-options-3t4-2F-F.js +0 -1
  298. package/dist/packem_shared/toolchain-BPzbahcQ.js +0 -5
  299. package/dist/packem_shared/typosquats-BWrmhh36.js +0 -1
  300. package/dist/packem_shared/use-measured-height-BwAwGHjw.js +0 -1
  301. package/dist/packem_shared/utils-CRueU43T.js +0 -1
  302. package/dist/packem_shared/verify-CzUPT6Uk.js +0 -1
  303. package/dist/packem_shared/vis-update-app-D6Wq8ZHM.js +0 -1
  304. package/dist/packem_shared/vis-user-error-CfM4_ORo.js +0 -30
  305. package/dist/packem_shared/watch-D_oAxW_Z.js +0 -1
  306. package/dist/packem_shared/watch-loop-BrjblOz5.js +0 -11
@@ -1,3 +1,27 @@
1
- import{createRequire as Me}from"node:module";import{l as e,m as n,i as o,r as p,X as Re,R as ze}from"./catalog.js";import"../packem_shared/en-BDYMmM2_.js";import{I as Ge}from"../packem_shared/index-BWl4DbMp.js";import{A as _e}from"../packem_shared/pm-runner-DRybtzOV.js";import{o as We,w as ne,l as Xe,z as $e,J as Ve,d as He}from"../packem_shared/index-BLtnel38.js";import{J as Je,I as qe,K as $,M as Ye}from"./cli-main.js";import{Dialog as Ke}from"@visulima/tui-kit/dialog";import{Tab as Qe}from"@visulima/tui-kit/tab";import{Tabs as Ze}from"@visulima/tui-kit/tabs";import{TextInput as se}from"@visulima/tui-kit/text-input";import{ScrollBar as ke}from"@visulima/tui-kit/scroll-bar";import{ScrollView as et}from"@visulima/tui-kit/scroll-view";let Le;const Be=s=>(Le??=Me(import.meta.url))(s),X=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ne=s=>{if(typeof X<"u"&&X.versions&&X.versions.node){const[t,i]=X.versions.node.split(".").map(Number);if(t>22||t===22&&i>=3||t===20&&i>=16)return X.getBuiltinModule(s)}return Be(s)},{writeFileSync:Ue}=Ne("node:fs"),tt=(s,{whitespace:t=!0}={})=>s.replace(We,i=>i.startsWith('"')||i[1]==="*"&&!i.endsWith("*/")?i:t?i.replaceAll(/\S/g," "):""),B=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],ot=s=>{const t=ne(s,".devcontainer","devcontainer.json");if(!Xe(t))return null;const i=$e(t),l=tt(i),c=l!==i;let r;try{r=JSON.parse(l)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:c}},rt=(s,t,i)=>{const l=i?Ve(i):ne(s,".devcontainer"),c=i??ne(l,"devcontainer.json");He(l),Ue(c,`${JSON.stringify(t,null,2)}
2
- `,"utf8")},nt={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},it=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],fe=(s,t,i)=>{const l=[],c=new Set(i.map(a=>typeof a=="string"?a:a.target));if(s)for(const a of nt[s])c.has(a.target)||l.push(a);const r=Object.keys(t);for(const{featureMatch:a,mounts:m}of it)if(r.some(g=>g.includes(a)))for(const g of m)c.has(g.target)||l.push(g);return l},F=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],V=s=>structuredClone(s);class st{#r=new Set;#e;constructor(t,i,l=null){const c=t===null,r=t??{name:""},a=V(r);this.#e={config:a,detectedPm:l,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:i,isDirty:!1,mode:c?"create":"edit",originalConfig:c?null:V(r),section:"general",showTemplateSelector:c,suggestedMounts:fe(l,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#r.add(t),()=>{this.#r.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const t=(F.indexOf(this.#e.section)+1)%F.length;this.setSection(F[t])}previousSection(){const t=(F.indexOf(this.#e.section)-1+F.length)%F.length;this.setSection(F[t])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const i=Math.max(0,Math.min(t,B.length-1));i!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:i})}applyTemplate(t){const i=B.find(l=>l.id===t);i&&this.#t(this.#o({...this.#e,config:V(i.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const i={...this.#e.config.features};i[t]===void 0?i[t]={}:delete i[t],this.#t(this.#o({...this.#e,config:{...this.#e.config,features:i},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const i=this.#e.config.forwardPorts??[];if(i.includes(t))return;const l=[...i,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:l},isDirty:!0})}removePort(t){const i=[...this.#e.config.forwardPorts??[]];i.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:i.length>0?i:void 0},isDirty:!0})}toggleExtension(t){const i={...this.#e.config.customizations},l={...i.vscode},c=[...l.extensions??[]],r=c.indexOf(t);r===-1?c.push(t):c.splice(r,1),l.extensions=c.length>0?c:void 0,i.vscode=l.extensions||l.settings?l:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:i.vscode||i.jetbrains?i:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,i,l){const c=t==="container"?"containerEnv":"remoteEnv",r={...this.#e.config[c],[i]:l};this.#t({...this.#e,config:{...this.#e.config,[c]:r},isDirty:!0})}removeEnvVar(t,i){const l=t==="container"?"containerEnv":"remoteEnv",c={...this.#e.config[l]};delete c[i],this.#t({...this.#e,config:{...this.#e.config,[l]:Object.keys(c).length>0?c:void 0},isDirty:!0})}addMount(t){const i=[...this.#e.config.mounts??[],t];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:i},isDirty:!0}))}removeMount(t){const i=[...this.#e.config.mounts??[]];i.splice(t,1),this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:i.length>0?i:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,i){this.#t({...this.#e,config:{...this.#e.config,[t]:i||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:V(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=V(this.#e.config);for(const[i,l]of Object.entries(t))(l===""||l===void 0)&&delete t[i];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#o(t){return{...t,suggestedMounts:fe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const i of this.#r)try{i()}catch{}}}const pe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],xe=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],ce=s=>{if(!s)return xe;const t=s.toLowerCase();return xe.filter(i=>i.name.toLowerCase().includes(t)||i.id.toLowerCase().includes(t)||i.description.toLowerCase().includes(t))},le=s=>{if(!s)return pe;const t=s.toLowerCase();return pe.filter(i=>i.name.toLowerCase().includes(t)||i.id.toLowerCase().includes(t)||i.description.toLowerCase().includes(t))},Ce=["dockerComposeFile","service"],ct={dockerComposeFile:"Compose File",service:"Service"},je={dockerComposeFile:"docker-compose.yml",service:"app"},lt={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},at=({config:s,fieldEditing:t,fieldIndex:i,onUpdate:l})=>{const c=!!s.dockerComposeFile,r=!!(s.image||s.build);return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsx(n,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),r&&c&&e.jsx(n,{marginBottom:1,children:e.jsx(o,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ce.map((a,m)=>{const g=m===i,f=s[a]??"",y=Array.isArray(s[a])?s[a].join(", "):f;return e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{children:[e.jsx(n,{width:20,children:e.jsxs(o,{bold:g,color:g?"cyan":"white",children:[g?"❯ ":" ",ct[a],":"]})}),e.jsx(n,{flexGrow:1,children:g&&t?e.jsx(se,{defaultValue:y,onChange:x=>{l({[a]:x||void 0})},placeholder:je[a]}):e.jsx(o,{color:y?"white":"gray",children:y||je[a]})})]}),e.jsx(n,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:lt[a]})})]},a)}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},dt=Ce.length,ut=({config:s,fieldIndex:t})=>{const i=s.containerEnv??{},l=s.remoteEnv??{},c=Object.keys(i),r=Object.keys(l),a=c.length,m=c.length+1,g=m+r.length,f=t<=a,y=t>a;return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsxs(n,{borderColor:f?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(n,{flexShrink:0,marginBottom:c.length>0?1:0,children:[e.jsx(o,{bold:!0,color:f?"cyan":"white",children:"containerEnv"}),e.jsx(o,{dimColor:!0,children:" — baked into the container image"})]}),c.map((x,v)=>{const b=v===t;return e.jsx(n,{flexShrink:0,children:e.jsxs(o,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:i[x]})]})},x)}),e.jsx(n,{flexShrink:0,marginTop:c.length>0?1:0,children:e.jsxs(o,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(n,{borderColor:y?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(n,{flexShrink:0,marginBottom:r.length>0?1:0,children:[e.jsx(o,{bold:!0,color:y?"cyan":"white",children:"remoteEnv"}),e.jsx(o,{dimColor:!0,children:" — set at runtime by the IDE"})]}),r.map((x,v)=>{const b=m+v===t;return e.jsx(n,{flexShrink:0,children:e.jsxs(o,{color:b?"cyan":void 0,inverse:b,wrap:"truncate",children:[b?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:l[x]})]})},x)}),e.jsx(n,{flexShrink:0,marginTop:r.length>0?1:0,children:e.jsxs(o,{color:t===g?"cyan":"gray",inverse:t===g,children:[" ","+ Add variable..."]})})]}),e.jsx(n,{flexShrink:0,marginTop:1,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[e.jsx(o,{bold:!0,color:"white",children:"a"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},ht=s=>{const t=Object.keys(s.containerEnv??{}).length,i=Object.keys(s.remoteEnv??{}).length;return t+1+i+1},mt=({config:s,fieldIndex:t,scrollOffset:i,searchText:l,viewportHeight:c})=>{const r=p.useMemo(()=>new Set(s.customizations?.vscode?.extensions),[s.customizations?.vscode?.extensions]),a=p.useMemo(()=>le(l),[l]),m=a.length,g=m>c&&c>0;return e.jsxs(n,{flexDirection:"column",flexGrow:1,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),l&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:l})," ","(",a.length," ","results)"]})]}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(n,{flexDirection:"column",marginTop:-i,children:a.map((f,y)=>{const x=y===t,v=r.has(f.id);return e.jsxs(n,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(o,{dimColor:!0,children:[" ","-",f.id]})]})})]},f.id)})})}),g&&e.jsx(n,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(ke,{contentHeight:m,placement:"inset",scrollOffset:i,style:"block",viewportHeight:c})})]}),a.length===0&&e.jsx(n,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No extensions match the search."})})]})},gt=({config:s,fieldIndex:t,scrollOffset:i,searchText:l,viewportHeight:c})=>{const r=p.useMemo(()=>new Set(Object.keys(s.features??{})),[s.features]),a=p.useMemo(()=>ce(l),[l]),m=a.length,g=m>c&&c>0;return e.jsxs(n,{flexDirection:"column",flexGrow:1,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),l&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:l})," ","(",a.length," ","results)"]})]}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(n,{flexDirection:"column",marginTop:-i,children:a.map((f,y)=>{const x=y===t,v=r.has(f.id);return e.jsxs(n,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:v?"white":"gray",children:[" ",v?"☑":"☐"," "]}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[f.name,e.jsxs(o,{dimColor:!0,children:[" ","-",f.description]})]})})]},f.id)})})}),g&&e.jsx(n,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(ke,{contentHeight:m,placement:"inset",scrollOffset:i,style:"block",viewportHeight:c})})]}),a.length===0&&e.jsx(n,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No features match the search."})})]})},ie=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],ft={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},ve={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},Y=["privileged","overrideCommand"],pt={overrideCommand:"Override Command",privileged:"Privileged"},xt=ie.length+Y.length,jt=({config:s,fieldEditing:t,fieldIndex:i,onUpdate:l})=>e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsx(n,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"General Configuration"})}),ie.map((c,r)=>{const a=r===i,m=s[c]??"";return e.jsxs(n,{marginBottom:1,children:[e.jsx(n,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",ft[c],":"]})}),e.jsx(n,{flexGrow:1,children:a&&t?e.jsx(se,{defaultValue:m,onChange:g=>{l({[c]:g})},placeholder:ve[c]}):e.jsx(o,{color:m?"white":"gray",children:m||ve[c]})})]},c)}),Y.map((c,r)=>{const a=ie.length+r===i,m=s[c]??!1;return e.jsxs(n,{marginBottom:r<Y.length-1?1:0,children:[e.jsx(n,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",pt[c],":"]})}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{color:m?"green":"gray",children:[m?"yes":"no",a&&e.jsx(o,{dimColor:!0,children:" (Space to toggle)"})]})})]},c)}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Se=xt,re=Y,Ee=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],vt={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},yt={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},bt=({config:s,fieldEditing:t,fieldIndex:i,onSetCommand:l})=>e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsx(n,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),Ee.map((c,r)=>{const a=r===i,m=s[c],g=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsx(n,{children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",vt[c]]})}),e.jsx(n,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:yt[c]})}),e.jsx(n,{paddingLeft:4,children:a&&t?e.jsx(se,{defaultValue:g,onChange:f=>{l(c,f)},placeholder:"e.g. npm install"}):e.jsx(o,{color:g?"green":"gray",children:g||"(not set)"})})]},c)}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),wt=Ee.length,ye=s=>typeof s=="string"?s:`[${s.type}] ${s.source} → ${s.target}`,kt=({addingMount:s,config:t,detectedPm:i,fieldIndex:l,mountPhase:c,mountSource:r,mountTarget:a,mountType:m,suggestedMounts:g})=>{const f=t.mounts??[];return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[f.length," ","mounts"]}),i&&e.jsxs(o,{dimColor:!0,children:["— detected:"," ",e.jsx(o,{color:"white",children:i})]})]}),g.length>0&&!s&&e.jsxs(n,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(n,{flexShrink:0,children:[e.jsx(o,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(o,{dimColor:!0,children:[" ","— press"," ",e.jsx(o,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),g.map((y,x)=>e.jsx(n,{flexShrink:0,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[" + ",ye(y)]})},`suggestion-${String(x)}`))]}),f.length>0&&e.jsx(n,{flexDirection:"column",marginBottom:1,children:f.map((y,x)=>{const v=x===l;return e.jsxs(n,{flexShrink:0,height:1,children:[e.jsx(o,{children:v?">":" "}),e.jsx(n,{flexGrow:1,children:e.jsxs(o,{bold:v,inverse:v,wrap:"truncate",children:[" ",ye(y)]})})]},`mount-${String(x)}`)})}),!s&&e.jsx(n,{flexShrink:0,children:e.jsxs(o,{color:l===f.length?"cyan":"gray",inverse:l===f.length,children:[" ","+ Add mount..."]})}),s&&e.jsxs(n,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(n,{flexShrink:0,marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(n,{flexShrink:0,children:[e.jsx(n,{width:12,children:e.jsxs(o,{bold:c==="source",color:c==="source"?"cyan":"white",children:[c==="source"?"❯ ":" ","Source:"]})}),e.jsx(o,{color:r?"yellow":"gray",children:r||(c==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(n,{flexShrink:0,children:[e.jsx(n,{width:12,children:e.jsxs(o,{bold:c==="target",color:c==="target"?"cyan":"white",children:[c==="target"?"❯ ":" ","Target:"]})}),e.jsx(o,{color:a?"yellow":"gray",children:a||(c==="target"?"_":"/container/path")})]}),e.jsxs(n,{flexShrink:0,children:[e.jsx(n,{width:12,children:e.jsxs(o,{bold:c==="type",color:c==="type"?"cyan":"white",children:[c==="type"?"❯ ":" ","Type:"]})}),c==="type"?e.jsxs(o,{children:[e.jsx(o,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(o,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(o,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(o,{color:"gray",children:m})]}),e.jsx(n,{flexShrink:0,marginTop:1,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:c==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),f.length===0&&!s&&g.length===0&&e.jsx(n,{marginTop:1,children:e.jsx(o,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ct=({addingPort:s,addPortValue:t,config:i,fieldIndex:l})=>{const c=i.forwardPorts??[],r=l===c.length;return e.jsxs(n,{flexDirection:"column",paddingX:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(o,{dimColor:!0,children:[" ","(",c.length," ","ports)"]})]}),c.map((a,m)=>{const g=m===l;return e.jsx(n,{children:e.jsxs(o,{color:g?"cyan":void 0,inverse:g,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(n,{marginTop:c.length>0?1:0,children:e.jsxs(o,{color:r?"cyan":"gray",inverse:r,children:[" ",r&&s?e.jsxs(o,{children:["Enter port:"," ",e.jsx(o,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(n,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ",r?"type port number, Enter to confirm":"select"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},St=({focused:s,hadComments:t,jsonPreview:i,mode:l,scrollRef:c})=>e.jsxs(n,{borderColor:s?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(n,{flexShrink:0,paddingX:1,children:[e.jsx(o,{bold:!0,color:s?"cyan":"white",children:"Preview"}),e.jsxs(o,{dimColor:!0,children:[" ","(",l==="create"?"new":"edit",")"]})]}),t&&l==="edit"&&e.jsx(n,{flexShrink:0,paddingX:1,children:e.jsx(o,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(et,{flexGrow:1,ref:c,scrollbar:!0,scrollbarColor:"gray",children:i.split(`
3
- `).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Et=s=>{const t=[],i=[],l=[];if(!s.image&&!s.build&&!s.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),s.build&&(s.image&&i.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),s.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),s.dockerComposeFile&&!s.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),s.features!==void 0&&(typeof s.features!="object"||Array.isArray(s.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),s.forwardPorts)if(Array.isArray(s.forwardPorts))for(const[c,r]of s.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(c)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return s.customizations?.vscode?.extensions&&!Array.isArray(s.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),s.customizations?.vscode?.settings&&typeof s.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),s.name||l.push({field:"name",message:"Consider adding a name for better identification"}),(!s.features||Object.keys(s.features).length===0)&&l.push({field:"features",message:"Consider adding features for common tools"}),(!s.customizations?.vscode?.extensions||s.customizations.vscode.extensions.length===0)&&l.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),s.privileged&&i.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:l,valid:t.length===0,warnings:i}},be=80,we=15,It=120,Ie=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Tt=new Map(Ie.map(s=>[s.id,s.description])),Dt=(s,t,i,l)=>{switch(s){case"compose":return dt;case"environment":return ht(t);case"extensions":return le(l).length;case"features":return ce(i).length;case"general":return Se;case"lifecycle":return wt;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Pt=({onSave:s,store:t})=>{const{exit:i}=Je(),{columns:l,rows:c}=qe(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[g,f]=p.useState(!1),[y,x]=p.useState(!1),[v,b]=p.useState(null),[w,I]=p.useState("editor"),[H,ae]=p.useState(0),[K,Q]=p.useState(!1),[de,N]=p.useState(""),[R,z]=p.useState(null),[G,T]=p.useState(""),[ue,D]=p.useState(""),[_,A]=p.useState("key"),[Z,J]=p.useState(!1),[ee,O]=p.useState(""),[te,M]=p.useState(""),[he,U]=p.useState("volume"),[C,L]=p.useState("source"),oe=p.useRef(null),P=p.useRef(null),E=p.useRef(null),q=p.useRef(!0);p.useEffect(()=>(q.current=!0,()=>{q.current=!1,E.current&&clearTimeout(E.current)}),[]);const me=Dt(r.section,r.config,r.featureSearch,r.extensionSearch),W=Math.max(1,c-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||ae(u=>r.fieldIndex>=u+W?r.fieldIndex-W+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,W]),p.useEffect(()=>{ae(0)},[r.section,r.featureSearch,r.extensionSearch]);const Te=p.useCallback(()=>{const u=t.cleanConfig(),h=Et(u);if(!h.valid){const j=h.errors[0];b(j?`Error: ${j.message}`:"Validation failed"),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{q.current&&b(null)},3e3);return}s(u),t.markClean();const d=h.warnings.length;b(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{q.current&&b(null)},2e3)},[s,t]);$((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=B[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),$((u,h)=>{if(h.escape){Q(!1),N("");return}if(h.return){const d=Number.parseInt(de,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),Q(!1),N("");return}if(h.backspace){N(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&N(d=>d+u)},{isActive:K}),$((u,h)=>{if(h.escape){z(null),T(""),D(""),A("key");return}if(h.return){if(_==="key"&&G){A("value");return}if(_==="value"&&G){t.addEnvVar(R,G,ue),z(null),T(""),D(""),A("key");return}}if(h.backspace){_==="key"?T(d=>d.slice(0,-1)):D(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(_==="key"?T(d=>d+u):D(d=>d+u))},{isActive:R!==null}),$((u,h)=>{if(h.escape){J(!1),O(""),M(""),L("source");return}if(h.return){if(C==="source"&&ee){L("target");return}if(C==="target"&&te){L("type");return}if(C==="type"){t.addMount({source:ee,target:te,type:he}),J(!1),O(""),M(""),L("source");return}}if(C==="type"){switch(u){case"1":{U("volume");break}case"2":{U("bind");break}case"3":{U("tmpfs");break}}return}if(h.backspace){C==="source"?O(d=>d.slice(0,-1)):C==="target"&&M(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="source"?O(d=>d+u):C==="target"&&M(d=>d+u))},{isActive:Z}),$((u,h)=>{if(u==="c"&&h.ctrl){i();return}if(!g){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?oe.current?.scrollBy(1):h.upArrow||u==="k"?oe.current?.scrollBy(-1):u==="q"&&(m(!1),f(!0));return}if(y){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?f(!0):i();return}if(u==="s"){Te();return}if(h.tab){I(d=>d==="editor"?"preview":"editor");return}if(w==="preview"){if(h.downArrow||u==="j"){P.current?.scrollBy(1);return}if(h.upArrow||u==="k"){P.current?.scrollBy(-1);return}if(h.pageDown){P.current?.scrollBy(10);return}if(h.pageUp){P.current?.scrollBy(-10);return}if(h.home){P.current?.scrollToTop();return}if(h.end){P.current?.scrollToBottom();return}h.escape&&I("editor");return}if(h.downArrow||u==="j"){me>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,me-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,S=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(z("container"),T(""),D(""),A("key")):r.fieldIndex===S&&(z("remote"),T(""),D(""),A("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(J(!0),O(""),M(""),U("volume"),L("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(Q(!0),N(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const d=le(r.extensionSearch)[r.fieldIndex];d&&t.toggleExtension(d.id);break}case"features":{const d=ce(r.featureSearch)[r.fieldIndex];d&&t.toggleFeature(d.id);break}case"general":{const d=Se-re.length,j=r.fieldIndex-d;if(j>=0&&j<re.length){const S=re[j];t.updateConfig({[S]:!r.config[S]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";z(j),T(""),D(""),A("key")}else r.section==="mounts"&&(J(!0),O(""),M(""),U("volume"),L("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const S=r.fieldIndex-d.length-1;S>=0&&S<j.length&&(t.removeEnvVar("remote",j[S]),j.length===1||S>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!K&&R===null&&!Z});const De=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(l<be||c<we)return e.jsx(n,{alignItems:"center",height:c,justifyContent:"center",width:l,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",l,"x",c,"), need"," ",be,"x",we]})});if(r.showTemplateSelector)return e.jsx(n,{alignItems:"center",flexDirection:"column",height:c,justifyContent:"center",width:l,children:e.jsxs(n,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(n,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),B.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(n,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(n,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let k;switch(r.section){case"compose":{k=e.jsx(at,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{k=e.jsxs(n,{flexDirection:"column",children:[e.jsx(ut,{config:r.config,fieldIndex:r.fieldIndex}),R!==null&&e.jsx(n,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",R," ","env:"," ",_==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:G||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[G,"=",e.jsx(o,{color:"yellow",children:ue||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{k=e.jsx(mt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:H,searchText:r.extensionSearch,viewportHeight:W});break}case"features":{k=e.jsx(gt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:H,searchText:r.featureSearch,viewportHeight:W});break}case"general":{k=e.jsx(jt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{k=e.jsx(bt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{k=e.jsx(kt,{addingMount:Z,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:C,mountSource:ee,mountTarget:te,mountType:he,suggestedMounts:r.suggestedMounts});break}case"ports":{k=e.jsx(Ct,{addingPort:K,addPortValue:de,config:r.config,fieldIndex:r.fieldIndex});break}default:k=e.jsx(o,{children:"Unknown section"})}const Pe=e.jsxs(n,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(n,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(n,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(n,{paddingX:1,children:[v&&e.jsxs(o,{color:v.startsWith("Error")?"red":"green",children:[v," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!v&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Fe=e.jsxs(Ke,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:oe,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(n,{flexDirection:"column",marginBottom:1,children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(n,{flexDirection:"column",children:[e.jsxs(n,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Ae=e.jsx(St,{focused:w==="preview",hadComments:r.hadComments,jsonPreview:De,mode:r.mode,scrollRef:P}),ge=l>=It,Oe=ge?Math.floor(l*.38):0;return e.jsxs(n,{flexDirection:"column",height:c,width:l,children:[e.jsxs(n,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(n,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(Ze,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),I("editor")},showIndex:!1,children:Ie.map(({id:u,label:h})=>e.jsx(Qe,{name:u,children:h},u))})}),e.jsx(n,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Tt.get(r.section)??""})}),e.jsxs(n,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(n,{borderColor:w==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:k}),ge&&e.jsx(n,{flexShrink:0,width:Oe,children:Ae})]}),Pe,e.jsx(Ye,{autoExitSeconds:3,onCancel:()=>{f(!1)},visible:g}),Fe]})},Xt=async({logger:s,options:t,workspaceRoot:i})=>{if(!i)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const l=i,c=t.template,r=t.output,a=!!process.stdout.isTTY&&!Ge;let m=null;try{m=_e(l).name}catch{}const g=ot(l);let f=g?.config??null;const y=g?.hadComments??!1;if(c&&!g){const w=B.find(I=>I.id===c);if(!w){const I=B.map(H=>H.id).join(", ");throw new Error(`Unknown template "${c}". Valid templates: ${I}`)}f=w.config}if(!a){f?s.info(JSON.stringify(f,null,2)):(s.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),v=new st(f,y,m);c&&!g&&v.dismissTemplateSelector();let b=null;if(await Re(ze.createElement(Pt,{onSave:w=>{rt(l,w,r),b=w},store:v}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),b){const w=r??".devcontainer/devcontainer.json";s.info(`DevContainer config saved to ${w}`)}};export{Xt as default};
1
+ import{createRequire as wt}from"node:module";import{a as x,$ as it,U as yt,v as at,e as P,q as Tt}from"../packem_shared/index-DHD8wb6Z.js";import{y as m,X as E,m as b,v as vt,j as St}from"./catalog.js";import ot from"./index.js";import{x as ct}from"../packem_shared/main-BP-w-K-6.js";import{y as B}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{C as $t}from"./cli-main.js";import{l as At}from"../packem_shared/spinner-CbJfWYwB.js";import{C as dt,D as F,T as lt}from"../packem_shared/symbols-BXDZ_sKt.js";import{b as z,F as C,q as D,X as L,J as It}from"../packem_shared/index.server-BAjDJSEu.js";import{withEnhancedPath as Mt}from"@visulima/task-runner";let mt;const kt=t=>(mt??=wt(import.meta.url))(t),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=t=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[e,s]=M.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return M.getBuiltinModule(t)}return kt(t)},{readFileSync:bt,writeFileSync:xt,unlinkSync:Ct}=G("node:fs"),{randomBytes:Et}=G("node:crypto"),{availableParallelism:V}=G("node:os");class A extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class Rt extends A{}class T extends A{}class W extends A{}class j extends A{stderr;constructor(e,s,r){super(e,r),this.stderr=s}}class X extends A{}class $ extends A{commandTitle;constructor(e,s,r){super(s,r),this.commandTitle=e}}const ut=t=>t.includes("/"),N=(t,e)=>e?t.toLowerCase():t,jt=(t,e,s,r={})=>{const n=ut(t),a=r.caseInsensitive===!0,c=N(t,a),i=[];for(const o of e){const l=n?x(s,o):it(o);ot(c,N(l,a))&&i.push(o)}return i},_t=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(a=>{for(const c of e){const i=ut(c)?x(s,a):it(a),o=N(c,n);if(ot(o,N(i,n)))return!1}return!0})},U=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",_=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Pt=(t,e)=>{const s=x(t,e);return s===""||!s.startsWith("..")&&!at(s)},Ft=(t,e)=>{let s;for(const r of e)Pt(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},Nt=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),a=(o,l,f,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],g=new Map;for(const h of f){const p=Ft(h,u)??t.cwd,k=g.get(p)??[];k.push(x(p,h)),g.set(p,k)}for(const h of[...g.keys()].sort()){const p=x(t.cwd,h)||".";d.push({command:o.command,cwd:h,files:g.get(h)??[],id:n(),source:"string",title:`${o.command} — ${p}`})}return}if(o.cwd!==void 0){const u=yt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:f,id:n(),source:"string",title:`${o.command} — ${x(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:n(),source:"string",title:o.command})},c=async(o,l,f,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:n(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,f,d);return}if(_(o)){a(o,l,f,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const g of u)if(typeof g=="string")d.push({command:g,files:l,id:n(),source:"function",title:g});else if(_(g))a(g,l,f,d);else if(U(g))d.push({files:l,id:n(),run:g.task,source:"custom",title:g.title});else throw new T("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(_(u)){a(u,l,f,d);return}if(U(u)){d.push({files:l,id:n(),run:u.task,source:"custom",title:u.title});return}throw new T("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(U(o)){d.push({files:l,id:n(),run:o.task,source:"custom",title:o.title});return}throw new T("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},i=[];for(const[o,l]of Object.entries(t.config)){const f=jt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(f.length===0)continue;const d=t.relative?f.map(g=>x(t.cwd,g)):f,u=[];await c(l,d,f,u),u.length!==0&&i.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${f.length} file${f.length===1?"":"s"}`})}return i},Ot=async t=>{if(t.config!==void 0)return t.config;throw new T(`No staged config provided. Add \`staged\` to your vis.config.ts:
2
+
3
+ import { defineConfig } from "@visulima/vis/config";
4
+
5
+ export default defineConfig({
6
+ staged: { "*.ts": "eslint --fix" },
7
+ });
8
+
9
+ Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},K=t=>{if(typeof t!="object"||t===null)throw new T("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new T("Staged config is empty — at least one glob pattern is required.");for(const[s,r]of e){if(!s||s.trim()==="")throw new T("Staged config keys must be non-empty glob patterns.");ft(s,r)}return t},ft=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new T(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new T(`Task array for "${t}" is empty.`);for(const s of e)ft(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new T(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(_(e)){if(e.command.trim()==="")throw new T(`Command task for "${t}" has an empty \`command\`.`);return}if(!Dt(e))throw new T(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Dt=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",Y=2048,w=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ct("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const{stderr:a}=r,c=a.length>Y?`${a.slice(0,Y)}…`:a;throw new j(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,a)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},I=async(t,e)=>{const{stdout:s}=await w(t,e);return s.trim()},Lt=async t=>{const e=await w(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Ut=async t=>I(["rev-parse","--absolute-git-dir"],{cwd:t}),ht=async t=>I(["rev-parse","--show-toplevel"],{cwd:t}),J=async t=>I(["write-tree"],{cwd:t}),Gt=async t=>{const e=await w(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},R={major:2,minor:32},Ht=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),r=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(r)?null:{major:s,minor:r}},qt=async t=>{const e=Ht(await I(["--version"],{cwd:t}));if(e===null)return;if(e.major<R.major||e.major===R.major&&e.minor<R.minor)throw new j(`Git ${R.major}.${R.minor} or newer is required; found ${e.major}.${e.minor}.`)},Bt="ACMR",Z=500,zt=async t=>{const{stdout:e}=await w(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(n=>n.length>0),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(!a?.startsWith(":"))continue;const c=a.slice(1).split(" "),i=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&i!==void 0&&/^0+$/.test(i)&&l!==void 0&&r.push(l)}return r},Q=async t=>{const{stdout:e}=await w(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},Vt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await w(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Wt=async t=>{const e=t.diffFilter??Bt,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:r}=await w(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const a=t.workTree??await ht(t.cwd);return n.map(c=>at(c)?c:P(a,c))},Xt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let a=0;a<t.length;a+=Z){const c=t.slice(a,a+Z),{stdout:i}=await w(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});i.length>0&&s.push(i)}if(s.length===0)return null;const r=s.join(""),n=r.endsWith(`
10
+ `)?r:`${r}
11
+ `;return Buffer.from(n,"utf8")},Kt=async t=>{const{stdout:e}=await w(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(a===void 0||a.length<4)continue;const c=a.charAt(0),i=a.charAt(1),o=a.slice(3),l=c==="R"||c==="C"||i==="R"||i==="C";c!==" "&&c!=="?"&&i!==" "&&i!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await w(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await w(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await w(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Zt="vis_staged_automatic_backup",gt=()=>`${Zt}-${process.pid}-${Date.now()}-${Et(3).toString("hex")}`,Qt=async t=>{const e=await I(["stash","create"],{cwd:t});return e.length===0?null:(await w(["stash","store","-m",gt(),e],{cwd:t}),e)},te=async t=>{const e=gt(),{exitCode:s,stdout:r}=await w(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const n=r.trim();return n.length>0&&/no local changes/i.test(n)?null:I(["rev-parse","stash@{0}"],{cwd:t})},H=async(t,e)=>{const{exitCode:s,stdout:r}=await w(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[a,c]=n.split(/\s+/,2);if(a===e&&c!==void 0)return c}return null},tt=async(t,e)=>{if(e===null)return;const s=await H(t,e);s!==null&&await w(["stash","drop","--quiet",s],{cwd:t})},ee=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");const s=await H(t,e);if(s===null)throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await w(["reset","--hard","HEAD"],{cwd:t}),await w(["stash","apply","--index","--quiet",s],{cwd:t})},se=async(t,e)=>{if(e===null)return;const s=await H(t,e);s!==null&&await w(["stash","pop","--quiet",s],{cwd:t})};class re{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Lt(this.cwd))throw new j(`Not a git repository: ${this.cwd}`);await qt(this.cwd),this.workTree=await ht(this.cwd),this.gitDir=await Ut(this.cwd),this.stagedFiles=await Wt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Kt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await zt(this.workTree),this.intentToAddPaths.length>0&&await Vt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Qt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await te(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await J(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await Gt(this.workTree),this.preTaskUntracked=new Set(await Q(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(r=>x(this.workTree,r));if(await Jt(s,{cwd:this.workTree}),e){const n=(await Q(this.workTree)).filter(a=>!this.preTaskUntracked.has(a));if(n.length>0){const a=`${n.join("\0")}\0`;await w(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:a})}}if(this.intentToAddPaths.length>0)try{await w(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await J(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let s;try{await w(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof j?r.stderr:String(r)}try{await w([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof j&&r.stderr?r.stderr:String(r);throw new X(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
12
+ First attempt: ${s??"(no stderr)"}
13
+ Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await ee(this.workTree,this.backupStashSha)}catch(e){throw new X("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await w(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await se(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(r=>x(this.workTree,r))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(r=>e.has(r)):[];s.length!==0&&(this.patch=await Xt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=P(this.gitDir,e);return B(s)?{body:bt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=P(this.gitDir,e.name);try{e.existed&&e.body!==null?xt(s,e.body):B(s)&&Ct(s)}catch{}}}}const ne=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},et=t=>{if(t==="running")return m.jsx(At,{type:"dots"});const e=t==="failed"?dt:t==="skipped"?F:t==="success"?lt:F;return m.jsx(b,{color:ne(t),children:e})},st=({state:t,tick:e,verbose:s})=>m.jsxs(E,{flexDirection:"column",children:[[...t.patterns.values()].map(r=>m.jsxs(E,{flexDirection:"column",children:[m.jsxs(E,{children:[et(r.status),m.jsxs(b,{children:[" ",r.title]})]}),[...r.commands.values()].map(n=>m.jsxs(E,{flexDirection:"column",marginLeft:2,children:[m.jsxs(E,{children:[et(n.status),m.jsxs(b,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?m.jsxs(b,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),s&&n.output?m.jsx(E,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((a,c)=>m.jsx(b,{color:"gray",children:a},`${n.id}-line-${c}`))}):null,n.status==="failed"&&n.error?m.jsx(E,{marginLeft:2,children:m.jsx(b,{color:"red",children:n.error.message})}):null]},n.id))]},r.id)),t.infoMessages.map((r,n)=>m.jsx(b,{color:"gray",children:r},`info-${n}`)),t.warnMessages.map((r,n)=>m.jsx(b,{color:"yellow",children:r},`warn-${n}`)),t.errorMessages.map(({message:r},n)=>m.jsx(b,{color:"red",children:r},`err-${n}`))]}),ie=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=$t(m.jsx(st,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),a=()=>{r+=1,n.rerender(m.jsx(st,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:i,error:o,output:l,patternId:f,status:d}){const u=s.patterns.get(f)?.commands.get(c);u&&(u.status=d,u.durationMs=i,u.output=l,u.error=o,a())},commandStart({commandId:c,patternId:i}){const o=s.patterns.get(i)?.commands.get(c);o&&(o.status="running",a())},error({error:c,message:i}){s.errorMessages.push({error:c,message:i}),a()},info({message:c}){s.infoMessages.push(c),a()},patternEnd({patternId:c,status:i}){const o=s.patterns.get(c);o&&(o.status=i,a())},patternStart({patternId:c}){const i=s.patterns.get(c);i&&(i.status="running",a())},start({patterns:c}){s.started=!0;for(const i of c){const o=new Map;for(const l of i.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(i.id,{commands:o,id:i.id,status:"pending",title:i.title})}a()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),a()}}},rt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,a=i=>{e||process.stderr.write(`${i}
14
+ `)},c=i=>{switch(i){case"failed":return L(dt);case"running":return D(">");case"skipped":return z(F);case"success":return It(lt);default:return C(F)}};return{commandEnd({commandId:i,durationMs:o,error:l,output:f,status:d}){const u=n.get(i)??i,g=C(`(${o}ms)`);if(a(` ${c(d)} ${u} ${g}`),d==="failed"&&l&&a(C(l.message)),(d==="failed"||s)&&f&&f.trim().length>0)for(const h of f.split(/\r?\n/))a(` ${C(h)}`)},commandStart({commandId:i}){if(!s)return;const o=n.get(i)??i;a(` ${C("…")} ${o}`)},error({error:i,message:o}){e?process.stderr.write(`${L(o)}
15
+ `):a(L(o)),i?.stack&&(s||!e)&&process.stderr.write(`${C(i.stack)}
16
+ `)},info({message:i}){a(C(i))},patternEnd({patternId:i,status:o}){const l=r.get(i)??i;a(`${c(o)} ${l}`)},patternStart({patternId:i}){const o=r.get(i)??i;a(`${D(">")} ${o}`)},start({patterns:i}){if(i.length===0){a(C("No staged files matched any pattern."));return}const o=new Set(i.flatMap(l=>l.files)).size;a(`${D(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${i.length} pattern${i.length===1?"":"s"}`);for(const l of i){r.set(l.id,l.title);for(const f of l.commands)n.set(f.id,f.title)}},stop(){},warn({message:i}){a(z(i))}}},ae=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return rt({quiet:t.quiet,verbose:t.verbose});try{return ie({verbose:t.verbose})}catch{return rt({quiet:t.quiet,verbose:t.verbose})}},oe=t=>{const e=[];let s="",r=!1,n=!1;for(let a=0;a<t.length;a+=1){const c=t[a];if(c===void 0)break;if(c==="\\"&&!r&&a+1<t.length){const i=t[a+1];if(i!==void 0){n&&i!=='"'&&i!=="\\"&&(s+=c),s+=i,a+=1;continue}}if(c==='"'&&!r){n=!n;continue}if(c==="'"&&!n){r=!r;continue}if(!r&&!n&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(r||n)throw new T(`Unterminated ${r?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},pt=process.platform==="win32"?28e3:131072,ce=(t,e,s)=>{const r=[];let n=[],a=e;const c=s<=0?pt:s;for(const i of t){const o=Buffer.byteLength(i)+1;n.length>0&&a+o>c&&(r.push(n),n=[],a=e),n.push(i),a+=o}return n.length>0&&r.push(n),r},de=async(t,e,s)=>{const r=oe(t);if(r.length===0)throw new $(t,"Empty command for staged task.");const[n,...a]=r;if(n===void 0)throw new $(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+a.reduce((f,d)=>f+Buffer.byteLength(d)+1,0),i=ce(e,c,s.maxArgLength??pt),o=Date.now(),l=[];for(const f of i){if(s.signal?.aborted===!0)throw new $(t,"Task aborted by earlier failure.");const d=ct(n,[...a,...f],{nodeOptions:{cwd:s.cwd,env:le(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,g=[u.stdout,u.stderr].filter(p=>p.length>0).join(`
17
+ `);g.length>0&&l.push(g);const h=d.process?.signalCode??null;if(d.aborted||h!==null||u.exitCode===void 0){const p=d.aborted?"Task aborted by earlier failure.":h===null?g.trim()||"Task exited without a numeric status code.":`Task killed by signal ${h}.`;throw new $(t,p)}if(u.exitCode!==0)throw new $(t,g.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
18
+ `)}},le=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return Mt(r,e)},ue=async(t,e,s)=>{const r=he(s.concurrent,t.length),n=[],a=new AbortController;let c=!1,i=0;const o=()=>{c||(c=!0,s.continueOnError||a.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=h=>{for(const p of h.commands)e.commandEnd({commandId:p.id,durationMs:0,patternId:h.id,status:"skipped"})},f=async h=>{if(c){l(h),e.patternEnd({patternId:h.id,status:"skipped"});return}e.patternStart({patternId:h.id});let p="success";for(const k of h.commands){if(c){e.commandEnd({commandId:k.id,durationMs:0,patternId:h.id,status:"skipped"}),p=p==="success"?"skipped":p;continue}e.commandStart({commandId:k.id,patternId:h.id});const v=await fe(k,s,a.signal),S=v.status==="failed"&&a.signal.aborted?{...v,status:"skipped"}:v;if(e.commandEnd({commandId:k.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:h.id,status:S.status}),S.status==="failed"){n.push(k.title),p="failed",o();break}if(S.status==="skipped"){p=p==="success"?"skipped":p;break}}e.patternEnd({patternId:h.id,status:p})},d=async()=>{for(;i<t.length;){const h=t[i];i+=1,h&&await f(h)}},u=[];for(let h=0;h<Math.min(r,t.length);h+=1)u.push(d());await Promise.all(u);const g=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!g}},fe=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await de(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new $(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const a=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:a,output:a instanceof $?a.message:void 0,status:"failed"}}},he=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof V=="function"?V():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},ge=!0,pe=t=>{try{return!Tt(t)}catch{return!1}},we=t=>{try{const e=vt(t);return e?St(t,e).map(s=>P(t,s)):[]}catch{return[]}},me=async(t={})=>{const e=t.cwd??process.cwd(),s=await ae(t),r=await Ot(t);typeof r!="function"&&K(r);const n=new re({...t,cwd:e}),a=new AbortController;let c=!1;const i=d=>{if(c){process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),a.abort()};process.on("SIGINT",i),process.on("SIGTERM",i);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,f=!1;try{await n.prepare(),l=!0;for(const v of n.warnings)s.warn({message:v});if(n.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),f=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=pe(e),u=_t(n.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&n.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),f=!0,{failedCommands:[],ranTasks:!1,success:!0};const g=typeof r=="function"?K(await r([...u])):r,h=await Nt({caseInsensitive:d,config:g,cwd:e,files:u,relative:t.relative,workspacePackages:we(e)});if(s.start({patterns:h}),h.length===0)return s.info({message:"No staged files matched any pattern."}),f=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:p,success:k}=await ue(h,s,{concurrent:t.concurrent??ge,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:a.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:p,ranTasks:!0,success:k},k){if(t.diff===void 0&&(await n.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&n.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...p],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new Rt("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)s.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const v=n.recoveryHint();v&&s.warn({message:v})}return await n.restoreUnstagedChanges(),f=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),g=d instanceof Error?d:new Error(u);if(s.error({error:g,message:u}),d instanceof A)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),l)try{await n.cleanup(f)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},ke="VIS_STAGED_CONCURRENT",nt=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},ye=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=y=>t[y]===void 0?void 0:!!t[y],n=y=>{const O=t[y];return typeof O=="string"&&O.length>0?O:void 0},a=r("allow-empty");a!==void 0&&(s.allowEmpty=a);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const i=r("continue-on-error");i!==void 0&&(s.continueOnError=i);const o=r("debug");o!==void 0&&(s.debug=o);const l=r("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const f=r("hide-partially-staged");f!==void 0&&(s.hidePartiallyStaged=f);const d=r("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=r("quiet");u!==void 0&&(s.quiet=u);const g=r("relative");g!==void 0&&(s.relative=g);const h=r("revert");h!==void 0&&(s.revert=h);const p=r("stash");p!==void 0&&(s.stash=p);const k=r("verbose");k!==void 0&&(s.verbose=k);const v=n("cwd");v!==void 0&&(s.cwd=v);const S=n("diff");S!==void 0&&(s.diff=S);const q=n("diff-filter");if(q!==void 0&&(s.diffFilter=q),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const y=process.env[ke];y!==void 0&&(s.concurrent=nt(y.trim()))}else{const{concurrent:y}=t;s.concurrent=nt(typeof y=="string"?y:typeof y=="number"||typeof y=="boolean"?String(y):"")}return s},je=async({options:t,visConfig:e})=>{const r=(e??{}).staged;if(!r)throw new Error(`No "staged" config found in vis.config.ts. Add one:
19
+
20
+ // vis.config.ts
21
+ import { defineConfig } from "@visulima/vis/config";
22
+
23
+ export default defineConfig({
24
+ staged: { '*': 'vis check --fix' },
25
+ });
26
+
27
+ Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await me(ye(t,r))).success||(process.exitCode=1)};export{ye as buildRunOptions,je as default};
@@ -1,27 +1,3 @@
1
- import{createRequire as mt}from"node:module";import{b as x,K as it,P as kt,v as at,w as O,l as B,p as vt}from"../packem_shared/index-BLtnel38.js";import{X as Tt,l as w,m as C,i as b,P as St,e as bt}from"./catalog.js";import ot from"./index.js";import{k as ct}from"../packem_shared/main-D_cam4hv.js";import"../packem_shared/en-BDYMmM2_.js";import{Spinner as Et}from"@visulima/tui-kit/spinner";import{C as dt,D as _,T as lt}from"../packem_shared/symbols-DPTlrJ3B.js";import{s as V,E as $,q as F,V as G,I as Mt}from"../packem_shared/index.server-CusjRLCh.js";import{withEnhancedPath as At}from"@visulima/task-runner";let wt;const yt=t=>(wt??=mt(import.meta.url))(t),A=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,q=t=>{if(typeof A<"u"&&A.versions&&A.versions.node){const[e,s]=A.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return A.getBuiltinModule(t)}return yt(t)},{readFileSync:xt,writeFileSync:$t,unlinkSync:Ct}=q("node:fs"),{randomBytes:It}=q("node:crypto"),{availableParallelism:z}=q("node:os");class E extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class jt extends E{}class v extends E{}class W extends E{}class R extends E{stderr;constructor(e,s,r){super(e,r),this.stderr=s}}class K extends E{}class I extends E{commandTitle;constructor(e,s,r){super(s,r),this.commandTitle=e}}const ut=t=>t.includes("/"),P=(t,e)=>e?t.toLowerCase():t,Rt=(t,e,s,r={})=>{const n=ut(t),a=r.caseInsensitive===!0,c=P(t,a),i=[];for(const o of e){const l=n?x(s,o):it(o);ot(c,P(l,a))&&i.push(o)}return i},Nt=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(a=>{for(const c of e){const i=ut(c)?x(s,a):it(a),o=P(c,n);if(ot(o,P(i,n)))return!1}return!0})},L=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",N=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Ot=(t,e)=>{const s=x(t,e);return s===""||!s.startsWith("..")&&!at(s)},_t=(t,e)=>{let s;for(const r of e)Ot(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},Pt=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),a=(o,l,h,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],p=new Map;for(const f of h){const g=_t(f,u)??t.cwd,y=p.get(g)??[];y.push(x(g,f)),p.set(g,y)}for(const f of[...p.keys()].sort()){const g=x(t.cwd,f)||".";d.push({command:o.command,cwd:f,files:p.get(f)??[],id:n(),source:"string",title:`${o.command} — ${g}`})}return}if(o.cwd!==void 0){const u=kt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:h,id:n(),source:"string",title:`${o.command} — ${x(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:n(),source:"string",title:o.command})},c=async(o,l,h,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:n(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,h,d);return}if(N(o)){a(o,l,h,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const p of u)if(typeof p=="string")d.push({command:p,files:l,id:n(),source:"function",title:p});else if(N(p))a(p,l,h,d);else if(L(p))d.push({files:l,id:n(),run:p.task,source:"custom",title:p.title});else throw new v("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(N(u)){a(u,l,h,d);return}if(L(u)){d.push({files:l,id:n(),run:u.task,source:"custom",title:u.title});return}throw new v("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(L(o)){d.push({files:l,id:n(),run:o.task,source:"custom",title:o.title});return}throw new v("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},i=[];for(const[o,l]of Object.entries(t.config)){const h=Rt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(h.length===0)continue;const d=t.relative?h.map(p=>x(t.cwd,p)):h,u=[];await c(l,d,h,u),u.length!==0&&i.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${h.length} file${h.length===1?"":"s"}`})}return i},Dt=async t=>{if(t.config!==void 0)return t.config;throw new v(`No staged config provided. Add \`staged\` to your vis.config.ts:
2
-
3
- import { defineConfig } from "@visulima/vis/config";
4
-
5
- export default defineConfig({
6
- staged: { "*.ts": "eslint --fix" },
7
- });
8
-
9
- Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},X=t=>{if(typeof t!="object"||t===null)throw new v("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new v("Staged config is empty — at least one glob pattern is required.");for(const[s,r]of e){if(!s||s.trim()==="")throw new v("Staged config keys must be non-empty glob patterns.");ht(s,r)}return t},ht=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new v(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new v(`Task array for "${t}" is empty.`);for(const s of e)ht(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new v(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(N(e)){if(e.command.trim()==="")throw new v(`Command task for "${t}" has an empty \`command\`.`);return}if(!Ft(e))throw new v(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Ft=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",Y=2048,m=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ct("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),n=typeof r.exitCode=="number"?r.exitCode:1;if(n!==0&&!e.lenient){const{stderr:a}=r,c=a.length>Y?`${a.slice(0,Y)}…`:a;throw new R(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,a)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},M=async(t,e)=>{const{stdout:s}=await m(t,e);return s.trim()},Gt=async t=>{const e=await m(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Lt=async t=>M(["rev-parse","--absolute-git-dir"],{cwd:t}),ft=async t=>M(["rev-parse","--show-toplevel"],{cwd:t}),J=async t=>M(["write-tree"],{cwd:t}),qt=async t=>{const e=await m(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},j={major:2,minor:32},Ht=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),r=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(r)?null:{major:s,minor:r}},Ut=async t=>{const e=Ht(await M(["--version"],{cwd:t}));if(e!==null&&(e.major<j.major||e.major===j.major&&e.minor<j.minor))throw new R(`Git ${j.major}.${j.minor} or newer is required; found ${e.major}.${e.minor}.`)},Bt="ACMR",Q=500,Vt=async t=>{const{stdout:e}=await m(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(n=>n.length>0),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(!a?.startsWith(":"))continue;const c=a.slice(1).split(" "),i=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&i!==void 0&&/^0+$/.test(i)&&l!==void 0&&r.push(l)}return r},Z=async t=>{const{stdout:e}=await m(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},zt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Wt=async t=>{const e=t.diffFilter??Bt,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:r}=await m(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const a=t.workTree??await ft(t.cwd);return n.map(c=>at(c)?c:O(a,c))},Kt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let a=0;a<t.length;a+=Q){const c=t.slice(a,a+Q),{stdout:i}=await m(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});i.length>0&&s.push(i)}if(s.length===0)return null;const r=s.join(""),n=r.endsWith(`
10
- `)?r:`${r}
11
- `;return Buffer.from(n,"utf8")},Xt=async t=>{const{stdout:e}=await m(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const a=s[n];if(a===void 0||a.length<4)continue;const c=a.charAt(0),i=a.charAt(1),o=a.slice(3),l=c==="R"||c==="C"||i==="R"||i==="C";c!==" "&&c!=="?"&&i!==" "&&i!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await m(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await m(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await m(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Qt="vis_staged_automatic_backup",pt=()=>`${Qt}-${process.pid}-${Date.now()}-${It(3).toString("hex")}`,Zt=async t=>{const e=await M(["stash","create"],{cwd:t});return e.length===0?null:(await m(["stash","store","-m",pt(),e],{cwd:t}),e)},te=async t=>{const e=pt(),{exitCode:s,stdout:r}=await m(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const n=r.trim();return n.length>0&&/no local changes/i.test(n)?null:M(["rev-parse","stash@{0}"],{cwd:t})},H=async(t,e)=>{const{exitCode:s,stdout:r}=await m(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[a,c]=n.split(/\s+/,2);if(a===e&&c!==void 0)return c}return null},tt=async(t,e)=>{if(e===null)return;const s=await H(t,e);s!==null&&await m(["stash","drop","--quiet",s],{cwd:t})},ee=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");const s=await H(t,e);if(s===null)throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await m(["reset","--hard","HEAD"],{cwd:t}),await m(["stash","apply","--index","--quiet",s],{cwd:t})},se=async(t,e)=>{if(e===null)return;const s=await H(t,e);s!==null&&await m(["stash","pop","--quiet",s],{cwd:t})};class re{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Gt(this.cwd))throw new R(`Not a git repository: ${this.cwd}`);await Ut(this.cwd),this.workTree=await ft(this.cwd),this.gitDir=await Lt(this.cwd),this.stagedFiles=await Wt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Xt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await Vt(this.workTree),this.intentToAddPaths.length>0&&await zt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Zt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await te(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await J(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await qt(this.workTree),this.preTaskUntracked=new Set(await Z(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(r=>x(this.workTree,r));if(await Jt(s,{cwd:this.workTree}),e){const r=(await Z(this.workTree)).filter(n=>!this.preTaskUntracked.has(n));if(r.length>0){const n=`${r.join("\0")}\0`;await m(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:n})}}if(this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await J(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const e=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let s;try{await m(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof R?r.stderr:String(r)}try{await m([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof R&&r.stderr?r.stderr:String(r);throw new K(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
12
- First attempt: ${s??"(no stderr)"}
13
- Second attempt: ${n}`,{cause:r})}}async revert(){if(this.backupStashSha!==null){try{await ee(this.workTree,this.backupStashSha)}catch(e){throw new K("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await tt(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await m(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await se(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await tt(this.workTree,this.backupStashSha)}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(r=>x(this.workTree,r))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(r=>e.has(r)):[];s.length!==0&&(this.patch=await Kt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=O(this.gitDir,e);return B(s)?{body:xt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=O(this.gitDir,e.name);try{e.existed&&e.body!==null?$t(s,e.body):B(s)&&Ct(s)}catch{}}}}const ne=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},et=t=>{if(t==="running")return w.jsx(Et,{type:"dots"});const e=t==="failed"?dt:t==="skipped"?_:t==="success"?lt:_;return w.jsx(b,{color:ne(t),children:e})},st=({state:t,tick:e,verbose:s})=>w.jsxs(C,{flexDirection:"column",children:[[...t.patterns.values()].map(r=>w.jsxs(C,{flexDirection:"column",children:[w.jsxs(C,{children:[et(r.status),w.jsxs(b,{children:[" ",r.title]})]}),[...r.commands.values()].map(n=>w.jsxs(C,{flexDirection:"column",marginLeft:2,children:[w.jsxs(C,{children:[et(n.status),w.jsxs(b,{children:[" ",n.title," "]}),n.status!=="pending"&&n.status!=="running"?w.jsxs(b,{color:"gray",children:["(",n.durationMs,"ms)"]}):null]}),s&&n.output?w.jsx(C,{flexDirection:"column",marginLeft:2,children:n.output.split(/\r?\n/).slice(0,20).map((a,c)=>w.jsx(b,{color:"gray",children:a},`${n.id}-line-${c}`))}):null,n.status==="failed"&&n.error?w.jsx(C,{marginLeft:2,children:w.jsx(b,{color:"red",children:n.error.message})}):null]},n.id))]},r.id)),t.infoMessages.map((r,n)=>w.jsx(b,{color:"gray",children:r},`info-${n}`)),t.warnMessages.map((r,n)=>w.jsx(b,{color:"yellow",children:r},`warn-${n}`)),t.errorMessages.map(({message:r},n)=>w.jsx(b,{color:"red",children:r},`err-${n}`))]}),ie=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=Tt(w.jsx(st,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),a=()=>{r+=1,n.rerender(w.jsx(st,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:i,error:o,output:l,patternId:h,status:d}){const u=s.patterns.get(h)?.commands.get(c);u&&(u.status=d,u.durationMs=i,u.output=l,u.error=o,a())},commandStart({commandId:c,patternId:i}){const o=s.patterns.get(i)?.commands.get(c);o&&(o.status="running",a())},error({error:c,message:i}){s.errorMessages.push({error:c,message:i}),a()},info({message:c}){s.infoMessages.push(c),a()},patternEnd({patternId:c,status:i}){const o=s.patterns.get(c);o&&(o.status=i,a())},patternStart({patternId:c}){const i=s.patterns.get(c);i&&(i.status="running",a())},start({patterns:c}){s.started=!0;for(const i of c){const o=new Map;for(const l of i.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(i.id,{commands:o,id:i.id,status:"pending",title:i.title})}a()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),a()}}},rt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,a=i=>{e||process.stderr.write(`${i}
14
- `)},c=i=>{switch(i){case"failed":return G(dt);case"running":return F(">");case"skipped":return V(_);case"success":return Mt(lt);default:return $(_)}};return{commandEnd({commandId:i,durationMs:o,error:l,output:h,status:d}){const u=n.get(i)??i,p=$(`(${o}ms)`);if(a(` ${c(d)} ${u} ${p}`),d==="failed"&&l&&a($(l.message)),(d==="failed"||s)&&h&&h.trim().length>0)for(const f of h.split(/\r?\n/))a(` ${$(f)}`)},commandStart({commandId:i}){if(!s)return;const o=n.get(i)??i;a(` ${$("…")} ${o}`)},error({error:i,message:o}){e?process.stderr.write(`${G(o)}
15
- `):a(G(o)),i?.stack&&(s||!e)&&process.stderr.write(`${$(i.stack)}
16
- `)},info({message:i}){a($(i))},patternEnd({patternId:i,status:o}){const l=r.get(i)??i;a(`${c(o)} ${l}`)},patternStart({patternId:i}){const o=r.get(i)??i;a(`${F(">")} ${o}`)},start({patterns:i}){if(i.length===0){a($("No staged files matched any pattern."));return}const o=new Set(i.flatMap(l=>l.files)).size;a(`${F(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${i.length} pattern${i.length===1?"":"s"}`);for(const l of i){r.set(l.id,l.title);for(const h of l.commands)n.set(h.id,h.title)}},stop(){},warn({message:i}){a(V(i))}}},ae=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return rt({quiet:t.quiet,verbose:t.verbose});try{return ie({verbose:t.verbose})}catch{return rt({quiet:t.quiet,verbose:t.verbose})}},oe=t=>{const e=[];let s="",r=!1,n=!1;for(let a=0;a<t.length;a+=1){const c=t[a];if(c===void 0)break;if(c==="\\"&&!r&&a+1<t.length){const i=t[a+1];if(i!==void 0){n&&i!=='"'&&i!=="\\"&&(s+=c),s+=i,a+=1;continue}}if(c==='"'&&!r){n=!n;continue}if(c==="'"&&!n){r=!r;continue}if(!r&&!n&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(r||n)throw new v(`Unterminated ${r?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},gt=process.platform==="win32"?28e3:131072,ce=(t,e,s)=>{const r=[];let n=[],a=e;const c=s<=0?gt:s;for(const i of t){const o=Buffer.byteLength(i)+1;n.length>0&&a+o>c&&(r.push(n),n=[],a=e),n.push(i),a+=o}return n.length>0&&r.push(n),r},de=async(t,e,s)=>{const r=oe(t);if(r.length===0)throw new I(t,"Empty command for staged task.");const[n,...a]=r;if(n===void 0)throw new I(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+a.reduce((h,d)=>h+Buffer.byteLength(d)+1,0),i=ce(e,c,s.maxArgLength??gt),o=Date.now(),l=[];for(const h of i){if(s.signal?.aborted===!0)throw new I(t,"Task aborted by earlier failure.");const d=ct(n,[...a,...h],{nodeOptions:{cwd:s.cwd,env:le(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,p=[u.stdout,u.stderr].filter(g=>g.length>0).join(`
17
- `);p.length>0&&l.push(p);const f=d.process?.signalCode??null;if(d.aborted||f!==null||u.exitCode===void 0){const g=d.aborted?"Task aborted by earlier failure.":f===null?p.trim()||"Task exited without a numeric status code.":`Task killed by signal ${f}.`;throw new I(t,g)}if(u.exitCode!==0)throw new I(t,p.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
18
- `)}},le=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const r=t?{...s,...t}:s;return At(r,e)},ue=async(t,e,s)=>{const r=fe(s.concurrent,t.length),n=[],a=new AbortController;let c=!1,i=0;const o=()=>{c||(c=!0,s.continueOnError||a.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=f=>{for(const g of f.commands)e.commandEnd({commandId:g.id,durationMs:0,patternId:f.id,status:"skipped"})},h=async f=>{if(c){l(f),e.patternEnd({patternId:f.id,status:"skipped"});return}e.patternStart({patternId:f.id});let g="success";for(const y of f.commands){if(c){e.commandEnd({commandId:y.id,durationMs:0,patternId:f.id,status:"skipped"}),g=g==="success"?"skipped":g;continue}e.commandStart({commandId:y.id,patternId:f.id});const T=await he(y,s,a.signal),S=T.status==="failed"&&a.signal.aborted?{...T,status:"skipped"}:T;if(e.commandEnd({commandId:y.id,durationMs:S.durationMs,error:S.error,output:S.output,patternId:f.id,status:S.status}),S.status==="failed"){n.push(y.title),g="failed",o();break}if(S.status==="skipped"){g=g==="success"?"skipped":g;break}}e.patternEnd({patternId:f.id,status:g})},d=async()=>{for(;i<t.length;){const f=t[i];i+=1,f&&await h(f)}},u=[];for(let f=0;f<Math.min(r,t.length);f+=1)u.push(d());await Promise.all(u);const p=s.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!p}},he=async(t,e,s)=>{const r=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-r,status:"success"};if(t.command){const n=await de(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s});return{durationMs:n.durationMs,output:e.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-r,error:new I(t.title,"Command has no invocation target."),status:"failed"}}catch(n){const a=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:a,output:a instanceof I?a.message:void 0,status:"failed"}}},fe=(t,e)=>{if(t===!1)return 1;if(t===!0){const r=Math.max(1,typeof z=="function"?z():4);return Math.min(Math.max(1,e),r)}const s=Math.floor(t);return s>0?s:1},pe=!0,ge=t=>{try{return!vt(t)}catch{return!1}},me=t=>{try{const e=St(t);return e?bt(t,e).map(s=>O(t,s)):[]}catch{return[]}},we=async(t={})=>{const e=t.cwd??process.cwd(),s=await ae(t),r=await Dt(t);typeof r!="function"&&X(r);const n=new re({...t,cwd:e}),a=new AbortController;let c=!1;const i=d=>{if(c){process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),a.abort()};process.on("SIGINT",i),process.on("SIGTERM",i);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,h=!1;try{await n.prepare(),l=!0;for(const T of n.warnings)s.warn({message:T});if(n.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=ge(e),u=Nt(n.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&n.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const p=typeof r=="function"?X(await r([...u])):r,f=await Pt({caseInsensitive:d,config:p,cwd:e,files:u,relative:t.relative,workspacePackages:me(e)});if(s.start({patterns:f}),f.length===0)return s.info({message:"No staged files matched any pattern."}),h=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:g,success:y}=await ue(f,s,{concurrent:t.concurrent??pe,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:a.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:g,ranTasks:!0,success:y},y){if(t.diff===void 0&&(await n.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&n.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...g],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new jt("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(t.revert===!0)s.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const T=n.recoveryHint();T&&s.warn({message:T})}return await n.restoreUnstagedChanges(),h=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),p=d instanceof Error?d:new Error(u);if(s.error({error:p,message:u}),d instanceof E)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",i),process.removeListener("SIGTERM",i),l)try{await n.cleanup(h)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},ye="VIS_STAGED_CONCURRENT",nt=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},ke=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=k=>t[k]===void 0?void 0:!!t[k],n=k=>{const D=t[k];return typeof D=="string"&&D.length>0?D:void 0},a=r("allow-empty");a!==void 0&&(s.allowEmpty=a);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const i=r("continue-on-error");i!==void 0&&(s.continueOnError=i);const o=r("debug");o!==void 0&&(s.debug=o);const l=r("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const h=r("hide-partially-staged");h!==void 0&&(s.hidePartiallyStaged=h);const d=r("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=r("quiet");u!==void 0&&(s.quiet=u);const p=r("relative");p!==void 0&&(s.relative=p);const f=r("revert");f!==void 0&&(s.revert=f);const g=r("stash");g!==void 0&&(s.stash=g);const y=r("verbose");y!==void 0&&(s.verbose=y);const T=n("cwd");T!==void 0&&(s.cwd=T);const S=n("diff");S!==void 0&&(s.diff=S);const U=n("diff-filter");if(U!==void 0&&(s.diffFilter=U),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const k=process.env[ye];k!==void 0&&(s.concurrent=nt(k.trim()))}else{const{concurrent:k}=t;s.concurrent=nt(typeof k=="string"?k:typeof k=="number"||typeof k=="boolean"?String(k):"")}return s},Ae=async({options:t,visConfig:e})=>{const s=(e??{}).staged;if(!s)throw new Error(`No "staged" config found in vis.config.ts. Add one:
19
-
20
- // vis.config.ts
21
- import { defineConfig } from "@visulima/vis/config";
22
-
23
- export default defineConfig({
24
- staged: { '*': 'vis check --fix' },
25
- });
26
-
27
- Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await we(ke(t,s))).success||(process.exitCode=1)};export{ke as buildRunOptions,Ae as default};
1
+ import{createRequire as Ne}from"node:module";import{u as W,V as Ce,U as ze,W as Ge,T as $e,X as We,Y as Ve,C as Ue}from"./cli-main.js";import{i as Xe}from"../packem_shared/index-BjdW45xX.js";import{u as p,y as e,X as s,m as o,R as He}from"./catalog.js";import{d as Ke}from"../packem_shared/pm-runner-de-jCq8q.js";import{i as qe,e as le,z as Ye,m as Qe}from"../packem_shared/index-DHD8wb6Z.js";import{y as Ze}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{h as et}from"../packem_shared/writeFileSync-DJoHk3Ks-CgQ-VNNT.js";import{n as tt,a as ot}from"../packem_shared/tabs-BilwonkM.js";let Re;const Be=i=>(Re??=Ne(import.meta.url))(i),q=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_e=i=>{if(typeof q<"u"&&q.versions&&q.versions.node){const[t,n]=q.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return q.getBuiltinModule(i)}return Be(i)},{writeFileSync:Je}=_e("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(qe,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),V=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],nt=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ze(t))return null;const n=Ye(t),c=rt(n),l=c!==n;let r;try{r=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:l}},it=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");et(c),Je(l,`${JSON.stringify(t,null,2)}
2
+ `,"utf8")},st={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],deno:[{source:"${localWorkspaceFolderBasename}-deno-cache",target:"/home/node/.cache/deno",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},ct=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of st[i])l.has(a.target)||c.push(a);const r=Object.keys(t);for(const{featureMatch:a,mounts:m}of ct)if(r.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},B=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],Y=i=>structuredClone(i);class lt{#r=new Set;#e;constructor(t,n,c=null){const l=t===null,r=t??{name:""},a=Y(r);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:Y(r),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#r.add(t),()=>{this.#r.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const n=(B.indexOf(this.#e.section)+1)%B.length;this.setSection(B[n])}previousSection(){const n=(B.indexOf(this.#e.section)-1+B.length)%B.length;this.setSection(B[n])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,V.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=V.find(c=>c.id===t);n&&this.#t(this.#o({...this.#e,config:Y(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#o({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],r=l.indexOf(t);r===-1?l.push(t):l.splice(r,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",r={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:r},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:Y(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=Y(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#o(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#r)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},at=/^[a-z]$/i,dt=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},ut=(i,t)=>i.length===0||dt(i)?!1:t.ctrl&&t.meta?!at.test(i):!(t.ctrl||t.meta),ht=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,ke=-1,mt=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:ke,gt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ht,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:r,suggestions:a}){const[m,f]=p.useState(i),[g,v]=p.useState(i.length),x=p.useRef(m);x.current=m;const b=p.useRef(g);b.current=g;const y=p.useRef(c);y.current=c;const D=p.useRef(l);D.current=l;const k=se(m,a),M=p.useCallback((T,I)=>{const{current:E}=b,S=x.current;if(I.return){const w=se(S,a),C=w?S+w:S;w&&(f(C),v(C.length),y.current?.(C)),D.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(S,a);if(E===S.length&&w){const C=S+w;f(C),v(C.length),y.current?.(C);return}v(Math.min(S.length,E+1));return}const A=mt(T,I,E,S.length);if(A!==ke){v(A);return}const H=gt(T,I,S,E);if(H){const[w,C]=H;f(w),v(C),y.current?.(w);return}if(ut(T,I)){const w=S.slice(0,E)+T+S.slice(E);f(w),v(E+T.length),y.current?.(w)}},[a]);W(M,{isActive:!t});const L=n?"*".repeat(m.length):m,U=L.slice(0,g),X=L[g],Q=L.slice(g+1);return t?e.jsx(s,{children:e.jsx(o,{dimColor:!0,children:L||r||""})}):m.length===0&&r?e.jsxs(s,{children:[e.jsx(o,{dimColor:!0,inverse:!0,children:r[0]}),e.jsx(o,{dimColor:!0,children:r.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(o,{children:[U,e.jsx(o,{inverse:!0,children:X??" "}),Q]}),k?e.jsx(o,{dimColor:!0,children:k}):void 0]})}const Ee=["dockerComposeFile","service"],ft={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},pt={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},xt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,r=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),r&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(o,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const f=m===n,g=i[a]??"",v=Array.isArray(i[a])?i[a].join(", "):g;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:f,color:f?"cyan":"white",children:[f?"❯ ":" ",ft[a],":"]})}),e.jsx(s,{flexGrow:1,children:f&&t?e.jsx(he,{defaultValue:v,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(o,{color:v?"white":"gray",children:v||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:pt[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},jt=Ee.length,vt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),r=Object.keys(c),a=l.length,m=l.length+1,f=m+r.length,g=t<=a,v=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:g?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(o,{bold:!0,color:g?"cyan":"white",children:"containerEnv"}),e.jsx(o,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,b)=>{const y=b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(o,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:v?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:r.length>0?1:0,children:[e.jsx(o,{bold:!0,color:v?"cyan":"white",children:"remoteEnv"}),e.jsx(o,{dimColor:!0,children:" — set at runtime by the IDE"})]}),r.map((x,b)=>{const D=m+b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:D?"cyan":void 0,inverse:D,wrap:"truncate",children:[D?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:r.length>0?1:0,children:e.jsxs(o,{color:t===f?"cyan":"gray",inverse:t===f,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[e.jsx(o,{bold:!0,color:"white",children:"a"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},bt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},wt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.id]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No extensions match the search."})})]})},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.description]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],St={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},be={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],Ct={overrideCommand:"Override Command",privileged:"Privileged"},kt=ae.length+te.length,Et=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,r)=>{const a=r===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",St[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:f=>{c({[l]:f})},placeholder:be[l]}):e.jsx(o,{color:m?"white":"gray",children:m||be[l]})})]},l)}),te.map((l,r)=>{const m=ae.length+r===n,f=i[l]??!1;return e.jsxs(s,{marginBottom:r<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:m,color:m?"cyan":"white",children:[m?"❯ ":" ",Ct[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{color:f?"green":"gray",children:[f?"yes":"no",m&&e.jsx(o,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=kt,ce=te,De=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],It={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},Dt={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),De.map((l,r)=>{const a=r===n,m=i[l],f=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",It[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:Dt[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:f,onChange:g=>{c(l,g)},placeholder:"e.g. npm install"}):e.jsx(o,{color:f?"green":"gray",children:f||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),At=De.length,we=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Ft=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:r,mountTarget:a,mountType:m,suggestedMounts:f})=>{const g=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[g.length," ","mounts"]}),n&&e.jsxs(o,{dimColor:!0,children:["— detected:"," ",e.jsx(o,{color:"white",children:n})]})]}),f.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(o,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(o,{dimColor:!0,children:[" ","— press"," ",e.jsx(o,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),f.map((v,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[" + ",we(v)]})},`suggestion-${String(x)}`))]}),g.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:g.map((v,x)=>{const b=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:b?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:b,inverse:b,wrap:"truncate",children:[" ",we(v)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:c===g.length?"cyan":"gray",inverse:c===g.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(o,{color:r?"yellow":"gray",children:r||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(o,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(o,{children:[e.jsx(o,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(o,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(o,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(o,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),g.length===0&&!i&&f.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(o,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Lt=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],r=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(o,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const f=m===c;return e.jsx(s,{children:e.jsxs(o,{color:f?"cyan":void 0,inverse:f,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(o,{color:r?"cyan":"gray",inverse:r,children:[" ",r&&i?e.jsxs(o,{children:["Enter port:"," ",e.jsx(o,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ",r?"type port number, Enter to confirm":"select"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},Ot=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(o,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(o,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(o,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
3
+ `).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Pt=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,r]of i.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},ye=80,Se=15,Mt=120,Te=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Nt=new Map(Te.map(i=>[i.id,i.description])),Rt=(i,t,n,c)=>{switch(i){case"compose":return jt;case"environment":return bt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return At;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},Bt=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=$e(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[f,g]=p.useState(!1),[v,x]=p.useState(!1),[b,y]=p.useState(null),[D,k]=p.useState("editor"),[M,L]=p.useState(0),[U,X]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[S,A]=p.useState(""),[H,w]=p.useState(""),[C,_]=p.useState("key"),[oe,Z]=p.useState(!1),[re,z]=p.useState(""),[ne,G]=p.useState(""),[me,K]=p.useState("volume"),[O,$]=p.useState("source"),ie=p.useRef(null),R=p.useRef(null),N=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,N.current&&clearTimeout(N.current)}),[]);const ge=Rt(r.section,r.config,r.featureSearch,r.extensionSearch),J=Math.max(1,l-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||L(u=>r.fieldIndex>=u+J?r.fieldIndex-J+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,J]),p.useEffect(()=>{L(0)},[r.section,r.featureSearch,r.extensionSearch]);const Ae=p.useCallback(()=>{const u=t.cleanConfig(),h=Pt(u);if(!h.valid){const j=h.errors[0];y(j?`Error: ${j.message}`:"Validation failed"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;y(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},2e3)},[i,t]);W((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=V[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),W((u,h)=>{if(h.escape){X(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),X(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:U}),W((u,h)=>{if(h.escape){E(null),A(""),w(""),_("key");return}if(h.return){if(C==="key"&&S){_("value");return}if(C==="value"&&S){t.addEnvVar(I,S,H),E(null),A(""),w(""),_("key");return}}if(h.backspace){C==="key"?A(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?A(d=>d+u):w(d=>d+u))},{isActive:I!==null}),W((u,h)=>{if(h.escape){Z(!1),z(""),G(""),$("source");return}if(h.return){if(O==="source"&&re){$("target");return}if(O==="target"&&ne){$("type");return}if(O==="type"){t.addMount({source:re,target:ne,type:me}),Z(!1),z(""),G(""),$("source");return}}if(O==="type"){switch(u){case"1":{K("volume");break}case"2":{K("bind");break}case"3":{K("tmpfs");break}}return}if(h.backspace){O==="source"?z(d=>d.slice(0,-1)):O==="target"&&G(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(O==="source"?z(d=>d+u):O==="target"&&G(d=>d+u))},{isActive:oe}),W((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!f){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),g(!0));return}if(v){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?g(!0):n();return}if(u==="s"){Ae();return}if(h.tab){k(d=>d==="editor"?"preview":"editor");return}if(D==="preview"){if(h.downArrow||u==="j"){R.current?.scrollBy(1);return}if(h.upArrow||u==="k"){R.current?.scrollBy(-1);return}if(h.pageDown){R.current?.scrollBy(10);return}if(h.pageUp){R.current?.scrollBy(-10);return}if(h.home){R.current?.scrollToTop();return}if(h.end){R.current?.scrollToBottom();return}h.escape&&k("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,P=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(E("container"),A(""),w(""),_("key")):r.fieldIndex===P&&(E("remote"),A(""),w(""),_("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(Z(!0),z(""),G(""),K("volume"),$("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(X(!0),T(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const j=ue(r.extensionSearch)[r.fieldIndex];j&&t.toggleExtension(j.id);break}case"features":{const j=de(r.featureSearch)[r.fieldIndex];j&&t.toggleFeature(j.id);break}case"general":{const d=Ie-ce.length,j=r.fieldIndex-d;if(j>=0&&j<ce.length){const P=ce[j];t.updateConfig({[P]:!r.config[P]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";E(j),A(""),w(""),_("key")}else r.section==="mounts"&&(Z(!0),z(""),G(""),K("volume"),$("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const P=r.fieldIndex-d.length-1;P>=0&&P<j.length&&(t.removeEnvVar("remote",j[P]),j.length===1||P>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!U&&I===null&&!oe});const Fe=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(c<ye||l<Se)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",ye,"x",Se]})});if(r.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),V.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(s,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let F;switch(r.section){case"compose":{F=e.jsx(xt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{F=e.jsxs(s,{flexDirection:"column",children:[e.jsx(vt,{config:r.config,fieldIndex:r.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:S||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[S,"=",e.jsx(o,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{F=e.jsx(wt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.extensionSearch,viewportHeight:J});break}case"features":{F=e.jsx(yt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.featureSearch,viewportHeight:J});break}case"general":{F=e.jsx(Et,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{F=e.jsx(Tt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{F=e.jsx(Ft,{addingMount:oe,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:O,mountSource:re,mountTarget:ne,mountType:me,suggestedMounts:r.suggestedMounts});break}case"ports":{F=e.jsx(Lt,{addingPort:U,addPortValue:Q,config:r.config,fieldIndex:r.fieldIndex});break}default:F=e.jsx(o,{children:"Unknown section"})}const Le=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[b&&e.jsxs(o,{color:b.startsWith("Error")?"red":"green",children:[b," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!b&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs(We,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Pe=e.jsx(Ot,{focused:D==="preview",hadComments:r.hadComments,jsonPreview:Fe,mode:r.mode,scrollRef:R}),fe=c>=Mt,Me=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(tt,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),k("editor")},showIndex:!1,children:Te.map(({id:u,label:h})=>e.jsx(ot,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Nt.get(r.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:D==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:F}),fe&&e.jsx(s,{flexShrink:0,width:Me,children:Pe})]}),Le,e.jsx(Ve,{autoExitSeconds:3,onCancel:()=>{g(!1)},visible:f}),Oe]})},Kt=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,r=t.output,a=!!process.stdout.isTTY&&!Xe;let m=null;try{m=Ke(c).name}catch{}const f=nt(c);let g=f?.config??null;const v=f?.hadComments??!1;if(l&&!f){const k=V.find(M=>M.id===l);if(!k){const M=V.map(L=>L.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${M}`)}g=k.config}if(!a){g?i.info(JSON.stringify(g,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),b=new lt(g,v,m);l&&!f&&b.dismissTemplateSelector();let y=null;if(await Ue(He.createElement(Bt,{onSave:k=>{it(c,k,r),y=k},store:b}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),y){const k=r??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${k}`)}};export{Kt as default};