@visulima/vis 4.1.20 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/LICENSE.md +804 -360
  3. package/dist/bin.js +1 -1
  4. package/dist/binx.js +1 -1
  5. package/dist/config/index.d.ts +21 -0
  6. package/dist/packem_chunks/CONFIG_FILES.js +3 -3
  7. package/dist/packem_chunks/bloom-status.js +1 -1
  8. package/dist/packem_chunks/bloom-sync.js +1 -1
  9. package/dist/packem_chunks/catalog.js +49 -49
  10. package/dist/packem_chunks/cli-exec.js +1 -1
  11. package/dist/packem_chunks/cli-main.js +151 -147
  12. package/dist/packem_chunks/dispatch.js +1 -1
  13. package/dist/packem_chunks/fix.js +8 -8
  14. package/dist/packem_chunks/handler.js +1 -1
  15. package/dist/packem_chunks/handler10.js +3 -3
  16. package/dist/packem_chunks/handler11.js +1 -1
  17. package/dist/packem_chunks/handler12.js +2 -2
  18. package/dist/packem_chunks/handler13.js +1 -1
  19. package/dist/packem_chunks/handler14.js +1 -1
  20. package/dist/packem_chunks/handler15.js +1 -1
  21. package/dist/packem_chunks/handler16.js +1 -1
  22. package/dist/packem_chunks/handler17.js +1 -1
  23. package/dist/packem_chunks/handler18.js +1 -1
  24. package/dist/packem_chunks/handler19.js +1 -1
  25. package/dist/packem_chunks/handler2.js +1 -1
  26. package/dist/packem_chunks/handler20.js +2 -2
  27. package/dist/packem_chunks/handler21.js +1 -1
  28. package/dist/packem_chunks/handler22.js +1 -1
  29. package/dist/packem_chunks/handler23.js +1 -1
  30. package/dist/packem_chunks/handler24.js +1 -1
  31. package/dist/packem_chunks/handler26.js +1 -1
  32. package/dist/packem_chunks/handler27.js +1 -1
  33. package/dist/packem_chunks/handler28.js +1 -1
  34. package/dist/packem_chunks/handler29.js +1 -1
  35. package/dist/packem_chunks/handler3.js +2 -2
  36. package/dist/packem_chunks/handler30.js +1 -1
  37. package/dist/packem_chunks/handler5.js +1 -1
  38. package/dist/packem_chunks/handler51.js +1 -1
  39. package/dist/packem_chunks/handler52.js +3 -3
  40. package/dist/packem_chunks/handler53.js +1 -1
  41. package/dist/packem_chunks/handler54.js +2 -2
  42. package/dist/packem_chunks/handler55.js +1 -1
  43. package/dist/packem_chunks/handler58.js +2 -2
  44. package/dist/packem_chunks/handler59.js +1 -1
  45. package/dist/packem_chunks/handler6.js +1 -1
  46. package/dist/packem_chunks/handler60.js +8 -8
  47. package/dist/packem_chunks/handler61.js +1 -1
  48. package/dist/packem_chunks/handler62.js +16 -16
  49. package/dist/packem_chunks/handler63.js +2 -2
  50. package/dist/packem_chunks/handler64.js +1 -1
  51. package/dist/packem_chunks/handler65.js +3 -3
  52. package/dist/packem_chunks/handler66.js +2 -2
  53. package/dist/packem_chunks/handler67.js +10 -10
  54. package/dist/packem_chunks/handler68.js +2 -2
  55. package/dist/packem_chunks/handler69.js +3 -3
  56. package/dist/packem_chunks/handler7.js +1 -1
  57. package/dist/packem_chunks/handler70.js +3 -3
  58. package/dist/packem_chunks/handler71.js +2 -2
  59. package/dist/packem_chunks/handler72.js +2 -2
  60. package/dist/packem_chunks/handler73.js +2 -2
  61. package/dist/packem_chunks/handler74.js +1 -1
  62. package/dist/packem_chunks/handler75.js +18 -18
  63. package/dist/packem_chunks/handler76.js +3 -3
  64. package/dist/packem_chunks/handler77.js +2 -2
  65. package/dist/packem_chunks/handler78.js +64 -64
  66. package/dist/packem_chunks/handler8.js +1 -1
  67. package/dist/packem_chunks/handler9.js +1 -1
  68. package/dist/packem_chunks/heal-accept.js +1 -1
  69. package/dist/packem_chunks/heal.js +1 -1
  70. package/dist/packem_chunks/help-command.js +7 -7
  71. package/dist/packem_chunks/index5.js +2 -2
  72. package/dist/packem_chunks/index6.js +7 -8
  73. package/dist/packem_chunks/keys-refresh.js +1 -1
  74. package/dist/packem_chunks/lean.js +1 -1
  75. package/dist/packem_chunks/list.js +2 -2
  76. package/dist/packem_chunks/loader.js +1 -1
  77. package/dist/packem_chunks/prune.js +1 -1
  78. package/dist/packem_chunks/status.js +1 -1
  79. package/dist/packem_chunks/sync.js +1 -1
  80. package/dist/packem_chunks/sync2.js +1 -1
  81. package/dist/packem_chunks/tripwire.js +2 -2
  82. package/dist/packem_chunks/ts-loader.js +5 -5
  83. package/dist/packem_chunks/verify-lockfile.js +2 -2
  84. package/dist/packem_shared/Table-BB8xHTU5-BLPS917D.js +11 -0
  85. package/dist/packem_shared/{advisories-0ScpWAHV.js → advisories-BSpzRIXP.js} +1 -1
  86. package/dist/packem_shared/affected-selection-M7riOi5-.js +1 -0
  87. package/dist/packem_shared/{affected-shas-Dd0P7fGD.js → affected-shas-CAwpSPmP.js} +1 -1
  88. package/dist/packem_shared/{ai-fix-BHyx1F1j.js → ai-fix-BTm1Z5og.js} +1 -1
  89. package/dist/packem_shared/{augment-COAiXSIx.js → augment-CBv1hwMR.js} +1 -1
  90. package/dist/packem_shared/{bin-Bq3tJmvE.js → bin-Cbs_ix6l.js} +1 -1
  91. package/dist/packem_shared/build-scripts-BIgkWVgY.js +1 -0
  92. package/dist/packem_shared/{command-runtime-CiLVo4ED.js → command-runtime-BD-4UmPB.js} +1 -1
  93. package/dist/packem_shared/{cyclonedx-CX2fFvDi.js → cyclonedx-CT1rtKxV.js} +3 -3
  94. package/dist/packem_shared/dependency-scan-W9b2X0a1.js +1 -0
  95. package/dist/packem_shared/{docker-Dy-X_BuM.js → docker-1jgKW5Wd.js} +3 -3
  96. package/dist/packem_shared/failure-log-B91LvYWw.js +2 -0
  97. package/dist/packem_shared/formatBytes-BHAzNIrn-CLYsxlUj.js +4 -0
  98. package/dist/packem_shared/glob-Cyk1H9ZL-Dxlf9Swz.js +1 -0
  99. package/dist/packem_shared/{index-DHD8wb6Z.js → index-CVBR-Kit.js} +5 -5
  100. package/dist/packem_shared/{index-Vm90Te96.js → index-Cq-J2MdB.js} +1 -1
  101. package/dist/packem_shared/index-onibYJkv.js +1 -0
  102. package/dist/packem_shared/{isAccessibleSync-DYKTrrvc-CSnBISfV.js → isAccessibleSync-DYKTrrvc-K2xhg6sV.js} +1 -1
  103. package/dist/packem_shared/lifecycle-DDJzp-4H.js +2 -0
  104. package/dist/packem_shared/lockfile-Bi1mw9jJ.js +1 -0
  105. package/dist/packem_shared/manifests-D671Sb1T.js +1 -0
  106. package/dist/packem_shared/{min-release-age-ChzTC7_I.js → min-release-age-Da4V046o.js} +7 -7
  107. package/dist/packem_shared/missing-package-json-CMoHdvmj.js +1 -0
  108. package/dist/packem_shared/{native-config-sync-BSzU4qUO.js → native-config-sync-CEB0rWlk.js} +2 -2
  109. package/dist/packem_shared/{osv-bloom-JYIWcH3F.js → osv-bloom-BRacgzs7.js} +1 -1
  110. package/dist/packem_shared/{package-version-DFlytdgJ.js → package-version-C5EPMgRw.js} +2 -2
  111. package/dist/packem_shared/packument-DuEV-qSE.js +1 -0
  112. package/dist/packem_shared/path-CxEa27Rz-pjheKk6v.js +1 -0
  113. package/dist/packem_shared/pm-runner-9L6ocnu2.js +1 -0
  114. package/dist/packem_shared/{project-name-filter-CC5FF49q.js → project-name-filter-zrdrEQbu.js} +1 -1
  115. package/dist/packem_shared/{provenance-BH80RHXx.js → provenance-CFPT_FQA.js} +1 -1
  116. package/dist/packem_shared/readJsonSync-CbryXYxN-BxKjDZnF.js +1 -0
  117. package/dist/packem_shared/registry-keys-C3EsP_s4.js +1 -0
  118. package/dist/packem_shared/{resolve-explicit-DuJ3mbzt.js → resolve-explicit-opfIkxoY.js} +1 -1
  119. package/dist/packem_shared/resolve-runtime-lJ5L9gU4.js +1 -0
  120. package/dist/packem_shared/run-file-DZff6GqY.js +1 -0
  121. package/dist/packem_shared/runtime-check-DAbveBr_.js +1 -0
  122. package/dist/packem_shared/s1ngularity-DTvrfWIM.js +1 -0
  123. package/dist/packem_shared/{scan-progress-DRIGQRMr.js → scan-progress-BGB9hIrD.js} +2 -2
  124. package/dist/packem_shared/{selectors-B7lSFz7l.js → selectors-CjIZ3gy2.js} +1 -1
  125. package/dist/packem_shared/{signatures-BP042BlB.js → signatures-DpqZVmmU.js} +1 -1
  126. package/dist/packem_shared/spinner-BVCEMm3G.js +1 -0
  127. package/dist/packem_shared/{tabs-UDYQ3tqt.js → tabs-Dz6xVpfX.js} +1 -1
  128. package/dist/packem_shared/{target-merge-B4No-LHM.js → target-merge-hsawesT4.js} +1 -1
  129. package/dist/packem_shared/target-options-Bxb0Y5qa.js +1 -0
  130. package/dist/packem_shared/toolchain-887JoquG.js +5 -0
  131. package/dist/packem_shared/typosquats-Xv6dN4sr.js +1 -0
  132. package/dist/packem_shared/verify-BLoaI7En.js +1 -0
  133. package/dist/packem_shared/{vis-update-app-CR21zyht.js → vis-update-app-D9KWJ9Ir.js} +1 -1
  134. package/dist/packem_shared/{vis-user-error-qqqhLoF6.js → vis-user-error-Bdg9NRuJ.js} +15 -15
  135. package/dist/packem_shared/watch-BTZw2Y8Q.js +1 -0
  136. package/dist/packem_shared/watch-loop-Cjh2wlUl.js +11 -0
  137. package/dist/packem_shared/{writeFileSync-DJoHk3Ks-CgQ-VNNT.js → writeFileSync-DJoHk3Ks-O9zOKqeM.js} +1 -1
  138. package/dist/runtime/preload.js +1 -1
  139. package/index.d.ts +204 -204
  140. package/index.js +26 -26
  141. package/package.json +10 -10
  142. package/schemas/vis-config.schema.json +14 -0
  143. package/dist/packem_shared/Table-kgZ-Cd21-DdNsp69H.js +0 -9
  144. package/dist/packem_shared/affected-selection-Bt4qkPUb.js +0 -1
  145. package/dist/packem_shared/build-scripts-pdVmqXRm.js +0 -1
  146. package/dist/packem_shared/dependency-scan-DBH2Qo4I.js +0 -1
  147. package/dist/packem_shared/failure-log-3R522Vb5.js +0 -2
  148. package/dist/packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js +0 -4
  149. package/dist/packem_shared/glob-Cyk1H9ZL-ox19CSsT.js +0 -1
  150. package/dist/packem_shared/index-Czrll7SU.js +0 -1
  151. package/dist/packem_shared/lifecycle-CAIJbxIa.js +0 -2
  152. package/dist/packem_shared/lockfile-DVFySxTS.js +0 -1
  153. package/dist/packem_shared/manifests-BNSmpPF_.js +0 -1
  154. package/dist/packem_shared/missing-package-json-C0keIt78.js +0 -1
  155. package/dist/packem_shared/packument-DyuhH1Gz.js +0 -1
  156. package/dist/packem_shared/pm-runner-d93_73O6.js +0 -1
  157. package/dist/packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js +0 -1
  158. package/dist/packem_shared/registry-keys-BWHRFWbb.js +0 -1
  159. package/dist/packem_shared/resolve-runtime-C7NBCA1C.js +0 -1
  160. package/dist/packem_shared/run-file-jMngGQhs.js +0 -1
  161. package/dist/packem_shared/runtime-check-BklgEMkC.js +0 -1
  162. package/dist/packem_shared/s1ngularity-BJ5j2vbJ.js +0 -1
  163. package/dist/packem_shared/spinner-BM_0Bj6x.js +0 -1
  164. package/dist/packem_shared/target-options-d_rIrLyq.js +0 -1
  165. package/dist/packem_shared/toolchain-DY11tPCw.js +0 -5
  166. package/dist/packem_shared/typosquats-CSkIFgF5.js +0 -1
  167. package/dist/packem_shared/verify-D8wYvB85.js +0 -1
  168. package/dist/packem_shared/watch-Dswvj6Zp.js +0 -1
  169. package/dist/packem_shared/watch-loop-COWvvSbR.js +0 -11
