@maizzle/framework 6.0.0-rc.9 → 6.0.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 (623) hide show
  1. package/README.md +3 -3
  2. package/bin/maizzle.mjs +1 -1
  3. package/dist/build.d.ts +38 -0
  4. package/dist/build.d.ts.map +1 -0
  5. package/dist/build.js +234 -0
  6. package/dist/build.js.map +1 -0
  7. package/dist/components/Body.vue +32 -3
  8. package/dist/components/Button.vue +91 -62
  9. package/dist/components/CodeBlock.vue +6 -4
  10. package/dist/components/CodeInline.vue +77 -6
  11. package/dist/components/Column.vue +67 -31
  12. package/dist/components/Container.vue +73 -12
  13. package/dist/components/Font.vue +96 -0
  14. package/dist/components/Head.vue +1 -1
  15. package/dist/components/Heading.vue +1 -1
  16. package/dist/components/Hr.vue +33 -0
  17. package/dist/components/Html.vue +36 -3
  18. package/dist/components/Img.vue +332 -0
  19. package/dist/components/Layout.vue +71 -21
  20. package/dist/components/Link.vue +1 -1
  21. package/dist/components/Markdown.vue +51 -24
  22. package/dist/components/MarkdownLayout.vue +39 -0
  23. package/dist/components/NotPlaintext.vue +14 -0
  24. package/dist/components/Outlook.vue +38 -11
  25. package/dist/components/OutlookBg.vue +241 -0
  26. package/dist/components/Plaintext.vue +14 -0
  27. package/dist/components/Preheader.vue +35 -10
  28. package/dist/components/QrCode.vue +157 -0
  29. package/dist/components/Raw.vue +28 -0
  30. package/dist/components/Row.vue +115 -22
  31. package/dist/components/Section.vue +65 -26
  32. package/dist/components/Spacer.vue +35 -29
  33. package/dist/components/Tailwind.vue +45 -0
  34. package/dist/components/Text.vue +3 -3
  35. package/dist/components/Vml.vue +207 -94
  36. package/dist/components/utils.d.ts +53 -0
  37. package/dist/components/utils.d.ts.map +1 -0
  38. package/dist/components/utils.js +80 -0
  39. package/dist/components/utils.js.map +1 -0
  40. package/dist/components/utils.ts +102 -0
  41. package/dist/composables/defineConfig.d.ts +13 -0
  42. package/dist/composables/defineConfig.d.ts.map +1 -0
  43. package/dist/composables/{defineConfig.mjs → defineConfig.js} +7 -9
  44. package/dist/composables/defineConfig.js.map +1 -0
  45. package/dist/composables/renderContext.d.ts +37 -0
  46. package/dist/composables/renderContext.d.ts.map +1 -0
  47. package/dist/composables/renderContext.js +6 -0
  48. package/dist/composables/renderContext.js.map +1 -0
  49. package/dist/composables/useBaseUrl.d.ts +19 -0
  50. package/dist/composables/useBaseUrl.d.ts.map +1 -0
  51. package/dist/composables/useBaseUrl.js +26 -0
  52. package/dist/composables/useBaseUrl.js.map +1 -0
  53. package/dist/composables/useConfig.d.ts +16 -0
  54. package/dist/composables/useConfig.d.ts.map +1 -0
  55. package/dist/composables/useConfig.js +19 -0
  56. package/dist/composables/useConfig.js.map +1 -0
  57. package/dist/composables/useCurrentTemplate.d.ts +31 -0
  58. package/dist/composables/useCurrentTemplate.d.ts.map +1 -0
  59. package/dist/composables/useCurrentTemplate.js +42 -0
  60. package/dist/composables/useCurrentTemplate.js.map +1 -0
  61. package/dist/composables/{useDoctype.d.mts → useDoctype.d.ts} +1 -1
  62. package/dist/composables/useDoctype.d.ts.map +1 -0
  63. package/dist/composables/{useDoctype.mjs → useDoctype.js} +3 -4
  64. package/dist/composables/useDoctype.js.map +1 -0
  65. package/dist/composables/{useEvent.d.mts → useEvent.d.ts} +3 -3
  66. package/dist/composables/useEvent.d.ts.map +1 -0
  67. package/dist/composables/{useEvent.mjs → useEvent.js} +4 -5
  68. package/dist/composables/useEvent.js.map +1 -0
  69. package/dist/composables/useFont.d.ts +50 -0
  70. package/dist/composables/useFont.d.ts.map +1 -0
  71. package/dist/composables/useFont.js +92 -0
  72. package/dist/composables/useFont.js.map +1 -0
  73. package/dist/composables/useOutlookFallback.d.ts +21 -0
  74. package/dist/composables/useOutlookFallback.d.ts.map +1 -0
  75. package/dist/composables/useOutlookFallback.js +29 -0
  76. package/dist/composables/useOutlookFallback.js.map +1 -0
  77. package/dist/composables/useOutputPath.d.ts +17 -0
  78. package/dist/composables/useOutputPath.d.ts.map +1 -0
  79. package/dist/composables/useOutputPath.js +23 -0
  80. package/dist/composables/useOutputPath.js.map +1 -0
  81. package/dist/composables/{usePlaintext.d.mts → usePlaintext.d.ts} +3 -1
  82. package/dist/composables/usePlaintext.d.ts.map +1 -0
  83. package/dist/composables/{usePlaintext.mjs → usePlaintext.js} +4 -4
  84. package/dist/composables/usePlaintext.js.map +1 -0
  85. package/dist/composables/usePreheader.d.ts +25 -0
  86. package/dist/composables/usePreheader.d.ts.map +1 -0
  87. package/dist/composables/usePreheader.js +28 -0
  88. package/dist/composables/usePreheader.js.map +1 -0
  89. package/dist/composables/useTransformers.d.ts +34 -0
  90. package/dist/composables/useTransformers.d.ts.map +1 -0
  91. package/dist/composables/useTransformers.js +48 -0
  92. package/dist/composables/useTransformers.js.map +1 -0
  93. package/dist/composables/useUrlQuery.d.ts +19 -0
  94. package/dist/composables/useUrlQuery.d.ts.map +1 -0
  95. package/dist/composables/useUrlQuery.js +26 -0
  96. package/dist/composables/useUrlQuery.js.map +1 -0
  97. package/dist/config/{defaults.d.mts → defaults.d.ts} +2 -2
  98. package/dist/config/defaults.d.ts.map +1 -0
  99. package/dist/config/{defaults.mjs → defaults.js} +10 -6
  100. package/dist/config/defaults.js.map +1 -0
  101. package/dist/config/index.d.ts +24 -0
  102. package/dist/config/index.d.ts.map +1 -0
  103. package/dist/config/{index.mjs → index.js} +45 -14
  104. package/dist/config/index.js.map +1 -0
  105. package/dist/events/{index.d.mts → index.d.ts} +35 -12
  106. package/dist/events/index.d.ts.map +1 -0
  107. package/dist/events/{index.mjs → index.js} +31 -13
  108. package/dist/events/index.js.map +1 -0
  109. package/dist/index.d.ts +41 -0
  110. package/dist/index.js +40 -0
  111. package/dist/{plaintext.d.mts → plaintext.d.ts} +1 -1
  112. package/dist/plaintext.d.ts.map +1 -0
  113. package/dist/{plaintext.mjs → plaintext.js} +4 -5
  114. package/dist/plaintext.js.map +1 -0
  115. package/dist/{plugin.d.mts → plugin.d.ts} +2 -2
  116. package/dist/plugin.d.ts.map +1 -0
  117. package/dist/{plugin.mjs → plugin.js} +8 -9
  118. package/dist/plugin.js.map +1 -0
  119. package/dist/plugins/postcss/{mergeMediaQueries.d.mts → mergeMediaQueries.d.ts} +2 -2
  120. package/dist/plugins/postcss/mergeMediaQueries.d.ts.map +1 -0
  121. package/dist/plugins/postcss/{mergeMediaQueries.mjs → mergeMediaQueries.js} +2 -3
  122. package/dist/plugins/postcss/mergeMediaQueries.js.map +1 -0
  123. package/dist/plugins/postcss/{pruneVars.d.mts → pruneVars.d.ts} +1 -1
  124. package/dist/plugins/postcss/pruneVars.d.ts.map +1 -0
  125. package/dist/plugins/postcss/{pruneVars.mjs → pruneVars.js} +2 -2
  126. package/dist/plugins/postcss/pruneVars.js.map +1 -0
  127. package/dist/plugins/postcss/quoteFontFamilies.d.ts +13 -0
  128. package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -0
  129. package/dist/plugins/postcss/quoteFontFamilies.js +84 -0
  130. package/dist/plugins/postcss/quoteFontFamilies.js.map +1 -0
  131. package/dist/plugins/postcss/{removeDeclarations.d.mts → removeDeclarations.d.ts} +1 -1
  132. package/dist/plugins/postcss/removeDeclarations.d.ts.map +1 -0
  133. package/dist/plugins/postcss/{removeDeclarations.mjs → removeDeclarations.js} +2 -2
  134. package/dist/plugins/postcss/removeDeclarations.js.map +1 -0
  135. package/dist/plugins/postcss/resolveMaizzleImports.d.ts +16 -0
  136. package/dist/plugins/postcss/resolveMaizzleImports.d.ts.map +1 -0
  137. package/dist/plugins/postcss/resolveMaizzleImports.js +39 -0
  138. package/dist/plugins/postcss/resolveMaizzleImports.js.map +1 -0
  139. package/dist/plugins/postcss/resolveProps.d.ts +8 -0
  140. package/dist/plugins/postcss/resolveProps.d.ts.map +1 -0
  141. package/dist/plugins/postcss/resolveProps.js +155 -0
  142. package/dist/plugins/postcss/resolveProps.js.map +1 -0
  143. package/dist/plugins/postcss/{tailwindCleanup.d.mts → tailwindCleanup.d.ts} +2 -2
  144. package/dist/plugins/postcss/tailwindCleanup.d.ts.map +1 -0
  145. package/dist/plugins/postcss/{tailwindCleanup.mjs → tailwindCleanup.js} +5 -3
  146. package/dist/plugins/postcss/tailwindCleanup.js.map +1 -0
  147. package/dist/prepare.d.ts +17 -0
  148. package/dist/prepare.d.ts.map +1 -0
  149. package/dist/prepare.js +44 -0
  150. package/dist/prepare.js.map +1 -0
  151. package/dist/render/active.d.ts +8 -0
  152. package/dist/render/active.d.ts.map +1 -0
  153. package/dist/render/active.js +12 -0
  154. package/dist/render/active.js.map +1 -0
  155. package/dist/render/buildTemplate.d.ts +49 -0
  156. package/dist/render/buildTemplate.d.ts.map +1 -0
  157. package/dist/render/buildTemplate.js +141 -0
  158. package/dist/render/buildTemplate.js.map +1 -0
  159. package/dist/render/{createRenderer.d.mts → createRenderer.d.ts} +14 -6
  160. package/dist/render/createRenderer.d.ts.map +1 -0
  161. package/dist/render/createRenderer.js +468 -0
  162. package/dist/render/createRenderer.js.map +1 -0
  163. package/dist/render/index.d.ts +18 -0
  164. package/dist/render/index.d.ts.map +1 -0
  165. package/dist/render/index.js +59 -0
  166. package/dist/render/index.js.map +1 -0
  167. package/dist/render/injectFonts.d.ts +15 -0
  168. package/dist/render/injectFonts.d.ts.map +1 -0
  169. package/dist/render/injectFonts.js +45 -0
  170. package/dist/render/injectFonts.js.map +1 -0
  171. package/dist/render/parallel/buildWorker.d.ts +31 -0
  172. package/dist/render/parallel/buildWorker.d.ts.map +1 -0
  173. package/dist/render/parallel/buildWorker.js +66 -0
  174. package/dist/render/parallel/buildWorker.js.map +1 -0
  175. package/dist/render/parallel/worker.mjs +28 -0
  176. package/dist/render/plugins/codeBlockExtract.d.ts +14 -0
  177. package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -0
  178. package/dist/render/plugins/codeBlockExtract.js +38 -0
  179. package/dist/render/plugins/codeBlockExtract.js.map +1 -0
  180. package/dist/render/plugins/markdownExtract.d.ts +12 -0
  181. package/dist/render/plugins/markdownExtract.d.ts.map +1 -0
  182. package/dist/render/plugins/markdownExtract.js +49 -0
  183. package/dist/render/plugins/markdownExtract.js.map +1 -0
  184. package/dist/render/plugins/rawExtract.d.ts +14 -0
  185. package/dist/render/plugins/rawExtract.d.ts.map +1 -0
  186. package/dist/render/plugins/rawExtract.js +34 -0
  187. package/dist/render/plugins/rawExtract.js.map +1 -0
  188. package/dist/render/plugins/rowSourceLocation.d.ts +18 -0
  189. package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -0
  190. package/dist/render/plugins/rowSourceLocation.js +45 -0
  191. package/dist/render/plugins/rowSourceLocation.js.map +1 -0
  192. package/dist/{serve.d.mts → serve.d.ts} +5 -3
  193. package/dist/serve.d.ts.map +1 -0
  194. package/dist/{serve.mjs → serve.js} +201 -107
  195. package/dist/serve.js.map +1 -0
  196. package/dist/server/compatibility.d.ts +59 -0
  197. package/dist/server/compatibility.d.ts.map +1 -0
  198. package/dist/server/compatibility.js +959 -0
  199. package/dist/server/compatibility.js.map +1 -0
  200. package/dist/server/{email.d.mts → email.d.ts} +2 -2
  201. package/dist/server/email.d.ts.map +1 -0
  202. package/dist/server/{email.mjs → email.js} +2 -3
  203. package/dist/server/email.js.map +1 -0
  204. package/dist/server/linter.d.ts +20 -0
  205. package/dist/server/linter.d.ts.map +1 -0
  206. package/dist/server/linter.js +345 -0
  207. package/dist/server/linter.js.map +1 -0
  208. package/dist/server/sfc-utils.d.ts +21 -0
  209. package/dist/server/sfc-utils.d.ts.map +1 -0
  210. package/dist/server/sfc-utils.js +198 -0
  211. package/dist/server/sfc-utils.js.map +1 -0
  212. package/dist/server/ui/.vite/deps/@lucide_vue.js +44967 -0
  213. package/dist/server/ui/.vite/deps/@lucide_vue.js.map +1 -0
  214. package/dist/server/ui/.vite/deps/@vueuse_core.js +8155 -0
  215. package/dist/server/ui/.vite/deps/@vueuse_core.js.map +1 -0
  216. package/dist/server/ui/.vite/deps/@vueuse_shared.js +1859 -0
  217. package/dist/server/ui/.vite/deps/@vueuse_shared.js.map +1 -0
  218. package/dist/server/ui/.vite/deps/_metadata.json +78 -0
  219. package/dist/server/ui/.vite/deps/chunk-EAsCxrDo.js +14 -0
  220. package/dist/server/ui/.vite/deps/class-variance-authority.js +57 -0
  221. package/dist/server/ui/.vite/deps/class-variance-authority.js.map +1 -0
  222. package/dist/server/ui/.vite/deps/clsx.js +18 -0
  223. package/dist/server/ui/.vite/deps/clsx.js.map +1 -0
  224. package/dist/server/ui/.vite/deps/culori.js +4312 -0
  225. package/dist/server/ui/.vite/deps/culori.js.map +1 -0
  226. package/dist/server/ui/.vite/deps/package.json +3 -0
  227. package/dist/server/ui/.vite/deps/reka-ui.js +44464 -0
  228. package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -0
  229. package/dist/server/ui/.vite/deps/tailwind-merge.js +3458 -0
  230. package/dist/server/ui/.vite/deps/tailwind-merge.js.map +1 -0
  231. package/dist/server/ui/.vite/deps/vue-router.js +6383 -0
  232. package/dist/server/ui/.vite/deps/vue-router.js.map +1 -0
  233. package/dist/server/ui/.vite/deps/vue.js +2 -0
  234. package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-DaqjATE_.js +8785 -0
  235. package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-DaqjATE_.js.map +1 -0
  236. package/dist/server/ui/App.vue +106 -66
  237. package/dist/server/ui/components/SidebarClose.vue +12 -0
  238. package/dist/server/ui/components/ui/checkbox/Checkbox.vue +1 -1
  239. package/dist/server/ui/components/ui/command/Command.vue +5 -1
  240. package/dist/server/ui/components/ui/command/CommandInput.vue +2 -2
  241. package/dist/server/ui/components/ui/dialog/DialogContent.vue +1 -1
  242. package/dist/server/ui/components/ui/dialog/DialogScrollContent.vue +1 -1
  243. package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +1 -1
  244. package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +1 -1
  245. package/dist/server/ui/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +1 -1
  246. package/dist/server/ui/components/ui/input/Input.vue +1 -1
  247. package/dist/server/ui/components/ui/sheet/SheetContent.vue +1 -1
  248. package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +2 -2
  249. package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +1 -1
  250. package/dist/server/ui/components/ui/tags-input/TagsInputItemDelete.vue +1 -1
  251. package/dist/server/ui/lib/emulated-dark-mode.ts +146 -0
  252. package/dist/server/ui/main.css +25 -0
  253. package/dist/server/ui/pages/Home.vue +1 -1
  254. package/dist/server/ui/pages/Preview.vue +377 -186
  255. package/dist/server/ui/vite-env.d.ts +1 -0
  256. package/dist/tests/render/_helpers.d.ts +6 -0
  257. package/dist/tests/render/_helpers.d.ts.map +1 -0
  258. package/dist/tests/render/_helpers.js +16 -0
  259. package/dist/tests/render/_helpers.js.map +1 -0
  260. package/dist/transformers/addAttributes.d.ts +42 -0
  261. package/dist/transformers/addAttributes.d.ts.map +1 -0
  262. package/dist/transformers/{addAttributes.mjs → addAttributes.js} +40 -24
  263. package/dist/transformers/addAttributes.js.map +1 -0
  264. package/dist/transformers/attributeToStyle.d.ts +38 -0
  265. package/dist/transformers/attributeToStyle.d.ts.map +1 -0
  266. package/dist/transformers/attributeToStyle.js +94 -0
  267. package/dist/transformers/attributeToStyle.js.map +1 -0
  268. package/dist/transformers/base.d.ts +71 -0
  269. package/dist/transformers/base.d.ts.map +1 -0
  270. package/dist/transformers/{base.mjs → base.js} +65 -40
  271. package/dist/transformers/base.js.map +1 -0
  272. package/dist/transformers/columnWidth.d.ts +31 -0
  273. package/dist/transformers/columnWidth.d.ts.map +1 -0
  274. package/dist/transformers/columnWidth.js +527 -0
  275. package/dist/transformers/columnWidth.js.map +1 -0
  276. package/dist/transformers/entities.d.ts +37 -0
  277. package/dist/transformers/entities.d.ts.map +1 -0
  278. package/dist/transformers/entities.js +74 -0
  279. package/dist/transformers/entities.js.map +1 -0
  280. package/dist/transformers/filters/{defaults.d.mts → defaults.d.ts} +1 -1
  281. package/dist/transformers/filters/defaults.d.ts.map +1 -0
  282. package/dist/transformers/filters/{defaults.mjs → defaults.js} +2 -2
  283. package/dist/transformers/filters/defaults.js.map +1 -0
  284. package/dist/transformers/filters/index.d.ts +43 -0
  285. package/dist/transformers/filters/index.d.ts.map +1 -0
  286. package/dist/transformers/filters/index.js +89 -0
  287. package/dist/transformers/filters/index.js.map +1 -0
  288. package/dist/transformers/format.d.ts +22 -0
  289. package/dist/transformers/format.d.ts.map +1 -0
  290. package/dist/transformers/format.js +30 -0
  291. package/dist/transformers/format.js.map +1 -0
  292. package/dist/transformers/imgWidth.d.ts +20 -0
  293. package/dist/transformers/imgWidth.d.ts.map +1 -0
  294. package/dist/transformers/imgWidth.js +76 -0
  295. package/dist/transformers/imgWidth.js.map +1 -0
  296. package/dist/transformers/{index.d.mts → index.d.ts} +4 -3
  297. package/dist/transformers/index.d.ts.map +1 -0
  298. package/dist/transformers/index.js +163 -0
  299. package/dist/transformers/index.js.map +1 -0
  300. package/dist/transformers/inlineCss.d.ts +85 -0
  301. package/dist/transformers/inlineCss.d.ts.map +1 -0
  302. package/dist/transformers/inlineCss.js +112 -0
  303. package/dist/transformers/inlineCss.js.map +1 -0
  304. package/dist/transformers/inlineLink.d.ts +35 -0
  305. package/dist/transformers/inlineLink.d.ts.map +1 -0
  306. package/dist/transformers/{inlineLink.mjs → inlineLink.js} +35 -11
  307. package/dist/transformers/inlineLink.js.map +1 -0
  308. package/dist/transformers/minify.d.ts +21 -0
  309. package/dist/transformers/minify.d.ts.map +1 -0
  310. package/dist/transformers/minify.js +25 -0
  311. package/dist/transformers/minify.js.map +1 -0
  312. package/dist/transformers/minifyCodeInline.d.ts +29 -0
  313. package/dist/transformers/minifyCodeInline.d.ts.map +1 -0
  314. package/dist/transformers/minifyCodeInline.js +36 -0
  315. package/dist/transformers/minifyCodeInline.js.map +1 -0
  316. package/dist/transformers/msoPlaceholders.d.ts +33 -0
  317. package/dist/transformers/msoPlaceholders.d.ts.map +1 -0
  318. package/dist/transformers/msoPlaceholders.js +114 -0
  319. package/dist/transformers/msoPlaceholders.js.map +1 -0
  320. package/dist/transformers/purgeCss.d.ts +43 -0
  321. package/dist/transformers/purgeCss.d.ts.map +1 -0
  322. package/dist/transformers/purgeCss.js +207 -0
  323. package/dist/transformers/purgeCss.js.map +1 -0
  324. package/dist/transformers/removeAttributes.d.ts +54 -0
  325. package/dist/transformers/removeAttributes.d.ts.map +1 -0
  326. package/dist/transformers/removeAttributes.js +72 -0
  327. package/dist/transformers/removeAttributes.js.map +1 -0
  328. package/dist/transformers/{replaceStrings.d.mts → replaceStrings.d.ts} +2 -2
  329. package/dist/transformers/replaceStrings.d.ts.map +1 -0
  330. package/dist/transformers/{replaceStrings.mjs → replaceStrings.js} +2 -2
  331. package/dist/transformers/replaceStrings.js.map +1 -0
  332. package/dist/transformers/safeSelectors.d.ts +37 -0
  333. package/dist/transformers/safeSelectors.d.ts.map +1 -0
  334. package/dist/transformers/{safeClassNames.mjs → safeSelectors.js} +40 -10
  335. package/dist/transformers/safeSelectors.js.map +1 -0
  336. package/dist/transformers/shorthandCss.d.ts +47 -0
  337. package/dist/transformers/shorthandCss.d.ts.map +1 -0
  338. package/dist/transformers/shorthandCss.js +92 -0
  339. package/dist/transformers/shorthandCss.js.map +1 -0
  340. package/dist/transformers/sixHex.d.ts +25 -0
  341. package/dist/transformers/sixHex.d.ts.map +1 -0
  342. package/dist/transformers/sixHex.js +42 -0
  343. package/dist/transformers/sixHex.js.map +1 -0
  344. package/dist/transformers/tailwindComponent.d.ts +16 -0
  345. package/dist/transformers/tailwindComponent.d.ts.map +1 -0
  346. package/dist/transformers/tailwindComponent.js +101 -0
  347. package/dist/transformers/tailwindComponent.js.map +1 -0
  348. package/dist/transformers/{tailwindcss.d.mts → tailwindcss.d.ts} +2 -2
  349. package/dist/transformers/tailwindcss.d.ts.map +1 -0
  350. package/dist/transformers/{tailwindcss.mjs → tailwindcss.js} +33 -74
  351. package/dist/transformers/tailwindcss.js.map +1 -0
  352. package/dist/transformers/urlQuery.d.ts +36 -0
  353. package/dist/transformers/urlQuery.d.ts.map +1 -0
  354. package/dist/transformers/urlQuery.js +77 -0
  355. package/dist/transformers/urlQuery.js.map +1 -0
  356. package/dist/types/{config.d.mts → config.d.ts} +231 -46
  357. package/dist/types/config.d.ts.map +1 -0
  358. package/dist/types/config.js +1 -0
  359. package/dist/types/index.d.ts +2 -0
  360. package/dist/types/index.js +1 -0
  361. package/dist/utils/ast/index.d.ts +4 -0
  362. package/dist/utils/ast/index.js +4 -0
  363. package/dist/utils/ast/{parser.d.mts → parser.d.ts} +1 -1
  364. package/dist/utils/ast/parser.d.ts.map +1 -0
  365. package/dist/utils/ast/{parser.mjs → parser.js} +2 -3
  366. package/dist/utils/ast/parser.js.map +1 -0
  367. package/dist/utils/ast/{serializer.d.mts → serializer.d.ts} +1 -1
  368. package/dist/utils/ast/serializer.d.ts.map +1 -0
  369. package/dist/utils/ast/serializer.js +46 -0
  370. package/dist/utils/ast/serializer.js.map +1 -0
  371. package/dist/utils/ast/{walker.d.mts → walker.d.ts} +1 -1
  372. package/dist/utils/ast/walker.d.ts.map +1 -0
  373. package/dist/utils/ast/{walker.mjs → walker.js} +2 -2
  374. package/dist/utils/ast/walker.js.map +1 -0
  375. package/dist/utils/cloneConfig.d.ts +13 -0
  376. package/dist/utils/cloneConfig.d.ts.map +1 -0
  377. package/dist/utils/cloneConfig.js +21 -0
  378. package/dist/utils/cloneConfig.js.map +1 -0
  379. package/dist/utils/compileTailwindCss.d.ts +16 -0
  380. package/dist/utils/compileTailwindCss.d.ts.map +1 -0
  381. package/dist/utils/compileTailwindCss.js +55 -0
  382. package/dist/utils/compileTailwindCss.js.map +1 -0
  383. package/dist/utils/componentSources.d.ts +50 -0
  384. package/dist/utils/componentSources.d.ts.map +1 -0
  385. package/dist/utils/componentSources.js +50 -0
  386. package/dist/utils/componentSources.js.map +1 -0
  387. package/dist/utils/cssBox.d.ts +42 -0
  388. package/dist/utils/cssBox.d.ts.map +1 -0
  389. package/dist/utils/cssBox.js +151 -0
  390. package/dist/utils/cssBox.js.map +1 -0
  391. package/dist/utils/decodeStyleEntities.d.ts +15 -0
  392. package/dist/utils/decodeStyleEntities.d.ts.map +1 -0
  393. package/dist/utils/decodeStyleEntities.js +18 -0
  394. package/dist/utils/decodeStyleEntities.js.map +1 -0
  395. package/dist/utils/{detect.d.mts → detect.d.ts} +1 -1
  396. package/dist/utils/detect.d.ts.map +1 -0
  397. package/dist/utils/{detect.mjs → detect.js} +2 -3
  398. package/dist/utils/detect.js.map +1 -0
  399. package/dist/utils/output-markers.d.ts +29 -0
  400. package/dist/utils/output-markers.d.ts.map +1 -0
  401. package/dist/utils/output-markers.js +68 -0
  402. package/dist/utils/output-markers.js.map +1 -0
  403. package/dist/utils/{url.d.mts → url.d.ts} +1 -1
  404. package/dist/utils/url.d.ts.map +1 -0
  405. package/dist/utils/{url.mjs → url.js} +2 -3
  406. package/dist/utils/url.js.map +1 -0
  407. package/dist/utils/watchPaths.d.ts +11 -0
  408. package/dist/utils/watchPaths.d.ts.map +1 -0
  409. package/dist/utils/watchPaths.js +19 -0
  410. package/dist/utils/watchPaths.js.map +1 -0
  411. package/node_modules/@clack/core/CHANGELOG.md +44 -0
  412. package/node_modules/@clack/core/dist/index.d.mts +125 -5
  413. package/node_modules/@clack/core/dist/index.mjs +972 -11
  414. package/node_modules/@clack/core/package.json +6 -2
  415. package/node_modules/@clack/prompts/CHANGELOG.md +70 -0
  416. package/node_modules/@clack/prompts/README.md +129 -3
  417. package/node_modules/@clack/prompts/dist/index.d.mts +567 -33
  418. package/node_modules/@clack/prompts/dist/index.mjs +1378 -133
  419. package/node_modules/@clack/prompts/package.json +7 -4
  420. package/node_modules/fast-string-truncated-width/dist/index.js +36 -96
  421. package/node_modules/fast-string-truncated-width/dist/types.d.ts +0 -3
  422. package/node_modules/fast-string-truncated-width/dist/utils.d.ts +3 -3
  423. package/node_modules/fast-string-truncated-width/dist/utils.js +14 -9
  424. package/node_modules/fast-string-truncated-width/package.json +1 -1
  425. package/node_modules/fast-string-truncated-width/readme.md +2 -3
  426. package/node_modules/fast-string-width/package.json +2 -2
  427. package/node_modules/fast-string-width/readme.md +0 -3
  428. package/node_modules/fast-wrap-ansi/lib/main.js +4 -2
  429. package/node_modules/fast-wrap-ansi/package.json +11 -11
  430. package/node_modules/maizzle/README.md +24 -0
  431. package/node_modules/maizzle/dist/commands/make/component.mjs +1 -1
  432. package/node_modules/maizzle/dist/commands/make/config.mjs +8 -7
  433. package/node_modules/maizzle/dist/commands/make/layout.mjs +3 -3
  434. package/node_modules/maizzle/dist/commands/make/scaffold.mjs +1 -1
  435. package/node_modules/maizzle/dist/commands/make/stubs/Layout.vue +146 -0
  436. package/node_modules/maizzle/dist/commands/make/stubs/component.vue +2 -4
  437. package/node_modules/maizzle/dist/commands/make/stubs/config.ts +1 -5
  438. package/node_modules/maizzle/dist/commands/make/template.mjs +1 -1
  439. package/node_modules/maizzle/dist/commands/new.mjs +46 -135
  440. package/node_modules/maizzle/dist/index.d.mts +1 -0
  441. package/node_modules/maizzle/dist/index.mjs +30 -7
  442. package/node_modules/maizzle/package.json +5 -4
  443. package/node_modules/nypm/dist/cli.mjs +28 -5
  444. package/node_modules/nypm/dist/index.d.mts +0 -8
  445. package/node_modules/nypm/dist/index.mjs +27 -4
  446. package/node_modules/nypm/package.json +12 -12
  447. package/node_modules/tinyexec/README.md +9 -1
  448. package/node_modules/tinyexec/dist/main.d.mts +22 -7
  449. package/node_modules/tinyexec/dist/main.mjs +189 -491
  450. package/node_modules/tinyexec/package.json +14 -16
  451. package/package.json +37 -30
  452. package/dist/_virtual/_rolldown/runtime.mjs +0 -32
  453. package/dist/build.d.mts +0 -19
  454. package/dist/build.d.mts.map +0 -1
  455. package/dist/build.mjs +0 -141
  456. package/dist/build.mjs.map +0 -1
  457. package/dist/components/Divider.vue +0 -133
  458. package/dist/components/Image.vue +0 -70
  459. package/dist/components/Overlap.vue +0 -80
  460. package/dist/components/utils.d.mts +0 -5
  461. package/dist/components/utils.d.mts.map +0 -1
  462. package/dist/components/utils.mjs +0 -9
  463. package/dist/components/utils.mjs.map +0 -1
  464. package/dist/composables/defineConfig.d.mts +0 -14
  465. package/dist/composables/defineConfig.d.mts.map +0 -1
  466. package/dist/composables/defineConfig.mjs.map +0 -1
  467. package/dist/composables/renderContext.d.mts +0 -24
  468. package/dist/composables/renderContext.d.mts.map +0 -1
  469. package/dist/composables/renderContext.mjs +0 -6
  470. package/dist/composables/renderContext.mjs.map +0 -1
  471. package/dist/composables/useConfig.d.mts +0 -9
  472. package/dist/composables/useConfig.d.mts.map +0 -1
  473. package/dist/composables/useConfig.mjs +0 -13
  474. package/dist/composables/useConfig.mjs.map +0 -1
  475. package/dist/composables/useDoctype.d.mts.map +0 -1
  476. package/dist/composables/useDoctype.mjs.map +0 -1
  477. package/dist/composables/useEvent.d.mts.map +0 -1
  478. package/dist/composables/useEvent.mjs.map +0 -1
  479. package/dist/composables/usePlaintext.d.mts.map +0 -1
  480. package/dist/composables/usePlaintext.mjs.map +0 -1
  481. package/dist/composables/usePreviewText.d.mts +0 -24
  482. package/dist/composables/usePreviewText.d.mts.map +0 -1
  483. package/dist/composables/usePreviewText.mjs +0 -29
  484. package/dist/composables/usePreviewText.mjs.map +0 -1
  485. package/dist/config/defaults.d.mts.map +0 -1
  486. package/dist/config/defaults.mjs.map +0 -1
  487. package/dist/config/index.d.mts +0 -15
  488. package/dist/config/index.d.mts.map +0 -1
  489. package/dist/config/index.mjs.map +0 -1
  490. package/dist/events/index.d.mts.map +0 -1
  491. package/dist/events/index.mjs.map +0 -1
  492. package/dist/index.d.mts +0 -31
  493. package/dist/index.mjs +0 -31
  494. package/dist/node_modules/picomatch/index.mjs +0 -13
  495. package/dist/node_modules/picomatch/index.mjs.map +0 -1
  496. package/dist/node_modules/picomatch/lib/constants.mjs +0 -174
  497. package/dist/node_modules/picomatch/lib/constants.mjs.map +0 -1
  498. package/dist/node_modules/picomatch/lib/parse.mjs +0 -1067
  499. package/dist/node_modules/picomatch/lib/parse.mjs.map +0 -1
  500. package/dist/node_modules/picomatch/lib/picomatch.mjs +0 -304
  501. package/dist/node_modules/picomatch/lib/picomatch.mjs.map +0 -1
  502. package/dist/node_modules/picomatch/lib/scan.mjs +0 -296
  503. package/dist/node_modules/picomatch/lib/scan.mjs.map +0 -1
  504. package/dist/node_modules/picomatch/lib/utils.mjs +0 -53
  505. package/dist/node_modules/picomatch/lib/utils.mjs.map +0 -1
  506. package/dist/plaintext.d.mts.map +0 -1
  507. package/dist/plaintext.mjs.map +0 -1
  508. package/dist/plugin.d.mts.map +0 -1
  509. package/dist/plugin.mjs.map +0 -1
  510. package/dist/plugins/postcss/mergeMediaQueries.d.mts.map +0 -1
  511. package/dist/plugins/postcss/mergeMediaQueries.mjs.map +0 -1
  512. package/dist/plugins/postcss/pruneVars.d.mts.map +0 -1
  513. package/dist/plugins/postcss/pruneVars.mjs.map +0 -1
  514. package/dist/plugins/postcss/removeDeclarations.d.mts.map +0 -1
  515. package/dist/plugins/postcss/removeDeclarations.mjs.map +0 -1
  516. package/dist/plugins/postcss/tailwindCleanup.d.mts.map +0 -1
  517. package/dist/plugins/postcss/tailwindCleanup.mjs.map +0 -1
  518. package/dist/render/createRenderer.d.mts.map +0 -1
  519. package/dist/render/createRenderer.mjs +0 -286
  520. package/dist/render/createRenderer.mjs.map +0 -1
  521. package/dist/render/index.d.mts +0 -26
  522. package/dist/render/index.d.mts.map +0 -1
  523. package/dist/render/index.mjs +0 -46
  524. package/dist/render/index.mjs.map +0 -1
  525. package/dist/serve.d.mts.map +0 -1
  526. package/dist/serve.mjs.map +0 -1
  527. package/dist/server/compatibility.d.mts +0 -5
  528. package/dist/server/compatibility.d.mts.map +0 -1
  529. package/dist/server/compatibility.mjs +0 -97
  530. package/dist/server/compatibility.mjs.map +0 -1
  531. package/dist/server/email.d.mts.map +0 -1
  532. package/dist/server/email.mjs.map +0 -1
  533. package/dist/server/linter.d.mts +0 -5
  534. package/dist/server/linter.d.mts.map +0 -1
  535. package/dist/server/linter.mjs +0 -189
  536. package/dist/server/linter.mjs.map +0 -1
  537. package/dist/transformers/addAttributes.d.mts +0 -32
  538. package/dist/transformers/addAttributes.d.mts.map +0 -1
  539. package/dist/transformers/addAttributes.mjs.map +0 -1
  540. package/dist/transformers/attributeToStyle.d.mts +0 -25
  541. package/dist/transformers/attributeToStyle.d.mts.map +0 -1
  542. package/dist/transformers/attributeToStyle.mjs +0 -80
  543. package/dist/transformers/attributeToStyle.mjs.map +0 -1
  544. package/dist/transformers/base.d.mts +0 -8
  545. package/dist/transformers/base.d.mts.map +0 -1
  546. package/dist/transformers/base.mjs.map +0 -1
  547. package/dist/transformers/entities.d.mts +0 -8
  548. package/dist/transformers/entities.d.mts.map +0 -1
  549. package/dist/transformers/entities.mjs +0 -41
  550. package/dist/transformers/entities.mjs.map +0 -1
  551. package/dist/transformers/filters/defaults.d.mts.map +0 -1
  552. package/dist/transformers/filters/defaults.mjs.map +0 -1
  553. package/dist/transformers/filters/index.d.mts +0 -22
  554. package/dist/transformers/filters/index.d.mts.map +0 -1
  555. package/dist/transformers/filters/index.mjs +0 -67
  556. package/dist/transformers/filters/index.mjs.map +0 -1
  557. package/dist/transformers/format.d.mts +0 -15
  558. package/dist/transformers/format.d.mts.map +0 -1
  559. package/dist/transformers/format.mjs +0 -26
  560. package/dist/transformers/format.mjs.map +0 -1
  561. package/dist/transformers/index.d.mts.map +0 -1
  562. package/dist/transformers/index.mjs +0 -81
  563. package/dist/transformers/index.mjs.map +0 -1
  564. package/dist/transformers/inlineCSS.d.mts +0 -17
  565. package/dist/transformers/inlineCSS.d.mts.map +0 -1
  566. package/dist/transformers/inlineCSS.mjs +0 -70
  567. package/dist/transformers/inlineCSS.mjs.map +0 -1
  568. package/dist/transformers/inlineLink.d.mts +0 -14
  569. package/dist/transformers/inlineLink.d.mts.map +0 -1
  570. package/dist/transformers/inlineLink.mjs.map +0 -1
  571. package/dist/transformers/minify.d.mts +0 -17
  572. package/dist/transformers/minify.d.mts.map +0 -1
  573. package/dist/transformers/minify.mjs +0 -24
  574. package/dist/transformers/minify.mjs.map +0 -1
  575. package/dist/transformers/purgeCSS.d.mts +0 -23
  576. package/dist/transformers/purgeCSS.d.mts.map +0 -1
  577. package/dist/transformers/purgeCSS.mjs +0 -132
  578. package/dist/transformers/purgeCSS.mjs.map +0 -1
  579. package/dist/transformers/removeAttributes.d.mts +0 -31
  580. package/dist/transformers/removeAttributes.d.mts.map +0 -1
  581. package/dist/transformers/removeAttributes.mjs +0 -63
  582. package/dist/transformers/removeAttributes.mjs.map +0 -1
  583. package/dist/transformers/replaceStrings.d.mts.map +0 -1
  584. package/dist/transformers/replaceStrings.mjs.map +0 -1
  585. package/dist/transformers/safeClassNames.d.mts +0 -22
  586. package/dist/transformers/safeClassNames.d.mts.map +0 -1
  587. package/dist/transformers/safeClassNames.mjs.map +0 -1
  588. package/dist/transformers/shorthandCSS.d.mts +0 -24
  589. package/dist/transformers/shorthandCSS.d.mts.map +0 -1
  590. package/dist/transformers/shorthandCSS.mjs +0 -48
  591. package/dist/transformers/shorthandCSS.mjs.map +0 -1
  592. package/dist/transformers/sixHex.d.mts +0 -16
  593. package/dist/transformers/sixHex.d.mts.map +0 -1
  594. package/dist/transformers/sixHex.mjs +0 -30
  595. package/dist/transformers/sixHex.mjs.map +0 -1
  596. package/dist/transformers/tailwindcss.d.mts.map +0 -1
  597. package/dist/transformers/tailwindcss.mjs.map +0 -1
  598. package/dist/transformers/urlQuery.d.mts +0 -24
  599. package/dist/transformers/urlQuery.d.mts.map +0 -1
  600. package/dist/transformers/urlQuery.mjs +0 -65
  601. package/dist/transformers/urlQuery.mjs.map +0 -1
  602. package/dist/types/config.d.mts.map +0 -1
  603. package/dist/types/config.mjs +0 -1
  604. package/dist/types/index.d.mts +0 -2
  605. package/dist/types/index.mjs +0 -1
  606. package/dist/utils/ast/index.d.mts +0 -4
  607. package/dist/utils/ast/index.mjs +0 -5
  608. package/dist/utils/ast/parser.d.mts.map +0 -1
  609. package/dist/utils/ast/parser.mjs.map +0 -1
  610. package/dist/utils/ast/serializer.d.mts.map +0 -1
  611. package/dist/utils/ast/serializer.mjs +0 -37
  612. package/dist/utils/ast/serializer.mjs.map +0 -1
  613. package/dist/utils/ast/walker.d.mts.map +0 -1
  614. package/dist/utils/ast/walker.mjs.map +0 -1
  615. package/dist/utils/detect.d.mts.map +0 -1
  616. package/dist/utils/detect.mjs.map +0 -1
  617. package/dist/utils/url.d.mts.map +0 -1
  618. package/dist/utils/url.mjs.map +0 -1
  619. package/node_modules/@clack/core/dist/index.mjs.map +0 -1
  620. package/node_modules/@clack/prompts/dist/index.mjs.map +0 -1
  621. package/node_modules/fast-wrap-ansi/lib/main.js.map +0 -1
  622. package/node_modules/maizzle/dist/commands/make/stubs/layout.vue +0 -39
  623. package/node_modules/tinyexec/dist/LICENSES.txt +0 -83
