@visulima/vis 6.1.0 → 6.1.1

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 (175) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/config/index.d.ts +1226 -1216
  5. package/dist/packem_chunks/bloom-sync.js +1 -1
  6. package/dist/packem_chunks/cargo-lock.js +5 -0
  7. package/dist/packem_chunks/cargo-plan.js +3 -3
  8. package/dist/packem_chunks/catalog-detector.js +1 -1
  9. package/dist/packem_chunks/catalog.js +1 -94
  10. package/dist/packem_chunks/catalog2.js +11 -0
  11. package/dist/packem_chunks/cli-exec.js +1 -1
  12. package/dist/packem_chunks/cli-main.js +156 -174
  13. package/dist/packem_chunks/context.js +8 -0
  14. package/dist/packem_chunks/fix.js +1 -1
  15. package/dist/packem_chunks/handler10.js +1 -1
  16. package/dist/packem_chunks/handler12.js +1 -1
  17. package/dist/packem_chunks/handler13.js +1 -1
  18. package/dist/packem_chunks/handler14.js +1 -1
  19. package/dist/packem_chunks/handler15.js +1 -1
  20. package/dist/packem_chunks/handler19.js +5 -5
  21. package/dist/packem_chunks/handler2.js +1 -1
  22. package/dist/packem_chunks/handler20.js +1 -1
  23. package/dist/packem_chunks/handler21.js +1 -1
  24. package/dist/packem_chunks/handler23.js +1 -1
  25. package/dist/packem_chunks/handler24.js +1 -1
  26. package/dist/packem_chunks/handler25.js +1 -1
  27. package/dist/packem_chunks/handler28.js +1 -1
  28. package/dist/packem_chunks/handler3.js +1 -1
  29. package/dist/packem_chunks/handler31.js +1 -1
  30. package/dist/packem_chunks/handler32.js +1 -1
  31. package/dist/packem_chunks/handler33.js +1 -1
  32. package/dist/packem_chunks/handler34.js +3 -3
  33. package/dist/packem_chunks/handler35.js +1 -1
  34. package/dist/packem_chunks/handler36.js +1 -1
  35. package/dist/packem_chunks/handler38.js +2 -2
  36. package/dist/packem_chunks/handler39.js +5 -5
  37. package/dist/packem_chunks/handler4.js +4 -4
  38. package/dist/packem_chunks/handler40.js +1 -1
  39. package/dist/packem_chunks/handler41.js +1 -1
  40. package/dist/packem_chunks/handler42.js +1 -1
  41. package/dist/packem_chunks/handler43.js +1 -1
  42. package/dist/packem_chunks/handler44.js +1 -1
  43. package/dist/packem_chunks/handler45.js +1 -1
  44. package/dist/packem_chunks/handler46.js +1 -1
  45. package/dist/packem_chunks/handler47.js +1 -1
  46. package/dist/packem_chunks/handler48.js +1 -1
  47. package/dist/packem_chunks/handler49.js +1 -1
  48. package/dist/packem_chunks/handler5.js +4 -4
  49. package/dist/packem_chunks/handler50.js +5 -5
  50. package/dist/packem_chunks/handler52.js +1 -1
  51. package/dist/packem_chunks/handler54.js +2 -2
  52. package/dist/packem_chunks/handler55.js +1 -1
  53. package/dist/packem_chunks/handler56.js +3 -3
  54. package/dist/packem_chunks/handler57.js +4 -4
  55. package/dist/packem_chunks/handler58.js +4 -4
  56. package/dist/packem_chunks/handler59.js +2 -2
  57. package/dist/packem_chunks/handler6.js +7 -7
  58. package/dist/packem_chunks/handler60.js +1 -1
  59. package/dist/packem_chunks/handler61.js +2 -2
  60. package/dist/packem_chunks/handler62.js +1 -1
  61. package/dist/packem_chunks/handler63.js +3 -3
  62. package/dist/packem_chunks/handler64.js +3 -3
  63. package/dist/packem_chunks/handler65.js +2 -2
  64. package/dist/packem_chunks/handler66.js +2 -2
  65. package/dist/packem_chunks/handler67.js +5 -5
  66. package/dist/packem_chunks/handler68.js +12 -25
  67. package/dist/packem_chunks/handler69.js +25 -22
  68. package/dist/packem_chunks/handler70.js +22 -10
  69. package/dist/packem_chunks/handler71.js +10 -133
  70. package/dist/packem_chunks/handler72.js +133 -23
  71. package/dist/packem_chunks/handler73.js +23 -323
  72. package/dist/packem_chunks/handler74.js +274 -659
  73. package/dist/packem_chunks/handler75.js +708 -48
  74. package/dist/packem_chunks/handler76.js +48 -27
  75. package/dist/packem_chunks/handler77.js +27 -3
  76. package/dist/packem_chunks/handler78.js +3 -191
  77. package/dist/packem_chunks/handler79.js +191 -0
  78. package/dist/packem_chunks/handler8.js +1 -1
  79. package/dist/packem_chunks/heal.js +2 -2
  80. package/dist/packem_chunks/help-command.js +1 -1
  81. package/dist/packem_chunks/index2.js +3 -58
  82. package/dist/packem_chunks/index3.js +40 -3
  83. package/dist/packem_chunks/index6.js +135 -7
  84. package/dist/packem_chunks/index7.js +7 -135
  85. package/dist/packem_chunks/keys-refresh.js +1 -1
  86. package/dist/packem_chunks/list.js +2 -2
  87. package/dist/packem_chunks/prune.js +1 -1
  88. package/dist/packem_chunks/python-plan.js +3 -3
  89. package/dist/packem_chunks/python-projects.js +1 -1
  90. package/dist/packem_chunks/python.js +1 -0
  91. package/dist/packem_chunks/run.js +1 -1
  92. package/dist/packem_chunks/snapshot.js +2 -2
  93. package/dist/packem_chunks/state.js +2 -2
  94. package/dist/packem_chunks/status.js +1 -1
  95. package/dist/packem_chunks/sync.js +1 -1
  96. package/dist/packem_chunks/verify-lockfile.js +1 -1
  97. package/dist/packem_chunks/version-resolver.js +1 -1
  98. package/dist/packem_chunks/workspace.js +2 -2
  99. package/dist/packem_shared/ReleaseClient-CWD9BC5w.js +1 -0
  100. package/dist/packem_shared/advisories-BodWQ5DQ.js +1 -0
  101. package/dist/packem_shared/{affected-selection-DGb6Xu5K.js → affected-selection-QaMUnFqe.js} +1 -1
  102. package/dist/packem_shared/{ai-analysis-pldoS_N4.js → ai-analysis-D7jlbJky.js} +3 -3
  103. package/dist/packem_shared/ai-cache-iSIyY3So.js +1 -0
  104. package/dist/packem_shared/{ai-fix-D9MxigBQ.js → ai-fix-CgCyO65Q.js} +6 -6
  105. package/dist/packem_shared/apply-DoeQAAGm.js +6 -0
  106. package/dist/packem_shared/apply-release-plan-BalHtK-g.js +15 -0
  107. package/dist/packem_shared/{bin-AZQv95jh.js → bin-LyW9KY0i.js} +1 -1
  108. package/dist/packem_shared/clean-package-json-rutwkKl-.js +1 -0
  109. package/dist/packem_shared/createAdapter-DMK4bBET.js +1 -0
  110. package/dist/packem_shared/createVersionActions-DXo4z8VN.js +1 -0
  111. package/dist/packem_shared/dependency-scan-DFnt1mni.js +1 -0
  112. package/dist/packem_shared/{ecosystem-gate-DiqQj0LJ.js → ecosystem-gate-Bdz-gK_Y.js} +1 -1
  113. package/dist/packem_shared/env-BSXG3QKH.js +4 -0
  114. package/dist/packem_shared/failure-log-DIsKBKaI.js +2 -0
  115. package/dist/packem_shared/formatBytes-_HvjOy8a-iHCer6uX.js +1 -0
  116. package/dist/packem_shared/glob-Cyk1H9ZL-DRlUeuow.js +1 -0
  117. package/dist/packem_shared/{index-JRb5wabN.js → index-B1ZsG3oa.js} +1 -1
  118. package/dist/packem_shared/index-CgNfNk12.js +1 -0
  119. package/dist/packem_shared/lifecycle-CQjeMPY0.js +2 -0
  120. package/dist/packem_shared/missing-package-json-dtwl6w-S.js +1 -0
  121. package/dist/packem_shared/multi-eco-lockfiles-CyIfYw4u.js +1 -0
  122. package/dist/packem_shared/npmrc-CHsOyMvA.js +2 -0
  123. package/dist/packem_shared/osv-C53WUoSW.js +1 -0
  124. package/dist/packem_shared/{package-version-KLwH0Ivy.js → package-version-DqYSd_ia.js} +1 -1
  125. package/dist/packem_shared/packument-CbTmbHU4.js +1 -0
  126. package/dist/packem_shared/{project-name-filter-B1ZCsbOW.js → project-name-filter-mwTJC1IK.js} +1 -1
  127. package/dist/packem_shared/{provenance-L1M2FPy_.js → provenance-SX1MxPUZ.js} +1 -1
  128. package/dist/packem_shared/publish-Dc0XGH3K.js +34 -0
  129. package/dist/packem_shared/registry-CkoaWkjP.js +81 -0
  130. package/dist/packem_shared/registry-keys-z038Ecb4.js +1 -0
  131. package/dist/packem_shared/removeSync-g1D5kONg-LbjATA8v.js +1 -0
  132. package/dist/packem_shared/renderToString-DR0zDUjh-C7p-L6AO.js +3 -0
  133. package/dist/packem_shared/{resolve-explicit-CQa37JSq.js → resolve-explicit-D9kdTNvl.js} +1 -1
  134. package/dist/packem_shared/{run-D-uVGHQ4.js → run-DLvd3RIZ.js} +1 -1
  135. package/dist/packem_shared/run-summary-utils-CMeURYtS.js +1 -0
  136. package/dist/packem_shared/s1ngularity-BuU9Cxpy.js +1 -0
  137. package/dist/packem_shared/{scaffold-files-DVyfB0yz.js → scaffold-files-Bje3_Ixv.js} +1 -1
  138. package/dist/packem_shared/scan-progress-D8ojNcKt.js +2 -0
  139. package/dist/packem_shared/{signatures-DIqFUOfs.js → signatures-CeL0bOEo.js} +1 -1
  140. package/dist/packem_shared/spinner-Bqjpz3i4.js +1 -0
  141. package/dist/packem_shared/table-DDAJalPF.js +1 -0
  142. package/dist/packem_shared/tabs-CC0GJLww.js +1 -0
  143. package/dist/packem_shared/{task-env-DzR4RkOj.js → task-env-C2lmxvzA.js} +1 -1
  144. package/dist/packem_shared/typosquats-BFKus_aM.js +1 -0
  145. package/dist/packem_shared/use-measured-height-_nYuZ-Au.js +1 -0
  146. package/dist/packem_shared/vis-update-app-Ba5ce8Jd.js +1 -0
  147. package/dist/packem_shared/{vis-user-error-CRmrBaD1.js → vis-user-error-D_ekz9rF.js} +1 -1
  148. package/dist/packem_shared/{watch-loop-D1_e-qIl.js → watch-loop-DWr41vHM.js} +1 -1
  149. package/dist/packem_shared/xxh3-BLHlvhgT.js +1 -0
  150. package/dist/release/core/package-managers/index.js +1 -1
  151. package/dist/release/core/version-actions/index.js +1 -1
  152. package/dist/release/index.js +1 -1
  153. package/index.js +26 -26
  154. package/package.json +9 -9
  155. package/dist/packem_chunks/orchestrator.js +0 -46
  156. package/dist/packem_shared/ReleaseClient-DAvbxCdo.js +0 -1
  157. package/dist/packem_shared/createAdapter-F7GidOzU.js +0 -1
  158. package/dist/packem_shared/createVersionActions-ByaJ1Nbv.js +0 -1
  159. package/dist/packem_shared/dependency-scan-CawAKoU_.js +0 -1
  160. package/dist/packem_shared/failure-log-BP-gCUb5.js +0 -2
  161. package/dist/packem_shared/formatBytes-_HvjOy8a-B_qQr4Hw.js +0 -4
  162. package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +0 -1
  163. package/dist/packem_shared/index-CDHP1kby.js +0 -1
  164. package/dist/packem_shared/lifecycle-DvmDIRbb.js +0 -2
  165. package/dist/packem_shared/missing-package-json-Cu5YVAot.js +0 -1
  166. package/dist/packem_shared/multi-eco-lockfiles-B2X3yhyo.js +0 -1
  167. package/dist/packem_shared/packument-zb18Jnlw.js +0 -1
  168. package/dist/packem_shared/registry-keys-DxdqMzyp.js +0 -1
  169. package/dist/packem_shared/s1ngularity-CO5GkkqX.js +0 -1
  170. package/dist/packem_shared/scan-progress-RwCRxJdX.js +0 -2
  171. package/dist/packem_shared/spinner-BJjbNl1F.js +0 -1
  172. package/dist/packem_shared/tabs--uxJGL8N.js +0 -1
  173. package/dist/packem_shared/typosquats-D4DEHhFy.js +0 -1
  174. package/dist/packem_shared/use-measured-height-DUZyyias.js +0 -1
  175. package/dist/packem_shared/vis-update-app-9b2kSk9f.js +0 -1