@@ -1 +1 @@
1
- import{createRequire as y}from"node:module";import{e as u}from"../packem_shared/index-DHD8wb6Z.js";import{cleanWorkspace as $}from"#native";import{l as E}from"../packem_shared/missing-package-json-C0keIt78.js";import{p as i}from"./cli-main.js";import{e as b}from"../packem_shared/utils-DQFHJn72.js";import{y as j}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{L as P}from"./catalog.js";let k;const h=e=>(k??=y(import.meta.url))(e),d=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,_=e=>{if(typeof d<"u"&&d.versions&&d.versions.node){const[o,t]=d.versions.node.split(".").map(Number);if(o>22||o===22&&t>=3||o===20&&t>=16)return d.getBuiltinModule(e)}return h(e)},{readdirSync:g,lstatSync:v,rmSync:R}=_("node:fs"),D=/node_modules/,L=/\.git/,M=e=>{const o=[],t=[e];for(;t.length>0;){const r=t.pop();let l;try{l=g(r)}catch{continue}for(const c of l){const s=u(r,c);try{const n=v(s);if(n.isSymbolicLink()||!n.isDirectory())continue}catch{continue}c==="node_modules"?o.push(s):c!==".git"&&c!==".hg"&&t.push(s)}}return o},S=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],N=(e,o,t)=>{let r=0,l=!1;for(const c of S){const s=u(e,c);if(j(s)){t.info(` ${s}`),r++;continue}}return{hadError:l,removed:r}},T=e=>{for(const o of P(e,{includeDirs:!1,includeSymlinks:!1,skip:[D,L]}))if(o.name==="package.json")return!0;return!1},p=(e,o,t)=>{let r=0,l=!1;for(const{packageDir:c}of E(e)){const s=u(e,c);if(!T(s)){if(o){t.info(` ${s}`),r++;continue}try{R(s,{force:!0,recursive:!0}),i.success(`Removed empty package ${s}`),r++}catch(n){i.error(`${s}: ${b(n)}`),l=!0}}}return{hadError:l,removed:r}},I=async({logger:e,options:o,workspaceRoot:t})=>{const r=t??process.cwd(),l=o.lockfile||!1,c=o.emptyPackages||!1;if(o.dryRun||!1){const f=M(r);if(f.length>0){i.info("Would remove:");for(const a of f)e.info(` ${a}`)}else i.info("No node_modules directories found.");l&&N(r,!0,e),c&&(i.info("Would remove empty packages:"),p(r,!0,e));return}const n=$(r,l);for(const f of n.removed)i.success(`Removed ${f}`);for(const f of n.lockfilesRemoved)i.success(`Removed ${f}`);for(const f of n.errors)i.error(f);n.removed.length===0&&n.lockfilesRemoved.length===0?i.info("No node_modules directories found."):i.info(`Cleaned ${n.removed.length} node_modules director${n.removed.length===1?"y":"ies"}`);let m=!1;if(c){const{hadError:f,removed:a}=p(r,!1,e);m=f,a>0&&i.info(`Cleaned ${a} empty package director${a===1?"y":"ies"}`)}(n.errors.length>0||m)&&(process.exitCode=1)};export{I as default};
1
+ import{createRequire as v}from"node:module";import"../packem_shared/index-CVBR-Kit.js";import{e as m}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{cleanWorkspace as E}from"#native";import{l as S}from"../packem_shared/missing-package-json-CMoHdvmj.js";import{p as c}from"./cli-main.js";import{e as p}from"../packem_shared/utils-DQFHJn72.js";import{y as P}from"../packem_shared/isAccessibleSync-DYKTrrvc-K2xhg6sV.js";let g;const _=e=>(g??=v(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,t]=u.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return u.getBuiltinModule(e)}return _(e)},{readdirSync:h,lstatSync:$,rmSync:b}=R("node:fs"),j=e=>{const r=[],t=[e];for(;t.length>0;){const o=t.pop();let i;try{i=h(o)}catch{continue}for(const l of i){const s=m(o,l);try{const n=$(s);if(n.isSymbolicLink()||!n.isDirectory())continue}catch{continue}l==="node_modules"?r.push(s):l!==".git"&&l!==".hg"&&t.push(s)}}return r},w=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],D=(e,r,t)=>{let o=0,i=!1;for(const l of w){const s=m(e,l);if(P(s)){t.info(` ${s}`),o++;continue}}return{hadError:i,removed:o}},L=new Set([".cache",".turbo","dist","node_modules"]),k=e=>{for(const r of h(e,{withFileTypes:!0})){const t=m(e,r.name);if(!r.isDirectory())return t;if(!L.has(r.name)){const o=k(t);if(o!==void 0)return o}}},y=(e,r,t)=>{let o=0,i=!1;for(const{packageDir:l}of S(e)){const s=m(e,l);let n;try{n=k(s)}catch(a){c.error(`${s}: ${p(a)}`),i=!0;continue}if(n!==void 0){c.warn(`Skipping ${s}: not empty (contains ${n})`);continue}if(r){t.info(` ${s}`),o++;continue}try{b(s,{force:!0,recursive:!0}),c.success(`Removed empty package ${s}`),o++}catch(a){c.error(`${s}: ${p(a)}`),i=!0}}return{hadError:i,removed:o}},B=async({logger:e,options:r,workspaceRoot:t})=>{const o=t??process.cwd(),i=r.lockfile||!1,l=r.emptyPackages||!1;if(r.dryRun||!1){const f=j(o);if(f.length>0){c.info("Would remove:");for(const d of f)e.info(` ${d}`)}else c.info("No node_modules directories found.");i&&D(o,!0,e),l&&(c.info("Would remove empty packages:"),y(o,!0,e));return}const n=E(o,i);for(const f of n.removed)c.success(`Removed ${f}`);for(const f of n.lockfilesRemoved)c.success(`Removed ${f}`);for(const f of n.errors)c.error(f);n.removed.length===0&&n.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${n.removed.length} node_modules director${n.removed.length===1?"y":"ies"}`);let a=!1;if(l){const{hadError:f,removed:d}=y(o,!1,e);a=f,d>0&&c.info(`Cleaned ${d} empty package director${d===1?"y":"ies"}`)}(n.errors.length>0||a)&&(process.exitCode=1)};export{B as default};
@@ -1 +1 @@
1
- import{a as d,e as l}from"../packem_shared/pm-runner-d93_73O6.js";import{r as m,a as p}from"../packem_shared/command-runtime-CiLVo4ED.js";const i=async({logger:a,options:s,visConfig:e,workspaceRoot:n})=>{const c=n??process.cwd(),t=m({logger:a,options:s,visConfig:e},c),r=d(c,{backend:p(t),configBackend:e?.install?.backend,configCorepack:e?.install?.corepack}),o=l(r,s.check||!1,c,a);o!==0&&(process.exitCode=o)};export{i as default};
1
+ import{a as d,e as l}from"../packem_shared/pm-runner-9L6ocnu2.js";import{r as m,a as p}from"../packem_shared/command-runtime-BD-4UmPB.js";const i=async({logger:a,options:s,visConfig:e,workspaceRoot:n})=>{const c=n??process.cwd(),t=m({logger:a,options:s,visConfig:e},c),r=d(c,{backend:p(t),configBackend:e?.install?.backend,configCorepack:e?.install?.corepack}),o=l(r,s.check||!1,c,a);o!==0&&(process.exitCode=o)};export{i as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as L}from"node:module";import{U as G,a as H}from"../packem_shared/index-DHD8wb6Z.js";import{d as U,f as F,p as S,v as P,a as D}from"./heal.js";import{d as j,c as V}from"../packem_shared/pm-runner-d93_73O6.js";import{p as s}from"./cli-main.js";let N;const O=t=>(N??=L(import.meta.url))(t),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,o]=I.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return I.getBuiltinModule(t)}return O(t)},{readFile:x}=B("node:fs/promises"),{createInterface:K}=B("node:readline"),M=()=>!!process.stdout.isTTY&&process.env.CI!=="true",q=t=>new Promise(e=>{const o=K({input:process.stdin,output:process.stderr});o.question(`${t} (Y/n) `,a=>{o.close();const i=a.trim().toLowerCase();e(i===""||i==="y"||i==="yes")})}),Y=(t,e)=>{const o=j(e),a=V(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[t],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:a})},$=t=>`pnpm add ${t}`,J=t=>t==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),A=async(t,e={})=>{const o=e.interactive??M(),a=e.prompt??q,i=e.runInstall??Y,c=e.importImpl??J,d=e.workspaceRoot??process.cwd();try{return await c(t)}catch(u){const{code:m}=u;if(m!=="ERR_MODULE_NOT_FOUND"&&m!=="MODULE_NOT_FOUND")throw u}if(!o)throw new Error(`${t} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
1
+ import{createRequire as L}from"node:module";import{U as G,n as H}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{d as U,f as F,p as S,v as P,a as D}from"./heal.js";import{d as j,c as V}from"../packem_shared/pm-runner-9L6ocnu2.js";import{p as s}from"./cli-main.js";let N;const O=t=>(N??=L(import.meta.url))(t),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[e,o]=I.versions.node.split(".").map(Number);if(e>22||e===22&&o>=3||e===20&&o>=16)return I.getBuiltinModule(t)}return O(t)},{readFile:x}=B("node:fs/promises"),{createInterface:K}=B("node:readline"),M=()=>!!process.stdout.isTTY&&process.env.CI!=="true",q=t=>new Promise(e=>{const o=K({input:process.stdin,output:process.stderr});o.question(`${t} (Y/n) `,a=>{o.close();const i=a.trim().toLowerCase();e(i===""||i==="y"||i==="yes")})}),Y=(t,e)=>{const o=j(e),a=V(o,{exact:!1,filter:[],global:!1,optional:!1,packages:[t],peer:!1,saveDev:!1,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:a})},$=t=>`pnpm add ${t}`,J=t=>t==="@gitbeaker/rest"?import("@gitbeaker/rest"):import("@octokit/rest"),A=async(t,e={})=>{const o=e.interactive??M(),a=e.prompt??q,i=e.runInstall??Y,c=e.importImpl??J,d=e.workspaceRoot??process.cwd();try{return await c(t)}catch(u){const{code:m}=u;if(m!=="ERR_MODULE_NOT_FOUND"&&m!=="MODULE_NOT_FOUND")throw u}if(!o)throw new Error(`${t} is not installed. \`vis ai heal accept\` needs it to talk to the host. Install it in your repo first:
2
2
  ${$(t)}`);if(!await a(`${t} isn't installed. Install it now?`))throw new Error(`${t} install declined. Re-run \`vis ai heal accept\` after installing manually:
3
3
  ${$(t)}`);const n=await i(t,d);if(n.exitCode!==0)throw new Error(`Install of ${t} failed (exit ${String(n.exitCode)}). Install manually and retry:
4
4
  ${$(t)}`);return await c(t)},W=t=>{const e=t.indexOf("/");if(e<=0||e===t.length-1)throw new Error(`Expected GITHUB_REPOSITORY in "owner/repo" form, got: ${t}`);return{owner:t.slice(0,e),repo:t.slice(e+1)}},z=async(t,e)=>{if(e.githubClient)return e.githubClient;const i=(await(e.loadSdk??A)("@octokit/rest")).Octokit;if(!i)throw new TypeError("Loaded `@octokit/rest` but no `Octokit` export was found. Reinstall the package or pin to a supported major.");return new i({auth:t})},X=async(t,e,o)=>{if(o.gitlabClient)return o.gitlabClient;const c=(await(o.loadSdk??A)("@gitbeaker/rest")).Gitlab;if(!c)throw new TypeError("Loaded `@gitbeaker/rest` but no `Gitlab` export was found. Reinstall the package or pin to a supported major.");return new c({host:e,token:t})},Q=t=>t.replace(/\/api\/v\d+\/?$/,""),Z=async t=>{const{branch:e,ciContext:o,files:a,message:i,workspaceRoot:c}=t,d=t.readFile??(_=>x(_,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitHub: GITHUB_REPOSITORY (owner/repo) is not set.");if(!o.token)throw new Error("Cannot commit on GitHub: GITHUB_TOKEN is not set. Grant the workflow `contents: write` and pass the token through.");const{owner:r,repo:n}=W(o.repo),u=await z(o.token,t),f=(await u.rest.git.getRef({owner:r,ref:`heads/${e}`,repo:n})).data.object.sha,g=(await u.rest.git.getCommit({commit_sha:f,owner:r,repo:n})).data.tree.sha,h=await Promise.all(a.map(async _=>{const T=G(c,_),w=await d(T),R=await u.rest.git.createBlob({content:Buffer.from(w,"utf8").toString("base64"),encoding:"base64",owner:r,repo:n});return{mode:"100644",path:_,sha:R.data.sha,type:"blob"}})),C=await u.rest.git.createTree({base_tree:g,owner:r,repo:n,tree:h}),b=await u.rest.git.createCommit({message:i,owner:r,parents:[f],repo:n,tree:C.data.sha});return await u.rest.git.updateRef({owner:r,ref:`heads/${e}`,repo:n,sha:b.data.sha}),{sha:b.data.sha,url:b.data.html_url}},tt=async t=>{const{branch:e,ciContext:o,files:a,message:i,workspaceRoot:c}=t,d=t.readFile??(p=>x(p,"utf8"));if(!o.repo)throw new Error("Cannot commit on GitLab: CI_PROJECT_ID / CI_PROJECT_PATH is not set.");if(!o.token)throw new Error("Cannot commit on GitLab: no token. CI_JOB_TOKEN cannot push commits — set GITLAB_TOKEN to a PAT/project-token with `api` scope.");if(!o.apiBaseUrl)throw new Error("Cannot commit on GitLab: CI_API_V4_URL is not set.");const r=Q(o.apiBaseUrl),n=await X(o.token,r,t),u=await Promise.all(a.map(async p=>{const g=G(c,p);return{action:"update",content:await d(g),filePath:p}})),m=await n.Commits.create(o.repo,e,i,u),f=m.id??m.sha;if(!f)throw new Error("GitLab Commits.create returned no commit ID — cannot reference the new commit.");return{sha:f,url:m.web_url??m.webUrl}},et=async t=>{if(t.files.length===0)throw new Error("Cannot commit: no files to include.");if(t.ciContext.provider==="github-actions")return await Z(t);if(t.ciContext.provider==="gitlab-ci")return await tt(t);throw new Error(`Cannot commit: unsupported CI provider \`${t.ciContext.provider}\`. Run \`vis ai heal accept\` from a recognised CI environment.`)},y="/vis heal accept",ot=async t=>{if(!t)return;let e;try{e=await x(t,"utf8")}catch{return}const o=JSON.parse(e),a=o.comment?.body??"",i=o.comment?.user?.login??"",c=o.pull_request?.head?.repo?.full_name,d=o.pull_request?.base?.repo?.full_name??o.repository?.full_name,r=c!==void 0&&d!==void 0&&c!==d;return{actor:i,body:a,headRef:o.pull_request?.head?.ref,isFork:r}},rt=t=>{const e=t.VIS_HEAL_TRIGGER_BODY,o=t.VIS_HEAL_TRIGGER_ACTOR;if(!(!e||!o))return{actor:o,body:e,headRef:t.VIS_HEAL_HEAD_REF,isFork:!1}},it=t=>{const e=t.BUILDKITE_UNBLOCKER_EMAIL??t.BUILDKITE_UNBLOCKER;if(e)return{actor:e,body:y,headRef:t.BUILDKITE_BRANCH,isFork:!1}},at=async(t,e)=>{if(t.provider==="github-actions")return await ot(e.GITHUB_EVENT_PATH);if(t.provider==="gitlab-ci")return rt(e);if(t.provider==="buildkite")return it(e)},nt=(t,e)=>{const o=e.BUILDKITE_REPO;if(!o)return;const a=/(?:^|@|\/\/)github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(o);if(a&&e.GITHUB_TOKEN)return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t.prNumber,provider:"github-actions",repo:`${a[1]}/${a[2]}`,sha:t.sha,token:e.GITHUB_TOKEN};const i=/\/\/([^/]*gitlab[^/]*)\/([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),c=i?null:/@([^/:]*gitlab[^/:]*):([^/]+)\/(.+?)(?:\.git)?\/?$/i.exec(o),d=i??c;if(d&&e.GITLAB_TOKEN){const r=d[1];return{apiBaseUrl:e.CI_API_V4_URL??`https://${r}/api/v4`,buildId:void 0,buildNumber:void 0,prNumber:t.prNumber,provider:"gitlab-ci",repo:`${d[2]}/${d[3]}`,sha:t.sha,token:e.GITLAB_TOKEN}}},st=async t=>{const e=t.fetchImpl??globalThis.fetch,a=`${(t.apiBaseUrl??"https://api.github.com").replace(/\/+$/,"")}/repos/${t.repo}/pulls/${String(t.prNumber)}`;try{const i=await e(a,{headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${t.token}`,"X-GitHub-Api-Version":"2022-11-28"}});return i.ok?(await i.json()).head?.ref:void 0}catch{return}},ct=(t,e,o,a)=>{const i=e.map(c=>`- \`${c}\``).join(`
@@ -1,4 +1,4 @@
1
- import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-sXNQYpsl.js";import{a as O}from"../packem_shared/index-DHD8wb6Z.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-BHyx1F1j.js";import{p,f as H}from"./cli-main.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
1
+ import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-sXNQYpsl.js";import{n as O}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-BTm1Z5og.js";import{p,f as H}from"./cli-main.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
2
2
  ${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
3
3
  `))a.push(`- ${c}`);for(const c of n.newString.split(`
4
4
  `))a.push(`+ ${c}`);a.push(d),r.push(a.join(`
@@ -1,8 +1,8 @@
1
- import{createRequire as At}from"node:module";import{w as It,$ as Wt,e as kt,j,P as b,q as x,J as N,b as L}from"../packem_shared/index.server-sXNQYpsl.js";import{u as ut,c as B,e as Mt}from"../packem_shared/vis-user-error-qqqhLoF6.js";import{N as R,a as _}from"../packem_shared/Table-kgZ-Cd21-DdNsp69H.js";import{b as Ct}from"../packem_shared/package-version-DFlytdgJ.js";let Ot;const xt=t=>(Ot??=At(import.meta.url))(t),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Et=t=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[e,n]=E.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return E.getBuiltinModule(t)}return xt(t)},{createRequire:Bt}=Et("node:module"),jt=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,z=t=>{let[,e]=jt.exec(t)??[];const n=e?e.length:0;if(n===3){const s=e.charAt(0),o=e.charAt(1),i=e.charAt(2);e=s+s+o+o+i+i}else if(n!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${t}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const r=Number.parseInt(e,16);return[r>>16&255,r>>8&255,r&255]},dt=(t,e,n)=>t===e&&e===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/51)+6*Math.round(e/51)+Math.round(n/51),H=t=>{let e,n,r;if(t<8)return 30+t;if(t<16)return 90+(t-8);if(t>=232)e=n=r=((t-232)*10+8)/255;else{t-=16;const i=t%36;e=Math.floor(t/36)/5,n=Math.floor(i/6)/5,r=i%6/5}const s=Math.max(e,n,r)*2;if(s===0)return 30;const o=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(e));return s===2?o+60:o},Z=(t,e,n)=>H(dt(t,e,n));function Rt({onlyFirst:t=!1}={}){const e="(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(e,t?void 0:"g")}const S=(t,e,n)=>e>t?e:Math.min(t,n),m=39,f=49,X=10,tt={close:"",open:""},ht=t=>{const e=t>0?(l,d)=>({close:`\x1B[${String(d)}m`,open:`\x1B[${String(l)}m`}):()=>tt,n=l=>(d,p,g)=>l(dt(Number(d),Number(p),Number(g))),r=l=>d=>{const[p,g,w]=z(d);return l(p,g,w)};let s=l=>e(`38;5;${String(l)}`,m),o=l=>e(`48;5;${String(l)}`,f),i=(l,d,p)=>e(`38;2;${String(l)};${String(d)};${String(p)}`,m),a=(l,d,p)=>e(`48;2;${String(l)};${String(d)};${String(p)}`,f);t===1?(s=l=>e(H(Number(l)),m),o=l=>e(H(Number(l))+X,f),i=(l,d,p)=>e(Z(Number(l),Number(d),Number(p)),m),a=(l,d,p)=>e(Z(Number(l),Number(d),Number(p))+X,f)):t===2&&(i=n(s),a=n(o));const u={bold:e(1,22),dim:e(2,22),hidden:e(8,28),inverse:e(7,27),italic:e(3,23),overline:e(53,55),reset:e(0,0),strike:e(9,29),strikethrough:e(9,29),underline:e(4,24),underlineCurly:e("4:3",24),underlineDashed:e("4:5",24),underlineDotted:e("4:4",24),underlineDouble:e("4:2",24),visible:tt},c={bgBlack:e(40,f),bgBlackBright:e(100,f),bgBlue:e(44,f),bgBlueBright:e(104,f),bgCyan:e(46,f),bgCyanBright:e(106,f),bgGray:e(100,f),bgGreen:e(42,f),bgGreenBright:e(102,f),bgGrey:e(100,f),bgMagenta:e(45,f),bgMagentaBright:e(105,f),bgRed:e(41,f),bgRedBright:e(101,f),bgWhite:e(47,f),bgWhiteBright:e(107,f),bgYellow:e(43,f),bgYellowBright:e(103,f),black:e(30,m),blackBright:e(90,m),blue:e(34,m),blueBright:e(94,m),cyan:e(36,m),cyanBright:e(96,m),gray:e(90,m),green:e(32,m),greenBright:e(92,m),grey:e(90,m),magenta:e(35,m),magentaBright:e(95,m),red:e(31,m),redBright:e(91,m),white:e(37,m),whiteBright:e(97,m),yellow:e(33,m),yellowBright:e(93,m)},h={bg:l=>o(S(l,0,255)),bgHex:r(a),bgRgb:(l,d,p)=>a(S(l,0,255),S(d,0,255),S(p,0,255)),fg:l=>s(S(l,0,255)),hex:r(i),rgb:(l,d,p)=>i(S(l,0,255),S(d,0,255),S(p,0,255))};return{baseColors:c,baseStyles:u,styleMethods:h}},pt=It();Wt();ht(pt);const _t=(t,e,n)=>{if(e==="")return t;let r=t.indexOf(e);if(r<0)return t;const s=e.length;let o=0,i="";for(;~r;)i+=t.slice(o,r)+n,o=r+s,r=t.indexOf(e,o);return i+t.slice(o)},Pt=(t,e,n)=>{if(t==null||t==="")return"";let r;if(t.raw===void 0?r=String(t):r=String.raw(t,...e),r.includes("\x1B"))for(let s=n;s;s=s.props)r=_t(r,s.close,s.open);return r.includes(`
2
- `)&&(r=r.replace(/(\r*\n)/g,`${n.closeStack}$1${n.openStack}`)),n.openStack+r+n.closeStack},Tt=function(t){const e=t?.level??pt,{baseColors:n,baseStyles:r,styleMethods:s}=ht(e),o={};let i=null;const a=({props:c},{close:h,open:l})=>{const d=(c?.openStack??"")+l,p=h+(c?.closeStack??""),g=(w,...y)=>Pt(w,y,g.props);return Object.setPrototypeOf(g,i),g.props={close:h,closeStack:p,open:l,openStack:d,props:c},g.open=d,g.close=p,g},u=c=>String(c);u.strip=c=>c.replaceAll(Rt(),"");for(const c in n)o[c]={get(){const h=a(this,n[c]);return Object.defineProperty(this,c,{value:h}),h}};for(const c in r)o[c]={get(){const h=a(this,r[c]);return Object.defineProperty(this,c,{value:h}),h}};for(const c in s)o[c]={get(){return(...h)=>a(this,s[c](...h))}};return o.ansi256=o.fg,o.bgAnsi256=o.bg,i=Object.defineProperties({},o),Object.setPrototypeOf(u,i),u},Lt=t=>(e,...n)=>{if(!Array.isArray(e)||!Array.isArray(e.raw))throw new TypeError("A tagged template literal must be provided");const r=[e.raw[0]];for(let s=1;s<e.raw.length;s+=1)r.push(String(n[s-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(e.raw[s]));return t(r.join(""))},Ft=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
3
- `],["r","\r"],["t"," "],["v","\v"]]),mt=t=>{const e=t.startsWith("u"),n=t[1]==="{";return e&&!n&&t.length===5||t.startsWith("x")&&t.length===3?String.fromCodePoint(Number.parseInt(t.slice(1),16)):e&&n?String.fromCodePoint(Number.parseInt(t.slice(2,-1),16)):Ft.get(t)??t},Dt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,et=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Vt=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,qt=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Ut=/\s*,\s*/,Gt=(t,e)=>{const n=[],r=e.trim().split(Ut);let s;for(const o of r){const i=Number(o);if(!Number.isNaN(i))n.push(i);else if(s=Vt.exec(o))n.push(s[2].replaceAll(qt,(a,u,c)=>u?mt(u):c));else throw new Error(`Invalid template style argument: ${o} (in style '${t}')`)}return n},zt=t=>{et.lastIndex=0;const e=[];let n;for(;(n=et.exec(t))!==null;){const r=n[1];n[2]?e.push([r,...Gt(r,n[2])]):n[3]||n[4]?(n[3]&&e.push(["rgb",...z(n[3])]),n[4]&&e.push(["bgRgb",...z(n[4])])):e.push([r])}return e},nt=(t,e)=>{const n={};for(const s of e)for(const o of s.styles)n[o[0]]=s.inverse?void 0:o.slice(1);let r=t;for(const[s,o]of Object.entries(n))if(Array.isArray(o)){if(!(s in r))throw new Error(`Unknown style: ${s}`);r=o.length>0?r[s](...o):r[s]}return r},Ht=t=>e=>{const n=[],r=[];let s=[];if(e.replaceAll(Dt,(o,i,a,u,c,h)=>{if(i)s.push(mt(i));else if(u){const l=s.join("");s=[],r.push(n.length===0?l:nt(t,n)(l)),n.push({inverse:a,styles:zt(u)})}else if(c){if(n.length===0)throw new Error("Found extraneous } in template literal");r.push(nt(t,n)(s.join(""))),s=[],n.pop()}else s.push(h)}),r.push(s.join("")),n.length>0)throw new Error(`template literal is missing ${String(n.length)} closing bracket${n.length===1?"":"s"} (\`}\`)`);return r.join("")},Yt=new Tt,Jt=Ht(Yt),Kt=Lt(Jt);let Qt;const Zt=t=>(Qt??=Bt(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:A,F=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,n]=O.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return O.getBuiltinModule(t)}return Zt(t)},A=O,{execFileSync:Xt}=F("node:child_process"),W=F("node:fs"),te=F("node:tty"),ee=F("node:os"),ne=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],re=12288,oe=65510,ie=[12288,12288,65281,65376,65504,65510],se=8361,ae=65518,le=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],ce=32,ue=10630,de=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],he=4352,pe=262141,ft=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],k=(t,e)=>{let n=0,r=Math.floor(t.length/2)-1;for(;n<=r;){const s=Math.floor((n+r)/2),o=s*2;if(e<t[o])r=s-1;else if(e>t[o+1])n=s+1;else return!0}return!1},rt=19968,[me,fe]=ge(ft);function ge(t){let e=t[0],n=t[1];for(let r=0;r<t.length;r+=2){const s=t[r],o=t[r+1];if(rt>=s&&rt<=o)return[s,o];o-s>n-e&&(e=s,n=o)}return[e,n]}const we=t=>t<161||t>1114109?!1:k(ne,t),be=t=>t<re||t>oe?!1:k(ie,t),ye=t=>t<se||t>ae?!1:k(le,t),$e=t=>t<ce||t>ue?!1:k(de,t),Ne=t=>t>=me&&t<=fe?!0:t<he||t>pe?!1:k(ft,t);function ve(t){return we(t)?"ambiguous":be(t)?"fullwidth":ye(t)?"halfwidth":$e(t)?"narrow":Ne(t)?"wide":"neutral"}function Se(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function gt(t){return Se(t),ve(t)}const ot=new Map,Ae=t=>[t.ambiguousIsNarrow?1:0,t.control,t.fullWidth,t.regular,t.wide].join("|"),Oe=t=>{const e=Ae(t.width);let n=ot.get(e);return n||(n=new Map,ot.set(e,n)),n},M=new RegExp(ut.source,"y"),U=new RegExp(Mt.source,"uy"),C=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,wt=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",xe=(t,e)=>{const n=Oe(e),r=Math.floor(t/65536),s=t%65536;let o=n.get(r);if(o||(o=new Map,n.set(r,o)),o.has(s))return o.get(s);let i;switch(wt(t)){case"control":{i=e.width.control;break}case"latin":{i=e.width.regular;break}case"wide":{i=e.width.wide;break}case"zero":{i=0;break}default:switch(gt(t)){case"ambiguous":{i=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{i=e.width.fullWidth;break}case"wide":{i=e.width.wide;break}default:i=e.width.regular}}return o.set(s,i),i},Ee=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,Y=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?Y(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},r=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:s}=t,o=s>1e4;let i=0,a=0,u=s,c=!1;const h=t.includes("\x1B")||t.includes("›");for(;i<s;){if(h&&(t[i]==="\x1B"||t[i]==="›")){if(t.startsWith("\x1B]8;;",i)){const y="\x1B]8;;\x07",v=y.length,D=t.indexOf("\x07",i+5);if(D!==-1){const V=t.indexOf(y,D+1);if(V!==-1){const vt=V+v,St=t.slice(D+1,V).replace(ut,""),Q=Y(St,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,r-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),q=Q.width;if(Q.truncated)c=!0,u=Math.min(u,i);else if(a+q>r&&(u=Math.min(u,i),c=!0,a+q>n.truncation.limit))break;if(a+=q,i=vt,c&&a>=n.truncation.limit)break;continue}}}if(M.lastIndex=i,M.test(t)){const y=M.lastIndex-i,v=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+v>r&&(u=Math.min(u,i),a+v>n.truncation.limit)){c=!0;break}a+=v,i=M.lastIndex;continue}}const p=t.codePointAt(i);if(p===8203||p===65279||p>=8288&&p<=8292){i+=1;continue}if(p===9){if(a+n.width.tab>r&&(u=Math.min(u,i),a+n.width.tab>n.truncation.limit)){c=!0;break}a+=n.width.tab,i+=1;continue}if(C.lastIndex=i,C.test(t)){const y=(C.lastIndex-i)*n.width.regular;if(a+y>r){const v=n.width.regular>0?Math.floor((r-a)/n.width.regular):0;if(u=Math.min(u,i+v),a+y>n.truncation.limit){c=!0;break}}a+=y,i=C.lastIndex;continue}if((p<=31||p>=127&&p<=159)&&(B.lastIndex=i,B.test(t))){const y=(B.lastIndex-i)*n.width.control;if(a+y>r){const v=n.width.control>0?Math.floor((r-a)/n.width.control):0;if(u=Math.min(u,i+v),a+y>n.truncation.limit){c=!0;break}}a+=y,i=B.lastIndex;continue}if(U.lastIndex=i,U.test(t)){if(a+n.width.emoji>r&&(u=Math.min(u,i),a+n.width.emoji>n.truncation.limit)){c=!0;break}a+=n.width.emoji,i=U.lastIndex;continue}const g=t.codePointAt(i)??0;if(Ee(g)){i+=g>65535?2:1;continue}let w;if(o)w=xe(g,n);else switch(wt(g)){case"control":{w=n.width.control;break}case"latin":{w=n.width.regular;break}case"wide":{w=n.width.wide;break}case"zero":{w=0;break}default:switch(gt(g)){case"ambiguous":{w=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{w=n.width.fullWidth;break}case"wide":{w=n.width.wide;break}default:w=n.width.regular}}if(a+w>r&&(u=Math.min(u,i),a+w>n.truncation.limit)){c=!0;break}a+=w,i+=g>65535?2:1}let l=a,d=!1;return c&&n.truncation.limit>=n.truncation.ellipsisWidth&&(l=n.truncation.limit,d=!0),{ellipsed:d,index:c?u:s,truncated:c,width:l}},Ie=(t,e={})=>Y(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,bt=80,yt=24,J=(t,e,{shell:n,env:r}={})=>Xt(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:r}).trim(),P=(t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),$t=(t,e)=>{const{columns:n,rows:r}=P(t,e);if(!(Number.isNaN(n)||Number.isNaN(r))&&!(n===bt&&r===yt))return{columns:n,rows:r}},We=()=>{if(A.platform!=="linux")return!0;try{const t=W.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const n=t.slice(e+2).trim().split(/\s+/),r=Number.parseInt(n[2],10),s=Number.parseInt(n[5],10);return Number.isNaN(r)||Number.isNaN(s)||s<=0?!1:r===s}catch{return!1}};function ke(){const{env:t,stdout:e,stderr:n}=A;if(e?.columns&&e?.rows)return P(e.columns,e.rows);if(n?.columns&&n?.rows)return P(n.columns,n.rows);if(t.COLUMNS&&t.LINES)return P(t.COLUMNS,t.LINES);const r={columns:bt,rows:yt};return A.platform==="win32"?G()??r:A.platform==="darwin"?it()??G()??r:it()??G()??Be()??r}const it=()=>{try{const t=A.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:e,rows:n}=te.WriteStream(W.openSync("/dev/tty",t));return{columns:e,rows:n}}catch{}},G=()=>{try{const t=J("tput",["cols"],{env:{TERM:"dumb",...A.env}}),e=J("tput",["lines"],{env:{TERM:"dumb",...A.env}});if(t&&e)return $t(t,e)}catch{}},Be=()=>{try{if(!We())return;const t=J("resize",["-u"]).match(/\d+/g);if(t.length===2)return $t(t[0],t[1])}catch{}},I=new Map,Me=500,$=t=>{if(!t||t==="")return"";const e=I.get(t);if(e!==void 0)return e;let n;try{n=Kt(Object.assign([],{raw:[t]}))}catch{n=t}if(I.size>=Me){const r=I.keys().next().value;r!==void 0&&I.delete(r)}return I.set(t,n),n},T=()=>{const t=Ct().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const e=Number.parseInt(t,10);if(!(Number.isNaN(e)||e<=0))return e};class Nt{lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(ee.EOL)}header(e){this.add(j(e)),this.lines.push("")}}const Ce=t=>t!==void 0&&t>0?t:ke().columns,je=(t,e,n,r)=>{if(t.length===0||t.some(c=>c.length!==2))return;let s=0;for(const c of t){const h=c[0];if(h===void 0)continue;const l=Ie(h);l>s&&(s=l)}if(s===0)return;const o=n+r,i=s+o,a=20+o;if(i+a>e)return;const u=e-i;return[i,u]};class Re extends Nt{constructor(e){if(super(),e.header&&this.header($(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(n=>typeof n=="string"))e.content.forEach(n=>{Array.isArray(n)?n.forEach(r=>{this.add($(r))}):this.add($(n))});else if(typeof e.content=="string")this.add($(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const n=R({showHeader:!1,style:{border:_,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.addRow([$(e)]),n.toString()}if(Array.isArray(e)&&e.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(r=>typeof r=="string"))){const n=Ce(T()),r=a=>Array.isArray(a)?a.map(u=>$(u)):[$(a)],s=e.map(a=>r(a)),o=je(s,n,4,1),i=R({columnWidths:o,showHeader:!1,style:{border:_,paddingLeft:4,paddingRight:1},terminalWidth:n,truncateOverflow:!1,wordWrap:!0});return s.forEach(a=>{o!==void 0&&a.length===2?i.addRow([{content:a[0],wordWrap:!1},a[1]]):i.addRow(a)}),i.toString()}if(typeof e=="object"){const n=e;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
4
- ${JSON.stringify(e)}`);const r=R({showHeader:!1,style:{border:_,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.data.forEach(s=>{Array.isArray(s)?r.addRow(s.map(o=>$(o))):r.addRow([$(s)])}),r.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
1
+ import{createRequire as Ae}from"node:module";import{w as Ie,$ as We,e as ke,j,P as b,q as x,J as N,b as L}from"../packem_shared/index.server-sXNQYpsl.js";import{u as ue,c as B,e as Me}from"../packem_shared/vis-user-error-Bdg9NRuJ.js";import{N as R,a as _}from"../packem_shared/Table-BB8xHTU5-BLPS917D.js";import{b as Ce}from"../packem_shared/package-version-C5EPMgRw.js";let Oe;const xe=e=>(Oe??=Ae(import.meta.url))(e),E=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ee=e=>{if(typeof E<"u"&&E.versions&&E.versions.node){const[t,n]=E.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return E.getBuiltinModule(e)}return xe(e)},{createRequire:Be}=Ee("node:module"),je=/^#?([a-f\d]{3}|[a-f\d]{6})$/i,z=e=>{let[,t]=je.exec(e)??[];const n=t?t.length:0;if(n===3){const s=t.charAt(0),o=t.charAt(1),i=t.charAt(2);t=s+s+o+o+i+i}else if(n!==6)return globalThis.process?.env?.NODE_ENV!=="production"&&console.warn(`[@visulima/colorize] Invalid hex color "${e}"; expected a 3- or 6-digit hex string (e.g. "#96C" or "#E0115F"). Falling back to black.`),[0,0,0];const r=Number.parseInt(t,16);return[r>>16&255,r>>8&255,r&255]},de=(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/51)+6*Math.round(t/51)+Math.round(n/51),H=e=>{let t,n,r;if(e<8)return 30+e;if(e<16)return 90+(e-8);if(e>=232)t=n=r=((e-232)*10+8)/255;else{e-=16;const i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}const s=Math.max(t,n,r)*2;if(s===0)return 30;const o=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return s===2?o+60:o},Z=(e,t,n)=>H(de(e,t,n));function Re({onlyFirst:e=!1}={}){const t="(?:\\u001B\\][^\\u0007\\u001B\\u009C]*(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";return new RegExp(t,e?void 0:"g")}const S=(e,t,n)=>t>e?t:Math.min(e,n),m=39,f=49,X=10,ee={close:"",open:""},he=e=>{const t=e>0?(l,d)=>({close:`\x1B[${String(d)}m`,open:`\x1B[${String(l)}m`}):()=>ee,n=l=>(d,p,g)=>l(de(Number(d),Number(p),Number(g))),r=l=>d=>{const[p,g,w]=z(d);return l(p,g,w)};let s=l=>t(`38;5;${String(l)}`,m),o=l=>t(`48;5;${String(l)}`,f),i=(l,d,p)=>t(`38;2;${String(l)};${String(d)};${String(p)}`,m),a=(l,d,p)=>t(`48;2;${String(l)};${String(d)};${String(p)}`,f);e===1?(s=l=>t(H(Number(l)),m),o=l=>t(H(Number(l))+X,f),i=(l,d,p)=>t(Z(Number(l),Number(d),Number(p)),m),a=(l,d,p)=>t(Z(Number(l),Number(d),Number(p))+X,f)):e===2&&(i=n(s),a=n(o));const u={bold:t(1,22),dim:t(2,22),hidden:t(8,28),inverse:t(7,27),italic:t(3,23),overline:t(53,55),reset:t(0,0),strike:t(9,29),strikethrough:t(9,29),underline:t(4,24),underlineCurly:t("4:3",24),underlineDashed:t("4:5",24),underlineDotted:t("4:4",24),underlineDouble:t("4:2",24),visible:ee},c={bgBlack:t(40,f),bgBlackBright:t(100,f),bgBlue:t(44,f),bgBlueBright:t(104,f),bgCyan:t(46,f),bgCyanBright:t(106,f),bgGray:t(100,f),bgGreen:t(42,f),bgGreenBright:t(102,f),bgGrey:t(100,f),bgMagenta:t(45,f),bgMagentaBright:t(105,f),bgRed:t(41,f),bgRedBright:t(101,f),bgWhite:t(47,f),bgWhiteBright:t(107,f),bgYellow:t(43,f),bgYellowBright:t(103,f),black:t(30,m),blackBright:t(90,m),blue:t(34,m),blueBright:t(94,m),cyan:t(36,m),cyanBright:t(96,m),gray:t(90,m),green:t(32,m),greenBright:t(92,m),grey:t(90,m),magenta:t(35,m),magentaBright:t(95,m),red:t(31,m),redBright:t(91,m),white:t(37,m),whiteBright:t(97,m),yellow:t(33,m),yellowBright:t(93,m)},h={bg:l=>o(S(l,0,255)),bgHex:r(a),bgRgb:(l,d,p)=>a(S(l,0,255),S(d,0,255),S(p,0,255)),fg:l=>s(S(l,0,255)),hex:r(i),rgb:(l,d,p)=>i(S(l,0,255),S(d,0,255),S(p,0,255))};return{baseColors:c,baseStyles:u,styleMethods:h}},pe=Ie();We();he(pe);const _e=(e,t,n)=>{if(t==="")return e;let r=e.indexOf(t);if(r<0)return e;const s=t.length;let o=0,i="";for(;~r;)i+=e.slice(o,r)+n,o=r+s,r=e.indexOf(t,o);return i+e.slice(o)},Pe=(e,t,n)=>{if(e==null||e==="")return"";let r;if(e.raw===void 0?r=String(e):r=String.raw(e,...t),r.includes("\x1B"))for(let s=n;s;s=s.props)r=_e(r,s.close,s.open);return r.includes(`
2
+ `)&&(r=r.replace(/(\r*\n)/g,`${n.closeStack}$1${n.openStack}`)),n.openStack+r+n.closeStack},Te=function(e){const t=e?.level??pe,{baseColors:n,baseStyles:r,styleMethods:s}=he(t),o={};let i=null;const a=({props:c},{close:h,open:l})=>{const d=(c?.openStack??"")+l,p=h+(c?.closeStack??""),g=(w,...y)=>Pe(w,y,g.props);return Object.setPrototypeOf(g,i),g.props={close:h,closeStack:p,open:l,openStack:d,props:c},g.open=d,g.close=p,g},u=c=>String(c);u.strip=c=>c.replaceAll(Re(),"");for(const c in n)o[c]={get(){const h=a(this,n[c]);return Object.defineProperty(this,c,{value:h}),h}};for(const c in r)o[c]={get(){const h=a(this,r[c]);return Object.defineProperty(this,c,{value:h}),h}};for(const c in s)o[c]={get(){return(...h)=>a(this,s[c](...h))}};return o.ansi256=o.fg,o.bgAnsi256=o.bg,i=Object.defineProperties({},o),Object.setPrototypeOf(u,i),u},Le=e=>(t,...n)=>{if(!Array.isArray(t)||!Array.isArray(t.raw))throw new TypeError("A tagged template literal must be provided");const r=[t.raw[0]];for(let s=1;s<t.raw.length;s+=1)r.push(String(n[s-1]).replaceAll(/[{}\\]/g,String.raw`\$&`),String(t.raw[s]));return e(r.join(""))},Fe=new Map([["0","\0"],["\\","\\"],["a","\x07"],["b","\b"],["e","\x1B"],["f","\f"],["n",`
3
+ `],["r","\r"],["t"," "],["v","\v"]]),me=e=>{const t=e.startsWith("u"),n=e[1]==="{";return t&&!n&&e.length===5||e.startsWith("x")&&e.length===3?String.fromCodePoint(Number.parseInt(e.slice(1),16)):t&&n?String.fromCodePoint(Number.parseInt(e.slice(2,-1),16)):Fe.get(e)??e},De=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|\{(~)?(#?[\w:]+(?:\([^)]*\))?(?:\.#?[\w:]+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n))|(\})|((?:.|[\r\n\f])+?)/gi,te=/(?:^|\.)(?:(\w+)(?:\(([^)]*)\))?|#(?=[:a-f\d]{2,})([a-f\d]{6})?(?::([a-f\d]{6}))?)/gi,Ve=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,qe=/\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.)|([^\\])/gi,Ue=/\s*,\s*/,Ge=(e,t)=>{const n=[],r=t.trim().split(Ue);let s;for(const o of r){const i=Number(o);if(!Number.isNaN(i))n.push(i);else if(s=Ve.exec(o))n.push(s[2].replaceAll(qe,(a,u,c)=>u?me(u):c));else throw new Error(`Invalid template style argument: ${o} (in style '${e}')`)}return n},ze=e=>{te.lastIndex=0;const t=[];let n;for(;(n=te.exec(e))!==null;){const r=n[1];n[2]?t.push([r,...Ge(r,n[2])]):n[3]||n[4]?(n[3]&&t.push(["rgb",...z(n[3])]),n[4]&&t.push(["bgRgb",...z(n[4])])):t.push([r])}return t},ne=(e,t)=>{const n={};for(const s of t)for(const o of s.styles)n[o[0]]=s.inverse?void 0:o.slice(1);let r=e;for(const[s,o]of Object.entries(n))if(Array.isArray(o)){if(!(s in r))throw new Error(`Unknown style: ${s}`);r=o.length>0?r[s](...o):r[s]}return r},He=e=>t=>{const n=[],r=[];let s=[];if(t.replaceAll(De,(o,i,a,u,c,h)=>{if(i)s.push(me(i));else if(u){const l=s.join("");s=[],r.push(n.length===0?l:ne(e,n)(l)),n.push({inverse:a,styles:ze(u)})}else if(c){if(n.length===0)throw new Error("Found extraneous } in template literal");r.push(ne(e,n)(s.join(""))),s=[],n.pop()}else s.push(h)}),r.push(s.join("")),n.length>0)throw new Error(`template literal is missing ${String(n.length)} closing bracket${n.length===1?"":"s"} (\`}\`)`);return r.join("")},Ye=new Te,Je=He(Ye),Ke=Le(Je);let Qe;const Ze=e=>(Qe??=Be(import.meta.url))(e),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:A,F=e=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[t,n]=O.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return O.getBuiltinModule(e)}return Ze(e)},A=O,{execFileSync:Xe}=F("node:child_process"),W=F("node:fs"),et=F("node:tty"),tt=F("node:os"),nt=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],rt=12288,ot=65510,it=[12288,12288,65281,65376,65504,65510],st=8361,at=65518,lt=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],ct=32,ut=10630,dt=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],ht=4352,pt=262141,fe=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],k=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;for(;n<=r;){const s=Math.floor((n+r)/2),o=s*2;if(t<e[o])r=s-1;else if(t>e[o+1])n=s+1;else return!0}return!1},re=19968,[mt,ft]=gt(fe);function gt(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){const s=e[r],o=e[r+1];if(re>=s&&re<=o)return[s,o];o-s>n-t&&(t=s,n=o)}return[t,n]}const wt=e=>e<161||e>1114109?!1:k(nt,e),bt=e=>e<rt||e>ot?!1:k(it,e),yt=e=>e<st||e>at?!1:k(lt,e),$t=e=>e<ct||e>ut?!1:k(dt,e),Nt=e=>e>=mt&&e<=ft?!0:e<ht||e>pt?!1:k(fe,e);function vt(e){return wt(e)?"ambiguous":bt(e)?"fullwidth":yt(e)?"halfwidth":$t(e)?"narrow":Nt(e)?"wide":"neutral"}function St(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function ge(e){return St(e),vt(e)}const oe=new Map,At=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),Ot=e=>{const t=At(e.width);let n=oe.get(t);return n||(n=new Map,oe.set(t,n)),n},M=new RegExp(ue.source,"y"),U=new RegExp(Me.source,"uy"),C=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,we=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",xt=(e,t)=>{const n=Ot(t),r=Math.floor(e/65536),s=e%65536;let o=n.get(r);if(o||(o=new Map,n.set(r,o)),o.has(s))return o.get(s);let i;switch(we(e)){case"control":{i=t.width.control;break}case"latin":{i=t.width.regular;break}case"wide":{i=t.width.wide;break}case"zero":{i=0;break}default:switch(ge(e)){case"ambiguous":{i=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{i=t.width.fullWidth;break}case"wide":{i=t.width.wide;break}default:i=t.width.regular}}return o.set(s,i),i},Et=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,Y=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const n={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?Y(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},r=Math.max(0,n.truncation.limit-n.truncation.ellipsisWidth),{length:s}=e,o=s>1e4;let i=0,a=0,u=s,c=!1;const h=e.includes("\x1B")||e.includes("›");for(;i<s;){if(h&&(e[i]==="\x1B"||e[i]==="›")){if(e.startsWith("\x1B]8;;",i)){const y="\x1B]8;;\x07",v=y.length,D=e.indexOf("\x07",i+5);if(D!==-1){const V=e.indexOf(y,D+1);if(V!==-1){const ve=V+v,Se=e.slice(D+1,V).replace(ue,""),Q=Y(Se,{ambiguousIsNarrow:n.width.ambiguousIsNarrow,ansiWidth:n.width.ansi,controlWidth:n.width.control,countAnsiEscapeCodes:!1,ellipsis:n.truncation.ellipsis,ellipsisWidth:n.truncation.ellipsisWidth,emojiWidth:n.width.emoji,fullWidth:n.width.fullWidth,halfWidth:n.width.halfWidth,limit:Math.max(0,r-a),regularWidth:n.width.regular,tabWidth:n.width.tab,wideWidth:n.width.wide}),q=Q.width;if(Q.truncated)c=!0,u=Math.min(u,i);else if(a+q>r&&(u=Math.min(u,i),c=!0,a+q>n.truncation.limit))break;if(a+=q,i=ve,c&&a>=n.truncation.limit)break;continue}}}if(M.lastIndex=i,M.test(e)){const y=M.lastIndex-i,v=n.truncation.countAnsiEscapeCodes?y:n.width.ansi;if(a+v>r&&(u=Math.min(u,i),a+v>n.truncation.limit)){c=!0;break}a+=v,i=M.lastIndex;continue}}const p=e.codePointAt(i);if(p===8203||p===65279||p>=8288&&p<=8292){i+=1;continue}if(p===9){if(a+n.width.tab>r&&(u=Math.min(u,i),a+n.width.tab>n.truncation.limit)){c=!0;break}a+=n.width.tab,i+=1;continue}if(C.lastIndex=i,C.test(e)){const y=(C.lastIndex-i)*n.width.regular;if(a+y>r){const v=n.width.regular>0?Math.floor((r-a)/n.width.regular):0;if(u=Math.min(u,i+v),a+y>n.truncation.limit){c=!0;break}}a+=y,i=C.lastIndex;continue}if((p<=31||p>=127&&p<=159)&&(B.lastIndex=i,B.test(e))){const y=(B.lastIndex-i)*n.width.control;if(a+y>r){const v=n.width.control>0?Math.floor((r-a)/n.width.control):0;if(u=Math.min(u,i+v),a+y>n.truncation.limit){c=!0;break}}a+=y,i=B.lastIndex;continue}if(U.lastIndex=i,U.test(e)){if(a+n.width.emoji>r&&(u=Math.min(u,i),a+n.width.emoji>n.truncation.limit)){c=!0;break}a+=n.width.emoji,i=U.lastIndex;continue}const g=e.codePointAt(i)??0;if(Et(g)){i+=g>65535?2:1;continue}let w;if(o)w=xt(g,n);else switch(we(g)){case"control":{w=n.width.control;break}case"latin":{w=n.width.regular;break}case"wide":{w=n.width.wide;break}case"zero":{w=0;break}default:switch(ge(g)){case"ambiguous":{w=n.width.ambiguousIsNarrow?n.width.regular:n.width.wide;break}case"fullwidth":{w=n.width.fullWidth;break}case"wide":{w=n.width.wide;break}default:w=n.width.regular}}if(a+w>r&&(u=Math.min(u,i),a+w>n.truncation.limit)){c=!0;break}a+=w,i+=g>65535?2:1}let l=a,d=!1;return c&&n.truncation.limit>=n.truncation.ellipsisWidth&&(l=n.truncation.limit,d=!0),{ellipsed:d,index:c?u:s,truncated:c,width:l}},It=(e,t={})=>Y(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,be=80,ye=24,J=(e,t,{shell:n,env:r}={})=>Xe(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:n,env:r}).trim(),P=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),$e=(e,t)=>{const{columns:n,rows:r}=P(e,t);if(!(Number.isNaN(n)||Number.isNaN(r))&&!(n===be&&r===ye))return{columns:n,rows:r}},Wt=()=>{if(A.platform!=="linux")return!0;try{const e=W.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const n=e.slice(t+2).trim().split(/\s+/),r=Number.parseInt(n[2],10),s=Number.parseInt(n[5],10);return Number.isNaN(r)||Number.isNaN(s)||s<=0?!1:r===s}catch{return!1}};function kt(){const{env:e,stdout:t,stderr:n}=A;if(t?.columns&&t?.rows)return P(t.columns,t.rows);if(n?.columns&&n?.rows)return P(n.columns,n.rows);if(e.COLUMNS&&e.LINES)return P(e.COLUMNS,e.LINES);const r={columns:be,rows:ye};return A.platform==="win32"?G()??r:A.platform==="darwin"?ie()??G()??r:ie()??G()??Bt()??r}const ie=()=>{try{const e=A.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:t,rows:n}=et.WriteStream(W.openSync("/dev/tty",e));return{columns:t,rows:n}}catch{}},G=()=>{try{const e=J("tput",["cols"],{env:{TERM:"dumb",...A.env}}),t=J("tput",["lines"],{env:{TERM:"dumb",...A.env}});if(e&&t)return $e(e,t)}catch{}},Bt=()=>{try{if(!Wt())return;const e=J("resize",["-u"]).match(/\d+/g);if(e.length===2)return $e(e[0],e[1])}catch{}},I=new Map,Mt=500,$=e=>{if(!e||e==="")return"";const t=I.get(e);if(t!==void 0)return t;let n;try{n=Ke(Object.assign([],{raw:[e]}))}catch{n=e}if(I.size>=Mt){const r=I.keys().next().value;r!==void 0&&I.delete(r)}return I.set(e,n),n},T=()=>{const e=Ce().CEREBRO_TERMINAL_WIDTH;if(e===void 0)return;const t=Number.parseInt(e,10);if(!(Number.isNaN(t)||t<=0))return t};class Ne{lines;constructor(){this.lines=[]}add(t){this.lines.push(t)}toString(){return this.lines.join(tt.EOL)}header(t){this.add(j(t)),this.lines.push("")}}const Ct=e=>e!==void 0&&e>0?e:kt().columns,jt=(e,t,n,r)=>{if(e.length===0||e.some(c=>c.length!==2))return;let s=0;for(const c of e){const h=c[0];if(h===void 0)continue;const l=It(h);l>s&&(s=l)}if(s===0)return;const o=n+r,i=s+o,a=20+o;if(i+a>t)return;const u=t-i;return[i,u]};class Rt extends Ne{constructor(t){if(super(),t.header&&this.header($(t.header)),t.content){if(t.raw)if(Array.isArray(t.content)&&t.content.every(n=>typeof n=="string"))t.content.forEach(n=>{Array.isArray(n)?n.forEach(r=>{this.add($(r))}):this.add($(n))});else if(typeof t.content=="string")this.add($(t.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(t.content));this.add("")}}getContentLines(t){if(typeof t=="string"){const n=R({showHeader:!1,style:{border:_,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.addRow([$(t)]),n.toString()}if(Array.isArray(t)&&t.every(n=>typeof n=="string"||Array.isArray(n)&&n.every(r=>typeof r=="string"))){const n=Ct(T()),r=a=>Array.isArray(a)?a.map(u=>$(u)):[$(a)],s=t.map(a=>r(a)),o=jt(s,n,4,1),i=R({columnWidths:o,showHeader:!1,style:{border:_,paddingLeft:4,paddingRight:1},terminalWidth:n,truncateOverflow:!1,wordWrap:!0});return s.forEach(a=>{o!==void 0&&a.length===2?i.addRow([{content:a[0],wordWrap:!1},a[1]]):i.addRow(a)}),i.toString()}if(typeof t=="object"){const n=t;if(!n.options||!n.data)throw new Error(`Must have an "options" or "data" property
4
+ ${JSON.stringify(t)}`);const r=R({showHeader:!1,style:{border:_,paddingLeft:4,paddingRight:1},terminalWidth:T(),truncateOverflow:!1,wordWrap:!0});return n.data.forEach(s=>{Array.isArray(s)?r.addRow(s.map(o=>$(o))):r.addRow([$(s)])}),r.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
5
5
 
6
- ${JSON.stringify(e)}`)}}class _e extends Nt{constructor(e){super();let n=e.optionList??[];const r=Array.isArray(e.hide)?e.hide:[e.hide].filter(i=>typeof i=="string"),s=Array.isArray(e.group)?e.group:[e.group].filter(i=>typeof i=="string");r.length>0&&(n=n.filter(i=>!r.includes(i.name))),e.header&&this.header($(e.header)),s.length>0&&(n=n.filter(i=>{const a=i,u=s.includes("_none")&&!a.group,c=a.group,h=this.intersect(Array.isArray(c)?c:[c],s);return u||h?i:void 0}));const o=R({showHeader:!1,style:{border:_,paddingLeft:2,paddingRight:1,...e.tableOptions?.style},terminalWidth:T()??e.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:e.tableOptions?.wordWrap??!0,...e.tableOptions});n.forEach(i=>{const a=i;o.addRow([this.getOptionNames(a,e.reverseNameOrder??!1,e.isArgument??!1),$(a.description)])}),this.add(o.toString()),this.lines.push("")}getOptionNames(e,n,r){if(!e.name)throw new TypeError("Invalid option definition, name is required.");const s=e.type?e.type.name.toLowerCase():"string",{lazyMultiple:o}=e,i=e.multiple||o?"[]":"",a=e.typeLabel===void 0?kt(`${s}${i}`):$(e.typeLabel),u=r?j(e.name):j.yellow(`--${e.name}`),c=e.alias;if(c){const h=j(`-${c}`);return n?`${u}, ${h} ${a}`:`${h}, ${u} ${a}`}return`${u} ${a}`}intersect(e,n){return e.some(r=>n.includes(r))}}const K=t=>(Array.isArray(t)?t:[t]).length===0?"":`
7
- ${t.map(e=>e.optionList?new _e(e).toString():new Re(e).toString()).join(`
8
- `)}`,st=(t,e)=>{const n=`${e==="readme"?t.name.toUpperCase():t.name}${t.multiple===!0?"...":""}`;return t.required===!0?e==="readme"?n:`<${n}>`:`[${n}]`},Pe=(t,e="help")=>t.argument?t.argument.hidden?"":e==="readme"?` ${st(t.argument,e)}`:" [positional arguments]":!t.arguments||t.arguments.length===0?"":t.arguments.filter(n=>!n.hidden).map(n=>` ${st(n,e)}`).join(""),Te=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],at="__Other",lt=t=>t.charAt(0).toUpperCase()+t.slice(1),Le=(t,e,n,r)=>{t.debug("no command given, printing general help...");let s=[...new Set(n.values())].filter(a=>!a.hidden);r&&(s=s.filter(a=>a.group===r));const o=s.reduce((a,u)=>{const c=u.group??at;return a[c]??=[],a[c].push(u),a},{}),i=a=>a.map(u=>{let c="";typeof u.alias=="string"?c=u.alias:Array.isArray(u.alias)&&(c=u.alias.join(", ")),c!==""&&(c=` [${c}]`);let h=u.name;return u.commandPath&&u.commandPath.length>0&&(h=`${u.commandPath.join(" ")} ${u.name}`),[`${N(h)}${c}`,u.description??""]});(t.raw??t.log)(K([{content:`${x(e.getCliName())} ${N("<command>")} [positional arguments] ${L("[options]")}`,header:b.cyan(" Usage ")},...Object.keys(o).map(a=>{const u=r?` ${lt(r)}`:"";return{content:i(o[a]),header:a===at||r?b.green(` Available${u} Commands `):` ${b.green(` ${lt(a)} `)}`}}),n.has("help")?{header:b.yellow(" Command Options "),optionList:n.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:b.yellow(" Global Options "),optionList:e.getGlobalOptions()},{content:Te.filter(a=>!a.hidden).map(a=>[a.name,a.description??""]),header:b.magenta(" Environment Variables ")},{content:`Run "${x(e.getCliName())} ${N("help <command>")}" or "${x(e.getCliName())} ${N("<command>")} ${L("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},ct=(t,e)=>{const n=[];for(const r of t.values()){if(r.hidden)continue;const s=r.commandPath??[];if(s.length<e.length)continue;let o=!0;for(const[i,a]of e.entries())if(s[i]!==a){o=!1;break}o&&n.push(r)}return n},Fe=(t,e,n,r)=>{const s=n.join(" "),o=[{content:`${x(e.getCliName())} ${N(s)} ${N("<subcommand>")} [positional arguments] ${L("[options]")}`,header:b.cyan(" Usage ")},{content:r.map(i=>{const a=[...i.commandPath??[],i.name].join(" ");return[N(a),i.description??""]}),header:b.green(" Subcommands ")},{header:b.yellow(" Global Options "),optionList:e.getGlobalOptions()},{content:`Run "${x(e.getCliName())} ${N(`${s} <subcommand>`)} ${L("--help")}" for help with a specific subcommand.`,raw:!0}];(t.raw??t.log)(K(o))},De=(t,e,n,r,s)=>{let o=s??n.get(r);if(!o)for(const l of n.values()){const d=l.commandPath?[...l.commandPath,l.name]:[l.name];if(d.at(-1)===r||d.join(" ")===r){o=l;break}}if(!o){const l=r.split(" ").filter(Boolean),d=l.length>0?ct(n,l):[];if(d.length>0){Fe(t,e,l,d);return}t.error(`Command "${r}" not found`);return}const i=[],a=(o.commandPath?[...o.commandPath,o.name]:[o.name]).join(" ");i.push({content:`${x(e.getCliName())} ${N(a)}${Pe(o)}${o.options?" [options]":""}`,header:b.cyan(" Usage ")}),o.description&&i.push({content:o.description,header:b.green(" Description ")});const u=(o.argument?[o.argument]:o.arguments??[]).filter(l=>!l.hidden);if(u.length>0&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:u}),Array.isArray(o.options)&&o.options.length>0&&i.push({header:b.yellow(" Command Options "),optionList:o.options.filter(l=>!l.hidden)}),i.push({header:b.yellow(" Global Options "),optionList:e.getGlobalOptions()}),Array.isArray(o.env)&&o.env.length>0){const l=o.env.filter(d=>!d.hidden);l.length>0&&i.push({content:l.map(d=>[d.name,d.description??""]),header:b.magenta(" Environment Variables ")})}if(o.alias!==void 0&&o.alias.length>0){let l=o.alias;typeof o.alias=="string"&&(l=[o.alias]),i.splice(1,0,{content:l,header:"Alias(es)"})}Array.isArray(o.examples)&&o.examples.length>0&&i.push({content:o.examples,header:"Examples"});const c=[...o.commandPath??[],o.name],h=ct(n,c);h.length>0&&i.push({content:h.map(l=>{const d=[...l.commandPath??[],l.name].join(" ");return[N(d),l.description??""]}),header:b.green(" Subcommands ")}),(t.raw??t.log)(K(i))};class He{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(e){this.commands=e}execute(e){const{argument:n,command:r,commandName:s,logger:o,options:i,runtime:a}=e,{footer:u,header:c}=a.getCommandSection();c&&(o.raw??o.log)($(c));const h=s==="help"&&Array.isArray(n)&&n.length>0?n.join(" "):void 0;if(s==="help"&&h===void 0)Le(o,a,this.commands,typeof i?.group=="string"?i.group:void 0);else{const l=h!==void 0||r===void 0||r.name==="help"?void 0:r;De(o,a,this.commands,h??s,l)}u&&(o.raw??o.log)($(u))}}export{He as default};
6
+ ${JSON.stringify(t)}`)}}class _t extends Ne{constructor(t){super();let n=t.optionList??[];const r=Array.isArray(t.hide)?t.hide:[t.hide].filter(i=>typeof i=="string"),s=Array.isArray(t.group)?t.group:[t.group].filter(i=>typeof i=="string");r.length>0&&(n=n.filter(i=>!r.includes(i.name))),t.header&&this.header($(t.header)),s.length>0&&(n=n.filter(i=>{const a=i,u=s.includes("_none")&&!a.group,c=a.group,h=this.intersect(Array.isArray(c)?c:[c],s);return u||h?i:void 0}));const o=R({showHeader:!1,style:{border:_,paddingLeft:2,paddingRight:1,...t.tableOptions?.style},terminalWidth:T()??t.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:t.tableOptions?.wordWrap??!0,...t.tableOptions});n.forEach(i=>{const a=i;o.addRow([this.getOptionNames(a,t.reverseNameOrder??!1,t.isArgument??!1),$(a.description)])}),this.add(o.toString()),this.lines.push("")}getOptionNames(t,n,r){if(!t.name)throw new TypeError("Invalid option definition, name is required.");const s=t.type?t.type.name.toLowerCase():"string",{lazyMultiple:o}=t,i=t.multiple||o?"[]":"",a=t.typeLabel===void 0?ke(`${s}${i}`):$(t.typeLabel),u=r?j(t.name):j.yellow(`--${t.name}`),c=t.alias;if(c){const h=j(`-${c}`);return n?`${u}, ${h} ${a}`:`${h}, ${u} ${a}`}return`${u} ${a}`}intersect(t,n){return t.some(r=>n.includes(r))}}const K=e=>(Array.isArray(e)?e:[e]).length===0?"":`
7
+ ${e.map(t=>t.optionList?new _t(t).toString():new Rt(t).toString()).join(`
8
+ `)}`,se=(e,t)=>{const n=`${t==="readme"?e.name.toUpperCase():e.name}${e.multiple===!0?"...":""}`;return e.required===!0?t==="readme"?n:`<${n}>`:`[${n}]`},Pt=(e,t="help")=>e.argument?e.argument.hidden?"":t==="readme"?` ${se(e.argument,t)}`:" [positional arguments]":!e.arguments||e.arguments.length===0?"":e.arguments.filter(n=>!n.hidden).map(n=>` ${se(n,t)}`).join(""),Tt=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],ae="__Other",le=e=>e.charAt(0).toUpperCase()+e.slice(1),Lt=(e,t,n,r)=>{e.debug("no command given, printing general help...");let s=[...new Set(n.values())].filter(a=>!a.hidden);r&&(s=s.filter(a=>a.group===r));const o=s.reduce((a,u)=>{const c=u.group??ae;return a[c]??=[],a[c].push(u),a},{}),i=a=>a.map(u=>{let c="";typeof u.alias=="string"?c=u.alias:Array.isArray(u.alias)&&(c=u.alias.join(", ")),c!==""&&(c=` [${c}]`);let h=u.name;return u.commandPath&&u.commandPath.length>0&&(h=`${u.commandPath.join(" ")} ${u.name}`),[`${N(h)}${c}`,u.description??""]});(e.raw??e.log)(K([{content:`${x(t.getCliName())} ${N("<command>")} [positional arguments] ${L("[options]")}`,header:b.cyan(" Usage ")},...Object.keys(o).map(a=>{const u=r?` ${le(r)}`:"";return{content:i(o[a]),header:a===ae||r?b.green(` Available${u} Commands `):` ${b.green(` ${le(a)} `)}`}}),n.has("help")?{header:b.yellow(" Command Options "),optionList:n.get("help").options?.filter(a=>!a.hidden)}:void 0,{header:b.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:Tt.filter(a=>!a.hidden).map(a=>[a.name,a.description??""]),header:b.magenta(" Environment Variables ")},{content:`Run "${x(t.getCliName())} ${N("help <command>")}" or "${x(t.getCliName())} ${N("<command>")} ${L("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},ce=(e,t)=>{const n=[];for(const r of e.values()){if(r.hidden)continue;const s=r.commandPath??[];if(s.length<t.length)continue;let o=!0;for(const[i,a]of t.entries())if(s[i]!==a){o=!1;break}o&&n.push(r)}return n},Ft=(e,t,n,r)=>{const s=n.join(" "),o=[{content:`${x(t.getCliName())} ${N(s)} ${N("<subcommand>")} [positional arguments] ${L("[options]")}`,header:b.cyan(" Usage ")},{content:r.map(i=>{const a=[...i.commandPath??[],i.name].join(" ");return[N(a),i.description??""]}),header:b.green(" Subcommands ")},{header:b.yellow(" Global Options "),optionList:t.getGlobalOptions()},{content:`Run "${x(t.getCliName())} ${N(`${s} <subcommand>`)} ${L("--help")}" for help with a specific subcommand.`,raw:!0}];(e.raw??e.log)(K(o))},Dt=(e,t,n,r,s)=>{let o=s??n.get(r);if(!o)for(const l of n.values()){const d=l.commandPath?[...l.commandPath,l.name]:[l.name];if(d.at(-1)===r||d.join(" ")===r){o=l;break}}if(!o){const l=r.split(" ").filter(Boolean),d=l.length>0?ce(n,l):[];if(d.length>0){Ft(e,t,l,d);return}e.error(`Command "${r}" not found`);return}const i=[],a=(o.commandPath?[...o.commandPath,o.name]:[o.name]).join(" ");i.push({content:`${x(t.getCliName())} ${N(a)}${Pt(o)}${o.options?" [options]":""}`,header:b.cyan(" Usage ")}),o.description&&i.push({content:o.description,header:b.green(" Description ")});const u=(o.argument?[o.argument]:o.arguments??[]).filter(l=>!l.hidden);if(u.length>0&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:u}),Array.isArray(o.options)&&o.options.length>0&&i.push({header:b.yellow(" Command Options "),optionList:o.options.filter(l=>!l.hidden)}),i.push({header:b.yellow(" Global Options "),optionList:t.getGlobalOptions()}),Array.isArray(o.env)&&o.env.length>0){const l=o.env.filter(d=>!d.hidden);l.length>0&&i.push({content:l.map(d=>[d.name,d.description??""]),header:b.magenta(" Environment Variables ")})}if(o.alias!==void 0&&o.alias.length>0){let l=o.alias;typeof o.alias=="string"&&(l=[o.alias]),i.splice(1,0,{content:l,header:"Alias(es)"})}Array.isArray(o.examples)&&o.examples.length>0&&i.push({content:o.examples,header:"Examples"});const c=[...o.commandPath??[],o.name],h=ce(n,c);h.length>0&&i.push({content:h.map(l=>{const d=[...l.commandPath??[],l.name].join(" ");return[N(d),l.description??""]}),header:b.green(" Subcommands ")}),(e.raw??e.log)(K(i))};class Ht{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(t){this.commands=t}execute(t){const{argument:n,command:r,commandName:s,logger:o,options:i,runtime:a}=t,{footer:u,header:c}=a.getCommandSection();c&&(o.raw??o.log)($(c));const h=s==="help"&&Array.isArray(n)&&n.length>0?n.join(" "):void 0;if(s==="help"&&h===void 0)Lt(o,a,this.commands,typeof i?.group=="string"?i.group:void 0);else{const l=h!==void 0||r===void 0||r.name==="help"?void 0:r;Dt(o,a,this.commands,h??s,l)}u&&(o.raw??o.log)($(u))}}export{Ht as default};
@@ -1,7 +1,7 @@
1
- import{a as nt,e as st,l as At,z as O}from"../packem_shared/index-DHD8wb6Z.js";import{L as Et}from"../packem_shared/index-BisalDCf.js";import{p as bt}from"./cli-main.js";import{q as xt,L as Ct,T as S,R as L,B as W,U as E,O as N,K as Q,Z as V,W as jt,r as K,t as kt,F as D,u as Y,x as J,H as Lt,w as Wt,M as Ut,C as St,P as Tt,v as Ot,y as Pt,Y as _t,z as It,J as Rt,A as zt,V as Nt,E as vt,G as Ft,I as Mt,N as Bt}from"../packem_shared/formatBytes-BHAzNIrn-XohRrPdt.js";import{P as I,L as qt}from"./catalog.js";const Gt=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Qt=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),Vt=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Qt,"")},v=new I(1e3),Kt=/[.*+?^${}()|[\]\\]/g,Dt=t=>{const e=t.join("");if(v.has(e)){const r=v.get(e);return r.lastIndex=0,r}const s=t.map(r=>r.replaceAll(Kt,String.raw`\$&`)).join("|"),n=new RegExp(s,"g");return v.set(e,n),n},Yt=t=>{const e=[];let s=0,n;for(L.lastIndex=0;(n=L.exec(t))!==null;)n.index>s&&e.push(t.slice(s,n.index)),e.push(n[0]),s=L.lastIndex;return s<t.length&&e.push(t.slice(s)),e.filter(Boolean)},Jt=/[ČŠŽĐ]/i,rt=new Uint8Array(128),ot=new Uint8Array(128),it=new Uint8Array(128);for(let t=0;t<128;t++)rt[t]=t>=65&&t<=90?1:0,ot[t]=t>=97&&t<=122?1:0,it[t]=t>=48&&t<=57?1:0;const F=t=>rt[t],Z=t=>ot[t],M=t=>it[t],j=(t,e,s,n,r)=>{if(t.length===0)return[];let o=!1;const a=Object.values(e);for(const u of a)if(u(t[0])){o=!0;break}if(!o&&!s)return[t];const l=[...t],h=[];let i=l[0],p="other";const d=Object.entries(e);for(const u of d){const[f,g]=u;if(g(l[0])){p=f;break}}let c=s&&n?l[0]===l[0].toLocaleUpperCase(n):!1;for(let u=1;u<l.length;u++){const f=l[u];let g="other";for(const w of d){const[$,A]=w;if(A(f)){g=$;break}}const y=s&&n?f===f.toLocaleUpperCase(n):!1;let m=!1;r?m=r(p,g,c,y,f,u,l):(p!==g&&p!=="other"&&g!=="other"&&(m=!0),s&&g!=="other"&&!c&&y&&(m=!0)),m?(h.push(i),i=f):i+=f,p=g,s&&(c=y)}return i&&i.length>0&&h.push(i),h.length>0?h:[t]},Zt=(t,e,s,n)=>{if(s.size===0)return e;for(const r of s)if(t.startsWith(r,e))return n.push(r),e+r.length;return e},lt=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let s=0;const n=[],r=t.length;for(let o=1;o<r;o++){const a=Zt(t,s,e,n);if(a!==s){s=a,o=s-1;continue}const l=t.codePointAt(o-1),h=t.codePointAt(o),i=l&&l<128&&F(l),p=h&&h<128&&F(h),d=l&&l<128&&Z(l),c=l&&l<128&&M(l),u=h&&h<128&&M(h);if(d&&p){n.push(t.slice(s,o)),s=o;continue}if(c&&!u||!c&&u){n.push(t.slice(s,o)),s=o;continue}if(u&&!c){let f=!1,g=!1;if(o+1<r){const y=t.codePointAt(o+1);f=y&&y<128&&F(y),g=y&&y<128&&M(y)}if(!g&&f){n.push(t.slice(s,o),t.slice(o,o+1)),s=o+1;continue}}if(o+1<r){const f=t.codePointAt(o+1),g=f&&f<128&&Z(f);if(i&&p&&g){const y=t.slice(s,o+1);e.has(y)||(n.push(t.slice(s,o)),s=o)}}}return s<r&&n.push(t.slice(s)),n.filter(o=>o!=="")},at=(t,e,s)=>{if(t.length===0)return[];const n=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!n&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const i=[...t],p=i.length,d=[];let c=i[0],u=i[0]===i[0].toLocaleUpperCase(e),f=u,g=u?0:-1;for(let y=1;y<p;y++){const m=i[y],w=m===m.toLocaleUpperCase(e);if(w===u)c+=m;else if(w)c&&c.length>0&&(d.push(c),c=m),f=!0,g=y;else{if(f&&y-g>1){const $=i[y-1],A=c.slice(0,-1);A&&A.length>0&&d.push(A),c=$+m}else c+=m;f=!1,g=-1}u=w}return c&&c.length>0&&d.push(c),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!W.test(t)&&!E.test(t))return[t];const i=[...t],p=i.length,d=[];let c=i[0];const u=i[0];let f;W.test(u)?f=1:E.test(u)?f=2:f=0;let g=u===u.toLocaleUpperCase(e);for(let m=1;m<p;m++){const w=i[m];let $;W.test(w)?$=1:E.test(w)?$=2:$=0;const A=w===w.toLocaleUpperCase(e);f!==$&&(f===1||f===2)&&($===1||$===2)||$===f&&!g&&A?(d.push(c),c=w):c+=w,f=$,g=A}c&&c.length>0&&d.push(c);const y=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&E.test(d[m])&&W.test(d[m+1][0])?(y.push(d[m]+d[m+1]),m+=1):y.push(d[m]);return y}if(e.startsWith("el")){if(!N.test(t)&&!E.test(t))return[t];const i=[];Q.lastIndex=0;let p;for(;(p=Q.exec(t))!==null;)i.push(p[0]);i.length===0&&i.push(t);const d=[];if(i.length===1){const c=i[0];if(!c||!N.test(c[0])||c.length===1)return[c??t]}for(const c of i){if(!c)continue;if(!N.test(c[0])||c.length===1){d.push(c);continue}const u=c.length;let f=c[0],g=c[0]===c[0].toLocaleUpperCase(e);for(let y=1;y<u;y++){const m=c[y],w=m===m.toLocaleUpperCase(e);!g&&w?(d.push(f),f=m):f+=m,g=w}f&&d.push(f)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const i=e.startsWith("ja"),p=i?{hiragana:c=>kt.test(c),kanji:c=>K.test(c),katakana:c=>jt.test(c),latin:c=>E.test(c)}:{hangul:c=>D.test(c),latin:c=>E.test(c)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(i){const c=j(t,p,!1,e,(f,g)=>f==="hiragana"&&g==="katakana"||f==="katakana"&&g==="hiragana"||f==="hiragana"&&g==="latin"||f==="katakana"&&g==="latin"||f==="kanji"&&g==="latin"||f==="latin"&&(g==="hiragana"||g==="katakana"||g==="kanji")),u=[];for(const f of c){const g=f;g.length===1&&d.has(g)&&u.length>0?u[u.length-1]=u.at(-1)+g:u.push(g)}return u.length>0?u:[t]}return j(t,p,!1,e,(c,u)=>c==="hangul"&&u==="latin"||c==="latin"&&u==="hangul")}if(e.startsWith("sl")){const i=[...t],p=i.length,d=[];let c=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(let f=1;f<p;f++){const g=i[f],y=g===g.toLocaleUpperCase(e),m=Jt.test(g),w=f<p-1&&i[f+1]===i[f+1].toLocaleUpperCase(e);!u&&y||m&&w?(d.push(c),c=g,m&&w&&(d.push(c),c="")):c+=g,u=y}return c&&c.length>0&&d.push(c),d}if(e.startsWith("zh"))return j(t,{han:i=>K.test(i),latin:i=>E.test(i)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const i=p=>Y.test(p)||J.test(p);return j(t,{latin:p=>E.test(p),rtl:p=>i(p)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const i=p=>Lt.test(p)||Wt.test(p)||Ut.test(p)||St.test(p)||Tt.test(p)||Ot.test(p)||Pt.test(p)||_t.test(p)||It.test(p)||Rt.test(p)||zt.test(p)||Nt.test(p)||vt.test(p)||Ft.test(p)||Mt.test(p)||Bt.test(p);return j(t,{indic:p=>i(p),latin:p=>E.test(p)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return j(t,{cyrillic:i=>W.test(i),latin:i=>E.test(i)},!0,e);if(["ar","fa","he"].includes(e))return j(t,{latin:i=>E.test(i),rtl:i=>Y.test(i)||J.test(i)},!1,e);if(e.startsWith("ko"))return j(t,{hangul:i=>D.test(i),latin:i=>E.test(i)},!1,e);if(e.startsWith("uz")){if(!W.test(t)&&!E.test(t))return[t];const i=[...t],p=i.length,d=[];let c=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(let f=1;f<p;f++){const g=i[f],y=g===g.toLocaleUpperCase(e);if(V.test(g)||V.test(i[f-1])){c+=g;continue}!u&&y?(d.push(c),c=g):c+=g,u=y}return c&&c.length>0&&d.push(c),d}const r=[...t],o=r.length,a=[];let l=r[0],h=r[0]===r[0].toLocaleUpperCase(e);for(const i of s)if(t.startsWith(i)){a.push(i),l=r[i.length],h=l===l.toLocaleUpperCase(e);break}for(let i=1;i<o;i++){const p=r[i],d=p===p.toLocaleUpperCase(e);let c=0;for(const u of s)if(t.startsWith(u,i)){a.push(l,u),c=u.length,l="";const f=u.at(-1);f&&(h=f===f.toLocaleUpperCase(e));break}if(c>0){i+=c-1;continue}!h&&d?(a.push(l),l=p):l+=p,h=d}return l&&a.push(l),a},Ht=(t,e,s)=>{const n=[],r=S.test(t)?t.split(S).filter(Boolean):[t];for(const o of r){const a=o;if(S.test(a))n.push(a);else{L.lastIndex=0;const l=L.test(a)?Yt(a).filter(Boolean):[a];for(const h of l)if(L.lastIndex=0,L.test(h))n.push(h);else if(e){const i=e.toLowerCase().split("-")[0];n.push(...at(h,i,s))}else n.push(...lt(h,s))}}return n},R=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:s=!1,handleEmoji:n=!1,knownAcronyms:r=[],locale:o,normalize:a=!1,separators:l,stripAnsi:h=!1,stripEmoji:i=!1}=e,p=new Set([...r].toSorted((m,w)=>w.length-m.length));let d=t;h&&(d=Vt(d)),i&&(d=xt(d));let c;Array.isArray(l)?c=Dt(l):l instanceof RegExp?c=l:c=Ct;const u=[];let f=d;const g=c.flags.includes("g")?c:new RegExp(c.source,`${c.flags}g`);for(;f.length>0;){const m=g.exec(f);if(!m){f===".."?u.push(".."):f==="."?u.push("."):f.length>0&&u.push(f);break}const w=m.index,$=m[0],A=$.length,T=f.slice(0,w),$t=f.slice(w+A);if($.startsWith("../"))u.push(".."),f=f.slice(w+3);else if($.startsWith("./"))u.push("."),f=f.slice(w+2);else if(w===0&&$==="..")u.push(".."),f=f.slice(2);else if(w===0&&$===".")u.push("."),f=f.slice(1);else{T.length>0&&u.push(T);let x=0;for(;(x=$.indexOf("../",x))!==-1;)u.push(".."),x+=3;for(x=0;(x=$.indexOf("./",x))!==-1;)(x===0||$[x-1]!==".")&&u.push("."),x+=2;let C=$t;for(;C.startsWith("../");)u.push(".."),C=C.slice(3);for(;C.startsWith("./");)u.push("."),C=C.slice(2);if(C===".."){u.push("..");break}else if(C==="."){u.push(".");break}else f=C}g.lastIndex=0}if(u.length===0){const m=d.split(c).filter(Boolean);u.push(...m)}let y=[];for(const m of u)s||n?y.push(...Ht(m,o,p)):o?y.push(...at(m,o,p)):y.push(...lt(m,p));return a&&(y=y.map(m=>p.has(m)?m:o&&m===m.toLocaleUpperCase(o)?m[0]+m.slice(1).toLocaleLowerCase(o):m.toUpperCase()===m&&!p.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),y},q=(t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),Xt=(t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}::${e?.stripAnsi?"true":"false"}::${e?.stripEmoji?"true":"false"}::${e?.handleAnsi?"true":"false"}::${e?.handleEmoji?"true":"false"}`,z=(t,e)=>{const{length:s}=t;if(s===0)return"";if(s===1)return t[0];const n=[];let r="",o="";for(let a=0;a<s;a++){const l=t[a];if(S.test(l)){r?(n.push(r+o+l),r="",o=""):(n.length>0&&n.push(e),r=l);continue}r?(o&&(o+=e),o+=l):(n.length>0&&n.push(e),n.push(l))}return n.join("")},te=/(?<![a-zß])SS(?![a-z])/g,ee=t=>t.replaceAll(te,"ß"),ne=(t,e)=>{if(typeof t!="string"||!t)return"";let s=!0;return z(R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(r=>{const o=r,a=o.toLowerCase();return s?(s=!1,Gt(a)):q(a,e)}),"")},se=new I(1e3),G=(t,e)=>{if(typeof t!="string")return"";const s=e?.cache??!1,n=e?.cacheStore??se;let r;if(s&&(r=Xt(t,e)),s&&r&&n.has(r))return n.get(r);const o=R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(l=>{if(e?.handleAnsi&&S.test(l))return l;if(e?.toUpperCase)return e.locale?l.toLocaleUpperCase(e.locale):l.toUpperCase();const h=e?.locale?.startsWith("de")?ee(l):l;return e?.locale?h.toLocaleLowerCase(e.locale):h.toLowerCase()}),a=z(o,e?.joiner??"-");return s&&r&&n.set(r,a),a},re=new I(1e3),oe=(t,e)=>G(t,{cacheStore:re,...e,joiner:"_",toUpperCase:!0}),ie=(t,e)=>typeof t!="string"||!t?"":z(R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(n=>q(n.toLowerCase(),{locale:e?.locale})),""),le=new I(1e3),ae=(t,e)=>G(t,{cacheStore:le,...e,joiner:"_"}),ce=(t,e)=>typeof t!="string"?"":z(R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(n=>q(n,{locale:e?.locale})),"-"),b=t=>t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):JSON.stringify(t),H={camel_case:t=>ne(b(t)),kebab_case:t=>G(b(t)),lower_case:t=>b(t).toLowerCase(),pascal_case:t=>ie(b(t)),path_join:(t,...e)=>{const s=[b(t),...e.map(n=>b(n))];return st(...s)},path_relative:(t,e)=>nt(b(e),b(t)),snake_case:t=>ae(b(t)),upper_case:t=>b(t).toUpperCase(),upper_kebab_case:t=>ce(b(t)),upper_snake_case:t=>oe(b(t))},ct=(t,e,s=[])=>{const n=H[t];if(!n)throw new Error(`Unknown filter "${t}". Known filters: ${Object.keys(H).sort().join(", ")}.`);return n(e,...s)},ft=t=>{const e=[];let s=0,n=0,r,o=-1;for(const a of t){if(o+=1,r){a===r&&(r=void 0);continue}if(a==='"'||a==="'"){r=a;continue}a==="("?s+=1:a===")"?s-=1:a===","&&s===0&&(e.push(t.slice(n,o)),n=o+1)}return e.push(t.slice(n)),e},fe=t=>{if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1)},ue=/\[([^\]]+)\]/g,pe=t=>{const e=t.trim(),s=e.indexOf("(");if(s===-1)return{args:[],name:e};if(!e.endsWith(")"))throw new Error(`Filter call "${t}" missing closing ")"`);const n=e.slice(0,s).trim(),r=e.slice(s+1,-1).trim();return r===""?{args:[],name:n}:{args:ft(r).map(a=>{const l=a.trim();return fe(l)??l}),name:n}},he=t=>{const e=t.split("|").map(r=>r.trim()),s=e[0]??"";if(!s)throw new Error(`Empty variable name in expression "${t}"`);return{filters:e.slice(1).map(r=>pe(r)),name:s}},de=t=>t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):JSON.stringify(t),me=(t,e)=>{const s=t.replaceAll(ue,(n,r)=>{const{filters:o,name:a}=he(r);if(!Object.hasOwn(e,a))throw new Error(`Variable "${a}" used in filename "${t}" but not defined`);let l=e[a];for(const h of o)l=ct(h.name,l,h.args);return de(l)});return ut(s)},ut=t=>t.split("/").map(e=>e.endsWith(".tera")||e.endsWith(".twig")?e.slice(0,-5):e).join("/"),ge=t=>t.endsWith(".raw")?t.slice(0,-4):t,ye=t=>{const e=t.split("/");return(e.at(-1)??"").startsWith("_")?!0:e.slice(0,-1).includes("partials")},k="---",we=(t,e)=>{if(!t.startsWith(`${k}
1
+ import{l as At,z as O}from"../packem_shared/index-CVBR-Kit.js";import{n as nt,e as st}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{L as Et}from"../packem_shared/index-BisalDCf.js";import{p as bt}from"./cli-main.js";import{q as xt,L as Ct,T as U,R as L,B as W,U as E,O as N,K as Q,Z as V,W as jt,r as K,t as kt,F as D,u as Y,x as J,H as Lt,w as Wt,M as St,C as Ut,P as Tt,v as Ot,y as Pt,Y as _t,z as It,J as Rt,A as zt,V as Nt,E as vt,G as Ft,I as Mt,N as Bt}from"../packem_shared/formatBytes-BHAzNIrn-CLYsxlUj.js";import{S as I,L as qt}from"./catalog.js";const Gt=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Qt=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),Vt=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Qt,"")},v=new I(1e3),Kt=/[.*+?^${}()|[\]\\]/g,Dt=t=>{const e=t.join("");if(v.has(e)){const r=v.get(e);return r.lastIndex=0,r}const s=t.map(r=>r.replaceAll(Kt,String.raw`\$&`)).join("|"),n=new RegExp(s,"g");return v.set(e,n),n},Yt=t=>{const e=[];let s=0,n;for(L.lastIndex=0;(n=L.exec(t))!==null;)n.index>s&&e.push(t.slice(s,n.index)),e.push(n[0]),s=L.lastIndex;return s<t.length&&e.push(t.slice(s)),e.filter(Boolean)},Jt=/[ČŠŽĐ]/i,rt=new Uint8Array(128),ot=new Uint8Array(128),it=new Uint8Array(128);for(let t=0;t<128;t++)rt[t]=t>=65&&t<=90?1:0,ot[t]=t>=97&&t<=122?1:0,it[t]=t>=48&&t<=57?1:0;const F=t=>rt[t],Z=t=>ot[t],M=t=>it[t],j=(t,e,s,n,r)=>{if(t.length===0)return[];let o=!1;const a=Object.values(e);for(const u of a)if(u(t[0])){o=!0;break}if(!o&&!s)return[t];const l=[...t],h=[];let i=l[0],p="other";const d=Object.entries(e);for(const u of d){const[f,g]=u;if(g(l[0])){p=f;break}}let c=s&&n?l[0]===l[0].toLocaleUpperCase(n):!1;for(let u=1;u<l.length;u++){const f=l[u];let g="other";for(const w of d){const[$,A]=w;if(A(f)){g=$;break}}const y=s&&n?f===f.toLocaleUpperCase(n):!1;let m=!1;r?m=r(p,g,c,y,f,u,l):(p!==g&&p!=="other"&&g!=="other"&&(m=!0),s&&g!=="other"&&!c&&y&&(m=!0)),m?(h.push(i),i=f):i+=f,p=g,s&&(c=y)}return i&&i.length>0&&h.push(i),h.length>0?h:[t]},Zt=(t,e,s,n)=>{if(s.size===0)return e;for(const r of s)if(t.startsWith(r,e))return n.push(r),e+r.length;return e},lt=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let s=0;const n=[],r=t.length;for(let o=1;o<r;o++){const a=Zt(t,s,e,n);if(a!==s){s=a,o=s-1;continue}const l=t.codePointAt(o-1),h=t.codePointAt(o),i=l&&l<128&&F(l),p=h&&h<128&&F(h),d=l&&l<128&&Z(l),c=l&&l<128&&M(l),u=h&&h<128&&M(h);if(d&&p){n.push(t.slice(s,o)),s=o;continue}if(c&&!u||!c&&u){n.push(t.slice(s,o)),s=o;continue}if(u&&!c){let f=!1,g=!1;if(o+1<r){const y=t.codePointAt(o+1);f=y&&y<128&&F(y),g=y&&y<128&&M(y)}if(!g&&f){n.push(t.slice(s,o),t.slice(o,o+1)),s=o+1;continue}}if(o+1<r){const f=t.codePointAt(o+1),g=f&&f<128&&Z(f);if(i&&p&&g){const y=t.slice(s,o+1);e.has(y)||(n.push(t.slice(s,o)),s=o)}}}return s<r&&n.push(t.slice(s)),n.filter(o=>o!=="")},at=(t,e,s)=>{if(t.length===0)return[];const n=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!n&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const i=[...t],p=i.length,d=[];let c=i[0],u=i[0]===i[0].toLocaleUpperCase(e),f=u,g=u?0:-1;for(let y=1;y<p;y++){const m=i[y],w=m===m.toLocaleUpperCase(e);if(w===u)c+=m;else if(w)c&&c.length>0&&(d.push(c),c=m),f=!0,g=y;else{if(f&&y-g>1){const $=i[y-1],A=c.slice(0,-1);A&&A.length>0&&d.push(A),c=$+m}else c+=m;f=!1,g=-1}u=w}return c&&c.length>0&&d.push(c),d}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!W.test(t)&&!E.test(t))return[t];const i=[...t],p=i.length,d=[];let c=i[0];const u=i[0];let f;W.test(u)?f=1:E.test(u)?f=2:f=0;let g=u===u.toLocaleUpperCase(e);for(let m=1;m<p;m++){const w=i[m];let $;W.test(w)?$=1:E.test(w)?$=2:$=0;const A=w===w.toLocaleUpperCase(e);f!==$&&(f===1||f===2)&&($===1||$===2)||$===f&&!g&&A?(d.push(c),c=w):c+=w,f=$,g=A}c&&c.length>0&&d.push(c);const y=[];for(let m=0;m<d.length;m++)m<d.length-1&&d[m].length===1&&E.test(d[m])&&W.test(d[m+1][0])?(y.push(d[m]+d[m+1]),m+=1):y.push(d[m]);return y}if(e.startsWith("el")){if(!N.test(t)&&!E.test(t))return[t];const i=[];Q.lastIndex=0;let p;for(;(p=Q.exec(t))!==null;)i.push(p[0]);i.length===0&&i.push(t);const d=[];if(i.length===1){const c=i[0];if(!c||!N.test(c[0])||c.length===1)return[c??t]}for(const c of i){if(!c)continue;if(!N.test(c[0])||c.length===1){d.push(c);continue}const u=c.length;let f=c[0],g=c[0]===c[0].toLocaleUpperCase(e);for(let y=1;y<u;y++){const m=c[y],w=m===m.toLocaleUpperCase(e);!g&&w?(d.push(f),f=m):f+=m,g=w}f&&d.push(f)}return d}if(e.startsWith("ja")||e.startsWith("ko")){const i=e.startsWith("ja"),p=i?{hiragana:c=>kt.test(c),kanji:c=>K.test(c),katakana:c=>jt.test(c),latin:c=>E.test(c)}:{hangul:c=>D.test(c),latin:c=>E.test(c)},d=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(i){const c=j(t,p,!1,e,(f,g)=>f==="hiragana"&&g==="katakana"||f==="katakana"&&g==="hiragana"||f==="hiragana"&&g==="latin"||f==="katakana"&&g==="latin"||f==="kanji"&&g==="latin"||f==="latin"&&(g==="hiragana"||g==="katakana"||g==="kanji")),u=[];for(const f of c){const g=f;g.length===1&&d.has(g)&&u.length>0?u[u.length-1]=u.at(-1)+g:u.push(g)}return u.length>0?u:[t]}return j(t,p,!1,e,(c,u)=>c==="hangul"&&u==="latin"||c==="latin"&&u==="hangul")}if(e.startsWith("sl")){const i=[...t],p=i.length,d=[];let c=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(let f=1;f<p;f++){const g=i[f],y=g===g.toLocaleUpperCase(e),m=Jt.test(g),w=f<p-1&&i[f+1]===i[f+1].toLocaleUpperCase(e);!u&&y||m&&w?(d.push(c),c=g,m&&w&&(d.push(c),c="")):c+=g,u=y}return c&&c.length>0&&d.push(c),d}if(e.startsWith("zh"))return j(t,{han:i=>K.test(i),latin:i=>E.test(i)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const i=p=>Y.test(p)||J.test(p);return j(t,{latin:p=>E.test(p),rtl:p=>i(p)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const i=p=>Lt.test(p)||Wt.test(p)||St.test(p)||Ut.test(p)||Tt.test(p)||Ot.test(p)||Pt.test(p)||_t.test(p)||It.test(p)||Rt.test(p)||zt.test(p)||Nt.test(p)||vt.test(p)||Ft.test(p)||Mt.test(p)||Bt.test(p);return j(t,{indic:p=>i(p),latin:p=>E.test(p)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return j(t,{cyrillic:i=>W.test(i),latin:i=>E.test(i)},!0,e);if(["ar","fa","he"].includes(e))return j(t,{latin:i=>E.test(i),rtl:i=>Y.test(i)||J.test(i)},!1,e);if(e.startsWith("ko"))return j(t,{hangul:i=>D.test(i),latin:i=>E.test(i)},!1,e);if(e.startsWith("uz")){if(!W.test(t)&&!E.test(t))return[t];const i=[...t],p=i.length,d=[];let c=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(let f=1;f<p;f++){const g=i[f],y=g===g.toLocaleUpperCase(e);if(V.test(g)||V.test(i[f-1])){c+=g;continue}!u&&y?(d.push(c),c=g):c+=g,u=y}return c&&c.length>0&&d.push(c),d}const r=[...t],o=r.length,a=[];let l=r[0],h=r[0]===r[0].toLocaleUpperCase(e);for(const i of s)if(t.startsWith(i)){a.push(i),l=r[i.length],h=l===l.toLocaleUpperCase(e);break}for(let i=1;i<o;i++){const p=r[i],d=p===p.toLocaleUpperCase(e);let c=0;for(const u of s)if(t.startsWith(u,i)){a.push(l,u),c=u.length,l="";const f=u.at(-1);f&&(h=f===f.toLocaleUpperCase(e));break}if(c>0){i+=c-1;continue}!h&&d?(a.push(l),l=p):l+=p,h=d}return l&&a.push(l),a},Ht=(t,e,s)=>{const n=[],r=U.test(t)?t.split(U).filter(Boolean):[t];for(const o of r){const a=o;if(U.test(a))n.push(a);else{L.lastIndex=0;const l=L.test(a)?Yt(a).filter(Boolean):[a];for(const h of l)if(L.lastIndex=0,L.test(h))n.push(h);else if(e){const i=e.toLowerCase().split("-")[0];n.push(...at(h,i,s))}else n.push(...lt(h,s))}}return n},R=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:s=!1,handleEmoji:n=!1,knownAcronyms:r=[],locale:o,normalize:a=!1,separators:l,stripAnsi:h=!1,stripEmoji:i=!1}=e,p=new Set([...r].toSorted((m,w)=>w.length-m.length));let d=t;h&&(d=Vt(d)),i&&(d=xt(d));let c;Array.isArray(l)?c=Dt(l):l instanceof RegExp?c=l:c=Ct;const u=[];let f=d;const g=c.flags.includes("g")?c:new RegExp(c.source,`${c.flags}g`);for(;f.length>0;){const m=g.exec(f);if(!m){f===".."?u.push(".."):f==="."?u.push("."):f.length>0&&u.push(f);break}const w=m.index,$=m[0],A=$.length,T=f.slice(0,w),$t=f.slice(w+A);if($.startsWith("../"))u.push(".."),f=f.slice(w+3);else if($.startsWith("./"))u.push("."),f=f.slice(w+2);else if(w===0&&$==="..")u.push(".."),f=f.slice(2);else if(w===0&&$===".")u.push("."),f=f.slice(1);else{T.length>0&&u.push(T);let x=0;for(;(x=$.indexOf("../",x))!==-1;)u.push(".."),x+=3;for(x=0;(x=$.indexOf("./",x))!==-1;)(x===0||$[x-1]!==".")&&u.push("."),x+=2;let C=$t;for(;C.startsWith("../");)u.push(".."),C=C.slice(3);for(;C.startsWith("./");)u.push("."),C=C.slice(2);if(C===".."){u.push("..");break}else if(C==="."){u.push(".");break}else f=C}g.lastIndex=0}if(u.length===0){const m=d.split(c).filter(Boolean);u.push(...m)}let y=[];for(const m of u)s||n?y.push(...Ht(m,o,p)):o?y.push(...at(m,o,p)):y.push(...lt(m,p));return a&&(y=y.map(m=>p.has(m)?m:o&&m===m.toLocaleUpperCase(o)?m[0]+m.slice(1).toLocaleLowerCase(o):m.toUpperCase()===m&&!p.has(m)?m.slice(0,1)+m.slice(1).toLowerCase():m)),y},q=(t,e)=>typeof t!="string"||t===""?"":(e?.locale?t[0].toLocaleUpperCase(e.locale):t[0].toUpperCase())+t.slice(1),Xt=(t,e)=>`${t}::${e?.joiner??""}::${e?.locale??""}::${e?.knownAcronyms?.join(",")??""}::${e?.normalize?"true":"false"}::${e?.stripAnsi?"true":"false"}::${e?.stripEmoji?"true":"false"}::${e?.handleAnsi?"true":"false"}::${e?.handleEmoji?"true":"false"}`,z=(t,e)=>{const{length:s}=t;if(s===0)return"";if(s===1)return t[0];const n=[];let r="",o="";for(let a=0;a<s;a++){const l=t[a];if(U.test(l)){r?(n.push(r+o+l),r="",o=""):(n.length>0&&n.push(e),r=l);continue}r?(o&&(o+=e),o+=l):(n.length>0&&n.push(e),n.push(l))}return n.join("")},te=/(?<![a-zß])SS(?![a-z])/g,ee=t=>t.replaceAll(te,"ß"),ne=(t,e)=>{if(typeof t!="string"||!t)return"";let s=!0;return z(R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(r=>{const o=r,a=o.toLowerCase();return s?(s=!1,Gt(a)):q(a,e)}),"")},se=new I(1e3),G=(t,e)=>{if(typeof t!="string")return"";const s=e?.cache??!1,n=e?.cacheStore??se;let r;if(s&&(r=Xt(t,e)),s&&r&&n.has(r))return n.get(r);const o=R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(l=>{if(e?.handleAnsi&&U.test(l))return l;if(e?.toUpperCase)return e.locale?l.toLocaleUpperCase(e.locale):l.toUpperCase();const h=e?.locale?.startsWith("de")?ee(l):l;return e?.locale?h.toLocaleLowerCase(e.locale):h.toLowerCase()}),a=z(o,e?.joiner??"-");return s&&r&&n.set(r,a),a},re=new I(1e3),oe=(t,e)=>G(t,{cacheStore:re,...e,joiner:"_",toUpperCase:!0}),ie=(t,e)=>typeof t!="string"||!t?"":z(R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(n=>q(n.toLowerCase(),{locale:e?.locale})),""),le=new I(1e3),ae=(t,e)=>G(t,{cacheStore:le,...e,joiner:"_"}),ce=(t,e)=>typeof t!="string"?"":z(R(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(n=>q(n,{locale:e?.locale})),"-"),b=t=>t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):JSON.stringify(t),H={camel_case:t=>ne(b(t)),kebab_case:t=>G(b(t)),lower_case:t=>b(t).toLowerCase(),pascal_case:t=>ie(b(t)),path_join:(t,...e)=>{const s=[b(t),...e.map(n=>b(n))];return st(...s)},path_relative:(t,e)=>nt(b(e),b(t)),snake_case:t=>ae(b(t)),upper_case:t=>b(t).toUpperCase(),upper_kebab_case:t=>ce(b(t)),upper_snake_case:t=>oe(b(t))},ct=(t,e,s=[])=>{const n=H[t];if(!n)throw new Error(`Unknown filter "${t}". Known filters: ${Object.keys(H).sort().join(", ")}.`);return n(e,...s)},ft=t=>{const e=[];let s=0,n=0,r,o=-1;for(const a of t){if(o+=1,r){a===r&&(r=void 0);continue}if(a==='"'||a==="'"){r=a;continue}a==="("?s+=1:a===")"?s-=1:a===","&&s===0&&(e.push(t.slice(n,o)),n=o+1)}return e.push(t.slice(n)),e},fe=t=>{if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1)},ue=/\[([^\]]+)\]/g,pe=t=>{const e=t.trim(),s=e.indexOf("(");if(s===-1)return{args:[],name:e};if(!e.endsWith(")"))throw new Error(`Filter call "${t}" missing closing ")"`);const n=e.slice(0,s).trim(),r=e.slice(s+1,-1).trim();return r===""?{args:[],name:n}:{args:ft(r).map(a=>{const l=a.trim();return fe(l)??l}),name:n}},he=t=>{const e=t.split("|").map(r=>r.trim()),s=e[0]??"";if(!s)throw new Error(`Empty variable name in expression "${t}"`);return{filters:e.slice(1).map(r=>pe(r)),name:s}},de=t=>t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):JSON.stringify(t),me=(t,e)=>{const s=t.replaceAll(ue,(n,r)=>{const{filters:o,name:a}=he(r);if(!Object.hasOwn(e,a))throw new Error(`Variable "${a}" used in filename "${t}" but not defined`);let l=e[a];for(const h of o)l=ct(h.name,l,h.args);return de(l)});return ut(s)},ut=t=>t.split("/").map(e=>e.endsWith(".tera")||e.endsWith(".twig")?e.slice(0,-5):e).join("/"),ge=t=>t.endsWith(".raw")?t.slice(0,-4):t,ye=t=>{const e=t.split("/");return(e.at(-1)??"").startsWith("_")?!0:e.slice(0,-1).includes("partials")},k="---",we=(t,e)=>{if(!t.startsWith(`${k}
2
2
  `)&&!t.startsWith(`${k}\r
3
3
  `))return{body:t};const s=t.indexOf(`
4
4
  ${k}`,k.length);if(s===-1)return{body:t};let n=s+1+k.length;t[n]==="\r"&&(n+=1),t[n]===`
5
5
  `&&(n+=1);const r=t.startsWith(`${k}\r
6
6
  `)?k.length+2:k.length+1,o=t.slice(r,s).replaceAll("\r","");let a;try{a=e(o)}catch(l){const h=l instanceof Error?l.message:String(l);throw new Error(`Failed to parse frontmatter YAML: ${h}`,{cause:l})}if(a==null)return{body:t.slice(n)};if(typeof a!="object"||Array.isArray(a))throw new TypeError(`Frontmatter must be a YAML mapping, got ${Array.isArray(a)?"array":typeof a}`);return{body:t.slice(n),frontmatter:a}},$e=/\{\{-?(.+?)-?\}\}|\{%-?(.+?)-?%\}/gs,pt=t=>{const e=[];let s=0,n=1;const r=o=>{for(const a of o)a===`
7
- `&&(n+=1)};for(const o of t.matchAll($e)){const a=o.index??0;if(a>s){const i=t.slice(s,a);e.push({line:n,type:"text",value:i}),r(i)}const l=n,h=o[0];h.startsWith("{{")?e.push({line:l,type:"expr",value:(o[1]??"").trim()}):e.push({line:l,type:"stmt",value:(o[2]??"").trim()}),r(h),s=a+h.length}if(s<t.length){const o=t.slice(s);e.push({line:n,type:"text",value:o})}return e},Ae=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),ht=(t,e)=>{let s=0;const n=(o,a)=>{throw new Error(`${e}:${o}: ${a}`)},r=o=>{const a=[];for(;s<t.length;){const l=t[s];if(l.type==="text"){a.push({type:"text",value:l.value}),s+=1;continue}if(l.type==="expr"){a.push({expression:l.value,line:l.line,type:"expr"}),s+=1;continue}const h=l.value.split(/\s+/)[0]??"";if(o.includes(h))return a;if(Ae.has(h)&&n(l.line,`Tera feature "{% ${h} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),h==="if"){s+=1;const i=l.value.slice(2).trim(),p=r(["else","endif"]);let d;s<t.length&&t[s].type==="stmt"&&t[s].value.split(/\s+/)[0]==="else"&&(s+=1,d=r(["endif"])),(s>=t.length||t[s].type!=="stmt"||t[s].value.split(/\s+/)[0]!=="endif")&&n(l.line,"Unterminated {% if %} — missing {% endif %}"),s+=1,a.push({alternate:d,condition:i,consequent:p,line:l.line,type:"if"});continue}if(h==="for"){s+=1;const i=l.value.slice(3).trim(),p=i.indexOf(" in ");p===-1&&n(l.line,"Malformed {% for %} — expected `for <name> in <collection>`");const d=i.slice(0,p).trim(),c=i.slice(p+4).trim();(!d||!c)&&n(l.line,"Malformed {% for %} — missing binding or collection");const u=r(["endfor"]);(s>=t.length||t[s].type!=="stmt"||t[s].value.split(/\s+/)[0]!=="endfor")&&n(l.line,"Unterminated {% for %} — missing {% endfor %}"),s+=1,a.push({binding:d,body:u,collection:c,line:l.line,type:"for"});continue}if(h==="include"){s+=1;const i=l.value.slice(7).trim(),p=dt(i);p===void 0&&n(l.line,"Malformed {% include %} — expected a quoted partial name"),a.push({line:l.line,name:p,type:"include"});continue}n(l.line,`Unknown tag "{% ${h} %}". Supported: if, for, include.`)}return a};return r([])},dt=t=>{if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1)},Ee=t=>t==null?"":typeof t=="boolean"||typeof t=="number"?String(t):typeof t=="string"?t:JSON.stringify(t),be=t=>t==null||t===!1||t===0||t===""?!1:Array.isArray(t)?t.length>0:!0,mt=(t,e,s,n,r=!0)=>{const o=t.split(".");if(r&&o.length>0&&!Object.hasOwn(e,o[0]))throw new Error(`${n}:${s}: Variable "${t}" is not defined`);let a=e;for(const l of o){if(a==null)return;if(typeof a!="object")throw new TypeError(`${n}:${s}: Cannot read "${l}" on non-object value`);a=a[l]}return a},xe=t=>{const e=[];let s=0,n=0,r;for(let o=0;o<t.length;o+=1){const a=t[o];if(r){a===r&&(r=void 0);continue}if(a==='"'||a==="'"){r=a;continue}a==="("?s+=1:a===")"?s-=1:a==="|"&&s===0&&(e.push(t.slice(n,o)),n=o+1)}return e.push(t.slice(n)),e},Ce=t=>{const e=t.trim(),s=e.indexOf("(");if(s===-1)return{args:[],name:e};if(!e.endsWith(")"))throw new Error(`Filter call "${t}" missing closing ")"`);const n=e.slice(0,s).trim(),r=e.slice(s+1,-1).trim();return r?{args:ft(r).map(o=>o.trim()),name:n}:{args:[],name:n}},_=(t,e,s,n,r=!0)=>{const o=t.trim();if(o==="true")return!0;if(o==="false")return!1;if(o==="null"||o==="none")return null;const a=dt(o);return a!==void 0?a:/^-?\d+(?:\.\d+)?$/.test(o)?Number(o):mt(o,e,s,n,r)},gt=(t,e,s,n,r=!0)=>{const o=xe(t),a=o[0].trim();let l=_(a,e,s,n,r);for(let h=1;h<o.length;h+=1){const i=o[h].trim(),{args:p,name:d}=Ce(i),c=p.map(u=>_(u,e,s,n,r));try{l=ct(d,l,c)}catch(u){const f=u instanceof Error?u.message:String(u);throw new Error(`${n}:${s}: ${f}`,{cause:u})}}return l},yt=(t,e)=>{let s,n=0;for(let r=0;r<=t.length-e.length;r+=1){const o=t[r];if(s){o===s&&(s=void 0);continue}if(o==='"'||o==="'"){s=o;continue}if(o==="("){n+=1;continue}if(o===")"){n-=1;continue}if(n===0&&t.slice(r,r+e.length)===e)return r}return-1},X=(t,e)=>{const s=[];let n=0,r=0;for(;r<=t.length-e.length;){const o=yt(t.slice(r),e);if(o===-1)break;s.push(t.slice(n,r+o)),r+=o+e.length,n=r}return s.push(t.slice(n)),s},U=(t,e,s,n)=>{const r=t.trim();if(r==="")return!1;if(r.startsWith("(")&&r.endsWith(")")&&je(r)===r.length-1)return U(r.slice(1,-1),e,s,n);const o=X(r," or ");if(o.length>1)return o.some(l=>U(l,e,s,n));const a=X(r," and ");if(a.length>1)return a.every(l=>U(l,e,s,n));if(r.startsWith("not "))return!U(r.slice(4),e,s,n);for(const l of["==","!="]){const h=yt(r,l);if(h!==-1){const i=_(r.slice(0,h),e,n,s,!1),p=_(r.slice(h+l.length),e,n,s,!1),d=i===p;return l==="=="?d:!d}}return be(gt(r,e,n,s,!1))},je=t=>{if(t[0]!=="(")return-1;let e=0,s,n=-1;for(const r of t){if(n+=1,s){r===s&&(s=void 0);continue}if(r==='"'||r==="'"){s=r;continue}if(r==="(")e+=1;else if(r===")"&&(e-=1,e===0))return n}return-1},P=(t,e)=>{let s="";for(const n of t){if(n.type==="text"){s+=n.value;continue}if(n.type==="expr"){s+=Ee(gt(n.expression,e.scope,n.line,e.filename));continue}if(n.type==="if"){const r=U(n.condition,e.scope,e.filename,n.line)?n.consequent:n.alternate??[];s+=P(r,e);continue}if(n.type==="for"){const r=mt(n.collection,e.scope,n.line,e.filename,!1);if(r==null)continue;if(!Array.isArray(r))throw new TypeError(`${e.filename}:${n.line}: {% for %} expected an array, got ${typeof r}`);for(const o of r){const a={...e.scope,[n.binding]:o};s+=P(n.body,{...e,scope:a})}continue}if(n.type==="include"){const r=e.partials?.get(n.name);if(!r)throw new Error(`${e.filename}:${n.line}: Partial "${n.name}" not found. Available: ${[...e.partials?.keys()??[]].join(", ")||"(none)"}`);const o=e.includeStack??new Set;if(o.has(n.name)){const a=[...o,n.name].join(" → ");throw new Error(`${e.filename}:${n.line}: Circular partial include detected: ${a}`)}o.add(n.name);try{s+=P(r,{...e,filename:`<partial:${n.name}>`,includeStack:o})}finally{o.delete(n.name)}}}return s},ke=(t,e)=>ht(pt(t),e),B=(t,e)=>P(ht(pt(t),e.filename),e),tt="template.yml",Le=".raw",We=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),Ue=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),Se=t=>{const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),s=e===-1?t:t.slice(e+1),n=s.lastIndexOf(".");return n===-1||n===0?"":s.slice(n).toLowerCase()},wt=t=>{const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e===-1?t:t.slice(e+1)},Te=t=>{const e=Se(t);if(e!=="")return We.has(e);const s=wt(t);return Ue.has(s)},Oe=t=>{const e={default:t.default,internal:t.internal,order:t.order,prompt:t.prompt,required:t.required};switch(t.type){case"array":return{...e,type:"array"};case"boolean":return{...e,default:typeof e.default=="boolean"?e.default:void 0,type:"boolean"};case"enum":return{...e,multiple:t.multiple,type:"enum",values:t.values??[]};case"number":return{...e,type:"number"};case"string":return{...e,type:"string"};default:throw new Error(`Unsupported variable type "${String(t.type)}"`)}},Pe=t=>t.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),_e=(t,e,s)=>{const n=e.split("/").filter(Boolean);if(n.length===0)throw new Error("Empty destination path for value");let r=t;for(let o=0;o<n.length-1;o+=1){const a=n[o],l=r[a];if(l===void 0){const h={};r[a]=h,r=h}else if(typeof l=="object"&&!Buffer.isBuffer(l))r=l;else throw new TypeError(`Path conflict: "${n.slice(0,o+1).join("/")}" is both a file and a directory`)}r[n.at(-1)]=s},et=(t,e,s)=>{if(typeof t!="string")return Ie(t);const n=t.includes("{{")||t.includes("{%")?B(t,{filename:`${s}#frontmatter`,scope:e}):t;return U(n,e,`${s}#frontmatter`,1)},Ie=t=>t==null||t===!1||t===0||t===""?!1:Array.isArray(t)?t.length>0:typeof t=="string"?t!=="false"&&t!=="0":!0,Be=(t,e)=>{const s=st(t,tt),n=At(s);if(!n||typeof n!="object")throw new Error(`${s}: must contain a YAML mapping`);const r={};if(n.variables)for(const[h,i]of Object.entries(n.variables))r[h]=Oe(i);const o=new Map,a=[];for(const h of qt(t,{includeDirs:!1,includeSymlinks:!1})){if(h.path===s)continue;const i=nt(t,h.path).replaceAll("\\","/");if(i===tt)continue;if(ye(i)){const c=O(h.path),u=ke(c,i);for(const f of Re(i))o.has(f)&&o.get(f)!==u&&bt.warn(`partial name "${f}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),o.set(f,u);continue}if(i.endsWith(Le)){const c=O(h.path);a.push({binary:null,isRaw:!0,rawText:c,relativePath:i});continue}if(Te(i)){const c=O(h.path);a.push({binary:null,isRaw:!1,rawText:c,relativePath:i});continue}const d=O(h.path,{buffer:!0});a.push({binary:d,isRaw:!1,rawText:null,relativePath:i})}const l=h=>{const i={...h.builtins,...h.options},p={},d={};for(const u of a){const f=u.relativePath;let g,y,m=!1;if(u.binary)g=u.binary;else if(u.isRaw)g=u.rawText??"";else{const $=u.rawText??"",A=we($,T=>Et(T));if(A.frontmatter){if(A.frontmatter.skip!==void 0&&et(A.frontmatter.skip,i,f)||A.frontmatter.if!==void 0&&!et(A.frontmatter.if,i,f))continue;typeof A.frontmatter.to=="string"&&(y=B(A.frontmatter.to,{filename:`${f}#frontmatter.to`,partials:o,scope:i})),A.frontmatter.force===!0&&(m=!0)}g=B(A.body,{filename:f,partials:o,scope:i})}const w=Pe(y??me(ge(f),i));_e(p,w,g),m&&(d[w]={force:!0})}const c={files:p};return Object.keys(d).length>0&&(c.filesMeta=d),c};return{about:{description:n.description??`Moon-format template at ${t}`,name:n.title??e},destination:n.destination,options:r,produce:l}},Re=t=>{const e=ut(t),s=wt(e),n=new Set([s,e]);if(s.startsWith("_")){n.add(s.replace(/^_+/,""));const r=e.slice(0,e.length-s.length);n.add(`${r}${s.replace(/^_+/,"")}`)}return[...n]};export{Be as loadMoonTemplate};
7
+ `&&(n+=1)};for(const o of t.matchAll($e)){const a=o.index??0;if(a>s){const i=t.slice(s,a);e.push({line:n,type:"text",value:i}),r(i)}const l=n,h=o[0];h.startsWith("{{")?e.push({line:l,type:"expr",value:(o[1]??"").trim()}):e.push({line:l,type:"stmt",value:(o[2]??"").trim()}),r(h),s=a+h.length}if(s<t.length){const o=t.slice(s);e.push({line:n,type:"text",value:o})}return e},Ae=new Set(["block","endblock","endfilter","endmacro","extends","filter","import","macro","set"]),ht=(t,e)=>{let s=0;const n=(o,a)=>{throw new Error(`${e}:${o}: ${a}`)},r=o=>{const a=[];for(;s<t.length;){const l=t[s];if(l.type==="text"){a.push({type:"text",value:l.value}),s+=1;continue}if(l.type==="expr"){a.push({expression:l.value,line:l.line,type:"expr"}),s+=1;continue}const h=l.value.split(/\s+/)[0]??"";if(o.includes(h))return a;if(Ae.has(h)&&n(l.line,`Tera feature "{% ${h} %}" is not supported. Supported: if/else/endif, for/endfor, include. Rewrite the template to avoid macros, set, extends, block, and import.`),h==="if"){s+=1;const i=l.value.slice(2).trim(),p=r(["else","endif"]);let d;s<t.length&&t[s].type==="stmt"&&t[s].value.split(/\s+/)[0]==="else"&&(s+=1,d=r(["endif"])),(s>=t.length||t[s].type!=="stmt"||t[s].value.split(/\s+/)[0]!=="endif")&&n(l.line,"Unterminated {% if %} — missing {% endif %}"),s+=1,a.push({alternate:d,condition:i,consequent:p,line:l.line,type:"if"});continue}if(h==="for"){s+=1;const i=l.value.slice(3).trim(),p=i.indexOf(" in ");p===-1&&n(l.line,"Malformed {% for %} — expected `for <name> in <collection>`");const d=i.slice(0,p).trim(),c=i.slice(p+4).trim();(!d||!c)&&n(l.line,"Malformed {% for %} — missing binding or collection");const u=r(["endfor"]);(s>=t.length||t[s].type!=="stmt"||t[s].value.split(/\s+/)[0]!=="endfor")&&n(l.line,"Unterminated {% for %} — missing {% endfor %}"),s+=1,a.push({binding:d,body:u,collection:c,line:l.line,type:"for"});continue}if(h==="include"){s+=1;const i=l.value.slice(7).trim(),p=dt(i);p===void 0&&n(l.line,"Malformed {% include %} — expected a quoted partial name"),a.push({line:l.line,name:p,type:"include"});continue}n(l.line,`Unknown tag "{% ${h} %}". Supported: if, for, include.`)}return a};return r([])},dt=t=>{if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1)},Ee=t=>t==null?"":typeof t=="boolean"||typeof t=="number"?String(t):typeof t=="string"?t:JSON.stringify(t),be=t=>t==null||t===!1||t===0||t===""?!1:Array.isArray(t)?t.length>0:!0,mt=(t,e,s,n,r=!0)=>{const o=t.split(".");if(r&&o.length>0&&!Object.hasOwn(e,o[0]))throw new Error(`${n}:${s}: Variable "${t}" is not defined`);let a=e;for(const l of o){if(a==null)return;if(typeof a!="object")throw new TypeError(`${n}:${s}: Cannot read "${l}" on non-object value`);a=a[l]}return a},xe=t=>{const e=[];let s=0,n=0,r;for(let o=0;o<t.length;o+=1){const a=t[o];if(r){a===r&&(r=void 0);continue}if(a==='"'||a==="'"){r=a;continue}a==="("?s+=1:a===")"?s-=1:a==="|"&&s===0&&(e.push(t.slice(n,o)),n=o+1)}return e.push(t.slice(n)),e},Ce=t=>{const e=t.trim(),s=e.indexOf("(");if(s===-1)return{args:[],name:e};if(!e.endsWith(")"))throw new Error(`Filter call "${t}" missing closing ")"`);const n=e.slice(0,s).trim(),r=e.slice(s+1,-1).trim();return r?{args:ft(r).map(o=>o.trim()),name:n}:{args:[],name:n}},_=(t,e,s,n,r=!0)=>{const o=t.trim();if(o==="true")return!0;if(o==="false")return!1;if(o==="null"||o==="none")return null;const a=dt(o);return a!==void 0?a:/^-?\d+(?:\.\d+)?$/.test(o)?Number(o):mt(o,e,s,n,r)},gt=(t,e,s,n,r=!0)=>{const o=xe(t),a=o[0].trim();let l=_(a,e,s,n,r);for(let h=1;h<o.length;h+=1){const i=o[h].trim(),{args:p,name:d}=Ce(i),c=p.map(u=>_(u,e,s,n,r));try{l=ct(d,l,c)}catch(u){const f=u instanceof Error?u.message:String(u);throw new Error(`${n}:${s}: ${f}`,{cause:u})}}return l},yt=(t,e)=>{let s,n=0;for(let r=0;r<=t.length-e.length;r+=1){const o=t[r];if(s){o===s&&(s=void 0);continue}if(o==='"'||o==="'"){s=o;continue}if(o==="("){n+=1;continue}if(o===")"){n-=1;continue}if(n===0&&t.slice(r,r+e.length)===e)return r}return-1},X=(t,e)=>{const s=[];let n=0,r=0;for(;r<=t.length-e.length;){const o=yt(t.slice(r),e);if(o===-1)break;s.push(t.slice(n,r+o)),r+=o+e.length,n=r}return s.push(t.slice(n)),s},S=(t,e,s,n)=>{const r=t.trim();if(r==="")return!1;if(r.startsWith("(")&&r.endsWith(")")&&je(r)===r.length-1)return S(r.slice(1,-1),e,s,n);const o=X(r," or ");if(o.length>1)return o.some(l=>S(l,e,s,n));const a=X(r," and ");if(a.length>1)return a.every(l=>S(l,e,s,n));if(r.startsWith("not "))return!S(r.slice(4),e,s,n);for(const l of["==","!="]){const h=yt(r,l);if(h!==-1){const i=_(r.slice(0,h),e,n,s,!1),p=_(r.slice(h+l.length),e,n,s,!1),d=i===p;return l==="=="?d:!d}}return be(gt(r,e,n,s,!1))},je=t=>{if(t[0]!=="(")return-1;let e=0,s,n=-1;for(const r of t){if(n+=1,s){r===s&&(s=void 0);continue}if(r==='"'||r==="'"){s=r;continue}if(r==="(")e+=1;else if(r===")"&&(e-=1,e===0))return n}return-1},P=(t,e)=>{let s="";for(const n of t){if(n.type==="text"){s+=n.value;continue}if(n.type==="expr"){s+=Ee(gt(n.expression,e.scope,n.line,e.filename));continue}if(n.type==="if"){const r=S(n.condition,e.scope,e.filename,n.line)?n.consequent:n.alternate??[];s+=P(r,e);continue}if(n.type==="for"){const r=mt(n.collection,e.scope,n.line,e.filename,!1);if(r==null)continue;if(!Array.isArray(r))throw new TypeError(`${e.filename}:${n.line}: {% for %} expected an array, got ${typeof r}`);for(const o of r){const a={...e.scope,[n.binding]:o};s+=P(n.body,{...e,scope:a})}continue}if(n.type==="include"){const r=e.partials?.get(n.name);if(!r)throw new Error(`${e.filename}:${n.line}: Partial "${n.name}" not found. Available: ${[...e.partials?.keys()??[]].join(", ")||"(none)"}`);const o=e.includeStack??new Set;if(o.has(n.name)){const a=[...o,n.name].join(" → ");throw new Error(`${e.filename}:${n.line}: Circular partial include detected: ${a}`)}o.add(n.name);try{s+=P(r,{...e,filename:`<partial:${n.name}>`,includeStack:o})}finally{o.delete(n.name)}}}return s},ke=(t,e)=>ht(pt(t),e),B=(t,e)=>P(ht(pt(t),e.filename),e),tt="template.yml",Le=".raw",We=new Set([".cjs",".css",".env",".gitattributes",".gitignore",".graphql",".html",".ini",".js",".json",".json5",".jsonc",".jsx",".lock",".md",".mdx",".mjs",".prettierrc",".raw",".rs",".scss",".sh",".sql",".svg",".tera",".toml",".ts",".tsx",".twig",".txt",".vue",".xml",".yaml",".yml"]),Se=new Set(["Brewfile","CHANGELOG","CODEOWNERS","CONTRIBUTING","COPYING","Dockerfile","Gemfile","LICENCE","LICENSE","Makefile","NOTICE","Procfile","Rakefile","README","VERSION"]),Ue=t=>{const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\")),s=e===-1?t:t.slice(e+1),n=s.lastIndexOf(".");return n===-1||n===0?"":s.slice(n).toLowerCase()},wt=t=>{const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e===-1?t:t.slice(e+1)},Te=t=>{const e=Ue(t);if(e!=="")return We.has(e);const s=wt(t);return Se.has(s)},Oe=t=>{const e={default:t.default,internal:t.internal,order:t.order,prompt:t.prompt,required:t.required};switch(t.type){case"array":return{...e,type:"array"};case"boolean":return{...e,default:typeof e.default=="boolean"?e.default:void 0,type:"boolean"};case"enum":return{...e,multiple:t.multiple,type:"enum",values:t.values??[]};case"number":return{...e,type:"number"};case"string":return{...e,type:"string"};default:throw new Error(`Unsupported variable type "${String(t.type)}"`)}},Pe=t=>t.replaceAll("\\","/").replace(/^\.\//,"").replaceAll(/\/+/g,"/"),_e=(t,e,s)=>{const n=e.split("/").filter(Boolean);if(n.length===0)throw new Error("Empty destination path for value");let r=t;for(let o=0;o<n.length-1;o+=1){const a=n[o],l=r[a];if(l===void 0){const h={};r[a]=h,r=h}else if(typeof l=="object"&&!Buffer.isBuffer(l))r=l;else throw new TypeError(`Path conflict: "${n.slice(0,o+1).join("/")}" is both a file and a directory`)}r[n.at(-1)]=s},et=(t,e,s)=>{if(typeof t!="string")return Ie(t);const n=t.includes("{{")||t.includes("{%")?B(t,{filename:`${s}#frontmatter`,scope:e}):t;return S(n,e,`${s}#frontmatter`,1)},Ie=t=>t==null||t===!1||t===0||t===""?!1:Array.isArray(t)?t.length>0:typeof t=="string"?t!=="false"&&t!=="0":!0,qe=(t,e)=>{const s=st(t,tt),n=At(s);if(!n||typeof n!="object")throw new Error(`${s}: must contain a YAML mapping`);const r={};if(n.variables)for(const[h,i]of Object.entries(n.variables))r[h]=Oe(i);const o=new Map,a=[];for(const h of qt(t,{includeDirs:!1,includeSymlinks:!1})){if(h.path===s)continue;const i=nt(t,h.path).replaceAll("\\","/");if(i===tt)continue;if(ye(i)){const c=O(h.path),u=ke(c,i);for(const f of Re(i))o.has(f)&&o.get(f)!==u&&bt.warn(`partial name "${f}" is declared by multiple files — last one wins. Use distinct names or fully-qualified includes.`),o.set(f,u);continue}if(i.endsWith(Le)){const c=O(h.path);a.push({binary:null,isRaw:!0,rawText:c,relativePath:i});continue}if(Te(i)){const c=O(h.path);a.push({binary:null,isRaw:!1,rawText:c,relativePath:i});continue}const d=O(h.path,{buffer:!0});a.push({binary:d,isRaw:!1,rawText:null,relativePath:i})}const l=h=>{const i={...h.builtins,...h.options},p={},d={};for(const u of a){const f=u.relativePath;let g,y,m=!1;if(u.binary)g=u.binary;else if(u.isRaw)g=u.rawText??"";else{const $=u.rawText??"",A=we($,T=>Et(T));if(A.frontmatter){if(A.frontmatter.skip!==void 0&&et(A.frontmatter.skip,i,f)||A.frontmatter.if!==void 0&&!et(A.frontmatter.if,i,f))continue;typeof A.frontmatter.to=="string"&&(y=B(A.frontmatter.to,{filename:`${f}#frontmatter.to`,partials:o,scope:i})),A.frontmatter.force===!0&&(m=!0)}g=B(A.body,{filename:f,partials:o,scope:i})}const w=Pe(y??me(ge(f),i));_e(p,w,g),m&&(d[w]={force:!0})}const c={files:p};return Object.keys(d).length>0&&(c.filesMeta=d),c};return{about:{description:n.description??`Moon-format template at ${t}`,name:n.title??e},destination:n.destination,options:r,produce:l}},Re=t=>{const e=ut(t),s=wt(e),n=new Set([s,e]);if(s.startsWith("_")){n.add(s.replace(/^_+/,""));const r=e.slice(0,e.length-s.length);n.add(`${r}${s.replace(/^_+/,"")}`)}return[...n]};export{qe as loadMoonTemplate};
@@ -24,7 +24,12 @@
24
24
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25
25
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
26
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
- */let O=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;class m extends Date{#r=!1;#t=!1;#e=null;constructor(i){let r=!0,t=!0,l="Z";if(typeof i=="string"){let n=i.match(O);n?(n[1]||(r=!1,i=`0000-01-01T${i}`),t=!!n[2],t&&i[10]===" "&&(i=i.replace(" ","T")),n[2]&&+n[2]>23?i="":(l=n[3]||null,i=i.toUpperCase(),!l&&t&&(i+="Z"))):i=""}super(i),isNaN(this.getTime())||(this.#r=r,this.#t=t,this.#e=l)}isDateTime(){return this.#r&&this.#t}isLocal(){return!this.#r||!this.#t||!this.#e}isDate(){return this.#r&&!this.#t}isTime(){return this.#t&&!this.#r}isValid(){return this.#r||this.#t}toISOString(){let i=super.toISOString();if(this.isDate())return i.slice(0,10);if(this.isTime())return i.slice(11,23);if(this.#e===null)return i.slice(0,-1);if(this.#e==="Z")return i;let r=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return r=this.#e[0]==="-"?r:-r,new Date(this.getTime()-r*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(i,r="Z"){let t=new m(i);return t.#e=r,t}static wrapAsLocalDateTime(i){let r=new m(i);return r.#e=null,r}static wrapAsLocalDate(i){let r=new m(i);return r.#t=!1,r.#e=null,r}static wrapAsLocalTime(i){let r=new m(i);return r.#r=!1,r.#e=null,r}}/*!
27
+ */function B(e,l){let i=e.slice(0,l).split(/\r?\n/);return[i.length,i.pop().length+1]}function L(e,l,i){let n=e.split(/\r?\n/),a="",s=(Math.log10(l+1)|0)+1;for(let r=l-1;r<=l+1;r++){let f=n[r-1];f&&(a+=r.toString().padEnd(s," "),a+=": ",a+=f,a+=`
28
+ `,r===l&&(a+=" ".repeat(s+i+2),a+=`^
29
+ `))}return a}class u extends Error{line;column;codeblock;constructor(l,i){const[n,a]=B(i.toml,i.ptr),s=L(i.toml,n,a);super(`Invalid TOML document: ${l}
30
+
31
+ ${s}`,i),this.line=n,this.column=a,this.codeblock=s}static x(l,i,n){throw new u(l,{toml:i.s,ptr:n??i.p})}}function I(e){let l=e.p,i=e.s.charCodeAt(e.p++),n=i,a=i===39,s=i===e.s.charCodeAt(e.p)&&i===e.s.charCodeAt(e.p+1);s&&((i=e.s.charCodeAt(e.p+=2))===10?e.p++:i===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let r="",f=e.p,t=0;for(;e.p<e.s.length;e.p++)if(i=e.s.charCodeAt(e.p),s&&(i===10||i===13&&e.s.charCodeAt(e.p+1)===10))t=t&&3;else if(i<32&&i!==9||i===127)u.x("control characters are not allowed in strings",e);else if((!t||t===3)&&i===n&&(!s||e.s.charCodeAt(e.p+1)===n&&e.s.charCodeAt(e.p+2)===n)){if(s&&(e.s.charCodeAt(e.p+3)===n&&e.p++,e.s.charCodeAt(e.p+3)===n&&e.p++),!t){let o=e.s.slice(f,e.p);r=r?r+o:o}return e.p+=s?3:1,r}else if(!t)!a&&i===92&&(r+=e.s.slice(f,f=e.p),t=1);else if(t===1)if(i===120||i===117||i===85){let o=e.p++-1,p=0,d=i===120?2:i===117?4:8;for(let m=0;m<d;m++,e.p++){let A=e.s.charCodeAt(e.p),y=A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1;y<0&&u.x("invalid non-hex character in unicode escape",e),p=p<<4|y}(p<0||p>1114111||p>=55296&&p<=57343)&&u.x("invalid unicode escape",e,o),r+=String.fromCodePoint(p),f=e.p--,t=0}else s&&(i===32||i===9)?t=2:(i===98?r+="\b":i===116?r+=" ":i===110?r+=`
32
+ `:i===102?r+="\f":i===114?r+="\r":i===101?r+="\x1B":i===34?r+='"':i===92?r+="\\":u.x("unrecognised escape sequence",e),f=e.p+1,t=0);else i!==32&&i!==9&&(t===2&&u.x("invalid escape: only line-ending whitespace may be escaped",e,f),t=!a&&i===92?1:0,f=e.p);u.x("unfinished string",e,l)}/*!
28
33
  * Copyright (c) Squirrel Chat et al., All rights reserved.
29
34
  * SPDX-License-Identifier: BSD-3-Clause
30
35
  *
@@ -50,10 +55,4 @@
50
55
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
51
56
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52
57
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53
- */function T(e,i){let r=e.slice(0,i).split(/\r\n|\n|\r/g);return[r.length,r.pop().length+1]}function E(e,i,r){let t=e.split(/\r\n|\n|\r/g),l="",n=(Math.log10(i+1)|0)+1;for(let s=i-1;s<=i+1;s++){let a=t[s-1];a&&(l+=s.toString().padEnd(n," "),l+=": ",l+=a,l+=`
54
- `,s===i&&(l+=" ".repeat(n+r+2),l+=`^
55
- `))}return l}class f extends Error{line;column;codeblock;constructor(i,r){const[t,l]=T(r.toml,r.ptr),n=E(r.toml,t,l);super(`Invalid TOML document: ${i}
56
-
57
- ${n}`,r),this.line=t,this.column=l,this.codeblock=n}}function k(e,i=0){let r=e.indexOf(`
58
- `,i);return e.charCodeAt(r-1)===13&&r--,r}function C(e){for(;e.p<e.s.length;e.p++){let i=e.s.charCodeAt(e.p);if(i===10)break;if(i===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}if(i<32&&i!==9||i===127)throw new f("control characters are not allowed in comments",{toml:e.s,ptr:e.p})}}function w(e,i,r){let t;for(;;){for(;(t=e.s.charCodeAt(e.p))===32||t===9||!i&&(t===10||t===13&&e.s.charCodeAt(e.p+1)===10);)e.p++;if(r||t!==35)break;C(e)}}function _(e,i,r){let t=e.p;if(!r){t=k(e.s,t),e.p=t<0?e.s.length:t;return}for(;e.p<e.s.length;e.p++){let l=e.s.charCodeAt(e.p);if(l===35)C(e);else if(l===r||l===i)return}throw new f("cannot find end of structure",{toml:e.s,ptr:t})}let S=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,D=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,L=/^[+-]?0[0-9_]/;function y(e){let i=e.p,r=e.s.charCodeAt(e.p++),t=r,l=r===39,n=r===e.s.charCodeAt(e.p)&&r===e.s.charCodeAt(e.p+1);n&&((r=e.s.charCodeAt(e.p+=2))===10?e.p++:r===13&&e.s.charCodeAt(e.p+1)===10&&(e.p+=2));let s="",a=e.p,o=0;for(;e.p<e.s.length;e.p++)if(r=e.s.charCodeAt(e.p),n&&(r===10||r===13&&e.s.charCodeAt(e.p+1)===10))o=o&&3;else{if(r<32&&r!==9||r===127)throw new f("control characters are not allowed in strings",{toml:e.s,ptr:e.p});if((!o||o===3)&&r===t&&(!n||e.s.charCodeAt(e.p+1)===t&&e.s.charCodeAt(e.p+2)===t))return n&&(e.s.charCodeAt(e.p+3)===t&&e.p++,e.s.charCodeAt(e.p+3)===t&&e.p++),o||(s+=e.s.slice(a,e.p)),e.p+=n?3:1,s;if(!o)!l&&r===92&&(s+=e.s.slice(a,a=e.p),o=1);else if(o===1)if(r===120||r===117||r===85){let p=0,d=r===120?2:r===117?4:8;for(let u=0;u<d;u++,e.p++){let h=e.s.charCodeAt(e.p+1),g=h>=48&&h<=57?h-48:h>=65&&h<=70?h-65+10:h>=97&&h<=102?h-97+10:-1;if(g<0)throw new f("invalid non-hex character in unicode escape",{toml:e.s,ptr:e.p+1});p=p<<4|g}if(p<0||p>1114111||p>=55296&&p<=57343)throw new f("invalid unicode escape",{toml:e.s,ptr:e.p});s+=String.fromCodePoint(p),a=e.p+1,o=0}else if(r===32||r===9)o=2;else{if(r===98)s+="\b";else if(r===116)s+=" ";else if(r===110)s+=`
59
- `;else if(r===102)s+="\f";else if(r===114)s+="\r";else if(r===101)s+="\x1B";else if(r===34)s+='"';else if(r===92)s+="\\";else throw new f("unrecognized escape sequence",{toml:e.s,ptr:e.p});a=e.p+1,o=0}else if(r!==32&&r!==9){if(o===2)throw new f("invalid escape: only line-ending whitespace may be escaped",{toml:e.s,ptr:a});o=!l&&r===92?1:0,a=e.p}}throw new f("unfinished string",{toml:e.s,ptr:i})}function I(e,i,r){let t=e.s.slice(i,r),l=t.indexOf("#");return l>0&&(C({s:t,p:l}),t=t.slice(0,l)),t.trimEnd()}function N(e,i,r){let t=e.p,l={toml:e.s,ptr:t};_(e,44,r);let n=I(e,t,e.p);if(!n)throw new f("incomplete declaration: value expected",l);if(n==="-inf")return-1/0;if(n==="inf"||n==="+inf")return 1/0;if(n==="nan"||n==="+nan"||n==="-nan")return NaN;if(n==="-0")return i?0n:0;let s=S.test(n);if(s||D.test(n)){if(L.test(n))throw new f("leading zeroes are not allowed",l);n=n.replace(/_/g,"");let o=+n;if(isNaN(o))throw new f("invalid number",l);if(s){if((s=!Number.isSafeInteger(o))&&!i)throw new f("integer value cannot be represented losslessly",l);(s||i===!0)&&(o=BigInt(n))}return o}const a=new m(n);if(!a.isValid())throw new f("invalid value",l);return a}function b(e,i,r){let t=e.p,l=e.s.charCodeAt(t);if(l===91||l===123){if(!e.d--)throw new f("document contains excessively nested structures. aborting.",{toml:e.s,ptr:t});let n=l===91?P(e,r):j(e,r);return e.d++,n}if(l===34||l===39)return y(e);if(l===116){if(e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)throw new f("invalid value",{toml:e.s,ptr:t});return e.p++,!0}if(l===102){if(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)throw new f("invalid value",{toml:e.s,ptr:t});return e.p++,!1}return N(e,r,i)}let c=/^[a-zA-Z0-9-_]+[ \t]*$/;function A(e,i="="){let r=e.p,t=r-1,l=[],n=e.s.indexOf(i,r);if(n<0)throw new f("incomplete key-value: cannot find end of key",{toml:e.s,ptr:r});do{let s=e.s.charCodeAt(e.p=++t);if(s!==32&&s!==9)if(s===34||s===39){if(s===e.s.charCodeAt(e.p+1)&&s===e.s.charCodeAt(e.p+2))throw new f("multiline strings are not allowed in keys",{toml:e.s,ptr:e.p});let a=y(e);t=e.s.indexOf(".",e.p);let o=e.s.slice(e.p,t<0||t>n?n:t),p=k(o);if(p>-1)throw new f("newlines are not allowed in keys",{toml:e.s,ptr:p});if(o.trimStart())throw new f("found extra tokens after the string part",{toml:e.s,ptr:e.p});if(n<e.p&&(n=e.s.indexOf(i,e.p),n<0))throw new f("incomplete key-value: cannot find end of key",{toml:e.s,ptr:r});l.push(a)}else{t=e.s.indexOf(".",e.p);let a=e.s.slice(e.p,t<0||t>n?n:t);if(!c.test(a))throw new f("only letter, numbers, dashes and underscores are allowed in keys",{toml:e.s,ptr:e.p});l.push(a.trimEnd())}}while(t+1&&t<n);return e.p=n+1,w(e,!0,!0),l}function j(e,i){let r={},t=new Set,l;for(e.p++;e.p<e.s.length;){if(w(e),(l=e.s.charCodeAt(e.p))===125)return e.p++,r;let n,s=r,a=!1,o=e.p,p=A(e);for(let u=0;u<p.length;u++){if(u&&(s=a?s[n]:s[n]={}),n=p[u],(a=Object.hasOwn(s,n))&&(typeof s[n]!="object"||t.has(s[n])))throw new f("trying to redefine an already defined value",{toml:e.s,ptr:o});!a&&n==="__proto__"&&Object.defineProperty(s,n,{enumerable:!0,configurable:!0,writable:!0})}if(a)throw new f("trying to redefine an already defined value",{toml:e.s,ptr:e.p});let d=b(e,125,i);if(t.add(s[n]=d),w(e),(l=e.s.charCodeAt(e.p++))===125)return r;if(l!==44)throw new f("expected comma or end of structure",{toml:e.s,ptr:e.p-1})}throw new f("unfinished table encountered",{toml:e.s,ptr:e.p})}function P(e,i){let r=[],t;for(e.p++;e.p<e.s.length;){if(w(e),(t=e.s.charCodeAt(e.p))===93)return e.p++,r;if(r.push(b(e,93,i)),w(e),(t=e.s.charCodeAt(e.p++))===93)return r;if(t!==44)throw new f("expected comma or end of structure",{toml:e.s,ptr:e.p-1})}throw new f("unfinished array encountered",{toml:e.s,ptr:e.p})}function v(e,i,r,t){let l=i,n=r,s,a=!1,o;for(let p=0;p<e.length;p++){if(p){if(l=a?l[s]:l[s]={},n=(o=n[s]).c,t===0&&(o.t===1||o.t===2))return null;if(o.t===2){let d=l.length-1;l=l[d],n=n[d].c}}if(s=e[p],(a=Object.hasOwn(l,s))&&n[s]?.t===0&&n[s]?.d)return null;a||(s==="__proto__"&&(Object.defineProperty(l,s,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(n,s,{enumerable:!0,configurable:!0,writable:!0})),n[s]={t:p<e.length-1&&t===2?3:t,d:!1,i:0,c:{}})}if(o=n[s],o.t!==t&&!(t===1&&o.t===3)||(t===2&&(o.d||(o.d=!0,l[s]=[]),l[s].push(l={}),o.c[o.i++]=o={t:1,d:!1,i:0,c:{}}),o.d))return null;if(o.d=!0,t===1)l=a?l[s]:l[s]={};else if(t===0&&a)return null;return[s,l,o.c]}function Z(e,{maxDepth:i=1e3,integersAsBigInt:r}={}){let t={s:e,p:0,d:i},l={},n={},s,a=l,o=n;for(w(t);t.p<e.length;){if(e.charCodeAt(t.p)===91){let p=e.charCodeAt(++t.p)===91;s=t.p+=+p;let d=A(t,"]");if(p){if(e.charCodeAt(t.p-1)!==93)throw new f("expected end of table declaration",{toml:e,ptr:t.p-1});t.p++}let u=v(d,l,n,p?2:1);if(!u)throw new f("trying to redefine an already defined table or value",{toml:e,ptr:s});o=u[2],a=u[1]}else{s=t.p;let p=A(t),d=v(p,a,o,0);if(!d)throw new f("trying to redefine an already defined table or value",{toml:e,ptr:s});d[1][d[0]]=b(t,void 0,r)}if(w(t,!0),t.p<e.length&&(s=e.charCodeAt(t.p))!==10&&s!==13)throw new f("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:t.p});w(t)}return l}export{m as TomlDate,f as TomlError,Z as parse};
58
+ */let Z=/^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;class C extends Date{#i=!1;#l=!1;#e=null;constructor(l,i,n){let a=!0,s=!0,r="Z",f;if(typeof l=="string")if(i)e:{if(i<3){if(+l.slice(11,13)>23){l="";break e}i===2?(r=null,l+="Z"):(f=l.charCodeAt(l.length-1))!==90&&f!==122&&(r=l.slice(l.length-6)),n&&(l=l.slice(0,10)+"T"+l.slice(11))}else i===4&&(l=+l.slice(0,2)>23?"":`0000-01-01T${l}Z`);a=i!==4,s=i!==3}else{let t=l.match(Z);t?(t[1]||(a=!1,l=`0000-01-01T${l}`),s=!!t[2],s&&l[10]===" "&&(l=l.replace(" ","T")),t[2]&&+t[2]>23?l="":(r=t[3]||null,!r&&s&&(l+="Z"))):l=""}super(l),isNaN(this.getTime())||(this.#i=a,this.#l=s,this.#e=r)}isDateTime(){return this.#i&&this.#l}isLocal(){return!this.#i||!this.#l||!this.#e}isDate(){return this.#i&&!this.#l}isTime(){return this.#l&&!this.#i}isValid(){return this.#i||this.#l}toISOString(){let l=super.toISOString();if(this.isDate())return l.slice(0,10);if(this.isTime())return l.slice(11,23);if(this.#e===null)return l.slice(0,-1);if(this.#e==="Z"||this.#e==="z")return l;let i=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return i=this.#e[0]==="-"?i:-i,new Date(this.getTime()-i*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(l,i="Z"){let n=new C(l);return n.#e=i,n}static wrapAsLocalDateTime(l){let i=new C(l);return i.#e=null,i}static wrapAsLocalDate(l){let i=new C(l);return i.#l=!1,i.#e=null,i}static wrapAsLocalTime(l){let i=new C(l);return i.#i=!1,i.#e=null,i}}function h(e,l=10){return l===16?e>47&&e<58||e>64&&e<71||e>96&&e<103:e>47&&e<48+l}function k(e,l){return e===32||e===9||e===10||e===13||l&&(e===l||e===44)||e===35}function O(e,l){let i=e.p,n=e.s.charCodeAt(e.p);if(n===91||n===123){e.d--||u.x("document contains excessively nested structures. aborting.",e);let a=n===91?V(e):P(e);return e.d++,a}return n===34||n===39?I(e):n===116?((e.s.charCodeAt(++e.p)!==114||e.s.charCodeAt(++e.p)!==117||e.s.charCodeAt(++e.p)!==101)&&u.x("invalid value",e,i),e.p++,!0):n===102?((e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==108||e.s.charCodeAt(++e.p)!==115||e.s.charCodeAt(++e.p)!==101)&&u.x("invalid value",e,i),e.p++,!1):n===43||n===45?w(e,e.p,e.s.charCodeAt(++e.p),44-n,l):e.s.charCodeAt(e.p+4)===45&&e.s.charCodeAt(e.p+7)===45?E(e,n,l):e.s.charCodeAt(e.p+2)===58?N(e,n,l):w(e,e.p,n,0,l)}function w(e,l,i,n,a){let s=i,r=0,f=!1;if(s===105)return(e.s.charCodeAt(++e.p)!==110||e.s.charCodeAt(++e.p)!==102)&&u.x("invalid value",e,l),e.p++,(n||1)/0;if(s===110)return(e.s.charCodeAt(++e.p)!==97||e.s.charCodeAt(++e.p)!==110)&&u.x("invalid value",e,l),e.p++,NaN;if(s===48){if(++e.p>=e.s.length||k(s=e.s.charCodeAt(e.p),a))return e.bi===!0?0n:0;if(!n){if(s===120)return v(e,l,16,a);if(s===98)return v(e,l,2,a);if(s===111)return v(e,l,8,a)}s===46?r=2:s===101||s===69?r=4:u.x("illegal leading zero",e,l)}else h(s)||u.x("invalid value",e,l);for(;++e.p<e.s.length&&(s=e.s.charCodeAt(e.p),!k(s,a));)r||(r=1),s===95?(r&1||u.x("illegal underscore",e),r+=11,f=!0):r===1&&s===46?r=2:(r===1||r===3)&&(s===101||s===69)?r=4:r===4&&(s===43||s===45)||(h(s)?r>9?r-=11:r&1||r++:u.x("illegal character in numeric literal",e));if(!r){let o=(i-48)*(n||1);return e.bi===!0?BigInt(o):o}r&1||u.x("unfinished numeric value",e,l);let t=e.s.slice(l,e.p);return f&&(t=t.replaceAll("_","")),r>1?parseFloat(t):S(e,t,10,l)}function v(e,l,i,n){let a,s=1;for(;++e.p<e.s.length&&(a=e.s.charCodeAt(e.p),!k(a,n));)a===95?(s&1&&u.x("illegal underscore",e),s=3):h(a,i)?s&1&&s--:u.x("illegal character in numeric literal",e);s&1&&u.x("unfinished numeric value",e);let r=e.s.slice(l+2,e.p);return s&&(r=r.replaceAll("_","")),S(e,r,i,l)}function S(e,l,i,n){if(e.bi!==!0)e:{let a=parseInt(l,i);if(!Number.isSafeInteger(a)){if(e.bi)break e;u.x("integer value cannot be represented losslessly",e,n)}return a}return BigInt(i===10?l:(i===2?"0b":i===8?"0o":"0x")+l)}function E(e,l,i){let n=e.p++,a;if(!h(l)||!h(e.s.charCodeAt(e.p++))||!h(e.s.charCodeAt(e.p++))||!h(e.s.charCodeAt(e.p++)))return w(e,e.p=n,l,0,i);if(e.p+=5,h(e.s.charCodeAt(e.p++))||u.x("invalid date-time: date part is malformed",e,n),e.p>=e.s.length||((l=e.s.charCodeAt(e.p))!==32||(a=!0,!h(e.s.charCodeAt(e.p+1))))&&l!==84&&l!==116){let r=e.s.slice(n,e.p);return b(e,r,3,!1,n)}if(e.s.charCodeAt(e.p+=3)!==58&&u.x("invalid date-time: time part is malformed",e,n),e.s.charCodeAt(e.p+=3)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;h(e.s.charCodeAt(++e.p)););if(l=e.s.charCodeAt(e.p)){if(l===90||l===122){let r=e.s.slice(n,++e.p);return b(e,r,1,a,n,"[+00:00]")}if(l===43||l===45){let r=e.s.slice(n,e.p+=6);return b(e,r,1,a,n,!e.ld&&"["+e.s.slice(e.p-6,e.p)+"]")}}let s=e.s.slice(n,e.p);return b(e,s,2,a,n)}function N(e,l,i){let n=e.p;if(!h(l)||!h(e.s.charCodeAt(++e.p)))return w(e,--e.p,l,0,i);if(e.s.charCodeAt(e.p+=4)===58&&(e.p+=3),e.s.charCodeAt(e.p)===46)for(;h(e.s.charCodeAt(++e.p)););let a=e.s.slice(n,e.p);return b(e,a,4,!1,n)}function b(e,l,i,n,a,s){if(e.ld){let r=new C(l,i,n);return r.isValid()||u.x("invalid date",e,a),r}try{switch(s&&(l+=s),i){case 1:return Temporal.ZonedDateTime.from(l);case 2:return Temporal.PlainDateTime.from(l);case 3:return Temporal.PlainDate.from(l);case 4:return Temporal.PlainTime.from(l)}}catch(r){u.x(r instanceof Error?r.message:""+r,e,a)}}function _(e){for(;e.p<e.s.length;e.p++){let l=e.s.charCodeAt(e.p);if(l===10)break;if(l===13&&e.s.charCodeAt(e.p+1)===10){e.p++;break}(l<32&&l!==9||l===127)&&u.x("control characters are not allowed in comments",e)}}function g(e,l,i){let n;for(;e.p<e.s.length;){for(;e.p<e.s.length&&((n=e.s.charCodeAt(e.p))===32||n===9||!l&&(n===10||n===13&&e.s.charCodeAt(e.p+1)===10));)e.p++;if(i||n!==35)break;_(e)}}function T(e,l=61){let i,n=0,a=[],s,r=e.s.charCodeAt(i=e.p);do{if(r===l)return n||u.x("unexpected end of key",e),n===1&&a.push(e.s.slice(s,e.p)),e.p++,a;r===46?(n||u.x("illegal empty bare key",e),n===1&&a.push(e.s.slice(s,e.p)),n=0):!n&&(r===34||r===39)?(r===e.s.charCodeAt(e.p+1)&&r===e.s.charCodeAt(e.p+2)&&u.x("illegal quoted key: multiline strings are not allowed",e),a.push(I(e)),n=2,e.p--):r===32||r===9?n===1&&(a.push(e.s.slice(s,e.p)),n=2):n===2||r<48&&r!==45||r>57&&r<65||r>90&&r<97&&r!==95||r>122?u.x("illegal character in key",e):n||(n=1,s=e.p)}while(r=e.s.charCodeAt(++e.p));u.x("incomplete key-value: cannot find end of key",e,i)}function P(e){let l=e.p++,i=Object.create(null),n=new Set,a;for(;e.p<e.s.length;){if(g(e),(a=e.s.charCodeAt(e.p))===125)return e.p++,i;let s,r=i,f=!1,t=e.p,o=T(e);for(let d=0;d<o.length;d++){d&&(r=f?r[s]:r[s]=Object.create(null)),s=o[d],(f=Object.hasOwn(r,s))&&(typeof r[s]!="object"||n.has(r[s]))&&u.x("trying to redefine an already defined value",e,t);let m=s==="__proto__";if(e.uk&&(m||s==="constructor")){r=e.uk!==1&&u.x("document contains an unsafe property",e,t);break}!f&&m&&Object.defineProperty(r,s,{enumerable:!0,configurable:!0,writable:!0})}f&&u.x("trying to redefine an already defined value",e,t),g(e,!0,!0);let p=O(e,125);if(r&&typeof(r[s]=p)=="object"&&n.add(p),g(e),(a=e.s.charCodeAt(e.p++))===125)return i;a!==44&&u.x("expected comma or end of structure",e,e.p-1)}u.x("unfinished table",e,l)}function V(e){let l=e.p++,i=[],n;for(;e.p<e.s.length;){if(g(e),(n=e.s.charCodeAt(e.p))===93)return e.p++,i;if(i.push(O(e,93)),g(e),(n=e.s.charCodeAt(e.p++))===93)return i;n!==44&&u.x("expected comma or end of structure",e,e.p-1)}u.x("unfinished array",e,l)}function D(e,l,i,n,a){let s=i,r=n,f,t=!1,o;for(let p=0;p<l.length;p++){if(p){if(s=t?s[f]:s[f]=Object.create(null),r=(o=r[f]).c,a===0&&(o.t===1||o.t===2))return null;if(o.t===2){let d=s.length-1;s=s[d],r=r[d].c}}if(f=l[p],(t=Object.hasOwn(s,f))&&r[f]?.t===0&&r[f]?.d)return null;if(!t){let d=f==="__proto__";if(e.uk&&(d||f==="constructor"))return!1;d&&(Object.defineProperty(s,f,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(r,f,{enumerable:!0,configurable:!0,writable:!0})),r[f]={t:p<l.length-1&&a===2?3:a,d:!1,i:0,c:Object.create(null)}}}if(o=r[f],o.t!==a&&!(a===1&&o.t===3)||(a===2&&(o.d||(o.d=!0,s[f]=[]),s[f].push(s=Object.create(null)),o.c[o.i++]=o={t:1,d:!1,i:0,c:Object.create(null)}),o.d))return null;if(o.d=!0,a===1)s=t?s[f]:s[f]=Object.create(null);else if(a===0&&t)return null;return[f,s,o.c]}function j(e,l,i){(l===null||e.uk===2)&&u.x(l===null?"trying to redefine an already defined table or value":"document contains an unsafe property",e,i)}function $(e,l={}){let i={s:e,p:0,d:l.maxDepth??1e3,bi:l.integersAsBigInt??!1,ld:l.useLegacyDate??!0,uk:l.unsafeKeyBehaviour==="throw"?2:l.unsafeKeyBehaviour==="drop"?1:0},n=Object.create(null),a=Object.create(null),s,r=!1,f=n,t=a;for(e.charCodeAt(0)===65279&&i.p++,g(i);i.p<e.length;){if(e.charCodeAt(i.p)===91){let o=e.charCodeAt(++i.p)===91;s=i.p+=+o,r=!1;let p=T(i,93);o&&(e.charCodeAt(i.p)!==93&&u.x("expected end of table array declaration",i),i.p++);let d=D(i,p,n,a,o?2:1);d?(t=d[2],f=d[1]):(j(i,d,s),r=!0)}else{s=i.p;let o=T(i),p=D(i,o,f,t,0);!p&&!r&&j(i,p,s),g(i,!0,!0);let d=O(i,void 0);p&&!r&&(p[1][p[0]]=d)}g(i,!0),i.p<e.length&&(s=e.charCodeAt(i.p))!==10&&(s!==13||e.charCodeAt(i.p+1)!==10)&&u.x("each key-value declaration must be followed by an end-of-line",i),g(i)}return n}export{C as TomlDate,u as TomlError,$ as parse};
@@ -1,4 +1,4 @@
1
- import{p as s}from"./cli-main.js";import{c as a,f as c}from"../packem_shared/registry-keys-BWHRFWbb.js";const f=async({options:r})=>{if(r.clear){const t=a();if(r.json){process.stdout.write(`${JSON.stringify({cleared:t,refetched:!1},void 0,2)}
1
+ import{p as s}from"./cli-main.js";import{c as a,f as c}from"../packem_shared/registry-keys-C3EsP_s4.js";const f=async({options:r})=>{if(r.clear){const t=a();if(r.json){process.stdout.write(`${JSON.stringify({cleared:t,refetched:!1},void 0,2)}
2
2
  `);return}s.success(t?"Cleared cached npm signing keys.":"No cached npm signing keys to clear.");return}const e=await c({forceRefresh:!0});if(e===void 0){if(r.json){process.stdout.write(`${JSON.stringify({cleared:!1,error:"fetch-failed",refetched:!1},void 0,2)}
3
3
  `),process.exitCode=1;return}s.error("Failed to fetch npm signing keys (network error and no cached keys available)."),process.exitCode=1;return}if(r.json){process.stdout.write(`${JSON.stringify({cleared:!1,fromCache:e.fromCache,keyCount:e.keys.length,refetched:!e.fromCache,stale:e.stale??!1},void 0,2)}
4
4
  `);return}if(e.fromCache&&e.stale===!0){s.warn(`Network fetch failed — falling back to expired cache (${String(e.keys.length)} keys).`);return}s.success(`Refreshed npm signing keys (${String(e.keys.length)} keys).`)};export{f as default};
@@ -1,4 +1,4 @@
1
- import{v as l,U as a}from"../packem_shared/index-DHD8wb6Z.js";import{r as m}from"../packem_shared/resolve-runtime-C7NBCA1C.js";import{r as u}from"../packem_shared/run-file-jMngGQhs.js";const p=s=>{let r,n=!1,o;const i=[];for(let e=0;e<s.length;e+=1){const t=s[e];if(o===void 0){if(t==="--node"){n=!0;continue}if(t==="--runtime"){r=s[e+1],e+=1;continue}if(t.startsWith("--runtime=")){r=t.slice(10);continue}o=t;continue}i.push(t)}return i[0]==="--"&&i.shift(),{file:o,node:n,runtimeFlag:r,scriptArguments:i}},h=async s=>{const{file:r,node:n,runtimeFlag:o,scriptArguments:i}=p(s);if(r===void 0){process.stderr.write(`No file specified. Usage: vis x <file> [args...]
1
+ import{v as l,U as a}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{r as m}from"../packem_shared/resolve-runtime-lJ5L9gU4.js";import{r as u}from"../packem_shared/run-file-DZff6GqY.js";const p=s=>{let r,n=!1,o;const i=[];for(let e=0;e<s.length;e+=1){const t=s[e];if(o===void 0){if(t==="--node"){n=!0;continue}if(t==="--runtime"){r=s[e+1],e+=1;continue}if(t.startsWith("--runtime=")){r=t.slice(10);continue}o=t;continue}i.push(t)}return i[0]==="--"&&i.shift(),{file:o,node:n,runtimeFlag:r,scriptArguments:i}},h=async s=>{const{file:r,node:n,runtimeFlag:o,scriptArguments:i}=p(s);if(r===void 0){process.stderr.write(`No file specified. Usage: vis x <file> [args...]
2
2
  `),process.exitCode=1;return}const e=process.cwd(),t=l(r)?r:a(e,r);if(n){const d=await u(t,i,"node",e,{node:!0});d!==0&&(process.exitCode=d);return}let c;try{c=m(e,{flag:o})}catch(d){process.stderr.write(`${d.message}
3
3
  `),process.exitCode=1;return}c.deferredNotice!==void 0&&process.stderr.write(`${c.deferredNotice}
4
4
  `);const f=await u(t,i,c.runtime,e);f!==0&&(process.exitCode=f)};export{p as parseLeanXArgs,h as runLeanX};
@@ -1,3 +1,3 @@
1
- import{createRequire as _}from"node:module";import{x,p as t,y as R}from"./cli-main.js";import{d as P}from"../packem_shared/pm-runner-d93_73O6.js";import{a as M}from"../packem_shared/build-scripts-pdVmqXRm.js";import{e as v}from"../packem_shared/index-DHD8wb6Z.js";import{y as k}from"../packem_shared/isAccessibleSync-DYKTrrvc-CSnBISfV.js";import{p as q}from"../packem_shared/readJsonSync-CbryXYxN-B2aSeDpC.js";let j;const B=c=>(j??=_(import.meta.url))(c),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[i,f]=y.versions.node.split(".").map(Number);if(i>22||i===22&&f>=3||i===20&&f>=16)return y.getBuiltinModule(c)}return B(c)},{readdirSync:S,statSync:N}=D("node:fs"),T=(c,i={})=>{const f=v(c,"node_modules");if(!k(f))return[];const l=new Map,p=new Set,b=(n,o,r)=>{const e=`${o}@${r}`;if(p.has(e))return;p.add(e);const s=r.startsWith(c)?r.slice(c.length+1):r;let u=l.get(n);u||(u=[],l.set(n,u)),u.some($=>$.name===o)||u.push({name:o,relativePath:s})},m=(n,o="")=>{let r;try{r=S(n)}catch{return}for(const e of r){const s=v(n,e);if(e.startsWith("@")){m(s,`${e}/`);continue}if(e===".pnpm"&&o===""){let a;try{a=S(s)}catch{continue}for(const d of a){const g=v(s,d,"node_modules");k(g)&&m(g)}continue}if(e.startsWith("."))continue;const u=o+e,$=v(s,"package.json");try{if(!N(s).isDirectory()||!k($))continue;const a=q($),d=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const w=d.includes("/")?d.split("/").pop():d;b(w,d,s)}else if(a.bin&&typeof a.bin=="object")for(const w of Object.keys(a.bin))b(w,d,s);const g=v(s,"node_modules");k(g)&&m(g)}catch{}}};m(f);const h=[];for(const[n,o]of l)o.length<2||i[n]===!0||o.every(e=>i[`${e.name}#${n}`]===!0)||h.push({bin:n,packages:o});return h.sort((n,o)=>n.bin.localeCompare(o.bin))},V=new Set(["bun","npm","pnpm","yarn"]),F=({options:c,visConfig:i,workspaceRoot:f})=>{const l=f??process.cwd(),p=P(l),b=i?.security?.policies?.installScripts?.allow??{},m=i?.security?.allowBins??{},h=i?.security?.pinVersions===!0,n=M(l,b,{pinVersions:h}),o=T(l,m),r=i&&V.has(p.name)?x(i,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:o,drift:r,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:h,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
1
+ import{createRequire as _}from"node:module";import{x,p as t,y as R}from"./cli-main.js";import{d as P}from"../packem_shared/pm-runner-9L6ocnu2.js";import{a as M}from"../packem_shared/build-scripts-BIgkWVgY.js";import"../packem_shared/index-CVBR-Kit.js";import{e as v}from"../packem_shared/path-CxEa27Rz-pjheKk6v.js";import{y as k}from"../packem_shared/isAccessibleSync-DYKTrrvc-K2xhg6sV.js";import{p as q}from"../packem_shared/readJsonSync-CbryXYxN-BxKjDZnF.js";let j;const B=c=>(j??=_(import.meta.url))(c),y=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,D=c=>{if(typeof y<"u"&&y.versions&&y.versions.node){const[i,f]=y.versions.node.split(".").map(Number);if(i>22||i===22&&f>=3||i===20&&f>=16)return y.getBuiltinModule(c)}return B(c)},{readdirSync:S,statSync:N}=D("node:fs"),T=(c,i={})=>{const f=v(c,"node_modules");if(!k(f))return[];const l=new Map,p=new Set,b=(n,o,r)=>{const e=`${o}@${r}`;if(p.has(e))return;p.add(e);const s=r.startsWith(c)?r.slice(c.length+1):r;let u=l.get(n);u||(u=[],l.set(n,u)),u.some($=>$.name===o)||u.push({name:o,relativePath:s})},m=(n,o="")=>{let r;try{r=S(n)}catch{return}for(const e of r){const s=v(n,e);if(e.startsWith("@")){m(s,`${e}/`);continue}if(e===".pnpm"&&o===""){let a;try{a=S(s)}catch{continue}for(const d of a){const g=v(s,d,"node_modules");k(g)&&m(g)}continue}if(e.startsWith("."))continue;const u=o+e,$=v(s,"package.json");try{if(!N(s).isDirectory()||!k($))continue;const a=q($),d=typeof a.name=="string"?a.name:u;if(typeof a.bin=="string"){const w=d.includes("/")?d.split("/").pop():d;b(w,d,s)}else if(a.bin&&typeof a.bin=="object")for(const w of Object.keys(a.bin))b(w,d,s);const g=v(s,"node_modules");k(g)&&m(g)}catch{}}};m(f);const h=[];for(const[n,o]of l)o.length<2||i[n]===!0||o.every(e=>i[`${e.name}#${n}`]===!0)||h.push({bin:n,packages:o});return h.sort((n,o)=>n.bin.localeCompare(o.bin))},V=new Set(["bun","npm","pnpm","yarn"]),G=({options:c,visConfig:i,workspaceRoot:f})=>{const l=f??process.cwd(),p=P(l),b=i?.security?.policies?.installScripts?.allow??{},m=i?.security?.allowBins??{},h=i?.security?.pinVersions===!0,n=M(l,b,{pinVersions:h}),o=T(l,m),r=i&&V.has(p.name)?x(i,p.name,l):void 0;if(c.json){process.stdout.write(`${JSON.stringify({binConflicts:o,drift:r,excess:n.excess,installed:n.installed.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),packageManager:p.name,pinVersions:h,unapproved:n.unapproved.map(e=>({hooks:e.hooks,name:e.name,version:e.version})),versionDrift:n.versionDrift},void 0,2)}
2
2
  `);return}if(t.info(`Build-script status (${p.name}):
3
- `),n.installed.length===0&&n.unapproved.length===0&&t.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){t.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)t.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){t.info(""),t.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)t.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);t.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){t.info(""),t.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)t.info(` ! ${e}`);t.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){t.info(""),t.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:s}of n.versionDrift)t.info(` ${e} → ${s}`);t.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(o.length>0){t.info(""),t.warn(` Bin conflicts (${String(o.length)}) — multiple packages expose the same bin name:`);for(const e of o)t.info(` ${e.bin} ← ${e.packages.map(s=>s.name).join(", ")}`);t.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(r?.hasDrift){t.info("");for(const e of R(r))t.warn(e)}};export{F as default};
3
+ `),n.installed.length===0&&n.unapproved.length===0&&t.success(" No installed packages declare lifecycle scripts."),n.installed.length>0){t.success(` Approved (${String(n.installed.length)}):`);for(const e of n.installed)t.info(` ✓ ${e.name} — ${e.hooks.join(", ")}`)}if(n.unapproved.length>0){t.info(""),t.warn(` Unapproved (${String(n.unapproved.length)}):`);for(const e of n.unapproved)t.info(` ✗ ${e.name} — ${e.hooks.join(", ")}`);t.notice(" Run 'vis approve-builds' to review.")}if(n.excess.length>0){t.info(""),t.warn(` Stale allowlist entries (${String(n.excess.length)}):`);for(const e of n.excess)t.info(` ! ${e}`);t.notice(" Remove these from vis.config.ts security.policies.installScripts.allow.")}if(n.versionDrift.length>0){t.info(""),t.warn(` Version drift (pinVersions: true) — ${String(n.versionDrift.length)} entr${n.versionDrift.length===1?"y":"ies"} point at outdated versions:`);for(const{from:e,to:s}of n.versionDrift)t.info(` ${e} → ${s}`);t.notice(" Update vis.config.ts security.policies.installScripts.allow keys to migrate.")}if(o.length>0){t.info(""),t.warn(` Bin conflicts (${String(o.length)}) — multiple packages expose the same bin name:`);for(const e of o)t.info(` ${e.bin} ← ${e.packages.map(s=>s.name).join(", ")}`);t.notice(" Add the bin (or 'pkg#bin') to vis.config.ts security.allowBins to silence this.")}if(r?.hasDrift){t.info("");for(const e of R(r))t.warn(e)}};export{G as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as f}from"node:module";import{d as p,c as I}from"../packem_shared/pm-runner-d93_73O6.js";let _;const w=e=>(_??=f(import.meta.url))(e),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,r]=o.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return o.getBuiltinModule(e)}return w(e)},{createInterface:y}=g("node:readline"),s="sigstore",v=()=>!!process.stdout.isTTY&&process.env.CI!=="true",$=e=>new Promise(t=>{const r=y({input:process.stdin,output:process.stderr});r.question(`${e} (Y/n) `,a=>{r.close();const n=a.trim().toLowerCase();t(n===""||n==="y"||n==="yes")})}),h=e=>{const t=p(e),r=I(t,{exact:!1,filter:[],global:!1,optional:!1,packages:[s],peer:!1,saveDev:!0,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:r})},C=()=>{try{return import.meta.resolve(s),!0}catch{return!1}},R=e=>{let t="pnpm";try{t=p(e).name}catch{}switch(t){case"bun":return`bun add -d ${s}`;case"npm":return`npm install -D ${s}`;case"yarn":return`yarn add -D ${s}`;default:return`pnpm add -D ${s}`}},D=()=>import("sigstore"),E=async(e={})=>{const t=e.interactive??v(),r=e.prompt??$,a=e.runInstall??h,n=e.importImpl??D,l=e.workspaceRoot??process.cwd(),i=R(l);try{return await n()}catch(d){const{code:u,message:m}=d;if(!(u==="ERR_MODULE_NOT_FOUND"||u==="MODULE_NOT_FOUND")||!m.includes(s))throw d}if(!t)throw new Error(`${s} is not installed. \`vis attest\` needs it for keyless signing/verification. Install it in your repo first:
1
+ import{createRequire as f}from"node:module";import{d as p,c as I}from"../packem_shared/pm-runner-9L6ocnu2.js";let _;const w=e=>(_??=f(import.meta.url))(e),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[t,r]=o.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return o.getBuiltinModule(e)}return w(e)},{createInterface:y}=g("node:readline"),s="sigstore",v=()=>!!process.stdout.isTTY&&process.env.CI!=="true",$=e=>new Promise(t=>{const r=y({input:process.stdin,output:process.stderr});r.question(`${e} (Y/n) `,a=>{r.close();const n=a.trim().toLowerCase();t(n===""||n==="y"||n==="yes")})}),h=e=>{const t=p(e),r=I(t,{exact:!1,filter:[],global:!1,optional:!1,packages:[s],peer:!1,saveDev:!0,workspace:!1,workspaceRoot:!1},e,console);return Promise.resolve({exitCode:r})},C=()=>{try{return import.meta.resolve(s),!0}catch{return!1}},R=e=>{let t="pnpm";try{t=p(e).name}catch{}switch(t){case"bun":return`bun add -d ${s}`;case"npm":return`npm install -D ${s}`;case"yarn":return`yarn add -D ${s}`;default:return`pnpm add -D ${s}`}},D=()=>import("sigstore"),E=async(e={})=>{const t=e.interactive??v(),r=e.prompt??$,a=e.runInstall??h,n=e.importImpl??D,l=e.workspaceRoot??process.cwd(),i=R(l);try{return await n()}catch(d){const{code:u,message:m}=d;if(!(u==="ERR_MODULE_NOT_FOUND"||u==="MODULE_NOT_FOUND")||!m.includes(s))throw d}if(!t)throw new Error(`${s} is not installed. \`vis attest\` needs it for keyless signing/verification. Install it in your repo first:
2
2
  ${i}`);if(!await r(`${s} isn't installed. Install it now?`))throw new Error(`${s} install declined. Re-run \`vis attest\` after installing manually:
3
3
  ${i}`);const c=await a(l);if(c.exitCode!==0)throw new Error(`Install of ${s} failed (exit ${String(c.exitCode)}). Install manually and retry:
4
4
  ${i}`);return await n()};export{R as installCommandFor,C as isSigstoreInstalled,E as loadOptionalSigstore};
@@ -1,3 +1,3 @@
1
- import{p as o}from"./cli-main.js";import{r as f}from"../packem_shared/advisories-0ScpWAHV.js";const d=async({fs:c,logger:u,options:r,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const e=r.db??f(t),s=r.format==="json";if(!r.force){o.warn(`Prune is destructive. Will remove: ${e}`),o.info("Re-run with --force to proceed."),s&&process.stdout.write(`${JSON.stringify({dbPath:e,reason:"needs --force",removed:!1})}
1
+ import{p as o}from"./cli-main.js";import{r as f}from"../packem_shared/advisories-BSpzRIXP.js";const d=async({fs:c,logger:u,options:r,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const e=r.db??f(t),s=r.format==="json";if(!r.force){o.warn(`Prune is destructive. Will remove: ${e}`),o.info("Re-run with --force to proceed."),s&&process.stdout.write(`${JSON.stringify({dbPath:e,reason:"needs --force",removed:!1})}
2
2
  `);return}const a=[e,`${e}-wal`,`${e}-shm`,`${e}-journal`],i=[];for(const n of a)try{await c.rm(n,{force:!0}),i.push(n)}catch{}if(s){process.stdout.write(`${JSON.stringify({dbPath:e,files:i,removed:!0})}
3
3
  `);return}o.success(`Removed ${e}.`)},v=d;export{v as advisoriesPruneExecute};