@@ -1,11 +1,972 @@
1
- import{styleText as y}from"node:util";import{stdout as S,stdin as $}from"node:process";import*as _ from"node:readline";import P from"node:readline";import{wrapAnsi as x}from"fast-wrap-ansi";import{cursor as c,erase as M}from"sisteransi";import{ReadStream as D}from"node:tty";function d(r,t,e){if(!e.some(o=>!o.disabled))return r;const s=r+t,i=Math.max(e.length-1,0),n=s<0?i:s>i?0:s;return e[n].disabled?d(n,t<0?-1:1,e):n}const E=["up","down","left","right","space","enter","cancel"],G=["January","February","March","April","May","June","July","August","September","October","November","December"],u={actions:new Set(E),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"},withGuide:!0,date:{monthNames:[...G],messages:{required:"Please enter a valid date",invalidMonth:"There are only 12 months in a year",invalidDay:(r,t)=>`There are only ${r} days in ${t}`,afterMin:r=>`Date must be on or after ${r.toISOString().slice(0,10)}`,beforeMax:r=>`Date must be on or before ${r.toISOString().slice(0,10)}`}}};function K(r){if(r.aliases!==void 0){const t=r.aliases;for(const e in t){if(!Object.hasOwn(t,e))continue;const s=t[e];u.actions.has(s)&&(u.aliases.has(e)||u.aliases.set(e,s))}}if(r.messages!==void 0){const t=r.messages;t.cancel!==void 0&&(u.messages.cancel=t.cancel),t.error!==void 0&&(u.messages.error=t.error)}if(r.withGuide!==void 0&&(u.withGuide=r.withGuide!==!1),r.date!==void 0){const t=r.date;t.monthNames!==void 0&&(u.date.monthNames=[...t.monthNames]),t.messages!==void 0&&(t.messages.required!==void 0&&(u.date.messages.required=t.messages.required),t.messages.invalidMonth!==void 0&&(u.date.messages.invalidMonth=t.messages.invalidMonth),t.messages.invalidDay!==void 0&&(u.date.messages.invalidDay=t.messages.invalidDay),t.messages.afterMin!==void 0&&(u.date.messages.afterMin=t.messages.afterMin),t.messages.beforeMax!==void 0&&(u.date.messages.beforeMax=t.messages.beforeMax))}}function V(r,t){if(typeof r=="string")return u.aliases.get(r)===t;for(const e of r)if(e!==void 0&&V(e,t))return!0;return!1}function j(r,t){if(r===t)return;const e=r.split(`
2
- `),s=t.split(`
3
- `),i=Math.max(e.length,s.length),n=[];for(let o=0;o<i;o++)e[o]!==s[o]&&n.push(o);return{lines:n,numLinesBefore:e.length,numLinesAfter:s.length,numLines:i}}const Y=globalThis.process.platform.startsWith("win"),C=Symbol("clack:cancel");function q(r){return r===C}function w(r,t){const e=r;e.isTTY&&e.setRawMode(t)}function z({input:r=$,output:t=S,overwrite:e=!0,hideCursor:s=!0}={}){const i=_.createInterface({input:r,output:t,prompt:"",tabSize:1});_.emitKeypressEvents(r,i),r instanceof D&&r.isTTY&&r.setRawMode(!0);const n=(o,{name:a,sequence:h})=>{const l=String(o);if(V([l,a,h],"cancel")){s&&t.write(c.show),process.exit(0);return}if(!e)return;const f=a==="return"?0:-1,v=a==="return"?-1:0;_.moveCursor(t,f,v,()=>{_.clearLine(t,1,()=>{r.once("keypress",n)})})};return s&&t.write(c.hide),r.once("keypress",n),()=>{r.off("keypress",n),s&&t.write(c.show),r instanceof D&&r.isTTY&&!Y&&r.setRawMode(!1),i.terminal=!1,i.close()}}const O=r=>"columns"in r&&typeof r.columns=="number"?r.columns:80,A=r=>"rows"in r&&typeof r.rows=="number"?r.rows:20;function R(r,t,e,s=e){const i=O(r??S);return x(t,i-e.length,{hard:!0,trim:!1}).split(`
4
- `).map((n,o)=>`${o===0?s:e}${n}`).join(`
5
- `)}let p=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;state="initial";error="";value;userInput="";constructor(t,e=!0){const{input:s=$,output:i=S,render:n,signal:o,...a}=t;this.opts=a,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=n.bind(this),this._track=e,this._abortSignal=o,this.input=s,this.output=i}unsubscribe(){this._subscribers.clear()}setSubscriber(t,e){const s=this._subscribers.get(t)??[];s.push(e),this._subscribers.set(t,s)}on(t,e){this.setSubscriber(t,{cb:e})}once(t,e){this.setSubscriber(t,{cb:e,once:!0})}emit(t,...e){const s=this._subscribers.get(t)??[],i=[];for(const n of s)n.cb(...e),n.once&&i.push(()=>s.splice(s.indexOf(n),1));for(const n of i)n()}prompt(){return new Promise(t=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),t(C);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}this.rl=P.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on("keypress",this.onKeypress),w(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(c.show),this.output.off("resize",this.render),w(this.input,!1),t(this.value)}),this.once("cancel",()=>{this.output.write(c.show),this.output.off("resize",this.render),w(this.input,!1),t(C)})})}_isActionKey(t,e){return t===" "}_setValue(t){this.value=t,this.emit("value",this.value)}_setUserInput(t,e){this.userInput=t??"",this.emit("userInput",this.userInput),e&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:"u"}),this._setUserInput("")}onKeypress(t,e){if(this._track&&e.name!=="return"&&(e.name&&this._isActionKey(t,e)&&this.rl?.write(null,{ctrl:!0,name:"h"}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state==="error"&&(this.state="active"),e?.name&&(!this._track&&u.aliases.has(e.name)&&this.emit("cursor",u.aliases.get(e.name)),u.actions.has(e.name)&&this.emit("cursor",e.name)),t&&(t.toLowerCase()==="y"||t.toLowerCase()==="n")&&this.emit("confirm",t.toLowerCase()==="y"),this.emit("key",t?.toLowerCase(),e),e?.name==="return"){if(this.opts.validate){const s=this.opts.validate(this.value);s&&(this.error=s instanceof Error?s.message:s,this.state="error",this.rl?.write(this.userInput))}this.state!=="error"&&(this.state="submit")}V([t,e?.name,e?.sequence],"cancel")&&(this.state="cancel"),(this.state==="submit"||this.state==="cancel")&&this.emit("finalize"),this.render(),(this.state==="submit"||this.state==="cancel")&&this.close()}close(){this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
6
- `),w(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){const t=x(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
7
- `).length-1;this.output.write(c.move(-999,t*-1))}render(){const t=x(this._render(this)??"",process.stdout.columns,{hard:!0,trim:!1});if(t!==this._prevFrame){if(this.state==="initial")this.output.write(c.hide);else{const e=j(this._prevFrame,t),s=A(this.output);if(this.restoreCursor(),e){const i=Math.max(0,e.numLinesAfter-s),n=Math.max(0,e.numLinesBefore-s);let o=e.lines.find(a=>a>=i);if(o===void 0){this._prevFrame=t;return}if(e.lines.length===1){this.output.write(c.move(0,o-n)),this.output.write(M.lines(1));const a=t.split(`
8
- `);this.output.write(a[o]),this._prevFrame=t,this.output.write(c.move(0,a.length-o-1));return}else if(e.lines.length>1){if(i<n)o=i;else{const h=o-n;h>0&&this.output.write(c.move(0,h))}this.output.write(M.down());const a=t.split(`
9
- `).slice(o);this.output.write(a.join(`
10
- `)),this._prevFrame=t;return}}this.output.write(M.down())}this.output.write(t),this.state==="initial"&&(this.state="active"),this._prevFrame=t}}};function W(r,t){if(r===void 0||t.length===0)return 0;const e=t.findIndex(s=>s.value===r);return e!==-1?e:0}function B(r,t){return(t.label??String(t.value)).toLowerCase().includes(r.toLowerCase())}function J(r,t){if(t)return r?t:t[0]}let H=class extends p{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#e=0;#o="";#t;#n;#a;get cursor(){return this.#e}get userInputWithCursor(){if(!this.userInput)return y(["inverse","hidden"],"_");if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;const t=this.userInput.slice(0,this._cursor),[e,...s]=this.userInput.slice(this._cursor);return`${t}${y("inverse",e)}${s.join("")}`}get options(){return typeof this.#n=="function"?this.#n():this.#n}constructor(t){super(t),this.#n=t.options,this.#a=t.placeholder;const e=this.options;this.filteredOptions=[...e],this.multiple=t.multiple===!0,this.#t=typeof t.options=="function"?t.filter:t.filter??B;let s;if(t.initialValue&&Array.isArray(t.initialValue)?this.multiple?s=t.initialValue:s=t.initialValue.slice(0,1):!this.multiple&&this.options.length>0&&(s=[this.options[0].value]),s)for(const i of s){const n=e.findIndex(o=>o.value===i);n!==-1&&(this.toggleSelected(i),this.#e=n)}this.focusedValue=this.options[this.#e]?.value,this.on("key",(i,n)=>this.#s(i,n)),this.on("userInput",i=>this.#i(i))}_isActionKey(t,e){return t===" "||this.multiple&&this.isNavigating&&e.name==="space"&&t!==void 0&&t!==""}#s(t,e){const s=e.name==="up",i=e.name==="down",n=e.name==="return",o=this.userInput===""||this.userInput===" ",a=this.#a,h=this.options,l=a!==void 0&&a!==""&&h.some(f=>!f.disabled&&(this.#t?this.#t(a,f):!0));if(e.name==="tab"&&o&&l){this.userInput===" "&&this._clearUserInput(),this._setUserInput(a,!0),this.isNavigating=!1;return}s||i?(this.#e=d(this.#e,s?-1:1,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#e]?.value,this.multiple||(this.selectedValues=[this.focusedValue]),this.isNavigating=!0):n?this.value=J(this.multiple,this.selectedValues):this.multiple?this.focusedValue!==void 0&&(e.name==="tab"||this.isNavigating&&e.name==="space")?this.toggleSelected(this.focusedValue):this.isNavigating=!1:(this.focusedValue&&(this.selectedValues=[this.focusedValue]),this.isNavigating=!1)}deselectAll(){this.selectedValues=[]}toggleSelected(t){this.filteredOptions.length!==0&&(this.multiple?this.selectedValues.includes(t)?this.selectedValues=this.selectedValues.filter(e=>e!==t):this.selectedValues=[...this.selectedValues,t]:this.selectedValues=[t])}#i(t){if(t!==this.#o){this.#o=t;const e=this.options;t&&this.#t?this.filteredOptions=e.filter(n=>this.#t?.(t,n)):this.filteredOptions=[...e];const s=W(this.focusedValue,this.filteredOptions);this.#e=d(s,0,this.filteredOptions);const i=this.filteredOptions[this.#e];i&&!i.disabled?this.focusedValue=i.value:this.focusedValue=void 0,this.multiple||(this.focusedValue!==void 0?this.toggleSelected(this.focusedValue):this.deselectAll())}}};class Q extends p{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(t){super(t,!1),this.value=!!t.initialValue,this.on("userInput",()=>{this.value=this._value}),this.on("confirm",e=>{this.output.write(c.move(0,-1)),this.value=e,this.state="submit",this.close()}),this.on("cursor",()=>{this.value=!this.value})}}const X={Y:{type:"year",len:4},M:{type:"month",len:2},D:{type:"day",len:2}};function L(r){return[...r].map(t=>X[t])}function Z(r){const t=new Intl.DateTimeFormat(r,{year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(new Date(2e3,0,15)),e=[];let s="/";for(const i of t)i.type==="literal"?s=i.value.trim()||i.value:(i.type==="year"||i.type==="month"||i.type==="day")&&e.push({type:i.type,len:i.type==="year"?4:2});return{segments:e,separator:s}}function k(r){return Number.parseInt((r||"0").replace(/_/g,"0"),10)||0}function I(r){return{year:k(r.year),month:k(r.month),day:k(r.day)}}function T(r,t){return new Date(r||2001,t||1,0).getDate()}function F(r){const{year:t,month:e,day:s}=I(r);if(!t||t<0||t>9999||!e||e<1||e>12||!s||s<1)return;const i=new Date(Date.UTC(t,e-1,s));if(!(i.getUTCFullYear()!==t||i.getUTCMonth()!==e-1||i.getUTCDate()!==s))return{year:t,month:e,day:s}}function N(r){const t=F(r);return t?new Date(Date.UTC(t.year,t.month-1,t.day)):void 0}function tt(r,t,e,s){const i=e?{year:e.getUTCFullYear(),month:e.getUTCMonth()+1,day:e.getUTCDate()}:null,n=s?{year:s.getUTCFullYear(),month:s.getUTCMonth()+1,day:s.getUTCDate()}:null;return r==="year"?{min:i?.year??1,max:n?.year??9999}:r==="month"?{min:i&&t.year===i.year?i.month:1,max:n&&t.year===n.year?n.month:12}:{min:i&&t.year===i.year&&t.month===i.month?i.day:1,max:n&&t.year===n.year&&t.month===n.month?n.day:T(t.year,t.month)}}class et extends p{#e;#o;#t;#n;#a;#s={segmentIndex:0,positionInSegment:0};#i=!0;#r=null;inlineError="";get segmentCursor(){return{...this.#s}}get segmentValues(){return{...this.#t}}get segments(){return this.#e}get separator(){return this.#o}get formattedValue(){return this.#c(this.#t)}#c(t){return this.#e.map(e=>t[e.type]).join(this.#o)}#h(){this._setUserInput(this.#c(this.#t)),this._setValue(N(this.#t)??void 0)}constructor(t){const e=t.format?{segments:L(t.format),separator:t.separator??"/"}:Z(t.locale),s=t.separator??e.separator,i=t.format?L(t.format):e.segments,n=t.initialValue??t.defaultValue,o=n?{year:String(n.getUTCFullYear()).padStart(4,"0"),month:String(n.getUTCMonth()+1).padStart(2,"0"),day:String(n.getUTCDate()).padStart(2,"0")}:{year:"____",month:"__",day:"__"},a=i.map(h=>o[h.type]).join(s);super({...t,initialUserInput:a},!1),this.#e=i,this.#o=s,this.#t=o,this.#n=t.minDate,this.#a=t.maxDate,this.#h(),this.on("cursor",h=>this.#d(h)),this.on("key",(h,l)=>this.#f(h,l)),this.on("finalize",()=>this.#g(t))}#u(){const t=Math.max(0,Math.min(this.#s.segmentIndex,this.#e.length-1)),e=this.#e[t];if(e)return this.#s.positionInSegment=Math.max(0,Math.min(this.#s.positionInSegment,e.len-1)),{segment:e,index:t}}#l(t){this.inlineError="",this.#r=null;const e=this.#u();e&&(this.#s.segmentIndex=Math.max(0,Math.min(this.#e.length-1,e.index+t)),this.#s.positionInSegment=0,this.#i=!0)}#p(t){const e=this.#u();if(!e)return;const{segment:s}=e,i=this.#t[s.type],n=!i||i.replace(/_/g,"")==="",o=Number.parseInt((i||"0").replace(/_/g,"0"),10)||0,a=tt(s.type,I(this.#t),this.#n,this.#a);let h;n?h=t===1?a.min:a.max:h=Math.max(Math.min(a.max,o+t),a.min),this.#t={...this.#t,[s.type]:h.toString().padStart(s.len,"0")},this.#i=!0,this.#r=null,this.#h()}#d(t){if(t)switch(t){case"right":return this.#l(1);case"left":return this.#l(-1);case"up":return this.#p(1);case"down":return this.#p(-1)}}#f(t,e){if(e?.name==="backspace"||e?.sequence==="\x7F"||e?.sequence==="\b"||t==="\x7F"||t==="\b"){this.inlineError="";const s=this.#u();if(!s)return;if(!this.#t[s.segment.type].replace(/_/g,"")){this.#l(-1);return}this.#t[s.segment.type]="_".repeat(s.segment.len),this.#i=!0,this.#s.positionInSegment=0,this.#h();return}if(e?.name==="tab"){this.inlineError="";const s=this.#u();if(!s)return;const i=e.shift?-1:1,n=s.index+i;n>=0&&n<this.#e.length&&(this.#s.segmentIndex=n,this.#s.positionInSegment=0,this.#i=!0);return}if(t&&/^[0-9]$/.test(t)){const s=this.#u();if(!s)return;const{segment:i}=s,n=!this.#t[i.type].replace(/_/g,"");if(this.#i&&this.#r!==null&&!n){const m=this.#r+t,g={...this.#t,[i.type]:m},b=this.#m(g,i);if(b){this.inlineError=b,this.#r=null,this.#i=!1;return}this.inlineError="",this.#t[i.type]=m,this.#r=null,this.#i=!1,this.#h(),s.index<this.#e.length-1&&(this.#s.segmentIndex=s.index+1,this.#s.positionInSegment=0,this.#i=!0);return}this.#i&&!n&&(this.#t[i.type]="_".repeat(i.len),this.#s.positionInSegment=0),this.#i=!1,this.#r=null;const o=this.#t[i.type],a=o.indexOf("_"),h=a>=0?a:Math.min(this.#s.positionInSegment,i.len-1);if(h<0||h>=i.len)return;let l=o.slice(0,h)+t+o.slice(h+1),f=!1;if(h===0&&o==="__"&&(i.type==="month"||i.type==="day")){const m=Number.parseInt(t,10);l=`0${t}`,f=m<=(i.type==="month"?1:2)}if(i.type==="year"&&(l=(o.replace(/_/g,"")+t).padStart(i.len,"_")),!l.includes("_")){const m={...this.#t,[i.type]:l},g=this.#m(m,i);if(g){this.inlineError=g;return}}this.inlineError="",this.#t[i.type]=l;const v=l.includes("_")?void 0:F(this.#t);if(v){const{year:m,month:g}=v,b=T(m,g);this.#t={year:String(Math.max(0,Math.min(9999,m))).padStart(4,"0"),month:String(Math.max(1,Math.min(12,g))).padStart(2,"0"),day:String(Math.max(1,Math.min(b,v.day))).padStart(2,"0")}}this.#h();const U=l.indexOf("_");f?(this.#i=!0,this.#r=t):U>=0?this.#s.positionInSegment=U:a>=0&&s.index<this.#e.length-1?(this.#s.segmentIndex=s.index+1,this.#s.positionInSegment=0,this.#i=!0):this.#s.positionInSegment=Math.min(h+1,i.len-1)}}#m(t,e){const{month:s,day:i}=I(t);if(e.type==="month"&&(s<0||s>12))return u.date.messages.invalidMonth;if(e.type==="day"&&(i<0||i>31))return u.date.messages.invalidDay(31,"any month")}#g(t){const{year:e,month:s,day:i}=I(this.#t);if(e&&s&&i){const n=T(e,s);this.#t={...this.#t,day:String(Math.min(i,n)).padStart(2,"0")}}this.value=N(this.#t)??t.defaultValue??void 0}}class st extends p{options;cursor=0;#e;getGroupItems(t){return this.options.filter(e=>e.group===t)}isGroupSelected(t){const e=this.getGroupItems(t),s=this.value;return s===void 0?!1:e.every(i=>s.includes(i.value))}toggleValue(){const t=this.options[this.cursor];if(this.value===void 0&&(this.value=[]),t.group===!0){const e=t.value,s=this.getGroupItems(e);this.isGroupSelected(e)?this.value=this.value.filter(i=>s.findIndex(n=>n.value===i)===-1):this.value=[...this.value,...s.map(i=>i.value)],this.value=Array.from(new Set(this.value))}else{const e=this.value.includes(t.value);this.value=e?this.value.filter(s=>s!==t.value):[...this.value,t.value]}}constructor(t){super(t,!1);const{options:e}=t;this.#e=t.selectableGroups!==!1,this.options=Object.entries(e).flatMap(([s,i])=>[{value:s,group:!0,label:s},...i.map(n=>({...n,group:s}))]),this.value=[...t.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:s})=>s===t.cursorAt),this.#e?0:1),this.on("cursor",s=>{switch(s){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;const i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;const i=this.options[this.cursor]?.group===!0;!this.#e&&i&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case"space":this.toggleValue();break}})}}let it=class extends p{options;cursor=0;get _value(){return this.options[this.cursor].value}get _enabledOptions(){return this.options.filter(t=>t.disabled!==!0)}toggleAll(){const t=this._enabledOptions,e=this.value!==void 0&&this.value.length===t.length;this.value=e?[]:t.map(s=>s.value)}toggleInvert(){const t=this.value;if(!t)return;const e=this._enabledOptions.filter(s=>!t.includes(s.value));this.value=e.map(s=>s.value)}toggleValue(){this.value===void 0&&(this.value=[]);const t=this.value.includes(this._value);this.value=t?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(t){super(t,!1),this.options=t.options,this.value=[...t.initialValues??[]];const e=Math.max(this.options.findIndex(({value:s})=>s===t.cursorAt),0);this.cursor=this.options[e].disabled?d(e,1,this.options):e,this.on("key",s=>{s==="a"&&this.toggleAll(),s==="i"&&this.toggleInvert()}),this.on("cursor",s=>{switch(s){case"left":case"up":this.cursor=d(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=d(this.cursor,1,this.options);break;case"space":this.toggleValue();break}})}};class rt extends p{_mask="\u2022";get cursor(){return this._cursor}get masked(){return this.userInput.replaceAll(/./g,this._mask)}get userInputWithCursor(){if(this.state==="submit"||this.state==="cancel")return this.masked;const t=this.userInput;if(this.cursor>=t.length)return`${this.masked}${y(["inverse","hidden"],"_")}`;const e=this.masked,s=e.slice(0,this.cursor),i=e.slice(this.cursor);return`${s}${y("inverse",i[0])}${i.slice(1)}`}clear(){this._clearUserInput()}constructor({mask:t,...e}){super(e),this._mask=t??"\u2022",this.on("userInput",s=>{this._setValue(s)})}}class nt extends p{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){this.value=this._selectedValue.value}constructor(t){super(t,!1),this.options=t.options;const e=this.options.findIndex(({value:i})=>i===t.initialValue),s=e===-1?0:e;this.cursor=this.options[s].disabled?d(s,1,this.options):s,this.changeValue(),this.on("cursor",i=>{switch(i){case"left":case"up":this.cursor=d(this.cursor,-1,this.options);break;case"down":case"right":this.cursor=d(this.cursor,1,this.options);break}this.changeValue()})}}class ot extends p{options;cursor=0;constructor(t){super(t,!1),this.options=t.options;const e=t.caseSensitive===!0,s=this.options.map(({value:[i]})=>e?i:i?.toLowerCase());this.cursor=Math.max(s.indexOf(t.initialValue),0),this.on("key",(i,n)=>{if(!i)return;const o=e&&n.shift?i.toUpperCase():i;if(!s.includes(o))return;const a=this.options.find(({value:[h]})=>e?h===o:h?.toLowerCase()===i);a&&(this.value=a.value,this.state="submit",this.emit("submit"))})}}class at extends p{get userInputWithCursor(){if(this.state==="submit")return this.userInput;const t=this.userInput;if(this.cursor>=t.length)return`${this.userInput}\u2588`;const e=t.slice(0,this.cursor),[s,...i]=t.slice(this.cursor);return`${e}${y("inverse",s)}${i.join("")}`}get cursor(){return this._cursor}constructor(t){super({...t,initialUserInput:t.initialUserInput??t.initialValue}),this.on("userInput",e=>{this._setValue(e)}),this.on("finalize",()=>{this.value||(this.value=t.defaultValue),this.value===void 0&&(this.value="")})}}export{H as AutocompletePrompt,Q as ConfirmPrompt,et as DatePrompt,st as GroupMultiSelectPrompt,it as MultiSelectPrompt,rt as PasswordPrompt,p as Prompt,ot as SelectKeyPrompt,nt as SelectPrompt,at as TextPrompt,z as block,O as getColumns,A as getRows,q as isCancel,u as settings,K as updateSettings,R as wrapTextWithPrefix};
11
- //# sourceMappingURL=index.mjs.map
1
+ import { styleText } from 'node:util';
2
+ import { stdout, stdin } from 'node:process';
3
+ import * as l from 'node:readline';
4
+ import l__default from 'node:readline';
5
+ import { wrapAnsi } from 'fast-wrap-ansi';
6
+ import { cursor, erase } from 'sisteransi';
7
+ import { ReadStream } from 'node:tty';
8
+
9
+ function findCursor(s, o, l) {
10
+ if (!l.some((r) => !r.disabled))
11
+ return s;
12
+ const t = s + o, n = Math.max(l.length - 1, 0), e = t < 0 ? n : t > n ? 0 : t;
13
+ return l[e].disabled ? findCursor(e, o < 0 ? -1 : 1, l) : e;
14
+ }
15
+ function findTextCursor(s, o, l, i) {
16
+ const t = i.split(`
17
+ `);
18
+ let n = 0, e = s;
19
+ for (const r of t) {
20
+ if (e <= r.length)
21
+ break;
22
+ e -= r.length + 1, n++;
23
+ }
24
+ for (n = Math.max(0, Math.min(t.length - 1, n + l)), e = Math.min(e, t[n].length) + o; e < 0 && n > 0; )
25
+ n--, e += t[n].length + 1;
26
+ for (; e > t[n].length && n < t.length - 1; )
27
+ e -= t[n].length + 1, n++;
28
+ e = Math.max(0, Math.min(t[n].length, e));
29
+ let h = 0;
30
+ for (let r = 0; r < n; r++)
31
+ h += t[r].length + 1;
32
+ return h + e;
33
+ }
34
+
35
+ const a$2 = ["up", "down", "left", "right", "space", "enter", "cancel"], t = [
36
+ "January",
37
+ "February",
38
+ "March",
39
+ "April",
40
+ "May",
41
+ "June",
42
+ "July",
43
+ "August",
44
+ "September",
45
+ "October",
46
+ "November",
47
+ "December"
48
+ ];
49
+ const settings = {
50
+ actions: new Set(a$2),
51
+ aliases: /* @__PURE__ */ new Map([
52
+ // vim support
53
+ ["k", "up"],
54
+ ["j", "down"],
55
+ ["h", "left"],
56
+ ["l", "right"],
57
+ ["", "cancel"],
58
+ // opinionated defaults!
59
+ ["escape", "cancel"]
60
+ ]),
61
+ messages: {
62
+ cancel: "Canceled",
63
+ error: "Something went wrong"
64
+ },
65
+ withGuide: true,
66
+ date: {
67
+ monthNames: [...t],
68
+ messages: {
69
+ required: "Please enter a valid date",
70
+ invalidMonth: "There are only 12 months in a year",
71
+ invalidDay: (n, e) => `There are only ${n} days in ${e}`,
72
+ afterMin: (n) => `Date must be on or after ${n.toISOString().slice(0, 10)}`,
73
+ beforeMax: (n) => `Date must be on or before ${n.toISOString().slice(0, 10)}`
74
+ }
75
+ }
76
+ };
77
+ function updateSettings(n) {
78
+ if (n.aliases !== void 0) {
79
+ const e = n.aliases;
80
+ for (const s in e) {
81
+ if (!Object.hasOwn(e, s)) continue;
82
+ const i = e[s];
83
+ settings.actions.has(i) && (settings.aliases.has(s) || settings.aliases.set(s, i));
84
+ }
85
+ }
86
+ if (n.messages !== void 0) {
87
+ const e = n.messages;
88
+ e.cancel !== void 0 && (settings.messages.cancel = e.cancel), e.error !== void 0 && (settings.messages.error = e.error);
89
+ }
90
+ if (n.withGuide !== void 0 && (settings.withGuide = n.withGuide !== false), n.date !== void 0) {
91
+ const e = n.date;
92
+ e.monthNames !== void 0 && (settings.date.monthNames = [...e.monthNames]), e.messages !== void 0 && (e.messages.required !== void 0 && (settings.date.messages.required = e.messages.required), e.messages.invalidMonth !== void 0 && (settings.date.messages.invalidMonth = e.messages.invalidMonth), e.messages.invalidDay !== void 0 && (settings.date.messages.invalidDay = e.messages.invalidDay), e.messages.afterMin !== void 0 && (settings.date.messages.afterMin = e.messages.afterMin), e.messages.beforeMax !== void 0 && (settings.date.messages.beforeMax = e.messages.beforeMax));
93
+ }
94
+ }
95
+ function isActionKey(n, e) {
96
+ if (typeof n == "string")
97
+ return settings.aliases.get(n) === e;
98
+ for (const s of n)
99
+ if (s !== void 0 && isActionKey(s, e))
100
+ return true;
101
+ return false;
102
+ }
103
+
104
+ function diffLines(i, s) {
105
+ if (i === s) return;
106
+ const e = i.split(`
107
+ `), t = s.split(`
108
+ `), r = Math.max(e.length, t.length), f = [];
109
+ for (let n = 0; n < r; n++)
110
+ e[n] !== t[n] && f.push(n);
111
+ return {
112
+ lines: f,
113
+ numLinesBefore: e.length,
114
+ numLinesAfter: t.length,
115
+ numLines: r
116
+ };
117
+ }
118
+
119
+ const R = globalThis.process.platform.startsWith("win");
120
+ const CANCEL_SYMBOL = Symbol("clack:cancel");
121
+ function isCancel(e) {
122
+ return e === CANCEL_SYMBOL;
123
+ }
124
+ function setRawMode(e, r) {
125
+ const o = e;
126
+ o.isTTY && o.setRawMode(r);
127
+ }
128
+ function block({
129
+ input: e = stdin,
130
+ output: r = stdout,
131
+ overwrite: o = true,
132
+ hideCursor: t = true
133
+ } = {}) {
134
+ const s = l.createInterface({
135
+ input: e,
136
+ output: r,
137
+ prompt: "",
138
+ tabSize: 1
139
+ });
140
+ l.emitKeypressEvents(e, s), e instanceof ReadStream && e.isTTY && e.setRawMode(true);
141
+ const n = (f, { name: a, sequence: p }) => {
142
+ const c = String(f);
143
+ if (isActionKey([c, a, p], "cancel")) {
144
+ t && r.write(cursor.show), process.exit(0);
145
+ return;
146
+ }
147
+ if (!o) return;
148
+ const i = a === "return" ? 0 : -1, m = a === "return" ? -1 : 0;
149
+ l.moveCursor(r, i, m, () => {
150
+ l.clearLine(r, 1, () => {
151
+ e.once("keypress", n);
152
+ });
153
+ });
154
+ };
155
+ return t && r.write(cursor.hide), e.once("keypress", n), () => {
156
+ e.off("keypress", n), t && r.write(cursor.show), e instanceof ReadStream && e.isTTY && !R && e.setRawMode(false), s.terminal = false, s.close();
157
+ };
158
+ }
159
+ const getColumns = (e) => "columns" in e && typeof e.columns == "number" ? e.columns : 80, getRows = (e) => "rows" in e && typeof e.rows == "number" ? e.rows : 20;
160
+ function wrapTextWithPrefix(e, r, o, t = o, s = o, n) {
161
+ const f = getColumns(e ?? stdout);
162
+ return wrapAnsi(r, f - o.length, {
163
+ hard: true,
164
+ trim: false
165
+ }).split(`
166
+ `).map((c, i, m) => {
167
+ const d = n ? n(c, i) : c;
168
+ return i === 0 ? `${t}${d}` : i === m.length - 1 ? `${s}${d}` : `${o}${d}`;
169
+ }).join(`
170
+ `);
171
+ }
172
+
173
+ function runValidation(e, n) {
174
+ if ("~standard" in e) {
175
+ const a = e["~standard"].validate(n);
176
+ if (a instanceof Promise)
177
+ throw new TypeError(
178
+ "Schema validation must be synchronous. Update `validate()` and remove any asynchronous logic."
179
+ );
180
+ return a.issues?.at(0)?.message;
181
+ }
182
+ return e(n);
183
+ }
184
+
185
+ class V {
186
+ input;
187
+ output;
188
+ _abortSignal;
189
+ rl;
190
+ opts;
191
+ _render;
192
+ _track = false;
193
+ _prevFrame = "";
194
+ _subscribers = /* @__PURE__ */ new Map();
195
+ _cursor = 0;
196
+ state = "initial";
197
+ error = "";
198
+ value;
199
+ userInput = "";
200
+ constructor(t, e = true) {
201
+ const { input: i = stdin, output: n = stdout, render: s, signal: r, ...o } = t;
202
+ this.opts = o, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = s.bind(this), this._track = e, this._abortSignal = r, this.input = i, this.output = n;
203
+ }
204
+ /**
205
+ * Unsubscribe all listeners
206
+ */
207
+ unsubscribe() {
208
+ this._subscribers.clear();
209
+ }
210
+ /**
211
+ * Set a subscriber with opts
212
+ * @param event - The event name
213
+ */
214
+ setSubscriber(t, e) {
215
+ const i = this._subscribers.get(t) ?? [];
216
+ i.push(e), this._subscribers.set(t, i);
217
+ }
218
+ /**
219
+ * Subscribe to an event
220
+ * @param event - The event name
221
+ * @param cb - The callback
222
+ */
223
+ on(t, e) {
224
+ this.setSubscriber(t, { cb: e });
225
+ }
226
+ /**
227
+ * Subscribe to an event once
228
+ * @param event - The event name
229
+ * @param cb - The callback
230
+ */
231
+ once(t, e) {
232
+ this.setSubscriber(t, { cb: e, once: true });
233
+ }
234
+ /**
235
+ * Emit an event with data
236
+ * @param event - The event name
237
+ * @param data - The data to pass to the callback
238
+ */
239
+ emit(t, ...e) {
240
+ const i = this._subscribers.get(t) ?? [], n = [];
241
+ for (const s of i)
242
+ s.cb(...e), s.once && n.push(() => i.splice(i.indexOf(s), 1));
243
+ for (const s of n)
244
+ s();
245
+ }
246
+ prompt() {
247
+ return new Promise((t) => {
248
+ if (this._abortSignal) {
249
+ if (this._abortSignal.aborted)
250
+ return this.state = "cancel", this.close(), t(CANCEL_SYMBOL);
251
+ this._abortSignal.addEventListener(
252
+ "abort",
253
+ () => {
254
+ this.state = "cancel", this.close();
255
+ },
256
+ { once: true }
257
+ );
258
+ }
259
+ this.rl = l__default.createInterface({
260
+ input: this.input,
261
+ tabSize: 2,
262
+ prompt: "",
263
+ escapeCodeTimeout: 50,
264
+ terminal: true
265
+ }), this.rl.prompt(), this.opts.initialUserInput !== void 0 && this._setUserInput(this.opts.initialUserInput, true), this.input.on("keypress", this.onKeypress), setRawMode(this.input, true), this.output.on("resize", this.render), this.render(), this.once("submit", () => {
266
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(this.value);
267
+ }), this.once("cancel", () => {
268
+ this.output.write(cursor.show), this.output.off("resize", this.render), setRawMode(this.input, false), t(CANCEL_SYMBOL);
269
+ });
270
+ });
271
+ }
272
+ _isActionKey(t, e) {
273
+ return t === " ";
274
+ }
275
+ _shouldSubmit(t, e) {
276
+ return true;
277
+ }
278
+ _setValue(t) {
279
+ this.value = t, this.emit("value", this.value);
280
+ }
281
+ _setUserInput(t, e) {
282
+ this.userInput = t ?? "", this.emit("userInput", this.userInput), e && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
283
+ }
284
+ _clearUserInput() {
285
+ this.rl?.write(null, { ctrl: true, name: "u" }), this._setUserInput("");
286
+ }
287
+ onKeypress(t, e) {
288
+ if (this._track && e.name !== "return" && (e.name && this._isActionKey(t, e) && this.rl?.write(null, { ctrl: true, name: "h" }), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), this.state === "error" && (this.state = "active"), e?.name && (!this._track && settings.aliases.has(e.name) && this.emit("cursor", settings.aliases.get(e.name)), settings.actions.has(e.name) && this.emit("cursor", e.name)), t && (t.toLowerCase() === "y" || t.toLowerCase() === "n") && this.emit("confirm", t.toLowerCase() === "y"), this.emit("key", t, e), e?.name === "return" && this._shouldSubmit(t, e)) {
289
+ if (this.opts.validate) {
290
+ const i = runValidation(this.opts.validate, this.value);
291
+ i && (this.error = i instanceof Error ? i.message : i, this.state = "error", this.rl?.write(this.userInput));
292
+ }
293
+ this.state !== "error" && (this.state = "submit");
294
+ }
295
+ isActionKey([t, e?.name, e?.sequence], "cancel") && (this.state = "cancel"), (this.state === "submit" || this.state === "cancel") && this.emit("finalize"), this.render(), (this.state === "submit" || this.state === "cancel") && this.close();
296
+ }
297
+ close() {
298
+ this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
299
+ `), setRawMode(this.input, false), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
300
+ }
301
+ restoreCursor() {
302
+ const t = wrapAnsi(this._prevFrame, process.stdout.columns, { hard: true, trim: false }).split(`
303
+ `).length - 1;
304
+ this.output.write(cursor.move(-999, t * -1));
305
+ }
306
+ render() {
307
+ const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
308
+ hard: true,
309
+ trim: false
310
+ });
311
+ if (t !== this._prevFrame) {
312
+ if (this.state === "initial")
313
+ this.output.write(cursor.hide);
314
+ else {
315
+ const e = diffLines(this._prevFrame, t), i = getRows(this.output);
316
+ if (this.restoreCursor(), e) {
317
+ const n = Math.max(0, e.numLinesAfter - i), s = Math.max(0, e.numLinesBefore - i);
318
+ let r = e.lines.find((o) => o >= n);
319
+ if (r === void 0) {
320
+ this._prevFrame = t;
321
+ return;
322
+ }
323
+ if (e.lines.length === 1) {
324
+ this.output.write(cursor.move(0, r - s)), this.output.write(erase.lines(1));
325
+ const o = t.split(`
326
+ `);
327
+ this.output.write(o[r]), this._prevFrame = t, this.output.write(cursor.move(0, o.length - r - 1));
328
+ return;
329
+ } else if (e.lines.length > 1) {
330
+ if (n < s)
331
+ r = n;
332
+ else {
333
+ const h = r - s;
334
+ h > 0 && this.output.write(cursor.move(0, h));
335
+ }
336
+ this.output.write(erase.down());
337
+ const f = t.split(`
338
+ `).slice(r);
339
+ this.output.write(f.join(`
340
+ `)), this._prevFrame = t;
341
+ return;
342
+ }
343
+ }
344
+ this.output.write(erase.down());
345
+ }
346
+ this.output.write(t), this.state === "initial" && (this.state = "active"), this._prevFrame = t;
347
+ }
348
+ }
349
+ }
350
+
351
+ function p$1(l, e) {
352
+ if (l === void 0 || e.length === 0)
353
+ return 0;
354
+ const i = e.findIndex((s) => s.value === l);
355
+ return i !== -1 ? i : 0;
356
+ }
357
+ function g(l, e) {
358
+ return (e.label ?? String(e.value)).toLowerCase().includes(l.toLowerCase());
359
+ }
360
+ function m(l, e) {
361
+ if (e)
362
+ return l ? e : e[0];
363
+ }
364
+ let T$1 = class T extends V {
365
+ filteredOptions;
366
+ multiple;
367
+ isNavigating = false;
368
+ selectedValues = [];
369
+ focusedValue;
370
+ #e = 0;
371
+ #s = "";
372
+ #t;
373
+ #i;
374
+ #n;
375
+ get cursor() {
376
+ return this.#e;
377
+ }
378
+ get userInputWithCursor() {
379
+ if (!this.userInput)
380
+ return styleText(["inverse", "hidden"], "_");
381
+ if (this._cursor >= this.userInput.length)
382
+ return `${this.userInput}\u2588`;
383
+ const e = this.userInput.slice(0, this._cursor), [t, ...i] = this.userInput.slice(this._cursor);
384
+ return `${e}${styleText("inverse", t)}${i.join("")}`;
385
+ }
386
+ get options() {
387
+ return typeof this.#i == "function" ? this.#i() : this.#i;
388
+ }
389
+ constructor(e) {
390
+ super(e), this.#i = e.options, this.#n = e.placeholder;
391
+ const t = this.options;
392
+ this.filteredOptions = [...t], this.multiple = e.multiple === true, this.#t = typeof e.options == "function" ? e.filter : e.filter ?? g;
393
+ let i;
394
+ if (e.initialValue && Array.isArray(e.initialValue) ? this.multiple ? i = e.initialValue : i = e.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (i = [this.options[0].value]), i)
395
+ for (const s of i) {
396
+ const n = t.findIndex((o) => o.value === s);
397
+ n !== -1 && (this.toggleSelected(s), this.#e = n);
398
+ }
399
+ this.focusedValue = this.options[this.#e]?.value, this.on("key", (s, n) => this.#l(s, n)), this.on("userInput", (s) => this.#u(s));
400
+ }
401
+ _isActionKey(e, t) {
402
+ return e === " " || this.multiple && this.isNavigating && t.name === "space" && e !== void 0 && e !== "";
403
+ }
404
+ #l(e, t) {
405
+ const i = t.name === "up", s = t.name === "down", n = t.name === "return", o = this.userInput === "" || this.userInput === " ", u = this.#n, h = this.options, f = u !== void 0 && u !== "" && h.some(
406
+ (r) => !r.disabled && (this.#t ? this.#t(u, r) : true)
407
+ );
408
+ if (t.name === "tab" && o && f) {
409
+ this.userInput === " " && this._clearUserInput(), this._setUserInput(u, true), this.isNavigating = false;
410
+ return;
411
+ }
412
+ i || s ? (this.#e = findCursor(this.#e, i ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#e]?.value, this.multiple || (this.selectedValues = [this.focusedValue]), this.isNavigating = true) : n ? this.value = m(this.multiple, this.selectedValues) : this.multiple ? this.focusedValue !== void 0 && (t.name === "tab" || this.isNavigating && t.name === "space") ? this.toggleSelected(this.focusedValue) : this.isNavigating = false : (this.focusedValue && (this.selectedValues = [this.focusedValue]), this.isNavigating = false);
413
+ }
414
+ deselectAll() {
415
+ this.selectedValues = [];
416
+ }
417
+ toggleSelected(e) {
418
+ this.filteredOptions.length !== 0 && (this.multiple ? this.selectedValues.includes(e) ? this.selectedValues = this.selectedValues.filter((t) => t !== e) : this.selectedValues = [...this.selectedValues, e] : this.selectedValues = [e]);
419
+ }
420
+ #u(e) {
421
+ if (e !== this.#s) {
422
+ this.#s = e;
423
+ const t = this.options;
424
+ e && this.#t ? this.filteredOptions = t.filter((n) => this.#t?.(e, n)) : this.filteredOptions = [...t];
425
+ const i = p$1(this.focusedValue, this.filteredOptions);
426
+ this.#e = findCursor(i, 0, this.filteredOptions);
427
+ const s = this.filteredOptions[this.#e];
428
+ s && !s.disabled ? this.focusedValue = s.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
429
+ }
430
+ }
431
+ };
432
+
433
+ class r extends V {
434
+ get cursor() {
435
+ return this.value ? 0 : 1;
436
+ }
437
+ get _value() {
438
+ return this.cursor === 0;
439
+ }
440
+ constructor(t) {
441
+ super(t, false), this.value = !!t.initialValue, this.on("userInput", () => {
442
+ this.value = this._value;
443
+ }), this.on("confirm", (i) => {
444
+ this.output.write(cursor.move(0, -1)), this.value = i, this.state = "submit", this.close();
445
+ }), this.on("cursor", () => {
446
+ this.value = !this.value;
447
+ });
448
+ }
449
+ }
450
+
451
+ const _ = {
452
+ Y: { type: "year", len: 4 },
453
+ M: { type: "month", len: 2 },
454
+ D: { type: "day", len: 2 }
455
+ };
456
+ function M(r) {
457
+ return [...r].map((t) => _[t]);
458
+ }
459
+ function P(r) {
460
+ const i = new Intl.DateTimeFormat(r, {
461
+ year: "numeric",
462
+ month: "2-digit",
463
+ day: "2-digit"
464
+ }).formatToParts(new Date(2e3, 0, 15)), s = [];
465
+ let n = "/";
466
+ for (const e of i)
467
+ e.type === "literal" ? n = e.value.trim() || e.value : (e.type === "year" || e.type === "month" || e.type === "day") && s.push({ type: e.type, len: e.type === "year" ? 4 : 2 });
468
+ return { segments: s, separator: n };
469
+ }
470
+ function p(r) {
471
+ return Number.parseInt((r || "0").replace(/_/g, "0"), 10) || 0;
472
+ }
473
+ function f(r) {
474
+ return {
475
+ year: p(r.year),
476
+ month: p(r.month),
477
+ day: p(r.day)
478
+ };
479
+ }
480
+ function c(r, t) {
481
+ return new Date(r || 2001, t || 1, 0).getDate();
482
+ }
483
+ function b(r) {
484
+ const { year: t, month: i, day: s } = f(r);
485
+ if (!t || t < 0 || t > 9999 || !i || i < 1 || i > 12 || !s || s < 1) return;
486
+ const n = new Date(Date.UTC(t, i - 1, s));
487
+ if (!(n.getUTCFullYear() !== t || n.getUTCMonth() !== i - 1 || n.getUTCDate() !== s))
488
+ return { year: t, month: i, day: s };
489
+ }
490
+ function C(r) {
491
+ const t = b(r);
492
+ return t ? new Date(Date.UTC(t.year, t.month - 1, t.day)) : void 0;
493
+ }
494
+ function T(r, t, i, s) {
495
+ const n = i ? {
496
+ year: i.getUTCFullYear(),
497
+ month: i.getUTCMonth() + 1,
498
+ day: i.getUTCDate()
499
+ } : null, e = s ? {
500
+ year: s.getUTCFullYear(),
501
+ month: s.getUTCMonth() + 1,
502
+ day: s.getUTCDate()
503
+ } : null;
504
+ return r === "year" ? { min: n?.year ?? 1, max: e?.year ?? 9999 } : r === "month" ? {
505
+ min: n && t.year === n.year ? n.month : 1,
506
+ max: e && t.year === e.year ? e.month : 12
507
+ } : {
508
+ min: n && t.year === n.year && t.month === n.month ? n.day : 1,
509
+ max: e && t.year === e.year && t.month === e.month ? e.day : c(t.year, t.month)
510
+ };
511
+ }
512
+ class U extends V {
513
+ #i;
514
+ #o;
515
+ #t;
516
+ #h;
517
+ #u;
518
+ #e = { segmentIndex: 0, positionInSegment: 0 };
519
+ #n = true;
520
+ #s = null;
521
+ inlineError = "";
522
+ get segmentCursor() {
523
+ return { ...this.#e };
524
+ }
525
+ get segmentValues() {
526
+ return { ...this.#t };
527
+ }
528
+ get segments() {
529
+ return this.#i;
530
+ }
531
+ get separator() {
532
+ return this.#o;
533
+ }
534
+ get formattedValue() {
535
+ return this.#l(this.#t);
536
+ }
537
+ #l(t) {
538
+ return this.#i.map((i) => t[i.type]).join(this.#o);
539
+ }
540
+ #r() {
541
+ this._setUserInput(this.#l(this.#t)), this._setValue(C(this.#t) ?? void 0);
542
+ }
543
+ constructor(t) {
544
+ const i = t.format ? { segments: M(t.format), separator: t.separator ?? "/" } : P(t.locale), s = t.separator ?? i.separator, n = t.format ? M(t.format) : i.segments, e = t.initialValue ?? t.defaultValue, m = e ? {
545
+ year: String(e.getUTCFullYear()).padStart(4, "0"),
546
+ month: String(e.getUTCMonth() + 1).padStart(2, "0"),
547
+ day: String(e.getUTCDate()).padStart(2, "0")
548
+ } : { year: "____", month: "__", day: "__" }, o = n.map((a) => m[a.type]).join(s);
549
+ super({ ...t, initialUserInput: o }, false), this.#i = n, this.#o = s, this.#t = m, this.#h = t.minDate, this.#u = t.maxDate, this.#r(), this.on("cursor", (a) => this.#f(a)), this.on("key", (a, u) => this.#y(a, u)), this.on("finalize", () => this.#p(t));
550
+ }
551
+ #a() {
552
+ const t = Math.max(0, Math.min(this.#e.segmentIndex, this.#i.length - 1)), i = this.#i[t];
553
+ if (i)
554
+ return this.#e.positionInSegment = Math.max(
555
+ 0,
556
+ Math.min(this.#e.positionInSegment, i.len - 1)
557
+ ), { segment: i, index: t };
558
+ }
559
+ #m(t) {
560
+ this.inlineError = "", this.#s = null;
561
+ const i = this.#a();
562
+ i && (this.#e.segmentIndex = Math.max(
563
+ 0,
564
+ Math.min(this.#i.length - 1, i.index + t)
565
+ ), this.#e.positionInSegment = 0, this.#n = true);
566
+ }
567
+ #d(t) {
568
+ const i = this.#a();
569
+ if (!i) return;
570
+ const { segment: s } = i, n = this.#t[s.type], e = !n || n.replace(/_/g, "") === "", m = Number.parseInt((n || "0").replace(/_/g, "0"), 10) || 0, o = T(
571
+ s.type,
572
+ f(this.#t),
573
+ this.#h,
574
+ this.#u
575
+ );
576
+ let a;
577
+ e ? a = t === 1 ? o.min : o.max : a = Math.max(Math.min(o.max, m + t), o.min), this.#t = {
578
+ ...this.#t,
579
+ [s.type]: a.toString().padStart(s.len, "0")
580
+ }, this.#n = true, this.#s = null, this.#r();
581
+ }
582
+ #f(t) {
583
+ if (t)
584
+ switch (t) {
585
+ case "right":
586
+ return this.#m(1);
587
+ case "left":
588
+ return this.#m(-1);
589
+ case "up":
590
+ return this.#d(1);
591
+ case "down":
592
+ return this.#d(-1);
593
+ }
594
+ }
595
+ #y(t, i) {
596
+ if (i?.name === "backspace" || i?.sequence === "\x7F" || i?.sequence === "\b" || t === "\x7F" || t === "\b") {
597
+ this.inlineError = "";
598
+ const n = this.#a();
599
+ if (!n) return;
600
+ if (!this.#t[n.segment.type].replace(/_/g, "")) {
601
+ this.#m(-1);
602
+ return;
603
+ }
604
+ this.#t[n.segment.type] = "_".repeat(n.segment.len), this.#n = true, this.#e.positionInSegment = 0, this.#r();
605
+ return;
606
+ }
607
+ if (i?.name === "tab") {
608
+ this.inlineError = "";
609
+ const n = this.#a();
610
+ if (!n) return;
611
+ const e = i.shift ? -1 : 1, m = n.index + e;
612
+ m >= 0 && m < this.#i.length && (this.#e.segmentIndex = m, this.#e.positionInSegment = 0, this.#n = true);
613
+ return;
614
+ }
615
+ if (t && /^[0-9]$/.test(t)) {
616
+ const n = this.#a();
617
+ if (!n) return;
618
+ const { segment: e } = n, m = !this.#t[e.type].replace(/_/g, "");
619
+ if (this.#n && this.#s !== null && !m) {
620
+ const h = this.#s + t, d = { ...this.#t, [e.type]: h }, g = this.#g(d, e);
621
+ if (g) {
622
+ this.inlineError = g, this.#s = null, this.#n = false;
623
+ return;
624
+ }
625
+ this.inlineError = "", this.#t[e.type] = h, this.#s = null, this.#n = false, this.#r(), n.index < this.#i.length - 1 && (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true);
626
+ return;
627
+ }
628
+ this.#n && !m && (this.#t[e.type] = "_".repeat(e.len), this.#e.positionInSegment = 0), this.#n = false, this.#s = null;
629
+ const o = this.#t[e.type], a = o.indexOf("_"), u = a >= 0 ? a : Math.min(this.#e.positionInSegment, e.len - 1);
630
+ if (u < 0 || u >= e.len) return;
631
+ let l = o.slice(0, u) + t + o.slice(u + 1), D = false;
632
+ if (u === 0 && o === "__" && (e.type === "month" || e.type === "day")) {
633
+ const h = Number.parseInt(t, 10);
634
+ l = `0${t}`, D = h <= (e.type === "month" ? 1 : 2);
635
+ }
636
+ if (e.type === "year" && (l = (o.replace(/_/g, "") + t).padStart(e.len, "_")), !l.includes("_")) {
637
+ const h = { ...this.#t, [e.type]: l }, d = this.#g(h, e);
638
+ if (d) {
639
+ this.inlineError = d;
640
+ return;
641
+ }
642
+ }
643
+ this.inlineError = "", this.#t[e.type] = l;
644
+ const y = l.includes("_") ? void 0 : b(this.#t);
645
+ if (y) {
646
+ const { year: h, month: d } = y, g = c(h, d);
647
+ this.#t = {
648
+ year: String(Math.max(0, Math.min(9999, h))).padStart(4, "0"),
649
+ month: String(Math.max(1, Math.min(12, d))).padStart(2, "0"),
650
+ day: String(Math.max(1, Math.min(g, y.day))).padStart(2, "0")
651
+ };
652
+ }
653
+ this.#r();
654
+ const S = l.indexOf("_");
655
+ D ? (this.#n = true, this.#s = t) : S >= 0 ? this.#e.positionInSegment = S : a >= 0 && n.index < this.#i.length - 1 ? (this.#e.segmentIndex = n.index + 1, this.#e.positionInSegment = 0, this.#n = true) : this.#e.positionInSegment = Math.min(u + 1, e.len - 1);
656
+ }
657
+ }
658
+ #g(t, i) {
659
+ const { month: s, day: n } = f(t);
660
+ if (i.type === "month" && (s < 0 || s > 12))
661
+ return settings.date.messages.invalidMonth;
662
+ if (i.type === "day" && (n < 0 || n > 31))
663
+ return settings.date.messages.invalidDay(31, "any month");
664
+ }
665
+ #p(t) {
666
+ const { year: i, month: s, day: n } = f(this.#t);
667
+ if (i && s && n) {
668
+ const e = c(i, s);
669
+ this.#t = {
670
+ ...this.#t,
671
+ day: String(Math.min(n, e)).padStart(2, "0")
672
+ };
673
+ }
674
+ this.value = C(this.#t) ?? t.defaultValue ?? void 0;
675
+ }
676
+ }
677
+
678
+ let u$1 = class u extends V {
679
+ options;
680
+ cursor = 0;
681
+ #t;
682
+ getGroupItems(t) {
683
+ return this.options.filter((r) => r.group === t);
684
+ }
685
+ isGroupSelected(t) {
686
+ const r = this.getGroupItems(t), e = this.value;
687
+ return e === void 0 ? false : r.every((s) => e.includes(s.value));
688
+ }
689
+ toggleValue() {
690
+ const t = this.options[this.cursor];
691
+ if (this.value === void 0 && (this.value = []), t.group === true) {
692
+ const r = t.value, e = this.getGroupItems(r);
693
+ this.isGroupSelected(r) ? this.value = this.value.filter(
694
+ (s) => e.findIndex((i) => i.value === s) === -1
695
+ ) : this.value = [...this.value, ...e.map((s) => s.value)], this.value = Array.from(new Set(this.value));
696
+ } else {
697
+ const r = this.value.includes(t.value);
698
+ this.value = r ? this.value.filter((e) => e !== t.value) : [...this.value, t.value];
699
+ }
700
+ }
701
+ constructor(t) {
702
+ super(t, false);
703
+ const { options: r } = t;
704
+ this.#t = t.selectableGroups !== false, this.options = Object.entries(r).flatMap(([e, s]) => [
705
+ { value: e, group: true, label: e },
706
+ ...s.map((i) => ({ ...i, group: e }))
707
+ ]), this.value = [...t.initialValues ?? []], this.cursor = Math.max(
708
+ this.options.findIndex(({ value: e }) => e === t.cursorAt),
709
+ this.#t ? 0 : 1
710
+ ), this.on("cursor", (e) => {
711
+ switch (e) {
712
+ case "left":
713
+ case "up": {
714
+ this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1;
715
+ const s = this.options[this.cursor]?.group === true;
716
+ !this.#t && s && (this.cursor = this.cursor === 0 ? this.options.length - 1 : this.cursor - 1);
717
+ break;
718
+ }
719
+ case "down":
720
+ case "right": {
721
+ this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
722
+ const s = this.options[this.cursor]?.group === true;
723
+ !this.#t && s && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
724
+ break;
725
+ }
726
+ case "space":
727
+ this.toggleValue();
728
+ break;
729
+ }
730
+ });
731
+ }
732
+ };
733
+
734
+ const o$1 = /* @__PURE__ */ new Set(["up", "down", "left", "right"]);
735
+ class h extends V {
736
+ #s = false;
737
+ #t;
738
+ focused = "editor";
739
+ get userInputWithCursor() {
740
+ if (this.state === "submit")
741
+ return this.userInput;
742
+ const t = this.userInput;
743
+ if (this.cursor >= t.length)
744
+ return `${t}\u2588`;
745
+ const s = t.slice(0, this.cursor), r = t[this.cursor], e = t.slice(this.cursor + 1);
746
+ return r === `
747
+ ` ? `${s}\u2588
748
+ ${e}` : `${s}${styleText("inverse", r)}${e}`;
749
+ }
750
+ get cursor() {
751
+ return this._cursor;
752
+ }
753
+ #r(t) {
754
+ if (this.userInput.length === 0) {
755
+ this._setUserInput(t);
756
+ return;
757
+ }
758
+ this._setUserInput(
759
+ this.userInput.slice(0, this.cursor) + t + this.userInput.slice(this.cursor)
760
+ );
761
+ }
762
+ #i(t) {
763
+ const s = this.value ?? "";
764
+ switch (t) {
765
+ case "up":
766
+ this._cursor = findTextCursor(this._cursor, 0, -1, s);
767
+ return;
768
+ case "down":
769
+ this._cursor = findTextCursor(this._cursor, 0, 1, s);
770
+ return;
771
+ case "left":
772
+ this._cursor = findTextCursor(this._cursor, -1, 0, s);
773
+ return;
774
+ case "right":
775
+ this._cursor = findTextCursor(this._cursor, 1, 0, s);
776
+ return;
777
+ }
778
+ }
779
+ _shouldSubmit(t, s) {
780
+ if (this.#t)
781
+ return this.focused === "submit" ? true : (this.#r(`
782
+ `), this._cursor++, false);
783
+ const r = this.#s;
784
+ return this.#s = true, r ? (this.userInput[this.cursor - 1] === `
785
+ ` && (this._setUserInput(
786
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
787
+ ), this._cursor--), true) : (this.#r(`
788
+ `), this._cursor++, false);
789
+ }
790
+ constructor(t) {
791
+ super(t, false), this.#t = t.showSubmit ?? false, this.on("key", (s, r) => {
792
+ if (r?.name && o$1.has(r.name)) {
793
+ this.#i(r.name);
794
+ return;
795
+ }
796
+ if (s === " " && this.#t) {
797
+ this.focused = this.focused === "editor" ? "submit" : "editor";
798
+ return;
799
+ }
800
+ if (r?.name !== "return") {
801
+ if (this.#s = false, r?.name === "backspace" && this.cursor > 0) {
802
+ this._setUserInput(
803
+ this.userInput.slice(0, this.cursor - 1) + this.userInput.slice(this.cursor)
804
+ ), this._cursor--;
805
+ return;
806
+ }
807
+ if (r?.name === "delete" && this.cursor < this.userInput.length) {
808
+ this._setUserInput(
809
+ this.userInput.slice(0, this.cursor) + this.userInput.slice(this.cursor + 1)
810
+ );
811
+ return;
812
+ }
813
+ s && (this.#t && this.focused === "submit" && (this.focused = "editor"), this.#r(s ?? ""), this._cursor++);
814
+ }
815
+ }), this.on("userInput", (s) => {
816
+ this._setValue(s);
817
+ }), this.on("finalize", () => {
818
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
819
+ });
820
+ }
821
+ }
822
+
823
+ let a$1 = class a extends V {
824
+ options;
825
+ cursor = 0;
826
+ get _value() {
827
+ return this.options[this.cursor].value;
828
+ }
829
+ get _enabledOptions() {
830
+ return this.options.filter((e) => e.disabled !== true);
831
+ }
832
+ toggleAll() {
833
+ const e = this._enabledOptions, i = this.value !== void 0 && this.value.length === e.length;
834
+ this.value = i ? [] : e.map((t) => t.value);
835
+ }
836
+ toggleInvert() {
837
+ const e = this.value;
838
+ if (!e)
839
+ return;
840
+ const i = this._enabledOptions.filter((t) => !e.includes(t.value));
841
+ this.value = i.map((t) => t.value);
842
+ }
843
+ toggleValue() {
844
+ this.value === void 0 && (this.value = []);
845
+ const e = this.value.includes(this._value);
846
+ this.value = e ? this.value.filter((i) => i !== this._value) : [...this.value, this._value];
847
+ }
848
+ constructor(e) {
849
+ super(e, false), this.options = e.options, this.value = [...e.initialValues ?? []];
850
+ const i = Math.max(
851
+ this.options.findIndex(({ value: t }) => t === e.cursorAt),
852
+ 0
853
+ );
854
+ this.cursor = this.options[i].disabled ? findCursor(i, 1, this.options) : i, this.on("key", (t, l) => {
855
+ l.name === "a" && this.toggleAll(), l.name === "i" && this.toggleInvert();
856
+ }), this.on("cursor", (t) => {
857
+ switch (t) {
858
+ case "left":
859
+ case "up":
860
+ this.cursor = findCursor(this.cursor, -1, this.options);
861
+ break;
862
+ case "down":
863
+ case "right":
864
+ this.cursor = findCursor(this.cursor, 1, this.options);
865
+ break;
866
+ case "space":
867
+ this.toggleValue();
868
+ break;
869
+ }
870
+ });
871
+ }
872
+ };
873
+
874
+ class o extends V {
875
+ _mask = "\u2022";
876
+ get cursor() {
877
+ return this._cursor;
878
+ }
879
+ get masked() {
880
+ return this.userInput.replaceAll(/./g, this._mask);
881
+ }
882
+ get userInputWithCursor() {
883
+ if (this.state === "submit" || this.state === "cancel")
884
+ return this.masked;
885
+ const t = this.userInput;
886
+ if (this.cursor >= t.length)
887
+ return `${this.masked}${styleText(["inverse", "hidden"], "_")}`;
888
+ const s = this.masked, r = s.slice(0, this.cursor), e = s.slice(this.cursor);
889
+ return `${r}${styleText("inverse", e[0])}${e.slice(1)}`;
890
+ }
891
+ clear() {
892
+ this._clearUserInput();
893
+ }
894
+ constructor({ mask: t, ...s }) {
895
+ super(s), this._mask = t ?? "\u2022", this.on("userInput", (r) => {
896
+ this._setValue(r);
897
+ });
898
+ }
899
+ }
900
+
901
+ class a extends V {
902
+ options;
903
+ cursor = 0;
904
+ get _selectedValue() {
905
+ return this.options[this.cursor];
906
+ }
907
+ changeValue() {
908
+ this.value = this._selectedValue.value;
909
+ }
910
+ constructor(t) {
911
+ super(t, false), this.options = t.options;
912
+ const i = this.options.findIndex(({ value: s }) => s === t.initialValue), e = i === -1 ? 0 : i;
913
+ this.cursor = this.options[e].disabled ? findCursor(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (s) => {
914
+ switch (s) {
915
+ case "left":
916
+ case "up":
917
+ this.cursor = findCursor(this.cursor, -1, this.options);
918
+ break;
919
+ case "down":
920
+ case "right":
921
+ this.cursor = findCursor(this.cursor, 1, this.options);
922
+ break;
923
+ }
924
+ this.changeValue();
925
+ });
926
+ }
927
+ }
928
+
929
+ class u extends V {
930
+ options;
931
+ cursor = 0;
932
+ constructor(t) {
933
+ super(t, false), this.options = t.options;
934
+ const s = t.caseSensitive === true, i = this.options.map(({ value: [e] }) => s ? e : e?.toLowerCase());
935
+ this.cursor = Math.max(i.indexOf(t.initialValue), 0), this.on("key", (e) => {
936
+ if (!e)
937
+ return;
938
+ const o = s ? e : e.toLowerCase();
939
+ if (!i.includes(o))
940
+ return;
941
+ const n = this.options.find(({ value: [r] }) => s ? r === o : r?.toLowerCase() === o);
942
+ n && (this.value = n.value, this.state = "submit", this.emit("submit"));
943
+ });
944
+ }
945
+ }
946
+
947
+ class n extends V {
948
+ get userInputWithCursor() {
949
+ if (this.state === "submit")
950
+ return this.userInput;
951
+ const t = this.userInput;
952
+ if (this.cursor >= t.length)
953
+ return `${this.userInput}\u2588`;
954
+ const e = t.slice(0, this.cursor), [s, ...r] = t.slice(this.cursor);
955
+ return `${e}${styleText("inverse", s)}${r.join("")}`;
956
+ }
957
+ get cursor() {
958
+ return this._cursor;
959
+ }
960
+ constructor(t) {
961
+ super({
962
+ ...t,
963
+ initialUserInput: t.initialUserInput ?? t.initialValue
964
+ }), this.on("userInput", (e) => {
965
+ this._setValue(e);
966
+ }), this.on("finalize", () => {
967
+ this.value || (this.value = t.defaultValue), this.value === void 0 && (this.value = "");
968
+ });
969
+ }
970
+ }
971
+
972
+ export { T$1 as AutocompletePrompt, r as ConfirmPrompt, U as DatePrompt, u$1 as GroupMultiSelectPrompt, h as MultiLinePrompt, a$1 as MultiSelectPrompt, o as PasswordPrompt, V as Prompt, u as SelectKeyPrompt, a as SelectPrompt, n as TextPrompt, block, getColumns, getRows, isCancel, runValidation, settings, updateSettings, wrapTextWithPrefix };