@@ -1,3 +1,27 @@
1
- import{createRequire as Ne}from"node:module";import{C as W,V as Ce,U as ze,W as Ge,T as $e,X as We,Y as Ve,q as Ue}from"./cli-main.js";import{i as Xe}from"../packem_shared/index-BjdW45xX.js";import{x as p,F as e,X as s,o,R as He}from"./catalog.js";import{d as qe}from"../packem_shared/pm-runner-RM72mDZg.js";import{h as Je,e as le,z as Ye,m as Qe}from"../packem_shared/index-BzhrR_iC.js";import{y as Ze}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{h as et}from"../packem_shared/writeFileSync-DJoHk3Ks-BPRoepNw.js";import{n as tt,a as ot}from"../packem_shared/tabs--uxJGL8N.js";let Re;const _e=i=>(Re??=Ne(import.meta.url))(i),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=i=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,n]=J.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return J.getBuiltinModule(i)}return _e(i)},{writeFileSync:Ke}=Be("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(Je,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),Ke(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"}],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},_=["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=(_.indexOf(this.#e.section)+1)%_.length;this.setSection(_[n])}previousSection(){const n=(_.indexOf(this.#e.section)-1+_.length)%_.length;this.setSection(_[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}},_t=({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,B]=p.useState("key"),[oe,Z]=p.useState(!1),[re,z]=p.useState(""),[ne,G]=p.useState(""),[me,q]=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),K=Math.max(1,l-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||L(u=>r.fieldIndex>=u+K?r.fieldIndex-K+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,K]),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(""),B("key");return}if(h.return){if(C==="key"&&S){B("value");return}if(C==="value"&&S){t.addEnvVar(I,S,H),E(null),A(""),w(""),B("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":{q("volume");break}case"2":{q("bind");break}case"3":{q("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(""),B("key")):r.fieldIndex===P&&(E("remote"),A(""),w(""),B("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(Z(!0),z(""),G(""),q("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(""),B("key")}else r.section==="mounts"&&(Z(!0),z(""),G(""),q("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:K});break}case"features":{F=e.jsx(yt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.featureSearch,viewportHeight:K});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]})},qt=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=qe(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(_t,{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{qt as default};
1
+ import{createRequire as wt}from"node:module";import{a as x,$ as nt,U as yt,v as it,e as P,q as Tt}from"../packem_shared/index-BzhrR_iC.js";import{j as m,X as E,O as b,l as vt,i as St}from"../packem_shared/registry-CkoaWkjP.js";import at from"./index.js";import{x as ot}from"../packem_shared/main-CgDAlZkm.js";import{y as B}from"../packem_shared/isAccessibleSync-DYKTrrvc-C-_5cgwu.js";import{q as $t}from"./cli-main.js";import{l as At}from"../packem_shared/spinner-Bqjpz3i4.js";import{C as ct,D as O,T as dt}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-Ca_EEVfw.js";import{withEnhancedPath as Mt}from"@visulima/task-runner";let mt;const kt=t=>(mt??=wt(import.meta.url))(t),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,G=t=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,s]=I.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return I.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 R 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 lt=t=>t.includes("/"),F=(t,e)=>e?t.toLowerCase():t,jt=(t,e,s,r={})=>{const n=lt(t),i=r.caseInsensitive===!0,c=F(t,i),a=[];for(const o of e){const l=n?x(s,o):nt(o);at(c,F(l,i))&&a.push(o)}return a},_t=(t,e,s,r={})=>{if(!e||e.length===0)return[...t];const n=r.caseInsensitive===!0;return t.filter(i=>{for(const c of e){const a=lt(c)?x(s,i):nt(i),o=F(c,n);if(at(o,F(a,n)))return!1}return!0})},q=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("..")&&!it(s)},Ot=(t,e)=>{let s;for(const r of e)Pt(r,t)&&(s===void 0||r.length>s.length)&&(s=r);return s},Ft=async t=>{let e=0,s=0;const r=()=>(e+=1,`pattern-${e}`),n=()=>(s+=1,`cmd-${s}`),i=(o,l,f,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],g=new Map;for(const h of f){const w=Ot(h,u)??t.cwd,k=g.get(w)??[];k.push(x(w,h)),g.set(w,k)}for(const h of[...g.keys()].sort()){const w=x(t.cwd,h)||".";d.push({command:o.command,cwd:h,files:g.get(h)??[],id:n(),source:"string",title:`${o.command} — ${w}`})}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)){i(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))i(g,l,f,d);else if(q(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)){i(u,l,f,d);return}if(q(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(q(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 }.")},a=[];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&&a.push({commands:u,files:d,id:r(),pattern:o,title:`${o} — ${f.length} file${f.length===1?"":"s"}`})}return a},Nt=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.");ut(s,r)}return t},ut=(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)ut(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,p=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),r=await ot("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:i}=r,c=i.length>Y?`${i.slice(0,Y)}…`:i;throw new R(`git ${t.join(" ")} failed with exit code ${n}: ${c.trim()}`,i)}return{exitCode:n,stderr:r.stderr,stdout:r.stdout}},j=async(t,e)=>{const{stdout:s}=await p(t,e);return s.trim()},Lt=async t=>{const e=await p(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},qt=async t=>j(["rev-parse","--absolute-git-dir"],{cwd:t}),ft=async t=>j(["rev-parse","--show-toplevel"],{cwd:t}),J=async t=>j(["write-tree"],{cwd:t}),Ut=async t=>{const e=await p(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},M={major:2,minor:32},Gt=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}},Ht=async t=>{const e=Gt(await j(["--version"],{cwd:t}));if(e===null)return;if(e.major<M.major||e.major===M.major&&e.minor<M.minor)throw new R(`Git ${M.major}.${M.minor} or newer is required; found ${e.major}.${e.minor}.`)},Bt="ACMR",Z=500,zt=async t=>{const{stdout:e}=await p(["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 i=s[n];if(!i?.startsWith(":"))continue;const c=i.slice(1).split(" "),a=c[3],o=c[4],l=s[n+1];n+=1,o==="A"&&a!==void 0&&/^0+$/.test(a)&&l!==void 0&&r.push(l)}return r},Q=async t=>{const{stdout:e}=await p(["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 p(["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 p(s,{cwd:t.cwd}),n=r.split("\0").filter(c=>c.length>0);if(n.length===0)return[];const i=t.workTree??await ft(t.cwd);return n.map(c=>it(c)?c:P(i,c))},Xt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let i=0;i<t.length;i+=Z){const c=t.slice(i,i+Z),{stdout:a}=await p(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});a.length>0&&s.push(a)}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 p(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),r=[];for(let n=0;n<s.length;n+=1){const i=s[n];if(i===void 0||i.length<4)continue;const c=i.charAt(0),a=i.charAt(1),o=i.slice(3),l=c==="R"||c==="C"||a==="R"||a==="C";c!==" "&&c!=="?"&&a!==" "&&a!=="?"&&r.push(o),l&&(n+=1)}return r},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await p(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await p(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await p(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Zt="vis_staged_automatic_backup",ht=()=>`${Zt}-${process.pid}-${Date.now()}-${Et(3).toString("hex")}`,Qt=async t=>{const e=await j(["stash","create"],{cwd:t});return e.length===0?null:(await p(["stash","store","-m",ht(),e],{cwd:t}),e)},te=async(t,e)=>{const{exitCode:s,stdout:r}=await p(["reflog","--format=%H %gs","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const i=n.indexOf(" ");if(i!==-1&&n.slice(i+1).includes(e))return n.slice(0,i)}return null},ee=async t=>{const e=ht(),{exitCode:s,stdout:r}=await p(["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:te(t,e)},se=async(t,e)=>{const{exitCode:s,stdout:r}=await p(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const n of r.split(/\r?\n/)){const[i,c]=n.split(/\s+/,2);if(i===e&&c!==void 0)return c}return null},gt=async(t,e)=>{const{exitCode:s}=await p(["rev-parse","--verify","--quiet",`${e}^{commit}`],{cwd:t,lenient:!0});return s===0},re=async(t,e)=>{const s=await se(t,e);if(s===null)return null;const{exitCode:r,stdout:n}=await p(["rev-parse","--verify","--quiet",s],{cwd:t,lenient:!0});return r===0&&n.trim()===e?s:null},U=async(t,e)=>{if(e===null)return;const s=await re(t,e);s!==null&&await p(["stash","drop","--quiet",s],{cwd:t})},ne=async(t,e)=>{if(e===null)throw new W("Backup stash was not found — can't revert working tree.");if(!await gt(t,e))throw new W(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await p(["reset","--hard","HEAD"],{cwd:t}),await p(["stash","apply","--index","--quiet",e],{cwd:t})},ie=async(t,e)=>{e!==null&&await gt(t,e)&&(await p(["stash","apply","--quiet",e],{cwd:t}),await U(t,e))};class ae{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 R(`Not a git repository: ${this.cwd}`);await Ht(this.cwd),this.workTree=await ft(this.cwd),this.gitDir=await qt(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 ee(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await J(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await Ut(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(i=>!this.preTaskUntracked.has(i));if(n.length>0){const i=`${n.join("\0")}\0`;await p(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:i})}}if(this.intentToAddPaths.length>0)try{await p(["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 p(e,{cwd:this.workTree,input:this.patch});return}catch(r){s=r instanceof R?r.stderr:String(r)}try{await p([...e,"--3way"],{cwd:this.workTree,input:this.patch})}catch(r){const n=r instanceof R&&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 ne(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 U(this.workTree,this.backupStashSha),this.intentToAddPaths.length>0)try{await p(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),this.hideAllStashSha!==null)try{await ie(this.workTree,this.hideAllStashSha)}catch{}e&&this.backupStashSha!==null&&!this.revertApplied&&await U(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 oe=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},tt=t=>{if(t==="running")return m.jsx(At,{type:"dots"});const e=t==="failed"?ct:t==="skipped"?O:t==="success"?dt:O;return m.jsx(b,{color:oe(t),children:e})},et=({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:[tt(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:[tt(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((i,c)=>m.jsx(b,{color:"gray",children:i},`${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}`))]}),ce=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let r=0;const n=$t(m.jsx(et,{state:s,tick:r,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),i=()=>{r+=1,n.rerender(m.jsx(et,{state:s,tick:r,verbose:e}))};return{commandEnd({commandId:c,durationMs:a,error:o,output:l,patternId:f,status:d}){const u=s.patterns.get(f)?.commands.get(c);u&&(u.status=d,u.durationMs=a,u.output=l,u.error=o,i())},commandStart({commandId:c,patternId:a}){const o=s.patterns.get(a)?.commands.get(c);o&&(o.status="running",i())},error({error:c,message:a}){s.errorMessages.push({error:c,message:a}),i()},info({message:c}){s.infoMessages.push(c),i()},patternEnd({patternId:c,status:a}){const o=s.patterns.get(c);o&&(o.status=a,i())},patternStart({patternId:c}){const a=s.patterns.get(c);a&&(a.status="running",i())},start({patterns:c}){s.started=!0;for(const a of c){const o=new Map;for(const l of a.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(a.id,{commands:o,id:a.id,status:"pending",title:a.title})}i()},async stop(){n.unmount(),await n.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),i()}}},st=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,r=new Map,n=new Map,i=a=>{e||process.stderr.write(`${a}
14
+ `)},c=a=>{switch(a){case"failed":return L(ct);case"running":return D(">");case"skipped":return z(O);case"success":return It(dt);default:return C(O)}};return{commandEnd({commandId:a,durationMs:o,error:l,output:f,status:d}){const u=n.get(a)??a,g=C(`(${o}ms)`);if(i(` ${c(d)} ${u} ${g}`),d==="failed"&&l&&i(C(l.message)),(d==="failed"||s)&&f&&f.trim().length>0)for(const h of f.split(/\r?\n/))i(` ${C(h)}`)},commandStart({commandId:a}){if(!s)return;const o=n.get(a)??a;i(` ${C("…")} ${o}`)},error({error:a,message:o}){e?process.stderr.write(`${L(o)}
15
+ `):i(L(o)),a?.stack&&(s||!e)&&process.stderr.write(`${C(a.stack)}
16
+ `)},info({message:a}){i(C(a))},patternEnd({patternId:a,status:o}){const l=r.get(a)??a;i(`${c(o)} ${l}`)},patternStart({patternId:a}){const o=r.get(a)??a;i(`${D(">")} ${o}`)},start({patterns:a}){if(a.length===0){i(C("No staged files matched any pattern."));return}const o=new Set(a.flatMap(l=>l.files)).size;i(`${D(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const l of a){r.set(l.id,l.title);for(const f of l.commands)n.set(f.id,f.title)}},stop(){},warn({message:a}){i(z(a))}}},de=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 st({quiet:t.quiet,verbose:t.verbose});try{return ce({verbose:t.verbose})}catch{return st({quiet:t.quiet,verbose:t.verbose})}},le=t=>{const e=[];let s="",r=!1,n=!1;for(let i=0;i<t.length;i+=1){const c=t[i];if(c===void 0)break;if(c==="\\"&&!r&&i+1<t.length){const a=t[i+1];if(a!==void 0){n&&a!=='"'&&a!=="\\"&&(s+=c),s+=a,i+=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,ue=(t,e,s)=>{const r=[];let n=[],i=e;const c=s<=0?pt:s;for(const a of t){const o=Buffer.byteLength(a)+1;n.length>0&&i+o>c&&(r.push(n),n=[],i=e),n.push(a),i+=o}return n.length>0&&r.push(n),r},fe=async(t,e,s)=>{const r=le(t);if(r.length===0)throw new $(t,"Empty command for staged task.");const[n,...i]=r;if(n===void 0)throw new $(t,"Empty command for staged task.");const c=Buffer.byteLength(n)+i.reduce((f,d)=>f+Buffer.byteLength(d)+1,0),a=ue(e,c,s.maxArgLength??pt),o=Date.now(),l=[];for(const f of a){if(s.signal?.aborted===!0)throw new $(t,"Task aborted by earlier failure.");const d=ot(n,[...i,...f],{nodeOptions:{cwd:s.cwd,env:he(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(w=>w.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 w=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,w)}if(u.exitCode!==0)throw new $(t,g.trim()||`Exit code ${u.exitCode} from ${n}`)}return{durationMs:Date.now()-o,output:l.join(`
18
+ `)}},he=(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)},ge=async(t,e,s)=>{const r=we(s.concurrent,t.length),n=[],i=new AbortController;let c=!1,a=0;const o=()=>{c||(c=!0,s.continueOnError||i.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=h=>{for(const w of h.commands)e.commandEnd({commandId:w.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 w="success";for(const k of h.commands){if(c){e.commandEnd({commandId:k.id,durationMs:0,patternId:h.id,status:"skipped"}),w=w==="success"?"skipped":w;continue}e.commandStart({commandId:k.id,patternId:h.id});const v=await pe(k,s,i.signal),S=v.status==="failed"&&i.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),w="failed",o();break}if(S.status==="skipped"){w=w==="success"?"skipped":w;break}}e.patternEnd({patternId:h.id,status:w})},d=async()=>{for(;a<t.length;){const h=t[a];a+=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}},pe=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 fe(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 i=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-r,error:i,output:i instanceof $?i.message:void 0,status:"failed"}}},we=(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},me=!0,ke=t=>{try{return!Tt(t)}catch{return!1}},ye=t=>{try{const e=vt(t);return e?St(t,e).map(s=>P(t,s)):[]}catch{return[]}},Te=async(t={})=>{const e=t.cwd??process.cwd(),s=await de(t),r=await Nt(t);typeof r!="function"&&K(r);const n=new ae({...t,cwd:e}),i=new AbortController;let c=!1;const a=d=>{if(c){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),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.`}),i.abort()};process.on("SIGINT",a),process.on("SIGTERM",a);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=ke(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 Ft({caseInsensitive:d,config:g,cwd:e,files:u,relative:t.relative,workspacePackages:ye(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:w,success:k}=await ge(h,s,{concurrent:t.concurrent??me,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:i.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:w,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:[...w],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",a),process.removeListener("SIGTERM",a),l)try{await n.cleanup(f)}catch(d){s.error({error:d,message:"Cleanup failed."})}await s.stop()}},ve="VIS_STAGED_CONCURRENT",rt=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},Se=(t,e)=>{const s={};e!==void 0&&(s.config=e);const r=y=>t[y]===void 0?void 0:!!t[y],n=y=>{const N=t[y];return typeof N=="string"&&N.length>0?N:void 0},i=r("allow-empty");i!==void 0&&(s.allowEmpty=i);const c=r("auto-stage");c!==void 0&&(s.autoStage=c);const a=r("continue-on-error");a!==void 0&&(s.continueOnError=a);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 w=r("stash");w!==void 0&&(s.stash=w);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 H=n("diff-filter");if(H!==void 0&&(s.diffFilter=H),r("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const y=process.env[ve];y!==void 0&&(s.concurrent=rt(y.trim()))}else{const{concurrent:y}=t;s.concurrent=rt(typeof y=="string"?y:typeof y=="number"||typeof y=="boolean"?String(y):"")}return s},Oe=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 Te(Se(t,r))).success||(process.exitCode=1)};export{Se as buildRunOptions,Oe as default};