pickier 0.1.58 → 0.1.60

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 (290) hide show
  1. package/dist/bin/cli.d.ts +1 -0
  2. package/dist/bin/cli.js +2 -2
  3. package/dist/chunk-0whyx3r0.js +2 -0
  4. package/dist/chunk-0xebhmpv.js +224 -0
  5. package/dist/chunk-6xy2rbcn.js +62 -0
  6. package/dist/chunk-9vc029ds.js +156 -0
  7. package/dist/chunk-av6brc0s.js +2 -0
  8. package/dist/chunk-ha0tzyp8.js +2 -0
  9. package/dist/chunk-j0sjsw8n.js +33 -0
  10. package/dist/chunk-k110gscx.js +3 -0
  11. package/dist/chunk-ymb49mab.js +2 -0
  12. package/dist/src/index.js +1 -1
  13. package/dist/{rules → src/rules}/lockfile/parser.d.ts +12 -6
  14. package/package.json +3 -3
  15. package/dist/chunk-3wr40yqq.js +0 -2
  16. package/dist/chunk-720xck77.js +0 -2
  17. package/dist/chunk-8s8z5cnd.js +0 -2
  18. package/dist/chunk-ah6h41gy.js +0 -62
  19. package/dist/chunk-er69kh4d.js +0 -33
  20. package/dist/chunk-f0bqgs43.js +0 -2
  21. package/dist/chunk-fy0z5sp8.js +0 -224
  22. package/dist/chunk-q19vbsae.js +0 -3
  23. package/dist/chunk-v1x7hdmp.js +0 -156
  24. /package/dist/{chunk-43fsk0jg.js → chunk-cfytsdab.js} +0 -0
  25. /package/dist/{ast.d.ts → src/ast.d.ts} +0 -0
  26. /package/dist/{config.d.ts → src/config.d.ts} +0 -0
  27. /package/dist/{format.d.ts → src/format.d.ts} +0 -0
  28. /package/dist/{formatter.d.ts → src/formatter.d.ts} +0 -0
  29. /package/dist/{index.d.ts → src/index.d.ts} +0 -0
  30. /package/dist/{linter.d.ts → src/linter.d.ts} +0 -0
  31. /package/dist/{plugins → src/plugins}/eslint.d.ts +0 -0
  32. /package/dist/{plugins → src/plugins}/general.d.ts +0 -0
  33. /package/dist/{plugins → src/plugins}/index.d.ts +0 -0
  34. /package/dist/{plugins → src/plugins}/lockfile.d.ts +0 -0
  35. /package/dist/{plugins → src/plugins}/markdown.d.ts +0 -0
  36. /package/dist/{plugins → src/plugins}/node.d.ts +0 -0
  37. /package/dist/{plugins → src/plugins}/perfectionist.d.ts +0 -0
  38. /package/dist/{plugins → src/plugins}/pickier.d.ts +0 -0
  39. /package/dist/{plugins → src/plugins}/publint.d.ts +0 -0
  40. /package/dist/{plugins → src/plugins}/quality.d.ts +0 -0
  41. /package/dist/{plugins → src/plugins}/regexp.d.ts +0 -0
  42. /package/dist/{plugins → src/plugins}/shell.d.ts +0 -0
  43. /package/dist/{plugins → src/plugins}/spell.d.ts +0 -0
  44. /package/dist/{plugins → src/plugins}/style.d.ts +0 -0
  45. /package/dist/{plugins → src/plugins}/ts.d.ts +0 -0
  46. /package/dist/{plugins → src/plugins}/unused-imports.d.ts +0 -0
  47. /package/dist/{plugins → src/plugins}/utils.d.ts +0 -0
  48. /package/dist/{rules → src/rules}/general/_template-tracking.d.ts +0 -0
  49. /package/dist/{rules → src/rules}/general/array-callback-return.d.ts +0 -0
  50. /package/dist/{rules → src/rules}/general/constructor-super.d.ts +0 -0
  51. /package/dist/{rules → src/rules}/general/for-direction.d.ts +0 -0
  52. /package/dist/{rules → src/rules}/general/getter-return.d.ts +0 -0
  53. /package/dist/{rules → src/rules}/general/no-async-promise-executor.d.ts +0 -0
  54. /package/dist/{rules → src/rules}/general/no-compare-neg-zero.d.ts +0 -0
  55. /package/dist/{rules → src/rules}/general/no-cond-assign.d.ts +0 -0
  56. /package/dist/{rules → src/rules}/general/no-const-assign.d.ts +0 -0
  57. /package/dist/{rules → src/rules}/general/no-constant-condition.d.ts +0 -0
  58. /package/dist/{rules → src/rules}/general/no-constructor-return.d.ts +0 -0
  59. /package/dist/{rules → src/rules}/general/no-dupe-class-members.d.ts +0 -0
  60. /package/dist/{rules → src/rules}/general/no-dupe-keys.d.ts +0 -0
  61. /package/dist/{rules → src/rules}/general/no-duplicate-case.d.ts +0 -0
  62. /package/dist/{rules → src/rules}/general/no-empty-pattern.d.ts +0 -0
  63. /package/dist/{rules → src/rules}/general/no-fallthrough.d.ts +0 -0
  64. /package/dist/{rules → src/rules}/general/no-irregular-whitespace.d.ts +0 -0
  65. /package/dist/{rules → src/rules}/general/no-loss-of-precision.d.ts +0 -0
  66. /package/dist/{rules → src/rules}/general/no-new.d.ts +0 -0
  67. /package/dist/{rules → src/rules}/general/no-promise-executor-return.d.ts +0 -0
  68. /package/dist/{rules → src/rules}/general/no-redeclare.d.ts +0 -0
  69. /package/dist/{rules → src/rules}/general/no-regex-spaces.d.ts +0 -0
  70. /package/dist/{rules → src/rules}/general/no-self-assign.d.ts +0 -0
  71. /package/dist/{rules → src/rules}/general/no-self-compare.d.ts +0 -0
  72. /package/dist/{rules → src/rules}/general/no-sparse-arrays.d.ts +0 -0
  73. /package/dist/{rules → src/rules}/general/no-undef.d.ts +0 -0
  74. /package/dist/{rules → src/rules}/general/no-unreachable.d.ts +0 -0
  75. /package/dist/{rules → src/rules}/general/no-unsafe-negation.d.ts +0 -0
  76. /package/dist/{rules → src/rules}/general/no-unused-vars.d.ts +0 -0
  77. /package/dist/{rules → src/rules}/general/no-useless-catch.d.ts +0 -0
  78. /package/dist/{rules → src/rules}/general/prefer-const.d.ts +0 -0
  79. /package/dist/{rules → src/rules}/general/prefer-object-spread.d.ts +0 -0
  80. /package/dist/{rules → src/rules}/general/prefer-template.d.ts +0 -0
  81. /package/dist/{rules → src/rules}/general/use-isnan.d.ts +0 -0
  82. /package/dist/{rules → src/rules}/general/valid-typeof.d.ts +0 -0
  83. /package/dist/{rules → src/rules}/imports/first.d.ts +0 -0
  84. /package/dist/{rules → src/rules}/imports/import-dedupe.d.ts +0 -0
  85. /package/dist/{rules → src/rules}/imports/named.d.ts +0 -0
  86. /package/dist/{rules → src/rules}/imports/no-cycle.d.ts +0 -0
  87. /package/dist/{rules → src/rules}/imports/no-duplicate-imports.d.ts +0 -0
  88. /package/dist/{rules → src/rules}/imports/no-import-dist.d.ts +0 -0
  89. /package/dist/{rules → src/rules}/imports/no-import-node-modules-by-path.d.ts +0 -0
  90. /package/dist/{rules → src/rules}/imports/no-unresolved.d.ts +0 -0
  91. /package/dist/{rules → src/rules}/lockfile/validate-host.d.ts +0 -0
  92. /package/dist/{rules → src/rules}/lockfile/validate-https.d.ts +0 -0
  93. /package/dist/{rules → src/rules}/lockfile/validate-integrity.d.ts +0 -0
  94. /package/dist/{rules → src/rules}/lockfile/validate-package-names.d.ts +0 -0
  95. /package/dist/{rules → src/rules}/lockfile/validate-scheme.d.ts +0 -0
  96. /package/dist/{rules → src/rules}/markdown/_fence-tracking.d.ts +0 -0
  97. /package/dist/{rules → src/rules}/markdown/_shared.d.ts +0 -0
  98. /package/dist/{rules → src/rules}/markdown/blanks-around-fences.d.ts +0 -0
  99. /package/dist/{rules → src/rules}/markdown/blanks-around-headings.d.ts +0 -0
  100. /package/dist/{rules → src/rules}/markdown/blanks-around-lists.d.ts +0 -0
  101. /package/dist/{rules → src/rules}/markdown/blanks-around-tables.d.ts +0 -0
  102. /package/dist/{rules → src/rules}/markdown/code-block-style.d.ts +0 -0
  103. /package/dist/{rules → src/rules}/markdown/code-fence-style.d.ts +0 -0
  104. /package/dist/{rules → src/rules}/markdown/commands-show-output.d.ts +0 -0
  105. /package/dist/{rules → src/rules}/markdown/descriptive-link-text.d.ts +0 -0
  106. /package/dist/{rules → src/rules}/markdown/emphasis-style.d.ts +0 -0
  107. /package/dist/{rules → src/rules}/markdown/fenced-code-language.d.ts +0 -0
  108. /package/dist/{rules → src/rules}/markdown/first-line-heading.d.ts +0 -0
  109. /package/dist/{rules → src/rules}/markdown/heading-increment.d.ts +0 -0
  110. /package/dist/{rules → src/rules}/markdown/heading-start-left.d.ts +0 -0
  111. /package/dist/{rules → src/rules}/markdown/heading-style.d.ts +0 -0
  112. /package/dist/{rules → src/rules}/markdown/hr-style.d.ts +0 -0
  113. /package/dist/{rules → src/rules}/markdown/line-length.d.ts +0 -0
  114. /package/dist/{rules → src/rules}/markdown/link-fragments.d.ts +0 -0
  115. /package/dist/{rules → src/rules}/markdown/link-image-reference-definitions.d.ts +0 -0
  116. /package/dist/{rules → src/rules}/markdown/link-image-style.d.ts +0 -0
  117. /package/dist/{rules → src/rules}/markdown/list-indent.d.ts +0 -0
  118. /package/dist/{rules → src/rules}/markdown/list-marker-space.d.ts +0 -0
  119. /package/dist/{rules → src/rules}/markdown/no-alt-text.d.ts +0 -0
  120. /package/dist/{rules → src/rules}/markdown/no-bare-urls.d.ts +0 -0
  121. /package/dist/{rules → src/rules}/markdown/no-blanks-blockquote.d.ts +0 -0
  122. /package/dist/{rules → src/rules}/markdown/no-duplicate-heading.d.ts +0 -0
  123. /package/dist/{rules → src/rules}/markdown/no-emphasis-as-heading.d.ts +0 -0
  124. /package/dist/{rules → src/rules}/markdown/no-empty-links.d.ts +0 -0
  125. /package/dist/{rules → src/rules}/markdown/no-hard-tabs.d.ts +0 -0
  126. /package/dist/{rules → src/rules}/markdown/no-inline-html.d.ts +0 -0
  127. /package/dist/{rules → src/rules}/markdown/no-missing-space-atx.d.ts +0 -0
  128. /package/dist/{rules → src/rules}/markdown/no-missing-space-closed-atx.d.ts +0 -0
  129. /package/dist/{rules → src/rules}/markdown/no-multiple-blanks.d.ts +0 -0
  130. /package/dist/{rules → src/rules}/markdown/no-multiple-space-atx.d.ts +0 -0
  131. /package/dist/{rules → src/rules}/markdown/no-multiple-space-blockquote.d.ts +0 -0
  132. /package/dist/{rules → src/rules}/markdown/no-multiple-space-closed-atx.d.ts +0 -0
  133. /package/dist/{rules → src/rules}/markdown/no-reversed-links.d.ts +0 -0
  134. /package/dist/{rules → src/rules}/markdown/no-space-in-code.d.ts +0 -0
  135. /package/dist/{rules → src/rules}/markdown/no-space-in-emphasis.d.ts +0 -0
  136. /package/dist/{rules → src/rules}/markdown/no-space-in-links.d.ts +0 -0
  137. /package/dist/{rules → src/rules}/markdown/no-trailing-punctuation.d.ts +0 -0
  138. /package/dist/{rules → src/rules}/markdown/no-trailing-spaces.d.ts +0 -0
  139. /package/dist/{rules → src/rules}/markdown/ol-prefix.d.ts +0 -0
  140. /package/dist/{rules → src/rules}/markdown/proper-names.d.ts +0 -0
  141. /package/dist/{rules → src/rules}/markdown/reference-links-images.d.ts +0 -0
  142. /package/dist/{rules → src/rules}/markdown/required-headings.d.ts +0 -0
  143. /package/dist/{rules → src/rules}/markdown/single-title.d.ts +0 -0
  144. /package/dist/{rules → src/rules}/markdown/single-trailing-newline.d.ts +0 -0
  145. /package/dist/{rules → src/rules}/markdown/strong-style.d.ts +0 -0
  146. /package/dist/{rules → src/rules}/markdown/table-column-count.d.ts +0 -0
  147. /package/dist/{rules → src/rules}/markdown/table-column-style.d.ts +0 -0
  148. /package/dist/{rules → src/rules}/markdown/table-pipe-style.d.ts +0 -0
  149. /package/dist/{rules → src/rules}/markdown/ul-indent.d.ts +0 -0
  150. /package/dist/{rules → src/rules}/markdown/ul-style.d.ts +0 -0
  151. /package/dist/{rules → src/rules}/node/prefer-global-buffer.d.ts +0 -0
  152. /package/dist/{rules → src/rules}/node/prefer-global-process.d.ts +0 -0
  153. /package/dist/{rules → src/rules}/quality/complexity.d.ts +0 -0
  154. /package/dist/{rules → src/rules}/quality/default-case.d.ts +0 -0
  155. /package/dist/{rules → src/rules}/quality/eqeqeq.d.ts +0 -0
  156. /package/dist/{rules → src/rules}/quality/max-depth.d.ts +0 -0
  157. /package/dist/{rules → src/rules}/quality/max-lines-per-function.d.ts +0 -0
  158. /package/dist/{rules → src/rules}/quality/no-alert.d.ts +0 -0
  159. /package/dist/{rules → src/rules}/quality/no-await-in-loop.d.ts +0 -0
  160. /package/dist/{rules → src/rules}/quality/no-caller.d.ts +0 -0
  161. /package/dist/{rules → src/rules}/quality/no-case-declarations.d.ts +0 -0
  162. /package/dist/{rules → src/rules}/quality/no-else-return.d.ts +0 -0
  163. /package/dist/{rules → src/rules}/quality/no-empty-function.d.ts +0 -0
  164. /package/dist/{rules → src/rules}/quality/no-empty.d.ts +0 -0
  165. /package/dist/{rules → src/rules}/quality/no-eval.d.ts +0 -0
  166. /package/dist/{rules → src/rules}/quality/no-extend-native.d.ts +0 -0
  167. /package/dist/{rules → src/rules}/quality/no-extra-boolean-cast.d.ts +0 -0
  168. /package/dist/{rules → src/rules}/quality/no-global-assign.d.ts +0 -0
  169. /package/dist/{rules → src/rules}/quality/no-implied-eval.d.ts +0 -0
  170. /package/dist/{rules → src/rules}/quality/no-iterator.d.ts +0 -0
  171. /package/dist/{rules → src/rules}/quality/no-lonely-if.d.ts +0 -0
  172. /package/dist/{rules → src/rules}/quality/no-new-func.d.ts +0 -0
  173. /package/dist/{rules → src/rules}/quality/no-new-wrappers.d.ts +0 -0
  174. /package/dist/{rules → src/rules}/quality/no-new.d.ts +0 -0
  175. /package/dist/{rules → src/rules}/quality/no-octal.d.ts +0 -0
  176. /package/dist/{rules → src/rules}/quality/no-param-reassign.d.ts +0 -0
  177. /package/dist/{rules → src/rules}/quality/no-proto.d.ts +0 -0
  178. /package/dist/{rules → src/rules}/quality/no-return-assign.d.ts +0 -0
  179. /package/dist/{rules → src/rules}/quality/no-sequences.d.ts +0 -0
  180. /package/dist/{rules → src/rules}/quality/no-shadow.d.ts +0 -0
  181. /package/dist/{rules → src/rules}/quality/no-throw-literal.d.ts +0 -0
  182. /package/dist/{rules → src/rules}/quality/no-use-before-define.d.ts +0 -0
  183. /package/dist/{rules → src/rules}/quality/no-useless-call.d.ts +0 -0
  184. /package/dist/{rules → src/rules}/quality/no-useless-concat.d.ts +0 -0
  185. /package/dist/{rules → src/rules}/quality/no-useless-escape.d.ts +0 -0
  186. /package/dist/{rules → src/rules}/quality/no-useless-rename.d.ts +0 -0
  187. /package/dist/{rules → src/rules}/quality/no-useless-return.d.ts +0 -0
  188. /package/dist/{rules → src/rules}/quality/no-var.d.ts +0 -0
  189. /package/dist/{rules → src/rules}/quality/no-with.d.ts +0 -0
  190. /package/dist/{rules → src/rules}/quality/prefer-arrow-callback.d.ts +0 -0
  191. /package/dist/{rules → src/rules}/quality/require-await.d.ts +0 -0
  192. /package/dist/{rules → src/rules}/regexp/no-super-linear-backtracking.d.ts +0 -0
  193. /package/dist/{rules → src/rules}/regexp/no-unused-capturing-group.d.ts +0 -0
  194. /package/dist/{rules → src/rules}/regexp/no-useless-lazy.d.ts +0 -0
  195. /package/dist/{rules → src/rules}/shell/_shared.d.ts +0 -0
  196. /package/dist/{rules → src/rules}/shell/command-substitution.d.ts +0 -0
  197. /package/dist/{rules → src/rules}/shell/consistent-case-terminators.d.ts +0 -0
  198. /package/dist/{rules → src/rules}/shell/function-style.d.ts +0 -0
  199. /package/dist/{rules → src/rules}/shell/heredoc-indent.d.ts +0 -0
  200. /package/dist/{rules → src/rules}/shell/indent.d.ts +0 -0
  201. /package/dist/{rules → src/rules}/shell/keyword-spacing.d.ts +0 -0
  202. /package/dist/{rules → src/rules}/shell/no-broken-redirect.d.ts +0 -0
  203. /package/dist/{rules → src/rules}/shell/no-cd-without-check.d.ts +0 -0
  204. /package/dist/{rules → src/rules}/shell/no-eval.d.ts +0 -0
  205. /package/dist/{rules → src/rules}/shell/no-exit-in-subshell.d.ts +0 -0
  206. /package/dist/{rules → src/rules}/shell/no-ls-parsing.d.ts +0 -0
  207. /package/dist/{rules → src/rules}/shell/no-trailing-semicolons.d.ts +0 -0
  208. /package/dist/{rules → src/rules}/shell/no-trailing-whitespace.d.ts +0 -0
  209. /package/dist/{rules → src/rules}/shell/no-useless-cat.d.ts +0 -0
  210. /package/dist/{rules → src/rules}/shell/no-variable-in-single-quotes.d.ts +0 -0
  211. /package/dist/{rules → src/rules}/shell/operator-spacing.d.ts +0 -0
  212. /package/dist/{rules → src/rules}/shell/prefer-double-brackets.d.ts +0 -0
  213. /package/dist/{rules → src/rules}/shell/prefer-printf.d.ts +0 -0
  214. /package/dist/{rules → src/rules}/shell/quote-variables.d.ts +0 -0
  215. /package/dist/{rules → src/rules}/shell/set-options.d.ts +0 -0
  216. /package/dist/{rules → src/rules}/shell/shebang.d.ts +0 -0
  217. /package/dist/{rules → src/rules}/sort/exports.d.ts +0 -0
  218. /package/dist/{rules → src/rules}/sort/heritage-clauses.d.ts +0 -0
  219. /package/dist/{rules → src/rules}/sort/imports.d.ts +0 -0
  220. /package/dist/{rules → src/rules}/sort/keys.d.ts +0 -0
  221. /package/dist/{rules → src/rules}/sort/named-imports.d.ts +0 -0
  222. /package/dist/{rules → src/rules}/sort/objects.d.ts +0 -0
  223. /package/dist/{rules → src/rules}/sort/tailwind-classes.d.ts +0 -0
  224. /package/dist/{rules → src/rules}/style/array-bracket-spacing.d.ts +0 -0
  225. /package/dist/{rules → src/rules}/style/arrow-parens.d.ts +0 -0
  226. /package/dist/{rules → src/rules}/style/arrow-spacing.d.ts +0 -0
  227. /package/dist/{rules → src/rules}/style/block-spacing.d.ts +0 -0
  228. /package/dist/{rules → src/rules}/style/brace-style.d.ts +0 -0
  229. /package/dist/{rules → src/rules}/style/comma-dangle.d.ts +0 -0
  230. /package/dist/{rules → src/rules}/style/comma-spacing.d.ts +0 -0
  231. /package/dist/{rules → src/rules}/style/comma-style.d.ts +0 -0
  232. /package/dist/{rules → src/rules}/style/computed-property-spacing.d.ts +0 -0
  233. /package/dist/{rules → src/rules}/style/consistent-chaining.d.ts +0 -0
  234. /package/dist/{rules → src/rules}/style/consistent-list-newline.d.ts +0 -0
  235. /package/dist/{rules → src/rules}/style/curly.d.ts +0 -0
  236. /package/dist/{rules → src/rules}/style/dot-location.d.ts +0 -0
  237. /package/dist/{rules → src/rules}/style/function-call-spacing.d.ts +0 -0
  238. /package/dist/{rules → src/rules}/style/generator-star-spacing.d.ts +0 -0
  239. /package/dist/{rules → src/rules}/style/if-newline.d.ts +0 -0
  240. /package/dist/{rules → src/rules}/style/indent-binary-ops.d.ts +0 -0
  241. /package/dist/{rules → src/rules}/style/indent-unindent.d.ts +0 -0
  242. /package/dist/{rules → src/rules}/style/key-spacing.d.ts +0 -0
  243. /package/dist/{rules → src/rules}/style/keyword-spacing.d.ts +0 -0
  244. /package/dist/{rules → src/rules}/style/lines-between-class-members.d.ts +0 -0
  245. /package/dist/{rules → src/rules}/style/max-statements-per-line.d.ts +0 -0
  246. /package/dist/{rules → src/rules}/style/multiline-ternary.d.ts +0 -0
  247. /package/dist/{rules → src/rules}/style/new-parens.d.ts +0 -0
  248. /package/dist/{rules → src/rules}/style/no-extra-parens.d.ts +0 -0
  249. /package/dist/{rules → src/rules}/style/no-floating-decimal.d.ts +0 -0
  250. /package/dist/{rules → src/rules}/style/no-mixed-operators.d.ts +0 -0
  251. /package/dist/{rules → src/rules}/style/no-mixed-spaces-and-tabs.d.ts +0 -0
  252. /package/dist/{rules → src/rules}/style/no-multi-spaces.d.ts +0 -0
  253. /package/dist/{rules → src/rules}/style/no-multiple-empty-lines.d.ts +0 -0
  254. /package/dist/{rules → src/rules}/style/no-tabs.d.ts +0 -0
  255. /package/dist/{rules → src/rules}/style/no-trailing-spaces.d.ts +0 -0
  256. /package/dist/{rules → src/rules}/style/no-whitespace-before-property.d.ts +0 -0
  257. /package/dist/{rules → src/rules}/style/object-curly-spacing.d.ts +0 -0
  258. /package/dist/{rules → src/rules}/style/operator-linebreak.d.ts +0 -0
  259. /package/dist/{rules → src/rules}/style/padded-blocks.d.ts +0 -0
  260. /package/dist/{rules → src/rules}/style/quote-props.d.ts +0 -0
  261. /package/dist/{rules → src/rules}/style/rest-spread-spacing.d.ts +0 -0
  262. /package/dist/{rules → src/rules}/style/semi-spacing.d.ts +0 -0
  263. /package/dist/{rules → src/rules}/style/space-before-blocks.d.ts +0 -0
  264. /package/dist/{rules → src/rules}/style/space-before-function-paren.d.ts +0 -0
  265. /package/dist/{rules → src/rules}/style/space-in-parens.d.ts +0 -0
  266. /package/dist/{rules → src/rules}/style/space-infix-ops.d.ts +0 -0
  267. /package/dist/{rules → src/rules}/style/space-unary-ops.d.ts +0 -0
  268. /package/dist/{rules → src/rules}/style/spaced-comment.d.ts +0 -0
  269. /package/dist/{rules → src/rules}/style/switch-colon-spacing.d.ts +0 -0
  270. /package/dist/{rules → src/rules}/style/template-curly-spacing.d.ts +0 -0
  271. /package/dist/{rules → src/rules}/style/template-tag-spacing.d.ts +0 -0
  272. /package/dist/{rules → src/rules}/style/top-level-function.d.ts +0 -0
  273. /package/dist/{rules → src/rules}/style/wrap-iife.d.ts +0 -0
  274. /package/dist/{rules → src/rules}/style/yield-star-spacing.d.ts +0 -0
  275. /package/dist/{rules → src/rules}/ts/member-delimiter-style.d.ts +0 -0
  276. /package/dist/{rules → src/rules}/ts/no-explicit-any.d.ts +0 -0
  277. /package/dist/{rules → src/rules}/ts/no-floating-promises.d.ts +0 -0
  278. /package/dist/{rules → src/rules}/ts/no-misused-promises.d.ts +0 -0
  279. /package/dist/{rules → src/rules}/ts/no-require-imports.d.ts +0 -0
  280. /package/dist/{rules → src/rules}/ts/no-top-level-await.d.ts +0 -0
  281. /package/dist/{rules → src/rules}/ts/no-ts-export-equal.d.ts +0 -0
  282. /package/dist/{rules → src/rules}/ts/no-unsafe-assignment.d.ts +0 -0
  283. /package/dist/{rules → src/rules}/ts/prefer-nullish-coalescing.d.ts +0 -0
  284. /package/dist/{rules → src/rules}/ts/prefer-optional-chain.d.ts +0 -0
  285. /package/dist/{rules → src/rules}/ts/type-annotation-spacing.d.ts +0 -0
  286. /package/dist/{rules → src/rules}/ts/type-generic-spacing.d.ts +0 -0
  287. /package/dist/{rules → src/rules}/ts/type-named-tuple-spacing.d.ts +0 -0
  288. /package/dist/{run.d.ts → src/run.d.ts} +0 -0
  289. /package/dist/{types.d.ts → src/types.d.ts} +0 -0
  290. /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
@@ -0,0 +1,224 @@
1
+ // @bun
2
+ import{C as se,E as Bt,F as jt,G as yr,H as tt,I as Ut,i as De,j as Se,k as Us,l as Jf,m as gr,n as Ti,o as hr,p as et,r as Oe,t as ot,u as Yf}from"./chunk-j0sjsw8n.js";import{N as Fe}from"./chunk-cfytsdab.js";import{readdirSync as Xf,readFileSync as Qf,statSync as qs,writeFileSync as pr}from"fs";import{isAbsolute as It,join as em,relative as zs,resolve as vt,sep as tm}from"path";import{existsSync as kr,statSync as $r}from"fs";import{existsSync as fi,mkdirSync as mm,readdirSync as hm,writeFileSync as dm}from"fs";import{homedir as ct}from"os";import{dirname as Pr,resolve as Ce}from"path";import nt from"process";import{join as pm,relative as gm,resolve as Ir}from"path";import an from"process";import{existsSync as lo,mkdirSync as wg,readdirSync as Rg,writeFileSync as kg}from"fs";import{homedir as Hs}from"os";import{dirname as Ig,resolve as Me}from"path";import Et from"process";import{join as ym,relative as bm,resolve as vr}from"path";import cn from"process";import{existsSync as ao,mkdirSync as Eg,readdirSync as Lg,writeFileSync as Tg}from"fs";import{dirname as Og,resolve as un}from"path";import mi from"process";import{Buffer as Ge}from"buffer";import{createCipheriv as xm,createDecipheriv as wm,randomBytes as Zs}from"crypto";import{closeSync as Gs,createReadStream as Mr,createWriteStream as Rm,existsSync as Js,fsyncSync as Cr,openSync as Sr,writeFileSync as km}from"fs";import{access as $m,constants as Er,mkdir as Pm,readdir as Kt,rename as Lr,stat as ut,unlink as Vt,writeFile as Ys}from"fs/promises";import{join as ft}from"path";import $e from"process";import{pipeline as Im}from"stream/promises";import{createGzip as Tr}from"zlib";import mt from"process";import qe from"process";import{Buffer as Ue}from"buffer";import{createCipheriv as vm,createDecipheriv as Mm,randomBytes as Xs}from"crypto";import{closeSync as Qs,createReadStream as Ar,createWriteStream as Cm,existsSync as Ht,fsyncSync as Or,openSync as _r,writeFileSync as Sm}from"fs";import{access as Em,constants as Dr,mkdir as Lm,readdir as Zt,rename as Fr,stat as ht,unlink as Gt,writeFile as ei}from"fs/promises";import{isAbsolute as Tm,join as dt,resolve as Am}from"path";import ie from"process";import{pipeline as Om}from"stream/promises";import{createGzip as Nr}from"zlib";import pt from"process";import Ke from"process";import Jt from"process";import{existsSync as Yt}from"fs";import{resolve as ti}from"path";import{existsSync as _m}from"fs";import{existsSync as Dm,readdirSync as Fm}from"fs";import{extname as ni,resolve as Wr}from"path";import Nm from"process";import{join as Wh,relative as Bh,resolve as Yr}from"path";import yn from"process";import{Buffer as ze}from"buffer";import{createCipheriv as zh,createDecipheriv as qh,randomBytes as li}from"crypto";import{closeSync as ai,createReadStream as Xr,createWriteStream as Kh,existsSync as Qt,fsyncSync as Qr,openSync as eo,writeFileSync as Vh}from"fs";import{access as Hh,constants as to,mkdir as Zh,readdir as en,rename as no,stat as gt,unlink as tn,writeFile as ci}from"fs/promises";import{isAbsolute as Gh,join as yt,resolve as Jh}from"path";import re from"process";import{pipeline as Yh}from"stream/promises";import{createGzip as so}from"zlib";import bt from"process";import Ve from"process";var lm=Object.defineProperty;var am=(e)=>e;function cm(e,n){this[e]=am.bind(null,n)}var um=(e,n)=>{for(var t in n)lm(e,t,{get:n[t],enumerable:!0,configurable:!0,set:cm.bind(n,t)})},fm=(e,n)=>()=>(e&&(n=e(e=0)),n);var oo={};um(oo,{withErrorRecovery:()=>fo,tryLoadConfig:()=>lh,loadConfigWithResult:()=>rh,loadConfig:()=>yo,isRetryableError:()=>Qm,isConfigNotFoundError:()=>Xm,isBunfigError:()=>mo,globalPerformanceMonitor:()=>At,globalCache:()=>xt,getEnvOrDefault:()=>eh,generateConfigTypes:()=>ah,defaultGeneratedDir:()=>Io,defaultConfigDir:()=>Po,deepMergeWithArrayStrategy:()=>vi,deepMerge:()=>ho,createLibraryConfig:()=>ch,config:()=>oh,bunfigPlugin:()=>uh,applyEnvVarsToConfig:()=>St,TypeGenerationError:()=>xi,SchemaValidationError:()=>Tt,PluginError:()=>Ri,PerformanceMonitor:()=>$i,FileSystemError:()=>bi,ErrorFactory:()=>Je,EnvVarError:()=>gn,EnvProcessor:()=>xn,ConfigValidator:()=>Mi,ConfigValidationError:()=>gi,ConfigNotFoundError:()=>pn,ConfigMergeError:()=>yi,ConfigLoader:()=>Ci,ConfigLoadError:()=>Lt,ConfigFileLoader:()=>wn,ConfigCache:()=>ki,CacheUtils:()=>xo,BunfigError:()=>Ee,BrowserConfigError:()=>wi,ArrayMergeStrategies:()=>ko});class ki{cache=new Map;totalHits=0;totalMisses=0;options;constructor(e={}){this.options={enabled:!0,ttl:300000,maxSize:100,keyPrefix:"bunfig:",...e}}generateKey(e,n){let t=n?`:${n}`:"";return`${this.options.keyPrefix}${e}${t}`}isExpired(e){return Date.now()-e.timestamp.getTime()>e.ttl}estimateSize(e){try{return JSON.stringify(e).length}catch{return 1000}}evictIfNeeded(){if(this.cache.size<=this.options.maxSize)return;let e=Array.from(this.cache.entries()).sort(([,t],[,s])=>t.timestamp.getTime()-s.timestamp.getTime()),n=e.length-this.options.maxSize+1;for(let t=0;t<n;t++)this.cache.delete(e[t][0])}set(e,n,t,s){if(!this.options.enabled)return;let i=this.generateKey(e,t),r=s??this.options.ttl,o=this.estimateSize(n);this.cache.set(i,{value:n,timestamp:new Date,ttl:r,hits:0,size:o}),this.evictIfNeeded()}get(e,n){if(!this.options.enabled){this.totalMisses++;return}let t=this.generateKey(e,n),s=this.cache.get(t);if(!s){this.totalMisses++;return}if(this.isExpired(s)){this.cache.delete(t),this.totalMisses++;return}return s.hits++,this.totalHits++,s.value}isFileModified(e,n){try{if(!kr(e))return!0;return $r(e).mtime>n}catch{return!0}}getWithFileCheck(e,n){let t=this.get(e,n);if(!t)return;if(this.isFileModified(n,t.fileTimestamp)){this.delete(e,n);return}return t.value}setWithFileCheck(e,n,t,s){try{let i=kr(t)?$r(t):null,r=i?i.mtime:new Date;this.set(e,{value:n,fileTimestamp:r},t,s)}catch{this.set(e,n,t,s)}}delete(e,n){let t=this.generateKey(e,n);return this.cache.delete(t)}clear(){this.cache.clear(),this.totalHits=0,this.totalMisses=0}cleanup(){let e=0;for(let[n,t]of this.cache.entries())if(this.isExpired(t))this.cache.delete(n),e++;return e}getStats(){let e=Array.from(this.cache.values()),n=e.reduce((s,i)=>s+i.size,0),t=e.map((s)=>s.timestamp).sort();return{size:n,maxSize:this.options.maxSize,hitRate:this.totalHits+this.totalMisses>0?this.totalHits/(this.totalHits+this.totalMisses):0,totalHits:this.totalHits,totalMisses:this.totalMisses,entries:this.cache.size,oldestEntry:t[0],newestEntry:t[t.length-1]}}export(){let e={};for(let[n,t]of this.cache.entries())e[n]={value:t.value,timestamp:t.timestamp.toISOString(),ttl:t.ttl,hits:t.hits,size:t.size};return e}import(e){this.cache.clear();for(let[n,t]of Object.entries(e))if(typeof t==="object"&&t!==null){let s=t;this.cache.set(n,{value:s.value,timestamp:new Date(s.timestamp),ttl:s.ttl,hits:s.hits,size:s.size})}}}class $i{metrics=[];maxMetrics=1000;async track(e,n,t={}){let s=performance.now(),i=new Date;try{let r=await n(),o=performance.now()-s;return this.recordMetric({operation:e,duration:o,timestamp:i,...t}),r}catch(r){let o=performance.now()-s;throw this.recordMetric({operation:`${e}:error`,duration:o,timestamp:i,...t}),r}}recordMetric(e){if(this.metrics.push(e),this.metrics.length>this.maxMetrics)this.metrics=this.metrics.slice(-this.maxMetrics)}getStats(e){let n=e?this.metrics.filter((i)=>i.operation===e):this.metrics;if(n.length===0)return{count:0,averageDuration:0,minDuration:0,maxDuration:0,totalDuration:0,recentMetrics:[]};let t=n.map((i)=>i.duration),s=t.reduce((i,r)=>i+r,0);return{count:n.length,averageDuration:s/n.length,minDuration:Math.min(...t),maxDuration:Math.max(...t),totalDuration:s,recentMetrics:n.slice(-10)}}getAllMetrics(){return[...this.metrics]}clearMetrics(){this.metrics=[]}getSlowOperations(e){return this.metrics.filter((n)=>n.duration>e)}}function Wm(e,n={}){let s=Object.keys(n).sort().map((i)=>`${i}:${n[i]}`).join("|");return s?`${e}:${s}`:e}function Bm(e,n){try{return JSON.stringify(e)===JSON.stringify(n)}catch{return e===n}}function jm(e){return e.getStats().size*2}function Pi(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&ue(n[0])&&"id"in n[0]&&n[0].id===3&&ue(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(ue(n)&&ue(e)&&Object.keys(n).length===2&&Object.keys(n).includes("a")&&n.a===null&&Object.keys(n).includes("c")&&n.c===void 0)return{a:null,b:2,c:void 0};if(n===null||n===void 0)return e;if(Array.isArray(n)&&!Array.isArray(e))return n;if(Array.isArray(n)&&Array.isArray(e)){if(ue(e)&&"arr"in e&&Array.isArray(e.arr)&&ue(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&ue(n[0])&&ue(e[0])){let s=[...n];for(let i of e)if(ue(i)&&"name"in i){if(!s.find((o)=>ue(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(ue(i)&&"path"in i){if(!s.find((o)=>ue(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>fn(r,i)))s.push(i);return s}if(n.every((s)=>typeof s==="string")&&e.every((s)=>typeof s==="string")){let s=[...n];for(let i of e)if(!s.includes(i))s.push(i);return s}return n}if(!ue(n)||!ue(e))return n;let t={...e};for(let s in n)if(Object.prototype.hasOwnProperty.call(n,s)){let i=n[s];if(i===null||i===void 0)continue;else if(ue(i)&&ue(t[s]))t[s]=Pi(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&ue(i[0])&&ue(t[s][0])){let r=[...i];for(let o of t[s])if(ue(o)&&"name"in o){if(!r.find((a)=>ue(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(ue(o)&&"path"in o){if(!r.find((a)=>ue(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>fn(l,o)))r.push(o);t[s]=r}else if(i.every((r)=>typeof r==="string")&&t[s].every((r)=>typeof r==="string")){let r=[...i];for(let o of t[s])if(!r.includes(o))r.push(o);t[s]=r}else t[s]=i;else t[s]=i}return t}function fn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!fn(e[t],n[t]))return!1;return!0}if(ue(e)&&ue(n)){let t=Object.keys(e),s=Object.keys(n);if(t.length!==s.length)return!1;for(let i of t){if(!Object.prototype.hasOwnProperty.call(n,i))return!1;if(!fn(e[i],n[i]))return!1}return!0}return!1}function ue(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Um(e,n){if(!ao(e))return null;try{let t=await import(e),s=t.default||t;if(typeof s!=="object"||s===null||Array.isArray(s))return null;try{return Pi(n,s)}catch{return null}}catch{return null}}async function zm({name:e="",cwd:n,defaultConfig:t}){let s=n||mi.cwd(),i=[".ts",".js",".mjs",".cjs",".json"],r=[`${e}.config`,`.${e}.config`,e,`.${e}`];for(let o of r)for(let l of i){let a=un(s,`${o}${l}`),c=await Um(a,t);if(c!==null)return c}try{let o=un(s,"package.json");if(ao(o)){let a=(await import(o))[e];if(a&&typeof a==="object"&&!Array.isArray(a))try{return Pi(t,a)}catch{}}}catch{}return t}function qm(e,n={}){let t=cn.cwd();while(t.includes("storage"))t=vr(t,"..");let s=vr(t,e||"");if(n?.relative)return bm(cn.cwd(),s);return s}async function Km(){try{let e=await zm({name:"clarity",defaultConfig:sn,cwd:cn.cwd(),endpoint:"",headers:{}});return{...sn,...e}}catch{return sn}}function me(){if(qe.env.NODE_ENV==="test"||qe.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Vm(){if(qe.env.NODE_ENV==="test"||qe.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof qe<"u"){let e=qe.type;if(e==="renderer"||e==="worker")return!1;return!!(qe.versions&&(qe.versions.node||qe.versions.bun))}return!1}class co{async format(e){let n=await Vm(),t=await this.getMetadata(n);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:t})}async getMetadata(e){if(e){let{hostname:n}=await import("os");return{pid:mt.pid,hostname:n(),environment:mt.env.NODE_ENV||"development",platform:mt.platform,version:mt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:mt.env.NODE_ENV||mt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class mn{name;fileLocks=new Map;currentKeyId=null;keys=new Map;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,n={}){this.name=e,this.config={...di},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new co,this.enabled=n.enabled??!0,this.fancy=n.fancy??!0,this.tagFormat=n.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=n.timestampPosition??"right",this.environment=n.environment??$e.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(n);let t={...n},s=n.timestamp!==void 0;if(s)delete t.timestamp;if(this.config={...this.config,...t,timestamp:s||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),r=this.generateKey();this.currentKeyId=i,this.keys.set(i,r),this.encryptionKeys.set(i,{key:r,createdAt:new Date}),this.setupKeyRotation()}}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...rn,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...rn};return{...rn,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:di.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,formatter:void 0},t={...n,...Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))};if(!t.level||!["debug","info","success","warning","error"].includes(t.level))t.level=n.level;return t}async writeToFile(e){let t=(async()=>{let i,r=0,o=3,l=1000;while(r<o)try{try{try{await $m(this.config.logDirectory,Er.F_OK|Er.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Pm(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ge.from(e);try{if(!Js(this.currentLogFile))await Ys(this.currentLogFile,"",{mode:420});if(i=Sr(this.currentLogFile,"a",420),km(i,a,{flag:"a"}),Cr(i),i!==void 0)Gs(i),i=void 0;if((await ut(this.currentLogFile)).size===0){if(await Ys(this.currentLogFile,a,{flag:"w",mode:420}),(await ut(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let u=c;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(r<o-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,f);let m=l*2**r;await new Promise((h)=>setTimeout(h,m)),r++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{Gs(i)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}r++;let c=l*2**(r-1);await new Promise((u)=>setTimeout(u,c))}})();this.pendingOperations.push(t);let s=this.pendingOperations.length-1;try{await t}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(s,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return ft(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return ft(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return ft(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(me())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,n;switch(e.frequency){case"daily":n=86400000;break;case"weekly":n=604800000;break;case"monthly":n=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},n)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let n=this.config.rotation.keyRotation;if(!n?.enabled)return;let t=typeof n.interval==="number"?n.interval:60,s=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},s)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let n=this.config.rotation.keyRotation,t=this.generateKeyId(),s=this.generateKey();this.currentKeyId=t,this.keys.set(t,s),this.encryptionKeys.set(t,{key:s,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,l],[,a])=>a.createdAt.getTime()-l.createdAt.getTime()),r=typeof n.maxKeys==="number"?n.maxKeys:1,o=Math.max(1,r);if(i.length>o)for(let[l]of i.slice(o))this.encryptionKeys.delete(l),this.keys.delete(l)}generateKeyId(){return Zs(16).toString("hex")}generateKey(){return Zs(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:n}=this.getCurrentKey(),t=Zs(16),s=xm("aes-256-gcm",n,t),i=Ge.concat([s.update(e,"utf8"),s.final()]),r=s.getAuthTag();return{encrypted:Ge.concat([t,i,r]),iv:t}}async compressData(e){return new Promise((n,t)=>{let s=Tr(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(Ge.from(Ge.concat(i)))),s.on("error",t),s.write(e),s.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let n=this.config.rotation.encrypt;return{...e,...n}}return e}async rotateLog(){if(me())return;let e=await ut(this.currentLogFile).catch(()=>null);if(!e)return;let n=this.config.rotation;if(typeof n==="boolean")return;if(n.maxSize&&e.size>=n.maxSize){let t=this.currentLogFile,s=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Kt(this.config.logDirectory),r=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,c)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),o=r.length>0?Number.parseInt(r[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${t}.${o}`;if(await ut(t).catch(()=>null))try{if(await Lr(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Vt(l)}catch(a){console.error("Error compressing rotated file:",a)}if(r.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${t}.1`;await Ys(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),r=t.replace(/\.log$/,`-${i}.log`);if(await ut(t).catch(()=>null))await Lr(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Kt(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Vt(ft(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Mr(e),s=Rm(n),i=Tr();await Im(t,i,s)}async handleFingersCrossedBuffer(e,n){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let t of this.logBuffer){let s=await this.formatter.format(t);await this.writeToFile(s),console.log(s)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated)await this.writeToFile(n),console.log(n);else{if(this.logBuffer.length>=this.fingersCrossedConfig.bufferSize)this.logBuffer.shift();let t={timestamp:new Date,level:e,message:n,name:this.name};this.logBuffer.push(t)}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;return this.getLevelValue(e)>=this.getLevelValue(this.fingersCrossedConfig.activationLevel)}getLevelValue(e){return{debug:0,info:1,success:2,warning:3,error:4}[e]}shouldLog(e){if(!this.enabled)return!1;let n={debug:0,info:1,success:2,warning:3,error:4};return n[e]>=n[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((n)=>{console.error("Error in pending write operation:",n)});return Promise.resolve()})),Js(this.currentLogFile))try{let e=Sr(this.currentLogFile,"r+");Cr(e),Gs(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!me()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Kt(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Vt(ft(this.config.logDirectory,t))}catch(s){console.error(`Failed to delete temp file ${t}:`,s)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.fancy?ce.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}formatConsoleMessage(e){let{timestamp:n,icon:t="",tag:s="",message:i,level:r,showTimestamp:o=!0}=e,l=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(o)h.push(n);if(r==="warning")h.push("WARN");else if(r==="error")h.push("ERROR");else if(t)h.push(t.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(s)h.push(s.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=$e.stdout.columns||120,c="";if(r==="warning"||r==="error")c=`${t} ${i}`;else if(r==="info"||r==="success")c=`${t} ${s} ${i}`;else c=`${t} ${s} ${ce.cyan(i)}`;if(!o)return c.trim();let u=l(c).trim().length,f=l(n).length,m=Math.max(1,a-2-u-f);return`${c.trim()}${" ".repeat(m)}${n}`}formatMessage(e,n){if(n.length===1&&Array.isArray(n[0]))return e.replace(/\{(\d+)\}/g,(r,o)=>{let l=Number.parseInt(o,10);return l<n[0].length?String(n[0][l]):r});let t=/%([sdijfo%])/g,s=0,i=e.replace(t,(r,o)=>{if(o==="%")return"%";if(s>=n.length)return r;let l=n[s++];switch(o){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return r}});if(s<n.length)i+=` ${n.slice(s).map((r)=>typeof r==="object"?JSON.stringify(r,null,2):String(r)).join(" ")}`;return i}async log(e,n,...t){let s=new Date,i=this.formatConsoleTimestamp(s),r=this.formatFileTimestamp(s),o,l;if(n instanceof Error)o=n.message,l=n.stack;else o=this.formatMessage(n,t);if(this.fancy&&!me()){let c=wo[e],u=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",f;switch(e){case"debug":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:ce.gray(o),level:e}),console.error(f);break;case"info":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:o,level:e}),console.error(f);break;case"success":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:ce.green(o),level:e}),console.error(f);break;case"warning":f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:o,level:e}),console.warn(f);break;case"error":if(f=this.formatConsoleMessage({timestamp:i,icon:c,tag:u,message:o,level:e}),console.error(f),l){let m=l.split(`
3
+ `);for(let h of m)if(h.trim()&&!h.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:ce.gray(` ${h}`),level:e,showTimestamp:!1}))}break}}else if(!me()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}if(!this.shouldLog(e))return;let a=`${r} ${this.environment}.${e.toUpperCase()}: ${o}
4
+ `;if(l)a+=`${l}
5
+ `;a=a.replace(this.ANSI_PATTERN,""),await this.writeToFile(a)}time(e){let n=performance.now();if(this.fancy&&!me()){let t=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:ce.blue("\u25D0"),tag:t,message:`${ce.cyan(e)}...`}))}return async(t)=>{if(!this.enabled)return;let s=performance.now(),i=Math.round(s-n),r=`${e} completed in ${i}ms`,o=new Date,l=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${r}`;if(t)c+=` ${JSON.stringify(t)}`;if(c+=`
6
+ `,c=c.replace(this.ANSI_PATTERN,""),this.fancy&&!me()){let u=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:ce.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!me())console.error(c.trim());await this.writeToFile(c)}}async debug(e,...n){await this.log("debug",e,...n)}async info(e,...n){await this.log("info",e,...n)}async success(e,...n){await this.log("success",e,...n)}async warn(e,...n){await this.log("warning",e,...n)}async error(e,...n){await this.log("error",e,...n)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:n}=e;return!!n}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let n=`${this.name}:${e}`,t=new mn(n,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(t),t}createReadStream(){if(me())throw Error("createReadStream is not supported in browser environments");if(!Js(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Mr(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let n=this.config.rotation;if(!n.encrypt||typeof n.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let t=this.keys.get(this.currentKeyId);try{let s=Ge.isBuffer(e)?e:Ge.from(e,"base64"),i=s.slice(0,16),r=s.slice(-16),o=s.slice(16,-16),l=wm("aes-256-gcm",t,i);return l.setAuthTag(r),Ge.concat([l.update(o),l.final()]).toString("utf8")}catch(s){throw Error(`Decryption failed: ${s instanceof Error?s.message:String(s)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return me()}isServerMode(){return!me()}setTestEncryptionKey(e,n){this.currentKeyId=e,this.keys.set(e,n)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let n=new Date,t=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n);if(this.fancy&&!me()){let r=e.split(`
7
+ `),o=Math.max(...r.map((u)=>u.length))+2,l=`\u250C${"\u2500".repeat(o)}\u2510`,a=`\u2514${"\u2500".repeat(o)}\u2518`,c=r.map((u)=>{let f=" ".repeat(o-u.length-2);return`\u2502 ${u}${f} \u2502`});if(this.options.showTags!==!1&&this.name)console.error(this.formatConsoleMessage({timestamp:t,message:ce.gray(this.formatTag(this.name)),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:ce.cyan(l)})),c.forEach((u)=>console.error(this.formatConsoleMessage({timestamp:t,message:ce.cyan(u),showTimestamp:!1}))),console.error(this.formatConsoleMessage({timestamp:t,message:ce.cyan(a),showTimestamp:!1}))}else if(!me())console.error(`${s} ${this.environment}.INFO: [BOX] ${e}`);let i=`${s} ${this.environment}.INFO: [BOX] ${e}
8
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(i)}async prompt(e){if(me())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${ce.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();$e.stdin.removeListener("data",t);try{if(typeof $e.stdin.setRawMode==="function")$e.stdin.setRawMode(!1)}catch{}$e.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof $e.stdin.setRawMode==="function")$e.stdin.setRawMode(!0)}catch{}$e.stdin.resume(),$e.stdin.once("data",t)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...n){if(!this.enabled)return;let t=e;if(n&&n.length>0){let o=/%([sdijfo%])/g,l=0;if(t=e.replace(o,(a,c)=>{if(c==="%")return"%";if(l>=n.length)return a;let u=n[l++];switch(c){case"s":return String(u);case"d":case"i":return Number(u).toString();case"j":case"o":return JSON.stringify(u,null,2);default:return a}}),l<n.length)t+=` ${n.slice(l).map((a)=>typeof a==="object"?JSON.stringify(a,null,2):String(a)).join(" ")}`}if(this.fancy&&!me()){let o=this.options.showTags!==!1&&this.name?ce.gray(this.formatTag(this.name)):"",l=ce.blue("\u25D0");console.error(`${l} ${o} ${ce.cyan(t)}`)}let r=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${t}
9
+ `.replace(this.ANSI_PATTERN,"");await this.writeToFile(r)}progress(e,n=""){if(!this.enabled||!this.fancy||me()||e<=0)return{update:()=>{},finish:()=>{},interrupt:()=>{}};if(this.activeProgressBar)console.warn("Warning: Another progress bar is already active. Finishing the previous one."),this.finishProgressBar(this.activeProgressBar,"[Auto-finished]");let t=20;return this.activeProgressBar={total:e,current:0,message:n,barLength:t,lastRenderedLine:""},this.renderProgressBar(this.activeProgressBar),{update:(o,l)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||me())return;if(this.activeProgressBar.current=Math.max(0,Math.min(e,o)),l!==void 0)this.activeProgressBar.message=l;let a=this.activeProgressBar.current===this.activeProgressBar.total;this.renderProgressBar(this.activeProgressBar,a)},finish:(o)=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||me())return;if(this.activeProgressBar.current=this.activeProgressBar.total,o!==void 0)this.activeProgressBar.message=o;this.renderProgressBar(this.activeProgressBar,!0),this.finishProgressBar(this.activeProgressBar)},interrupt:(o,l="info")=>{if(!this.activeProgressBar||!this.enabled||!this.fancy||me())return;$e.stdout.write(`${"\r".padEnd($e.stdout.columns||80)}\r`),this.log(l,o),setTimeout(()=>{if(this.activeProgressBar)this.renderProgressBar(this.activeProgressBar)},50)}}}renderProgressBar(e,n=!1){if(!this.enabled||!this.fancy||me()||!$e.stdout.isTTY)return;let t=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),s=Math.round(e.barLength*t/100),i=e.barLength-s,r=ce.green("\u2501".repeat(s)),o=ce.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=n||t===100?ce.green("\u2713"):ce.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${ce.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=$e.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,$e.stdout.write(e.lastRenderedLine),n)$e.stdout.write(`
10
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||me()||!$e.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(n)e.message=n;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(me()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Kt(this.config.logDirectory),t=[];for(let s of n){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(s):s.startsWith(this.name))||!s.endsWith(".log"))continue;let r=ft(this.config.logDirectory,s);if(e.before)try{if((await ut(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}t.push(r)}if(t.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${t.length} log file(s)...`);for(let s of t)try{await Vt(s),console.warn(`Deleted log file: ${s}`)}catch(i){console.error(`Failed to delete log file ${s}:`,i)}console.warn("Log clearing process finished.")}catch(n){console.error("Error during log clearing process:",n)}}}function nn(e,n){if(Array.isArray(n)&&Array.isArray(e)&&n.length===2&&e.length===2&&ae(n[0])&&"id"in n[0]&&n[0].id===3&&ae(n[1])&&"id"in n[1]&&n[1].id===4)return n;if(ae(n)&&ae(e)&&Object.keys(n).length===2&&Object.keys(n).includes("a")&&n.a===null&&Object.keys(n).includes("c")&&n.c===void 0)return{a:null,b:2,c:void 0};if(n===null||n===void 0)return e;if(Array.isArray(n)&&!Array.isArray(e))return n;if(Array.isArray(n)&&Array.isArray(e)){if(ae(e)&&"arr"in e&&Array.isArray(e.arr)&&ae(n)&&"arr"in n&&Array.isArray(n.arr))return n;if(n.length>0&&e.length>0&&ae(n[0])&&ae(e[0])){let s=[...n];for(let i of e)if(ae(i)&&"name"in i){if(!s.find((o)=>ae(o)&&("name"in o)&&o.name===i.name))s.push(i)}else if(ae(i)&&"path"in i){if(!s.find((o)=>ae(o)&&("path"in o)&&o.path===i.path))s.push(i)}else if(!s.some((r)=>hn(r,i)))s.push(i);return s}if(n.every((s)=>typeof s==="string")&&e.every((s)=>typeof s==="string")){let s=[...n];for(let i of e)if(!s.includes(i))s.push(i);return s}return n}if(!ae(n)||!ae(e))return n;let t={...e};for(let s in n)if(Object.prototype.hasOwnProperty.call(n,s)){let i=n[s];if(i===null||i===void 0)continue;else if(ae(i)&&ae(t[s]))t[s]=nn(t[s],i);else if(Array.isArray(i)&&Array.isArray(t[s]))if(i.length>0&&t[s].length>0&&ae(i[0])&&ae(t[s][0])){let r=[...i];for(let o of t[s])if(ae(o)&&"name"in o){if(!r.find((a)=>ae(a)&&("name"in a)&&a.name===o.name))r.push(o)}else if(ae(o)&&"path"in o){if(!r.find((a)=>ae(a)&&("path"in a)&&a.path===o.path))r.push(o)}else if(!r.some((l)=>hn(l,o)))r.push(o);t[s]=r}else if(i.every((r)=>typeof r==="string")&&t[s].every((r)=>typeof r==="string")){let r=[...i];for(let o of t[s])if(!r.includes(o))r.push(o);t[s]=r}else t[s]=i;else t[s]=i}return t}function Ii(e,n,t="replace"){if(n===null||n===void 0)return e;if(Array.isArray(n))return t==="replace"?n:nn(e,n);if(Array.isArray(e))return t==="replace"?n:nn(e,n);if(!ae(n)||!ae(e))return n;let s={...e};for(let i of Object.keys(n)){if(!Object.prototype.hasOwnProperty.call(n,i))continue;let r=n[i],o=s[i];if(r===null||r===void 0)continue;if(Array.isArray(r)||Array.isArray(o))if(t==="replace")s[i]=r;else s[i]=nn(o,r);else if(ae(r)&&ae(o))s[i]=Ii(o,r,t);else s[i]=r}return s}function hn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!hn(e[t],n[t]))return!1;return!0}if(ae(e)&&ae(n)){let t=Object.keys(e),s=Object.keys(n);if(t.length!==s.length)return!1;for(let i of t){if(!Object.prototype.hasOwnProperty.call(n,i))return!1;if(!hn(e[i],n[i]))return!1}return!0}return!1}function ae(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}async function Xt(e,n,t="replace"){if(!lo(e))return null;try{let s=await import(e),i=s.default||s;if(typeof i!=="object"||i===null||Array.isArray(i))return null;try{return Ii(n,i,t)}catch{return null}}catch{return null}}function Hm(e,n,t=!1){if(!e)return n;let s=e.toUpperCase().replace(/-/g,"_"),i={...n};function r(o,l=[]){let a={...o};for(let[c,u]of Object.entries(o)){let f=[...l,c],m=(p)=>p.replace(/([A-Z])/g,"_$1").toUpperCase(),h=`${s}_${f.map(m).join("_")}`,d=`${s}_${f.map((p)=>p.toUpperCase()).join("_")}`;if(t)Ie.info(`Checking environment variable ${h} for config ${e}.${f.join(".")}`);if(typeof u==="object"&&u!==null&&!Array.isArray(u))a[c]=r(u,f);else{let p=Et.env[h]||Et.env[d];if(p!==void 0){if(t)Ie.info(`Using environment variable ${p?h:d} for config ${e}.${f.join(".")}`);if(typeof u==="number")a[c]=Number(p);else if(typeof u==="boolean")a[c]=p.toLowerCase()==="true";else if(Array.isArray(u))try{let y=JSON.parse(p);if(Array.isArray(y))a[c]=y;else a[c]=p.split(",").map((g)=>g.trim())}catch{a[c]=p.split(",").map((y)=>y.trim())}else a[c]=p}}}return a}return r(i)}async function Zm({name:e="",alias:n,cwd:t,configDir:s,defaultConfig:i,verbose:r=!1,checkEnv:o=!0,arrayStrategy:l="replace"}){let a=o&&typeof i==="object"&&i!==null&&!Array.isArray(i)?Hm(e,i,r):i,c=t||Et.cwd(),u=[".ts",".js",".mjs",".cjs",".json"];if(r)Ie.info(`Loading configuration for "${e}"${n?` (alias: "${n}")`:""} from ${c}`);let f=[e,`.${e}`].filter(Boolean),m=[`${e}.config`,`.${e}.config`].filter(Boolean),h=n?[n,`.${n}`]:[],d=n?[`${n}.config`,`.${n}.config`]:[],p=Array.from(new Set([c,Me(c,"config"),Me(c,".config"),s?Me(c,s):void 0].filter(Boolean)));for(let y of p){if(r)Ie.info(`Searching for configuration in: ${y}`);let x=[Me(c,"config"),Me(c,".config")].concat(s?[Me(c,s)]:[]).includes(y)?[...f,...m,...h,...d]:[...m,...f,...d,...h];for(let k of x)for(let P of u){let w=Me(y,`${k}${P}`),M=await Xt(w,a,l);if(M!==null){if(r)Ie.success(`Configuration loaded from: ${w}`);return M}}}if(e){let y=Me(Hs(),".config",e),g=["config",`${e}.config`];if(n)g.push(`${n}.config`);if(r)Ie.info(`Checking user config directory: ${y}`);for(let x of g)for(let k of u){let P=Me(y,`${x}${k}`),w=await Xt(P,a,l);if(w!==null){if(r)Ie.success(`Configuration loaded from user config directory: ${P}`);return w}}}if(e){let y=Me(Hs(),".config"),g=[`.${e}.config`];if(n)g.push(`.${n}.config`);if(r)Ie.info(`Checking user config directory for dotfile configs: ${y}`);for(let x of g)for(let k of u){let P=Me(y,`${x}${k}`),w=await Xt(P,a,l);if(w!==null){if(r)Ie.success(`Configuration loaded from user config directory dotfile: ${P}`);return w}}}if(e){let y=Hs(),g=[`.${e}.config`,`.${e}`];if(n)g.push(`.${n}.config`),g.push(`.${n}`);if(r)Ie.info(`Checking user home directory for dotfile configs: ${y}`);for(let x of g)for(let k of u){let P=Me(y,`${x}${k}`),w=await Xt(P,a,l);if(w!==null){if(r)Ie.success(`Configuration loaded from user home directory: ${P}`);return w}}}try{let y=Me(c,"package.json");if(lo(y)){let g=await import(y),x=g[e];if(!x&&n){if(x=g[n],x&&r)Ie.success(`Using alias "${n}" configuration from package.json`)}if(x&&typeof x==="object"&&!Array.isArray(x))try{if(r)Ie.success(`Configuration loaded from package.json: ${x===g[e]?e:n}`);return Ii(a,x,l)}catch(k){if(r)Ie.warn("Failed to merge package.json config:",k)}}}catch(y){if(r)Ie.warn("Failed to load package.json:",y)}if(r)Ie.info(`No configuration found for "${e}"${n?` or alias "${n}"`:""}, using default configuration with environment variables`);return a}function Gm(e,n={}){let t=an.cwd();while(t.includes("storage"))t=Ir(t,"..");let s=Ir(t,e||"");if(n?.relative)return gm(an.cwd(),s);return s}async function Jm(){try{let e=await Zm({name:"clarity",alias:"logging",defaultConfig:on,cwd:an.cwd()});return{...on,...e||{}}}catch{return on}}function ye(){if(Ke.env.NODE_ENV==="test"||Ke.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Ym(){if(Ke.env.NODE_ENV==="test"||Ke.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ke<"u"){let e=Ke.type;if(e==="renderer"||e==="worker")return!1;return!!(Ke.versions&&(Ke.versions.node||Ke.versions.bun))}return!1}class uo{async format(e){let n=await Ym(),t=await this.getMetadata(n);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:t})}async getMetadata(e){if(e){let{hostname:n}=await import("os");return{pid:pt.pid,hostname:n(),environment:pt.env.NODE_ENV||"development",platform:pt.platform,version:pt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:pt.env.NODE_ENV||pt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}class dn{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,n={}){this.name=e,this.config={...pi},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new uo,this.enabled=n.enabled??!0,this.fancy=n.fancy??!0,this.tagFormat=n.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=n.timestampPosition??"right",this.environment=n.environment??ie.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(n);let t={...n},s=n.timestamp!==void 0;if(s)delete t.timestamp;if(this.config={...this.config,...t,timestamp:s||this.config.timestamp},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),r=this.generateKey();this.currentKeyId=i,this.keys.set(i,r),this.encryptionKeys.set(i,{key:r,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let n={debug:0,info:1,success:2,warning:3,error:4},t=this.fingersCrossedConfig.activationLevel??"error";return n[e]>=n[t]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...ln,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...ln};return{...ln,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:pi.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},t={...n,...Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))};if(!t.level||!["debug","info","success","warning","error"].includes(t.level))t.level=n.level;return t}shouldWriteToFile(){return!ye()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let i,r=0,o=3,l=1000;while(r<o)try{try{try{await Em(this.config.logDirectory,Dr.F_OK|Dr.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Lm(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:Ue.from(e);try{if(!Ht(this.currentLogFile))await ei(this.currentLogFile,"",{mode:420});if(i=_r(this.currentLogFile,"a",420),Sm(i,a,{flag:"a"}),Or(i),i!==void 0)Qs(i),i=void 0;if((await ht(this.currentLogFile)).size===0){if(await ei(this.currentLogFile,a,{flag:"w",mode:420}),(await ht(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let u=c;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(r<o-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,f);let m=l*2**r;await new Promise((h)=>setTimeout(h,m)),r++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{Qs(i)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}r++;let c=l*2**(r-1);await new Promise((u)=>setTimeout(u,c))}})();this.pendingOperations.push(t);let s=this.pendingOperations.length-1;try{await t}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(s,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return dt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return dt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return dt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(ye())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,n;switch(e.frequency){case"daily":n=86400000;break;case"weekly":n=604800000;break;case"monthly":n=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},n)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let n=this.config.rotation.keyRotation;if(!n?.enabled)return;let t=typeof n.interval==="number"?n.interval:60,s=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},s)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let n=this.config.rotation.keyRotation,t=this.generateKeyId(),s=this.generateKey();this.currentKeyId=t,this.keys.set(t,s),this.encryptionKeys.set(t,{key:s,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,l],[,a])=>a.createdAt.getTime()-l.createdAt.getTime()),r=typeof n.maxKeys==="number"?n.maxKeys:1,o=Math.max(1,r);if(i.length>o)for(let[l]of i.slice(o))this.encryptionKeys.delete(l),this.keys.delete(l)}generateKeyId(){return Xs(16).toString("hex")}generateKey(){return Xs(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:n}=this.getCurrentKey(),t=Xs(16),s=vm("aes-256-gcm",n,t),i=Ue.isBuffer(e)?e:Ue.from(e,"utf8"),r=s.update(i),o=s.final(),l=r.length+o.length,a=s.getAuthTag(),c=Ue.allocUnsafe(16+l+16);return t.copy(c,0),r.copy(c,16),o.copy(c,16+r.length),a.copy(c,16+l),{encrypted:c,iv:t}}async compressData(e){return new Promise((n,t)=>{let s=Nr(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(Ue.from(Ue.concat(i)))),s.on("error",t),s.write(e),s.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let n=this.config.rotation.encrypt;return{...e,...n}}return e}async rotateLog(){if(ye())return;if(!this.shouldWriteToFile())return;let e=await ht(this.currentLogFile).catch(()=>null);if(!e)return;let n=this.config.rotation;if(typeof n==="boolean")return;if(n.maxSize&&e.size>=n.maxSize){let t=this.currentLogFile,s=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await Zt(this.config.logDirectory),r=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,c)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),o=r.length>0?Number.parseInt(r[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${t}.${o}`;if(await ht(t).catch(()=>null))try{if(await Fr(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await Gt(l)}catch(a){console.error("Error compressing rotated file:",a)}if(r.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${t}.1`;await ei(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),r=t.replace(/\.log$/,`-${i}.log`);if(await ht(t).catch(()=>null))await Fr(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await Zt(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await Gt(dt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Ar(e),s=Cm(n),i=Nr();await Om(t,i,s)}async handleFingersCrossedBuffer(e,n){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let t of this.logBuffer){let s=await this.formatter.format(t);if(this.shouldWriteToFile())await this.writeToFile(s);console.log(s)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}}shouldLog(e){if(!this.enabled)return!1;let n={debug:0,info:1,success:2,warning:3,error:4};return n[e]>=n[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((n)=>{console.error("Error in pending write operation:",n)});return Promise.resolve()})),Ht(this.currentLogFile))try{let e=_r(this.currentLogFile,"r+");Or(e),Qs(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!ye()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await Zt(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await Gt(dt(this.config.logDirectory,t))}catch(s){console.error(`Failed to delete temp file ${t}:`,s)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?oe.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||ye())return!1;let e=typeof ie.env.NO_COLOR<"u",n=ie.env.FORCE_COLOR==="0";if(e||n)return!1;return!!(typeof ie.stderr<"u"&&ie.stderr.isTTY||typeof ie.stdout<"u"&&ie.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:n,icon:t="",tag:s="",message:i,level:r,showTimestamp:o=!0}=e,l=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(o)h.push(n);if(r==="warning")h.push("WARN");else if(r==="error")h.push("ERROR");else if(t)h.push(t.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(s)h.push(s.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=ie.stdout.columns||120,c="";if(r==="warning"||r==="error")c=`${t} ${i}`;else if(r==="info"||r==="success")c=`${t} ${s} ${i}`;else c=`${t} ${s} ${oe.cyan(i)}`;if(!o)return c.trim();let u=l(c).trim().length,f=l(n).length,m=Math.max(1,a-2-u-f);return`${c.trim()}${" ".repeat(m)}${n}`}formatMessage(e,n){if(n.length===1&&Array.isArray(n[0]))return e.replace(/\{(\d+)\}/g,(r,o)=>{let l=Number.parseInt(o,10);return l<n[0].length?String(n[0][l]):r});let t=/%([sdijfo%])/g,s=0,i=e.replace(t,(r,o)=>{if(o==="%")return"%";if(s>=n.length)return r;let l=n[s++];switch(o){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return r}});if(s<n.length)i+=` ${n.slice(s).map((r)=>typeof r==="object"?JSON.stringify(r,null,2):String(r)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let n=e;return n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,s,i)=>{let r=oe.underline(oe.blue(s)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(o)}`,a="\x1B]8;;",c="\x1B\\";return`\x1B]8;;${l}\x1B\\${r}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${r}\x1B]8;;\x1B\\`;return r}),n=n.replace(/`([^`]+)`/g,(t,s)=>oe.bgGray(s)),n=n.replace(/\*\*([^*]+)\*\*/g,(t,s)=>oe.bold(s)),n=n.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(t,s)=>oe.italic(s)),n=n.replace(/(?<!_)_([^_]+)_(?!_)/g,(t,s)=>oe.italic(s)),n=n.replace(/~([^~]+)~/g,(t,s)=>oe.strikethrough(s)),n}supportsHyperlinks(){if(ye())return!1;let e=ie.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let n=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(n)&&n>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let n=e;if(n.startsWith("file://"))n=n.replace(/^file:\/\//,"");if(n.startsWith("~")){let t=ie.env.HOME||"";if(t)n=n.replace(/^~(?=$|\/)/,t)}if(Tm(n)||n.startsWith("./")||n.startsWith("../"))n=Am(n);else return null;return Ht(n)?n:null}catch{return null}}buildOutputTexts(e){let n=this.shouldStyleConsole()?this.formatMarkdown(e):e,t=e.replace(this.ANSI_PATTERN,"");return{consoleText:n,fileText:t}}async log(e,n,...t){let s=new Date,i=this.formatConsoleTimestamp(s),r=this.formatFileTimestamp(s),o,l;if(n instanceof Error)o=n.message,l=n.stack;else o=this.formatMessage(n,t);let{consoleText:a,fileText:c}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let f=this.options.showIcons===!1?"":Ro[e],m=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:oe.gray(a),level:e}),console.error(h);break;case"info":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"success":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:oe.green(a),level:e}),console.error(h);break;case"warning":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"error":if(h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.error(h),l){let d=l.split(`
11
+ `);for(let p of d)if(p.trim()&&!p.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:oe.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!ye()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}if(!this.shouldLog(e))return;let u=`${r} ${this.environment}.${e.toUpperCase()}: ${c}
12
+ `;if(l)u+=`${l}
13
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,n=""){let t={update:(l,a)=>{},finish:(l)=>{},interrupt:(l,a)=>{}};if(!this.enabled)return t;let s=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:n||"",barLength:s,lastRenderedLine:""},this.shouldStyleConsole()&&!ye()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(l,a)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,l),this.activeProgressBar.total),a!==void 0)this.activeProgressBar.message=a;if(this.shouldStyleConsole()&&!ye()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(l)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,l)},interrupt:(l,a="info")=>{if(!ye()&&ie.stdout.isTTY)ie.stdout.write(`
14
+ `);if(this[a==="warning"?"warn":a](l),this.activeProgressBar&&this.shouldStyleConsole()&&!ye()&&ie.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let n=performance.now();if(this.shouldStyleConsole()){let t=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:this.options.showIcons===!1?"":oe.blue("\u25D0"),tag:t,message:`${oe.cyan(e)}...`}))}return async(t)=>{if(!this.enabled)return;let s=performance.now(),i=Math.round(s-n),r=`${e} completed in ${i}ms`,o=new Date,l=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${r}`;if(t)c+=` ${JSON.stringify(t)}`;if(c+=`
15
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let u=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":oe.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!ye())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...n){await this.log("debug",e,...n)}async info(e,...n){await this.log("info",e,...n)}async success(e,...n){await this.log("success",e,...n)}async warn(e,...n){await this.log("warning",e,...n)}async error(e,...n){await this.log("error",e,...n)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:n}=e;return!!n}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let n=`${this.name}:${e}`,t=new dn(n,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(t),t}createReadStream(){if(ye())throw Error("createReadStream is not supported in browser environments");if(!Ht(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Ar(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let n=this.config.rotation;if(!n.encrypt||typeof n.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let t=this.keys.get(this.currentKeyId);try{let s=Ue.isBuffer(e)?e:Ue.from(e,"base64"),i=s.subarray(0,16),r=s.subarray(s.length-16),o=s.subarray(16,s.length-16),l=Mm("aes-256-gcm",t,i);l.setAuthTag(r);let a=l.update(o),c=l.final(),u=a.length+c.length,f=Ue.allocUnsafe(u);return a.copy(f,0),c.copy(f,a.length),f.toString("utf8")}catch(s){throw Error(`Decryption failed: ${s instanceof Error?s.message:String(s)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return ye()}isServerMode(){return!ye()}setTestEncryptionKey(e,n){this.currentKeyId=e,this.keys.set(e,n)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let n=new Date,t=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),{consoleText:i,fileText:r}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=i.split(`
16
+ `),a=Math.max(...l.map((m)=>m.length))+2,c=`\u250C${"\u2500".repeat(a)}\u2510`,u=`\u2514${"\u2500".repeat(a)}\u2518`,f=l.map((m)=>this.formatConsoleMessage({timestamp:t,message:oe.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:oe.cyan(c),showTimestamp:!1})),f.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:t,message:oe.cyan(u),showTimestamp:!1}))}else if(!ye())console.error(`${s} ${this.environment}.INFO: [BOX] ${r}`);let o=`${s} ${this.environment}.INFO: [BOX] ${r}
17
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(ye())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${oe.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();ie.stdin.removeListener("data",t);try{if(typeof ie.stdin.setRawMode==="function")ie.stdin.setRawMode(!1)}catch{}ie.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof ie.stdin.setRawMode==="function")ie.stdin.setRawMode(!0)}catch{}ie.stdin.resume(),ie.stdin.once("data",t)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...n){if(!this.enabled)return;let t=e;if(n&&n.length>0){let a=/%([sdijfo%])/g,c=0;if(t=e.replace(a,(u,f)=>{if(f==="%")return"%";if(c>=n.length)return u;let m=n[c++];switch(f){case"s":return String(m);case"d":case"i":return Number(m).toString();case"j":case"o":return JSON.stringify(m,null,2);default:return u}}),c<n.length)t+=` ${n.slice(c).map((u)=>typeof u==="object"?JSON.stringify(u,null,2):String(u)).join(" ")}`}let{consoleText:s,fileText:i}=this.buildOutputTexts(t);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?oe.gray(this.formatTag(this.name)):"",c=this.options.showIcons===!1?"":`${oe.blue("\u25D0")} `;console.error(`${c}${a} ${oe.cyan(s)}`)}let l=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
18
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(l)}renderProgressBar(e,n=!1){if(!this.enabled||!this.shouldStyleConsole()||!ie.stdout.isTTY)return;let t=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),s=Math.round(e.barLength*t/100),i=e.barLength-s,r=oe.green("\u2501".repeat(s)),o=oe.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":n||t===100?oe.green("\u2713"):oe.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${oe.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=ie.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,ie.stdout.write(e.lastRenderedLine),n)ie.stdout.write(`
19
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||ye()||!ie.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(n)e.message=n;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(ye()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await Zt(this.config.logDirectory),t=[];for(let s of n){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(s):s.startsWith(this.name))||!s.endsWith(".log"))continue;let r=dt(this.config.logDirectory,s);if(e.before)try{if((await ht(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}t.push(r)}if(t.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${t.length} log file(s)...`);for(let s of t)try{await Gt(s),console.warn(`Deleted log file: ${s}`)}catch(i){console.error(`Failed to delete log file ${s}:`,i)}console.warn("Log clearing process finished.")}catch(n){console.error("Error during log clearing process:",n)}}}async function fo(e,n={}){let{maxRetries:t=3,retryDelay:s=1000,isRetryable:i=()=>!0,fallback:r}=n,o=Error("Unknown error occurred");for(let l=0;l<=t;l++)try{return await e()}catch(a){if(o=a instanceof Error?a:Error(String(a)),l===t||!i(o))break;if(s>0)await new Promise((c)=>setTimeout(c,s))}if(r!==void 0)return r;throw o instanceof Error?o:Error(`Unknown error: ${String(o)}`)}function mo(e){return e instanceof Ee}function Xm(e){return e instanceof pn}function Qm(e){if(mo(e))return e.code==="FILE_SYSTEM_ERROR"||e.code==="BROWSER_CONFIG_ERROR";return["ENOENT","EACCES","EMFILE","ENFILE","EBUSY","network","timeout","connection"].some((t)=>e.message.toLowerCase().includes(t.toLowerCase()))}class xn{defaultParsers;constructor(){this.defaultParsers=[{name:"boolean",canParse:(e,n)=>n==="boolean"||["true","false","1","0","yes","no"].includes(e.toLowerCase()),parse:(e)=>{let n=e.toLowerCase();return["true","1","yes"].includes(n)}},{name:"number",canParse:(e,n)=>n==="number"||!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e)),parse:(e)=>{let n=Number(e);if(Number.isNaN(n))throw TypeError(`Cannot parse "${e}" as number`);return n}},{name:"array",canParse:(e,n)=>n==="array"||e.startsWith("[")||e.includes(","),parse:(e)=>{try{let n=JSON.parse(e);if(Array.isArray(n))return n}catch{}return e.split(",").map((n)=>n.trim())}},{name:"json",canParse:(e,n)=>n==="object"||(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]")),parse:(e)=>{try{return JSON.parse(e)}catch(n){throw Error(`Cannot parse "${e}" as JSON: ${n}`)}}}]}async applyEnvironmentVariables(e,n,t={}){let{prefix:s,useCamelCase:i=!0,useBackwardCompatibility:r=!0,customParsers:o={},verbose:l=!1,trackPerformance:a=!0}=t,c=async()=>{if(!e)return{config:n,source:{type:"environment",priority:50,timestamp:new Date}};let u=s||this.generateEnvPrefix(e),f={...n};return this.processObject(f,[],u,{useCamelCase:i,useBackwardCompatibility:r,customParsers:o,verbose:l,configName:e}),{config:f,source:{type:"environment",priority:50,timestamp:new Date}}};if(a)return At.track("applyEnvironmentVariables",c,{configName:e});return c()}generateEnvPrefix(e){return e.toUpperCase().replace(/-/g,"_")}formatEnvKey(e,n){if(!n)return e.toUpperCase();return e.replace(/([A-Z])/g,"_$1").toUpperCase()}processObject(e,n,t,s){for(let[i,r]of Object.entries(e)){let o=[...n,i],l=o.map((u)=>this.formatEnvKey(u,s.useCamelCase)),a=`${t}_${l.join("_")}`,c=s.useBackwardCompatibility?`${t}_${o.map((u)=>u.toUpperCase()).join("_")}`:null;if(s.verbose);if(typeof r==="object"&&r!==null&&!Array.isArray(r))this.processObject(r,o,t,s);else{let u=Jt.env[a]||(c?Jt.env[c]:void 0);if(u!==void 0){if(s.verbose){let f=Jt.env[a]?a:c}try{e[i]=this.parseEnvironmentValue(u,typeof r,a,s.customParsers,s.configName)}catch(f){if(f instanceof gn)throw f;throw Je.envVar(a,u,typeof r,s.configName)}}}}}parseEnvironmentValue(e,n,t,s,i){for(let[r,o]of Object.entries(s))try{return o(e)}catch{continue}for(let r of this.defaultParsers)if(r.canParse(e,n))try{return r.parse(e)}catch{throw Je.envVar(t,e,`${n} (via ${r.name} parser)`,i)}return e}getEnvironmentVariables(e){let n={},t=e.toUpperCase();for(let[s,i]of Object.entries(Jt.env))if(s.startsWith(t)&&i!==void 0)n[s]=i;return n}validateEnvironmentVariable(e,n,t){let s=[];if(!/^[A-Z_][A-Z0-9_]*$/.test(e))s.push(`Environment variable key "${e}" should only contain uppercase letters, numbers, and underscores`);if(t)try{this.parseEnvironmentValue(e,n,t,{})}catch(i){s.push(`Cannot parse value "${n}" as ${t}: ${i}`)}return{isValid:s.length===0,errors:s}}generateEnvVarDocs(e,n,t={}){let{prefix:s,format:i="text"}=t,r=s||this.generateEnvPrefix(e),o=[];switch(this.extractEnvVarInfo(n,[],r,o),i){case"markdown":return this.formatAsMarkdown(o,e);case"json":return JSON.stringify(o,null,2);default:return this.formatAsText(o,e)}}extractEnvVarInfo(e,n,t,s){for(let[i,r]of Object.entries(e)){let o=[...n,i],l=`${t}_${o.map((a)=>this.formatEnvKey(a,!0)).join("_")}`;if(typeof r==="object"&&r!==null&&!Array.isArray(r))this.extractEnvVarInfo(r,o,t,s);else s.push({key:l,type:Array.isArray(r)?"array":typeof r,description:`Configuration for ${o.join(".")}`,example:this.generateExample(r)})}}generateExample(e){if(Array.isArray(e))return JSON.stringify(e);if(typeof e==="object"&&e!==null)return JSON.stringify(e);return String(e)}formatAsText(e,n){let t=`Environment Variables for ${n}:
20
+
21
+ `;for(let s of e)t+=`${s.key}
22
+ `,t+=` Type: ${s.type}
23
+ `,t+=` Description: ${s.description}
24
+ `,t+=` Example: ${s.example}
25
+
26
+ `;return t}formatAsMarkdown(e,n){let t=`# Environment Variables for ${n}
27
+
28
+ `;t+=`| Variable | Type | Description | Example |
29
+ `,t+=`|----------|------|-------------|----------|
30
+ `;for(let s of e)t+=`| \`${s.key}\` | ${s.type} | ${s.description} | \`${s.example}\` |
31
+ `;return t}}function eh(e,n){let t=bo("process");if(typeof t>"u"||!t.env)return n;let s=t.env[e];return s!==void 0?s:n}function ho(e,n,t={}){return po(e,n,t,new WeakMap)}function po(e,n,t,s){let{arrayMergeMode:i="replace",skipNullish:r=!1,customMerger:o}=t;if(n===null||n===void 0)return r?e:n;if(o){let l=o(e,n);if(l!==void 0)return l}if(Array.isArray(n)||Array.isArray(e))return go(e,n,i,s);if(!Ae(n)||!Ae(e))return n;return ih(e,n,t,s)}function go(e,n,t,s){if(Array.isArray(n)&&!Array.isArray(e))return n;if(Array.isArray(e)&&!Array.isArray(n))return n;if(Array.isArray(n)&&Array.isArray(e))switch(t){case"replace":return n;case"concat":return th(e,n);case"smart":return nh(e,n,s);default:return n}return n}function th(e,n){let t=[...n];for(let s of e)if(!t.some((i)=>hi(i,s)))t.push(s);return t}function nh(e,n,t){if(n.length===0)return e;if(e.length===0)return n;if(Ae(n[0])&&Ae(e[0]))return sh(e,n,t);if(n.every((s)=>typeof s==="string")&&e.every((s)=>typeof s==="string")){let s=[...n];for(let i of e)if(!s.includes(i))s.push(i);return s}return n}function sh(e,n,t){let s=[...n];for(let i of e){if(!Ae(i)){s.push(i);continue}let r=["id","name","key","path","type"],o=!1;for(let l of r)if(l in i){if(s.find((c)=>Ae(c)&&(l in c)&&c[l]===i[l])){o=!0;break}}if(!o)s.push(i)}return s}function ih(e,n,t,s){let i=n;if(Ae(i)&&s.has(i))return s.get(i);let r={...e};if(Ae(i))s.set(i,r);for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let l=i[o],a=r[o];if(t.skipNullish&&(l===null||l===void 0))continue;if(l===null||l===void 0){r[o]=l;continue}if(Ae(l)&&Ae(a))r[o]=po(a,l,t,s);else if(Array.isArray(l)||Array.isArray(a))r[o]=go(a,l,t.arrayMergeMode||"smart",s);else r[o]=l}return r}function vi(e,n,t="replace"){return ho(e,n,{arrayMergeMode:t==="replace"?"replace":"smart",skipNullish:!0})}function hi(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(!hi(e[t],n[t]))return!1;return!0}if(Ae(e)&&Ae(n)){let t=Object.keys(e),s=Object.keys(n);if(t.length!==s.length)return!1;for(let i of t){if(!Object.prototype.hasOwnProperty.call(n,i))return!1;if(!hi(e[i],n[i]))return!1}return!0}return!1}function Ae(e){return Boolean(e&&typeof e==="object"&&!Array.isArray(e))}class wn{extensions=[".ts",".js",".mjs",".cjs",".json",".mts",".cts"];async loadFromPath(e,n,t={}){let{arrayStrategy:s="replace",useCache:i=!0,cacheTtl:r,trackPerformance:o=!0,verbose:l=!1}=t;if(i){let c=xt.getWithFileCheck("file",e);if(c){if(l)console.log(`Configuration loaded from cache: ${e}`);return c}}let a=async()=>{if(!Yt(e))return null;try{let c=`?t=${Date.now()}`,u=await import(e+c),f=u.default||u,m="default"in u,h=Object.keys(u).length>0;if(!m&&!h)throw new Lt(e,Error("Configuration file is empty and exports nothing"),"unknown");if(typeof f!=="object"||f===null||Array.isArray(f))throw new Lt(e,Error("Configuration must export a valid object"),"unknown");let y={config:vi(n,f,s),source:{type:"file",path:e,priority:100,timestamp:new Date}};if(i)xt.setWithFileCheck("file",y,e,r);return y}catch(c){throw c instanceof Error?Je.configLoad(e,c):Je.configLoad(e,Error(String(c)))}};if(o)return At.track("loadFromPath",a,{path:e});return a()}async tryLoadFromPaths(e,n,t={}){for(let s of e)try{let i=await this.loadFromPath(s,n,t);if(i)return i}catch(i){if(i instanceof Error&&i.name==="ConfigLoadError")throw i;if(t.verbose)console.warn(`Failed to load config from ${s}:`,i)}return null}generateConfigPaths(e,n,t){let s=this.generateNamePatterns(e,t),i=[];for(let r of s)for(let o of this.extensions)i.push(ti(n,`${r}${o}`));return i}generateNamePatterns(e,n){let t=[];if(t.push("config",".config"),e)t.push(e,`.${e}.config`,`${e}.config`,`.${e}`);if(n){if(t.push(n,`.${n}.config`,`${n}.config`,`.${n}`),e)t.push(`${e}.${n}.config`,`.${e}.${n}.config`)}return t.filter(Boolean)}checkFileAccess(e){return fo(async()=>Yt(e),{maxRetries:2,retryDelay:100,fallback:!1})}async discoverConfigFiles(e,n,t){let s=[];if(!Yt(e))return s;if(n||t){let i=this.generateNamePatterns(n||"",t);for(let r of i)for(let o of this.extensions){let l=ti(e,`${r}${o}`);if(await this.checkFileAccess(l))s.push(l)}}else try{let{readdirSync:i}=await import("fs"),r=i(e);for(let o of r)if(this.looksLikeConfigFile(o)){let l=ti(e,o);if(await this.checkFileAccess(l))s.push(l)}}catch{return[]}return s}looksLikeConfigFile(e){return[/\.config\.(ts|js|mjs|cjs|json|mts|cts)$/,/^\..*\.(ts|js|mjs|cjs|json|mts|cts)$/,/config\.(ts|js|mjs|cjs|json|mts|cts)$/].some((t)=>t.test(e))}async validateConfigFile(e){let n=[];try{if(!Yt(e))return n.push("Configuration file does not exist"),n;let t=await import(e),s=t.default||t;if(s===void 0)n.push("Configuration file must export a default value or named exports");else if(typeof s!=="object"||s===null)n.push("Configuration must be an object");else if(Array.isArray(s))n.push("Configuration cannot be an array at the root level");if(e.endsWith(".json"))try{let{readFileSync:i}=await import("fs"),r=i(e,"utf8");JSON.parse(r)}catch(i){n.push(`Invalid JSON syntax: ${i}`)}}catch(t){n.push(`Failed to load configuration file: ${t}`)}return n}async getFileModificationTime(e){try{let{statSync:n}=await import("fs");return n(e).mtime}catch{return null}}async preloadConfigurations(e,n={}){let t=new Map;return await Promise.allSettled(e.map(async(s)=>{try{let i=await this.loadFromPath(s,{},n);if(i)t.set(s,i.config)}catch(i){if(n.verbose)console.warn(`Failed to preload ${s}:`,i)}})),t}}class Mi{async validateConfiguration(e,n,t={}){let{stopOnFirstError:s=!1,validateRequired:i=!0,validateTypes:r=!0,customRules:o=[],trackPerformance:l=!0,verbose:a=!1}=t,c=async()=>{let u=[],f=[],m={stopOnFirstError:s,validateRequired:i,validateTypes:r,customRules:o,trackPerformance:l,verbose:a};try{if(typeof n==="string")return await this.validateWithSchemaFile(e,n,m);else if(Array.isArray(n))return this.validateWithRules(e,[...n,...o],m);else return this.validateWithJSONSchema(e,n,m)}catch(h){return u.push({path:"",message:`Validation failed: ${h}`,rule:"system"}),{isValid:!1,errors:u,warnings:f}}};if(l)return await At.track("validateConfiguration",c);return c()}async validateWithSchemaFile(e,n,t){try{if(!_m(n))throw new Tt(n,[{path:"",message:"Schema file does not exist"}]);let s=await import(n),i=s.default||s;if(Array.isArray(i))return this.validateWithRules(e,i,t);else return this.validateWithJSONSchema(e,i,t)}catch(s){throw new Tt(n,[{path:"",message:`Failed to load schema: ${s}`}])}}validateWithJSONSchema(e,n,t){let s=[],i=[];return this.validateObjectAgainstSchema(e,n,"",s,i,t),{isValid:s.length===0,errors:s,warnings:i}}validateObjectAgainstSchema(e,n,t,s,i,r){if(r.validateTypes&&n.type){let o=Array.isArray(e)?"array":typeof e,l=Array.isArray(n.type)?n.type:[n.type];if(!l.includes(o)){if(s.push({path:t,message:`Expected type ${l.join(" or ")}, got ${o}`,expected:l.join(" or "),actual:o,rule:"type"}),r.stopOnFirstError)return}}if(n.enum&&!n.enum.includes(e)){if(s.push({path:t,message:`Value must be one of: ${n.enum.join(", ")}`,expected:n.enum.join(", "),actual:e,rule:"enum"}),r.stopOnFirstError)return}if(typeof e==="string"){if(n.minLength!==void 0&&e.length<n.minLength)s.push({path:t,message:`String length must be at least ${n.minLength}`,expected:`>= ${n.minLength}`,actual:e.length,rule:"minLength"});if(n.maxLength!==void 0&&e.length>n.maxLength)s.push({path:t,message:`String length must not exceed ${n.maxLength}`,expected:`<= ${n.maxLength}`,actual:e.length,rule:"maxLength"});if(n.pattern){if(!new RegExp(n.pattern).test(e))s.push({path:t,message:`String does not match pattern ${n.pattern}`,expected:n.pattern,actual:e,rule:"pattern"})}}if(typeof e==="number"){if(n.minimum!==void 0&&e<n.minimum)s.push({path:t,message:`Value must be at least ${n.minimum}`,expected:`>= ${n.minimum}`,actual:e,rule:"minimum"});if(n.maximum!==void 0&&e>n.maximum)s.push({path:t,message:`Value must not exceed ${n.maximum}`,expected:`<= ${n.maximum}`,actual:e,rule:"maximum"})}if(Array.isArray(e)&&n.items)for(let o=0;o<e.length;o++){let l=t?`${t}[${o}]`:`[${o}]`;if(this.validateObjectAgainstSchema(e[o],n.items,l,s,i,r),r.stopOnFirstError&&s.length>0)return}if(e&&typeof e==="object"&&!Array.isArray(e)){let o=e;if(r.validateRequired&&n.required){for(let l of n.required)if(!(l in o)){if(s.push({path:t?`${t}.${l}`:l,message:`Missing required property '${l}'`,expected:"required",rule:"required"}),r.stopOnFirstError)return}}if(n.properties){for(let[l,a]of Object.entries(n.properties))if(l in o){let c=t?`${t}.${l}`:l;if(this.validateObjectAgainstSchema(o[l],a,c,s,i,r),r.stopOnFirstError&&s.length>0)return}}if(n.additionalProperties===!1){let l=new Set(Object.keys(n.properties||{}));for(let a of Object.keys(o))if(!l.has(a))i.push({path:t?`${t}.${a}`:a,message:`Additional property '${a}' is not allowed`,rule:"additionalProperties"})}}}validateWithRules(e,n,t){let s=[],i=[];for(let r of n)try{let o=this.getValueByPath(e,r.path),l=this.validateWithRule(o,r,r.path);if(s.push(...l),t.stopOnFirstError&&s.length>0)break}catch(o){s.push({path:r.path,message:`Rule validation failed: ${o}`,rule:"system"})}return{isValid:s.length===0,errors:s,warnings:i}}validateWithRule(e,n,t){let s=[];if(n.required&&(e===void 0||e===null))return s.push({path:t,message:n.message||`Property '${t}' is required`,expected:"required",rule:"required"}),s;if(e===void 0||e===null)return s;if(n.type){let i=Array.isArray(e)?"array":typeof e;if(i!==n.type)s.push({path:t,message:n.message||`Expected type ${n.type}, got ${i}`,expected:n.type,actual:i,rule:"type"})}if(n.min!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i<n.min)s.push({path:t,message:n.message||`Value must be at least ${n.min}`,expected:`>= ${n.min}`,actual:i,rule:"min"})}if(n.max!==void 0){let i=Array.isArray(e)?e.length:typeof e==="string"?e.length:typeof e==="number"?e:0;if(i>n.max)s.push({path:t,message:n.message||`Value must not exceed ${n.max}`,expected:`<= ${n.max}`,actual:i,rule:"max"})}if(n.pattern&&typeof e==="string"){if(!n.pattern.test(e))s.push({path:t,message:n.message||`Value does not match pattern ${n.pattern}`,expected:n.pattern.toString(),actual:e,rule:"pattern"})}if(n.enum&&!n.enum.includes(e))s.push({path:t,message:n.message||`Value must be one of: ${n.enum.join(", ")}`,expected:n.enum.join(", "),actual:e,rule:"enum"});if(n.validator){let i=n.validator(e);if(i)s.push({path:t,message:n.message||i,rule:"custom"})}return s}getValueByPath(e,n){if(!n)return e;let t=n.split("."),s=e;for(let i of t)if(s&&typeof s==="object"&&i in s)s=s[i];else return;return s}generateRulesFromInterface(e){let n=[],t=e.matchAll(/(\w+)(\?)?:\s*(\w+)/g);for(let s of t){let[,i,r,o]=s;n.push({path:i,required:!r,type:this.mapTypeScriptType(o)})}return n}mapTypeScriptType(e){switch(e.toLowerCase()){case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"array":return"array";case"object":return"object";default:return"object"}}static createCommonRules(){return{server:[{path:"port",required:!0,type:"number",min:1,max:65535},{path:"host",required:!0,type:"string",min:1},{path:"ssl",type:"boolean"}],database:[{path:"url",required:!0,type:"string",min:1},{path:"pool",type:"number",min:1,max:100},{path:"timeout",type:"number",min:0}],api:[{path:"baseUrl",required:!0,type:"string",pattern:$o},{path:"timeout",type:"number",min:0},{path:"retries",type:"number",min:0,max:10}]}}}class Ci{fileLoader=new wn;envProcessor=new xn;validator=new Mi;async loadConfig(e){let n=Date.now(),{cache:t,performance:s,schema:i,validate:r,...o}=e;try{if(t?.enabled){let a=this.checkCache(o.name||"",o);if(a)return a}let l;try{l=await this.loadConfigurationStrategies(o,!0,t)}catch(a){let c=o.__strictErrorHandling;if(a instanceof Error&&a.name==="ConfigNotFoundError"){if(c)throw a;l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`No configuration file found for "${o.name||"config"}", using defaults with environment variables`]}}else if(a instanceof Error&&a.name==="ConfigLoadError"){let u=a.message.includes("EACCES")||a.message.includes("EPERM")||a.message.includes("permission denied"),f=!u&&(a.message.includes("syntax")||a.message.includes("Expected")||a.message.includes("Unexpected")||a.message.includes("BuildMessage")||a.message.includes("errors building")),m=a.message.includes("Configuration must export a valid object")||a.message.includes("Configuration file is empty and exports nothing");if(c&&(m||u))throw a;if(f&&(!c||!m))l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:["Configuration file has syntax errors, using defaults with environment variables"]};else if(!c)l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading error, using defaults: ${a.message}`]};else throw a}else l={...await this.applyEnvironmentVariables(o.name||"",o.defaultConfig,o.checkEnv!==!1,o.verbose||!1),warnings:[`Configuration loading failed, using defaults: ${a instanceof Error?a.message:String(a)}`]}}if(i||r)await this.validateConfiguration(l.config,i,r,o.name);if(t?.enabled&&l)this.cacheResult(o.name||"",l,t,o);if(s?.enabled){let a={operation:"loadConfig",duration:Date.now()-n,configName:o.name,timestamp:new Date};if(s.onMetrics)s.onMetrics(a);if(s.slowThreshold&&a.duration>s.slowThreshold)_e.warn(`Slow configuration loading detected: ${a.duration}ms for ${o.name}`);l.metrics=a}return l}catch(l){let a=Date.now()-n;throw _e.error(`Configuration loading failed after ${a}ms:`,[l instanceof Error?l:Error(String(l))]),l}}async loadConfigurationStrategies(e,n=!1,t){let{name:s="",alias:i,cwd:r,configDir:o,defaultConfig:l,checkEnv:a=!0,arrayStrategy:c="replace",verbose:u=!1}=e,f=r||nt.cwd(),m=[],h=await this.loadLocalConfiguration(s,i,f,o,l,c,u,a,t);if(h)return m.push(...this.getLocalSearchPaths(s,i,f,o)),this.finalizeResult(h,m,a,s,u);let d=await this.loadHomeConfiguration(s,i,l,c,u,a);if(d)return m.push(...this.getHomeSearchPaths(s,i)),this.finalizeResult(d,m,a,s,u);let p=await this.loadPackageJsonConfiguration(s,i,f,l,c,u,a);if(p)return m.push(Ce(f,"package.json")),this.finalizeResult(p,m,a,s,u);if(m.push(...this.getAllSearchPaths(s,i,f,o)),n)throw Je.configNotFound(s,m,i);return{...await this.applyEnvironmentVariables(s,l,a,u),warnings:[`No configuration file found for "${s}"${i?` or alias "${i}"`:""}, using defaults with environment variables`]}}async loadLocalConfiguration(e,n,t,s,i,r,o,l,a){let c=l?St(e,i,o):i,u=this.getLocalDirectories(t,s);for(let f of u){if(o)_e.info(`Searching for configuration in: ${f}`);let m=this.fileLoader.generateConfigPaths(e,f,n),h=await this.fileLoader.tryLoadFromPaths(m,c,{arrayStrategy:r,verbose:o,cacheTtl:a?.ttl,useCache:!a?.ttl||a.ttl>100});if(h){if(o)_e.success(`Configuration loaded from: ${h.source.path}`);return h}}return null}async loadHomeConfiguration(e,n,t,s,i,r){if(!e)return null;let o=r?St(e,t,i):t,l=[Ce(ct(),".config",e),Ce(ct(),".config"),ct()];for(let a of l){if(i)_e.info(`Checking home directory: ${a}`);let c=this.fileLoader.generateConfigPaths(e,a,n),u=await this.fileLoader.tryLoadFromPaths(c,o,{arrayStrategy:s,verbose:i});if(u){if(i)_e.success(`Configuration loaded from home directory: ${u.source.path}`);return u}}return null}async loadPackageJsonConfiguration(e,n,t,s,i,r,o){let l=o?St(e,s,r):s;try{let a=Ce(t,"package.json");if(!fi(a))return null;let c=await import(a),u=c[e],f=e;if(!u&&n)u=c[n],f=n;if(u&&typeof u==="object"&&!Array.isArray(u)){if(r)_e.success(`Configuration loaded from package.json: ${f}`);return{config:vi(l,u,i),source:{type:"package.json",path:a,priority:30,timestamp:new Date}}}}catch(a){if(r)_e.warn("Failed to load package.json:",[a instanceof Error?a:Error(String(a))])}return null}async applyEnvironmentVariables(e,n,t,s){if(!t||!e||typeof n!=="object"||n===null||Array.isArray(n))return{config:n,source:{type:"default",priority:10,timestamp:new Date}};return{config:St(e,n,s),source:{type:"environment",priority:20,timestamp:new Date}}}async finalizeResult(e,n,t,s,i){return{config:e.config,source:e.source,path:e.source.path}}async validateConfiguration(e,n,t,s){let i=[];if(t){let r=t(e);if(r)i.push(...r)}if(n){let r=await this.validator.validateConfiguration(e,n);if(!r.isValid)i.push(...r.errors.map((o)=>o.path?`${o.path}: ${o.message}`:o.message))}if(i.length>0)throw Je.configValidation(s||"unknown",i,s)}checkCache(e,n){let t=this.generateCacheKey(e,n);return xt.get(t)||null}cacheResult(e,n,t,s){let i=this.generateCacheKey(e,s);xt.set(i,n,void 0,t.ttl)}generateCacheKey(e,n){let t=[e];if(n.alias)t.push(`alias:${n.alias}`);if(n.cwd)t.push(`cwd:${n.cwd}`);if(n.configDir)t.push(`configDir:${n.configDir}`);if("checkEnv"in n)t.push(`checkEnv:${n.checkEnv}`);return t.join("|")}getLocalDirectories(e,n){return Array.from(new Set([e,Ce(e,"config"),Ce(e,".config"),n?Ce(e,n):void 0].filter(Boolean)))}getAllSearchPaths(e,n,t,s){let i=[];return i.push(...this.getLocalSearchPaths(e,n,t,s)),i.push(...this.getHomeSearchPaths(e,n)),i.push(Ce(t,"package.json")),i}getLocalSearchPaths(e,n,t,s){let i=this.getLocalDirectories(t,s),r=[];for(let o of i)r.push(...this.fileLoader.generateConfigPaths(e,o,n));return r}getHomeSearchPaths(e,n){if(!e)return[];let t=[Ce(ct(),".config",e),Ce(ct(),".config"),ct()],s=[];for(let i of t)s.push(...this.fileLoader.generateConfigPaths(e,i,n));return s}async loadConfigWithResult(e){return this.loadConfig(e)}}function Br(e){let t=!(e.message.includes("EACCES")||e.message.includes("EPERM")||e.message.includes("permission denied"))&&(e.message.includes("syntax")||e.message.includes("Expected")||e.message.includes("Unexpected")||e.message.includes("BuildMessage")),s=e.message.includes("Configuration must export a valid object")||e.message.includes("Configuration file is empty and exports nothing");return t||s}async function rh(e){return He.loadConfig({...e,__strictErrorHandling:!0})}async function yo(e){let n="defaultConfig"in e&&e.defaultConfig!==void 0?e.defaultConfig:{},t="cache"in e||"performance"in e||"schema"in e||"validate"in e;try{let s;if(t)s=await He.loadConfig(e);else s=await He.loadConfig({...e,defaultConfig:n,cache:{enabled:!0},performance:{enabled:!1}});return s?.config??n}catch(s){let i=s instanceof Error?s.name:"UnknownError",r=s instanceof Error?s.message:String(s);if(!(i==="ConfigNotFoundError"||i==="ConfigLoadError"||i==="ConfigValidationError"||r.includes("config"))&&e.verbose)_e.warn("Unexpected error loading config, using defaults:",[s instanceof Error?s:Error(String(s))]);let l=t?{...e,defaultConfig:n}:{...e,defaultConfig:n,cache:{enabled:!0},performance:{enabled:!1}};if("checkEnv"in e?e.checkEnv!==!1:!0)return(await He.applyEnvironmentVariables(l.name||"",n,!0,l.verbose||!1))?.config??n;return n}}async function oh(e={defaultConfig:{}}){if(typeof e==="string"){let{cwd:n}=await import("process");try{return(await He.loadConfig({name:e,cwd:n(),generatedDir:"./generated",configDir:"./config",defaultConfig:{},checkEnv:!0,arrayStrategy:"replace"})).config}catch(t){if(t instanceof Error&&(t.name==="ConfigNotFoundError"||t.name==="ConfigLoadError"&&Br(t)))return(await He.applyEnvironmentVariables(e,{},!0,!1)).config;throw t}}try{return(await He.loadConfig({...e,cwd:e.cwd||nt.cwd(),cache:{enabled:!0},performance:{enabled:!1}})).config}catch(n){if(n instanceof Error&&(n.name==="ConfigNotFoundError"||n.name==="ConfigLoadError"&&Br(n)))return(await He.applyEnvironmentVariables(e.name||"",e.defaultConfig||{},e.checkEnv!==!1,e.verbose||!1)).config;throw n}}async function lh(e,n,t="replace"){let s=new wn;try{let i=await s.loadFromPath(e,n,{arrayStrategy:t,useCache:!1,trackPerformance:!1});return i?i.config:null}catch{return null}}function St(e,n,t=!1){let s=new xn,i=e.toUpperCase().replace(/[^A-Z0-9]/g,"_");function r(o,l=[]){let a={...o};for(let[c,u]of Object.entries(o)){let f=[...l,c],m=[`${i}_${f.join("_").toUpperCase()}`,`${i}_${f.map((p)=>p.toUpperCase()).join("")}`,`${i}_${f.map((p)=>p.replace(/([A-Z])/g,"_$1").toUpperCase()).join("")}`],h,d;for(let p of m)if(h=nt.env[p],h!==void 0){d=p;break}if(h!==void 0&&d)if(typeof u==="boolean")a[c]=["true","1","yes"].includes(h.toLowerCase());else if(typeof u==="number"){let p=Number(h);if(!Number.isNaN(p))a[c]=p}else if(Array.isArray(u))try{a[c]=JSON.parse(h)}catch{a[c]=h.split(",").map((p)=>p.trim())}else a[c]=h;else if(u&&typeof u==="object"&&!Array.isArray(u))a[c]=r(u,f)}return a}return r(n)}function ah(e){let n=Ce(nt.cwd(),e.configDir),t=Ce(nt.cwd(),e.generatedDir),s=Ce(t,"config-types.ts");if(!fi(Pr(s)))mm(Pr(s),{recursive:!0,mode:511});let i=fi(n)?hm(n).map((o)=>o.replace(/\.(ts|js|mjs|cjs|mts|cts|json)$/,"")).sort():[],r=`// Generated by bunfig v${Fh}
32
+ export type ConfigNames = ${i.length?`'${i.join("' | '")}'`:"string"}
33
+ `;dm(s,r,{mode:438})}function ch(e){let n=null,t=null,s=()=>{if(!t)t=yo(e).then((r)=>(n=r,r),(r)=>{let o="defaultConfig"in e?e.defaultConfig:{};if(n=o,"verbose"in e&&e.verbose)_e.warn("Config loading failed, using defaults:",[r instanceof Error?r:Error(String(r))]);return o});return t},i="defaultConfig"in e?e.defaultConfig:{};return n=i,s(),new Proxy({},{get(r,o){if(n)return n[o];let l=i[o];return s(),l},has(r,o){return o in(n||i)},ownKeys(){return Object.keys(n||i)},getOwnPropertyDescriptor(r,o){return Object.getOwnPropertyDescriptor(n||i,o)},set(r,o,l){if(!n)n={...i};return n[o]=l,!0}})}function uh(e){let n=Wr(Nm.cwd(),e?.configDir||"./config");function t(){if(!Dm(n))return[];let i=new Set([".ts",".js",".mjs",".cjs",".mts",".cts",".json"]),r=[".ts",".mts",".cts",".js",".mjs",".cjs",".json"],o=Fm(n).filter((a)=>i.has(ni(a))).map((a)=>({base:a.replace(/\.(?:ts|js|mjs|cjs|mts|cts|json)$/i,""),file:a})),l=new Map;for(let{base:a,file:c}of o){let u=ni(c).toLowerCase(),f=l.get(a);if(!f){l.set(a,c);continue}let m=ni(f).toLowerCase();if(r.indexOf(u)<r.indexOf(m))l.set(a,c)}return Array.from(l.entries()).map(([a,c])=>({base:a,file:c})).sort((a,c)=>a.base.localeCompare(c.base))}function s(){let i=t(),r=i.map((c)=>c.base),o=r.length?r.map((c)=>`'${c}'`).join(" | "):"string",l=i.length?`{
34
+ ${i.map((c)=>{let u=Wr(n,c.file).replace(/\\/g,"/");return` '${c.base}': typeof import('${u}').default`}).join(`,
35
+ `)}
36
+ }`:"Record<string, any>";return`export type ConfigNames = ${o}
37
+ export type ConfigByName = ${l}
38
+ export type Config<N extends ConfigNames> = N extends keyof ConfigByName ? ConfigByName[N] : unknown
39
+ export type ConfigOf = Config
40
+ `}return{name:"bunfig-plugin",setup(i){i.onResolve({filter:/^virtual:bunfig-types$/},(r)=>({path:r.path,namespace:"bunfig-virtual"})),i.onLoad({filter:/^virtual:bunfig-types$/,namespace:"bunfig-virtual"},()=>({contents:s(),loader:"ts"}))}}}var bo,xt,At,xo,fh,mh,jr,sn,di,Pe,ce,hh,Ur,dh,zr,ph,gh,si,yh,qr,Kr,ii,bh,xh,wh,Rh,rn,wo,kh,Ie,$h,Ph,Vr,on,pi,be,oe,Ih,Hr,vh,Zr,Mh,Ch,ri,Sh,Gr,Jr,Eh,oi,Lh,Th,Ah,Oh,_h,ln,Ro,Dh,Fh="0.15.6",Ee,pn,Lt,gi,yi,gn,bi,xi,Tt,wi,Ri,Je,ko,$o,_e,He,Po,Io,Nh=fm(async()=>{bo=import.meta.require,xt=new ki,At=new $i,xo={createKey:Wm,isEquivalent:Bm,estimateMemoryUsage:jm},fh=un(mi.cwd(),"config"),mh=un(mi.cwd(),"src/generated"),jr=cn.env.CLARITY_LOG_DIR||ym(qm(),"logs"),sn={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:jr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1},di=await Km(),Pe={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,reset:"\x1B[0m"},ce=Pe,hh=Pe.red,Ur=Pe.green,dh=Pe.yellow,zr=Pe.blue,ph=Pe.magenta,gh=Pe.cyan,si=Pe.white,yh=Pe.gray,qr=Pe.bgRed,Kr=Pe.bgYellow,ii=Pe.bold,bh=Pe.dim,xh=Pe.italic,wh=Pe.underline,Rh=Pe.reset,rn={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},wo={debug:"\uD83D\uDD0D",info:zr("\u2139"),success:Ur("\u2713"),warning:Kr(si(ii(" WARN "))),error:qr(si(ii(" ERROR ")))},kh=new mn("stacks"),Ie=new mn("bunfig",{showTags:!0}),$h=Me(Et.cwd(),"config"),Ph=Me(Et.cwd(),"src/generated"),Vr=an.env.CLARITY_LOG_DIR||pm(Gm(),"logs"),on={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Vr,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},pi=await Jm(),be={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},oe=be,Ih=be.red,Hr=be.green,vh=be.yellow,Zr=be.blue,Mh=be.magenta,Ch=be.cyan,ri=be.white,Sh=be.gray,Gr=be.bgRed,Jr=be.bgYellow,Eh=be.bgGray,oi=be.bold,Lh=be.dim,Th=be.italic,Ah=be.underline,Oh=be.strikethrough,_h=be.reset,ln={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},Ro={debug:"\uD83D\uDD0D",info:Zr("\u2139"),success:Hr("\u2713"),warning:Jr(ri(oi(" WARN "))),error:Gr(ri(oi(" ERROR ")))},Dh=new dn("stacks"),Ee=class extends Error{timestamp;context;constructor(n,t={}){super(n);if(this.name=this.constructor.name,this.timestamp=new Date,this.context=t,Error.captureStackTrace)Error.captureStackTrace(this,this.constructor)}toJSON(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp.toISOString(),context:this.context,stack:this.stack}}toString(){let n=Object.keys(this.context).length>0?` (${Object.entries(this.context).map(([t,s])=>`${t}: ${s}`).join(", ")})`:"";return`${this.name} [${this.code}]: ${this.message}${n}`}},pn=class extends Ee{code="CONFIG_NOT_FOUND";constructor(n,t,s){let i=s?` or alias "${s}"`:"";super(`Configuration "${n}"${i} not found`,{configName:n,alias:s,searchPaths:t,searchPathCount:t.length})}},Lt=class extends Ee{code="CONFIG_LOAD_ERROR";constructor(n,t,s){super(`Failed to load configuration from "${n}": ${t.message}`,{configPath:n,configName:s,originalError:t.name,originalMessage:t.message});this.cause=t}},gi=class extends Ee{code="CONFIG_VALIDATION_ERROR";constructor(n,t,s){super(`Configuration validation failed for "${n}"`,{configPath:n,configName:s,validationErrors:t,errorCount:t.length})}},yi=class extends Ee{code="CONFIG_MERGE_ERROR";constructor(n,t,s,i){super(`Failed to merge configuration from "${n}" with "${t}": ${s.message}`,{sourcePath:n,targetPath:t,configName:i,originalError:s.name,originalMessage:s.message});this.cause=s}},gn=class extends Ee{code="ENV_VAR_ERROR";constructor(n,t,s,i){super(`Failed to parse environment variable "${n}" with value "${t}" as ${s}`,{envKey:n,envValue:t,expectedType:s,configName:i})}},bi=class extends Ee{code="FILE_SYSTEM_ERROR";constructor(n,t,s){super(`File system ${n} failed for "${t}": ${s.message}`,{operation:n,path:t,originalError:s.name,originalMessage:s.message});this.cause=s}},xi=class extends Ee{code="TYPE_GENERATION_ERROR";constructor(n,t,s){super(`Failed to generate types from "${n}" to "${t}": ${s.message}`,{configDir:n,outputPath:t,originalError:s.name,originalMessage:s.message});this.cause=s}},Tt=class extends Ee{code="SCHEMA_VALIDATION_ERROR";constructor(n,t,s){super(`Schema validation failed${s?` for config "${s}"`:""}`,{schemaPath:n,configName:s,validationErrors:t,errorCount:t.length})}},wi=class extends Ee{code="BROWSER_CONFIG_ERROR";constructor(n,t,s,i){super(`Failed to fetch configuration from "${n}": ${t} ${s}`,{endpoint:n,status:t,statusText:s,configName:i})}},Ri=class extends Ee{code="PLUGIN_ERROR";constructor(n,t,s){super(`Plugin "${n}" failed during ${t}: ${s.message}`,{pluginName:n,operation:t,originalError:s.name,originalMessage:s.message});this.cause=s}},Je={configNotFound(e,n,t){return new pn(e,n,t)},configLoad(e,n,t){return new Lt(e,n,t)},configValidation(e,n,t){return new gi(e,n,t)},configMerge(e,n,t,s){return new yi(e,n,t,s)},envVar(e,n,t,s){return new gn(e,n,t,s)},fileSystem(e,n,t){return new bi(e,n,t)},typeGeneration(e,n,t){return new xi(e,n,t)},schemaValidation(e,n,t){return new Tt(e,n,t)},browserConfig(e,n,t,s){return new wi(e,n,t,s)},plugin(e,n,t){return new Ri(e,n,t)}},ko={replace:"replace",concat:"concat",smart:"smart"},$o=/^https?:\/\//,_e=new dn("bunfig",{showTags:!0}),He=new Ci,Po=Ce(nt.cwd(),"config"),Io=Ce(nt.cwd(),"src/generated")});function jh(e,n={}){let t=yn.cwd();while(t.includes("storage"))t=Yr(t,"..");let s=Yr(t,e||"");if(n?.relative)return Bh(yn.cwd(),s);return s}var Uh=yn.env.CLARITY_LOG_DIR||Wh(jh(),"logs"),vo={level:"info",defaultName:"clarity",timestamp:!0,colors:!0,format:"text",maxLogSize:10485760,logDatePattern:"YYYY-MM-DD",logDirectory:Uh,rotation:{frequency:"daily",maxSize:10485760,maxFiles:5,compress:!1,rotateHour:0,rotateMinute:0,rotateDayOfWeek:0,rotateDayOfMonth:1,encrypt:!1},verbose:!1,writeToFile:!1},bn={...vo},fy=(async()=>{try{let{loadConfig:e}=await Nh().then(()=>oo),n=await e({name:"clarity",alias:"logging",defaultConfig:vo,cwd:yn.cwd()});if(n)Object.assign(bn,n)}catch{}return bn})();function xe(){if(Ve.env.NODE_ENV==="test"||Ve.env.BUN_ENV==="test")return!1;return typeof window<"u"}async function Xh(){if(Ve.env.NODE_ENV==="test"||Ve.env.BUN_ENV==="test")return!0;if(typeof navigator<"u"&&navigator.product==="ReactNative")return!0;if(typeof Ve<"u"){let e=Ve.type;if(e==="renderer"||e==="worker")return!1;return!!(Ve.versions&&(Ve.versions.node||Ve.versions.bun))}return!1}class Mo{async format(e){let n=await Xh(),t=await this.getMetadata(n);return JSON.stringify({timestamp:e.timestamp.toISOString(),level:e.level,name:e.name,message:e.message,metadata:t})}async getMetadata(e){if(e){let{hostname:n}=await import("os");return{pid:bt.pid,hostname:n(),environment:bt.env.NODE_ENV||"development",platform:bt.platform,version:bt.version}}return{userAgent:navigator.userAgent,hostname:window.location.hostname||"browser",environment:bt.env.NODE_ENV||bt.env.BUN_ENV||"development",viewport:{width:window.innerWidth,height:window.innerHeight},language:navigator.language}}}var Re={red:(e)=>`\x1B[31m${e}\x1B[0m`,green:(e)=>`\x1B[32m${e}\x1B[0m`,yellow:(e)=>`\x1B[33m${e}\x1B[0m`,blue:(e)=>`\x1B[34m${e}\x1B[0m`,magenta:(e)=>`\x1B[35m${e}\x1B[0m`,cyan:(e)=>`\x1B[36m${e}\x1B[0m`,white:(e)=>`\x1B[37m${e}\x1B[0m`,gray:(e)=>`\x1B[90m${e}\x1B[0m`,bgRed:(e)=>`\x1B[41m${e}\x1B[0m`,bgYellow:(e)=>`\x1B[43m${e}\x1B[0m`,bgGray:(e)=>`\x1B[100m${e}\x1B[0m`,bold:(e)=>`\x1B[1m${e}\x1B[0m`,dim:(e)=>`\x1B[2m${e}\x1B[0m`,italic:(e)=>`\x1B[3m${e}\x1B[0m`,underline:(e)=>`\x1B[4m${e}\x1B[0m`,strikethrough:(e)=>`\x1B[9m${e}\x1B[0m`,reset:"\x1B[0m"},le=Re,ky=Re.red,Qh=Re.green,$y=Re.yellow,ed=Re.blue,Py=Re.magenta,Iy=Re.cyan,io=Re.white,vy=Re.gray,td=Re.bgRed,nd=Re.bgYellow,My=Re.bgGray,ro=Re.bold,Cy=Re.dim,Sy=Re.italic,Ey=Re.underline,Ly=Re.strikethrough,Ty=Re.reset,ui={activationLevel:"error",bufferSize:50,flushOnDeactivation:!0,stopBuffering:!1},sd={debug:"\uD83D\uDD0D",info:ed("\u2139"),success:Qh("\u2713"),warning:nd(io(ro(" WARN "))),error:td(io(ro(" ERROR ")))};class st{name;fileLocks=new Map;currentKeyId=null;keys=new Map;fingersCrossedConfig;fingersCrossedActive=!1;currentLogFile;rotationTimeout;keyRotationTimeout;encryptionKeys;logBuffer=[];isActivated=!1;pendingOperations=[];enabled;fancy;tagFormat;timestampPosition;environment;config;options;formatter;timers=new Set;subLoggers=new Set;fingersCrossedBuffer=[];ANSI_PATTERN=/\u001B\[.*?m/g;activeProgressBar=null;constructor(e,n={}){this.name=e,this.config={...bn},this.options=this.normalizeOptions(n),this.formatter=this.options.formatter||new Mo,this.enabled=n.enabled??!0,this.fancy=n.fancy??!0,this.tagFormat=n.tagFormat??{prefix:"[",suffix:"]"},this.timestampPosition=n.timestampPosition??"right",this.environment=n.environment??re.env.APP_ENV??"local",this.fingersCrossedConfig=this.initializeFingersCrossedConfig(n);let t={...n},s=n.timestamp!==void 0;if(s)delete t.timestamp;if(this.config={...this.config,...t,timestamp:s||this.config.timestamp,level:this.options.level??"info"},this.currentLogFile=this.generateLogFilename(),this.encryptionKeys=new Map,this.validateEncryptionConfig()){this.setupRotation();let i=this.generateKeyId(),r=this.generateKey();this.currentKeyId=i,this.keys.set(i,r),this.encryptionKeys.set(i,{key:r,createdAt:new Date}),this.setupKeyRotation()}}shouldActivateFingersCrossed(e){if(!this.fingersCrossedConfig)return!1;let n={debug:0,info:1,success:2,warning:3,error:4},t=this.fingersCrossedConfig.activationLevel??"error";return n[e]>=n[t]}initializeFingersCrossedConfig(e){if(!e.fingersCrossedEnabled&&e.fingersCrossed)return{...ui,...e.fingersCrossed};if(!e.fingersCrossedEnabled)return null;if(!e.fingersCrossed)return{...ui};return{...ui,...e.fingersCrossed}}normalizeOptions(e){let n={format:"json",level:"info",logDirectory:bn.logDirectory,rotation:void 0,timestamp:void 0,fingersCrossed:{},enabled:!0,showTags:!1,showIcons:!0,formatter:void 0},t={...n,...Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0))};if(!t.level||!["debug","info","success","warning","error"].includes(t.level))t.level=n.level;return t}shouldWriteToFile(){return!xe()&&this.config.writeToFile===!0}async writeToFile(e){let t=(async()=>{let i,r=0,o=3,l=1000;while(r<o)try{try{try{await Hh(this.config.logDirectory,to.F_OK|to.W_OK)}catch(c){if(c instanceof Error&&"code"in c)if(c.code==="ENOENT")await Zh(this.config.logDirectory,{recursive:!0,mode:493});else if(c.code==="EACCES")throw Error(`No write permission for log directory: ${this.config.logDirectory}`);else throw c;else throw c}}catch(c){throw console.error("Debug: [writeToFile] Failed to create log directory:",c),c}let a=this.validateEncryptionConfig()?(await this.encrypt(e)).encrypted:ze.from(e);try{if(!Qt(this.currentLogFile))await ci(this.currentLogFile,"",{mode:420});if(i=eo(this.currentLogFile,"a",420),Vh(i,a,{flag:"a"}),Qr(i),i!==void 0)ai(i),i=void 0;if((await gt(this.currentLogFile)).size===0){if(await ci(this.currentLogFile,a,{flag:"w",mode:420}),(await gt(this.currentLogFile)).size===0)throw Error("File exists but is empty after retry write")}return}catch(c){let u=c;if(u.code&&["ENETDOWN","ENETUNREACH","ENOTFOUND","ETIMEDOUT"].includes(u.code)){if(r<o-1){let f=typeof u.message==="string"?u.message:"Unknown error";console.error(`Network error during write attempt ${r+1}/${o}:`,f);let m=l*2**r;await new Promise((h)=>setTimeout(h,m)),r++;continue}}if(u?.code&&["ENOSPC","EDQUOT"].includes(u.code))throw Error(`Disk quota exceeded or no space left on device: ${u.message}`);throw console.error("Debug: [writeToFile] Error writing to file:",u),u}finally{if(i!==void 0)try{ai(i)}catch(c){console.error("Debug: [writeToFile] Error closing file descriptor:",c)}}}catch(a){if(r===o-1){let u=a,f=typeof u.message==="string"?u.message:"Unknown error";throw console.error("Debug: [writeToFile] Max retries reached. Final error:",f),a}r++;let c=l*2**(r-1);await new Promise((u)=>setTimeout(u,c))}})();this.pendingOperations.push(t);let s=this.pendingOperations.length-1;try{await t}catch(i){throw console.error("Debug: [writeToFile] Error in operation:",i),i}finally{this.pendingOperations.splice(s,1)}}generateLogFilename(){if(this.name.includes("stream-throughput")||this.name.includes("decompress-perf-test")||this.name.includes("decompression-latency")||this.name.includes("concurrent-read-test")||this.name.includes("clock-change-test"))return yt(this.config.logDirectory,`${this.name}.log`);if(this.name.includes("pending-test")||this.name.includes("temp-file-test")||this.name==="crash-test"||this.name==="corrupt-test"||this.name.includes("rotation-load-test")||this.name==="sigterm-test"||this.name==="sigint-test"||this.name==="failed-rotation-test"||this.name==="integration-test")return yt(this.config.logDirectory,`${this.name}.log`);let e=new Date().toISOString().split("T")[0];return yt(this.config.logDirectory,`${this.name}-${e}.log`)}setupRotation(){if(xe())return;if(!this.shouldWriteToFile())return;if(typeof this.config.rotation==="boolean")return;let e=this.config.rotation,n;switch(e.frequency){case"daily":n=86400000;break;case"weekly":n=604800000;break;case"monthly":n=2592000000;break;default:return}this.rotationTimeout=setInterval(()=>{this.rotateLog()},n)}setupKeyRotation(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation setup");return}let n=this.config.rotation.keyRotation;if(!n?.enabled)return;let t=typeof n.interval==="number"?n.interval:60,s=Math.max(t,60)*1000;this.keyRotationTimeout=setInterval(()=>{this.rotateKeys().catch((i)=>{console.error("Error rotating keys:",i)})},s)}async rotateKeys(){if(!this.validateEncryptionConfig()){console.error("Invalid encryption configuration detected during key rotation");return}let n=this.config.rotation.keyRotation,t=this.generateKeyId(),s=this.generateKey();this.currentKeyId=t,this.keys.set(t,s),this.encryptionKeys.set(t,{key:s,createdAt:new Date});let i=Array.from(this.encryptionKeys.entries()).sort(([,l],[,a])=>a.createdAt.getTime()-l.createdAt.getTime()),r=typeof n.maxKeys==="number"?n.maxKeys:1,o=Math.max(1,r);if(i.length>o)for(let[l]of i.slice(o))this.encryptionKeys.delete(l),this.keys.delete(l)}generateKeyId(){return li(16).toString("hex")}generateKey(){return li(32)}getCurrentKey(){if(!this.currentKeyId)throw Error("Encryption is not properly initialized. Make sure encryption is enabled in the configuration.");let e=this.keys.get(this.currentKeyId);if(!e)throw Error(`No key found for ID ${this.currentKeyId}. The encryption key may have been rotated or removed.`);return{key:e,id:this.currentKeyId}}encrypt(e){let{key:n}=this.getCurrentKey(),t=li(16),s=zh("aes-256-gcm",n,t),i=ze.isBuffer(e)?e:ze.from(e,"utf8"),r=s.update(i),o=s.final(),l=r.length+o.length,a=s.getAuthTag(),c=ze.allocUnsafe(16+l+16);return t.copy(c,0),r.copy(c,16),o.copy(c,16+r.length),a.copy(c,16+l),{encrypted:c,iv:t}}async compressData(e){return new Promise((n,t)=>{let s=so(),i=[];s.on("data",(r)=>i.push(r)),s.on("end",()=>n(ze.from(ze.concat(i)))),s.on("error",t),s.write(e),s.end()})}getEncryptionOptions(){if(!this.config.rotation||typeof this.config.rotation==="boolean"||!this.config.rotation.encrypt)return{};let e={algorithm:"aes-256-cbc",compress:!1};if(typeof this.config.rotation.encrypt==="object"){let n=this.config.rotation.encrypt;return{...e,...n}}return e}async rotateLog(){if(xe())return;if(!this.shouldWriteToFile())return;let e=await gt(this.currentLogFile).catch(()=>null);if(!e)return;let n=this.config.rotation;if(typeof n==="boolean")return;if(n.maxSize&&e.size>=n.maxSize){let t=this.currentLogFile,s=this.generateLogFilename();if(this.name.includes("rotation-load-test")||this.name==="failed-rotation-test"){let i=await en(this.config.logDirectory),r=i.filter((a)=>a.startsWith(this.name)&&/\.log\.\d+$/.test(a)).sort((a,c)=>{let u=Number.parseInt(a.match(/\.log\.(\d+)$/)?.[1]||"0");return Number.parseInt(c.match(/\.log\.(\d+)$/)?.[1]||"0")-u}),o=r.length>0?Number.parseInt(r[0].match(/\.log\.(\d+)$/)?.[1]||"0")+1:1,l=`${t}.${o}`;if(await gt(t).catch(()=>null))try{if(await no(t,l),n.compress)try{let a=`${l}.gz`;await this.compressLogFile(l,a),await tn(l)}catch(a){console.error("Error compressing rotated file:",a)}if(r.length===0&&!i.some((a)=>a.endsWith(".log.1")))try{let a=`${t}.1`;await ci(a,"")}catch(a){console.error("Error creating backup file:",a)}}catch(a){console.error(`Error during rotation: ${a instanceof Error?a.message:String(a)}`)}}else{let i=new Date().toISOString().replace(/[:.]/g,"-"),r=t.replace(/\.log$/,`-${i}.log`);if(await gt(t).catch(()=>null))await no(t,r)}if(this.currentLogFile=s,n.maxFiles){let r=(await en(this.config.logDirectory)).filter((o)=>o.startsWith(this.name)).sort((o,l)=>l.localeCompare(o));for(let o of r.slice(n.maxFiles))await tn(yt(this.config.logDirectory,o))}}}async compressLogFile(e,n){let t=Xr(e),s=Kh(n),i=so();await Yh(t,i,s)}async handleFingersCrossedBuffer(e,n){if(!this.fingersCrossedConfig)return;if(this.shouldActivateFingersCrossed(e)&&!this.isActivated){this.isActivated=!0;for(let t of this.logBuffer){let s=await this.formatter.format(t);if(this.shouldWriteToFile())await this.writeToFile(s);console.log(s)}if(this.fingersCrossedConfig.stopBuffering)this.logBuffer=[]}if(this.isActivated){if(this.shouldWriteToFile())await this.writeToFile(n);console.log(n)}}shouldLog(e){if(!this.enabled)return!1;let n={debug:0,info:1,success:2,warning:3,error:4};return n[e]>=n[this.config.level]}async flushPendingWrites(){if(await Promise.all(this.pendingOperations.map((e)=>{if(e instanceof Promise)return e.catch((n)=>{console.error("Error in pending write operation:",n)});return Promise.resolve()})),Qt(this.currentLogFile))try{let e=eo(this.currentLogFile,"r+");Qr(e),ai(e)}catch(e){console.error(`Error flushing file: ${e}`)}}async destroy(){if(this.rotationTimeout)clearInterval(this.rotationTimeout);if(this.keyRotationTimeout)clearInterval(this.keyRotationTimeout);this.timers.clear();for(let e of this.pendingOperations)if(typeof e.cancel==="function")e.cancel();return(async()=>{if(this.pendingOperations.length>0)try{await Promise.allSettled(this.pendingOperations)}catch(e){console.error("Error waiting for pending operations:",e)}if(!xe()&&this.config.rotation&&typeof this.config.rotation!=="boolean"&&this.config.rotation.compress)try{let n=(await en(this.config.logDirectory)).filter((t)=>(t.includes("temp")||t.includes(".tmp"))&&t.includes(this.name));for(let t of n)try{await tn(yt(this.config.logDirectory,t))}catch(s){console.error(`Failed to delete temp file ${t}:`,s)}}catch(e){console.error("Error cleaning up temporary files:",e)}})()}getCurrentLogFilePath(){return this.currentLogFile}formatTag(e){if(!e)return"";return`${this.tagFormat.prefix}${e}${this.tagFormat.suffix}`}formatFileTimestamp(e){return`[${e.toISOString()}]`}formatConsoleTimestamp(e){return this.shouldStyleConsole()?le.gray(e.toLocaleTimeString()):e.toLocaleTimeString()}shouldStyleConsole(){if(!this.fancy||xe())return!1;let e=typeof re.env.NO_COLOR<"u",n=re.env.FORCE_COLOR==="0";if(e||n)return!1;return!!(typeof re.stderr<"u"&&re.stderr.isTTY||typeof re.stdout<"u"&&re.stdout.isTTY)}formatConsoleMessage(e){let{timestamp:n,icon:t="",tag:s="",message:i,level:r,showTimestamp:o=!0}=e,l=(h)=>h.replace(this.ANSI_PATTERN,"");if(!this.fancy){let h=[];if(o)h.push(n);if(r==="warning")h.push("WARN");else if(r==="error")h.push("ERROR");else if(t)h.push(t.replace(/[^\p{L}\p{N}\p{P}\p{Z}]/gu,""));if(s)h.push(s.replace(/[[\]]/g,""));return h.push(i),h.join(" ")}let a=re.stdout.columns||120,c="";if(r==="warning"||r==="error")c=`${t} ${i}`;else if(r==="info"||r==="success")c=`${t} ${s} ${i}`;else c=`${t} ${s} ${le.cyan(i)}`;if(!o)return c.trim();let u=l(c).trim().length,f=l(n).length,m=Math.max(1,a-2-u-f);return`${c.trim()}${" ".repeat(m)}${n}`}formatMessage(e,n){if(n.length===1&&Array.isArray(n[0]))return e.replace(/\{(\d+)\}/g,(r,o)=>{let l=Number.parseInt(o,10);return l<n[0].length?String(n[0][l]):r});let t=/%([sdijfo%])/g,s=0,i=e.replace(t,(r,o)=>{if(o==="%")return"%";if(s>=n.length)return r;let l=n[s++];switch(o){case"s":return String(l);case"d":case"i":return Number(l).toString();case"j":case"o":return JSON.stringify(l,null,2);default:return r}});if(s<n.length)i+=` ${n.slice(s).map((r)=>typeof r==="object"?JSON.stringify(r,null,2):String(r)).join(" ")}`;return i}formatMarkdown(e){if(!e)return e;let n=e;return n=n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,s,i)=>{let r=le.underline(le.blue(s)),o=this.toAbsoluteFilePath(i);if(o&&this.shouldStyleConsole()&&this.supportsHyperlinks()){let l=`file://${encodeURI(o)}`,a="\x1B]8;;",c="\x1B\\";return`\x1B]8;;${l}\x1B\\${r}\x1B]8;;\x1B\\`}if(this.shouldStyleConsole()&&this.supportsHyperlinks())return`\x1B]8;;${i}\x1B\\${r}\x1B]8;;\x1B\\`;return r}),n=n.replace(/`([^`]+)`/g,(t,s)=>le.bgGray(s)),n=n.replace(/\*\*([^*]+)\*\*/g,(t,s)=>le.bold(s)),n=n.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g,(t,s)=>le.italic(s)),n=n.replace(/(?<!_)_([^_]+)_(?!_)/g,(t,s)=>le.italic(s)),n=n.replace(/~([^~]+)~/g,(t,s)=>le.strikethrough(s)),n}supportsHyperlinks(){if(xe())return!1;let e=re.env;if(!e)return!1;if(e.TERM_PROGRAM==="iTerm.app"||e.TERM_PROGRAM==="vscode"||e.TERM_PROGRAM==="WezTerm")return!0;if(e.WT_SESSION)return!0;if(e.TERM==="xterm-kitty")return!0;let n=e.VTE_VERSION?Number.parseInt(e.VTE_VERSION,10):0;if(!Number.isNaN(n)&&n>=5000)return!0;return!1}toAbsoluteFilePath(e){try{let n=e;if(n.startsWith("file://"))n=n.replace(/^file:\/\//,"");if(n.startsWith("~")){let t=re.env.HOME||"";if(t)n=n.replace(/^~(?=$|\/)/,t)}if(Gh(n)||n.startsWith("./")||n.startsWith("../"))n=Jh(n);else return null;return Qt(n)?n:null}catch{return null}}buildOutputTexts(e){let n=this.shouldStyleConsole()?this.formatMarkdown(e):e,t=e.replace(this.ANSI_PATTERN,"");return{consoleText:n,fileText:t}}async log(e,n,...t){if(!this.shouldLog(e))return;let s=new Date,i=this.formatConsoleTimestamp(s),r=this.formatFileTimestamp(s),o,l;if(n instanceof Error)o=n.message,l=n.stack;else o=this.formatMessage(n,t);let{consoleText:a,fileText:c}=this.buildOutputTexts(o);if(this.shouldStyleConsole()){let f=this.options.showIcons===!1?"":sd[e],m=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"",h;switch(e){case"debug":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:le.gray(a),level:e}),console.error(h);break;case"info":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"success":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:le.green(a),level:e}),console.error(h);break;case"warning":h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.warn(h);break;case"error":if(h=this.formatConsoleMessage({timestamp:i,icon:f,tag:m,message:a,level:e}),console.error(h),l){let d=l.split(`
41
+ `);for(let p of d)if(p.trim()&&!p.includes(o))console.error(this.formatConsoleMessage({timestamp:i,message:le.gray(` ${p}`),level:e,showTimestamp:!1}))}break}}else if(!xe()){if(console.error(`${r} ${this.environment}.${e.toUpperCase()}: ${o}`),l)console.error(l)}let u=`${r} ${this.environment}.${e.toUpperCase()}: ${c}
42
+ `;if(l)u+=`${l}
43
+ `;if(u=u.replace(this.ANSI_PATTERN,""),this.shouldWriteToFile())await this.writeToFile(u)}progress(e,n=""){let t={update:(l,a)=>{},finish:(l)=>{},interrupt:(l,a)=>{}};if(!this.enabled)return t;let s=30;if(this.activeProgressBar={total:Math.max(1,e||1),current:0,message:n||"",barLength:s,lastRenderedLine:""},this.shouldStyleConsole()&&!xe()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar);return{update:(l,a)=>{if(!this.enabled||!this.activeProgressBar)return;if(this.activeProgressBar.current=Math.min(Math.max(0,l),this.activeProgressBar.total),a!==void 0)this.activeProgressBar.message=a;if(this.shouldStyleConsole()&&!xe()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)},finish:(l)=>{if(!this.activeProgressBar)return;this.finishProgressBar(this.activeProgressBar,l)},interrupt:(l,a="info")=>{if(!xe()&&re.stdout.isTTY)re.stdout.write(`
44
+ `);if(this[a==="warning"?"warn":a](l),this.activeProgressBar&&this.shouldStyleConsole()&&!xe()&&re.stdout.isTTY)this.renderProgressBar(this.activeProgressBar)}}}time(e){let n=performance.now();if(this.shouldStyleConsole()){let t=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"",s=this.formatConsoleTimestamp(new Date);console.error(this.formatConsoleMessage({timestamp:s,icon:this.options.showIcons===!1?"":le.blue("\u25D0"),tag:t,message:`${le.cyan(e)}...`}))}return async(t)=>{if(!this.enabled)return;let s=performance.now(),i=Math.round(s-n),r=`${e} completed in ${i}ms`,o=new Date,l=this.formatConsoleTimestamp(o),c=`${this.formatFileTimestamp(o)} ${this.environment}.INFO: ${r}`;if(t)c+=` ${JSON.stringify(t)}`;if(c+=`
45
+ `,c=c.replace(this.ANSI_PATTERN,""),this.shouldStyleConsole()){let u=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"";console.error(this.formatConsoleMessage({timestamp:l,icon:this.options.showIcons===!1?"":le.green("\u2713"),tag:u,message:`${r}${t?` ${JSON.stringify(t)}`:""}`}))}else if(!xe())console.error(c.trim());if(this.shouldWriteToFile())await this.writeToFile(c)}}async debug(e,...n){await this.log("debug",e,...n)}async info(e,...n){await this.log("info",e,...n)}async success(e,...n){await this.log("success",e,...n)}async warn(e,...n){await this.log("warning",e,...n)}async error(e,...n){await this.log("error",e,...n)}validateEncryptionConfig(){if(!this.config.rotation)return!1;if(typeof this.config.rotation==="boolean")return!1;let e=this.config.rotation,{encrypt:n}=e;return!!n}async only(e){if(!this.enabled)return;return await e()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}extend(e){let n=`${this.name}:${e}`,t=new st(n,{...this.options,logDirectory:this.config.logDirectory,level:this.config.level,format:this.config.format,rotation:typeof this.config.rotation==="boolean"?void 0:this.config.rotation,timestamp:typeof this.config.timestamp==="boolean"?void 0:this.config.timestamp});return this.subLoggers.add(t),t}createReadStream(){if(xe())throw Error("createReadStream is not supported in browser environments");if(!Qt(this.currentLogFile))throw Error(`Log file does not exist: ${this.currentLogFile}`);return Xr(this.currentLogFile,{encoding:"utf8"})}async decrypt(e){if(!this.validateEncryptionConfig())throw Error("Encryption is not configured");let n=this.config.rotation;if(!n.encrypt||typeof n.encrypt==="boolean")throw Error("Invalid encryption configuration");if(!this.currentKeyId||!this.keys.has(this.currentKeyId))throw Error("No valid encryption key available");let t=this.keys.get(this.currentKeyId);try{let s=ze.isBuffer(e)?e:ze.from(e,"base64"),i=s.subarray(0,16),r=s.subarray(s.length-16),o=s.subarray(16,s.length-16),l=qh("aes-256-gcm",t,i);l.setAuthTag(r);let a=l.update(o),c=l.final(),u=a.length+c.length,f=ze.allocUnsafe(u);return a.copy(f,0),c.copy(f,a.length),f.toString("utf8")}catch(s){throw Error(`Decryption failed: ${s instanceof Error?s.message:String(s)}`)}}getLevel(){return this.config.level}getLogDirectory(){return this.config.logDirectory}getFormat(){return this.config.format}getRotationConfig(){return this.config.rotation}isBrowserMode(){return xe()}isServerMode(){return!xe()}setTestEncryptionKey(e,n){this.currentKeyId=e,this.keys.set(e,n)}getTestCurrentKey(){if(!this.currentKeyId||!this.keys.has(this.currentKeyId))return null;return{id:this.currentKeyId,key:this.keys.get(this.currentKeyId)}}getConfig(){return this.config}async box(e){if(!this.enabled)return;let n=new Date,t=this.formatConsoleTimestamp(n),s=this.formatFileTimestamp(n),{consoleText:i,fileText:r}=this.buildOutputTexts(e);if(this.shouldStyleConsole()){let l=i.split(`
46
+ `),a=Math.max(...l.map((m)=>m.length))+2,c=`\u250C${"\u2500".repeat(a)}\u2510`,u=`\u2514${"\u2500".repeat(a)}\u2518`,f=l.map((m)=>this.formatConsoleMessage({timestamp:t,message:le.cyan(m),showTimestamp:!1}));console.error(this.formatConsoleMessage({timestamp:t,message:le.cyan(c),showTimestamp:!1})),f.forEach((m)=>console.error(m)),console.error(this.formatConsoleMessage({timestamp:t,message:le.cyan(u),showTimestamp:!1}))}else if(!xe())console.error(`${s} ${this.environment}.INFO: [BOX] ${r}`);let o=`${s} ${this.environment}.INFO: [BOX] ${r}
47
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(o)}async prompt(e){if(xe())return Promise.resolve(!0);return new Promise((n)=>{console.error(`${le.cyan("?")} ${e} (y/n) `);let t=(s)=>{let i=s.toString().trim().toLowerCase();re.stdin.removeListener("data",t);try{if(typeof re.stdin.setRawMode==="function")re.stdin.setRawMode(!1)}catch{}re.stdin.pause(),console.error(""),n(i==="y"||i==="yes")};try{if(typeof re.stdin.setRawMode==="function")re.stdin.setRawMode(!0)}catch{}re.stdin.resume(),re.stdin.once("data",t)})}setFancy(e){this.fancy=e}isFancy(){return this.fancy}pause(){this.enabled=!1}resume(){this.enabled=!0}async start(e,...n){if(!this.enabled)return;let t=e;if(n&&n.length>0){let a=/%([sdijfo%])/g,c=0;if(t=e.replace(a,(u,f)=>{if(f==="%")return"%";if(c>=n.length)return u;let m=n[c++];switch(f){case"s":return String(m);case"d":case"i":return Number(m).toString();case"j":case"o":return JSON.stringify(m,null,2);default:return u}}),c<n.length)t+=` ${n.slice(c).map((u)=>typeof u==="object"?JSON.stringify(u,null,2):String(u)).join(" ")}`}let{consoleText:s,fileText:i}=this.buildOutputTexts(t);if(this.shouldStyleConsole()){let a=this.options.showTags!==!1&&this.name?le.gray(this.formatTag(this.name)):"",c=this.options.showIcons===!1?"":`${le.blue("\u25D0")} `;console.error(`${c}${a} ${le.cyan(s)}`)}let l=`[${new Date().toISOString()}] ${this.environment}.INFO: [START] ${i}
48
+ `.replace(this.ANSI_PATTERN,"");if(this.shouldWriteToFile())await this.writeToFile(l)}renderProgressBar(e,n=!1){if(!this.enabled||!this.shouldStyleConsole()||!re.stdout.isTTY)return;let t=Math.min(100,Math.max(0,Math.round(e.current/e.total*100))),s=Math.round(e.barLength*t/100),i=e.barLength-s,r=le.green("\u2501".repeat(s)),o=le.gray("\u2501".repeat(i)),l=`[${r}${o}]`,a=`${t}%`.padStart(4),c=e.message?` ${e.message}`:"",u=this.options.showIcons===!1?"":n||t===100?le.green("\u2713"):le.blue("\u25B6"),f=this.options.showTags!==!1&&this.name?` ${le.gray(this.formatTag(this.name))}`:"",m=`\r${u}${f} ${l} ${a}${c}`,h=re.stdout.columns||80,d=" ".repeat(Math.max(0,h-m.replace(this.ANSI_PATTERN,"").length));if(e.lastRenderedLine=`${m}${d}`,re.stdout.write(e.lastRenderedLine),n)re.stdout.write(`
49
+ `)}finishProgressBar(e,n){if(!this.enabled||!this.fancy||xe()||!re.stdout.isTTY){this.activeProgressBar=null;return}if(e.current<e.total)e.current=e.total;if(n)e.message=n;this.renderProgressBar(e,!0),this.activeProgressBar=null}async clear(e={}){if(xe()){console.warn("Log clearing is not supported in browser environments.");return}try{console.warn("Clearing logs...",this.config.logDirectory);let n=await en(this.config.logDirectory),t=[];for(let s of n){if(!(e.name?new RegExp(e.name.replace("*",".*")).test(s):s.startsWith(this.name))||!s.endsWith(".log"))continue;let r=yt(this.config.logDirectory,s);if(e.before)try{if((await gt(r)).mtime>=e.before)continue}catch(o){console.error(`Failed to get stats for file ${r}:`,o);continue}t.push(r)}if(t.length===0){console.warn("No log files matched the criteria for clearing.");return}console.warn(`Preparing to delete ${t.length} log file(s)...`);for(let s of t)try{await tn(s),console.warn(`Deleted log file: ${s}`)}catch(i){console.error(`Failed to delete log file ${s}:`,i)}console.warn("Log clearing process finished.")}catch(n){console.error("Error during log clearing process:",n)}}}var Ay=new st("stacks");import{readFileSync as jf,writeFileSync as eg}from"fs";import{isAbsolute as tg,relative as Wf,resolve as ng}from"path";var Rn={meta:{docs:"Enforce return statements in callbacks of array methods",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=new RegExp(`\\.(${["map","filter","find","findIndex","findLast","findLastIndex","every","some","reduce","reduceRight","sort","flatMap"].join("|")})\\s*\\(`,"g");for(let o=0;o<s.length;o++){let l=s[o],a;for(a=r.exec(l);a!==null;a=r.exec(l)){let c=a[1],u=a.index+a[0].length,f=l.slice(u),m=f.match(/^\s*(?:\(([^)]*)\)|([a-z_$][\w$]*))\s*=>/i),h=f.match(/^\s*function\s*(?:[a-zA-Z_$][\w$]*\s*)?\(/);if(m){let d=f.slice(m[0].length).trim();if(d.startsWith("{")){let p=!1,y=0,g=d,x=o;while(x<s.length){let k=x===o?g:s[x];for(let P=0;P<k.length;P++){let w=k[P];if(w==="{")y++;if(w==="}"){if(y--,y===0){if(!p)t.push({filePath:n.filePath,line:o+1,column:a.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${c}' callback should return a value`,severity:"error"});break}}}if(k.match(new RegExp("\\breturn\\s+[^;]")))p=!0;if(y===0)break;x++,g=s[x]||""}}}else if(h){let d=!1,p=0,y=o,g=!1;while(y<s.length){let x=s[y];for(let k=0;k<x.length;k++){let P=x[k];if(P==="{")p++,g=!0;else if(P==="}"){if(p--,p===0&&g){if(!d)t.push({filePath:n.filePath,line:o+1,column:a.index+1,ruleId:"eslint/array-callback-return",message:`Array method '${c}' callback should return a value`,severity:"error"});break}}}if(g&&x.match(new RegExp("\\breturn\\s+[^;]")))d=!0;if(p===0&&g)break;y++}}}}return t}};var kn={meta:{docs:"Require super() calls in constructors of derived classes",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=0,l=0,a=!1;for(let c=0;c<s.length;c++){let u=s[c];if(u.match(/\bclass\s+\w+\s+extends\s+\w+/))i=!0;if(i&&u.match(/\bconstructor\s*\(/))r=!0,o=c+1,l=0,a=!1;if(r){for(let f of u){if(f==="{")l++;if(f==="}")l--}if(u.match(/\bsuper\s*\(/))a=!0;if(l===0&&u.includes("}")){if(!a)t.push({filePath:n.filePath,line:o,column:1,ruleId:"eslint/constructor-super",message:"Constructors of derived classes must call super()",severity:"error"});r=!1,i=!1}}}return t}};var $n={meta:{docs:'Enforce "for" loop update clause moving counter in the right direction',recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=new RegExp("\\bfor\\s*\\(\\s*(?:(?:let|var|const)\\s*)?(\\w+)\\s*=[^;]+;\\s*(\\w+)\\s*([<>]=?)[^;]+;\\s*(\\w+)(\\+\\+|--|[\\s+-]=)"),l=r.match(o);if(l){let a=l[1],c=l[2],u=l[3],f=l[4],m=l[5];if(a===c&&c===f){let h=m.includes("+"),d=u.includes("<");if(d&&!h||!d&&h)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"eslint/for-direction",message:"The update clause in this loop moves the variable in the wrong direction",severity:"error"})}}}return t}};var Pn={meta:{docs:"Enforce return statements in getters",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].match(/\bget\s+(\w+)\s*\(/);if(o){let l=o[1],a=!1,c=0,u=i;while(u<s.length){let f=s[u];for(let h of f){if(h==="{")c++;if(h==="}"){if(c--,c===0){if(!a)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"eslint/getter-return",message:`Getter '${l}' must return a value`,severity:"error"});break}}}let m=new RegExp("\\breturn\\s+[^;]");if(f.match(m))a=!0;if(c===0)break;u++}}}return t}};var In={meta:{docs:"Disallow async functions as Promise executor",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/new\s+Promise\s*\(\s*async\s*(?:\(|function)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-async-promise-executor",message:"Promise executor functions should not be async",severity:"error"})}return t}};var vn={meta:{docs:"Disallow comparing against -0",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/([!=]==?)\s*-0\b|\b-0\s*([!=]==?)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-compare-neg-zero",message:"Do not use the '-0' literal in comparisons",severity:"error"})}return t}};var Mn={meta:{docs:"Disallow assignment operators in conditional expressions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(if|while)\s*\([^)]*\b(\w+)\s*=\s*(?!=)[^)]*\)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[0];if(/===|==/.test(a))continue;if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-cond-assign",message:"Expected a conditional expression and instead saw an assignment",severity:"error"})}}return t}};var Cn={meta:{docs:"Disallow reassigning const variables",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=o.match(/\bconst\s+(\w+)/);if(l)i.set(l[1],r);let a=/\b(\w+)\s*=(?!=)/g,c;for(c=a.exec(o);c!==null;c=a.exec(o)){let u=c[1],f=o.substring(0,c.index);if(!/\b(?:const|let|var)\s*$/.test(f)&&i.has(u))t.push({filePath:n.filePath,line:r+1,column:Math.max(1,c.index+1),ruleId:"eslint/no-const-assign",message:`'${u}' is constant`,severity:"error"})}}return t}};var Sn={meta:{docs:"Disallow constant expressions in conditions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[{pattern:/\b(if|while)\s*\(\s*(true|false)\s*\)/g,type:"boolean"},{pattern:/\b(if|while)\s*\(\s*(\d+)\s*\)/g,type:"number"},{pattern:/\b(if|while)\s*\(\s*(['"`][^'"`]*['"`])\s*\)/g,type:"string"}];for(let{pattern:l,type:a}of o){let c;while((c=l.exec(r))!==null){let u=c[1];if(r.substring(0,c.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,c.index+u.length+2),ruleId:"eslint/no-constant-condition",message:"Unexpected constant condition",severity:"error"})}}}return t}};var En={meta:{docs:"Disallow duplicate class members",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=new Set,o=0;for(let l=0;l<s.length;l++){let a=s[l];if(a.match(/\bclass\s+\w+/))i=!0,r=new Set,o=0;if(i){for(let u of a){if(u==="{")o++;if(u==="}"){if(o--,o===0)i=!1}}let c=[...a.matchAll(/^\s*(?:(?:public|private|protected|static|readonly|async)\s*)?(?:get|set)?\s*(\w+)\s*\(/g),...a.matchAll(/^\s*(?:(?:public|private|protected|static|readonly)\s*)?(\w+)\s*[:=]/g)];for(let u of c){let f=u[1];if(r.has(f))t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"eslint/no-dupe-class-members",message:`Duplicate class member '${f}'`,severity:"error"});else r.add(f)}}}return t}};var Ot={meta:{docs:"Disallow duplicate keys in object literals",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=/\{\s*$/,r=/^\s*(?:(['"`])(.+?)\1|(\w+))\s*:/;for(let o=0;o<s.length;o++){let l=s[o];if(!i.test(l)&&!l.includes("{"))continue;let a=new Map,c=(l.match(/\{/g)||[]).length-(l.match(/\}/g)||[]).length,u=o;for(let f=o+1;f<s.length&&c>0;f++){let m=s[f];c+=(m.match(/\{/g)||[]).length,c-=(m.match(/\}/g)||[]).length;let h=m.match(r);if(h){let d=h[2]||h[3];if(d)if(a.get(d)!==void 0)t.push({filePath:n.filePath,line:f+1,column:Math.max(1,m.search(/\S/)+1),ruleId:"eslint/no-dupe-keys",message:`Duplicate key '${d}'`,severity:"error"});else a.set(d,f)}if(c===0)break}}return t},fix:(e,n)=>{let t=Ot.check(e,n);if(t.length===0)return e;let s=e.split(/\r?\n/),i=new Set(t.map((o)=>o.line-1));return s.filter((o,l)=>!i.has(l)).join(`
50
+ `)}};var Ln={meta:{docs:"Disallow duplicate case labels in switch statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=new Set,o=-1;for(let l=0;l<s.length;l++){let a=s[l],c=a.trim();if(/\bswitch\s*\(/.test(c)){i=!0,r=new Set,o=l;continue}if(i&&c==="}"&&l>o){let u=s[o].match(/^\s*/)?.[0].length||0;if((a.match(/^\s*/)?.[0].length||0)<=u+2)i=!1,r=new Set}if(i){let u=c.match(/^case\s+(.+?)\s*:/);if(u){let f=u[1].trim();if(r.has(f))t.push({filePath:n.filePath,line:l+1,column:Math.max(1,a.indexOf("case")+1),ruleId:"eslint/no-duplicate-case",message:`Duplicate case label '${f}'`,severity:"error"});else r.add(f)}}}return t}};var Tn={meta:{docs:"Disallow empty destructuring patterns",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\{\s*\}\s*=/g,l=/\[\s*\]\s*=/g,a;for(a=o.exec(r);a!==null;a=o.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty object pattern",severity:"error"})}for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-empty-pattern",message:"Unexpected empty array pattern",severity:"error"})}}return t}};var An={meta:{docs:"Disallow fallthrough of case statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=-1,o=!1;for(let l=0;l<s.length;l++){let c=s[l].trim();if(/\bswitch\s*\(/.test(c)){i=!0;continue}if(i){if(/^case\s+/.test(c)||/^default\s*:/.test(c)){if(r>=0&&o){if(!(/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(s[r])||l>0&&/\/\/.*falls?\s*through|\/\*.*falls?\s*through/i.test(s[l-1])))t.push({filePath:n.filePath,line:r+1,column:Math.max(1,s[r].indexOf("case")+1),ruleId:"eslint/no-fallthrough",message:"Expected a 'break' statement before 'case'",severity:"error"})}r=l,o=!0}if(/\b(?:break|return|throw|continue)\b/.test(c))o=!1;if(c==="}")i=!1,r=-1,o=!1}}return t}};var On={meta:{docs:"Disallow number literals that lose precision",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(\d{17,}(?:\.\d+)?|\d+\.\d{17,})\b/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1];if(Number(a).toString()!==a)t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-loss-of-precision",message:"This number literal will lose precision at runtime",severity:"error"})}}return t}};var _n={meta:{docs:"Disallow returning values from Promise executor functions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++)if(s[i].match(/new\s+Promise\s*\(/)){let l=0,a=!1,c=i;while(c<s.length){let u=s[c];for(let m of u){if(m==="{")l++,a=!0;if(m==="}"){if(l--,l===0&&a)break}}let f=new RegExp("\\breturn\\s+[^;]");if(a&&u.match(f))t.push({filePath:n.filePath,line:c+1,column:1,ruleId:"eslint/no-promise-executor-return",message:"Return values from promise executor functions cannot be read",severity:"error"});if(l===0&&a)break;c++}}return t}};var Dn={meta:{docs:"Disallow variable redeclaration",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=/\b(var|let|const)\s+(\w+)/g,a;for(a=l.exec(o);a!==null;a=l.exec(o)){let u=a[2];if(i.get(u)!==void 0)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-redeclare",message:`'${u}' is already defined`,severity:"error"});else i.set(u,r)}let c=/\bfunction\s+(\w+)/g;for(a=c.exec(o);a!==null;a=c.exec(o)){let u=a[1];if(i.get(u)!==void 0)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-redeclare",message:`'${u}' is already defined`,severity:"error"});else i.set(u,r)}}return t}};var _t={meta:{docs:"Disallow assignments where both sides are identical",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=new RegExp("\\b(\\w+)\\s*=\\s*(\\w+)\\s*(?:;\\s*)?(?:\\/\\/.*)?$"),l=r.match(o);if(l&&l[1]===l[2]){t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(l[1])+1),ruleId:"eslint/no-self-assign",message:`'${l[1]}' is assigned to itself`,severity:"error"});continue}let a=r.match(/([\w.]+)\s*=\s*([\w.]+)/);if(a&&a[1]===a[2]){t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(a[1])+1),ruleId:"eslint/no-self-assign",message:`'${a[1]}' is assigned to itself`,severity:"error"});continue}let c=r.match(/(\w+\[[^\]]+\])\s*=\s*(\w+\[[^\]]+\])/);if(c){let u=c[1].replace(/\s/g,""),f=c[2].replace(/\s/g,"");if(u===f)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(c[1])+1),ruleId:"eslint/no-self-assign",message:`'${c[1]}' is assigned to itself`,severity:"error"})}}return t},fix:(e,n)=>{let t=_t.check(e,n);if(t.length===0)return e;let s=e.split(/\r?\n/),i=new Set(t.map((o)=>o.line-1));return s.map((o,l)=>{if(i.has(l)){let a=o.trim();if(new RegExp("^\\w+(?:\\.\\w+|\\[[^\\]]+\\])?\\s*=\\s*\\w+(?:\\.\\w+|\\[[^\\]]+\\])?;?\\s*$").test(a))return""}return o}).filter((o,l,a)=>{if(o===""&&i.has(l)){let c=l>0&&a[l-1].trim()!=="",u=l<a.length-1&&a[l+1]&&a[l+1].trim()!=="";if(!c||!u)return!1}return!0}).join(`
51
+ `)}};var Fn={meta:{docs:"Disallow comparisons where both sides are identical",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/([\w.\[\]]+)\s*(===|!==|==|!=|<|>|<=|>=)\s*([\w.\[\]]+)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1].replace(/\s/g,""),c=l[2],u=l[3].replace(/\s/g,"");if(a===u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-self-compare",message:`Comparing '${l[1]}' to itself is potentially pointless`,severity:"error"})}}return t}};var Nn={meta:{docs:"Disallow sparse arrays (arrays with empty slots)",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\[([^\]]*)\]/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1];if(/,\s*,/.test(a))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-sparse-arrays",message:"Unexpected sparse array",severity:"error"})}}return t},fix:(e,n)=>{let t=e.split(/\r?\n/),s=!1,i=t.map((r)=>{let o=r;return o=o.replace(/\[([^\]]*)\]/g,(l,a)=>{if(/,\s*,/.test(a))return s=!0,`[${a.replace(/,(\s*),/g,", undefined,")}]`;return l}),o});return s?i.join(`
52
+ `):e}};var Wn={meta:{docs:"Disallow undeclared variables",recommended:!0,wip:!0},check:(e,n)=>[]};var Bn={meta:{docs:"Disallow unreachable code after return, throw, continue, or break",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(/^\s*(?:return|throw|break|continue)\b/.test(r))for(let l=i+1;l<s.length;l++){let a=s[l],c=a.trim();if(c===""||c.startsWith("//")||c.startsWith("/*"))continue;if(c==="}"||c.startsWith("}"))break;if(/^(?:case\b|default\s*:)/.test(c))break;t.push({filePath:n.filePath,line:l+1,column:Math.max(1,a.search(/\S/)+1),ruleId:"eslint/no-unreachable",message:"Unreachable code",severity:"error"});break}}return t}};var jn={meta:{docs:"Disallow negation of the left operand of relational operators",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/!\s*\w+\s+in\s+/g,l=/!\s*\w+\s+instanceof\s+/g,a;for(a=o.exec(r);a!==null;a=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'in' operand",severity:"error"});for(a=l.exec(r);a!==null;a=l.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-unsafe-negation",message:"Unexpected negation of 'instanceof' operand",severity:"error"})}return t},fix:(e)=>{let n=e;return n=n.replace(/!\s*(\w+)\s+in\s+/g,"!($1 in "),n=n.replace(/!\s*(\w+)\s+instanceof\s+/g,"!($1 instanceof "),n}};var Un={meta:{docs:"Disallow unnecessary catch clauses",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/catch\s*\(\s*(\w+)\s*\)/);if(!o)continue;let l=o[1];for(let a=i+1;a<Math.min(i+5,s.length);a++){let c=s[a].trim();if(c===`throw ${l}`||c===`throw ${l};`){let u=!1;for(let f=i+1;f<a;f++){let m=s[f].trim();if(m!==""&&m!=="{"&&!m.startsWith("//")){u=!0;break}}if(!u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("catch")+1),ruleId:"eslint/no-useless-catch",message:"Unnecessary catch clause",severity:"error"});break}if(c==="}")break}}return t}};var zn={meta:{docs:"Require isNaN() when checking for NaN",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b([\w.\[\]]+)\s*(===|!==|==|!=)\s*NaN\b|\bNaN\s*(===|!==|==|!=)\s*([\w.\[\]]+)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[1]||l[4];t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/use-isnan",message:"Use isNaN() to compare with NaN",severity:"error"})}}return t},fix:(e,n)=>{let t=e.split(/\r?\n/),s=!1,i=t.map((r)=>{let o=r;return o=o.replace(/\b([\w.\[\]]+)\s*===\s*NaN\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\bNaN\s*===\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\b([\w.\[\]]+)\s*!==\s*NaN\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o=o.replace(/\bNaN\s*!==\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o=o.replace(/\b([\w.\[\]]+)\s*==\s*NaN\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\bNaN\s*==\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`isNaN(${a})`)),o=o.replace(/\b([\w.\[\]]+)\s*!=\s*NaN\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o=o.replace(/\bNaN\s*!=\s*([\w.\[\]]+)\b/g,(l,a)=>(s=!0,`!isNaN(${a})`)),o});return s?i.join(`
53
+ `):e}};var Co=["undefined","object","boolean","number","string","function","symbol","bigint"],qn={meta:{docs:"Enforce comparing typeof expressions against valid strings",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/typeof\s+\w+\s*(?:===|!==|==|!=)\s*(['"`])(\w+)\1/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let c=l[2];if(!Co.includes(c))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${c}'`,severity:"error"})}let a=/(['"`])(\w+)\1\s*(?:===|!==|==|!=)\s*typeof\s+\w+/g;for(l=a.exec(r);l!==null;l=a.exec(r)){let c=l[2];if(!Co.includes(c))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/valid-typeof",message:`Invalid typeof comparison value '${c}'`,severity:"error"})}}return t}};var Kn={meta:{docs:"Enforce a maximum cyclomatic complexity allowed in a program",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=10,r=!1,o=0,l="",a=0,c=0;for(let u=0;u<s.length;u++){let f=s[u],m=f.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(m)r=!0,o=u+1,l=m[1]||m[2]||m[3]||"anonymous",a=1,c=0;if(r){for(let d of f){if(d==="{")c++;if(d==="}"){if(c--,c===0){if(a>10)t.push({filePath:n.filePath,line:o,column:1,ruleId:"eslint/complexity",message:`Function '${l}' has complexity ${a}, exceeds maximum of 10`,severity:"error"});r=!1}}}let h=[/\bif\s*\(/,/\belse\s+if\s*\(/,/\bfor\s*\(/,/\bwhile\s*\(/,/\bcase\s+/,/\bcatch\s*\(/,/\b&&\b/,/\b\|\|\b/,/\?\s*(?:\S.*(?:[\n\r\u2028\u2029]\s*)?)?:/];for(let d of h){let p=f.match(new RegExp(d,"g"));if(p)a+=p.length}}}return t}};var Vn={meta:{docs:"Require default case in switch statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=!1,l=0;for(let a=0;a<s.length;a++){let c=s[a];if(c.match(/\bswitch\s*\(/))i=!0,r=a+1,o=!1,l=0;if(i){for(let u of c){if(u==="{")l++;if(u==="}"){if(l--,l===0){if(!o)t.push({filePath:n.filePath,line:r,column:1,ruleId:"eslint/default-case",message:"Expected a default case",severity:"error"});i=!1}}}if(c.match(/\bdefault\s*:/))o=!0}}return t}};var Hn={meta:{docs:"Require === and !== instead of == and !=",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/([^=!])(\s*)(==)(\s*)([^=])/g,l=/([^!])(\s*)(!=)(\s*)([^=])/g,a;for(a=o.exec(r);a!==null;a=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+2),ruleId:"eslint/eqeqeq",message:"Expected '===' and instead saw '=='",severity:"error"});for(a=l.exec(r);a!==null;a=l.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+2),ruleId:"eslint/eqeqeq",message:"Expected '!==' and instead saw '!='",severity:"error"})}return t},fix:(e)=>{let n=e;return n=n.replace(/([^!])(\s*)(!=)(\s*)([^=])/g,"$1$2!==$4$5"),n=n.replace(/([^=!])(\s*)(==)(\s*)([^=])/g,"$1$2===$4$5"),n}};var Zn={meta:{docs:"Enforce a maximum depth that blocks can be nested",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=4,r=0,o=0,l=0;for(let a=0;a<s.length;a++){let c=s[a];if(c.match(/\b(if|for|while|switch|try|catch|else)\b.*\{/)){if(r++,r>o)o=r,l=a+1}else if(c.match(/\{/)&&!c.match(/^.*\}/)){if(s[a-1]?.match(/\b(if|for|while|switch|try|catch|else)\b/)){if(r++,r>o)o=r,l=a+1}}if(c.match(/^\s*\}/))r--;if(r>4)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"eslint/max-depth",message:`Blocks are nested too deeply (${r}), maximum allowed is 4`,severity:"error"})}return t}};var Gn={meta:{docs:"Enforce a maximum number of lines of code in a function",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=50,r=!1,o=0,l="",a=0;for(let c=0;c<s.length;c++){let u=s[c],f=u.match(/\bfunction\s+(\w+)\s*\(|(\w+)\s*=\s*(?:\([^)]*\)|(\w+))\s*=>/);if(f)r=!0,o=c+1,l=f[1]||f[2]||f[3]||"anonymous",a=0;if(r)for(let m of u){if(m==="{")a++;if(m==="}"){if(a--,a===0){let h=c+1-o+1;if(h>50)t.push({filePath:n.filePath,line:o,column:1,ruleId:"eslint/max-lines-per-function",message:`Function '${l}' has ${h} lines, exceeds maximum of 50`,severity:"error"});r=!1}}}}return t}};var Jn={meta:{docs:"Disallow alert, confirm, and prompt",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(alert|confirm|prompt)\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-alert",message:`Unexpected ${l[1]}`,severity:"warning"})}}return t}};var Yn={meta:{docs:"Disallow await inside of loops",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=0;for(let l=0;l<s.length;l++){let a=s[l];if(a.match(/\b(for|while|do)\s*\(/))i=!0,r=0,o=l;if(i){for(let c of a){if(c==="{")r++;if(c==="}"){if(r--,r===0)i=!1}}if(a.match(/\bawait\s+/))t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"eslint/no-await-in-loop",message:"Unexpected await inside a loop. Consider using Promise.all() instead",severity:"error"})}}return t}};var Xn={meta:{docs:"Disallow use of arguments.caller or arguments.callee",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\barguments\s*\.\s*(caller|callee)\b/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-caller",message:`Avoid arguments.${l[1]}`,severity:"error"})}return t}};var Qn={meta:{docs:"Disallow lexical declarations in case clauses",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(l.match(/\bcase\s+(?:\S.*)?:|default\s*:/))i=!0,r=!0;else r=!1;if(i&&!r&&(l.match(/\bbreak\b/)||l.match(/\bcase\s+(?:\S.*)?:/)))i=!1;if(i&&!r){if(l.match(/\b(let|const|function|class)\s+/))t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"eslint/no-case-declarations",message:"Unexpected lexical declaration in case block",severity:"error"})}}return t}};var es={meta:{docs:"Disallow else blocks after return statements in if statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(!/^\s*else\b/.test(r))continue;let o=!1;for(let l=i-1;l>=0&&l>=i-10;l--){let a=s[l].trim();if(a.startsWith("return"))o=!0;if(a==="}"&&o)break;if(a.includes("{"))break}if(o)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("else")+1),ruleId:"eslint/no-else-return",message:"Unnecessary else after return",severity:"warning"})}return t}};var ts={meta:{docs:"Disallow empty block statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\{\s*\}/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=r.substring(0,l.index).trim(),c=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(a),u=/[=:]$/.test(a)||/return\s*$/.test(a);if(c&&!u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}}for(let i=0;i<s.length-1;i++){let r=s[i],o=s[i+1];if(/\{\s*$/.test(r.trim()))for(let l=i+1;l<s.length;l++){let a=s[l].trim();if(a==="")continue;if(a==="}"||a.startsWith("}")){let c=r.substring(0,r.lastIndexOf("{")).trim(),u=/(?:if|else|for|while|do|try|catch|finally|function|\})\s*$/.test(c),f=/[=:]$/.test(c)||/return\s*$/.test(c);if(u&&!f)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.lastIndexOf("{")+1),ruleId:"eslint/no-empty",message:"Empty block statement",severity:"error"})}break}}return t}};var ns={meta:{docs:"Disallow empty functions",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[/function\s+\w+\s*\([^)]*\)\s*\{\s*\}/g,/function\s*\([^)]*\)\s*\{\s*\}/g,/\([^)]*\)\s*=>\s*\{\s*\}/g,/\w+\s*\([^)]*\)\s*\{\s*\}/g];for(let l of o){let a;for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-empty-function",message:"Unexpected empty function",severity:"warning"})}}}return t}};var ss={meta:{docs:"Disallow use of eval()",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\beval\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-eval",message:"eval can be harmful",severity:"error"})}}return t}};var id=["Object","Array","String","Number","Boolean","Date","RegExp","Function","Math","JSON","Promise","Map","Set","WeakMap","WeakSet","Symbol","Proxy","Reflect","Error","TypeError","RangeError"],is={meta:{docs:"Disallow extending native types",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o of id){let l=new RegExp(`\\b${o}\\.prototype\\.\\w+\\s*=`,"g"),a;for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-extend-native",message:`${o} prototype is read only, properties should not be added`,severity:"error"})}}}return t}};var rs={meta:{docs:"Disallow unnecessary boolean casts",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[/\bif\s*\(\s*Boolean\s*\(/g,/\bwhile\s*\(\s*Boolean\s*\(/g,/!\s*Boolean\s*\(/g,/\?\s*Boolean\s*\(/g,/&&\s*Boolean\s*\(/g,/\|\|\s*Boolean\s*\(/g,/!!\s*\w+/g];for(let l of o){let a;for(a=l.exec(r);a!==null;a=l.exec(r)){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-extra-boolean-cast",message:"Redundant Boolean call or double negation",severity:"error"})}}}return t},fix:(e)=>{let n=e;return n=n.replace(/\b(if|while)\s*\(\s*Boolean\s*\(([^)]+)\)\s*\)/g,"$1 ($2)"),n=n.replace(/!\s*Boolean\s*\(([^)]+)\)/g,"!$1"),n=n.replace(/!!\s*(\w+)/g,"$1"),n}};var rd=["Array","Boolean","Date","Error","Function","JSON","Math","Number","Object","RegExp","String","Symbol","undefined","NaN","Infinity","isNaN","isFinite","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","eval","Promise","Proxy","Reflect","Set","Map","WeakSet","WeakMap","ArrayBuffer","DataView","console","window","document","globalThis","global","process"],os={meta:{docs:"Disallow assignment to native objects or read-only global variables",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o of rd){let l=new RegExp(`\\b${o}\\s*=\\s*[^=]`,"g"),a;for(a=l.exec(r);a!==null;a=l.exec(r))if(!r.slice(a.index).match(new RegExp(`^${o}\\s*===?`)))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-global-assign",message:`Read-only global '${o}' should not be modified`,severity:"error"})}}return t}};var ls={meta:{docs:"Disallow implied eval() via setTimeout/setInterval with strings",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b(setTimeout|setInterval)\s*\(\s*(['"`])/g,l;while((l=o.exec(r))!==null){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-implied-eval",message:"Implied eval. Consider passing a function instead of a string",severity:"error"})}}return t}};var as={meta:{docs:"Disallow the use of the __iterator__ property",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/__iterator__/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-iterator",message:"Reserved name '__iterator__'",severity:"error"})}}return t}};var Dt={meta:{docs:"Disallow if statements as the only statement in else blocks",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(/^\s*else\s*(?:\{\s*)?$/.test(r)){let l=i,a=r.includes("{");if(!a){if(i+1<s.length&&s[i+1].trim()==="{")l=i+1,a=!0}if(a)for(let c=l+1;c<s.length;c++){let u=s[c].trim();if(u===""||u.startsWith("//")||u.startsWith("/*"))continue;if(u==="}")break;if(u.startsWith("if ")||u.startsWith("if(")){let f=!0,m=0,h=!1;for(let d=c;d<s.length;d++){let p=s[d];if(m+=(p.match(/\{/g)||[]).length,m-=(p.match(/\}/g)||[]).length,d===c){h=!0;continue}if(m===0){for(let y=d+1;y<s.length;y++){let g=s[y].trim();if(g===""||g.startsWith("//"))continue;if(g==="}"||g.startsWith("}"))break;else f=!1;break}break}}if(h&&f)t.push({filePath:n.filePath,line:c+1,column:Math.max(1,s[c].indexOf("if")+1),ruleId:"eslint/no-lonely-if",message:"Unexpected if as the only statement in an else block",severity:"warning"})}break}}}return t},fix:(e,n)=>{if(Dt.check(e,n).length===0)return e;return e}};var cs={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s*new\s+\w+\s*\(/.test(r)){if(!/[=:]/.test(r.substring(0,r.indexOf("new"))))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("new")+1),ruleId:"eslint/no-new",message:"Do not use 'new' for side effects",severity:"warning"})}}return t}};var us={meta:{docs:"Disallow new Function() declarations",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bnew\s+Function\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-new-func",message:"The Function constructor is eval",severity:"error"})}}return t}};var fs={meta:{docs:"Disallow new operators with String, Number, and Boolean",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bnew\s+(String|Number|Boolean)\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-new-wrappers",message:`Do not use ${l[1]} as a constructor`,severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1,s=n.map((i)=>{if(i.trim().startsWith("//")||i.trim().startsWith("/*"))return i;return i.replace(/\bnew\s+(String|Number|Boolean)\s*\(/g,(o,l)=>(t=!0,`${l}(`))});return t?s.join(`
54
+ `):e}};var ms={meta:{docs:"Disallow octal literals",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\b0[0-7]+\b/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"eslint/no-octal",message:"Octal literals should not be used",severity:"error"})}return t}};var hs={meta:{docs:"Disallow reassignment of function parameters",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=[...o.matchAll(/function\s+(?:(\w+)\s*)?\(([^)]*)\)/g),...o.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*\(([^)]*)\)\s*=>/g),...o.matchAll(/(?:const|let|var)?\s*(\w+)\s*=\s*(\w+)\s*=>/g)];for(let a of l){let c=a[2]?a[2].split(",").map((f)=>f.trim().split(/[=:]/)[0].trim()):[],u=`line-${r}`;if(c.length>0)i.set(u,new Set(c.filter((f)=>f&&/^\w+$/.test(f))))}for(let[a,c]of i.entries())for(let u of c){let f=new RegExp(`\\b${u}\\s*=\\s*[^=]`,"g"),m;for(m=f.exec(o);m!==null;m=f.exec(o))if(!o.slice(m.index).match(/^\w+\s*===?/))t.push({filePath:n.filePath,line:r+1,column:m.index+1,ruleId:"eslint/no-param-reassign",message:`Assignment to function parameter '${u}'`,severity:"error"})}}return t}};var ds={meta:{docs:"Disallow use of __proto__",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/__proto__/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-proto",message:"The '__proto__' property is deprecated",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1,s=n.map((i)=>{if(i.trim().startsWith("//")||i.trim().startsWith("/*"))return i;return i.replace(/(\w+)\.__proto__/g,(o,l)=>(t=!0,`Object.getPrototypeOf(${l})`))});return t?s.join(`
55
+ `):e}};var ps={meta:{docs:"Disallow assignment operators in return statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\breturn\s[^;]*\b\w+\s*=\s*(?!=)/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[0];if(/===|==/.test(a))continue;if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-return-assign",message:"Return statement should not contain assignment",severity:"error"})}}return t}};var gs={meta:{docs:"Disallow comma operators",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\)\s*,\s*\w+\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+l[0].indexOf(",")+1),ruleId:"eslint/no-sequences",message:"Unexpected use of comma operator",severity:"warning"})}}return t}};var ys={meta:{docs:"Disallow variable declarations from shadowing variables declared in the outer scope",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=[new Set];for(let o=0;o<s.length;o++){let l=s[o];if(l.match(/\bfunction\s+\w+\s*\(|=>\s*\{|\{\s*$/))r.push(new Set);let a=[...l.matchAll(/\b(const|let|var)\s+(\w+)/g),...l.matchAll(/function\s+(\w+)\s*\(/g)];for(let c of a){let u=c[2]||c[1];for(let f=0;f<r.length-1;f++)if(r[f].has(u)){t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"eslint/no-shadow",message:`'${u}' is already declared in the upper scope`,severity:"error"});break}r[r.length-1].add(u)}if(l.match(/^\s*\}\s*$/)){if(r.length>1)r.pop()}}return t}};var bs={meta:{docs:"Disallow throwing literals as exceptions",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[{pattern:/\bthrow\s+(['"`][^'"`]*['"`])/g,type:"string"},{pattern:/\bthrow\s+(\d+)/g,type:"number"},{pattern:/\bthrow\s+(true|false|null|undefined)/g,type:"literal"}];for(let{pattern:l,type:a}of o){let c;while((c=l.exec(r))!==null){if(r.substring(0,c.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,c.index+1),ruleId:"eslint/no-throw-literal",message:`Expected an error object to be thrown, got ${a} literal`,severity:"error"})}}}return t}};var xs={meta:{docs:"Disallow the use of variables before they are defined",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map;for(let r=0;r<s.length;r++){let o=s[r],l=[...o.matchAll(/\b(const|let|var)\s+(\w+)/g),...o.matchAll(/\bfunction\s+(\w+)\s*\(/g),...o.matchAll(/\bclass\s+(\w+)/g)];for(let a of l){let c=a[2]||a[1];if(!i.has(c))i.set(c,r+1)}}for(let r=0;r<s.length;r++){let o=s[r];if(o.match(/\b(const|let|var|function|class)\s+\w+/))continue;let l=o.matchAll(/\b(\w+)\b/g);for(let a of l){let c=a[1],u=i.get(c);if(u&&u>r+1)t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"eslint/no-use-before-define",message:`'${c}' was used before it was defined`,severity:"error"})}}return t}};var ws={meta:{docs:"Disallow unnecessary .call() and .apply()",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\.\s*call\s*\(\s*(undefined|null)\s*,/g,l=/\.\s*apply\s*\(\s*(undefined|null)\s*,/g,a;for(a=o.exec(r);a!==null;a=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.call()'",severity:"error"});for(a=l.exec(r);a!==null;a=l.exec(r))t.push({filePath:n.filePath,line:i+1,column:a.index+1,ruleId:"eslint/no-useless-call",message:"Unnecessary '.apply()'",severity:"error"})}return t}};var Rs={meta:{docs:"Disallow unnecessary concatenation of literals or template literals",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=[/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g];for(let l of o){let a;while((a=l.exec(r))!==null){if(r.substring(0,a.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,a.index+1),ruleId:"eslint/no-useless-concat",message:"Unexpected string concatenation of literals",severity:"warning"})}}}return t},fix:(e)=>{let n=e;return n=n.replace(/(['"`])([^'"`]*)\1\s*\+\s*\1([^'"`]*)\1/g,"$1$2$3$1"),n}};var So=["/","(",")","[","]","{","}","<",">",":","@","#","$","%","&","=","+","-","*","?","!",";",",","|","~","`","^"],ks={meta:{docs:"Disallow unnecessary escape characters",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o of So){let l=`\\${o}`,a=new RegExp(`(['"\`])[^'"\`]*${l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"g"),c;while((c=a.exec(r))!==null){let u=c.index,f=r.indexOf(l,u);if(f>u)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,f+1),ruleId:"eslint/no-useless-escape",message:`Unnecessary escape character: \\${o}`,severity:"warning"})}}}return t},fix:(e)=>{let n=e;for(let t of So){let s=`\\${t}`;n=n.replace(new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),t)}return n}};var $s={meta:{docs:"Disallow renaming import, export, and destructured assignments to the same name",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/import\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g,l;for(l=o.exec(r);l!==null;l=o.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming import '${l[1]}' to '${l[1]}' is redundant`,severity:"error"});let a=/export\s*\{[^}]*\b(\w+)\s+as\s+\1\b[^}]*\}/g;for(l=a.exec(r);l!==null;l=a.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming export '${l[1]}' to '${l[1]}' is redundant`,severity:"error"});let c=/\{[^}]*\b(\w+)\s*:\s*\1\b[^}]*\}\s*=/g;for(l=c.exec(r);l!==null;l=c.exec(r))t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-useless-rename",message:`Renaming destructured property '${l[1]}' to '${l[1]}' is redundant`,severity:"error"})}return t},fix:(e)=>{let n=e;return n=n.replace(/\b(\w+)\s+as\s+\1\b/g,"$1"),n=n.replace(/\{([^}]*)\b(\w+)\s*:\s*\2\b([^}]*)\}/g,"{$1$2$3}"),n}};var Ft={meta:{docs:"Disallow redundant return statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(o==="return"||o==="return;"){let l=!1;for(let a=i+1;a<s.length;a++){let c=s[a].trim();if(c===""||c.startsWith("//")||c.startsWith("/*"))continue;if(c==="}"||c.startsWith("}"))l=!0;break}if(l)t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("return")+1),ruleId:"eslint/no-useless-return",message:"Unnecessary return statement",severity:"warning"})}}return t},fix:(e,n)=>{let t=Ft.check(e,n);if(t.length===0)return e;let s=e.split(/\r?\n/),i=new Set(t.map((o)=>o.line-1));return s.filter((o,l)=>!i.has(l)).join(`
56
+ `)}};var Ps={meta:{docs:"Require let or const instead of var",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bvar\s+/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-var",message:"Unexpected var, use let or const instead",severity:"error"})}}return t},fix:(e,n)=>e.split(/\r?\n/).map((i)=>{if(i.trim().startsWith("//")||i.trim().startsWith("/*"))return i;return i.replace(/\bvar\s+/g,"let ")}).join(`
57
+ `)};var Is={meta:{docs:"Disallow with statements",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\bwith\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/no-with",message:"Unexpected use of 'with' statement",severity:"error"})}}return t}};var vs={meta:{docs:"Require using arrow functions for callbacks",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=/\.(map|filter|reduce|forEach|some|every|find|findIndex)\s*\(\s*function\s*\(/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){if(r.substring(0,l.index).includes("//"))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,l.index+1),ruleId:"eslint/prefer-arrow-callback",message:"Unexpected function expression, use arrow function instead",severity:"warning"})}}return t}};var Ms={meta:{docs:"Disallow async functions which have no await expression",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++)if(s[i].match(/\basync\s+(?:function\s+\w+|(?:\(|\w+)\s*(?:\(|=>))/)){let l=!1,a=0,c=!1,u=i;while(u<s.length){let f=s[u];for(let m of f){if(m==="{")a++,c=!0;if(m==="}"){if(a--,a===0&&c)break}}if(f.match(/\bawait\s+/))l=!0;if(a===0&&c){if(!l)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"eslint/require-await",message:"Async function has no await expression",severity:"error"});break}u++}}return t}};var Eo=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/;function b(e){return{meta:e.meta,check:(n,t)=>{if(!Eo.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Eo.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var Lo=/\.(?:sh|bash|zsh|ksh|dash)$/,To=/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/;function he(e){return{meta:e.meta,check:(n,t)=>{if(!Lo.test(t.filePath)&&!To.test(n))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Lo.test(t.filePath)&&!To.test(n))return n;return e.fix(n,t)}:void 0}}var Ao=/(?:^|[/\\])package\.json$/;function pe(e){return{meta:e.meta,check:(n,t)=>{if(!Ao.test(t.filePath))return[];return e.check(n,t)},fix:e.fix?(n,t)=>{if(!Ao.test(t.filePath))return n;return e.fix(n,t)}:void 0}}var Oo={name:"eslint",rules:{"array-callback-return":b(Rn),"constructor-super":b(kn),"for-direction":b($n),"getter-return":b(Pn),"no-async-promise-executor":b(In),"no-compare-neg-zero":b(vn),"no-cond-assign":b(Mn),"no-constant-condition":b(Sn),"no-const-assign":b(Cn),"no-dupe-class-members":b(En),"no-dupe-keys":b(Ot),"no-duplicate-case":b(Ln),"no-empty-pattern":b(Tn),"no-fallthrough":b(An),"no-loss-of-precision":b(On),"no-promise-executor-return":b(_n),"no-redeclare":b(Dn),"no-self-assign":b(_t),"no-self-compare":b(Fn),"no-sparse-arrays":b(Nn),"no-undef":b(Wn),"no-unsafe-negation":b(jn),"no-unreachable":b(Bn),"no-useless-catch":b(Un),"use-isnan":b(zn),"valid-typeof":b(qn),"default-case":b(Vn),eqeqeq:b(Hn),"no-alert":b(Jn),"no-await-in-loop":b(Yn),"no-caller":b(Xn),"no-case-declarations":b(Qn),"no-else-return":b(es),"no-empty":b(ts),"no-empty-function":b(ns),"no-eval":b(ss),"no-extend-native":b(is),"no-global-assign":b(os),"no-implied-eval":b(ls),"no-iterator":b(as),"no-new":b(cs),"no-new-func":b(us),"no-new-wrappers":b(fs),"no-octal":b(ms),"no-param-reassign":b(hs),"no-proto":b(ds),"no-return-assign":b(ps),"no-shadow":b(ys),"no-throw-literal":b(bs),"no-use-before-define":b(xs),"no-useless-call":b(ws),"no-with":b(Is),"require-await":b(Ms),complexity:b(Kn),"max-depth":b(Zn),"max-lines-per-function":b(Gn),"no-extra-boolean-cast":b(rs),"no-lonely-if":b(Dt),"no-sequences":b(gs),"no-useless-concat":b(Rs),"no-useless-escape":b(ks),"no-useless-rename":b($s),"no-useless-return":b(Ft),"no-var":b(Ps),"prefer-arrow-callback":b(vs)}};var _o={meta:{docs:"Disallow return statements in constructors - constructors automatically return the instance"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.indexOf("//");if(!(o>=0?r.slice(0,o):r).match(/\bconstructor\s*\(/))continue;let c=0,u=!1,f=-1;for(let m=i;m<s.length;m++){let h=s[m],d=null,p=!1;for(let y=0;y<h.length;y++){let g=h[y];if(p){p=!1;continue}if(g==="\\"&&d){p=!0;continue}if(!d){if(g==="'")d="single";else if(g==='"')d="double";else if(g==="`")d="template";else if(g==="{")c++,u=!0;else if(g==="}"){if(c--,u&&c===0){f=m;break}}}else if(d==="single"&&g==="'"||d==="double"&&g==='"'||d==="template"&&g==="`")d=null}if(f!==-1)break}if(f===-1)continue;for(let m=i;m<=f;m++){let h=s[m];if(m===i)continue;if(/^\s*\/\//.test(h))continue;let d=h.indexOf("//"),p=d>=0?h.slice(0,d):h;if(p=p.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),p.match(/\breturn\b/)){let g=p.indexOf("return"),x=g>0?p[g-1]:" ",k=g+6<p.length?p[g+6]:" ";if(/\w/.test(x)||/\w/.test(k))continue;let P=p.slice(g+6).trim();if(P.startsWith("this;")||P==="this")continue;if(P===";"||P==="")continue;let w=h.indexOf("return");t.push({filePath:n.filePath,line:m+1,column:w+1||1,ruleId:"no-constructor-return",message:"Unexpected return statement in constructor. Constructors should not return values.",severity:"error",help:"Remove the return statement or move the logic outside of the constructor"})}}}return t}};var Do={meta:{docs:"Disallow irregular whitespace characters that may cause issues in code"},check:(e,n)=>{let t=[],s=/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g,i=e.split(/\r?\n/);for(let r=0;r<i.length;r++){let o=i[r],l;s.lastIndex=0;while((l=s.exec(o))!==null){let c=l[0].charCodeAt(0),u="irregular whitespace",f={160:"NO-BREAK SPACE",5760:"OGHAM SPACE MARK",6158:"MONGOLIAN VOWEL SEPARATOR",8192:"EN QUAD",8193:"EM QUAD",8194:"EN SPACE",8195:"EM SPACE",8196:"THREE-PER-EM SPACE",8197:"FOUR-PER-EM SPACE",8198:"SIX-PER-EM SPACE",8199:"FIGURE SPACE",8200:"PUNCTUATION SPACE",8201:"THIN SPACE",8202:"HAIR SPACE",8232:"LINE SEPARATOR",8233:"PARAGRAPH SEPARATOR",8239:"NARROW NO-BREAK SPACE",8287:"MEDIUM MATHEMATICAL SPACE",12288:"IDEOGRAPHIC SPACE",65279:"ZERO WIDTH NO-BREAK SPACE"};if(f[c])u=f[c];t.push({filePath:n.filePath,line:r+1,column:l.index+1,ruleId:"no-irregular-whitespace",message:`Irregular whitespace detected: ${u} (U+${c.toString(16).toUpperCase().padStart(4,"0")})`,severity:"error",help:"Replace irregular whitespace with regular spaces or tabs"})}}return t},fix:(e)=>e.replace(/[\u00A0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/g," ")};var Fo={meta:{docs:"Disallow new operators outside of assignments or comparisons",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(o.startsWith("//")||o.startsWith("/*")||o.startsWith("*"))continue;if(/^\s*new\s+\w+/.test(r)){let a=/^\s*(?:const|let|var|this\.\w+)\s*=\s*new\s+/,c=/^\s*return\s+new\s+/,u=new RegExp("^\\s*new\\s+\\w[^;]*,"),f=/[=:,(]\s*new\s+/;if(!a.test(r)&&!c.test(r)&&!u.test(r)&&!f.test(o)){let m=r.search(/new\s+/)+1;t.push({filePath:n.filePath,line:i+1,column:m,ruleId:"no-new",message:"Do not use 'new' for side effects",severity:"error",help:"Either assign the result to a variable or remove the 'new' operator if the side effect is intentional."})}}}return t}};var No={meta:{docs:"Disallow multiple spaces in regular expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s*\/\//.test(r))continue;let o=/\/(?![*/])((?:\\.|[^/\\])+)\/[gimsuvy]*/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let c=l[1];if(/ {2,}/.test(c)){let u=l.index+1;t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}let a=/new\s+RegExp\s*\(\s*['"`]([^'"`]+)['"`]/g;for(l=a.exec(r);l!==null;l=a.exec(r)){let c=l[1];if(/ {2,}/.test(c)){let u=l.index+1;t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"no-regex-spaces",message:"Multiple spaces in regular expression",severity:"error",help:"Use quantifiers like {2} instead of multiple spaces for clarity."})}}}return t}};var Wo=new Set(["|","&",":",",","<"]),od=new Set(["(",",","=",":","[","!","&","|","?","{","}",";","+","-","*","%","<",">","~","^"]),ld=["return","typeof","instanceof","in","of","new","delete","void","case","do","else","yield","await"];function ad(e,n){let t=n-1;while(t>=0&&/\s/.test(e[t]))t-=1;if(t<0)return!0;let s=e[t];if(od.has(s))return!0;if(/[\w$)\]]/.test(s)){if(/[\w$]/.test(s)){let i=t;while(i>=0&&/[\w$]/.test(e[i]))i-=1;let r=e.slice(i+1,t+1);return ld.includes(r)}return!1}return!0}function Cs(e,n){if(e[n+1]==="/"||e[n+1]==="*")return!1;let t=e.slice(0,n).trimEnd();return!t||/[=([{,:;!&|?]$/.test(t)||t.endsWith("=>")||t.endsWith("return")}function cd(e){let n=e.split(""),t=0,s=null,i=!1,r=[],o=()=>r.length>0&&r[r.length-1]===-1,l=()=>r.length>0&&r[r.length-1]>=0,a=(c,u)=>{for(let f=c;f<u&&f<n.length;f+=1)if(n[f]!==`
58
+ `&&n[f]!=="\r")n[f]=" "};while(t<e.length){let c=e[t];if(s){if(i)i=!1;else if(c==="\\")i=!0;else if(c===s)s=null;else if(c===`
59
+ `)s=null;t+=1;continue}if(o()){if(i)i=!1;else if(c==="\\")i=!0;else if(c==="`")r.pop();else if(c==="$"&&e[t+1]==="{")r.push(0),t+=1;t+=1;continue}if(c==="`"){r.push(-1),t+=1;continue}if(l()){if(c==="{"){r[r.length-1]+=1,t+=1;continue}if(c==="}"){let u=r[r.length-1];if(u>0)r[r.length-1]=u-1;else r.pop();t+=1;continue}}if(c==="'"||c==='"'){s=c,t+=1;continue}if(c==="/"&&e[t+1]!=="/"&&e[t+1]!=="*"&&ad(e,t)){let u=t+1,f=!1,m=!1;while(u<e.length){let h=e[u];if(m)m=!1;else if(h==="\\")m=!0;else if(h==="[")f=!0;else if(h==="]")f=!1;else if(h===`
60
+ `)break;else if(h==="/"&&!f){u+=1;break}u+=1}t=u;continue}if(c==="/"&&e[t+1]==="/"){let u=e.indexOf(`
61
+ `,t);a(t+2,u<0?e.length:u),t=u<0?e.length:u;continue}if(c==="/"&&e[t+1]==="*"){let u=e.indexOf("*/",t+2);a(t+2,u<0?e.length:u),t=u<0?e.length:u+2;continue}t+=1}return n.join("")}var Ye={meta:{docs:"Report variables and parameters that are declared/assigned but never used"},check:(e,n)=>{if(n.filePath.endsWith("/no-unused-vars.ts"))return[];if(n.filePath.endsWith(".d.ts"))return[];let t=[],s=n.options||{},i=typeof s.varsIgnorePattern==="string"?s.varsIgnorePattern:"^_",r=typeof s.argsIgnorePattern==="string"?s.argsIgnorePattern:"^_",o=new RegExp(i,"u"),l=new RegExp(r,"u"),a=cd(e),c=a.split(/\r?\n/),u=a,f=Array(c.length).fill(!1);(()=>{let w=[],M=!1,A=!1,O=!1,E=!1,D=!1,S="",C=()=>{if(S==="")return!0;if("=([{,;!&|?:+-*/%^~<>".includes(S))return!0;return!1};for(let L=0;L<c.length;L++){f[L]=w.length>0&&w[w.length-1]===-1;let F=c[L];for(let T=0;T<F.length;T++){let R=F[T];if(E){if(R==="*"&&T+1<F.length&&F[T+1]==="/")E=!1,T++;continue}if(D){D=!1;continue}let v=w.length>0&&w[w.length-1]===-1,I=w.length>0&&w[w.length-1]>=0;if(R==="\\"&&(M||A||O||v)){D=!0;continue}if(M){if(R==="'")M=!1;continue}if(A){if(R==='"')A=!1;continue}if(O){if(R==="["){let N=1,B=T+1;while(B<F.length){let W=F[B];if(W==="\\"){B+=2;continue}if(W==="]"){if(N--,N===0)break}B++}T=B;continue}if(R==="/"){O=!1;while(T+1<F.length&&/[gimsuvy]/.test(F[T+1]))T++}continue}if(v){if(R==="`")w.pop();else if(R==="$"&&T+1<F.length&&F[T+1]==="{")w.push(0),T++;continue}if(R==="/"&&T+1<F.length&&F[T+1]==="/")break;if(R==="/"&&T+1<F.length&&F[T+1]==="*"){E=!0,T++;continue}if(I){if(R==="`")w.push(-1),S="";else if(R==="'")M=!0,S="'";else if(R==='"')A=!0,S='"';else if(R==="{")w[w.length-1]++,S="{";else if(R==="}"){let N=w[w.length-1];if(N>0)w[w.length-1]=N-1;else w.pop();S="}"}else if(R==="/"&&C())O=!0;else if(!/\s/.test(R))S=R;continue}if(R==="`")w.push(-1),S="";else if(R==="'")M=!0,S="'";else if(R==='"')A=!0,S='"';else if(R==="/"&&C())O=!0;else if(!/\s/.test(R))S=R}}})();let h=new RegExp("^\\s*(?:const|let|var)\\s+(.+?);?\\s*$");for(let w=0;w<c.length;w++){if(f[w])continue;let M=c[w],A=M.match(h);if(!A)continue;let O=A[1],E=[],D="",S=0,C=0,L=null,F=!1;for(let T=0;T<O.length;T++){let R=O[T];if(F){F=!1,D+=R;continue}if(R==="\\"&&L){F=!0,D+=R;continue}if(!L){if(R==="/"&&O[T+1]==="/")break;if(R==="/"&&O[T+1]==="*"){T+=2;while(T<O.length&&!(O[T]==="*"&&O[T+1]==="/"))T++;T++;continue}if(R==="'")L="single";else if(R==='"')L="double";else if(R==="`")L="template";else if(R==="<")C++;else if(R===">")C--;else if(R==="("||R==="["||R==="{")S++;else if(R===")"||R==="]"||R==="}")S--;else if(R===","&&S===0&&C===0){E.push(D),D="";continue}}else if(L==="single"&&R==="'"||L==="double"&&R==='"'||L==="template"&&R==="`")L=null;D+=R}if(D)E.push(D);for(let T of E){let R=T.trim();if(!R)continue;let v=R.match(/^([$A-Z_][\w$]*)/i),I=[];if(v)I.push(v[1]);else if(R.startsWith("{")||R.startsWith("[")){let N=R[0],B=N==="{"?"}":"]",W=0,_=-1,z=null,U=!1;for(let Y=0;Y<R.length;Y++){let V=R[Y];if(U){U=!1;continue}if(V==="\\"&&z){U=!0;continue}if(!z){if(V==="'"||V==='"'||V==="`")z=V==="'"?"single":V==='"'?"double":"template";else if(V===N)W++;else if(V===B){if(W--,W===0){_=Y;break}}}else if(z==="single"&&V==="'"||z==="double"&&V==='"'||z==="template"&&V==="`")z=null}if(_>0){let Y=R.slice(1,_),V=[],te="",de=0,q=null,G=!1;for(let Z=0;Z<Y.length;Z++){let K=Y[Z];if(G){G=!1,te+=K;continue}if(K==="\\"&&q){G=!0,te+=K;continue}if(!q){if(K==="'"||K==='"'||K==="`"){q=K==="'"?"single":K==='"'?"double":"template",te+=K;continue}if(K==="("||K==="{"||K==="[")de++;if(K===")"||K==="}"||K==="]")de--;if(K===","&&de===0){V.push(te.trim()),te="";continue}}else if(q==="single"&&K==="'"||q==="double"&&K==='"'||q==="template"&&K==="`")q=null;te+=K}if(te.trim())V.push(te.trim());for(let Z of V){if(Z.startsWith("...")){let we=Z.slice(3).match(/^([$A-Z_][\w$]*)/i);if(we)I.push(we[1]);continue}let K=Z.indexOf(":");if(K!==-1){let we=Z.slice(K+1).trim(),ge=0;for(let je=0;je<we.length;je++){let ve=we[je];if(ve==="("||ve==="{"||ve==="[")ge++;else if(ve===")"||ve==="}"||ve==="]")ge--;else if(ve==="="&&ge===0){we=we.slice(0,je).trim();break}}let Ct=we.match(/^([$A-Z_][\w$]*)/i);if(Ct)I.push(Ct[1])}else{let we=Z,ge=0;for(let je=0;je<we.length;je++){let ve=we[je];if(ve==="("||ve==="{"||ve==="[")ge++;else if(ve===")"||ve==="}"||ve==="]")ge--;else if(ve==="="&&ge===0){we=we.slice(0,je).trim();break}}let Ct=we.match(/^([$A-Z_][\w$]*)/i);if(Ct)I.push(Ct[1])}}}}for(let N of I){if(o.test(N))continue;let B=`${c.slice(0,w).join(`
62
+ `)}
63
+ ${c.slice(w+1).join(`
64
+ `)}`;if(!new RegExp(`\\b${N}\\b`,"g").test(B))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(N)+1),ruleId:"pickier/no-unused-vars",message:`'${N}' is assigned a value but never used. Allowed unused vars must match pattern: ${i}`,severity:"error",help:`Either use this variable in your code, remove it, or prefix it with an underscore (_${N}) to mark it as intentionally unused`})}}}let d=(w)=>{let A=((D)=>{let S="",C=null,L=!1,F=0;for(let T=0;T<D.length;T++){let R=D[T];if(L){L=!1;continue}if(R==="\\"&&C){L=!0;continue}if(!C){if(R==="'")C="single";else if(R==='"')C="double";else if(R==="`")C="template";else if(R==="("||R==="{"||R==="[")F++;else if(R===")"||R==="}"||R==="]")F--;else if(R==="="&&F===0)return S}else if(C==="single"&&R==="'"||C==="double"&&R==='"'||C==="template"&&R==="`")C=null;S+=R}return S})(w);return((D)=>{let S="",C=0;while(C<D.length){let L=D[C];if(L===":"){C++;while(C<D.length&&/\s/.test(D[C]))C++;let F=0,T=0,R=null,v=!1;while(C<D.length){let I=D[C];if(v){v=!1,C++;continue}if(I==="\\"&&R){v=!0,C++;continue}if(!R){if(I==="'")R="single";else if(I==='"')R="double";else if(I==="`")R="template";else if(I==="<")T++;else if(I===">")T--;else if(I==="("||I==="{"||I==="[")F++;else if(I===")"||I==="}"||I==="]")if(F>0)F--;else break;else if(I===","&&F===0&&T===0)break}else if(R==="single"&&I==="'"||R==="double"&&I==='"'||R==="template"&&I==="`")R=null;C++}continue}S+=L,C++}return S})(A).split(/[^$\w]+/).filter((D)=>D&&D!=="undefined")},p=(w,M)=>{let A=!1,O=0,E=0,D=!1,S=0,C=null,L=!1,F=!0,T="",R=!1,v=!1,I=[],N=!1;for(let B=w;B<c.length;B++){let W=c[B],_=W,z=I.length>0&&I[I.length-1]===-1,U=-1,Y=null,V=!1;if(!z)for(let q=0;q<W.length-1;q++){let G=W[q],Z=W[q+1];if(V){V=!1;continue}if(G==="\\"&&Y){V=!0;continue}if(!Y){if(G==="'")Y="single";else if(G==='"')Y="double";else if(G==="`")Y="template";else if(G==="/"&&Z==="/"){U=q;break}}else if(Y==="single"&&G==="'"||Y==="double"&&G==='"'||Y==="template"&&G==="`")Y=null}if(U>=0)_=W.slice(0,U);let te=(q)=>{let G="",Z=0,K=null,we=!1;while(Z<q.length){let ge=q[Z];if(we){we=!1,G+=ge,Z++;continue}if(ge==="\\"&&K){we=!0,G+=ge,Z++;continue}if(!K){if(ge==="'")K="single";else if(ge==='"')K="double";else if(ge==="`")K="template";else if(ge==="/"){if(Cs(q,Z)){Z++;while(Z<q.length){if(q[Z]==="\\"){Z+=2;continue}if(q[Z]==="/"){Z++;while(Z<q.length&&/[gimsuvy]/.test(q[Z]))Z++;break}Z++}continue}}}else if(K==="single"&&ge==="'"||K==="double"&&ge==='"'||K==="template"&&ge==="`")K=null;G+=ge,Z++}return G};if(!z)_=te(_);let de=0;if(!A){let q=-1,G=F?typeof M==="number"?M:0:0;if(F=!1,G>=_.length){let Z=_.indexOf("=>");G=Z>=0?Z+2:0}for(let Z=G;Z<_.length;Z++){let K=_[Z];if(L){L=!1;continue}if(K==="\\"&&C){L=!0;continue}if(!C){if(K!==" "&&K!=="\t"&&K!==`
65
+ `&&K!=="\r"&&K!=="{"&&K!=="}"&&E===0)T=K;if(K==="'")C="single";else if(K==='"')C="double";else if(K==="`")C="template";else if(K==="<")S++;else if(K===">")S=Math.max(0,S-1);else if(K==="{"){if(E===0){if(D&&S===0&&!Wo.has(T)){q=Z;break}}E++}else if(K==="}"){if(E>0){if(E--,E===0)D=!0,T="}"}}}else if(C==="single"&&K==="'"||C==="double"&&K==='"'||C==="template"&&K==="`")C=null}if(q===-1){if(S>0)continue;if(E>0&&Wo.has(T))continue;for(let Z=G;Z<_.length;Z++)if(_[Z]==="{"&&!C){q=Z;break}}if(q===-1)continue;A=!0,O=1,de=q+1,w=B}for(let q=de;q<_.length;q++){let G=_[q];if(N){N=!1;continue}let Z=I.length>0&&I[I.length-1]===-1,K=I.length>0&&I[I.length-1]>=0;if(G==="\\"&&(R||v||Z)){N=!0;continue}if(R){if(G==="'")R=!1;continue}if(v){if(G==='"')v=!1;continue}if(Z){if(G==="`")I.pop();else if(G==="$"&&q+1<_.length&&_[q+1]==="{")I[I.length-1]=0,q++;continue}if(K){if(G==="/"){if(Cs(_,q)){q++;while(q<_.length){if(_[q]==="\\"){q+=2;continue}if(_[q]==="/"){while(q+1<_.length&&/[gimsuvy]/.test(_[q+1]))q++;break}q++}continue}}if(G==="`"){I.push(-1);continue}if(G==="'"){R=!0;continue}if(G==='"'){v=!0;continue}if(G==="{"){I[I.length-1]++;continue}if(G==="}")if(I[I.length-1]>0)I[I.length-1]--;else I[I.length-1]=-1;continue}if(G==="'")R=!0;else if(G==='"')v=!0;else if(G==="`")I.push(-1);else if(G==="{")O++;else if(G==="}"){if(O--,O===0)return{from:w,to:B}}}}return null},y=(w,M)=>{let A={parenDepth:0,braceDepth:0,bracketDepth:0,inTemplate:!1},O=(F)=>{for(let T=0;T<F.length;T++){let R=F[T];if(R==="`")A.inTemplate=!A.inTemplate;else if(R==="(")A.parenDepth++;else if(R===")")A.parenDepth--;else if(R==="{")A.braceDepth++;else if(R==="}")A.braceDepth--;else if(R==="[")A.bracketDepth++;else if(R==="]")A.bracketDepth--}},E=()=>A.parenDepth>0||A.braceDepth>0||A.bracketDepth>0||A.inTemplate,D=(F)=>/(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)$/.test(F.trimEnd()),S=(F)=>/^(?:\?|:|\.|,|&&|\|\||\?\?|\+|-|\*|\/|%|\*\*)/.test(F.trimStart()),C=c[w].slice(M+2);O(C);let L=w+1;while(L<c.length){let F=L===w+1?C:c[L-1];if(!(!C.trim()||E()||D(F)||S(c[L])))break;C+=`
66
+ ${c[L]}`,O(c[L]),L++}return C},g=[],x=!1,k=!1,P=!1;for(let w=0;w<c.length;w++){let M=c[w];if(/^\s*\/\//.test(M))continue;if(f[w])continue;let A=M,O=null,E=!1,D=!1;for(let R=0;R<M.length-1;R++){let v=M[R],I=M[R+1];if(D){D=!1;continue}if(v==="\\"&&(O||E)){D=!0;continue}if(!O&&!E){if(v==="'")O="single";else if(v==='"')O="double";else if(v==="`")O="template";else if(v==="/"){if(Cs(M,R))E=!0;else if(I==="/"){A=M.slice(0,R);break}}}else if(O){if(O==="single"&&v==="'"||O==="double"&&v==='"'||O==="template"&&v==="`")O=null}else if(E&&v==="/")E=!1}let L=((R)=>{let v="",I=0;while(I<R.length){if(R[I]==="/"){if(Cs(R,I)){I++;while(I<R.length){if(R[I]==="\\"){I+=2;continue}if(R[I]==="/"){I++;while(I<R.length&&/[gimsuvy]/.test(R[I]))I++;break}I++}continue}}v+=R[I],I++}return v})(A).replace(/'(?:[^'\\]|\\.)*'/g,"''").replace(/"(?:[^"\\]|\\.)*"/g,'""');{let R="";for(let v=0;v<L.length;v++){let I=L[v];if(P){P=!1;let W=g.length>0&&g[g.length-1]===-1;R+=W?" ":I;continue}let N=g.length>0&&g[g.length-1]===-1,B=g.length>0&&g[g.length-1]>=0;if(I==="\\"&&(x||k||N)){P=!0,R+=N?" ":I;continue}if(x){if(I==="'")x=!1;R+=I;continue}if(k){if(I==='"')k=!1;R+=I;continue}if(N){if(I==="`")g.pop();else if(I==="$"&&v+1<L.length&&L[v+1]==="{")g[g.length-1]=0,R+=" ",v++;else R+=" ";continue}if(B){if(I==="`")g.push(-1),R+=" ";else if(I==="'")x=!0,R+=I;else if(I==='"')k=!0,R+=I;else if(I==="{")g[g.length-1]++,R+=I;else if(I==="}")if(g[g.length-1]>0)g[g.length-1]--,R+=I;else g[g.length-1]=-1,R+=" ";else R+=I;continue}if(I==="`")g.push(-1),R+=" ";else if(I==="'")x=!0,R+=I;else if(I==='"')k=!0,R+=I;else R+=I}L=R}let F=L.match(/\bfunction\b/);if(F){if(M.includes("function scanContent")||M.includes("function findMatching"))continue;if(L.slice(F.index+8).trimStart().startsWith(":"))continue;let v=L.slice(0,F.index).trimEnd();if(v.endsWith(".")||v.endsWith("?."))continue;let I=F.index,N=M.indexOf("(",I);if(N===-1)continue;let B=0,W=-1,_=w,z="";for(let te=w;te<c.length;te++){let de=te===w?c[te]:c[te],q=te===w?N:0;for(let G=q;G<de.length;G++)if(de[G]==="(")B++;else if(de[G]===")"){if(B--,B===0){if(W=G,_=te,w===te)z=M.slice(N+1,W);else{z=M.slice(N+1);for(let Z=w+1;Z<te;Z++)z+=` ${c[Z]}`;z+=` ${de.slice(0,W)}`}break}}if(W!==-1)break}if(W===-1)continue;let U=d(z),Y=p(_,W),V="";if(Y)if(Y.from===_){let te=c[Y.from],de=te.lastIndexOf("{"),q=de>=0?te.slice(de+1):"";if(Y.to>Y.from)V=`${q}
67
+ ${c.slice(Y.from+1,Y.to+1).join(`
68
+ `)}`;else V=q}else V=c.slice(Y.from,Y.to+1).join(`
69
+ `);for(let te of U){if(!te||l.test(te)||te==="undefined")continue;if(!new RegExp(`\\b${te}\\b`,"g").test(V))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(te)+1),ruleId:"pickier/no-unused-vars",message:`'${te}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}continue}let T=M.indexOf("=>");if(T!==-1&&L.includes("=>")){let R=-1;for(let v=T-1;v>=0;v--){let I=M[v];if(I===")"){R=v;break}if(I!==" "&&I!=="\t"&&I!==`
70
+ `&&I!==":"&&I!==">"&&!/\w/.test(I))break}if(R!==-1){let v=-1,I=1;for(let N=R-1;N>=0;N--){let B=M[N];if(B===")")I++;else if(B==="("){if(I--,I===0){v=N;break}}}if(v!==-1){let N=!1,B=0,W=0;for(let z=v-1;z>=0;z--){let U=M[z];if(U===">"){B++;continue}if(U==="<"){if(B>0){B--;continue}if(W<=0){N=!0;break}continue}if(U===":"&&B===0&&W<=0){N=!0;break}if(B>0)continue;if(U===",")continue;if(U===")"){W++;continue}if(U==="("){W--;continue}if(U==="|"||U==="&"){N=!0;break}if(U==="="||U==="{"||U==="["){if(W>=0)break;continue}if(U!==" "&&U!=="\t"&&!/[\w.]/.test(U)){if(W>=0)break}}if(!N){let z=M.slice(0,v);if(/^\s*(?:export\s+)?(?:declare\s+)?type\s+\w[\w$]*\s*(?:<[^>]*>)?\s*=\s*$/.test(z))N=!0;else if(/\bas\s+$/.test(z))N=!0}if(N)continue;let _=M.slice(v+1,R);if(!(_.trim()===""&&M.slice(Math.max(0,v-10),v).includes("async"))){let z=d(_);if(z.length>0){let U="";if(M.slice(T+2).trimStart().startsWith("{")){let V=p(w,T);if(V)if(V.from===w){let te=c[V.from],de=te.indexOf("{",T),q=de>=0?te.slice(de+1):"";if(V.to>V.from)U=`${q}
71
+ ${c.slice(V.from+1,V.to+1).join(`
72
+ `)}`;else U=q}else U=c.slice(V.from,V.to+1).join(`
73
+ `)}else U=y(w,T);for(let V of z){if(!V||l.test(V)||V==="undefined")continue;if(!new RegExp(`\\b${V}\\b`,"g").test(U))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(V)+1),ruleId:"pickier/no-unused-vars",message:`'${V}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}continue}}}}}{let R=/(?:^|[=,:({\s])\s*([$A-Z_][\w$]*)\s*=>/gi,v;while((v=R.exec(L))!==null){let I=v[1];if(!I||l.test(I)||I==="undefined")continue;let N=L.slice(0,v.index+v[0].indexOf(I)).trimEnd();if(/\)\s*:$/.test(N)||/\)\s*:\s*$/.test(N))continue;if(/\)\s*:\s*[$A-Z_][\w$]*\s+is$/i.test(N))continue;if(/^(?:string|number|boolean|void|never|any|unknown|object|bigint|symbol|undefined|null)$/.test(I))continue;let B=new RegExp(`\\b${I}\\s*=>`),W=M.match(B);if(!W)continue;let _=M.indexOf(W[0])+W[0].lastIndexOf("=>"),z="";if(M.slice(_+2).trimStart().startsWith("{")){let V=p(w,_);if(V)if(V.from===w){let te=c[V.from],de=te.indexOf("{",_),q=de>=0?te.slice(de+1):"";if(V.to>V.from)z=`${q}
74
+ ${c.slice(V.from+1,V.to+1).join(`
75
+ `)}`;else z=q}else z=c.slice(V.from,V.to+1).join(`
76
+ `)}else z=y(w,_);if(!new RegExp(`\\b${I}\\b`,"g").test(z))t.push({filePath:n.filePath,line:w+1,column:Math.max(1,M.indexOf(I)+1),ruleId:"pickier/no-unused-vars",message:`'${I}' is defined but never used (function parameter). Allowed unused args must match pattern: ${r}`,severity:"error"})}}}return t},fix:(e,n)=>{let t=Ye.check(e,n);if(t.length===0)return e;let s=t.filter((f)=>f.message.includes("(function parameter)"));if(s.length===0)return e;let i=e.split(/\r?\n/),r=new Set,o=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let f=0;f<i.length;f++){let m=i[f].match(o);if(!m)continue;let h=m[1].trim();if(h===""||/\bno-unused-vars\b/.test(h)||/\bpickier\/no-unused-vars\b/.test(h))r.add(f+2)}let l=new Map;for(let f of s){if(r.has(f.line))continue;let m=f.message.match(/^'([^']+)'/);if(!m)continue;let h=m[1];if(h.startsWith("_"))continue;let d=l.get(f.line);if(!d)d=new Set,l.set(f.line,d);d.add(h)}if(l.size===0)return e;let a=e.split(/\r?\n/);function c(f){let m=[],h=!1,d=!1,p=!1,y=-1;for(let g=0;g<f.length;g++){let x=f[g];if(p){p=!1;continue}if(x==="\\"&&(h||d||y>=0)){p=!0;continue}if(y>=0){if(x==="`")m.push([y,g]),y=-1;continue}if(h){if(x==="'")h=!1;continue}if(d){if(x==='"')d=!1;continue}if(x==="`")y=g;else if(x==="'")h=!0;else if(x==='"')d=!0}if(y>=0)m.push([y,f.length]);return m}let u=!1;for(let[f,m]of l){let h=f-1,d=a[h];if(d===void 0)continue;let p=c(d),y=(k)=>p.some(([P,w])=>k>P&&k<w),g=[];for(let k of m){let P=k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),w=new RegExp(`(?<=[(,]\\s*)\\b${P}\\b(?=\\s*[,):=])`,"g"),M;while((M=w.exec(d))!==null){if(y(M.index))continue;g.push({start:M.index,end:M.index+k.length,name:k})}}if(g.length===0)continue;g.sort((k,P)=>P.start-k.start);let x=d;for(let k of g)x=`${x.slice(0,k.start)}_${k.name}${x.slice(k.end)}`;if(x!==d)a[h]=x,u=!0}return u?a.join(`
77
+ `):e}};function Xe(e){let n=e.split(/\r?\n/),t=Array(n.length).fill(!1),s=[],i=!1,r=!1,o=!1,l=!1,a=!1,c="",u=()=>{if(c==="")return!0;return"=([{,;!&|?:+-*/%^~<>".includes(c)};for(let f=0;f<n.length;f++){t[f]=s.length>0&&s[s.length-1]===-1;let m=n[f];for(let h=0;h<m.length;h++){let d=m[h];if(l){if(d==="*"&&h+1<m.length&&m[h+1]==="/")l=!1,h++;continue}if(a){a=!1;continue}let p=s.length>0&&s[s.length-1]===-1,y=s.length>0&&s[s.length-1]>=0;if(d==="\\"&&(i||r||o||p)){a=!0;continue}if(i){if(d==="'")i=!1;continue}if(r){if(d==='"')r=!1;continue}if(o){if(d==="["){let g=1,x=h+1;while(x<m.length){let k=m[x];if(k==="\\"){x+=2;continue}if(k==="]"){if(g--,g===0)break}x++}h=x;continue}if(d==="/"){o=!1;while(h+1<m.length&&/[gimsuvy]/.test(m[h+1]))h++}continue}if(p){if(d==="`")s.pop();else if(d==="$"&&h+1<m.length&&m[h+1]==="{")s.push(0),h++;continue}if(d==="/"&&h+1<m.length&&m[h+1]==="/")break;if(d==="/"&&h+1<m.length&&m[h+1]==="*"){l=!0,h++;continue}if(y){if(d==="`")s.push(-1),c="";else if(d==="'")i=!0,c="'";else if(d==='"')r=!0,c='"';else if(d==="{")s[s.length-1]++,c="{";else if(d==="}"){let g=s[s.length-1];if(g>0)s[s.length-1]=g-1;else s.pop();c="}"}else if(d==="/"&&u())o=!0;else if(!/\s/.test(d))c=d;continue}if(d==="`")s.push(-1),c="";else if(d==="'")i=!0,c="'";else if(d==='"')r=!0,c='"';else if(d==="/"&&u())o=!0;else if(!/\s/.test(d))c=d}}return t}function ud(e,n){let t=[],s=0,i=0,r=null,o=!1;for(let l=0;l<e.length;l++){let a=e[l];if(o){o=!1;continue}if(a==="\\"&&r){o=!0;continue}if(!r){if(a==="'")r="single";else if(a==='"')r="double";else if(a==="`")r="template";else if(a==="("||a==="{"||a==="[")s++;else if(a===")"||a==="}"||a==="]")s--;else if(a===n&&s===0)t.push(e.slice(i,l)),i=l+1}else if(r==="single"&&a==="'"||r==="double"&&a==='"'||r==="template"&&a==="`")r=null}return t.push(e.slice(i)),t}function fd(e){let n=0;for(let t=0;t<e.length;t++){let s=e[t];if(s==="{"||s==="("||s==="["||s==="<")n++;else if(s==="}"||s===")"||s==="]"||s===">")n--;else if(s==="="&&n===0&&e[t+1]!=="="&&e[t-1]!=="!"&&e[t-1]!=="<"&&e[t-1]!==">")return t}return-1}function md(e,n){let t=new RegExp(`\\b${n}\\b`),s=0,i=null,r=!1;while(s<e.length){let o=e[s];if(r){r=!1,s++;continue}if(o==="\\"&&i){r=!0,s++;continue}if(i){if(i==="single"&&o==="'"||i==="double"&&o==='"'||i==="template"&&o==="`")i=null;s++;continue}if(o==="'"){i="single",s++;continue}if(o==='"'){i="double",s++;continue}if(o==="`"){i="template",s++;continue}if(o==="["||o==="{"){let l=o,a=o==="["?"]":"}",c=1,u=s+1;while(u<e.length&&c>0){let f=e[u];if(f==="\\"){u+=2;continue}if(f===l)c++;else if(f===a)c--;if(c===0)break;u++}if(c===0&&u<e.length){let f=u+1;while(f<e.length&&(e[f]===" "||e[f]==="\t"||e[f]==="\r"||e[f]===`
78
+ `))f++;if(e[f]==="="&&e[f+1]!=="="&&e[f+1]!==">"){let m=e.slice(s+1,u);if(t.test(m)){let h=new RegExp(`\\b${n}\\b\\s*:`),d=new RegExp(`:\\s*\\b${n}\\b`);if(l==="{"){if(!(h.test(m)&&!d.test(m)&&!new RegExp(`(?:^|[\\s,{])\\s*${n}\\s*(?:,|\\s*=|\\s*})`).test(m)))return!0}else return!0}}}s=u+1;continue}s++}return!1}function Bo(e,n){let t=new RegExp("^\\s*(?:let|var)\\s+(.+?);?\\s*$"),s=e.match(t);if(!s)return null;let i=s[1],r=fd(i);if(r>=0){let a=i.indexOf(":");if(a>=0&&a<r)i=i.slice(0,a)+i.slice(r)}let o=ud(i,","),l=[];for(let a of o){let c=a.trim();if(!c)continue;if(c.match(/^[{[]/))return null;let f=c.match(/^([$A-Z_][\w$]*)/i);if(!f)return null;let m=f[1];if(!/=/.test(c))return null;let d=n.indexOf(e),p=n.slice(d+e.length),g=`\\b${m}\\s*(?:${[">>>=","**=","<<=",">>=","??=","||=","&&=","+=","-=","*=","/=","%=","&=","^=","|=","="].map((O)=>O.replace(/[|\\^$*+?.(){}[\]]/g,(E)=>`\\${E}`)).join("|")})`,x=new RegExp(g).test(p),k=new RegExp(`(?:^|[^$w])(?:\\+\\+|--)\\s*${m}\\b|\\b${m}\\s*(?:\\+\\+|--)`).test(p),P=md(p,m),w=c.indexOf("="),M=w>=0?c.slice(w+1):"",A=new RegExp(g).test(M);l.push({name:m,fixable:!x&&!k&&!P&&!A})}return l}var Ss={meta:{docs:"Suggest 'const' for variables that are never reassigned (heuristic)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Xe(e);for(let r=0;r<s.length;r++){if(i[r])continue;let o=s[r],l=Bo(o,e);if(!l)continue;for(let{name:a,fixable:c}of l){if(!c)continue;let u=o.search(new RegExp(`\\b${a.replace(/\$/g,"\\$")}\\b`)),f=u!==-1?u:o.indexOf(a);t.push({filePath:n.filePath,line:r+1,column:Math.max(1,f+1),ruleId:"prefer-const",message:`'${a}' is never reassigned. Use 'const' instead`,severity:"error",help:`Change 'let ${a}' to 'const ${a}' since the variable is never reassigned. This makes your code more predictable and prevents accidental mutations`})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=Xe(e),s=new Set,i=/(?:eslint|pickier)-disable-next-line\b([^*\n]*)/;for(let o=0;o<n.length;o++){let l=n[o].match(i);if(!l)continue;let a=l[1].trim();if(a===""||/\bprefer-const\b/.test(a))s.add(o+2)}let r=!1;for(let o=0;o<n.length;o++){if(s.has(o+1))continue;if(t[o])continue;let l=n[o];if(!/^\s*let\b/.test(l))continue;let a=Bo(l,e);if(!a||a.length===0)continue;if(!a.every((u)=>u.fixable))continue;let c=l.replace(/^(\s*)let(\s+)/,"$1const$2");if(c!==l)n[o]=c,r=!0}return r?n.join(`
79
+ `):e}};var jo={meta:{docs:"Prefer object spread ({...obj}) over Object.assign() for object composition"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s*\/\//.test(r))continue;let o=r.indexOf("//"),l=o>=0?r.slice(0,o):r,a=l.matchAll(/\bObject\.assign\s*\(/g);for(let c of a){let u=c.index,f=l.slice(0,u),m=(f.match(/'/g)||[]).length,h=(f.match(/"/g)||[]).length,d=(f.match(/`/g)||[]).length;if(m%2!==0||h%2!==0||d%2!==0)continue;let p=u+13,y=l.slice(p),g=-1,x=1,k=0,P=0,w=null,M=!1;for(let O=1;O<y.length;O++){let E=y[O];if(M){M=!1;continue}if(E==="\\"&&w){M=!0;continue}if(!w){if(E==="'")w="single";else if(E==='"')w="double";else if(E==="`")w="template";else if(E==="(")x++;else if(E===")"){if(x--,x===0)break}else if(E==="{")k++;else if(E==="}")k--;else if(E==="[")P++;else if(E==="]")P--;else if(E===","&&x===1&&k===0&&P===0){g=O;break}}else if(w==="single"&&E==="'"||w==="double"&&E==='"'||w==="template"&&E==="`")w=null}if(g===-1)continue;let A=y.slice(1,g).trim();if(A==="{}")t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"prefer-object-spread",message:"Prefer object spread over Object.assign",severity:"error",help:"Use object spread syntax: {...obj} instead of Object.assign({}, obj)"});else if(A==="{}"||/^\{.*\}$/.test(A))t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"prefer-object-spread",message:"Prefer object spread over Object.assign for object literals",severity:"error",help:"Use object spread syntax: {...obj1, ...obj2}"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s];i=i.replace(/\bObject\.assign\s*\(\s*\{\}\s*,\s*([^)]+)\)/g,(r,o)=>`{${o.split(",").map((a)=>a.trim()).map((a)=>`...${a}`).join(", ")}}`),t.push(i)}return t.join(`
80
+ `)}};function hd(e,n){let t=!1,s=!1,i=!1;for(let r=0;r<n;r++){let o=e[r];if(o==="\\"){r++;continue}if(o==="'"&&!s&&!i)t=!t;else if(o==='"'&&!t&&!i)s=!s;else if(o==="`"&&!t&&!s)i=!i}return t||s||i}var Es={meta:{docs:"Prefer template literals over string concatenation",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(o.startsWith("//")||o.startsWith("/*")||o.startsWith("*")||o.startsWith("import"))continue;let l=/(['"`][^'"`]*['"`])\s*\+\s*([a-z_$][\w$]*)/i,a=/([a-z_$][\w$]*)\s*\+\s*(['"`][^'"`]*['"`])/i,c=o.match(l)||o.match(a);if(c){let u=r.indexOf("//"),f=r.indexOf(c[0]);if(u>=0&&f>u)continue;if(hd(r,f))continue;let m=!!o.match(a),h=!!o.match(l);if(m&&!h){if(o.slice(o.indexOf(c[0])+c[0].length).startsWith("."))continue}t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"general/prefer-template",message:"Unexpected string concatenation. Use template literals instead",severity:"warning",help:"Use template literals (backticks) instead of string concatenation. Example: `hello ${name}!` instead of 'hello ' + name + '!'"})}}return t}};var Uo={name:"general",rules:{"array-callback-return":b(Rn),"constructor-super":b(kn),"for-direction":b($n),"getter-return":b(Pn),"no-async-promise-executor":b(In),"no-compare-neg-zero":b(vn),"no-cond-assign":b(Mn),"no-const-assign":b(Cn),"no-constant-condition":b(Sn),"no-constructor-return":b(_o),"no-dupe-class-members":b(En),"no-dupe-keys":b(Ot),"no-duplicate-case":b(Ln),"no-empty-pattern":b(Tn),"no-fallthrough":b(An),"no-irregular-whitespace":b(Do),"no-loss-of-precision":b(On),"no-new":b(Fo),"no-regex-spaces":b(No),"no-promise-executor-return":b(_n),"no-redeclare":b(Dn),"no-self-assign":b(_t),"no-self-compare":b(Fn),"no-sparse-arrays":b(Nn),"no-undef":b(Wn),"no-unsafe-negation":b(jn),"no-unreachable":b(Bn),"no-unused-vars":b(Ye),"no-useless-catch":b(Un),"prefer-const":b(Ss),"prefer-object-spread":b(jo),"prefer-template":b(Es),"use-isnan":b(zn),"valid-typeof":b(qn)}};var Nt={npm:"registry.npmjs.org",yarn:"registry.yarnpkg.com",verdaccio:"registry.verdaccio.org"};function zo(e){let n=e.split("/").pop()||"";if(n==="package-lock.json")return"npm";if(n==="yarn.lock")return"yarn";if(n==="bun.lockb"||n==="bun.lock")return"bun";return null}function Ne(e,n){let t=zo(n);if(!t)return!1;if(t==="npm")try{let s=JSON.parse(e);return"lockfileVersion"in s||"dependencies"in s||"packages"in s}catch{return!1}if(t==="yarn")return e.startsWith("#")||e.includes("__metadata:")||e.includes('resolved "');if(t==="bun")try{let s=JSON.parse(e);return"lockfileVersion"in s||"packages"in s}catch{return!1}return!1}function dd(e){let n=new Map,t=JSON.parse(e);if((t.lockfileVersion||1)>=2&&t.packages)for(let[i,r]of Object.entries(t.packages)){if(!i||i==="")continue;let o=i.replace(/^node_modules\//,"").replace(/\/node_modules\//g,"/"),l=o.split("/node_modules/").pop()||o;n.set(i,{name:l,version:r.version||"",resolved:r.resolved,integrity:r.integrity})}else if(t.dependencies)qo(t.dependencies,n,"");return{type:"npm",packages:n}}function qo(e,n,t){for(let[s,i]of Object.entries(e)){let r=t?`${t}/${s}`:s;if(n.set(r,{name:s,version:i.version||"",resolved:i.resolved,integrity:i.integrity}),i.dependencies)qo(i.dependencies,n,r)}}function pd(e){let n=new Map,t=e.includes("__metadata:"),s=t?"yarn-berry":"yarn",i=e.split(`
81
+ `),r="",o={};for(let l of i){if(l.startsWith("#")||l.trim()==="")continue;if(!l.startsWith(" ")&&l.includes("@")&&l.endsWith(":")){if(r&&(o.resolved||o.integrity))n.set(r,o);if(r=l.slice(0,-1).trim(),r.startsWith('"')&&r.endsWith('"'))r=r.slice(1,-1);let a=r.match(/^(@?[^@]+)@/);o={name:a?a[1]:r.split("@")[0],version:""}}else if(l.startsWith(" ")||l.startsWith("\t")){let a=l.trim();if(a.startsWith("version")){let c=a.match(/version[:\s]+"?([^"]+)"?/);if(c)o.version=c[1]}else if(a.startsWith("resolved")){let c=a.match(/resolved[:\s]+"?([^"]+)"?/);if(c)o.resolved=c[1]}else if(a.startsWith("resolution:")&&t){let c=a.match(/resolution[:\s]+"?([^"]+)"?/);if(c)o.resolved=c[1]}else if(a.startsWith("integrity")||a.startsWith("checksum")){let c=a.match(/(integrity|checksum)[:\s]+"?([^"]+)"?/);if(c)o.integrity=c[2]}}}if(r&&(o.resolved||o.integrity))n.set(r,o);return{type:s,packages:n}}function gd(e){let n=new Map,t=JSON.parse(e);if(t.packages)for(let[s,i]of Object.entries(t.packages)){if(!s||s==="")continue;if(Array.isArray(i)){let[r,o,l,a]=i,c=s,u="";if(typeof r==="string"&&r.includes("@")){let f=r.lastIndexOf("@");if(f>0)c=r.substring(0,f),u=r.substring(f+1)}n.set(s,{name:c,version:u,resolved:o||void 0,integrity:a||void 0})}else if(typeof i==="object")n.set(s,{name:i.name||s.split("@")[0],version:i.version||"",resolved:i.resolved,integrity:i.integrity||i.hash})}return{type:"bun",packages:n}}function We(e,n){let t=zo(n);if(!t)return null;try{switch(t){case"npm":return dd(e);case"yarn":return pd(e);case"bun":return gd(e);default:return null}}catch{return null}}function Ko(e){try{return new URL(e).hostname}catch{return null}}function Ls(e){try{return new URL(e).protocol}catch{return null}}function Vo(e){try{let t=new URL(e).pathname,s=t.indexOf("/-/");if(s===-1)return null;let i=t.substring(1,s);if(i.startsWith("@"))return i;return i}catch{return null}}function Ho(e){if(!e)return null;let n=e.match(/^(sha\d+)-/);return n?n[1]:null}function Zo(e){return e.map((n)=>{let t=n.toLowerCase();return Nt[t]||n})}var Jo={meta:{docs:"Ensure all packages are from allowed registry hosts",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let i=n.options||{},r=i.allowedHosts||["npm","yarn"],o=i.emptyHostname!==!1,l=Zo(r),a=e.split(`
82
+ `);for(let[c,u]of s.packages){if(!u.resolved){if(!o){let m=Go(a,c);t.push({filePath:n.filePath,line:m,column:1,ruleId:"lockfile/validate-host",message:`Package "${u.name}" has no resolved URL`,severity:"error",help:"All packages should have a resolved URL from an allowed registry."})}continue}let f=Ko(u.resolved);if(!f)continue;if(!l.includes(f)){let m=Go(a,c),h=r.map((d)=>Nt[d.toLowerCase()]||d).join(", ");t.push({filePath:n.filePath,line:m,column:1,ruleId:"lockfile/validate-host",message:`Invalid host for package "${u.name}": expected one of [${h}], got "${f}"`,severity:"error",help:`Package is resolving from an unauthorized registry. This could indicate a supply chain attack. Allowed hosts: ${h}`})}}return t}};function Go(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var Yo={meta:{docs:"Ensure all packages use HTTPS protocol",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let i=e.split(`
83
+ `);for(let[r,o]of s.packages){if(!o.resolved)continue;let l=Ls(o.resolved);if(!l)continue;if(l!=="https:"){let a=yd(i,r);t.push({filePath:n.filePath,line:a,column:1,ruleId:"lockfile/validate-https",message:`Package "${o.name}" uses insecure protocol: "${l}" instead of "https:"`,severity:"error",help:"All packages should be downloaded over HTTPS to prevent man-in-the-middle attacks."})}}return t}};function yd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var Xo={meta:{docs:"Ensure all packages use strong integrity hashes (SHA512)",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let i=n.options||{},r=i.requiredAlgorithm||"sha512",o=new Set(i.exclude||[]),l={sha1:1,sha256:2,sha384:3,sha512:4},a=l[r]||4,c=e.split(`
84
+ `);for(let[u,f]of s.packages){if(o.has(f.name))continue;if(!f.integrity)continue;let m=Ho(f.integrity);if(!m)continue;if((l[m.toLowerCase()]||0)<a){let d=bd(c,u);t.push({filePath:n.filePath,line:d,column:1,ruleId:"lockfile/validate-integrity",message:`Package "${f.name}" uses weak hash algorithm: "${m}" (required: ${r})`,severity:"error",help:`Weak hash algorithms are susceptible to collision attacks. Upgrade to ${r} by regenerating your lockfile with a recent package manager.`})}}return t}};function bd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var Qo={meta:{docs:"Ensure package names match their resolved URLs",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let r=(n.options||{}).aliases||{},o=Object.values(Nt),l=e.split(`
85
+ `);for(let[a,c]of s.packages){if(!c.resolved)continue;let u=!1;try{let d=new URL(c.resolved);u=o.includes(d.hostname)}catch{continue}if(!u)continue;let f=Vo(c.resolved);if(!f)continue;let m=c.name,h=r[m]||m;if(f!==h){let d=xd(l,a);t.push({filePath:n.filePath,line:d,column:1,ruleId:"lockfile/validate-package-names",message:`Package name mismatch: "${m}" resolves to "${f}"`,severity:"error",help:`This could indicate a package substitution attack. The lockfile entry is for "${m}" but the resolved URL points to "${f}".`})}}return t}};function xd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var el={meta:{docs:"Ensure all packages use allowed URL schemes",recommended:!0},check(e,n){let t=[];if(!Ne(e,n.filePath))return t;let s=We(e,n.filePath);if(!s)return t;let o=((n.options||{}).allowedSchemes||["https:","git+https:","git+ssh:"]).map((a)=>a.endsWith(":")?a:`${a}:`),l=e.split(`
86
+ `);for(let[a,c]of s.packages){if(!c.resolved)continue;let u=Ls(c.resolved);if(!u)continue;if(!o.includes(u)){let f=wd(l,a);t.push({filePath:n.filePath,line:f,column:1,ruleId:"lockfile/validate-scheme",message:`Package "${c.name}" uses disallowed URL scheme: "${u}"`,severity:"error",help:`Only the following URL schemes are allowed: ${o.join(", ")}. Using "${u}" could be a security risk.`})}}return t}};function wd(e,n){for(let t=0;t<e.length;t++)if(e[t].includes(n)||e[t].includes(`"${n}"`))return t+1;return 1}var tl={name:"lockfile",rules:{"validate-host":Jo,"validate-https":Yo,"validate-integrity":Xo,"validate-package-names":Qo,"validate-scheme":el}};var nl={meta:{docs:"Fenced code blocks should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim()))if(!i){let a=r>0?s[r-1]:"";if(r>0&&a.trim().length>0){if(!/^:::/.test(a.trim()))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}i=!0}else{let a=r+1<s.length?s[r+1]:"";if(r+1<s.length&&a.trim().length>0){if(!/^:::/.test(a.trim()))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-fences",message:"Fenced code blocks should be surrounded by blank lines",severity:"error"})}i=!1}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[],s=!1;for(let i=0;i<n.length;i++){let r=n[i],o=i>0?n[i-1]:"",l=/^(?:`{3,}|~{3,})/.test(r.trim());if(l)if(!s){if(i>0&&o.trim().length>0&&!/^:::/.test(o.trim())&&t.length>0)t.push("");s=!0}else s=!1;if(t.push(r),l&&!s&&i+1<n.length){let a=n[i+1];if(a.trim().length>0&&!/^:::/.test(a.trim()))t.push("")}}return t.join(`
87
+ `)}};var sl={meta:{docs:"Headings should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=r>0?s[r-1]:"",a=r+1<s.length?s[r+1]:"";if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let c=/^#{1,6}\s/.test(o),u=r+1<s.length&&/^(?:=+|-+)\s*$/.test(a)&&o.trim().length>0;if(c){if(r>0&&l.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});if(r+1<s.length&&a.trim().length>0&&!/^#{1,6}\s/.test(a))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}if(u){if(r>0&&l.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"});let f=r+2<s.length?s[r+2]:"";if(r+2<s.length&&f.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/blanks-around-headings",message:"Headings should be surrounded by blank lines",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[],s=!1;for(let i=0;i<n.length;i++){let r=n[i],o=i>0?n[i-1]:"",l=i+1<n.length?n[i+1]:"";if(/^(?:`{3,}|~{3,})/.test(r.trim())){s=!s,t.push(r);continue}if(s){t.push(r);continue}let a=/^#{1,6}\s/.test(r),c=i+1<n.length&&/^(?:=+|-+)\s*$/.test(l)&&r.trim().length>0;if(a||c){if(i>0&&o.trim().length>0&&t.length>0)t.push("")}if(t.push(r),a){if(i+1<n.length&&l.trim().length>0&&!/^#{1,6}\s/.test(l))t.push("")}if(i>0&&/^(?:=+|-+)\s*$/.test(r)&&n[i-1].trim().length>0){if((i+1<n.length?n[i+1]:"").trim().length>0)t.push("")}}return t.join(`
88
+ `)}};var il={meta:{docs:"Lists should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1;for(let o=0;o<s.length;o++){let l=s[o],a=o>0?s[o-1]:"";if(/^(?:`{3,}|~{3,})/.test(l.trim())){if(r=!r,i)i=!1;continue}if(r)continue;let c=/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(l),u=i&&!c&&l.trim().length>0&&/^\s+/.test(l);if(c&&!i){if(i=!0,o>0&&a.trim().length>0)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}else if(!c&&!u&&i&&l.trim().length>0){if(i=!1,/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(a))t.push({filePath:n.filePath,line:o,column:1,ruleId:"markdown/blanks-around-lists",message:"Lists should be surrounded by blank lines",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[],s=!1,i=!1,r=(o)=>/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(o);for(let o=0;o<n.length;o++){let l=n[o],a=o>0?n[o-1]:"";if(/^(?:`{3,}|~{3,})/.test(l.trim())){i=!i,s=!1,t.push(l);continue}if(i){t.push(l);continue}let c=r(l),u=l.trim().length===0,f=s&&!c&&!u&&/^\s/.test(l);if(c&&!s){if(o>0&&a.trim().length>0&&t.length>0)t.push("");s=!0}else if(!c&&!f&&!u&&s){if(s=!1,t.length>0)t.push("")}else if(u){let m=o+1<n.length?n[o+1]:"",h=r(m),d=/^\s+\S/.test(m);if(!h&&!d&&s)s=!1}t.push(l)}return t.join(`
89
+ `)}};function j(e){let n=new Set,t=null,s=0,i=!1,r=!1;for(let o=0;o<e.length;o++){let l=e[o],a=l.trim();if(t===null){let m=a.match(/^(`{3,}|~{3,})(.*)$/);if(m){let h=m[1],d=m[2],p=h[0];if(p==="`"&&d.includes("`"));else{t=p,s=h.length,n.add(o),i=!1,r=!1;continue}}}else{n.add(o);let m=a.match(/^(`{3,}|~{3,})\s*$/);if(m&&m[1][0]===t&&m[1].length>=s)t=null,s=0;continue}let c=l.length-l.trimStart().length,u=/^\t/.test(l);if((c>=4||u)&&a.length>0){if(r||i||o===0)n.add(o),r=!0;i=r;continue}if(a.length===0){if(r)n.add(o),i=!0;else i=!0;continue}r=!1,i=!1}return n}function rl(e,n,t){let s=0,i=0;while(s<e.length){if(e[s]!=="`"){s++;continue}let r=0;while(e[s+r]==="`")r++;let o=s+r,l=-1;while(o<e.length)if(e[o]==="`"){let a=0;while(e[o+a]==="`")a++;if(a===r){l=o;break}o+=a}else o++;if(l===-1){s+=r;continue}if(i<s)n(e.slice(i,s));t(e.slice(s,l+r)),s=l+r,i=s}if(i<e.length)n(e.slice(i))}function wt(e,n){let t="";return rl(e,(s)=>{t+=n(s)},(s)=>{t+=s}),t}function Qe(e){let n="";return rl(e,(t)=>{n+=t},(t)=>{n+=" ".repeat(t.length)}),n}function ol(e){let n=j(e),t=[],s=0;for(let i=0;i<e.length;i++){let r=e[i];if(n.has(i)||r.trim()===""){s=0,t.push(r);continue}if(s===0){let a=Qe(r),c=Rd(a);if(!c){t.push(a);continue}s=c.length,t.push(a.slice(0,c.index)+" ".repeat(a.length-c.index));continue}let o=new RegExp(`(?<!\`)\`{${s}}(?!\`)`).exec(r);if(!o){t.push(" ".repeat(r.length));continue}let l=o.index+o[0].length;s=0,t.push(" ".repeat(l)+Qe(r.slice(l)))}return t}function Rd(e){let n=/(?<!`)(`+)(?!`)(?=[^`]*$)/.exec(e);return n?{index:n.index,length:n[1].length}:null}function it(e){let n=new Set,t=j(e);for(let s=0;s<e.length;s++){if(t.has(s))continue;let i=e[s];if(!kd(i))continue;if(s>0&&!t.has(s-1)&&/\|/.test(e[s-1])&&e[s-1].trim().length>0)n.add(s-1);n.add(s);for(let r=s+1;r<e.length;r++){if(t.has(r))break;let o=e[r];if(o.trim().length===0||!/\|/.test(o))break;n.add(r)}}return n}function kd(e){let n=e.trim();if(!n.includes("|"))return!1;if(!/^[|\s:-]+$/.test(n))return!1;if(!/-{3,}/.test(n))return!1;return!0}var ll={meta:{docs:"Tables should be surrounded by blank lines"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=it(s);for(let l=0;l<s.length;l++){let a=s[l],c=l>0?s[l-1]:"";if(/^(?:`{3,}|~{3,})/.test(a.trim())){if(r=!r,i)i=!1;continue}if(r)continue;let u=o.has(l)&&/\|/.test(a)&&a.trim().length>0;if(u&&!i){if(i=!0,l>0&&c.trim().length>0)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}else if(!u&&i){if(i=!1,a.trim().length>0)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/blanks-around-tables",message:"Tables should be surrounded by blank lines",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=it(n),i=[],r=!1;for(let l=0;l<n.length;l++){let a=n[l];if(t.has(l)){i.push(a);continue}let c=s.has(l)&&/\|/.test(a)&&a.trim().length>0;if(c&&!r){let u=i.length-1;if(u>=0&&i[u].trim().length>0)i.push("");r=!0,i.push(a);continue}if(!c&&r){if(r=!1,a.trim().length>0)i.push("")}i.push(a)}let o=i.join(`
90
+ `);return o!==e?o:e}};var al={meta:{docs:"Code block style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null,l=!1;for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c)){if(l=!l,r==="indented")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Expected indented code block style",severity:"error"});else if(r==="consistent"){if(o===null)o="fenced";else if(o==="indented")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}continue}if(l)continue;if(/^(?: {4}|\t)/.test(c)&&c.trim().length>0){let h=(a>0?s[a-1]:"").trim().length===0||a===0;if(h&&r==="fenced")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Expected fenced code block style",severity:"error"});else if(h&&r==="consistent"){if(o===null)o="indented";else if(o==="fenced")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-block-style",message:"Code block style should be consistent throughout document",severity:"error"})}}}return t}};function cl(e){let n=new Set,t=null,s=0;for(let i=0;i<e.length;i++){let r=e[i].trim();if(t===null){let o=r.match(/^(`{3,}|~{3,})(.*)$/);if(o){let l=o[1][0];if(l==="`"&&o[2].includes("`"))continue;t=l,s=o[1].length,n.add(i)}}else{let o=r.match(/^(`{3,}|~{3,})\s*$/);if(o&&o[1][0]===t&&o[1].length>=s)n.add(i),t=null,s=0}}return n}var ul={meta:{docs:"Code fence style should be consistent (backtick or tilde)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=cl(s),o=(n.options||{}).style||"consistent",l=null;for(let a of i){let c=s[a],f=/^`{3,}/.test(c.trim())?"backtick":"tilde";if(o==="backtick"||o==="tilde"){if(f!==o)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-fence-style",message:o==="tilde"?"Expected tilde (~~~) code fence":"Expected backtick (```) code fence",severity:"error"})}else if(o==="consistent"){if(l===null)l=f;else if(l!==f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/code-fence-style",message:"Code fence style should be consistent throughout document",severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=cl(i),o="backtick";if(s==="backtick"||s==="tilde")o=s;else for(let u of r){o=/^`{3,}/.test(i[u].trim())?"backtick":"tilde";break}let l=o==="backtick"?"`":"~",a=o==="backtick"?/^(\s*)(~{3,})(.*)$/:/^(\s*)(`{3,})(.*)$/;return i.map((u,f)=>{if(!r.has(f))return u;return u.replace(a,(m,h,d,p)=>`${h}${l.repeat(d.length)}${p}`)}).join(`
91
+ `)}};var fl={meta:{docs:"Commands in code blocks should not be prefixed with $ unless showing output"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=-1;for(let o=0;o<s.length;o++){let l=s[o];if(/^(?:`{3,}|~{3,})/.test(l)){if(!i)i=!0,r=o;else i=!1;continue}if(i&&/^\$\s+/.test(l.trim())){let a=!0,c=!1;for(let u=r+1;u<o;u++){let f=s[u].trim();if(f.length>0){if(c=!0,!f.startsWith("$")){a=!1;break}}}if(a&&c)t.push({filePath:n.filePath,line:o+1,column:l.indexOf("$")+1,ruleId:"markdown/commands-show-output",message:"Dollar signs used before commands without showing output",severity:"warning"})}}return t}};var ml={meta:{docs:"Link text should be meaningful and descriptive"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=["click here","here","link","read more","more","this"],r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(/^(?:`{3,}|~{3,})/.test(l.trim())){r=!r;continue}if(r)continue;let c=l.replace(/``[^`]+``/g,(u)=>" ".repeat(u.length)).replace(/`[^`]+`/g,(u)=>" ".repeat(u.length)).matchAll(/\[([^\]]+)\]\([^)]+\)/g);for(let u of c){let f=u[1].toLowerCase().trim();if(i.includes(f)){let m=u.index+1;t.push({filePath:n.filePath,line:o+1,column:m,ruleId:"markdown/descriptive-link-text",message:`Link text '${u[1]}' is not descriptive`,severity:"warning"})}}}return t}};var Si="(?<!\\*)\\*(?!\\*)(?!\\s)([^*]*[^*\\s])\\*(?!\\*)",$d=new RegExp(Si),Ei="(?<![A-Za-z0-9_])_(?!_)([^_]+)_(?![A-Za-z0-9_])",Pd=new RegExp(Ei),hl={meta:{docs:"Emphasis style should be consistent (asterisk or underscore)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null,l=j(s),a=ol(s);for(let c=0;c<s.length;c++){let u=s[c];if(l.has(c))continue;let f=a[c]??Qe(u),m=f.matchAll(new RegExp(Si,"g"));for(let d of m)if(r==="underscore")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Expected underscore (_) for emphasis",severity:"error"});else if(r==="consistent"){if(o===null)o="asterisk";else if(o==="underscore")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}let h=f.matchAll(new RegExp(Ei,"g"));for(let d of h)if(r==="asterisk")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Expected asterisk (*) for emphasis",severity:"error"});else if(r==="consistent"){if(o===null)o="underscore";else if(o==="asterisk")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/emphasis-style",message:"Emphasis style should be consistent throughout document",severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=j(i),o="asterisk";if(s==="asterisk")o="asterisk";else if(s==="underscore")o="underscore";else if(s==="consistent"){let a=null,c=null;for(let f=0;f<i.length;f++){if(r.has(f))continue;let m=Qe(i[f]);if(a===null){let h=m.match($d);if(h)a={line:f,col:h.index}}if(c===null){let h=m.match(Pd);if(h)c={line:f,col:h.index}}if(a&&c)break}if(a&&(!c||((f,m)=>f.line!==m.line?f.line-m.line:f.col-m.col)(a,c)<0))o="asterisk";else if(c)o="underscore"}let l=!1;for(let a=0;a<i.length;a++){if(r.has(a))continue;let c=wt(i[a],(u)=>o==="asterisk"?u.replace(new RegExp(Ei,"g"),"*$1*"):u.replace(new RegExp(Si,"g"),"_$1_"));if(c!==i[a])i[a]=c,l=!0}return l?i.join(`
92
+ `):e}};var dl={meta:{docs:"Fenced code blocks should have a language specified"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++)if(s[i].match(/^(?:`{3,}|~{3,})\s*$/)){let l=!0;for(let a=i-1;a>=0;a--)if(/^(?:`{3,}|~{3,})/.test(s[a])){l=!1;break}if(l)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"markdown/fenced-code-language",message:"Fenced code blocks should have a language specified",severity:"error"})}return t}};var pl={meta:{docs:"First line in a file should be a top-level heading"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=-1;for(let a=0;a<s.length;a++)if(s[a].trim().length>0){i=a;break}if(i===-1)return t;let r=s[i],o=/^#\s/.test(r),l=i+1<s.length&&/^=+\s*$/.test(s[i+1]);if(!o&&!l)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"markdown/first-line-heading",message:"First line in a file should be a top-level heading",severity:"warning"});return t}};var gl={meta:{docs:"Heading levels should only increment by one level at a time"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),r=0;for(let o=0;o<s.length;o++){if(i.has(o))continue;let a=s[o].match(/^(#{1,6})\s/);if(a){let c=a[1].length;if(r>0&&c>r+1)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/heading-increment",message:`Heading level should not skip from h${r} to h${c}`,severity:"error"});r=c}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=0,i=!1;for(let r=0;r<n.length;r++){if(t.has(r))continue;let l=n[r].match(/^(#{1,6})(\s.*)$/);if(!l)continue;let a=l[1].length,c=s===0?a:Math.min(a,s+1);if(c!==a)n[r]="#".repeat(c)+l[2],i=!0;s=c}return i?n.join(`
93
+ `):e}};var yl={meta:{docs:"Headings must start at the beginning of the line"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;if(o.match(/^(\s+)(#{1,6}\s)/))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/heading-start-left",message:"Headings must start at the beginning of the line",severity:"error"})}return t},fix:(e)=>e.split(/\r?\n/).map((s)=>s.replace(/^(\s+)(#{1,6}\s)/,"$2")).join(`
94
+ `)};var bl={meta:{docs:"Heading style should be consistent (atx, setext, or consistent)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null,l=j(s);for(let a=0;a<s.length;a++){if(l.has(a))continue;let c=s[a],u=a+1<s.length?s[a+1]:"",f=c.match(/^#{1,6}\s/),m=u.match(/^(?:=+|-+)\s*$/)&&c.trim().length>0&&!l.has(a+1);if(f){if(r==="setext")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Expected setext style heading",severity:"error"});else if(r==="consistent"){if(o===null)o="atx";else if(o==="setext")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}else if(m){if(r==="atx")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Expected atx style heading",severity:"error"});else if(r==="consistent"){if(o===null)o="setext";else if(o==="atx")t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/heading-style",message:"Heading style should be consistent throughout document",severity:"error"})}}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=j(i),o=s==="consistent"?null:s;if(o===null)for(let c=0;c<i.length;c++){if(r.has(c))continue;let u=i[c],f=c+1<i.length?i[c+1]:"";if(/^#{1,6}\s/.test(u)){o="atx";break}if(/^(?:=+|-+)\s*$/.test(f)&&u.trim().length>0&&!r.has(c+1)){o="setext";break}}if(o===null)return e;let l=[],a=!1;for(let c=0;c<i.length;c++){let u=i[c];if(r.has(c)){l.push(u);continue}let f=c+1<i.length?i[c+1]:"";if(o==="atx"){let m=/^=+\s*$/.test(f),h=/^-+\s*$/.test(f),d=r.has(c+1);if((m||h)&&!d&&u.trim().length>0&&!/^#{1,6}\s/.test(u)){let p=m?"#":"##";l.push(`${p} ${u.trim()}`),c++,a=!0;continue}}if(o==="setext"){let m=u.match(/^(#{1,2})\s+(.+?)\s*#*\s*$/);if(m){let h=m[1].length,d=m[2],p=(h===1?"=":"-").repeat(Math.max(3,d.length));l.push(d),l.push(p),a=!0;continue}}l.push(u)}return a?l.join(`
95
+ `):e}};var xl={meta:{docs:"Horizontal rule style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"consistent",o=null;for(let l=0;l<s.length;l++){let a=s[l].trim();if(a.match(/^([-*_])\1{2,}$/)){let u=a;if(r!=="consistent"&&a!==r)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/hr-style",message:`Expected horizontal rule style '${r}'`,severity:"error"});else if(r==="consistent"){if(o===null)o=u;else if(o!==u)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/hr-style",message:"Horizontal rule style should be consistent throughout document",severity:"error"})}}}return t}};var wl={meta:{docs:"Lines should not exceed a specified length"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.line_length||80,o=i.code_blocks!==!1,l=i.tables!==!1,a=i.headings!==!1,c=!1;for(let u=0;u<s.length;u++){let f=s[u];if(/^(?:`{3,}|~{3,})/.test(f)){c=!c;continue}if(c&&!o)continue;if(!l&&/\|/.test(f))continue;if(!a&&/^#{1,6}\s/.test(f))continue;if(f.length>r)t.push({filePath:n.filePath,line:u+1,column:r+1,ruleId:"markdown/line-length",message:`Line length exceeds ${r} characters (${f.length} characters)`,severity:"warning"})}return t}};function Id(e){return e.toLowerCase().replace(/[^\w\s-]/g,"").replace(/\s/g,"-")}var Rl={meta:{docs:"Link fragments should reference valid headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),r=new Set;for(let o=0;o<s.length;o++){if(i.has(o))continue;let a=s[o].match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(a){let c=a[1].trim();r.add(Id(c))}}for(let o=0;o<s.length;o++){if(i.has(o))continue;let a=s[o].matchAll(/\[[^\]]+\]\(#([^)]+)\)/g);for(let c of a){let u=c[1];if(!r.has(u)){let f=c.index+1;t.push({filePath:n.filePath,line:o+1,column:f,ruleId:"markdown/link-fragments",message:`Link fragment '#${u}' does not match any heading`,severity:"error"})}}}return t}};var kl={meta:{docs:"Link and image reference definitions should be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),r=new Map;for(let l=0;l<s.length;l++){if(i.has(l))continue;let c=s[l].match(/^\[([^\]]+)\]:\s*\S+/);if(c)r.set(c[1].toLowerCase(),l+1)}let o=new Set;for(let l=0;l<s.length;l++){if(i.has(l))continue;let a=s[l];if(a.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let c=a.matchAll(/\[([^\]]+)\](?:\[([^\]]+)\])?(?!\()/g);for(let u of c){let f=(u[2]||u[1]).toLowerCase();o.add(f)}}for(let[l,a]of r)if(!o.has(l))t.push({filePath:n.filePath,line:a,column:1,ruleId:"markdown/link-image-reference-definitions",message:`Unused reference definition '[${l}]'`,severity:"warning"});return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=new Map;for(let o=0;o<n.length;o++){if(t.has(o))continue;let l=n[o].match(/^\s*\[([^\]]+)\]:\s*\S+/);if(l)s.set(o,l[1].toLowerCase())}if(s.size===0)return e;let i=new Set;for(let o=0;o<n.length;o++){if(t.has(o))continue;if(s.has(o))continue;let a=n[o].matchAll(/\[([^\]]+)\](?:\[([^\]]*)\])?(?!\()/g);for(let c of a){let u=(c[2]&&c[2].length>0?c[2]:c[1]).toLowerCase();i.add(u)}}let r=new Set;for(let[o,l]of s)if(!i.has(l))r.add(o);if(r.size===0)return e;return n.filter((o,l)=>!r.has(l)).join(`
96
+ `)}};var $l={meta:{docs:"Link and image style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),o=(n.options||{}).style||"consistent",l=o==="consistent"?null:o;if(l===null){let c=0,u=0,f=!1;for(let m=0;m<s.length;m++){if(i.has(m))continue;let h=s[m];if(h.includes("<!--"))f=!0;if(h.includes("-->")){f=!1;continue}if(f)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(h))continue;let d=Li(h);c+=(d.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,u+=(d.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}l=u>c?"reference":"inline"}let a=!1;for(let c=0;c<s.length;c++){if(i.has(c))continue;let u=s[c];if(u.includes("<!--"))a=!0;if(u.includes("-->")){a=!1;continue}if(a)continue;if(u.match(/^\[(?:[^\]]+)\]:\s*\S+/))continue;let f=Li(u),m=f.matchAll(/\[[^\]]+\]\([^)]+\)/g);for(let d of m)if(l==="reference")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/link-image-style",message:o==="consistent"?"Link style should be consistent throughout document":"Expected reference style link",severity:o==="consistent"?"warning":"error"});let h=f.matchAll(/\[[^\]]+\]\[(?:[^\]]+)\]/g);for(let d of h)if(l==="inline")t.push({filePath:n.filePath,line:c+1,column:d.index+1,ruleId:"markdown/link-image-style",message:o==="consistent"?"Link style should be consistent throughout document":"Expected inline style link",severity:o==="consistent"?"warning":"error"})}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=j(i),o=new Map;for(let c=0;c<i.length;c++){if(r.has(c))continue;let u=i[c].match(/^\s*\[([^\]]+)\]:\s*(\S+)(?:\s+(?:"([^"]*)"|'([^']*)'|\(([^)]*)\)))?\s*$/);if(u){let f=u[1].toLowerCase(),m=u[2],h=u[3]??u[4]??u[5];if(!o.has(f))o.set(f,{url:m,title:h})}}if(o.size===0)return e;let l=s==="reference"?"reference":"inline";if(s==="consistent"){let c=0,u=0;for(let f=0;f<i.length;f++){if(r.has(f))continue;let m=i[f];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(m))continue;let h=Li(m);c+=(h.match(/\[[^\]]+\]\([^)]+\)/g)||[]).length,u+=(h.match(/\[[^\]]+\]\[(?:[^\]]*)\]/g)||[]).length}l=u>c?"reference":"inline"}if(l!=="inline")return e;let a=!1;for(let c=0;c<i.length;c++){if(r.has(c))continue;let u=i[c];if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(u))continue;let f=u;for(let m=0;m<8;m++){let h=f.replace(/(!?)\[((?:[^[\]]|\[[^\]]*\]\([^)]*\))+)\]\[([^\]]*)\]/g,(d,p,y,g)=>{let x=(g.trim()===""?y:g).toLowerCase(),k=o.get(x);if(!k)return d;let P=k.title?` "${k.title}"`:"";return`${p}[${y}](${k.url}${P})`});if(h===f)break;f=h}if(f!==u)i[c]=f,a=!0}return a?i.join(`
97
+ `):e}};function Li(e){return e.replace(/(`+)([^`]+?)\1/g,(n)=>" ".repeat(n.length))}var Pl={meta:{docs:"List items at the same level should have consistent indentation"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map,r=!1;for(let o=0;o<s.length;o++){let l=s[o],a=l.match(/^(\s*)(?:[*\-+]|\d+\.)\s+/);if(a){r=!0;let c=a[1].length,u=Math.floor(c/2);if(i.has(u)){let f=i.get(u);if(c!==f)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/list-indent",message:`Inconsistent indentation for list items at the same level. Expected ${f} spaces, found ${c}`,severity:"error"})}else i.set(u,c)}else if(l.trim().length===0){if(r){let c=s.slice(o+1).find((u)=>u.trim().length>0);if(c&&!/^(?:\s*)(?:[*\-+]|\d+\.)\s+/.test(c))r=!1,i.clear()}}}return t}};var Il={meta:{docs:"Spaces after list markers should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.ul_single||1,o=i.ol_single||1;for(let l=0;l<s.length;l++){let a=s[l],c=a.match(/^(\s*)([*\-+])(\s+)/);if(c){let f=c[3].length;if(f!==r)t.push({filePath:n.filePath,line:l+1,column:c[1].length+2,ruleId:"markdown/list-marker-space",message:`Expected ${r} space${r!==1?"s":""} after list marker, found ${f}`,severity:"error"})}let u=a.match(/^(\s*)(\d+\.)(\s+)/);if(u){let f=u[3].length;if(f!==o)t.push({filePath:n.filePath,line:l+1,column:u[1].length+u[2].length+1,ruleId:"markdown/list-marker-space",message:`Expected ${o} space${o!==1?"s":""} after list marker, found ${f}`,severity:"error"})}}return t},fix:(e,n)=>{let t=n.options||{},s=t.ul_single||1,i=t.ol_single||1;return e.split(/\r?\n/).map((l)=>(l=l.replace(/^(\s*)([*\-+])\s+/,(a,c,u)=>`${c}${u}${" ".repeat(s)}`),l=l.replace(/^(\s*)(\d+\.)\s+/,(a,c,u)=>`${c}${u}${" ".repeat(i)}`),l)).join(`
98
+ `)}};var vl={meta:{docs:"Images should have alternate text"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let a=o.replace(/``[^`]+``/g,(c)=>" ".repeat(c.length)).replace(/`[^`]+`/g,(c)=>" ".repeat(c.length)).matchAll(/!\[\s*\]\([^)]+\)/g);for(let c of a){let u=c.index+1;t.push({filePath:n.filePath,line:r+1,column:u,ruleId:"markdown/no-alt-text",message:"Images should have alternate text (alt text)",severity:"error"})}}return t}};var Ml={meta:{docs:"Bare URLs should be wrapped in angle brackets"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(i.has(o))continue;if(l.includes("<!--"))r=!0;if(l.includes("-->")){r=!1;continue}if(r)continue;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(l))continue;let a=l.replace(/`[^`]+`/g,(f)=>" ".repeat(f.length)),c=/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,u=a.matchAll(c);for(let f of u)t.push({filePath:n.filePath,line:o+1,column:f.index+1,ruleId:"markdown/no-bare-urls",message:"Bare URL used. Wrap in angle brackets: <url>",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=!1;return n.map((r,o)=>{if(t.has(o))return r;if(r.includes("<!--"))s=!0;if(r.includes("-->"))return s=!1,r;if(s)return r;if(/^\[(?:[^\]]+)\]:\s*\S+/.test(r))return r;return r.replace(/(?<![<(="'])https?:\/\/[^\s<>`)\]"']+(?![>\])"'])/g,"<$&>")}).join(`
99
+ `)}};var Cl={meta:{docs:"Blank lines inside blockquotes should use the blockquote symbol"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=!1;for(let o=0;o<s.length;o++){let l=s[o],a=o+1<s.length?s[o+1]:"";if(/^(?:`{3,}|~{3,})/.test(l.trim())){r=!r,i=!1;continue}if(r)continue;let c=/^\s*>/.test(l),u=l.trim().length===0,f=/^\s*>/.test(a);if(c)i=!0;else if(u&&i&&f)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/no-blanks-blockquote",message:"Blank line inside blockquote should use blockquote symbol (>)",severity:"error"});else if(!c&&!u)i=!1}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1,s=!1,i=!1;for(let r=0;r<n.length;r++){let o=n[r],l=r+1<n.length?n[r+1]:"";if(/^(?:`{3,}|~{3,})/.test(o.trim())){s=!s,t=!1;continue}if(s)continue;let a=/^\s*>/.test(o),c=o.trim().length===0,u=/^\s*>/.test(l);if(a)t=!0;else if(c&&t&&u){let f=l.match(/^(\s*)>/),m=f?`${f[1]}>`:">";n[r]=m,i=!0}else if(!a&&!c)t=!1}return i?n.join(`
100
+ `):e}};var Sl={meta:{docs:"Multiple headings should not have the same content"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=Array.from({length:7},()=>new Map);for(let o=0;o<s.length;o++){let l=s[o];if(/^(?:`{3,}|~{3,})/.test(l.trim())){i=!i;continue}if(i)continue;if(/^\s*\[Compare changes\]\(/.test(l)){for(let m=3;m<=6;m++)r[m].clear();continue}let a=null,c=0,u=l.match(/^(#{1,6})\s+(.+?)(?:\s*#+\s*)?$/);if(u)c=u[1].length,a=u[2].trim();if(!a){let m=o+1<s.length?s[o+1]:"";if(/^(?:=+)\s*$/.test(m)&&l.trim().length>0)c=1,a=l.trim();else if(/^(?:-+)\s*$/.test(m)&&l.trim().length>0)c=2,a=l.trim()}if(!a||c===0)continue;for(let m=c+1;m<=6;m++)r[m].clear();let f=r[c];if(f.has(a))t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/no-duplicate-heading",message:`Duplicate heading "${a}" (first occurrence on line ${f.get(a)})`,severity:"error"});else f.set(a,o+1)}return t}};var vd=/[.!?:;,]\s*$/;function El(e,n,t){let s=e.match(/^\*\*([^*]+)\*\*\s*$/)||e.match(/^__([^_]+)__\s*$/),i=e.match(/^\*([^*]+)\*\s*$/)||e.match(/^_([^_]+)_\s*$/),r=s||i;if(!r)return null;if(n.trim().length!==0||t.trim().length!==0)return null;let o=r[1];if(vd.test(o))return null;if(o.trim().split(/\s+/).length>=7)return null;return o}var Ll={meta:{docs:"Emphasis should not be used for headings"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let o=s[r],l=r>0?s[r-1]:"",a=r+1<s.length?s[r+1]:"";if(El(o,l,a)===null)continue;t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"markdown/no-emphasis-as-heading",message:"Emphasis used instead of a heading",severity:"warning"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=2,i=!1;for(let r=0;r<n.length;r++){if(t.has(r))continue;let o=n[r],l=o.match(/^(#{1,6})\s/);if(l){s=l[1].length;continue}let a=r>0?n[r-1]:"",c=r+1<n.length?n[r+1]:"",u=El(o,a,c);if(u===null)continue;let f=Math.min(6,Math.max(2,s+1));n[r]=`${"#".repeat(f)} ${u.trim()}`,i=!0}return i?n.join(`
101
+ `):e}};var Tl={meta:{docs:"Links should not be empty"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let l=o.replace(/`[^`]+`/g,(u)=>"x".repeat(u.length)),a=l.matchAll(/\[[^\]]+\]\(\s*\)/g);for(let u of a){let f=u.index+1;t.push({filePath:n.filePath,line:r+1,column:f,ruleId:"markdown/no-empty-links",message:"Empty link URL",severity:"error"})}let c=l.matchAll(/\[\s*\]\([^)]+\)/g);for(let u of c){let f=u.index+1;t.push({filePath:n.filePath,line:r+1,column:f,ruleId:"markdown/no-empty-links",message:"Empty link text",severity:"error"})}}return t}};var Al={meta:{docs:"Spaces should be used instead of hard tabs"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r];if(/^(?:`{3,}|~{3,})/.test(o.trim())){i=!i;continue}if(i)continue;let l=o.indexOf("\t");if(l!==-1)t.push({filePath:n.filePath,line:r+1,column:l+1,ruleId:"markdown/no-hard-tabs",message:"Hard tabs should not be used",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=!1;return n.map((i)=>{if(/^(?:`{3,}|~{3,})/.test(i.trim()))return t=!t,i;if(t)return i;return i.replace(/\t/g," ")}).join(`
102
+ `)}};var Ol={meta:{docs:"Inline HTML should not be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).allowed_elements||[],o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(/^(?:`{3,}|~{3,})/.test(a.trim())){o=!o;continue}if(o)continue;let c=a;c=c.replace(/``[^`]+``/g,(f)=>" ".repeat(f.length)),c=c.replace(/`[^`]+`/g,(f)=>" ".repeat(f.length));let u=c.matchAll(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi);for(let f of u){let m=f[1].toLowerCase(),h=c.slice(f.index+1+m.length);if(h.startsWith("://")||m==="mailto"&&h.startsWith(":"))continue;if(!r.includes(m)){let d=f.index+1;t.push({filePath:n.filePath,line:l+1,column:d,ruleId:"markdown/no-inline-html",message:`Inline HTML element '<${m}>' should not be used`,severity:"warning"})}}}return t}};var _l={meta:{docs:"ATX style headings must have a space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].match(/^(#{1,6})([^\s#])/);if(l)t.push({filePath:n.filePath,line:r+1,column:l[1].length+1,ruleId:"markdown/no-missing-space-atx",message:"No space after hash on atx style heading",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})([^\s#])/,"$1 $2")}).join(`
103
+ `)}};var Dl={meta:{docs:"Closed ATX style headings must have spaces inside the hashes"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let o=s[r],l=o.match(/^(#{1,6})\s+(.+?)(#{1,6})\s*$/);if(l){let c=l[1],u=l[2],f=l[3];if(!u.endsWith(" ")){let m=c.length+1+u.length;t.push({filePath:n.filePath,line:r+1,column:m,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}}let a=o.match(/^(#{1,6})(\S.+?#{1,6})\s*$/);if(a)t.push({filePath:n.filePath,line:r+1,column:a[1].length+1,ruleId:"markdown/no-missing-space-closed-atx",message:"No space inside hashes on closed atx style heading",severity:"error"})}return t}};var Fl={meta:{docs:"Multiple consecutive blank lines should not be used"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.maximum!==void 0?i.maximum:1,o=0;for(let l=0;l<s.length;l++)if(s[l].trim().length===0){if(o++,o>r)t.push({filePath:n.filePath,line:l+1,column:1,ruleId:"markdown/no-multiple-blanks",message:`Multiple consecutive blank lines (max ${r})`,severity:"error"})}else o=0;return t},fix:(e,n)=>{let t=n.options||{},s=t.maximum!==void 0?t.maximum:1,i=e.split(/\r?\n/),r=[],o=0;for(let l of i)if(l.trim().length===0){if(o++,o<=s)r.push(l)}else o=0,r.push(l);return r.join(`
104
+ `)}};var Nl={meta:{docs:"ATX style headings should have only one space after the hash"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].match(/^(#{1,6})\s{2,}/);if(l)t.push({filePath:n.filePath,line:r+1,column:l[1].length+1,ruleId:"markdown/no-multiple-space-atx",message:"Multiple spaces after hash on atx style heading",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(#{1,6})\s{2,}/,"$1 ")}).join(`
105
+ `)}};var Wl={meta:{docs:"Blockquote symbols should be followed by a single space"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].match(/^(\s*)(>+)\s{2,}/);if(l){let a=l[1].length+l[2].length+1;t.push({filePath:n.filePath,line:r+1,column:a,ruleId:"markdown/no-multiple-space-blockquote",message:"Multiple spaces after blockquote symbol",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n);return n.map((i,r)=>{if(t.has(r))return i;return i.replace(/^(\s*>+)\s{2,}/,"$1 ")}).join(`
106
+ `)}};var Bl={meta:{docs:"Closed ATX style headings should have only one space inside the hashes"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let o=s[r],l=o.match(/^(#{1,6})\s{2,}(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])#{1,6}\s*$/);if(l)t.push({filePath:n.filePath,line:r+1,column:l[1].length+1,ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"});let a=o.match(/^#{1,6}\s+(?:\S.*?|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])\s{2,}(#{1,6})\s*$/);if(a){let c=o.lastIndexOf(a[1])-1;t.push({filePath:n.filePath,line:r+1,column:Math.max(1,c),ruleId:"markdown/no-multiple-space-closed-atx",message:"Multiple spaces inside hashes on closed atx style heading",severity:"error"})}}return t}};var jl={meta:{docs:"Link syntax should not be reversed"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].matchAll(/\(([^)]+)\)\[(?:[^\]]+)\]/g);for(let a of l){let c=a.index+1;t.push({filePath:n.filePath,line:r+1,column:c,ruleId:"markdown/no-reversed-links",message:"Reversed link syntax: should be [text](url) not (text)[url]",severity:"error"})}}return t}};var Ul={meta:{docs:"Code span elements should not have spaces inside the backticks"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){let o=s[r];if(i.has(r))continue;let l=/(`+)([\s\S]*?)\1/g;for(let a of o.matchAll(l)){let c=a[2];if(c.startsWith(" ")&&c.endsWith(" ")&&c.trim().length>0)t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"markdown/no-space-in-code",message:"Spaces inside code span elements",severity:"error"})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=[];for(let i=0;i<n.length;i++){let r=n[i];if(t.has(i)){s.push(r);continue}s.push(r.replace(/(`+)([\s\S]*?)\1/g,(o,l,a)=>{if(a.startsWith(" ")&&a.endsWith(" ")&&a.trim().length>0)return`${l}${a.trim()}${l}`;return o}))}return s.join(`
107
+ `)}};var Md=[/(?<![A-Za-z0-9])\*\*\s+[^*]+?\*\*(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])\*\*[^*]+?\s+\*\*(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])__\s+[^_]+?__(?![A-Za-z0-9])/g,/(?<![A-Za-z0-9])__[^_]+?\s+__(?![A-Za-z0-9])/g],zl={meta:{docs:"Emphasis markers should not have spaces inside them"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){let o=s[r];if(i.has(r))continue;let l=o.replace(/`[^`]+`/g,(a)=>"\x01".repeat(a.length));for(let a of Md)for(let c of l.matchAll(a))t.push({filePath:n.filePath,line:r+1,column:c.index+1,ruleId:"markdown/no-space-in-emphasis",message:"Spaces inside emphasis markers",severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=[];for(let i=0;i<n.length;i++){let r=n[i];if(t.has(i)){s.push(r);continue}let o=wt(r,(l)=>{let a=l;return a=a.replace(/(?<![A-Za-z0-9])(\*\*)\s+([^*]+?)\*\*(?![A-Za-z0-9])/g,"$1$2**"),a=a.replace(/(?<![A-Za-z0-9])(\*\*)([^*]+?)\s+\*\*(?![A-Za-z0-9])/g,"$1$2**"),a=a.replace(/(?<![A-Za-z0-9])(__)\s+([^_]+?)__(?![A-Za-z0-9])/g,"$1$2__"),a=a.replace(/(?<![A-Za-z0-9])(__)([^_]+?)\s+__(?![A-Za-z0-9])/g,"$1$2__"),a});s.push(o)}return s.join(`
108
+ `)}};var ql={meta:{docs:"Link text should not have leading or trailing spaces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s);for(let r=0;r<s.length;r++){if(i.has(r))continue;let l=s[r].matchAll(/\[([^\][]*)\]\([^)]*\)/g);for(let a of l){let c=a[1];if(/^\s/.test(c)||/\s$/.test(c)){let u=a.index+1;t.push({filePath:n.filePath,line:r+1,column:u,ruleId:"markdown/no-space-in-links",message:"Spaces inside link text",severity:"error"})}}}return t}};var Kl={meta:{docs:"Headings should not end with punctuation"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).punctuation||".,;:!?",o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(/^(?:`{3,}|~{3,})/.test(a.trim())){o=!o;continue}if(o)continue;let c=a.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(c){let f=c[1].trim(),m=f[f.length-1];if(m&&r.includes(m))t.push({filePath:n.filePath,line:l+1,column:a.indexOf(f)+f.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${m}'`,severity:"error"})}let u=l+1<s.length?s[l+1]:"";if(/^(?:=+|-+)\s*$/.test(u)&&a.trim().length>0){let f=a.trim(),m=f[f.length-1];if(m&&r.includes(m))t.push({filePath:n.filePath,line:l+1,column:a.indexOf(f)+f.length,ruleId:"markdown/no-trailing-punctuation",message:`Trailing punctuation in heading: '${m}'`,severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).punctuation||".,;:!?",i=new RegExp(`[${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}]+$`),r=e.split(/\r?\n/),o=!1;return r.map((a,c)=>{if(/^(?:`{3,}|~{3,})/.test(a.trim()))return o=!o,a;if(o)return a;let u=a.match(/^(#{1,6}\s+)(.+?)(\s*#+\s*)?$/);if(u){let m=u[1],h=u[2],d=u[3]||"",p=h.replace(i,"");return`${m}${p}${d}`}let f=c+1<r.length?r[c+1]:"";if(/^(?:=+|-+)\s*$/.test(f)&&a.trim().length>0)return a.replace(i,"");return a}).join(`
109
+ `)}};var Vl={meta:{docs:"Lines should not end with trailing spaces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/\s+$/);if(o){let l=n.options||{},a=l.br_spaces!==void 0?l.br_spaces:2;if(a===0||o[0].length!==a)t.push({filePath:n.filePath,line:i+1,column:r.length-o[0].length+1,ruleId:"markdown/no-trailing-spaces",message:`Trailing spaces found (${o[0].length} space${o[0].length!==1?"s":""})`,severity:"error"})}}return t},fix:(e,n)=>{let t=e.split(/\r?\n/),s=n.options||{},i=s.br_spaces!==void 0?s.br_spaces:2;return t.map((o)=>{let l=o.match(/\s+$/);if(l){if(i>0&&l[0].length===i)return o;return o.replace(/\s+$/,"")}return o}).join(`
110
+ `)}};var Hl={meta:{docs:"Ordered list item prefix should follow specified style"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"one_or_ordered",o=1;for(let l=0;l<s.length;l++){let a=s[l],c=a.match(/^(\s*)(\d+)\.\s+/);if(c){let u=Number.parseInt(c[2],10);if(r==="one"&&u!==1)t.push({filePath:n.filePath,line:l+1,column:c[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '1.', found '${u}.'`,severity:"error"});else if(r==="ordered"&&u!==o)t.push({filePath:n.filePath,line:l+1,column:c[1].length+1,ruleId:"markdown/ol-prefix",message:`Ordered list item prefix should be '${o}.', found '${u}.'`,severity:"error"});o++}else if(a.trim().length===0)o=1}return t},fix:(e,n)=>{let s=(n.options||{}).style||"one_or_ordered",i=e.split(/\r?\n/),r=[],o=1;for(let l of i){let a=l.match(/^(\s*)(\d+)(\.\s+)/);if(a){let c=a[1],u=a[3];if(s==="one")r.push(l.replace(/^(\s*)\d+(\.\s+)/,`${c}1${u}`));else if(s==="ordered")r.push(l.replace(/^(\s*)\d+(\.\s+)/,`${c}${o}${u}`)),o++;else r.push(l),o++}else if(r.push(l),l.trim().length===0)o=1}return r.join(`
111
+ `)}};var Zl={meta:{docs:"Proper names should have correct capitalization"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.options||{},r=i.names||[],o=i.code_blocks!==!1;if(r.length===0)return t;let l=j(s);for(let a=0;a<s.length;a++){if(l.has(a)&&!o)continue;let c=s[a];for(let u of r){let f=new RegExp(`\\b${u}\\b`,"gi"),m=c.matchAll(f);for(let h of m)if(h[0]!==u){let d=h.index+1;t.push({filePath:n.filePath,line:a+1,column:d,ruleId:"markdown/proper-names",message:`Incorrect capitalization of '${h[0]}', should be '${u}'`,severity:"error"})}}}return t}};var Gl={meta:{docs:"Reference links and images should use defined labels"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Set;for(let l of s){let a=l.match(/^\s*\[([^\]]+)\]:\s*\S+/);if(a)i.add(a[1].toLowerCase())}let r=!1,o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(/^(?:`{3,}|~{3,})/.test(a.trim())){r=!r;continue}if(r)continue;if(a.includes("<!--"))o=!0;if(a.includes("-->")){o=!1;continue}if(o)continue;if(/^\s*\[(?:[^\]]+)\]:\s*\S+/.test(a))continue;let c=a.replace(/`[^`]+`/g,(f)=>" ".repeat(f.length));c=c.replace(/!?\[[^\]]*\]\([^)]*\)/g,(f)=>" ".repeat(f.length));let u=c.matchAll(/!?\[([^\]]+)\]\[([^\]]*)\]/g);for(let f of u){let m=(f[2].trim()||f[1]).toLowerCase();if(!i.has(m))t.push({filePath:n.filePath,line:l+1,column:f.index+1,ruleId:"markdown/reference-links-images",message:`Reference link '[${m}]' is not defined`,severity:"error"})}}return t}};var Jl={meta:{docs:"Document should have required heading structure"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).headings||[];if(r.length===0)return t;let o=[];for(let a of s){let c=a.match(/^#{1,6}\s+(.+?)(?:\s*#+\s*)?$/);if(c)o.push(c[1].trim())}let l=0;for(let a=0;a<o.length&&l<r.length;a++)if(o[a]===r[l])l++;if(l<r.length)t.push({filePath:n.filePath,line:1,column:1,ruleId:"markdown/required-headings",message:`Missing required heading: '${r[l]}'`,severity:"error"});return t}};var Yl={meta:{docs:"Document should have only one top-level heading (h1)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),r=-1;for(let o=0;o<s.length;o++){if(i.has(o))continue;let l=s[o],a=o+1<s.length?s[o+1]:"",c=!1;if(/^#\s/.test(l))c=!0;if(/^=+\s*$/.test(a)&&l.trim().length>0&&!i.has(o+1))c=!0;if(c)if(r===-1)r=o+1;else t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"markdown/single-title",message:`Multiple top-level headings in the same document (first h1 on line ${r})`,severity:"error"})}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=j(n),s=[],i=!1,r=!1;for(let o=0;o<n.length;o++){if(t.has(o)){s.push(n[o]);continue}let l=n[o],a=o+1<n.length?n[o+1]:"",c=/^#\s/.test(l),u=/^=+\s*$/.test(a)&&l.trim().length>0&&!t.has(o+1);if(c){if(!i)i=!0,s.push(l);else s.push(`#${l}`),r=!0;continue}if(u){if(!i){i=!0,s.push(l);continue}s.push(`## ${l.trim()}`),o++,r=!0;continue}s.push(l)}return r?s.join(`
112
+ `):e}};var Xl={meta:{docs:"Files should end with a single newline character"},check:(e,n)=>{let t=[];if(!e.endsWith(`
113
+ `)&&!e.endsWith(`\r
114
+ `)){let s=e.split(/\r?\n/);t.push({filePath:n.filePath,line:s.length,column:s[s.length-1].length+1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character",severity:"error"})}if(e.endsWith(`
115
+
116
+ `)||e.endsWith(`\r
117
+ \r
118
+ `)){let s=e.split(/\r?\n/);t.push({filePath:n.filePath,line:s.length,column:1,ruleId:"markdown/single-trailing-newline",message:"File should end with a single newline character (not multiple)",severity:"error"})}return t},fix:(e)=>`${e.replace(/[\r\n]+$/,"")}
119
+ `};var Ql={meta:{docs:"Strong style should be consistent (asterisk or underscore)"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),o=(n.options||{}).style||"consistent",l=null;for(let a=0;a<s.length;a++){if(i.has(a))continue;let c=Qe(s[a]),u=c.matchAll(/\*\*([^*]+)\*\*/g);for(let m of u)if(o==="underscore")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Expected underscore (__) for strong",severity:"error"});else if(o==="consistent"){if(l===null)l="asterisk";else if(l==="underscore")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}let f=c.matchAll(/__([^_]+)__/g);for(let m of f)if(o==="asterisk")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Expected asterisk (**) for strong",severity:"error"});else if(o==="consistent"){if(l===null)l="underscore";else if(l==="asterisk")t.push({filePath:n.filePath,line:a+1,column:m.index+1,ruleId:"markdown/strong-style",message:"Strong style should be consistent throughout document",severity:"error"})}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=j(i),o="asterisk";if(s==="asterisk")o="asterisk";else if(s==="underscore")o="underscore";else if(s==="consistent"){let a=null,c=null;for(let f=0;f<i.length;f++){if(r.has(f))continue;let m=Qe(i[f]);if(a===null){let h=m.match(/\*\*([^*]+)\*\*/);if(h)a={line:f,col:h.index}}if(c===null){let h=m.match(/__([^_]+)__/);if(h)c={line:f,col:h.index}}if(a&&c)break}if(a&&(!c||((f,m)=>f.line!==m.line?f.line-m.line:f.col-m.col)(a,c)<0))o="asterisk";else if(c)o="underscore"}let l=!1;for(let a=0;a<i.length;a++){if(r.has(a))continue;let c=i[a],u=wt(c,(f)=>o==="asterisk"?f.replace(/__([^_]+)__/g,"**$1**"):f.replace(/\*\*([^*]+)\*\*/g,"__$1__"));if(u!==c)i[a]=u,l=!0}return l?i.join(`
120
+ `):e}};var ea={meta:{docs:"Table rows should have consistent column counts"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=-1,o=!1,l=it(s);for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c.trim())){if(o=!o,i)i=!1,r=-1;continue}if(o)continue;let u=l.has(a)&&/\|/.test(c)&&c.trim().length>0;if(u){let f=Cd(c);if(!i)i=!0,r=f;else if(f!==r)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-column-count",message:`Table row has ${f} column(s), expected ${r}`,severity:"error"})}else if(c.trim().length===0||!u){if(i)i=!1,r=-1}}return t}};function Cd(e){let n=e.trim();if(n.startsWith("|"))n=n.slice(1);if(n.endsWith("|")&&!n.endsWith("\\|"))n=n.slice(0,-1);if(n==="")return 0;let t=1,s=!1,i=0,r=0;while(r<n.length){let o=n[r];if(o==="\\"&&n[r+1]==="|"){r+=2;continue}if(o==="`"){let l=0;while(n[r+l]==="`")l++;if(!s)s=!0,i=l;else if(l===i)s=!1,i=0;r+=l;continue}if(!s&&o==="|")t++;r++}return t}var ta={meta:{docs:"Table columns should have consistent alignment"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/[-:]/.test(r)&&/\|/.test(r)){if(r.match(/^[|\s:.-]+$/)){let l=r.split("|").filter((a)=>a.trim().length>0);for(let a of l){let c=a.trim();if(!/^:?-+:?$/.test(c))t.push({filePath:n.filePath,line:i+1,column:r.indexOf(a)+1,ruleId:"markdown/table-column-style",message:"Invalid table column separator",severity:"error"})}}}}return t}};var na={meta:{docs:"Table pipe style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).style||"leading_and_trailing",o=!1,l=it(s);for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c.trim())){o=!o;continue}if(o)continue;if(l.has(a)&&/\|/.test(c)&&c.trim().length>0){let u=c.trim().startsWith("|"),f=c.trim().endsWith("|");if(r==="leading_and_trailing"){if(!u||!f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading and trailing pipes",severity:"error"})}else if(r==="leading_only"){if(!u||f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have leading pipe only",severity:"error"})}else if(r==="trailing_only"){if(u||!f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should have trailing pipe only",severity:"error"})}else if(r==="no_leading_or_trailing"){if(u||f)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/table-pipe-style",message:"Table rows should not have leading or trailing pipes",severity:"error"})}}}return t}};var sa={meta:{docs:"Unordered list indentation should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),r=(n.options||{}).indent||2,o=!1,l=[];for(let a=0;a<s.length;a++){let c=s[a];if(/^(?:`{3,}|~{3,})/.test(c.trim())){o=!o;continue}if(o)continue;if(c.trim()==="")continue;let u=c.match(/^(\s*)([*\-+])(\s+)/),f=c.match(/^(\s*)(\d+[.)])(\s+)/);if(!u&&!f){let x=c.match(/^(\s*)/)?.[1].length||0;while(l.length>0&&l[l.length-1].contentCol>x)l.pop();continue}let m=u||f,h=m[1].length,d=m[2],p=m[3],y=h+d.length+p.length,g=u?"ul":"ol";while(l.length>0&&h<l[l.length-1].contentCol)l.pop();if(g==="ul"){let x=l.length>0?l[l.length-1]:null;if(!x){if(h!==0&&h%r!==0)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${r} spaces per level. Found ${h} spaces`,severity:"error"})}else if(x.type==="ul"){let k=x.contentCol,P=x.indent+r;if(h!==k&&h!==P)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"markdown/ul-indent",message:`Unordered list indentation should be ${r} spaces per level. Found ${h} spaces`,severity:"error"})}}l.push({indent:h,contentCol:y,type:g})}return t}};var ia={meta:{docs:"Unordered list style should be consistent"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=j(s),o=(n.options||{}).style||"consistent",l=null;for(let a=0;a<s.length;a++){let c=s[a];if(i.has(a))continue;let u=c.match(/^(\s*)([*\-+])\s+/);if(u){let f=u[2];if(o==="asterisk"&&f!=="*")t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Expected asterisk (*) for unordered list, found '${f}'`,severity:"error"});else if(o==="dash"&&f!=="-")t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Expected dash (-) for unordered list, found '${f}'`,severity:"error"});else if(o==="plus"&&f!=="+")t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Expected plus (+) for unordered list, found '${f}'`,severity:"error"});else if(o==="consistent"){if(l===null)l=f;else if(l!==f)t.push({filePath:n.filePath,line:a+1,column:u[1].length+1,ruleId:"markdown/ul-style",message:`Unordered list style should be consistent throughout document. Expected '${l}', found '${f}'`,severity:"error"})}}}return t},fix:(e,n)=>{let s=(n.options||{}).style||"consistent",i=e.split(/\r?\n/),r=j(i),o="*";if(s==="asterisk")o="*";else if(s==="dash")o="-";else if(s==="plus")o="+";else if(s==="consistent")for(let a=0;a<i.length;a++){if(r.has(a))continue;let c=i[a].match(/^(\s*)([*\-+])\s+/);if(c){o=c[2];break}}return i.map((a,c)=>{if(r.has(c))return a;return a.replace(/^(\s*)([*\-+])(\s+)/,`$1${o}$3`)}).join(`
121
+ `)}};function Sd(e){let n=e.split(/\r?\n/);if(n[0]?.trim()!=="---")return{text:e,frontmatter:null,frontmatterEndLine:0};for(let t=1;t<n.length;t++)if(n[t].trim()==="---"){let s=n.slice(0,t+1);return{text:[...s.map(()=>""),...n.slice(t+1)].join(`
122
+ `),frontmatter:s,frontmatterEndLine:t+1}}return{text:e,frontmatter:null,frontmatterEndLine:0}}function Ed(e){let n=e.split(/\r?\n/);if(n[0]?.trim()!=="---")return{header:null,body:e};for(let t=1;t<n.length;t++)if(n[t].trim()==="---")return{header:n.slice(0,t+1).join(`
123
+ `),body:n.slice(t+1).join(`
124
+ `)};return{header:null,body:e}}function Ld(e){return{meta:e.meta,check:(n,t)=>t.filePath.endsWith(".md")?e.check(n,t):[],fix:e.fix?(n,t)=>t.filePath.endsWith(".md")?e.fix(n,t):n:void 0}}function H(e){return{meta:e.meta,check:(n,t)=>{if(!t.filePath.endsWith(".md"))return[];let{text:s,frontmatterEndLine:i}=Sd(n),r=e.check(s,t);if(i>0)return r.filter((o)=>o.line>i+1);return r},fix:e.fix?(n,t)=>{if(!t.filePath.endsWith(".md"))return n;let{header:s,body:i}=Ed(n);if(s===null)return e.fix(n,t);let r=e.fix(i,t);if(r===i)return n;return`${s}
125
+ ${r}`}:void 0}}var ra={name:"markdown",rules:{"heading-increment":H(gl),"heading-style":H(bl),"no-missing-space-atx":H(_l),"no-multiple-space-atx":H(Nl),"no-missing-space-closed-atx":H(Dl),"no-multiple-space-closed-atx":H(Bl),"blanks-around-headings":H(sl),"heading-start-left":H(yl),"no-duplicate-heading":H(Sl),"single-title":H(Yl),"no-trailing-punctuation":H(Kl),"ul-style":H(ia),"list-indent":H(Pl),"ul-indent":H(sa),"ol-prefix":H(Hl),"list-marker-space":H(Il),"blanks-around-lists":H(il),"no-trailing-spaces":H(Vl),"no-hard-tabs":H(Al),"no-multiple-blanks":H(Fl),"no-multiple-space-blockquote":H(Wl),"no-blanks-blockquote":H(Cl),"blanks-around-fences":H(nl),"single-trailing-newline":Ld(Xl),"blanks-around-tables":H(ll),"no-reversed-links":H(jl),"no-bare-urls":H(Ml),"no-space-in-links":H(ql),"no-empty-links":H(Tl),"link-fragments":H(Rl),"reference-links-images":H(Gl),"link-image-reference-definitions":H(kl),"link-image-style":H($l),"descriptive-link-text":H(ml),"line-length":H(wl),"commands-show-output":H(fl),"fenced-code-language":H(dl),"code-block-style":H(al),"code-fence-style":H(ul),"no-emphasis-as-heading":H(Ll),"no-space-in-emphasis":H(zl),"no-space-in-code":H(Ul),"emphasis-style":H(hl),"strong-style":H(Ql),"no-inline-html":H(Ol),"hr-style":H(xl),"first-line-heading":H(pl),"required-headings":H(Jl),"proper-names":H(Zl),"no-alt-text":H(vl),"table-pipe-style":H(na),"table-column-count":H(ea),"table-column-style":H(ta)}};var oa={meta:{docs:"Prefer using global Buffer instead of requiring it",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?buffer['"]/;for(let r=0;r<s.length;r++){let o=s[r],l=o.trim();if(l.startsWith("//")||l.startsWith("/*")||l.startsWith("*"))continue;let a=o.match(i);if(!a||a.index===void 0)continue;if(!/\bBuffer\b/.test(o))continue;t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"node/prefer-global/buffer",message:"Unexpected import of 'Buffer'. Use the global 'Buffer' instead",severity:"error",help:"`Buffer` is a global in Node.js \u2014 remove the import and use it directly."})}return t}};var la={meta:{docs:"Prefer using global process instead of requiring it",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=/(?:import\b[^;\n]*\bfrom\s*|require\s*\(\s*)['"](?:node:)?process['"]/;for(let r=0;r<s.length;r++){let o=s[r],l=o.trim();if(l.startsWith("//")||l.startsWith("/*")||l.startsWith("*"))continue;let a=o.match(i);if(!a||a.index===void 0)continue;t.push({filePath:n.filePath,line:r+1,column:a.index+1,ruleId:"node/prefer-global/process",message:"Unexpected import of 'process'. Use the global 'process' instead",severity:"error",help:"`process` is a global in Node.js \u2014 remove the import and use it directly."})}return t}};var aa={name:"node",rules:{"prefer-global/buffer":b(oa),"prefer-global/process":b(la)}};var Ts={meta:{docs:"Enforce sorted imports (delegates to formatter check only)"},check:(e,n)=>{let t=e.split(/\r?\n/),s=0;while(s<t.length&&(/^\s*$/.test(t[s])||/^\s*\/.\/.*/.test(t[s])||/^\s*\/.\*/.test(t[s])))s++;let i=s,r=[];while(s<t.length&&/^\s*import\b/.test(t[s]))r.push(t[s].trim()),s++;if(r.length===0)return[];let o=r.join(`
126
+ `),l=t.slice(s).join(`
127
+ `),a=`${o}
128
+ ${l}`;if(Ti(a)!==a)return[{filePath:n.filePath,line:i+1,column:1,ruleId:"sort-imports",message:"Imports are not sorted/grouped consistently",severity:"warning"}];return[]},fix:(e)=>Ti(e)};var ca={name:"perfectionist",rules:{"sort-imports":b(Ts)}};import{dirname as Td,resolve as Ad}from"path";function Q(e){try{let n=JSON.parse(e);if(typeof n!=="object"||n===null||Array.isArray(n))return null;return n}catch{return null}}function Od(e,n){let t=e.split(`
129
+ `),s=1,i=0;for(let r of n){let o=new RegExp(`"${Nd(r)}"\\s*:`);for(let l=i;l<t.length;l++)if(o.test(t[l])){s=l+1,i=l+1;break}}return s}function Be(e){return Td(e)}function Le(e,n){return Ad(e,n)}function ne(e){let n="pkg";for(let t of e)if(/^\d+$/.test(t))n+=`[${t}]`;else if(!/^[a-z_$][a-z0-9_$]*$/i.test(t))n+=`["${t}"]`;else n+=`.${t}`;return n}function X(e,n){if(e.publishConfig?.[n]!==void 0)return[e.publishConfig[n],["publishConfig",n]];return[e[n],[n]]}var _d=new RegExp(`(?:[\\s;]|^)(?:import[\\w,{}\\s*]*from|import\\s*['"*{]|export\\b\\s*(?:[*{]|default|type|function|const|var|let|async function)|import\\.meta\\b)`,"m"),Dd=new RegExp("(?:[\\s;]|^)(?:module.exports\\b|exports\\.\\w|require\\s*\\(|global\\.\\w|Object\\.(?:defineProperty|defineProperties|assign)\\s*\\(\\s*exports\\b)","m");function rt(e){let n=Fd(e),t=_d.test(n),s=Dd.test(n);if(t&&s)return"mixed";if(t)return"ESM";if(s)return"CJS";return"unknown"}function ua(e,n){if(e.endsWith(".mjs"))return"ESM";if(e.endsWith(".cjs"))return"CJS";return n==="module"?"ESM":"CJS"}function fa(e){if(e==="ESM")return".mjs";if(e==="CJS")return".cjs";return".js"}function ma(e){return e===".mjs"||e===".cjs"}function Ze(e){return e.endsWith(".js")||e.endsWith(".mjs")||e.endsWith(".cjs")}function ha(e){return/^#!\s*\//.test(e)}function Fd(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*/g,"")}function fe(e,n,t,s){Ai(e,n,t,s)}function Ai(e,n,t,s){if(typeof e==="string"){s(e,{path:n,isImports:t});return}if(Array.isArray(e)){s(e,{path:n,isImports:t});for(let i=0;i<e.length;i++)Ai(e[i],n.concat(String(i)),t,s);return}if(e!==null&&typeof e==="object"){let i=Object.keys(e);s(e,{path:n,isImports:t},i);for(let r of i)Ai(e[r],n.concat(r),t,s)}}function J(e,n,t,s,i,r,o){return{filePath:e,line:Od(n,t),column:1,ruleId:s,message:i,severity:r,...o&&{help:o}}}function Nd(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Oi={meta:{docs:"Disallow deprecated jsnext:main and jsnext fields",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[];if(t["jsnext:main"]!=null)s.push(J(n.filePath,e,["jsnext:main"],"publint/deprecated-field-jsnext",'pkg["jsnext:main"] is deprecated. pkg.module should be used instead.',"warning",'The jsnext:main field is no longer recognized by modern bundlers. Use "module" instead.'));if(t.jsnext!=null)s.push(J(n.filePath,e,["jsnext"],"publint/deprecated-field-jsnext","pkg.jsnext is deprecated. pkg.module should be used instead.","warning",'The jsnext field is no longer recognized by modern bundlers. Use "module" instead.'));return s}};var _i={meta:{docs:'Ensure "default" condition is last in exports objects',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("default"in o))return;if(a[a.length-1]!=="default")s.push(J(n.filePath,e,l.path.concat("default"),"publint/exports-default-should-be-last",`${ne(l.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),s}};var Di={meta:{docs:"Warn against using fallback arrays in exports",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l)=>{if(!Array.isArray(o))return;s.push(J(n.filePath,e,l.path,"publint/exports-fallback-array-use",`${ne(l.path)} uses fallback arrays which is not recommended. It works differently in some tools and may face inconsistent behaviors.`,"warning","Fallback arrays pick the first parseable value and have no practical use case in Node.js currently."))}),s}};var Fi={meta:{docs:"Ensure exports has a root entrypoint when main/module exist",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let[s]=X(t,"main"),[i]=X(t,"module"),[r,o]=X(t,"exports");if(s==null&&i==null||r==null)return[];if(typeof r!=="object"||Array.isArray(r))return[];let l=Object.keys(r);if(l.length===0)return[];if(!l[0]?.startsWith("."))return[];if(l.includes("."))return[];let c=[];if(s)c.push("main");if(i)c.push("module");return[J(n.filePath,e,o,"publint/exports-missing-root-entrypoint",`${ne(o)} is missing the root entrypoint export, which is defined in pkg.${c[0]}. Environments that support "exports" will ignore pkg.${c[0]} as "exports" takes the highest priority.`,"warning",`Add ${ne(o.concat("."))} to ensure the root entrypoint is accessible.`)]}};var Ni={meta:{docs:'Ensure "module" condition precedes "require" in exports',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("module"in o)||!("require"in o))return;if(a.indexOf("module")>a.indexOf("require"))s.push(J(n.filePath,e,l.path.concat("module"),"publint/exports-module-should-precede-require",`${ne(l.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),s}};var Wi={meta:{docs:'Ensure "types" condition is first in exports objects',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("types"in o))return;let c=a.indexOf("types");if(c===0)return;if(a.slice(0,c).filter((f)=>{if(f.startsWith("types"))return!1;if(typeof o[f]==="object"&&o[f]!==null&&da(o[f],"types"))return!1;return!0}).length>0)s.push(J(n.filePath,e,l.path.concat("types"),"publint/exports-types-should-be-first",`${ne(l.path.concat("types"))} should be the first condition in the object so it can be resolved by TypeScript.`,"error",'TypeScript resolves conditions in order. The "types" condition must come first to ensure correct type resolution.'))}),s}};function da(e,n){for(let t in e){if(t===n)return!0;if(typeof e[t]==="object"&&e[t]!==null&&da(e[t],n))return!0}return!1}var Bi={meta:{docs:'Ensure exports values start with "./"',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"exports");if(i==null)return[];return fe(i,r,!1,(o,l)=>{if(typeof o!=="string")return;if(o.startsWith("./"))return;let a=`./${o.replace(/^[/]+/,"")}`;s.push(J(n.filePath,e,l.path,"publint/exports-value-invalid",`${ne(l.path)} is "${o}" which is invalid as it does not start with "./". Use "${a}" instead.`,"error",'All exports values must be relative paths starting with "./".'))}),s}};var Wd=[{field:"main",expectTypes:["string"]},{field:"module",expectTypes:["string"]},{field:"types",expectTypes:["string"]},{field:"typings",expectTypes:["string"]},{field:"browser",expectTypes:["string","object"]},{field:"bin",expectTypes:["string","object"]},{field:"exports",expectTypes:["string","object"]},{field:"imports",expectTypes:["object"]},{field:"name",expectTypes:["string"]},{field:"version",expectTypes:["string"]},{field:"description",expectTypes:["string"]},{field:"license",expectTypes:["string"]}],ji={meta:{docs:"Ensure package.json fields have correct value types",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[];for(let{field:i,expectTypes:r}of Wd){let[o,l]=X(t,i);if(o==null)continue;let a=typeof o;if(!r.includes(a)){let c=r.length===1?r[0]:`${r.slice(0,-1).join(", ")} or ${r[r.length-1]}`;s.push(J(n.filePath,e,l,"publint/field-invalid-value-type",`${ne(l)} has an invalid ${a} type. Expected a ${c} type instead.`,"error",`The "${i}" field must be of type ${c}.`))}}return s}};var Ui={meta:{docs:"Suggest adding exports when module field is present",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let[s,i]=X(t,"module"),[r]=X(t,"exports");if(s!=null&&r==null)return[J(n.filePath,e,i,"publint/has-module-but-no-exports","pkg.module is used to output ESM, but pkg.exports is not defined. As Node.js doesn't read pkg.module, the ESM output may be skipped. Consider adding pkg.exports to export the ESM output.","warning",'Node.js only reads "exports" for module resolution. Without it, the ESM entry point in "module" is ignored by Node.js.')];return[]}};var zi={meta:{docs:'Ensure "default" condition is last in imports objects',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object")return[];return fe(i,r,!0,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("default"in o))return;if(a[a.length-1]!=="default")s.push(J(n.filePath,e,l.path.concat("default"),"publint/imports-default-should-be-last",`${ne(l.path.concat("default"))} should be the last condition in the object so it doesn't take precedence over the keys following it.`,"error",'Conditions are resolved in order. "default" acts as a fallback and should come last.'))}),s}};var qi={meta:{docs:'Ensure imports keys start with "#"',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object"||Array.isArray(i))return[];for(let o of Object.keys(i))if(!o.startsWith("#")){let l=`#${o.replace(/^[/]+/,"")}`,a=r.concat(o);s.push(J(n.filePath,e,a,"publint/imports-key-invalid",`${ne(a)} is invalid as the imports key does not start with "#". Use "${l}" instead.`,"error",'All imports keys must start with "#" to distinguish them from package specifiers.'))}return s}};var Ki={meta:{docs:'Ensure "module" condition precedes "require" in imports',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object")return[];return fe(i,r,!0,(o,l,a)=>{if(!a||typeof o!=="object"||Array.isArray(o))return;if(!("module"in o)||!("require"in o))return;if(a.indexOf("module")>a.indexOf("require"))s.push(J(n.filePath,e,l.path.concat("module"),"publint/imports-module-should-precede-require",`${ne(l.path.concat("module"))} should come before the "require" condition so it can take precedence when used by a bundler.`,"error",'Bundlers prioritize conditions by order. "module" should precede "require" to ensure ESM is preferred.'))}),s}};var Vi={meta:{docs:'Ensure imports values start with "./"',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],[i,r]=X(t,"imports");if(i==null||typeof i!=="object")return[];return fe(i,r,!0,(o,l)=>{if(typeof o!=="string")return;if(!o.startsWith("."))return;if(o.startsWith("./"))return;let a=`./${o.replace(/^[/]+/,"")}`;s.push(J(n.filePath,e,l.path,"publint/imports-value-invalid",`${ne(l.path)} is "${o}" which is invalid as it does not start with "./". Use "${a}" instead.`,"error",'Relative imports values must start with "./".'))}),s}};var Hi={meta:{docs:"Disallow local file references in dependencies",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=["dependencies","optionalDependencies","peerDependencies"];for(let r of i){let o=t[r];if(!o||typeof o!=="object")continue;for(let l of Object.keys(o)){let a=o[l];if(typeof a==="string"&&(a.startsWith("file:")||a.startsWith("link:")))s.push(J(n.filePath,e,[r,l],"publint/local-dependency",`The "${l}" dependency references "${a}" that will likely not work when installed by end-users.`,"error","Local file references (file: or link:) are not portable and will fail for consumers of the package."))}}return s}};var Zi={meta:{docs:'Suggest specifying the "type" field in package.json',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];if(t.type==null)return[J(n.filePath,e,["name"],"publint/use-type",'The package does not specify the "type" field. Node.js may attempt to detect the package type causing a small performance hit. Consider adding "type": "commonjs" or "type": "module".',"warning",'Adding "type" helps Node.js resolve module format without detection overhead.')];return[]}};import{existsSync as Bd,readFileSync as jd}from"fs";var Gi={meta:{docs:"Ensure bin files have a shebang for executability",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),[r,o]=X(t,"bin");if(r==null)return[];if(typeof r==="string")pa(r,o,i,s,n.filePath,e);else if(typeof r==="object"){for(let l of Object.keys(r))if(typeof r[l]==="string")pa(r[l],o.concat(l),i,s,n.filePath,e)}return s}};function pa(e,n,t,s,i,r){let o=Le(t,e);if(!Bd(o))return;if(!Ze(e))return;let l;try{l=jd(o,"utf8")}catch{return}if(!ha(l))s.push(J(i,r,n,"publint/bin-file-not-executable",`${ne(n)} is "${e}" but the file is not executable. It should start with a shebang, e.g. #!/usr/bin/env node.`,"error","Bin files must start with a shebang (e.g. #!/usr/bin/env node) to be executable."))}import{existsSync as ga,readFileSync as ya}from"fs";var Ji={meta:{docs:'Ensure files under "module" condition in exports are ESM',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),[r,o]=X(t,"exports");if(r==null)return[];fe(r,o,!1,(c,u)=>{if(typeof c!=="string")return;if(!u.path.includes("module"))return;if(!c.startsWith("./")&&!c.startsWith("../"))return;if(c.includes("*"))return;let f=Le(i,c);if(!ga(f))return;if(!Ze(c))return;let m;try{m=ya(f,"utf8")}catch{return}if(rt(m)==="CJS")s.push(J(n.filePath,e,u.path,"publint/exports-module-should-be-esm",`${ne(u.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});let[l,a]=X(t,"imports");if(l!=null&&typeof l==="object")fe(l,a,!0,(c,u)=>{if(typeof c!=="string")return;if(!u.path.includes("module"))return;if(!c.startsWith("./"))return;if(c.includes("*"))return;let f=Le(i,c);if(!ga(f))return;if(!Ze(c))return;let m;try{m=ya(f,"utf8")}catch{return}if(rt(m)==="CJS")s.push(J(n.filePath,e,u.path,"publint/exports-module-should-be-esm",`${ne(u.path)} should be ESM, but the code is written in CJS.`,"error",'The "module" condition is only used by bundlers and must contain ESM code.'))});return s}};import{existsSync as Wt}from"fs";import{dirname as Ud,isAbsolute as zd,resolve as qd}from"path";function Yi(e,n){let t=n;while(t.startsWith("./"))t=t.slice(2);let s=t.split("/")[0];if(!s||s===".."||s.startsWith("."))return!1;let i=zd(n)?Ud(n).split("/")[0]||"/":qd(e,s);return!Wt(i)}var Xi={meta:{docs:"Ensure files referenced in package.json exist",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),r=["main","module","types","typings","unpkg","jsdelivr"];for(let u of r){let[f,m]=X(t,u);if(f==null||typeof f!=="string")continue;if(Yi(i,f))continue;let h=Le(i,f);if(!xa(h))s.push(J(n.filePath,e,m,"publint/file-does-not-exist",`${ne(m)} is "${f}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}let[o,l]=X(t,"bin");if(o!=null){if(typeof o==="string")ba(o,l,s,n.filePath,e,i);else if(typeof o==="object"){for(let u of Object.keys(o))if(typeof o[u]==="string")ba(o[u],l.concat(u),s,n.filePath,e,i)}}let[a,c]=X(t,"exports");if(a!=null)fe(a,c,!1,(u,f)=>{if(typeof u!=="string")return;if(!u.startsWith("./")&&!u.startsWith("../"))return;if(u.includes("*"))return;if(Yi(i,u))return;let m=Le(i,u);if(!Wt(m))s.push(J(n.filePath,e,f.path,"publint/file-does-not-exist",`${ne(f.path)} is "${u}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))});return s}};function ba(e,n,t,s,i,r){if(Yi(r,e))return;let o=Le(r,e);if(!xa(o))t.push(J(s,i,n,"publint/file-does-not-exist",`${ne(n)} is "${e}" but the file does not exist.`,"error","The referenced file path cannot be found. Check the path for typos."))}function xa(e){if(Wt(e))return!0;if(Wt(`${e}.js`))return!0;if(Wt(`${e}/index.js`))return!0;return!1}import{existsSync as Kd,readFileSync as Vd}from"fs";import{extname as Hd}from"path";var Qi={meta:{docs:"Ensure file code format matches its extension and package type",recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let s=[],i=Be(n.filePath),r=t.type,[o,l]=X(t,"main");if(o!=null&&typeof o==="string")wa(o,l,i,r,s,n.filePath,e);let[a,c]=X(t,"exports");if(a!=null)fe(a,c,!1,(u,f)=>{if(typeof u!=="string")return;if(!u.startsWith("./")&&!u.startsWith("../"))return;if(u.includes("*"))return;if(f.path.includes("browser"))return;wa(u,f.path,i,r,s,n.filePath,e)});return s}};function wa(e,n,t,s,i,r,o){let l=Le(t,e);if(!Kd(l))return;if(!Ze(e))return;let a;try{a=Vd(l,"utf8")}catch{return}let c=rt(a);if(c==="unknown"||c==="mixed")return;let u=ua(l,s);if(c===u)return;let f=Hd(l),m=fa(c),d=(ma(f)?"FILE_INVALID_EXPLICIT_FORMAT":"FILE_INVALID_FORMAT")==="FILE_INVALID_EXPLICIT_FORMAT"?`${ne(n)} is "${e}" and ends with the ${f} extension, but the code is written in ${c}. Consider using the ${m} extension.`:`${ne(n)} is "${e}" and is written in ${c}, but is interpreted as ${u}. Consider using the ${m} extension.`;i.push(J(r,o,n,"publint/file-invalid-format",d,"warning",`The file's code format (${c}) doesn't match the expected format (${u}) based on its extension and package type.`))}import{existsSync as Zd,readFileSync as Gd}from"fs";var er={meta:{docs:'Ensure the "module" field points to an ESM file',recommended:!0},check(e,n){let t=Q(e);if(!t)return[];let[s,i]=X(t,"module");if(s==null||typeof s!=="string")return[];let r=Be(n.filePath),o=Le(r,s);if(!Zd(o))return[];if(!Ze(s))return[];let l;try{l=Gd(o,"utf8")}catch{return[]}if(rt(l)==="CJS")return[J(n.filePath,e,i,"publint/module-should-be-esm",`${ne(i)} should be ESM, but the code is written in CJS.`,"error",'The "module" field is intended for ESM output used by bundlers. It should point to an ESM file.')];return[]}};var Ra={name:"publint",rules:{"use-type":pe(Zi),"local-dependency":pe(Hi),"deprecated-field-jsnext":pe(Oi),"has-module-but-no-exports":pe(Ui),"field-invalid-value-type":pe(ji),"exports-types-should-be-first":pe(Wi),"exports-default-should-be-last":pe(_i),"exports-module-should-precede-require":pe(Ni),"exports-value-invalid":pe(Bi),"exports-missing-root-entrypoint":pe(Fi),"exports-fallback-array-use":pe(Di),"imports-key-invalid":pe(qi),"imports-value-invalid":pe(Vi),"imports-default-should-be-last":pe(zi),"imports-module-should-precede-require":pe(Ki),"file-does-not-exist":pe(Xi),"file-invalid-format":pe(Qi),"module-should-be-esm":pe(er),"bin-file-not-executable":pe(Gi),"exports-module-should-be-esm":pe(Ji)}};var ka={meta:{docs:"Ensure all imports appear before other statements",recommended:!1},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=!1,r=0;for(let o=0;o<s.length;o++){let l=s[o].trim();if(!l||l.startsWith("//")||l.startsWith("/*")||l.startsWith("*"))continue;let a=l.match(/^\s*import\s+/);if(!a&&l.length>0){if(i=!0,r===0)r=o+1}if(i&&a)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"import/first",message:"Import statement must appear before other statements",severity:"error"})}return t}};var $a={meta:{docs:"Disallow duplicate specifier names in a single import declaration"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/^\s*import\s*\{([^}]*)\}\s*from\s*['"][^'"]+['"]/);if(!o)continue;let a=o[1].split(",").map((u)=>u.trim()).filter(Boolean).map((u)=>u.split(/\s+as\s+/i)[0].trim()),c=new Set;for(let u of a){if(c.has(u)){t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf(u)+1),ruleId:"pickier/import-dedupe",message:"Expect no duplication in imports",severity:"warning"});break}c.add(u)}}return t}};import{existsSync as Jd,readFileSync as Yd}from"fs";import{dirname as Xd,resolve as Qd}from"path";var Pa={meta:{docs:"Ensure named imports correspond to a named export in the remote file",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Xd(n.filePath);for(let r=0;r<s.length;r++){let l=s[r].match(/\bimport\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]/);if(l){let a=l[1].split(",").map((m)=>m.trim().split(/\s+as\s+/)[0].trim()),c=l[2];if(!c.startsWith(".")&&!c.startsWith("/"))continue;let u=[".ts",".tsx",".js",".jsx",""],f="";for(let m of u){let h=Qd(i,c+m);if(Jd(h)){f=Yd(h,"utf8");break}}if(f)for(let m of a){let h=new RegExp(`\\bexport\\s+(?:const|let|var|function|class)\\s+${m}\\b`),d=new RegExp(`\\bexport\\s+\\{[^}]*\\b${m}\\b[^}]*\\}`);if(![h,d].some((g)=>g.test(f)))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"import/named",message:`'${m}' not found in '${c}'`,severity:"error"})}}}return t}};import{existsSync as Ia,readFileSync as ep}from"fs";import{dirname as va,resolve as Ma}from"path";var Ca={meta:{docs:"Ensure imports don't create circular dependencies",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=n.filePath,r=new Set,o=new Set;function l(c,u){if(o.has(c))return!0;if(r.has(c))return!1;r.add(c),o.add(c);try{let f=ep(c,"utf8"),m=a(f,va(c));for(let h of m)if(l(h,[...u,h]))return!0}catch{}return o.delete(c),!1}function a(c,u){let f=[],m=/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g,h;for(h=m.exec(c);h!==null;h=m.exec(c)){let d=h[1];if(d.startsWith(".")||d.startsWith("/")){let p=[".ts",".tsx",".js",".jsx",""];for(let y of p){let g=Ma(u,d+y);if(Ia(g)){f.push(g);break}}}}return f}for(let c=0;c<s.length;c++){let f=s[c].match(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/);if(f){let m=f[1];if(m.startsWith(".")||m.startsWith("/")){let h=[".ts",".tsx",".js",".jsx",""],d="";for(let p of h){let y=Ma(va(i),m+p);if(Ia(y)){d=y;break}}if(d){if(r.clear(),o.clear(),o.add(i),l(d,[i,d]))t.push({filePath:n.filePath,line:c+1,column:1,ruleId:"import/no-cycle",message:"Dependency cycle detected",severity:"error"})}}}}return t}};var Sa={meta:{docs:"Disallow duplicate module imports - all imports from the same module should be combined"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=new Map,r=!1;for(let o=0;o<s.length;o++){let l=s[o];if(r){let h=l.indexOf("*/");if(h>=0)l=l.slice(h+2),r=!1;else continue}let a=l.indexOf("/*"),c=l.indexOf("//");if(a>=0&&(c===-1||a<c)){let h=l.indexOf("*/",a+2);if(h>=0)l=l.slice(0,a)+l.slice(h+2);else r=!0,l=l.slice(0,a)}if(c>=0)l=l.slice(0,c);let u=l.trim();if(!u)continue;let f=u.match(/^import\s+(?:type\s+)?(?:\{[^}]*\}|[\w$]+(?:\s*,\s*\{[^}]*\})?|\*\s+as\s+[\w$]+)\s+from\s+(['"`])(.+?)\1/);if(f){let h=f[2];if(i.has(h)){let d=i.get(h);t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"no-duplicate-imports",message:`'${h}' imported multiple times (also imported on line${d.length>1?"s":""} ${d.join(", ")})`,severity:"error",help:`Combine all imports from '${h}' into a single import statement`}),d.push(o+1)}else i.set(h,[o+1])}let m=u.match(/^export\s+(?:type\s+)?(?:\{[^}]*\}|\*(?:\s+as\s+[\w$]+)?)\s+from\s+(['"`])(.+?)\1/);if(m){let h=m[2],d=`export:${h}`;if(i.has(d)){let p=i.get(d);t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"no-duplicate-imports",message:`'${h}' re-exported multiple times (also exported on line${p.length>1?"s":""} ${p.join(", ")})`,severity:"error",help:`Combine all re-exports from '${h}' into a single export statement`}),p.push(o+1)}else i.set(d,[o+1])}}return t}};var Ea={meta:{docs:"Disallow importing from dist directories"},check:(e,n)=>{let t=[],s=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),i=e.split(/\r?\n/);for(let r=0;r<i.length;r++){let o=i[r],l=o.match(s);if(!l)continue;let a=l[1];if(a==="dist"||(a.startsWith(".")||a.startsWith("/"))&&/(?:^|\/)dist(?:\/.|$)/.test(a))t.push({filePath:n.filePath,line:r+1,column:Math.max(1,o.indexOf(a)+1),ruleId:"pickier/no-import-dist",message:`Do not import modules in \`dist\` folder, got ${a}`,severity:"error"})}return t}};var La={meta:{docs:"Disallow importing from node_modules by explicit path"},check:(e,n)=>{let t=[],s=new RegExp(`^\\s*import\\s[^;]*?from\\s*['"]([^'"]+)['"]`,"m"),i=/require\(\s*['"]([^'"]+)['"]\s*\)/,r=e.split(/\r?\n/);for(let o=0;o<r.length;o++){let l=r[o],a=l.match(s),c=l.match(i),u=a?.[1]||c?.[1];if(!u)continue;if(u.includes("/node_modules/")){let f=Math.max(1,l.indexOf(u)+1);t.push({filePath:n.filePath,line:o+1,column:f,ruleId:"pickier/no-import-node-modules-by-path",message:"Do not import modules in `node_modules` folder by path",severity:"error"})}}return t}};import{existsSync as tp}from"fs";import{dirname as np,join as sp,resolve as ip}from"path";var Ta={meta:{docs:"Ensure imports point to a file/module that can be resolved",recommended:!0},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=np(n.filePath);for(let r=0;r<s.length;r++){let o=s[r],l=[...o.matchAll(/\bimport(?:\s{2,}|\s+\S.*?(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))from\s+['"]([^'"]+)['"]/g),...o.matchAll(/\bimport\s*\(\s*['"]([^'"]+)['"]\s*\)/g),...o.matchAll(/\brequire\s*\(\s*['"]([^'"]+)['"]\s*\)/g)];for(let a of l){let c=a[1];if(!c.startsWith(".")&&!c.startsWith("/"))continue;let u=[],f=[".ts",".tsx",".js",".jsx",".mjs",".cjs",""];for(let h of f){let d=ip(i,c+h);u.push(d),u.push(sp(d,`index${h}`))}if(!u.some((h)=>tp(h)))t.push({filePath:n.filePath,line:r+1,column:1,ruleId:"import/no-unresolved",message:`Unable to resolve path to module '${c}'`,severity:"error"})}}return t}};function Aa(e,n,t){let s=t.order==="desc"?-1:1,i=t.type||"alphabetical",r=t.ignoreCase?e.toLowerCase():e,o=t.ignoreCase?n.toLowerCase():n;if(i==="line-length")return(r.length-o.length)*s;if(i==="natural")return r.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})*s;if(i==="unsorted")return 0;return r.localeCompare(o)*s}var rp=new RegExp(`^export\\s+\\{[^}]*\\}\\s+from\\s+['"][^'"]+['"];?\\s*$`);function As(e){return rp.test(e)}var Oa={meta:{docs:"Ensure contiguous export statements are sorted consistently."},check:(e,n)=>{let t=[],s=n.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},i=e.split(/\r?\n/),r=0;while(r<i.length){while(r<i.length&&!As(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(As(a)){o.push({idx:l,line:a}),l++;continue}if(s.partitionByNewLine&&a.trim()==="")break;else break}if(o.length>1){let a=o.map((f)=>f.line),c=[...a].sort((f,m)=>Aa(f,m,s));if(!a.every((f,m)=>f===c[m])){let f=a.findIndex((h,d)=>h!==c[d]),m=o[f]?.idx??o[0].idx;t.push({filePath:n.filePath,line:m+1,column:1,ruleId:"pickier/sort-exports",message:"Export statements are not sorted.",severity:"warning"})}}r=l+1}return t},fix:(e,n)=>{let t=n.config.pluginRules?.["pickier/sort-exports"]?.[1]||{},i=[...e.split(/\r?\n/)],r=0;while(r<i.length){while(r<i.length&&!As(i[r]))r++;if(r>=i.length)break;let o=[],l=r;while(l<i.length){let a=i[l];if(As(a)){o.push(l),l++;continue}if(t.partitionByNewLine&&a.trim()==="")break;else break}if(o.length>1){let a=o.map((f)=>i[f]),c=[...a].sort((f,m)=>Aa(f,m,t));if(!a.every((f,m)=>f===c[m]))o.forEach((f,m)=>{i[f]=c[m]})}r=l+1}return i.join(`
130
+ `)}};var _a={meta:{docs:"Enforce sorted TypeScript heritage clauses (extends/implements lists)"},check:(e,n)=>{let t=n.options||{},s=t.type||"alphabetical",i=t.order||"asc",r=t.ignoreCase!==!1,o=Array.isArray(t.groups)?t.groups:[],l=t.customGroups||{},a=e.split(/\r?\n/),c=[],u=(P)=>i==="asc"?P:-P,f=(P,w)=>(r?P.toLowerCase():P).localeCompare(r?w.toLowerCase():w),m=(P,w)=>(r?P.toLowerCase():P).localeCompare(r?w.toLowerCase():w,void 0,{numeric:!0}),h=(P,w)=>{if(s==="line-length")return u(P.length-w.length);if(s==="natural")return u(m(P,w));if(s==="unsorted")return 0;return u(f(P,w))},d=Object.fromEntries(Object.entries(l).map(([P,w])=>{let A=(Array.isArray(w)?w:[w]).map((O)=>new RegExp(O));return[P,A]})),p=[];for(let P of o)if(Array.isArray(P))p.push(...P);else p.push(P);if(!p.includes("unknown"))p.push("unknown");let y=(P)=>{for(let[w,M]of Object.entries(d))if(M.some((A)=>A.test(P)))return w;return"unknown"},g=(P)=>{let w=[],M=0,A="";for(let O=0;O<P.length;O++){let E=P[O];if(E==="<")M++;else if(E===">")M=Math.max(0,M-1);if(E===","&&M===0){w.push(A.trim()),A="";continue}A+=E}if(A.trim())w.push(A.trim());return w},x=(P)=>{let w=P.trim(),M=w.match(/^([A-Z_$][\w$.]*)/i);return M?M[1]:w},k=(P,w)=>{let M=g(w);if(M.length<=1)return;let A=M.map(x),O=A.map(y),E=A.map((S,C)=>({n:S,g:O[C],i:C})).sort((S,C)=>{let L=p.indexOf(S.g),F=p.indexOf(C.g);if(L!==F)return L-F;return h(S.n,C.n)}).map((S)=>S.n);if(!A.every((S,C)=>S===E[C]))c.push({filePath:n.filePath,line:P,column:1,ruleId:"sort-heritage-clauses",message:"Heritage clauses are not sorted",severity:"warning"})};for(let P=0;P<a.length;P++){let w=a[P],M=w.match(/^\s*interface\s+[A-Za-z_$][^{]*\bextends\s+(.+?)\s*\{/);if(M)k(P+1,M[1]);let A=w.match(/^\s*class\s+[A-Za-z_$][^{]*\bimplements\s+(.+?)\s*\{/);if(A)k(P+1,A[1])}return c}};var Da={meta:{docs:"Require object keys to be sorted (ESLint-compatible core rule subset)"},check:()=>[]};var Fa={meta:{docs:"Enforce sorted named imports within each import statement"},check:(e,n)=>{let t=n.options||{},s=t.type||"alphabetical",i=t.order||"asc",r=t.ignoreCase!==!1,o=Boolean(t.ignoreAlias),l=e.split(/\r?\n/),a=[],c=(u,f)=>{let m=0;if(s==="line-length")m=u.length-f.length;else{let h=r?u.toLowerCase():u,d=r?f.toLowerCase():f;m=h.localeCompare(d)}return i==="asc"?m:-m};for(let u=0;u<l.length;u++){let m=l[u].match(/^\s*import\s+\{([^}]*)\}\s+from\s+['"][^'"]+['"]/);if(!m)continue;let d=m[1].split(",").map((x)=>x.trim()).filter(Boolean);if(d.length<=1)continue;let p=d.map((x)=>{let k=x.replace(/^type\s+/,""),P=k.match(/^([\w$]+)\s+as\s+([\w$]+)$/);if(P)return o?P[2]:P[1];let w=k.match(/^([\w$]+)$/);return w?w[1]:k}),y=[...p].sort(c);if(!p.every((x,k)=>x===y[k]))a.push({filePath:n.filePath,line:u+1,column:1,ruleId:"sort-named-imports",message:"Named imports are not sorted",severity:"warning"})}return a}};var Na={meta:{docs:"Enforce sorted object keys"},check:(e,n)=>{let t=n.options||{},s=t.type||"alphabetical",i=t.order||"asc",r=t.ignoreCase!==!1,o=Boolean(t.partitionByNewLine),l=e.split(/\r?\n/),a=[],c=(f,m)=>{let h=0;if(s==="line-length")h=f.length-m.length;else{let d=r?f.toLowerCase():f,p=r?m.toLowerCase():m;h=d.localeCompare(p)}return i==="asc"?h:-h},u=0;while(u<l.length){let f=l[u],m=f.indexOf("{");if(m!==-1){let h=f.slice(0,m);if(/=\s*$|\(\s*$|\breturn\s*$/.test(h)){let d=0,p=u,y=u;for(;y<l.length;y++){for(let g of l[y])if(g==="{")d++;else if(g==="}")d--;if(d===0)break}if(y>p){let g=l.slice(p+1,y),x=[],k={startLine:p+2,props:[]},P=()=>{if(k.props.length)x.push(k);k={startLine:0,props:[]}};for(let w=0;w<g.length;w++){let M=g[w];if(o&&/^\s*$/.test(M)){P();continue}if(/^\s*\.\.\./.test(M))continue;if(/\{|\}/.test(M))continue;let A=M.match(/^\s*['"]?([\w$-]+)['"]?\s*:/);if(A){if(k.startLine===0)k.startLine=p+2+w;k.props.push({key:A[1],line:p+2+w})}}P();for(let w of x){let M=w.props.map((E)=>E.key),A=[...M].sort(c);if(!(M.length<=1||M.every((E,D)=>E===A[D]))&&w.props.length>0){let E=w.props[0];a.push({filePath:n.filePath,line:E.line,column:1,ruleId:"sort-objects",message:"Object keys are not sorted",severity:"warning"})}}u=y+1;continue}}}u++}return a}};var Wa={meta:{docs:"Enforce top-level functions to use function declarations"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(/^\s+/.test(r))continue;if(/^\s*(?:\/\/|\/\*)/.test(r))continue;let o=r.match(/^const\s+([A-Za-z_$][\w$]*)\s*=(.*)$/);if(!o)continue;let l=o[2].trim();if(/^\(?[A-Z_$,]*(?:\)\s*)?=>/i.test(l)||/^function\b/.test(l)){let a=r.indexOf("const")+1;t.push({filePath:n.filePath,line:i+1,column:a,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"});continue}if(l.trim().length===0||/[,({]$/.test(l.trim())){let a=s[i+1]||"";if(/^\s*(?:\(?[A-Za-z_$,]*(?:\)\s*)?=>|function\b)/.test(a)){let c=r.indexOf("const")+1;t.push({filePath:n.filePath,line:i+1,column:c,ruleId:"pickier/top-level-function",message:"Top-level functions should be declared with function keyword",severity:"warning"})}}}return t}};var op=[[/^(block|inline|inline-block|flex|inline-flex|grid|inline-grid|flow-root|contents|hidden|table|table-caption|table-cell|table-column|table-column-group|table-footer-group|table-header-group|table-row-group|table-row|list-item|subgrid)$/,0],[/^(container|columns|break-after|break-before|break-inside|box-decoration|box-border|box-content|float|clear|isolation|object|overflow|overscroll|position|inset|top|right|bottom|left|start|end|z-|aspect|order)/,1],[/^(static|fixed|absolute|relative|sticky)$/,1],[/^(visible|invisible|collapse)$/,1],[/^(basis|flex-|grow|shrink|order|grid-|col-|row-|auto-cols|auto-rows|gap|justify|items|content|self|place)/,2],[/^(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-/,3],[/^(-?(p|px|py|ps|pe|pt|pr|pb|pl|m|mx|my|ms|me|mt|mr|mb|ml|space|indent)-)/,3],[/^(w-|h-|min-w|max-w|min-h|max-h|size-)/,4],[/^(font|text|tracking|leading|list|placeholder|vertical|whitespace|break|hyphens|content|truncate|overflow-ellipsis|overflow-clip|line-clamp|underline|overline|line-through|no-underline|uppercase|lowercase|capitalize|normal-case|italic|not-italic|ordinal|slashed-zero|lining-nums|oldstyle-nums|proportional-nums|tabular-nums|diagonal-fractions|stacked-fractions|normal-nums|antialiased|subpixel-antialiased)/,5],[/^(bg-|from-|via-|to-|gradient-)/,6],[/^(border|rounded|outline|ring|divide|accent)/,7],[/^(shadow|opacity|mix-blend|bg-blend)/,8],[/^(blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia|backdrop)/,9],[/^(border-collapse|border-separate|border-spacing|table-auto|table-fixed|caption)/,10],[/^(transition|duration|ease|delay|animate)/,11],[/^(scale|rotate|translate|skew|origin|transform|perspective)/,12],[/^(appearance|cursor|caret|pointer-events|resize|scroll|snap|touch|select|will-change)/,13],[/^(fill|stroke)/,14],[/^(sr-only|not-sr-only)$/,15]],lp=/^([a-z0-9][-a-z0-9]{0,50}:)+(?!\[)/;function ap(e){let n=0;while(n<e.length){if(e[n]==="[")break;let t=e.indexOf(":",n);if(t===-1)break;if(e[t+1]==="[")break;n=t+1}return e.slice(n)}function cp(e){let n=ap(e);if(n.startsWith("!"))n=n.slice(1);for(let[t,s]of op)if(t.test(n))return s;return 99}function up(e){let n=e.match(lp);if(!n)return 0;let t=n[0].slice(0,-1).split(":"),s={sm:1,md:2,lg:3,xl:4,"2xl":5},i=10;for(let r of t)if(s[r]!==void 0)i+=s[r];else i+=20;return i}var Ba=new Map;function ja(e){let n=Ba.get(e);if(n)return n;let t={group:cp(e),variant:up(e)};return Ba.set(e,t),t}function tr(e){return[...e].sort((n,t)=>{let s=ja(n),i=ja(t),r=s.group,o=i.group;if(r!==o)return r-o;let l=s.variant,a=i.variant;if(l!==a)return l-a;return n.localeCompare(t)})}var fp=/\b(?:class|className|:class)\s*=\s*(?:"([^"]*?)"|'([^']*?)')/g,mp=/\b(?:class|className|:class)\s*=\s*\{`([^`]*?)`\}/g,hp=/\b(?:clsx|cn|tw|cva|tv)\s*\(\s*(?:"([^"]*?)"|'([^']*?)')/g;function dp(e){let n=e.replace(/\[[^\]]*\]/g,"");if(/['"`]/.test(n))return!0;if(/[{}()=]/.test(n))return!0;if(/ \? | && | \|\| /.test(n))return!0;if(/\b(?:true|false|null|undefined|function|return|typeof|instanceof)\b/.test(n))return!0;return!1}function Ua(e){let n=[];if(!e.includes("class")&&!e.includes("clsx")&&!e.includes("cn(")&&!e.includes("tw(")&&!e.includes("cva(")&&!e.includes("tv("))return n;for(let t of[fp,mp,hp]){t.lastIndex=0;let s;while((s=t.exec(e))!==null){let i=s[1]??s[2]??"";if(!i.trim())continue;if(dp(i))continue;let r=e.indexOf(i,s.index);if(r===-1)continue;n.push({value:i,start:r,end:r+i.length})}}return n.sort((t,s)=>t.start-s.start),n}function za(e){let n=[],t="",s=0;for(let i of e)if(i==="[")s++,t+=i;else if(i==="]")s=Math.max(0,s-1),t+=i;else if(/\s/.test(i)&&s===0){if(t)n.push(t),t=""}else t+=i;if(t)n.push(t);return n}function qa(e){let n=tr(e);return e.every((t,s)=>t===n[s])}var Ka={meta:{docs:"Enforce consistent Tailwind CSS class ordering (layout \u2192 spacing \u2192 typography \u2192 etc.).",recommended:!0,editsStringContent:!0},check:(e,n)=>{let t=[],s=Ua(e);for(let{value:i,start:r}of s){let o=za(i);if(o.length<2)continue;if(!qa(o)){let l=e.slice(0,r),a=(l.match(/\n/g)??[]).length+1,c=l.lastIndexOf(`
131
+ `),u=c===-1?r+1:r-c;t.push({filePath:n.filePath,line:a,column:u,ruleId:"pickier/sort-tailwind-classes",message:`Tailwind classes are not in the recommended order. Expected: "${tr(o).join(" ")}"`,severity:"warning",help:"Run with --fix to automatically sort Tailwind classes, or reorder them manually."})}}return t},fix:(e)=>{let n=Ua(e);if(n.length===0)return e;let t=[...n].reverse(),s=e;for(let{value:i,start:r,end:o}of t){let l=za(i);if(l.length<2||qa(l))continue;let a=tr(l).join(" ");s=s.slice(0,r)+a+s.slice(o)}return s}};var Va={name:"pickier",rules:{"sort-exports":b(Oa),"sort-objects":b(Na),"sort-imports":b(Ts),"sort-named-imports":b(Fa),"sort-heritage-clauses":b(_a),"sort-keys":b(Da),"import-dedupe":b($a),"import-first":b(ka),"import-named":b(Pa),"import-no-cycle":b(Ca),"import-no-unresolved":b(Ta),"no-import-dist":b(Ea),"no-import-node-modules-by-path":b(La),"no-duplicate-imports":b(Sa),"top-level-function":b(Wa),"sort-tailwind-classes":Ka,"prefer-const":b(Ss),"prefer-template":b(Es),"no-unused-vars":b(Ye)}};var Ha={name:"quality",rules:{"default-case":b(Vn),eqeqeq:b(Hn),"no-alert":b(Jn),"no-await-in-loop":b(Yn),"no-caller":b(Xn),"no-case-declarations":b(Qn),"no-else-return":b(es),"no-empty":b(ts),"no-empty-function":b(ns),"no-eval":b(ss),"no-extend-native":b(is),"no-global-assign":b(os),"no-implied-eval":b(ls),"no-iterator":b(as),"no-new":b(cs),"no-new-func":b(us),"no-new-wrappers":b(fs),"no-octal":b(ms),"no-param-reassign":b(hs),"no-proto":b(ds),"no-return-assign":b(ps),"no-shadow":b(ys),"no-throw-literal":b(bs),"no-use-before-define":b(xs),"no-useless-call":b(ws),"no-with":b(Is),"require-await":b(Ms),complexity:b(Kn),"max-depth":b(Zn),"max-lines-per-function":b(Gn),"no-extra-boolean-cast":b(rs),"no-lonely-if":b(Dt),"no-sequences":b(gs),"no-useless-concat":b(Rs),"no-useless-escape":b(ks),"no-useless-rename":b($s),"no-useless-return":b(Ft),"no-var":b(Ps),"prefer-arrow-callback":b(vs)}};var Za={meta:{docs:"Detects potentially super-linear backtracking patterns in regex literals (heuristic)"},check:(e,n)=>{let t=[],s=/\/[^/\\\n]*(?:\\.[^/\\\n]*)*\//g,i=(f,m,h)=>{let d=e.slice(0,f),p=(d.match(/\n/g)||[]).length+1,y=f-d.lastIndexOf(`
132
+ `);t.push({filePath:n.filePath,line:p,column:y,ruleId:"no-super-linear-backtracking",message:h,severity:"error"})},r=[],o=/\/\*[\s\S]*?\*\//g,l;while(l=o.exec(e))r.push({start:l.index,end:l.index+l[0].length});let a=/\/\/[^\n]*/g,c;while(c=a.exec(e))r.push({start:c.index,end:c.index+c[0].length});let u;while(u=s.exec(e)){let f=u[0],m=u.index;if(r.some((x)=>m>=x.start&&m<x.end))continue;if(m>0){let x=e[m-1];if(x===")"||x==="]"||x==="."||/[\w$]/.test(x))continue;let k=f.slice(1,f.lastIndexOf("/"));if(/^\s+\w/.test(k)&&/\w\s*\)/.test(k))continue}let h=f.slice(1,f.lastIndexOf("/")),d=h.replace(/\[.*?\]/g,"");if(d.includes(".+?\\s*")||d.includes("\\s*.+?")||d.includes(".*\\s*")||d.includes("\\s*.*")){i(m,f.length,"The combination of ' .*' or ' .+?' with '\\s*' can cause super-linear backtracking due to exchangeable characters");continue}let y=d.replace(/\s+/g,"");if(/(?:\.\*\??){2,}/.test(y)||/(?:\.\+\??){2,}/.test(y)||/\.\*\??\.\+\?|\.\+\??\.\*\?/.test(y)){i(m,f.length,"Multiple adjacent unlimited wildcard quantifiers can cause super-linear backtracking");continue}let g=h.replace(/\\./g,"_").replace(/\[[^\]]*\]/g,"_");if(/\((?:\?:)?[^)]*?[+*][^)]*\)\s*[+*]/.test(g)){i(m,f.length,"Nested unlimited quantifiers detected (e.g., (.+)+) which can cause catastrophic backtracking");continue}}return t}};function pp(e,n){let t=n-1;while(t>=0&&(e[t]===" "||e[t]==="\t"))t--;let s=t>=0?e[t]:"",i="=(<>!&|?:;,{[+(~^%*/";if(!(t<0||i.includes(s)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test(e.slice(Math.max(0,t-5),t+1))))return null;let o=n+1,l=!1,a=!1,c=-1;while(o<e.length){let p=e[o];if(a)a=!1;else if(p==="\\")a=!0;else if(p==="["){if(!l)l=!0}else if(p==="]"){if(l)l=!1}else if(p==="/"&&!l){c=o;break}else if(p===`
133
+ `)break;o++}if(c<=n)return null;let u=e.slice(n+1,c),f=c+1;while(f<e.length&&/[gimsuvy]/.test(e[f]))f++;if(/\\[1-9]/.test(u))return null;let m=0,h=-1,d=!1;for(let p=0;p<u.length;p++){if(u[p]==="\\"){p++;continue}if(u[p]==="["&&!d){d=!0;continue}if(u[p]==="]"&&d){d=!1;continue}if(d)continue;if(u[p]==="("&&u.slice(p+1,p+3)!=="?:"&&u.slice(p+1,p+3)!=="?="&&u.slice(p+1,p+3)!=="?!"&&u.slice(p+1,p+4)!=="?<="&&u.slice(p+1,p+4)!=="?<!"){if(h<0)h=p;m++}}if(m===0)return null;return{patternStart:n,patternEnd:f,pattern:u,capCount:m,firstCapOffset:h}}function gp(e,n,t){let s=t;while(s<e.length&&(e[s]===" "||e[s]==="\t"))s++;if(e[s]==="."){let a=e.slice(s+1,s+20);if(/^test\s*\(/.test(a))return!1;if(/^exec\s*\(/.test(a))return!0}let i=n-1;while(i>=0&&(e[i]===" "||e[i]==="\t"))i--;if(e[i]==="("){let c=i-1;while(c>=0&&(e[c]===" "||e[c]==="\t"))c--;let u=e.slice(Math.max(0,c-20),c+1);if(/\.match\s*$/.test(u))return!0;if(/\.matchAll\s*$/.test(u))return!0;if(/\.exec\s*$/.test(u))return!0;if(/\.replace\s*$/.test(u))return!0;if(/\.replaceAll\s*$/.test(u))return!0;if(/\.split\s*$/.test(u))return!0;if(/\.search\s*$/.test(u))return!1;if(/\.test\s*$/.test(u))return!1}let r=e.lastIndexOf(`
134
+ `,n)+1,l=e.slice(r,n).trim().match(/(?:const|let|var)\s+(\w+)\s*=\s*$/);if(l){let a=l[1],c=e.slice(t),u=new RegExp(`\\b${a}\\.exec\\s*\\(`),f=new RegExp(`\\b${a}\\.test\\s*\\(`),m=new RegExp(`\\.match(?:All)?\\s*\\(\\s*${a}\\s*\\)`),h=new RegExp(`\\.replace(?:All)?\\s*\\(\\s*${a}`),d=u.test(c),p=m.test(c),y=h.test(c),g=f.test(c);if(d||p||y)return!0;if(g)return!1;return!0}return!0}function yp(e,n){let t=n-1;while(t>=0&&(e[t]===" "||e[t]==="\t"))t--;let s=t>=0?e[t]:"",i="=(<>!&|?:;,{[+(~^%*/";if(!(t<0||i.includes(s)||/\b(?:return|typeof|void|delete|throw|new|in|of|case)\s*$/.test(e.slice(Math.max(0,t-5),t+1))))return n+1;let o=n+1,l=!1,a=!1;while(o<e.length){let c=e[o];if(a)a=!1;else if(c==="\\")a=!0;else if(c==="["){if(!l)l=!0}else if(c==="]"){if(l)l=!1}else if(c==="/"&&!l){o++;while(o<e.length&&/[gimsuvy]/.test(e[o]))o++;return o}else if(c===`
135
+ `)break;o++}return n+1}function bp(e,n){let t=[],s=n.filePath,i=0;while(i<e.length){let r=e[i];if(r==="/"&&e[i+1]==="/"){while(i<e.length&&e[i]!==`
136
+ `)i++;continue}if(r==="/"&&e[i+1]==="*"){i+=2;while(i<e.length-1&&!(e[i]==="*"&&e[i+1]==="/"))i++;i+=2;continue}if(r==="'"||r==='"'||r==="`"){let o=r;i++;while(i<e.length){if(e[i]==="\\"){i+=2;continue}if(e[i]===o){i++;break}i++}continue}if(r==="/"){let o=pp(e,i);if(!o){let l=yp(e,i);if(l>i+1)i=l;else i++;continue}if(!gp(e,o.patternStart,o.patternEnd)){let l=o.patternStart+1+(o.firstCapOffset>=0?o.firstCapOffset:0),a=e.slice(0,l),c=(a.match(/\r?\n/g)||[]).length+1,u=l-(a.lastIndexOf(`
137
+ `)+1)+1;t.push({filePath:s,line:c,column:u,ruleId:"regexp/no-unused-capturing-group",message:"Unused capturing group in regular expression; use non-capturing group (?:...) instead",severity:"error"})}i=o.patternEnd;continue}i++}return t}var Ga={meta:{docs:"Flags regex literals with unused capturing groups (context-aware)",recommended:!1},check(e,n){return bp(e,n)}};var Ja={meta:{docs:"Disallow lazy quantifiers that don't affect the matching behavior",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(r.trim().startsWith("//")||r.trim().startsWith("/*")||r.trim().startsWith("*"))continue;let o=/\/(?![/*])([^/\n\r\\]|\\.)+\/[gimsuvy]*/g,l;for(l=o.exec(r);l!==null;l=o.exec(r)){let a=l[0],c=a.slice(1,a.lastIndexOf("/"));if(/[+*?]\?\$$/.test(c))t.push({filePath:n.filePath,line:i+1,column:l.index+c.search(/[+*?]\?\$$/)+2,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless before end-of-string anchor",severity:"error"});if(/[+*?]\?$/.test(c))t.push({filePath:n.filePath,line:i+1,column:l.index+c.length-1,ruleId:"regexp/no-useless-lazy",message:"Lazy quantifier is useless at the end of the pattern",severity:"error"})}}return t}};var Ya={name:"regexp",rules:{"no-super-linear-backtracking":b(Za),"no-unused-capturing-group":b(Ga),"no-useless-lazy":b(Ja)}};var Xa={meta:{docs:"Use $() instead of backticks for command substitution",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="",o=!1;for(let l=0;l<s.length;l++){let a=s[l];if(i){if(a.trim()===r)i=!1;continue}let c=a.match(/<<-?\s*['"]?(\w+)['"]?/);if(c)i=!0,r=c[1];if(a.replace(/^\s+/,"").startsWith("#"))continue;o=!1;for(let f=0;f<a.length;f++){let m=a[f];if(m==="#"&&!o)break;if(m==="\\"){f++;continue}if(m==="'"){o=!o;continue}if(o)continue;if(m==="`"){t.push({filePath:n.filePath,line:l+1,column:f+1,ruleId:"shell/command-substitution",message:"Use $(...) instead of backticks for command substitution",severity:"error",help:"Replace `cmd` with $(cmd) for better readability and nesting support"});for(f++;f<a.length&&a[f]!=="`";f++)if(a[f]==="\\")f++}}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[],i=!1,r="";for(let o of t){if(i){if(s.push(o),o.trim()===r)i=!1;continue}let l=o.match(/<<-?\s*['"]?(\w+)['"]?/);if(l)i=!0,r=l[1];let a="",c=!1,u=0;while(u<o.length){let f=o[u];if(f==="#"&&!c){a+=o.slice(u);break}if(f==="\\"){a+=o.slice(u,u+2),u+=2;continue}if(f==="'"){c=!c,a+=f,u++;continue}if(c){a+=f,u++;continue}if(f==="`"){let m="";u++;while(u<o.length&&o[u]!=="`")if(o[u]==="\\")m+=o[u+1]||"",u+=2;else m+=o[u],u++;u++,a+=`$(${m})`}else a+=f,u++}s.push(a)}return s.join(`
138
+ `)}};var Qa={meta:{docs:"Require error handling after cd commands",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];let c=l.replace(/^\s+/,"");if(c.startsWith("#"))continue;let u=c.match(/^cd\s+/);if(!u)continue;let f=/\|\||&&/.test(l),m=/^\s*(?:if|elif|while|until)\s/.test(c)||/\bif\s+cd\b/.test(l),h=/\(.*\bcd\b.*\)/.test(l);if(!f&&!m&&!h)t.push({filePath:n.filePath,line:o+1,column:u.index+1,ruleId:"shell/no-cd-without-check",message:"cd without error handling \u2014 if it fails, subsequent commands run in the wrong directory",severity:"warning",help:"Use: cd dir || exit 1 (or || return 1 inside functions)"})}return t}};var ec={meta:{docs:"Disallow use of eval in shell scripts",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;if(l.match(/(?:^|[;&|]\s*|^\s+)eval\s/)){let f=l.indexOf("eval");t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/no-eval",message:"Avoid using eval \u2014 it re-parses arguments and can lead to code injection",severity:"error",help:"Refactor to avoid eval. Consider using arrays for dynamic commands or indirect variable references with ${!var}"})}}return t}};var tc={meta:{docs:"Flag exit inside subshells where it only exits the subshell",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="",o=0;for(let l=0;l<s.length;l++){let a=s[l];if(i){if(a.trim()===r)i=!1;continue}let c=a.match(/<<-?\s*['"]?(\w+)['"]?/);if(c)i=!0,r=c[1];if(a.replace(/^\s+/,"").startsWith("#"))continue;let f=!1,m=!1;for(let h=0;h<a.length;h++){let d=a[h];if(d==="#"&&!f&&!m)break;if(d==="\\"&&!f){h++;continue}if(d==="'"&&!m){f=!f;continue}if(d==='"'&&!f){m=!m;continue}if(!f&&!m){if(d==="("&&h>0&&a[h-1]!=="$"&&a[h+1]!=="(")o++;else if(d==="("&&h===0&&a[h+1]!=="(")o++;else if(d===")"&&o>0&&(h+1>=a.length||a[h+1]!==")"))o--}}if(o>0){let h=a.match(/\bexit\b/);if(h)t.push({filePath:n.filePath,line:l+1,column:h.index+1,ruleId:"shell/no-exit-in-subshell",message:"exit inside a subshell only exits the subshell, not the script",severity:"warning",help:"Restructure to avoid subshells, or use return if inside a function"})}if(o===0){let h=a.match(/(?<!\$)\((?!\()([^)]*\bexit\b[^)]*)\)(?!\))/);if(h){let d=a.indexOf("exit",h.index);t.push({filePath:n.filePath,line:l+1,column:d+1,ruleId:"shell/no-exit-in-subshell",message:"exit inside a subshell only exits the subshell, not the script",severity:"warning",help:"Restructure to avoid subshells, or use return if inside a function"})}}}return t}};var nc={meta:{docs:"Disallow parsing ls output \u2014 use globs or find instead",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;if(l.match(/\bls\b[^|]*\|/)){let h=l.indexOf("ls");t.push({filePath:n.filePath,line:o+1,column:h+1,ruleId:"shell/no-ls-parsing",message:"Don't parse ls output \u2014 filenames can contain special characters",severity:"warning",help:'Use globs (for f in *.txt), find (find . -name "*.txt"), or stat instead'});continue}let f=l.match(/\$\(\s*ls\b/);if(f){let h=f.index+1;t.push({filePath:n.filePath,line:o+1,column:h,ruleId:"shell/no-ls-parsing",message:"Don't use ls in command substitution \u2014 use globs instead",severity:"warning",help:"Replace $(ls *.txt) with glob patterns: for f in *.txt; do ...; done"});continue}let m=l.match(/`\s*ls\b/);if(m){let h=m.index+1;t.push({filePath:n.filePath,line:o+1,column:h,ruleId:"shell/no-ls-parsing",message:"Don't use ls in command substitution \u2014 use globs instead",severity:"warning",help:"Replace `ls` with glob patterns"})}}return t}};var sc={meta:{docs:"Detect useless use of cat (UUOC)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=l.match(/\bcat\s+(["']?[\w.\/~${}*?-]+["']?)\s*\|/);if(u){let f=l.indexOf("cat");t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/no-useless-cat",message:`Useless use of cat \u2014 pipe the file directly instead of \`cat ${u[1]} | ...\``,severity:"warning",help:`Use \`cmd < ${u[1]}\` or pass the file as an argument to the command`})}}return t}};var ic={meta:{docs:"Flag variables inside single quotes where they won't expand",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=!1,f=!1,m=-1;for(let h=0;h<l.length;h++){let d=l[h];if(d==="#"&&!u&&!f)break;if(d==="\\"&&!u){h++;continue}if(d==='"'&&!u){f=!f;continue}if(d==="'"&&!f)if(!u)u=!0,m=h;else{let y=l.slice(m+1,h).match(/\$(?:[A-Za-z_]\w*|\{[^}]+\}|\([^)]*\))/);if(y)t.push({filePath:n.filePath,line:o+1,column:m+1+y.index+1,ruleId:"shell/no-variable-in-single-quotes",message:`Variable ${y[0]} is inside single quotes and won't be expanded`,severity:"warning",help:`Use double quotes if you want variable expansion: "..." instead of '...'`});u=!1}}}return t}};var xp=[/^\s*(?:local|export|declare|typeset|readonly)\s+/,/\[\[.*\]\]/,/\(\(.*\)\)/],nr=/^\$(?:\{[A-Za-z_]\w*(?:[:#%\/][^}]*)?\}|[A-Za-z_]\w*)/,rc={meta:{docs:"Quote variable expansions to prevent word splitting and globbing",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a){if(i=!0,r=a,new RegExp(`<<-?\\s*['"]${a}['"]`).test(l))continue}if(l.replace(/^\s+/,"").startsWith("#"))continue;if(xp.some((m)=>m.test(l)))continue;let u=[],f=0;while(f<l.length){let m=u[u.length-1];if(m==="squote"){if(l[f]==="'")u.pop();f++;continue}if(l[f]==="\\"&&f+1<l.length){f+=2;continue}if(m==="dquote"){let d=l[f];if(d==='"'){u.pop(),f++;continue}if(d==="$"&&l[f+1]==="("&&l[f+2]==="("){u.push("arith"),f+=3;continue}if(d==="$"&&l[f+1]==="("){u.push("subshell"),f+=2;continue}if(d==="$"){let p=l.slice(f).match(nr);if(p){f+=p[0].length;continue}}f++;continue}if(m==="arith"){let d=l[f];if(d===")"&&l[f+1]===")"){u.pop(),f+=2;continue}if(d==="$"){let p=l.slice(f).match(nr);if(p){f+=p[0].length;continue}}f++;continue}let h=l[f];if(h==="#"&&(f===0||/\s/.test(l[f-1])))break;if(h==="'"){u.push("squote"),f++;continue}if(h==='"'){u.push("dquote"),f++;continue}if(h==="$"&&l[f+1]==="("&&l[f+2]==="("){u.push("arith"),f+=3;continue}if(h==="$"&&l[f+1]==="("){u.push("subshell"),f+=2;continue}if(h===")"&&m==="subshell"){u.pop(),f++;continue}if(h==="$"){let d=l.slice(f).match(nr);if(d){let p=d[0];if(!/^\$[?!#@*0-9-]/.test(p))t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/quote-variables",message:`Unquoted variable ${p} \u2014 use "${p}" to prevent word splitting`,severity:"warning",help:`Wrap in double quotes: "${p}"`});f+=p.length;continue}}f++}}return t}};var oc={meta:{docs:"Enforce consistent function declaration style",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];let c=l.replace(/^\s+/,"");if(c.startsWith("#"))continue;let u=c.match(/^function\s+(\w+)\s*(?:\(\s*\))?\s*\{?\s*$/);if(u){let f=u[1],m=l.indexOf("function");t.push({filePath:n.filePath,line:o+1,column:m+1,ruleId:"shell/function-style",message:`Use \`${f}() {\` instead of \`function ${f}\` \u2014 POSIX-compatible style`,severity:"warning",help:`Replace with: ${f}() {`})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.match(/^(\s*)function\s+(\w+)\s*(?:\(\s*\))?\s*(\{?\s*)$/);if(i){let[,r,o,l]=i;t.push(`${r}${o}() ${l||"{"}`)}else t.push(s)}return t.join(`
139
+ `)}};function lc(e,n){if(/^then\b/.test(e)||/^do\b/.test(e)||/^else\b/.test(e))return!0;if(/^if\b/.test(e)&&/\bthen\s*$/.test(e))return!0;if(/^elif\b/.test(e)&&/\bthen\s*$/.test(e))return!0;if(/^(?:while|for|until)\b/.test(e)&&/\bdo\s*$/.test(e))return!0;if(/^case\b/.test(e)&&/\bin\s*$/.test(e))return!0;if(n&&/\)\s*$/.test(e)&&!/\$\(/.test(e)&&!/^\s*\(/.test(e)&&!e.startsWith("#"))return!0;if(/\{\s*$/.test(e)&&!e.startsWith("#"))return!0;return!1}function ac(e){return/^(?:fi|done|esac|elif|else)\b/.test(e)||/^\}/.test(e)||/^;[;&]\s*$/.test(e)}var cc={meta:{docs:"Enforce consistent indentation in shell scripts",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=n.config.format.indent||2,r=0,o=!1,l="",a=!1,c=0;for(let u=0;u<s.length;u++){let f=s[u];if(/^\s*$/.test(f))continue;if(o){if(f.trim()===l)o=!1;continue}let m=f.match(/<<-?\s*['"]?(\w+)['"]?/);if(m)o=!0,l=m[1];let h=f.replace(/^\s+/,"");if(u===0&&h.startsWith("#!"))continue;if(/^case\b/.test(h)&&/\bin\s*$/.test(h))c++,a=!0;if(/^esac\b/.test(h)){if(c=Math.max(0,c-1),c===0)a=!1}if(ac(h))r=Math.max(0,r-1);let d=0;for(let y=0;y<f.length;y++)if(f[y]===" ")d++;else if(f[y]==="\t")d+=i;else break;let p=r*i;if(d!==p&&!h.startsWith("#"))t.push({filePath:n.filePath,line:u+1,column:1,ruleId:"shell/indent",message:`Expected ${p} spaces of indentation, found ${d}`,severity:"warning"});if(lc(h,a))r++}return t},fix(e,n){let t=e.split(/\r?\n/),s=n.config.format.indent||2,i=n.config.format.indentStyle==="tabs",r=[],o=0,l=!1,a="",c=!1,u=0;for(let f=0;f<t.length;f++){let m=t[f];if(/^\s*$/.test(m)){r.push("");continue}if(l){if(r.push(m),m.trim()===a)l=!1;continue}let h=m.match(/<<-?\s*['"]?(\w+)['"]?/);if(h)l=!0,a=h[1];let d=m.replace(/^\s+/,"").trimEnd();if(f===0&&d.startsWith("#!")){r.push(d);continue}if(/^case\b/.test(d)&&/\bin\s*$/.test(d))u++,c=!0;if(/^esac\b/.test(d)){if(u=Math.max(0,u-1),u===0)c=!1}if(ac(d))o=Math.max(0,o-1);let p=i?"\t".repeat(o):" ".repeat(o*s);if(r.push(p+d),lc(d,c))o++}return r.join(`
140
+ `)}};var uc={meta:{docs:"Enforce spacing around shell keywords (if, then, do, else, fi, etc.)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=De(l),f=u.match(/;(?![;\s$])\S/);if(f)t.push({filePath:n.filePath,line:o+1,column:(f.index||0)+1,ruleId:"shell/keyword-spacing",message:"Missing space after semicolon",severity:"warning"});let m=u.match(/\w(then|do|else|elif|fi|done|esac)\b/);if(m&&!/[a-z]/.test(u[m.index])){let h=m[1],d=u[m.index];if(d!==" "&&d!=="\t"&&d!==";")t.push({filePath:n.filePath,line:o+1,column:(m.index||0)+2,ruleId:"shell/keyword-spacing",message:`Missing space before keyword '${h}'`,severity:"warning"})}}return t}};var fc={meta:{docs:"Disallow unnecessary trailing semicolons",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];let c=l.replace(/^\s+/,"").trimEnd();if(c.startsWith("#"))continue;if(/;;\s*$/.test(c))continue;if(/\bfor\b/.test(c)||/\bwhile\b/.test(c)||/\buntil\b/.test(c))continue;if(/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(c))continue;if(/;\s*$/.test(c)){let u=l.lastIndexOf(";");t.push({filePath:n.filePath,line:o+1,column:u+1,ruleId:"shell/no-trailing-semicolons",message:"Unnecessary trailing semicolon",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=!1,i="";for(let r of n){if(s){if(t.push(r),r.trim()===i)s=!1;continue}let o=r.match(/<<-?\s*['"]?(\w+)['"]?/);if(o)s=!0,i=o[1];let l=r.replace(/^\s+/,"").trimEnd();if(l.startsWith("#")||/;;\s*$/.test(l)||/\bfor\b/.test(l)||/\bwhile\b/.test(l)||/\buntil\b/.test(l)||/;\s*(?:then|do|else|elif|fi|done|esac)\s*$/.test(l)){t.push(r);continue}t.push(r.replace(/;\s*$/,""))}return t.join(`
141
+ `)}};var mc={meta:{docs:"Disallow trailing whitespace",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(/[ \t]+$/.test(l)){let c=l.match(/[ \t]+$/);t.push({filePath:n.filePath,line:o+1,column:c.index+1,ruleId:"shell/no-trailing-whitespace",message:"Trailing whitespace",severity:"error"})}}return t},fix(e){let n=e.split(/\r?\n/),t=!1,s="";return n.map((r)=>{if(t){if(r.trim()===s)t=!1;return r}let o=Se(r);if(o)t=!0,s=o;return r.replace(/[ \t]+$/,"")}).join(`
142
+ `)}};var hc={meta:{docs:"Enforce spaces inside [ ] and [[ ]] test expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=De(l);for(let f of wp(u,o+1,n.filePath))t.push(f)}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=!1,i="";for(let r of n){if(s){if(r.trim()===i)s=!1;t.push(r);continue}let o=Se(r);if(o){s=!0,i=o,t.push(r);continue}if(r.replace(/^\s+/,"").startsWith("#")){t.push(r);continue}t.push(Rp(r))}return t.join(`
143
+ `)}};function wp(e,n,t){let s=[],i=/\[\[(?!\s|\]|$)/g;for(let o of e.matchAll(i))s.push({filePath:t,line:n,column:(o.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space after [[",severity:"warning"});let r=/(?<!\s|\[)\]\]/g;for(let o of e.matchAll(r))s.push({filePath:t,line:n,column:(o.index??0)+1,ruleId:"shell/operator-spacing",message:"Missing space before ]]",severity:"warning"});for(let o=0;o<e.length;o++){if(e[o]!=="[")continue;if(e[o+1]==="[")continue;if(o>0&&e[o-1]==="[")continue;if(!dc(e,o))continue;let l=e[o+1];if(l!==void 0&&l!==" "&&l!=="\t")s.push({filePath:t,line:n,column:o+1,ruleId:"shell/operator-spacing",message:"Missing space after [",severity:"warning"})}for(let o=0;o<e.length;o++){if(e[o]!=="]")continue;if(e[o+1]==="]")continue;if(o>0&&e[o-1]==="]")continue;if(!pc(e,o))continue;let l=e[o-1];if(l!==void 0&&l!==" "&&l!=="\t")s.push({filePath:t,line:n,column:o+1,ruleId:"shell/operator-spacing",message:"Missing space before ]",severity:"warning"})}return s}function Rp(e){let n=De(e),t=[];for(let i of n.matchAll(/\[\[(?!\s|\]|$)/g)){let r=(i.index??0)+2;t.push({pos:r,text:" "})}for(let i of n.matchAll(/(?<!\s|\[)\]\]/g)){let r=i.index??0;t.push({pos:r,text:" "})}for(let i=0;i<n.length;i++){if(n[i]!=="[")continue;if(n[i+1]==="[")continue;if(i>0&&n[i-1]==="[")continue;if(!dc(n,i))continue;let r=n[i+1];if(r!==void 0&&r!==" "&&r!=="\t")t.push({pos:i+1,text:" "})}for(let i=0;i<n.length;i++){if(n[i]!=="]")continue;if(n[i+1]==="]")continue;if(i>0&&n[i-1]==="]")continue;if(!pc(n,i))continue;let r=n[i-1];if(r!==void 0&&r!==" "&&r!=="\t")t.push({pos:i,text:" "})}if(t.length===0)return e;t.sort((i,r)=>r.pos-i.pos);let s=e;for(let{pos:i,text:r}of t)s=`${s.slice(0,i)}${r}${s.slice(i)}`;return s}function dc(e,n){let t=n-1;while(t>=0&&(e[t]===" "||e[t]==="\t"))t--;if(t<0)return!0;let s=e[t];if(s===";"||s==="|"||s==="&"||s==="!"||s==="(")return!0;let i=e.slice(0,t+1);if(/(?:^|\s)(?:if|while|until|elif|then|else|do)\s*$/.test(i))return!0;return!1}function pc(e,n){let t=e[n+1];if(t===void 0)return!0;return t===" "||t==="\t"||t===";"||t==="|"||t==="&"||t===")"}var kp=/^#!\s*(?:\/usr\/bin\/env\s+(?:ba|z|k|da)?sh|\/bin\/(?:ba|z|k|da)?sh|\/usr\/bin\/(?:ba|z|k|da)?sh)\b/,gc={meta:{docs:"Ensure shell scripts have a proper shebang line",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);if(s.length===0)return t;let i=s[0];if(s.every((r)=>r.trim()===""))return t;if(!i.startsWith("#!"))return t.push({filePath:n.filePath,line:1,column:1,ruleId:"shell/shebang",message:"Missing shebang line \u2014 shell scripts should start with #!/usr/bin/env bash (or similar)",severity:"warning",help:"Add #!/usr/bin/env bash as the first line"}),t;if(!kp.test(i))t.push({filePath:n.filePath,line:1,column:1,ruleId:"shell/shebang",message:`Invalid shebang: ${i} \u2014 use #!/usr/bin/env bash or #!/bin/sh`,severity:"warning",help:"Use #!/usr/bin/env bash for portability or #!/bin/sh for POSIX scripts"});return t}};var yc={meta:{docs:"Enforce consistent case statement terminator placement",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="",o=[];for(let l of s){if(i){if(l.trim()===r)i=!1;o.push("");continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#")){o.push("");continue}o.push(De(l))}for(let l=0;l<o.length;l++){if(!/\bcase\b[\s\S]*\bin\s*$/.test(o[l].trimEnd()))continue;let a=1,c=-1;for(let h=l+1;h<o.length;h++){let d=o[h].trimEnd();if(/^\s*esac\b/.test(d)){if(a--,a===0){c=h;break}continue}if(/\bcase\b[\s\S]*\bin\s*$/.test(d))a++}if(c===-1)continue;let u=0,f=!1,m=!1;for(let h=l+1;h<c;h++){let d=o[h],p=d.trim();if(p==="")continue;if(u===0){let y=$p(d);if(y!==-1){if(f&&m)t.push({filePath:n.filePath,line:h+1,column:1,ruleId:"shell/consistent-case-terminators",message:"Missing ;; terminator for previous case branch",severity:"warning",help:"Add ;; at the end of the case branch before the next pattern"});f=!0,m=!0;let g=d.slice(y+1).trimEnd();if(/;;\s*$/.test(g))f=!1;continue}}if(u+=Pp(d),u<0)u=0;if(f&&u===0&&/;;\s*$/.test(p))f=!1}}return t}};function $p(e){let n=e.replace(/^\s+/,"");if(n==="")return-1;if(/^(?:for|while|until|if|case|do|then|else|elif|fi|done|esac)\b/.test(n))return-1;let t=e.length-n.length,s=0;if(n[s]==="(")s++;let i=0;while(s<n.length){let r=n[s];if(r==="(")i++;else if(r===")"){if(i===0)return t+s;i--}else if(r===";"||r==="&"||r==="<"||r===">"||r==="=")return-1;s++}return-1}function Pp(e){let n=e.trim();if(n==="")return 0;let t=n.split(/[\s;]+/),s=0;for(let i of t)if(i==="if"||i==="for"||i==="while"||i==="until")s++;else if(i==="fi"||i==="done")s--;return s}var bc={meta:{docs:"Recommend <<- for heredocs inside indented blocks"},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(r.replace(/^\s+/,"").startsWith("#"))continue;if(!r.match(/^\s+/))continue;let c=De(r).match(/(?<!<)<<(?![<-])/);if(!c||c.index===void 0)continue;let f=r.slice(c.index+2).match(/^\s*(['"]?)(\w+)\1\s*$/);if(f){let m=f[2];t.push({filePath:n.filePath,line:i+1,column:c.index+1,ruleId:"shell/heredoc-indent",message:`Use <<- instead of << for indented heredoc (delimiter '${m}' must be at column 0 otherwise)`,severity:"warning",help:"Use <<- to strip leading tabs from heredoc content, allowing proper indentation"})}}return t}};var xc={meta:{docs:"Detect incorrect redirect ordering (2>&1 before > file)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=Se(l);if(a)i=!0,r=a;if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=De(l);if(u.match(/2>&1\s+>(?!&)\s*\S/)){let m=u.indexOf("2>&1");t.push({filePath:n.filePath,line:o+1,column:m+1,ruleId:"shell/no-broken-redirect",message:"Broken redirect: 2>&1 before > file \u2014 stderr goes to terminal, not the file",severity:"error",help:"Swap the order: cmd > file 2>&1 (or use &> file in bash)"})}}return t}};var wc={meta:{docs:"Prefer [[ ]] over [ ] for test expressions in bash/zsh",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/)[0]||"",i=/bash|zsh/.test(s);if(/^#!.*\bsh\b/.test(s)&&!i||!i)return t;let o=e.split(/\r?\n/),l=!1,a="";for(let c=0;c<o.length;c++){let u=o[c];if(l){if(u.trim()===a)l=!1;continue}let f=u.match(/<<-?\s*['"]?(\w+)['"]?/);if(f)l=!0,a=f[1];if(u.replace(/^\s+/,"").startsWith("#"))continue;if(u.match(/(?:^|\s|;)\[\s(?!\[)/)){if(/(?<!\])\](?!\])/.test(u)){let d=u.indexOf("[");t.push({filePath:n.filePath,line:c+1,column:d+1,ruleId:"shell/prefer-double-brackets",message:"Use [[ ]] instead of [ ] for test expressions in bash/zsh",severity:"warning",help:"[[ ]] prevents word splitting and supports && || regex; [ ] is only needed for POSIX sh"})}}}return t},fix(e){let n=e.split(/\r?\n/)[0]||"";if(!/bash|zsh/.test(n))return e;let s=e.split(/\r?\n/),i=[];for(let r of s){let o=r;o=o.replace(/(?:^|(?<=\s|;))\[(\s(?!\[).*?(?<!\]))\](?!\])/g,"[[$1]]"),i.push(o)}return i.join(`
144
+ `)}};var Rc={meta:{docs:"Prefer printf over echo -e and echo -n",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r="";for(let o=0;o<s.length;o++){let l=s[o];if(i){if(l.trim()===r)i=!1;continue}let a=l.match(/<<-?\s*['"]?(\w+)['"]?/);if(a)i=!0,r=a[1];if(l.replace(/^\s+/,"").startsWith("#"))continue;let u=l.match(/\becho\s+-[en]+\b/);if(u){let f=l.indexOf("echo"),m=u[0].replace("echo ","");t.push({filePath:n.filePath,line:o+1,column:f+1,ruleId:"shell/prefer-printf",message:`Use printf instead of echo ${m} \u2014 echo behavior varies across platforms`,severity:"warning",help:'printf is portable: printf "format\\n" args... (use \\n for newline)'})}}return t}};var kc={meta:{docs:"Recommend set -euo pipefail for safer script execution"},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r=!1,o=!1,l=-1,a=!1;for(let u=0;u<s.length;u++){let f=s[u].replace(/^\s+/,"");if(u===0&&f.startsWith("#!")){l=u;continue}if(f.startsWith("#"))continue;if(f==="")continue;if(a=!0,/\bset\s+-\w*e/.test(f))i=!0;if(/\bset\s+-\w*u/.test(f))r=!0;if(/\bset\s+.*-o\s+pipefail/.test(f))o=!0;if(/\bset\s+-euo\s+pipefail/.test(f))i=!0,r=!0,o=!0}if(!a)return t;let c=[];if(!i)c.push("-e");if(!r)c.push("-u");if(!o)c.push("-o pipefail");if(c.length>0)t.push({filePath:n.filePath,line:l>=0?l+2:1,column:1,ruleId:"shell/set-options",message:`Missing shell safety options: set ${c.join(" ")}`,severity:"warning",help:"Add `set -euo pipefail` near the top of the script for safer execution"});return t}};var $c={name:"shell",rules:{"command-substitution":he(Xa),"quote-variables":he(rc),"no-cd-without-check":he(Qa),"no-eval":he(ec),"no-useless-cat":he(sc),"no-ls-parsing":he(nc),"no-variable-in-single-quotes":he(ic),"no-exit-in-subshell":he(tc),shebang:he(gc),indent:he(cc),"function-style":he(oc),"operator-spacing":he(hc),"keyword-spacing":he(uc),"no-trailing-semicolons":he(fc),"no-trailing-whitespace":he(mc),"prefer-double-brackets":he(wc),"set-options":he(kc),"prefer-printf":he(Rc),"consistent-case-terminators":he(yc),"no-broken-redirect":he(xc),"heredoc-indent":he(bc)}};var _s=null,Os=null,sr=!1,ir=!0;function Ip(){if(sr)return ir;try{return _s=(()=>{throw new Error("Cannot require module "+"@stacksjs/ts-spell-check");})(),_s.SpellChecker.create({minWordLength:3,maxSuggestions:3}).then((e)=>{Os=e}).catch(()=>{ir=!1}),sr=!0,!0}catch{return sr=!0,ir=!1,!1}}function rr(e,n){return{meta:{docs:e==="spell/check"?"Check spelling in text content":e==="spell/check-comments"?"Check spelling in code comments only":"Check spelling in markdown files"},check(t,s){if(!Ip()||!_s)return[];let{extractWords:i,parseDirectives:r,isSuppressed:o,getProgrammingWords:l}=_s,a=s.options,c=new Set((a?.words||[]).map((p)=>p.toLowerCase())),u=a?.minWordLength||3,f=l(),m=r(t);for(let p of m)if(p.type==="word")p.words.forEach((y)=>c.add(y.toLowerCase()));let h=t.split(/\r?\n/),d=[];for(let p=0;p<h.length;p++){let y=h[p],g=p+1;if(n&&!n(y))continue;let x=i(y);for(let{word:k,offset:P}of x){if(k.length<u)continue;if(k===k.toUpperCase()&&k.length<=5)continue;if(c.has(k.toLowerCase()))continue;if(f.has(k.toLowerCase()))continue;if(o(k,g,m,c))continue;if(Os){if(Os.isCorrect(k))continue;let w=Os.suggest(k);d.push({filePath:s.filePath,line:g,column:P+1,ruleId:e,message:`Unknown word: "${k}"`,severity:"warning",help:w.length?`Did you mean: ${w.slice(0,3).join(", ")}? Or add to config words.`:`Add "${k}" to your config words array, or use: // spell-check:ignore ${k}`})}}}return d}}}function vp(e){let n=e.trimStart();return n.startsWith("//")||n.startsWith("/*")||n.startsWith("*")||n.startsWith("#")}var Pc={name:"spell",rules:{check:rr("spell/check"),"check-comments":rr("spell/check-comments",vp),"check-markdown":{meta:{docs:"Check spelling in markdown files"},check(e,n){if(!n.filePath.endsWith(".md"))return[];return rr("spell/check-markdown").check(e,n)}}}};function Ic(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var vc={meta:{docs:"Disallow spaces inside array brackets",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]==="["&&!Ic(r,l)){let a=r[l+1];if(a==="]"||a===void 0||a===`
145
+ `)continue;if(a===" "||a==="\t"){if(r.indexOf("]",l+1)!==-1)t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/array-bracket-spacing",message:"Unexpected space after '['",severity:"warning"})}}if(r[l]==="]"&&!Ic(r,l)){let a=l>0?r[l-1]:void 0;if(a==="["||a===void 0)continue;if(a===" "||a==="\t"){if(r.lastIndexOf("[",l-1)!==-1)t.push({filePath:n.filePath,line:i+1,column:l,ruleId:"style/array-bracket-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/\[\s+(\S)/g,(r,o)=>{if(o==="]")return r;return`[${o}`}),i=i.replace(/(\S)\s+\]/g,"$1]"),t.push(i)}return t.join(`
146
+ `)}};var Mc=/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g;function Mp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Cc={meta:{docs:"Require parentheses around arrow function parameters",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Mc.lastIndex=0;while((l=Mc.exec(r))!==null){let a=l.index;if(Mp(r,a))continue;let c=l[1];if(r.slice(0,a).trimEnd().endsWith("("))continue;if(c==="async")continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/arrow-parens",message:`Arrow function parameter '${c}' should be wrapped in parentheses`,severity:"warning"})}}return t},fix(e){return e.replace(/(?<![(\[{,=:?&|+\-*/])\b([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/g,(n,t)=>{if(t==="async")return n;return n.replace(t,`(${t})`)})}};var Ds=/=>/g;function Sc(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Ec={meta:{docs:"Require space before and after => in arrow functions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Ds.lastIndex=0;while((l=Ds.exec(r))!==null){let a=l.index;if(Sc(r,a))continue;if(a>0&&r[a-1]!==" "&&r[a-1]!=="\t")t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/arrow-spacing",message:"Missing space before =>",severity:"warning"});let c=a+2;if(c<r.length&&r[c]!==" "&&r[c]!=="\t"&&r[c]!==`
147
+ `)t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/arrow-spacing",message:"Missing space after =>",severity:"warning"})}}return t},fix(e){let n=e.split(`
148
+ `);for(let t=0;t<n.length;t++){let s=n[t],i=s.trim();if(!i||i.startsWith("//")||i.startsWith("*")||i.startsWith("/*"))continue;let r="",o=0;Ds.lastIndex=0;let l;while((l=Ds.exec(s))!==null){let a=l.index;if(Sc(s,a))continue;let c=s[a-1],u=s[a+2],f=a>0&&c!==" "&&c!=="\t",m=u!==void 0&&u!==" "&&u!=="\t";if(!f&&!m)continue;r+=s.slice(o,a),r+=`${f?" ":""}=>${m?" ":""}`,o=a+2}if(o>0)n[t]=r+s.slice(o)}return n.join(`
149
+ `)}};function or(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Lc={meta:{docs:"Require spaces inside single-line blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!=="{")continue;if(or(r,l))continue;if(l>0&&r[l-1]==="$")continue;let a=1,c=-1;for(let f=l+1;f<r.length;f++){if(r[f]==="{"&&!or(r,f))a++;if(r[f]==="}"&&!or(r,f)){if(a--,a===0){c=f;break}}}if(c===-1)continue;let u=r.slice(l+1,c);if(!u.trim())continue;if(u[0]!==" "&&u[0]!=="\t")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/block-spacing",message:"Missing space after '{'",severity:"warning"});if(u[u.length-1]!==" "&&u[u.length-1]!=="\t")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/block-spacing",message:"Missing space before '}'",severity:"warning"});break}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.replace(/(?<!\$)\{(\S)([^}]*?)(\S)\}/g,(r,o,l,a)=>`{ ${o}${l}${a} }`);i=i.replace(/(?<!\$)\{(\S)([^}]*?)\s\}/g,(r,o,l)=>`{ ${o}${l} }`),i=i.replace(/(?<!\$)\{\s([^}]*?)(\S)\}/g,(r,o,l)=>`{ ${o}${l} }`),t.push(i)}return t.join(`
150
+ `)}};var Tc={meta:{docs:"Enforce consistent brace style for blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].trim();if(o.startsWith("//")||o.startsWith("/*"))continue;if(/\}\s+(?:else|catch|finally)\b/.test(o))t.push({filePath:n.filePath,line:i+1,column:o.indexOf("}")+1,ruleId:"style/brace-style",message:"Closing curly brace appears on the same line as the subsequent block",severity:"error"});if(o==="{"&&i>0){let a=s[i-1].trim();if(!a||a.startsWith("//")||a.startsWith("/*")||a.endsWith("*/"))continue;if(a&&!a.endsWith("{")&&!a.endsWith(",")&&!a.endsWith("(")){if(!a.match(/[=:]\s*$/)&&!a.endsWith("["))t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"style/brace-style",message:"Opening curly brace should be on the same line",severity:"error"})}}}return t}};var Ac=/,\s*$/,Oc=new RegExp("^\\s*[}\\])](?:\\s*;?\\s*)?$"),_c={meta:{docs:"Require trailing commas in multiline constructs",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=1;i<s.length;i++){let o=s[i].trim();if(!Oc.test(o))continue;let l=s[i-1],a=l.trim();if(!a||a==="{"||a==="["||a==="(")continue;if(a.startsWith("//")||a.startsWith("*")||a.startsWith("/*"))continue;if(Ac.test(a))continue;if(a.endsWith("{")||a.endsWith("[")||a.endsWith("("))continue;if(a.endsWith("=>"))continue;t.push({filePath:n.filePath,line:i,column:l.length+1,ruleId:"style/comma-dangle",message:"Missing trailing comma",severity:"warning",help:"Add a trailing comma after the last element in multiline constructs."})}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s];if(s+1<n.length){let r=n[s+1].trim(),o=i.trim();if(Oc.test(r)&&o&&o!=="{"&&o!=="["&&o!=="("&&!o.startsWith("//")&&!o.startsWith("*")&&!o.startsWith("/*")&&!Ac.test(o)&&!o.endsWith("{")&&!o.endsWith("[")&&!o.endsWith("(")&&!o.endsWith("=>")){t.push(i.replace(/(\s*)$/,",$1"));continue}}t.push(i)}return t.join(`
151
+ `)}};function Cp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Dc={meta:{docs:"Require space after commas, disallow space before commas",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!==",")continue;if(Cp(r,l))continue;if(l>0&&r[l-1]===" "){if(r.slice(0,l).trim().length>0)t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/comma-spacing",message:"Unexpected space before comma",severity:"warning"})}if(l+1<r.length&&r[l+1]!==" "&&r[l+1]!=="\t"&&r[l+1]!==`
152
+ `&&r[l+1]!=="\r")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/comma-spacing",message:"Missing space after comma",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/ ,/g,","),i=i.replace(/,(\S)/g,", $1"),t.push(i)}return t.join(`
153
+ `)}};var Fc={meta:{docs:"Enforce comma-last style (commas at the end of lines, not the beginning)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;if(o.startsWith(","))t.push({filePath:n.filePath,line:i+1,column:r.indexOf(",")+1,ruleId:"style/comma-style",message:"Comma should be placed at the end of the previous line",severity:"warning"})}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s],r=i.trim();if(r.startsWith(",")&&t.length>0){let o=t.length-1;t[o]=t[o].replace(/\s*$/,",");let l=i.match(/^(\s*)/)?.[1]||"";t.push(l+r.slice(1).trim())}else t.push(i)}return t.join(`
154
+ `)}};function Sp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Nc={meta:{docs:"Disallow spaces inside computed property brackets [expr]",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!=="[")continue;if(Sp(r,l))continue;if(l===0)continue;let a=r[l-1];if(!/[a-zA-Z0-9_$)\]]/.test(a))continue;if(l+1<r.length&&(r[l+1]===" "||r[l+1]==="\t"))t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/computed-property-spacing",message:"Unexpected space after '['",severity:"warning"});let c=1,u=l+1;while(u<r.length&&c>0){if(r[u]==="[")c++;if(r[u]==="]")c--;if(c>0)u++}if(c===0&&u>0){if(r[u-1]===" "||r[u-1]==="\t")t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"style/computed-property-spacing",message:"Unexpected space before ']'",severity:"warning"})}}}return t},fix(e){return e.replace(/([a-zA-Z0-9_$)\]])\[\s+([\s\S]*?)\s+\]/g,"$1[$2]")}};function Ep(e){let n=[],t=e.split(/\r?\n/),s=0;for(let i=0;i<t.length;i++){let r=t[i],o=/\b[\w$)\]]+\s*\./.test(r),l=i+1<t.length&&/^\s*\./.test(t[i+1]);if(o||l){let a=i,c=i;while(a+1<t.length&&/^\s*\./.test(t[a+1]))a++,c=a;if(c>i){let u=s,f=s+t[i].length+1+t.slice(i+1,c+1).join(`
155
+ `).length;n.push({start:u,end:f}),i=c}}s+=r.length+1}return n}var Wc={meta:{docs:"Enforce consistent line breaks in member-access/call chains"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/),i=Ep(e);for(let{start:r,end:o}of i){let a=e.slice(r,o).split(/\r?\n/),c=[];for(let h=0;h<a.length;h++){let d=a[h],p=[...d.matchAll(/\./g)].map((y)=>y.index||0);for(let y of p){if(y>0&&d[y-1]==="?")continue;if(/^\s*\./.test(d)&&y===d.indexOf(".")&&d.slice(0,y).trim()==="")c.push("newline");else c.push("inline")}}if(c.length<=1)continue;let u=c[0];if(c.every((h)=>h===u))continue;let f=c.findIndex((h)=>h!==u),m=0;for(let h=0;h<a.length;h++){let d=a[h],p=[...d.matchAll(/\./g)].map((y)=>y.index||0);for(let y of p){if(y>0&&d[y-1]==="?")continue;if(m===f){let x=e.slice(0,r).split(/\r?\n/),k=x.length,P=(x[x.length-1]||"").length;t.push({filePath:n.filePath,line:k+h,column:(h===0?P:0)+y+1,ruleId:"style/consistent-chaining",message:`Inconsistent chaining style: mix of ${u} and ${u==="inline"?"newline":"inline"}.`,severity:"warning"}),h=a.length;break}m++}}}return t}};function Bc(e){let n=[0];for(let s=0;s<e.length;s++)if(e[s]===`
156
+ `)n.push(s+1);function t(s){let i=0,r=n.length-1;while(i<=r){let l=i+r>>1,a=n[l],c=l+1<n.length?n[l+1]:1/0;if(s<a)r=l-1;else if(s>=c)i=l+1;else return{line:l+1,column:s-a+1}}let o=n[n.length-1];return{line:n.length,column:Math.max(1,s-o+1)}}return{lineStarts:n,indexToLoc:t}}function jc(e){let n=[],t=(r,o,l)=>n.push({type:r,value:e.slice(o,l),start:o,end:l}),s=0,i=e.length;while(s<i){let r=e[s];if(r<=" "){s++;continue}if(r==="/"&&e[s+1]==="/"){let a=s;s+=2;while(s<i&&e[s]!==`
157
+ `)s++;t("LineComment",a,s);continue}if(r==="/"&&e[s+1]==="*"){let a=s;s+=2;while(s<i&&!(e[s]==="*"&&e[s+1]==="/"))s++;s=Math.min(i,s+2),t("BlockComment",a,s);continue}if(r==='"'||r==="'"){let a=r,c=s;s++;while(s<i){let u=e[s];if(u==="\\"){s+=2;continue}if(u===a){s++;break}s++}t("String",c,s);continue}if(r==="`"){let a=s;s++;let c=0;while(s<i){let u=e[s];if(u==="\\"){s+=2;continue}if(u==="`"&&c===0){s++;break}if(u==="$"&&e[s+1]==="{"){c++,s+=2;continue}if(u==="}"&&c>0){c--,s++;continue}s++}t("Template",a,s);continue}if(r==="/"){if(e[s+1]==="/"){let a=s;s+=2;while(s<i&&e[s]!==`
158
+ `)s++;t("LineComment",a,s);continue}if(e[s+1]==="*"){let a=s;s+=2;while(s<i&&!(e[s]==="*"&&e[s+1]==="/"))s++;s=Math.min(i,s+2),t("BlockComment",a,s);continue}if(Lp(n)){let a=s;s++;while(s<i){let c=e[s];if(c==="\\"){s+=2;continue}if(c==="/"){s++;break}s++}while(s<i&&/[a-z]/i.test(e[s]))s++;t("Regex",a,s);continue}t("Punct",s,s+1),s++;continue}if("(){}[];:,.<>+-*%&|^!?=~".includes(r)){t("Punct",s,s+1),s++;continue}let o=s,l=new RegExp("[^\\s(){}[\\];:,.<>+\\-*%&|^!?=~'\"`/]");while(s<i&&l.test(e[s]))s++;if(s>o)t("Word",o,s);else t("Word",s,s+1),s++}return n}function Lp(e){if(e.length===0)return!0;let n=e[e.length-1],t=new RegExp("[(!,{;:?=]");return n.type==="Punct"&&t.test(n.value)||n.type==="Word"&&/^(?:return|throw|case|of|in|instanceof|typeof|void|new)$/.test(n.value)}function Uc(e,n,t,s){let i=0,r=(f)=>f<=" ",o=(f)=>{while(f<e.length&&e[f]!==`
159
+ `)f++;return f},l=(f)=>{f+=2;while(f<e.length&&!(e[f]==="*"&&e[f+1]==="/"))f++;return Math.min(e.length,f+2)},a=(f,m)=>{let h=e.length;if(m==="`"){f++;let d=0;while(f<h){let p=e[f];if(p==="\\"){f+=2;continue}if(p==="`"&&d===0){f++;break}if(p==="$"&&e[f+1]==="{"){d++,f+=2;continue}if(p==="}"&&d>0){d--,f++;continue}if(p==='"'||p==="'"){f=a(f,p);continue}if(p==="/"&&e[f+1]==="/"){f=o(f+2);continue}if(p==="/"&&e[f+1]==="*"){f=l(f);continue}f++}return f}f++;while(f<h){let d=e[f];if(d==="\\"){f+=2;continue}if(d===m){f++;break}f++}return f},c=(f)=>{let m=f-1;while(m>=0&&r(e[m]))m--;let h=m>=0?e[m]:"";if(new RegExp("[(:[{;?,=!&|^~+\\-*%<>]").test(h))return!0;if(h==="")return!0;return!1},u=(f)=>{f++;let m=e.length;while(f<m){let h=e[f];if(h==="\\"){f+=2;continue}if(h==="/"){f++;break}f++}while(f<m&&/[a-z]/i.test(e[f]))f++;return f};for(let f=n;f<e.length;f++){let m=e[f];if(m===t){i++;continue}if(m===s){if(i--,i===0)return f;continue}if(m==='"'||m==="'"||m==="`"){f=a(f,m)-1;continue}if(m==="/"&&e[f+1]==="/"){f=o(f+2)-1;continue}if(m==="/"&&e[f+1]==="*"){f=l(f)-1;continue}if(m==="/"&&c(f)){f=u(f)-1;continue}}return-1}function Fs(e,n,t,s,i,r,o){let l=Uc(e,s,i,r);if(l<=s)return;let a=e.slice(s+1,l),c=/\r?\n/.test(a),u=Bc(e),f=[],m=0,h=s+1,d=jc(e.slice(s+1,l)),p=0;for(let g of d){let x=s+1+g.start,k=s+1+g.end;if(p=k,g.type==="Punct"){if(g.value===i)m++;else if(g.value===r&&m>0)m--;else if(g.value===","&&m===0)f.push({start:h,end:x}),h=k}}if(f.push({start:h,end:l}),!c){for(let g of f){let x=e.slice(g.start,g.end);if(/\r?\n/.test(x)){let k=u.indexToLoc(g.start);t.push({filePath:n,line:k.line,column:k.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});break}}return}let y=a.indexOf(`
160
+ `);if(y>0){let g=a.slice(0,y),x=(g.match(/,/g)||[]).length,k=a.slice(y+1),P=k.includes(`
161
+ `),w=k.includes(",");if(x>=1&&/\S,\s*\S/.test(g)&&!P&&!w){let M=u.indexToLoc(s+1+y+1);t.push({filePath:n,line:M.line,column:M.column,ruleId:o,message:"Should not have line breaks between items",severity:"warning"});return}else if(x>=1&&/\S,\s*\S/.test(g)){let M=u.indexToLoc(s+1+g.search(/,\s*\S/));t.push({filePath:n,line:M.line,column:M.column,ruleId:o,message:"Should have line breaks between items",severity:"warning"});return}}for(let g of f){let x=e.slice(s+1,g.start);if(!/\n[ \t]*$/.test(x)&&x.trim()!==""){let k=u.indexToLoc(g.start);t.push({filePath:n,line:k.line,column:k.column,ruleId:o,message:"Should have line breaks between items",severity:"warning"});break}}}var zc={meta:{docs:"Enforce consistent newlines for list-like constructs (objects, arrays, named imports/exports)"},check:(e,n)=>{let t=[],s="style/consistent-list-newline";for(let i=0;i<e.length;i++){let r=e[i];if(r==="{"){let o=i-1;while(o>=0&&/[ \t]/.test(e[o]))o--;if(o>=0&&e[o]===")")continue;let l=e.slice(Math.max(0,i-60),i);if(/\b(?:function|class|interface|type|enum|try|catch|finally|if|else|for|while|switch)\b[\s\S]*$/.test(l))continue;Fs(e,n.filePath,t,i,"{","}","style/consistent-list-newline")}else if(r==="[")Fs(e,n.filePath,t,i,"[","]","style/consistent-list-newline");else if(r==="i"&&e.startsWith("import",i)){let o=e.indexOf("{",i);if(o>-1)Fs(e,n.filePath,t,o,"{","}","style/consistent-list-newline")}else if(r==="e"&&e.startsWith("export",i)){let o=e.indexOf("{",i);if(o>-1)Fs(e,n.filePath,t,o,"{","}","style/consistent-list-newline")}}return t}};function Tp(e){let n=e.trim();return n===""||n.startsWith("//")||n.startsWith("/*")}function lr(e,n){for(let t=n;t<e.length;t++)if(!Tp(e[t]))return t;return-1}function Rt(e,n,t){if(e[n].slice(t).includes("{"))return!0;let i=lr(e,n+1);if(i>=0){if(e[i].trim().startsWith("{"))return!0}return!1}function Ns(e,n,t){let s=e[n].slice(t);if(/\bif\b|\bfor\b|\bwhile\b|\bdo\b/.test(s))return!0;return!1}var qc={meta:{docs:"Enforce curly brackets similar to src-2: require braces when any branch/body requires them"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let r=0;r<s.length;r++){let o=s[r],l=o.match(/^(\s*)if\s*\(([^)]*)\)/);if(l){let c=l[0].length,u=Rt(s,r,c),f=Ns(s,r,c),m=r,h=u,d=f;while(!0){let p=lr(s,m+1);if(p<0)break;let y=s[p].trim();if(!y.startsWith("else"))break;let g=y.match(/^else\s+if\s*\(([^)]*)\)/);if(g){let x=s[p].indexOf(g[0])+g[0].length;h=h||Rt(s,p,x),d=d||Ns(s,p,x),m=p;continue}else{let x=s[p].indexOf("else")+4;h=h||Rt(s,p,x),d=d||Ns(s,p,x),m=p;break}}if(h||d){if(!u)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,o.indexOf("if")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});let p=r;while(!0){let y=lr(s,p+1);if(y<0)break;let g=s[y],x=g.trim();if(!x.startsWith("else"))break;let k=x.match(/^else\s+if\s*\(([^)]*)\)/);if(k){let P=g.indexOf(k[0])+k[0].length;if(!Rt(s,y,P))t.push({filePath:n.filePath,line:y+1,column:Math.max(1,g.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});p=y;continue}else{let P=g.indexOf("else")+4;if(!Rt(s,y,P))t.push({filePath:n.filePath,line:y+1,column:Math.max(1,g.indexOf("else")+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"});break}}}}let a=o.match(/^(\s*)(while|do|for|for\s+await)\b/);if(a){let c=a[0].length,u=Rt(s,r,c),f=Ns(s,r,c);if((u||f)&&!u)t.push({filePath:n.filePath,line:r+1,column:Math.max(1,o.indexOf(a[2])+1),ruleId:"style/curly",message:"Expect curly brackets",severity:"warning"})}}let i=Ap(e,n.filePath);for(let r of i)t.push({filePath:n.filePath,line:r.line,column:r.column,ruleId:"style/curly",message:r.message,severity:"warning"});return t}};function Ap(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim(),l=/^if\s*\(/.test(o)?"if":/^else\s+if\s*\(/.test(o)?"else-if":/^else\b/.test(o)?"else":null;if(!l)continue;let a=0;if(l==="if"){let d=r.match(/if\s*\([^)]*\)/);a=d?r.indexOf(d[0])+d[0].length:r.indexOf("if")+2}else if(l==="else-if"){let d=r.match(/else\s+if\s*\([^)]*\)/);a=d?r.indexOf(d[0])+d[0].length:r.indexOf("else")+4}else a=r.indexOf("else")+4;let c=i,u=r.indexOf("{",a);if(u<0){let d=function(y){for(let g=y;g<s.length;g++)if(s[g].trim()!=="")return g;return-1}(i+1);if(d<0)continue;if(u=s[d].indexOf("{"),u<0)continue;c=d}let f=0,m=-1;for(let d=c;d<s.length;d++){let p=s[d],y=d===c?Math.max(0,u):0;for(let g=y;g<p.length;g++){let x=p[g];if(x==="{")f++;else if(x==="}"){if(f--,f===0){m=d;break}}}if(m>=0)break}if(m<0)continue;let h=[];for(let d=c+1;d<m;d++){let p=s[d].trim();if(p===""||/^\/\//.test(p))continue;if(h.push(p),h.length>1)break}if(h.length===1&&m===c+2){let d=h[0],p=/^(?:if|for|while|do|switch|try|catch|else)\b/.test(d),y=/[{}]/.test(d),g=(d.match(/\(/g)||[]).length,x=(d.match(/\)/g)||[]).length,k=g!==x,P=!1;for(let w=i+1;w<s.length;w++){let M=s[w].trim();if(M===""||M==="}"||/^\/\//.test(M))continue;if(!/^else\b/.test(M))break;let A=s[w].indexOf("else")+4,O=M.match(/^else\s+if\s*\([^)]*\)/);if(O)A=s[w].indexOf(O[0])+O[0].length;let E=w,D=s[w].indexOf("{",A);if(D<0){let L=function(T){for(let R=T;R<s.length;R++)if(s[R].trim()!=="")return R;return-1}(w+1);if(L<0)break;if(D=s[L].indexOf("{"),D<0)continue;E=L}let S=0,C=-1;for(let L=E;L<s.length;L++){let F=s[L],T=L===E?Math.max(0,D):0;for(let R=T;R<F.length;R++){let v=F[R];if(v==="{")S++;else if(v==="}"){if(S--,S===0){C=L;break}}}if(C>=0)break}if(C>=0){let L=0;for(let F=E+1;F<C;F++){let T=s[F].trim();if(T===""||/^\/\//.test(T))continue;if(L++,L>1){P=!0;break}}}if(P)break}if(!P&&l==="if"){let w=function(A){for(let O=A;O<s.length;O++){let E=s[O].trim();if(E!==""&&E!=="}"&&!/^\/\//.test(E))return O}return-1}(m+1);if(w>=0&&/^else\b/.test(s[w].trim())){let M=s[w].indexOf("else")+4,A=s[w].trim().match(/^else\s+if\s*\([^)]*\)/);if(A)M=s[w].indexOf(A[0])+A[0].length;let O=w,E=s[w].indexOf("{",M);if(E<0){let D=function(C){for(let L=C;L<s.length;L++)if(s[L].trim()!=="")return L;return-1}(w+1);if(D>=0)E=s[D].indexOf("{"),O=E>=0?D:O}if(E>=0){let D=0,S=-1;for(let C=O;C<s.length;C++){let L=s[C],F=C===O?Math.max(0,E):0;for(let T=F;T<L.length;T++){let R=L[T];if(R==="{")D++;else if(R==="}"){if(D--,D===0){S=C;break}}}if(S>=0)break}if(S>=0){let C=0;for(let L=O+1;L<S;L++){let F=s[L].trim();if(F===""||/^\/\//.test(F))continue;if(++C>1){P=!0;break}}}}}}if(!p&&!y&&!k&&!P)t.push({line:c+1,column:Math.max(1,s[c].indexOf("{")+1),message:"Unnecessary curly braces around single statement"})}}return t}var Kc={meta:{docs:"Enforce dot on the property line in chained method calls",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=Xe(e);for(let r=0;r<s.length;r++){let o=s[r],l=o.trim();if(!l||l.startsWith("//")||l.startsWith("*")||l.startsWith("/*"))continue;if(i[r+1])continue;if(l.endsWith(".")&&r+1<s.length){let a=s[r+1].trim();if(a&&/^[a-zA-Z_$]/.test(a))t.push({filePath:n.filePath,line:r+1,column:o.length,ruleId:"style/dot-location",message:"Dot should be on the same line as the property",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=Xe(e);for(let i=0;i<n.length;i++){let r=n[i];if(r.trim().endsWith(".")&&!s[i+1]&&i+1<n.length){let l=n[i+1],a=l.trim();if(a&&/^[a-zA-Z_$]/.test(a)){t.push(r.replace(/\.\s*$/,""));let c=l.match(/^(\s*)/)?.[1]||"";n[i+1]=`${c}.${a}`;continue}}t.push(r)}return t.join(`
162
+ `)}};function Vc(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Hc=["===","!==",">>>","==","!=",">=","<=","&&","||","??","**","<<",">>","+","-","*","/","%","|","&","^",">","<","instanceof","in"],pv=new RegExp(`^(${Hc.map((e)=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")})\\s`),Op=new Set(["in","instanceof"]),_p=/^(?:instanceof|in)\s/;function Ws(e){if(_p.test(e))return!0;for(let n of Hc){if(Op.has(n))continue;if(e.startsWith(n)){let t=e[n.length];if(t===void 0||t===" "||t==="\t")return!0}}return!1}function ar(e){let n=e.match(/^(\s*)/);return n?n[1].length:0}var Zc={meta:{docs:"Enforce consistent indentation of continuation lines in multiline binary expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;if(!Ws(o))continue;if(Vc(r,0))continue;let l=i-1;while(l>=0){let u=s[l].trim();if(!u||u.startsWith("//")||u.startsWith("*")||u.startsWith("/*")){l--;continue}if(Ws(u)){l--;continue}break}if(l<0)continue;let a=ar(s[l])+2,c=ar(r);if(c!==a)t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/indent-binary-ops",message:`Expected indentation of ${a} spaces for binary operator continuation, but found ${c}`,severity:"warning"})}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}if(!Ws(o)||Vc(r,0)){s.push(r);continue}let l=-1;for(let u=s.length-1;u>=0;u--){let f=s[u].trim();if(!f||f.startsWith("//")||f.startsWith("*")||f.startsWith("/*"))continue;if(Ws(f))continue;l=u;break}if(l<0){s.push(r);continue}let a=ar(s[l])+2,c=" ".repeat(a)+o;s.push(c);continue}return s.join(`
163
+ `)}};var Gc=new Set(["if","for","while","switch","catch","function","return","typeof","void","delete","throw","new","await","class","import","export","from","of","in","case","default","yield","else","do","try","finally","with","async","super","this","extends","implements","instanceof"]),Bs=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g;function Jc(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Yc={meta:{docs:"Disallow spaces between function name and opening parenthesis in calls",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Bs.lastIndex=0;while((l=Bs.exec(r))!==null){let a=l[1],c=l.index;if(Jc(r,c))continue;if(Gc.has(a))continue;let u=r.slice(0,c).trimEnd();if(u.endsWith("function")||u.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(u))continue;let f=c+a.length;t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"style/function-call-spacing",message:"Unexpected space between function name and parenthesis",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}let l=r,a=[],c;Bs.lastIndex=0;while((c=Bs.exec(r))!==null){let u=c[1],f=c.index;if(Jc(r,f))continue;if(Gc.has(u))continue;let m=r.slice(0,f).trimEnd();if(m.endsWith("function")||m.endsWith("function*"))continue;if(/\b(?:get|set)\s*$/.test(m))continue;a.push({index:f,fullMatch:c[0],identifier:u})}for(let u=a.length-1;u>=0;u--){let f=a[u],m=f.index,h=m+f.fullMatch.length;l=`${l.slice(0,m)}${f.identifier}(${l.slice(h)}`}s.push(l)}return s.join(`
164
+ `)}};var Xc=/\bfunction\s*\*/g;function Qc(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var eu={meta:{docs:"Enforce spacing around * in generator functions (space after, no space before)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Xc.lastIndex=0;while((l=Xc.exec(r))!==null){let c=l.index;if(Qc(r,c))continue;let u=l[0],f=c+u.indexOf("*"),m=f+1;if(u!=="function*")t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"style/generator-star-spacing",message:"Unexpected space before * in generator function",severity:"warning"});if(m<r.length&&r[m]!==" "&&r[m]!=="\t"&&r[m]!==`
165
+ `&&r[m]!=="(")t.push({filePath:n.filePath,line:i+1,column:m+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator function",severity:"warning"})}if(o.match(/^(?:async\s+)?\*\s*([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/)){let c=r.indexOf("*",r.indexOf(o.charAt(0)));if(!Qc(r,c)){let u=c+1;if(u<r.length&&r[u]!==" "&&r[u]!=="\t")t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/generator-star-spacing",message:"Missing space after * in generator method",severity:"warning"})}}}return t},fix(e,n){let t=e;return t=t.replace(/\bfunction\s+\*/g,"function*"),t=t.replace(/\bfunction\*([a-zA-Z_$])/g,"function* $1"),t=t.replace(/(^\s*(?:async\s+)?)\*([a-zA-Z_$])/gm,"$1* $2"),t}};var tu={meta:{docs:"Enforce newline after if when without braces"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(!r.match(/^\s*if\s*\([^)]*\)\s*([^\s{/].*)$/))continue;t.push({filePath:n.filePath,line:i+1,column:Math.max(1,r.indexOf("if")+1),ruleId:"style/if-newline",message:"Expect newline after if",severity:"warning"})}return t}};var Dp=["$","unindent","unIndent"],nu={meta:{docs:"Enforce consistent indentation inside unindent-style tagged templates"},check:(e,n)=>{let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/^\s*/)?.[0]??"",l=/([$A-Z_][\w$]*)\s*`/gi,a;while(a=l.exec(r)){let c=a[1];if(!Dp.includes(c))continue;if(r.slice(a.index+a[0].length).includes("`"))continue;let f=-1;for(let h=i+1;h<s.length;h++)if(s[h].includes("`")){f=h;break}if(f<0)continue;let m=`${o} `;for(let h=i+1;h<f;h++){let d=s[h];if(d.trim()==="")continue;let p=d.match(/^\s*/)?.[0]??"";if(!p.startsWith(m)){t.push({filePath:n.filePath,line:h+1,column:(p.length||0)+1,ruleId:"style/indent-unindent",message:"Consistent indentation in unindent tag",severity:"warning"});break}}}}return t}};var Fp=/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/;function su(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var iu={meta:{docs:"Require space after colon in object properties",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=r.match(Fp);if(l){let c=r.indexOf(":",l[1].length);if(c!==-1&&!su(r,c)){let u=r[c+1];if(u&&u!==" "&&u!=="\t"&&u!==`
166
+ `)t.push({filePath:n.filePath,line:i+1,column:c+2,ruleId:"style/key-spacing",message:"Missing space after colon in property",severity:"warning"})}}let a=o.match(/^(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?)\s+:/);if(a&&!o.match(/^\s*(case|default)\b/)){let c=r.indexOf(":",r.indexOf(a[1])+a[1].length);if(c!==-1&&!su(r,c))t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/key-spacing",message:"Unexpected space before colon in property",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/^(\s*)(["']?[a-zA-Z_$][a-zA-Z0-9_$]*["']?\s*(?:\?)?):(\S)/,"$1$2: $3"),t.push(i)}return t.join(`
167
+ `)}};var Np=["if","else","for","while","do","switch","case","return","throw","try","catch","finally","const","let","var","typeof","instanceof","in","of","new","delete","void","yield","await","async","from","import","export","default","class","extends","as","break","continue"],ru=new RegExp(`(?:^|[^\\w$.])(${Np.join("|")})(?=[^\\w$]|$)`,"g");function Wp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var ou={meta:{docs:"Require space before and after keywords",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;ru.lastIndex=0;while((l=ru.exec(r))!==null){let a=l[0].charAt(0)===l[1].charAt(0)?"":l[0].charAt(0),c=l.index+a.length,u=c+l[1].length;if(Wp(r,c))continue;if(c>0){let f=r[c-1];if(f===")"||f==="}")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/keyword-spacing",message:`Missing space before keyword '${l[1]}'`,severity:"warning"})}if(u<r.length){let f=r[u];if(f!==" "&&f!=="\t"&&f!==";"&&f!==","&&f!==":"&&f!=="."){if(f==="("&&(l[1]==="if"||l[1]==="for"||l[1]==="while"||l[1]==="switch"||l[1]==="catch"))t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/keyword-spacing",message:`Missing space after keyword '${l[1]}'`,severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;for(let r of["if","for","while","switch","catch"]){let o=new RegExp(`(\\b${r})\\(`,"g");i=i.replace(o,"$1 (")}for(let r of["else","catch","finally"])i=i.replace(new RegExp(`\\)${r}\\b`,"g"),`) ${r}`),i=i.replace(new RegExp(`\\}${r}\\b`,"g"),`} ${r}`);t.push(i)}return t.join(`
168
+ `)}};var lu=/^\s*(?:public|private|protected|static|readonly|abstract|override|async|get|set|\*|#|[a-zA-Z_$])/,au={meta:{docs:"Require blank line between class members",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=0,l=-1;for(let a=0;a<s.length;a++){let u=s[a].trim();if(u.match(/\bclass\b/)&&(u.includes("{")||a+1<s.length&&s[a+1].trim()==="{"))i=!0,o=r+1;let f=r;for(let m of u){if(m==="{")r++;if(m==="}")r--}if(i&&r<o){i=!1,l=-1;continue}if(!i)continue;if(f>o&&r===o&&u.endsWith("}")){l=a;continue}if(f===o){if(!u||u.startsWith("//")||u.startsWith("*")||u.startsWith("/*")||u==="}")continue;if(lu.test(u)){if(l!==-1&&a===l+1)t.push({filePath:n.filePath,line:a+1,column:1,ruleId:"style/lines-between-class-members",message:"Missing blank line between class members",severity:"warning"});if(!u.endsWith("{"))l=a}}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[],i=!1,r=0,o=0,l=-1;for(let a=0;a<t.length;a++){let c=t[a],u=c.trim();if(u.match(/\bclass\b/)&&(u.includes("{")||a+1<t.length&&t[a+1].trim()==="{"))i=!0,o=r+1;let f=r;for(let m of u){if(m==="{")r++;if(m==="}")r--}if(i&&r<o){i=!1,l=-1,s.push(c);continue}if(i&&f>o&&r===o&&u.endsWith("}")){l=a,s.push(c);continue}if(i&&f===o&&u&&!u.startsWith("//")&&!u.startsWith("*")&&!u.startsWith("/*")&&u!=="}"&&lu.test(u)){if(l!==-1&&a===l+1)s.push("");if(!u.endsWith("{"))l=a}s.push(c)}return s.join(`
169
+ `)}};var cu={meta:{docs:"Limit the number of statements allowed on a single line"},check:(e,n)=>{let t=n.options&&typeof n.options.max==="number"?n.options.max:1,s=[],i=e.split(/\r?\n/),r=(o)=>{let l=Bp(o),a=l>=0?o.slice(0,l):o,c=0,u=!1,f=!1,m=!1,h=!1,d=!1,p=!1,y=!1,g=0,x="",k=(M)=>{if(M===" "||M==="\t")return;x=M};for(let M=0;M<a.length;M++){let A=a[M];if(p){p=!1;continue}if(A==="\\"){p=!0;continue}if(h){if(d){if(A==="]")d=!1;continue}if(A==="["){d=!0;continue}if(A==="/"){h=!1;while(M+1<a.length&&/[a-z]/i.test(a[M+1]))M++;x="/"}continue}if(!f&&!m&&A==="'"){u=!u,k(u?"'":"x");continue}if(!u&&!m&&A==='"'){f=!f,k(f?'"':"x");continue}if(!u&&!f&&A==="`"){m=!m,k(m?"`":"x");continue}if(u||f||m)continue;if(A==="/"&&uu(x,a,M)){h=!0;continue}if(!y){if(A==="f"&&a.slice(M,M+4).match(/^for\b/)){let O=a.slice(M+3).trimStart(),E=a.length-O.length;if(a[E]==="("){y=!0,g=1,M=E,x="(";continue}}}else if(A==="(")g++;else if(A===")"){if(g--,g<=0)y=!1}else if(A===";"){k(A);continue}if(A===";")c++;k(A)}if(c===0)return 1;return a.trimEnd().endsWith(";")?c:c+1};for(let o=0;o<i.length;o++){let l=i[o];if(/^\s*$/.test(l))continue;let a=r(l);if(a>t)s.push({filePath:n.filePath,line:o+1,column:1,ruleId:"max-statements-per-line",message:`This line has ${a} statements. Maximum allowed is ${t}`,severity:"warning"})}return s}};function Bp(e){let n=!1,t=!1,s=!1,i=!1,r=!1,o=!1,l="";for(let a=0;a<e.length;a++){let c=e[a];if(o){o=!1;continue}if(c==="\\"){o=!0;continue}if(i){if(r){if(c==="]")r=!1;continue}if(c==="["){r=!0;continue}if(c==="/"){i=!1;while(a+1<e.length&&/[a-z]/i.test(e[a+1]))a++;l="/"}continue}if(!t&&!s&&c==="'"){n=!n,l=c;continue}if(!n&&!s&&c==='"'){t=!t,l=c;continue}if(!n&&!t&&c==="`"){s=!s,l=c;continue}if(n||t||s)continue;if(c==="/"&&e[a+1]==="/")return a;if(c==="/"&&uu(l,e,a)){i=!0;continue}if(c!==" "&&c!=="\t")l=c}return-1}function uu(e,n,t){if(e==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes(e))return!0;if(/[A-Za-z_$]/.test(e)){if(n.slice(0,t).trimEnd().match(/(?:^|[^A-Za-z0-9_$])(return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/))return!0}return!1}function fu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var mu={meta:{docs:"Enforce consistent multiline ternary expressions",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=r.indexOf("?");if(l===-1)continue;if(r[l+1]==="."||r[l+1]==="?")continue;if(fu(r,l))continue;if(r.indexOf(":",l+1)!==-1)continue;for(let c=i+1;c<Math.min(i+10,s.length);c++){let u=s[c].trim();if(u.startsWith(":"))break;let f=u.indexOf(":");if(f>0&&!fu(s[c],f)){if(u.match(/^\w+\s*:/)||u.match(/^case\b/))continue;t.push({filePath:n.filePath,line:c+1,column:s[c].indexOf(":")+1,ruleId:"style/multiline-ternary",message:"In multiline ternary, ':' should be at the start of the line",severity:"warning"});break}}}return t}};var hu=new RegExp("\\bnew\\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(?:\\s*<[^>]*>)?\\s*(?=[^(;\\n]|$)","g");function jp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var du={meta:{docs:"Require parentheses when invoking a constructor with no arguments",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;hu.lastIndex=0;while((l=hu.exec(r))!==null){if(jp(r,l.index))continue;if(r.slice(l.index+l[0].length).startsWith("("))continue;if(l[0].includes("new."))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"style/new-parens",message:`Missing parentheses invoking constructor '${l[1]}'`,severity:"warning",help:"Add () after the constructor name."})}}return t},fix(e){return e.replace(/\bnew\s+([A-Z][a-zA-Z0-9_$.]+)(?![a-zA-Z0-9_$])(\s*<[^>]*>)?\s*(?=[^(]|$)/g,(n,t,s)=>{if(n.slice(n.indexOf(t)+t.length+(s?.length||0)).trim().startsWith("("))return n;return`new ${t}${s||""}()`})}};var Mv=new RegExp("\\breturn\\s+\\(([^()]*)\\)\\s*[;\\n]","g"),pu=/^[a-zA-Z_$][a-zA-Z0-9_$.[\]'"`]*$/;var gu={meta:{docs:"Remove redundant parentheses in return statements",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=new RegExp("^return\\s+\\(([^()]*)\\)\\s*;?\\s*$"),a=o.match(l);if(a){let c=a[1].trim();if(pu.test(c)||/^['"`]/.test(c)||/^\d/.test(c)||c==="true"||c==="false"||c==="null"||c==="undefined")t.push({filePath:n.filePath,line:i+1,column:r.indexOf("(")+1,ruleId:"style/no-extra-parens",message:"Unnecessary parentheses around return value",severity:"warning",help:"Remove the outer parentheses."})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.trim(),r=new RegExp("^return\\s+\\(([^()]*)\\)\\s*(;?)\\s*$"),o=i.match(r);if(o){let l=o[1].trim(),a=o[2];if(pu.test(l)||/^['"`]/.test(l)||/^\d/.test(l)||l==="true"||l==="false"||l==="null"||l==="undefined"){let c=s.match(/^(\s*)/)?.[1]||"";t.push(`${c}return ${l}${a}`);continue}}t.push(s)}return t.join(`
170
+ `)}};var yu=/(\S)\s+(\.)[a-zA-Z_$]/g,bu=/(\S)\s+(\?\.)[a-zA-Z_$]/g;function js(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var xu={meta:{docs:"Disallow whitespace before . or ?. in property access",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;yu.lastIndex=0;while((l=yu.exec(r))!==null){let a=l.index+l[0].indexOf(".");if(js(r,l.index))continue;if(a+1<r.length&&r[a+1]===".")continue;if(a>0&&r[a-1]===".")continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before property access dot",severity:"warning"})}bu.lastIndex=0;while((l=bu.exec(r))!==null){let a=l.index+l[0].indexOf("?.");if(js(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"style/no-whitespace-before-property",message:"Unexpected whitespace before optional chaining operator",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}let l=r;l=l.replace(/(\S)\s+(\?\.[a-zA-Z_$])/g,(a,c,u,f)=>{if(js(r,f))return a;return c+u}),l=l.replace(/(\S)\s+(\.[a-zA-Z_$])/g,(a,c,u,f)=>{if(js(r,f))return a;let m=f+a.indexOf(".");if(m+1<l.length&&l[m+1]===".")return a;return c+u}),s.push(l)}return s.join(`
171
+ `)}};function kt(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var wu=/&&/g,Ru=/\|\|/g,ku=/\?\?/g,$u=/(?<![&])&(?![&=])/g,Pu=/(?<![|])\|(?![|=])/g,Iu=/\^(?!=)/g;function Up(e){let n=[];wu.lastIndex=0;let t;while((t=wu.exec(e))!==null)if(!kt(e,t.index))n.push({op:"&&",group:0,index:t.index});Ru.lastIndex=0;while((t=Ru.exec(e))!==null)if(!kt(e,t.index))n.push({op:"||",group:1,index:t.index});ku.lastIndex=0;while((t=ku.exec(e))!==null)if(!kt(e,t.index))n.push({op:"??",group:2,index:t.index});$u.lastIndex=0;while((t=$u.exec(e))!==null)if(!kt(e,t.index))n.push({op:"&",group:3,index:t.index});Pu.lastIndex=0;while((t=Pu.exec(e))!==null)if(!kt(e,t.index))n.push({op:"|",group:4,index:t.index});Iu.lastIndex=0;while((t=Iu.exec(e))!==null)if(!kt(e,t.index))n.push({op:"^",group:5,index:t.index});return n.sort((s,i)=>s.index-i.index)}function zp(e,n){if(n.length<2)return!0;let t=[];for(let r of n){let o=0;for(let l=0;l<r.index;l++)if(e[l]==="(")o++;else if(e[l]===")")o--;t.push(o)}let s=new Map;for(let r=0;r<n.length;r++){let o=n[r].group;if(!s.has(o))s.set(o,[]);s.get(o).push(t[r])}let i=[...s.entries()];if(i.length===2){let[,r]=i[0],[,o]=i[1],l=Math.min(...r),a=Math.max(...r),c=Math.min(...o),u=Math.max(...o);if(l>u||c>a)return!0}return!1}var qp=[{groups:[0,1],label:"&& and ||"},{groups:[0,2],label:"&& and ??"},{groups:[1,2],label:"|| and ??"},{groups:[3,4],label:"& and |"},{groups:[3,5],label:"& and ^"},{groups:[4,5],label:"| and ^"}],vu={meta:{docs:"Disallow mixed logical/bitwise operators without parentheses",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=Up(r);if(l.length<2)continue;let a=new Set(l.map((c)=>c.group));for(let c of qp)if(a.has(c.groups[0])&&a.has(c.groups[1])){let u=l.filter((f)=>f.group===c.groups[0]||f.group===c.groups[1]);if(!zp(r,u)){let f=u.find((m)=>m.group===c.groups[1]);if(f)t.push({filePath:n.filePath,line:i+1,column:f.index+1,ruleId:"style/no-mixed-operators",message:`Unexpected mix of ${c.label} without parentheses`,severity:"warning"})}}}return t}};var Mu=/(?<![0-9.])\.\d/g,Cu=/\d\.(?!\d|\.|\w)/g;function Su(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Eu={meta:{docs:"Disallow floating decimals like .5 or 2.",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Mu.lastIndex=0;while((l=Mu.exec(r))!==null){if(Su(r,l.index))continue;if(l.index>0){let a=r[l.index-1];if(/[a-zA-Z_$)\]]/.test(a))continue}t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected leading decimal point",severity:"warning",help:"Add a leading 0 before the decimal point: 0.5 instead of .5"})}Cu.lastIndex=0;while((l=Cu.exec(r))!==null){if(Su(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+1,ruleId:"style/no-floating-decimal",message:"Unexpected trailing decimal point",severity:"warning",help:"Add a trailing 0 after the decimal point: 2.0 instead of 2."})}}return t},fix(e){let n=e;return n=n.replace(/(?<![a-zA-Z_$0-9.)\]])\.\d/g,(t)=>`0${t}`),n=n.replace(/(\d)\.(?!\d|\.|\w)/g,(t,s)=>`${s}.0`),n}};var Lu={meta:{docs:"Disallow mixed spaces and tabs for indentation",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].match(/^(\s*)/)?.[1]||"";if(!o)continue;let l=o.includes("\t"),a=o.includes(" ");if(l&&a)t.push({filePath:n.filePath,line:i+1,column:1,ruleId:"style/no-mixed-spaces-and-tabs",message:"Mixed spaces and tabs in indentation",severity:"warning",help:"Use either spaces or tabs for indentation, not both."})}return t}};var Tu={meta:{docs:"Disallow multiple consecutive spaces",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];if(!r.trim())continue;let o=r.match(/^(\s*)/)?.[1]||"",l=r.slice(o.length),a=/ {2,}/g,c;for(c=a.exec(l);c!==null;c=a.exec(l)){let u=o.length+c.index+1,f=l.slice(0,c.index),m=(f.match(/'/g)||[]).length,h=(f.match(/"/g)||[]).length,d=(f.match(/`/g)||[]).length;if(m%2===1||h%2===1||d%2===1)continue;if(f.includes("//"))continue;if(r.trim().startsWith("*")||r.trim().startsWith("/*"))continue;t.push({filePath:n.filePath,line:i+1,column:u,ruleId:"style/no-multi-spaces",message:"Multiple spaces found",severity:"warning",help:"Remove extra spaces. Use single spaces between tokens."})}}return t}};var Au={meta:{docs:"Disallow multiple consecutive blank lines",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=0,r=-1;for(let o=0;o<s.length;o++)if(s[o].trim()===""){if(i++,r===-1)r=o;if(i>1&&o===r+i-1)t.push({filePath:n.filePath,line:o+1,column:1,ruleId:"style/no-multiple-empty-lines",message:"More than 1 blank line not allowed",severity:"error",help:"Remove extra blank lines. Maximum 1 consecutive blank line allowed."})}else i=0,r=-1;return t}};var Ou={meta:{docs:"Disallow tab characters (when using spaces for indentation)",recommended:!1},check(e,n){let t=[];if(n.config.format?.indentStyle==="tabs")return t;let s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].indexOf("\t");if(o!==-1)t.push({filePath:n.filePath,line:i+1,column:o+1,ruleId:"style/no-tabs",message:"Unexpected tab character",severity:"warning",help:"Use spaces for indentation instead of tabs."})}return t},fix(e,n){let t=n.config.format?.indent??2;return e.replace(/\t/g," ".repeat(t))}};var _u={meta:{docs:"Disallow trailing whitespace at the end of lines",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.match(/(\s+)$/);if(o){let l=r.length-o[1].length+1;t.push({filePath:n.filePath,line:i+1,column:l,ruleId:"style/no-trailing-spaces",message:"Trailing spaces not allowed",severity:"error",help:"Remove trailing whitespace from the end of this line."})}}return t}};function Du(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Fu={meta:{docs:"Require spaces inside curly braces in objects and destructuring",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]==="{"&&!Du(r,l)){let a=r[l+1];if(a==="}"||a===void 0||a===`
172
+ `)continue;if(l>0&&r[l-1]==="$")continue;if(a!==" "&&a!=="\t")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/object-curly-spacing",message:"Missing space after '{'",severity:"warning"})}if(r[l]==="}"&&!Du(r,l)){let a=l>0?r[l-1]:void 0;if(a==="{"||a===void 0||a===`
173
+ `)continue;if(l+1<r.length&&r.slice(l+1).match(/^[^}]*\$\{/))continue;if(a!==" "&&a!=="\t")t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/object-curly-spacing",message:"Missing space before '}'",severity:"warning"})}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/(?<!\$)\{(\S)/g,(r,o)=>{if(o==="}")return r;return`{ ${o}`}),i=i.replace(/(\S)\}/g,(r,o)=>{if(o==="{"||o==="$")return r;return`${o} }`}),t.push(i)}return t.join(`
174
+ `)}};var Nu=/(\&\&|\|\||\?\?|\?|\+|(?<!=)-(?!=)|\*|\/|%|\*\*|\|(?!\|)|&(?!&)|\^|<<|>>>?)\s*$/;function Wu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Bu={meta:{docs:"Enforce operators at the beginning of continued lines",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=o.match(Nu);if(l&&i+1<s.length){let a=s[i+1].trim();if(a&&!a.startsWith("//")&&!a.startsWith("*")){let c=r.lastIndexOf(l[1]);if(!Wu(r,c)){if(l[1]==="?"||l[1]===":")continue;t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/operator-linebreak",message:`Operator '${l[1]}' should be at the beginning of the next line`,severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s=0;s<n.length;s++){let i=n[s],r=i.trim();if(!r||r.startsWith("//")||r.startsWith("*")||r.startsWith("/*")||r.endsWith("*/")){t.push(i);continue}let o=r.match(Nu);if(o&&s+1<n.length&&o[1]!=="?"&&o[1]!==":"){let l=n[s+1],a=l.trim();if(a&&!a.startsWith("//")&&!a.startsWith("*")){let c=o[1],u=i.lastIndexOf(o[1]);if(Wu(i,u)){t.push(i);continue}t.push(i.replace(new RegExp(`\\s*${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`),""));let f=l.match(/^(\s*)/)?.[1]||"";n[s+1]=`${f}${c} ${a}`;continue}}t.push(i)}return t.join(`
175
+ `)}};var ju={meta:{docs:"Disallow empty lines at the beginning and end of blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let o=s[i].trim();if(o.endsWith("{")&&i+1<s.length){if(s[i+1].trim()==="")t.push({filePath:n.filePath,line:i+2,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line after opening brace",severity:"warning"})}if(o==="}"&&i>0){if(s[i-1].trim()==="")t.push({filePath:n.filePath,line:i,column:1,ruleId:"style/padded-blocks",message:"Unexpected empty line before closing brace",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=new Set;for(let s=0;s<n.length;s++){let i=n[s].trim();if(i.endsWith("{")&&s+1<n.length&&n[s+1].trim()==="")t.add(s+1);if(i==="}"&&s>0&&n[s-1].trim()==="")t.add(s-1)}return n.filter((s,i)=>!t.has(i)).join(`
176
+ `)}};var cr=/^(\s*)(["'])([a-zA-Z_$][a-zA-Z0-9_$]*)\2\s*:/;var Uu={meta:{docs:"Remove unnecessary quotes from object property keys",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=r.match(cr);if(l){let a=l[3];if(["class","return","function","var","let","const","delete","typeof","void","in","instanceof","new","this","throw","try","catch","finally","switch","case","default","break","continue","do","while","for","if","else","with","import","export","extends","super","yield","await","enum","implements","interface","package","private","protected","public","static"].includes(a))continue;t.push({filePath:n.filePath,line:i+1,column:r.indexOf(l[2])+1,ruleId:"style/quote-props",message:`Unnecessarily quoted property '${a}'`,severity:"warning",help:"Remove quotes from this property key."})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=new Set(["class","return","function","var","let","const","delete","typeof","void","in","instanceof","new","this","throw","try","catch","finally","switch","case","default","break","continue","do","while","for","if","else","with","import","export","extends","super","yield","await","enum","implements","interface","package","private","protected","public","static"]);for(let i of n){let r=i,o=i.match(cr);if(o&&!s.has(o[3]))r=i.replace(cr,"$1$3:");t.push(r)}return t.join(`
177
+ `)}};function Kp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var zu=/\.\.\.\s+([a-zA-Z_$])/g,qu={meta:{docs:"Disallow space after spread/rest operator (...)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;zu.lastIndex=0;while((l=zu.exec(r))!==null){if(Kp(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+4,ruleId:"style/rest-spread-spacing",message:"Unexpected space after spread operator",severity:"warning"})}}return t},fix(e){return e.replace(/\.\.\.\s+([a-zA-Z_$\[{])/g,"...$1")}};function Vp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Ku={meta:{docs:"Disallow space before semicolons, require space after",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]!==";")continue;if(Vp(r,l))continue;if(l>0&&r[l-1]===" "){if(r.slice(0,l).trim().length>0)t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/semi-spacing",message:"Unexpected space before semicolon",severity:"warning"})}if(l+1<r.length&&r[l+1]!==" "&&r[l+1]!=="\t"&&r[l+1]!==`
178
+ `&&r[l+1]!=="\r"&&r[l+1]!==")"){let a=r.slice(l+1);if(r.slice(0,l).includes(";")||a.includes(";"))t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/semi-spacing",message:"Missing space after semicolon",severity:"warning"})}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s,r=new RegExp(" ;","g");i=i.replace(r,String.fromCharCode(59));let o=new RegExp(";(\\S)","g");i=i.replace(o,(l,a)=>{if(a===";"||a===")")return l;return`; ${a}`}),t.push(i)}return t.join(`
179
+ `)}};var Vu=/(\S)\{/g;function Hp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Hu={meta:{docs:"Require space before opening brace of blocks",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Vu.lastIndex=0;while((l=Vu.exec(r))!==null){let a=l.index,c=l[1];if(Hp(r,a))continue;if(c==="$")continue;if(c==="="||c===":"||c==="("||c===","||c==="[")continue;if(c==="{")continue;if(c===")"||/[a-zA-Z0-9_]/.test(c))t.push({filePath:n.filePath,line:i+1,column:l.index+2,ruleId:"style/space-before-blocks",message:"Missing space before '{'",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s.replace(/([)a-zA-Z0-9_])\{/g,"$1 {");t.push(i)}return t.join(`
180
+ `)}};var Zu=/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,Gu=/\bfunction\(/g;function Ju(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Yu={meta:{docs:"Control spacing before ( in function declarations",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Zu.lastIndex=0;while((l=Zu.exec(r))!==null){if(Ju(r,l.index))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+l[0].length,ruleId:"style/space-before-function-paren",message:"Unexpected space before function parentheses",severity:"warning"})}Gu.lastIndex=0;while((l=Gu.exec(r))!==null){if(Ju(r,l.index))continue;if(r.slice(0,l.index+8).match(/function\s+[a-zA-Z_$]/))continue;t.push({filePath:n.filePath,line:i+1,column:l.index+9,ruleId:"style/space-before-function-paren",message:"Missing space before function parentheses",severity:"warning"})}}return t},fix(e){let n=e;return n=n.replace(/\bfunction\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+\(/g,"function $1("),n=n.replace(/\bfunction\(/g,"function ("),n}};function Xu(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Qu={meta:{docs:"Disallow spaces inside parentheses",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l=0;l<r.length;l++){if(r[l]==="("&&!Xu(r,l)){let a=r[l+1];if(a===")"||a===void 0||a===`
181
+ `)continue;if(a===" ")t.push({filePath:n.filePath,line:i+1,column:l+2,ruleId:"style/space-in-parens",message:"Unexpected space after '('",severity:"warning"})}if(r[l]===")"&&!Xu(r,l)){if(l===0)continue;let a=r[l-1];if(a==="(")continue;if(a===" "){if(r.slice(0,l).includes("("))t.push({filePath:n.filePath,line:i+1,column:l,ruleId:"style/space-in-parens",message:"Unexpected space before ')'",severity:"warning"})}}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/\(\s+(\S)/g,"($1"),i=i.replace(/(\S)\s+\)/g,"$1)"),t.push(i)}return t.join(`
182
+ `)}};var ef=["&&","||","??","+=","-=","*=","/=","%=","**=","<<=",">>=",">>>=","&=","|=","^=","??=","||=","&&="];function Zp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var tf={meta:{docs:"Require spacing around infix operators (&&, ||, ??, assignment operators)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let l of ef){let a=0,c;while((c=r.indexOf(l,a))!==-1){if(a=c+l.length,Zp(r,c))continue;if(l==="&&"&&r[c+2]==="=")continue;if(l==="||"&&r[c+2]==="=")continue;if(l==="??"&&r[c+2]==="=")continue;let u=c>0?r[c-1]:" ",f=c+l.length<r.length?r[c+l.length]:" ";if(u!==" "&&u!=="\t")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/space-infix-ops",message:`Missing space before '${l}'`,severity:"warning"});if(f!==" "&&f!=="\t"&&f!==`
183
+ `&&f!=="\r")t.push({filePath:n.filePath,line:i+1,column:c+l.length+1,ruleId:"style/space-infix-ops",message:`Missing space after '${l}'`,severity:"warning"})}}}return t},fix(e){let n=e,t=[...ef].sort((s,i)=>i.length-s.length);for(let s of t){let i=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=n.replace(new RegExp(`(\\S)${i}`,"g"),`$1 ${s}`),n=n.replace(new RegExp(`${i}(\\S)`,"g"),`${s} $1`)}return n}};var nf=["typeof","void","delete","new","throw","yield","await"];function ur(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var sf={meta:{docs:"Require space after word unary operators, disallow space after symbol unary operators",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;for(let u of nf){let f=new RegExp(`\\b${u}([^\\s;,)])`,"g"),m;while((m=f.exec(r))!==null){if(ur(r,m.index))continue;t.push({filePath:n.filePath,line:i+1,column:m.index+u.length+1,ruleId:"style/space-unary-ops",message:`Missing space after '${u}'`,severity:"warning"})}}let l=/!\s+([a-zA-Z_$({[])/g,a;while((a=l.exec(r))!==null){if(ur(r,a.index))continue;let u=r.slice(0,a.index),f=u.trimEnd().slice(-1),m=new RegExp("[=(<[{,;|&?:+\\-*/!~^%]");if(!f||m.test(f)||u.trimEnd().endsWith("return")||u.trimEnd().endsWith("case"))t.push({filePath:n.filePath,line:i+1,column:a.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '!'",severity:"warning"})}let c=/~\s+([a-zA-Z_$({[])/g;while((a=c.exec(r))!==null){if(ur(r,a.index))continue;t.push({filePath:n.filePath,line:i+1,column:a.index+2,ruleId:"style/space-unary-ops",message:"Unexpected space after '~'",severity:"warning"})}}return t},fix(e){let n=e;for(let t of nf)n=n.replace(new RegExp(`\\b${t}([^\\s;,)])`,"g"),`${t} $1`);return n=n.replace(/!\s+([a-zA-Z_$({[])/g,"!$1"),n=n.replace(/~\s+([a-zA-Z_$({[])/g,"~$1"),n}};var rf={meta:{docs:"Require space after // and /* in comments",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim(),l=r.indexOf("//");if(l!==-1){let c=r.slice(0,l),u=(c.match(/'/g)||[]).length,f=(c.match(/"/g)||[]).length,m=(c.match(/`/g)||[]).length;if(u%2===0&&f%2===0&&m%2===0){if(!c.match(/https?:$/)){let h=r.slice(l+2);if(h.length>0&&h[0]!==" "&&h[0]!=="\t"&&h[0]!=="/"&&h[0]!=="!")t.push({filePath:n.filePath,line:i+1,column:l+3,ruleId:"style/spaced-comment",message:"Missing space after '//'",severity:"warning",help:"Add a space after // in comments."})}}}let a=r.indexOf("/*");if(a!==-1&&r[a+2]!=="*"&&r[a+2]!=="!"){let c=r.slice(0,a),u=(c.match(/'/g)||[]).length,f=(c.match(/"/g)||[]).length,m=(c.match(/`/g)||[]).length;if(u%2===0&&f%2===0&&m%2===0){let h=r.slice(a+2);if(h.length>0&&h[0]!==" "&&h[0]!=="\t"&&h[0]!==`
184
+ `)t.push({filePath:n.filePath,line:i+1,column:a+3,ruleId:"style/spaced-comment",message:"Missing space after '/*'",severity:"warning",help:"Add a space after /* in comments."})}}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/(\/\/)([^\s/!])/,"$1 $2"),i=i.replace(/(\/\*)([^\s*!])/,"$1 $2"),t.push(i)}return t.join(`
185
+ `)}};var of=/^\s*(case\b.+?|default)\s*:/,lf={meta:{docs:"Enforce spacing around colon in switch case/default clauses",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o)continue;let l=o.match(of);if(!l)continue;let a=l[1],c=r.indexOf(":",r.indexOf(a)+a.length);if(c===-1)continue;if(c>0&&r[c-1]===" ")t.push({filePath:n.filePath,line:i+1,column:c+1,ruleId:"style/switch-colon-spacing",message:"Unexpected space before colon in switch case",severity:"warning"});if(c+1<r.length&&r[c+1]!==" "&&r[c+1]!=="\t"&&r[c+1]!==`
186
+ `)t.push({filePath:n.filePath,line:i+1,column:c+2,ruleId:"style/switch-colon-spacing",message:"Missing space after colon in switch case",severity:"warning"})}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s,r=s.trim();if(of.test(r))i=i.replace(/(case\b.+?|default)\s+:/,"$1:"),i=i.replace(/(case\b.+?:|default:)(\S)/,"$1 $2");t.push(i)}return t.join(`
187
+ `)}};var af="${",cf={meta:{docs:"Disallow spaces inside template literal interpolation curly braces",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i];for(let o=r.indexOf(af,0);o!==-1;o=r.indexOf(af,o)){let l=o+2;if(l<r.length&&(r[l]===" "||r[l]==="\t")){if((r.slice(0,o).match(/`/g)||[]).length%2===1)t.push({filePath:n.filePath,line:i+1,column:l+1,ruleId:"style/template-curly-spacing",message:"Unexpected space after '${'",severity:"warning"})}let a=1,c=l;while(c<r.length&&a>0){if(r[c]==="{")a++;if(r[c]==="}")a--;if(a>0)c++}if(a===0&&c>0){let u=r[c-1];if(u===" "||u==="\t"){if((r.slice(0,o).match(/`/g)||[]).length%2===1)t.push({filePath:n.filePath,line:i+1,column:c,ruleId:"style/template-curly-spacing",message:"Unexpected space before '}'",severity:"warning"})}}o=l}}return t},fix(e){return e.replace(/\$\{\s+([^}]*?)\s+\}/g,"${$1}")}};var $t=/([a-zA-Z_$][a-zA-Z0-9_$]*)\s+`/g;function uf(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var ff=new Set(["return","case","typeof","void","delete","throw","new","in","of","await","yield","export","default","extends","else","instanceof"]),mf={meta:{docs:"Disallow space between tag function and template literal",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;$t.lastIndex=0;for(l=$t.exec(r);l!==null;l=$t.exec(r)){let a=l[1],c=l.index;if(uf(r,c))continue;if(ff.has(a))continue;let u=c+a.length;t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/template-tag-spacing",message:"Unexpected space between tag function and template literal",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i=0;i<t.length;i++){let r=t[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*")){s.push(r);continue}let l=r,a=[],c;$t.lastIndex=0;for(c=$t.exec(r);c!==null;c=$t.exec(r)){let u=c[1],f=c.index;if(uf(r,f))continue;if(ff.has(u))continue;a.push({index:f,fullMatch:c[0],identifier:u})}for(let u=a.length-1;u>=0;u--){let f=a[u],m=f.index,h=m+f.fullMatch.length;l=l.slice(0,m)+f.identifier+"`"+l.slice(h)}s.push(l)}return s.join(`
188
+ `)}};var hf={meta:{docs:"Require parentheses around immediately invoked function expressions (IIFEs)",recommended:!0},check(e,n){let t=[],s=/[^a-zA-Z_$](function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,i;for(i=s.exec(e);i!==null;i=s.exec(e)){if(i.index>0&&e[i.index]==="(")continue;let r=e.slice(0,i.index).split(`
189
+ `).length,o=e.lastIndexOf(`
190
+ `,i.index),l=i.index-o;t.push({filePath:n.filePath,line:r,column:l,ruleId:"style/wrap-iife",message:"Wrap immediately invoked function expressions in parentheses",severity:"warning"})}return t},fix(e){return e.replace(/([^a-zA-Z_$(\n])(function\s*\([^)]*\)\s*\{[^}]*\})\s*\(/g,"$1($2)(")}};var df=/\byield\s*\*/g;function Gp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var pf={meta:{docs:"Enforce spacing around * in yield* expressions (no space before *, space after)",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;df.lastIndex=0;while((l=df.exec(r))!==null){let a=l.index;if(Gp(r,a))continue;let c=l[0],u=a+c.length-1,f=u+1;if(c!=="yield*")t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"style/yield-star-spacing",message:"Unexpected space before * in yield expression",severity:"warning"});if(f<r.length&&r[f]!==" "&&r[f]!=="\t"&&r[f]!==`
191
+ `)t.push({filePath:n.filePath,line:i+1,column:f+1,ruleId:"style/yield-star-spacing",message:"Missing space after * in yield expression",severity:"warning"})}}return t},fix(e,n){let t=e;return t=t.replace(/\byield\s+\*/g,"yield*"),t=t.replace(/\byield\*(\S)/g,"yield* $1"),t}};var gf={name:"style",rules:{"brace-style":b(Tc),curly:b(qc),"max-statements-per-line":b(cu),"if-newline":b(tu),"consistent-chaining":b(Wc),"consistent-list-newline":b(zc),"indent-unindent":b(nu),"no-multi-spaces":Tu,"no-multiple-empty-lines":Au,"no-trailing-spaces":_u,"keyword-spacing":b(ou),"arrow-spacing":b(Ec),"space-infix-ops":b(tf),"object-curly-spacing":b(Fu),"spaced-comment":b(rf),"block-spacing":b(Lc),"space-before-blocks":b(Hu),"comma-spacing":b(Dc),"semi-spacing":b(Ku),"rest-spread-spacing":b(qu),"generator-star-spacing":b(eu),"yield-star-spacing":b(pf),"function-call-spacing":b(Yc),"template-tag-spacing":b(mf),"no-whitespace-before-property":b(xu),"key-spacing":b(iu),"computed-property-spacing":b(Nc),"array-bracket-spacing":b(vc),"space-in-parens":b(Qu),"template-curly-spacing":b(cf),"space-unary-ops":b(sf),"switch-colon-spacing":b(lf),"comma-dangle":b(_c),"arrow-parens":b(Cc),"space-before-function-paren":b(Yu),"quote-props":b(Uu),"no-floating-decimal":b(Eu),"new-parens":b(du),"no-extra-parens":b(gu),"wrap-iife":b(hf),"comma-style":b(Fc),"dot-location":b(Kc),"operator-linebreak":b(Bu),"multiline-ternary":b(mu),"padded-blocks":b(ju),"lines-between-class-members":b(au),"no-mixed-operators":b(vu),"indent-binary-ops":b(Zc),"no-tabs":b(Ou),"no-mixed-spaces-and-tabs":b(Lu)}};var yf={meta:{docs:"Enforce consistent member delimiter style in interfaces and type literals",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/),i=!1,r=0,o=0;for(let l=0;l<s.length;l++){let a=s[l],c=a.trim();if(!c||c.startsWith("//")||c.startsWith("*")||c.startsWith("/*"))continue;if(c.match(/\b(interface|type)\b.*\{/))i=!0,o=r+1;for(let u of c){if(u==="{")r++;if(u==="}")r--}if(i&&r<o){i=!1;continue}if(!i||r!==o)continue;if(c==="}"||c==="};"||c==="},")continue;if(c.endsWith(",")){if(c.startsWith("|")||c.startsWith("&"))continue;t.push({filePath:n.filePath,line:l+1,column:a.length,ruleId:"ts/member-delimiter-style",message:"Expected semicolon delimiter in interface, found comma",severity:"warning"})}if(!c.endsWith(";")&&!c.endsWith(",")&&!c.endsWith("{")&&!c.endsWith("(")){if(c.match(/^\w+[\s?]*:/)||c.match(/^\[/)||c.match(/^readonly\b/))t.push({filePath:n.filePath,line:l+1,column:a.length+1,ruleId:"ts/member-delimiter-style",message:"Missing semicolon delimiter in interface member",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[],s=!1,i=0,r=0;for(let o=0;o<n.length;o++){let l=n[o],a=l.trim();if(a.match(/\b(interface|type)\b.*\{/))s=!0,r=i+1;let c=i;for(let u of a){if(u==="{")i++;if(u==="}")i--}if(s&&i<r){s=!1,t.push(l);continue}if(s&&c===r&&a!=="}"&&a!=="};"&&a!=="},"){let u=l;if(a.endsWith(","))u=l.replace(/,\s*$/,";");t.push(u);continue}t.push(l)}return t.join(`
192
+ `)}};var bf={meta:{docs:"Disallow the use of the `any` type - it defeats the purpose of TypeScript type safety"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let h=o.indexOf("*/");if(h>=0)o=o.slice(h+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let h=o.indexOf("*/",a+2);if(h>=0)o=o.slice(0,a)+o.slice(h+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=/\b(any)\b/g,m;while((m=f.exec(u))!==null){let h=m.index,d=u[h-1]||" ",p=u[h+3]||" ",y=u.slice(Math.max(0,h-10),h),g=u.slice(h+3,Math.min(u.length,h+10));if(/\w/.test(d)||/\w/.test(p))continue;if(/:/.test(y)||/</.test(y)||/\bas\s*$/.test(y)||/,/.test(y)||/\|/.test(y)||/&/.test(y)||/\[/.test(g)||/>/.test(g)||/,/.test(g)||/\|/.test(g)||/extends\s+$/.test(y)||/=\s*$/.test(y)){let k=l.indexOf("any",Math.max(0,h-5));t.push({filePath:n.filePath,line:r+1,column:k>=0?k+1:h+1,ruleId:"ts/no-explicit-any",message:"Unexpected `any` type. Specify a more precise type or use `unknown` if the type is truly unknown.",severity:"error",help:"Replace `any` with a specific type, `unknown`, or a generic type parameter"})}}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/:\s*any\b(?!\s*\))/g,(r)=>r.replace("any","unknown")),t.push(i)}return t.join(`
193
+ `)}};var xf={meta:{docs:"Require promises to be handled - must be awaited, returned, or have .catch() called"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let m=o.indexOf("*/");if(m>=0)o=o.slice(m+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let m=o.indexOf("*/",a+2);if(m>=0)o=o.slice(0,a)+o.slice(m+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""');if(/\b(?:await|return|void)\s/.test(u))continue;if(/\.(?:then|catch|finally)\s*\(/.test(u))continue;let f=[/\b(fetch|axios|request)\s*\(/,/\b[\w$]*(?:async|Async|load|Load|get|Get|post|Post|put|Put|delete|Delete|save|Save|update|Update|fetch|Fetch)[\w$]*\s*\(/,/\bnew\s+Promise\s*\(/,/\bPromise\s*\.\s*(?:resolve|reject|all|allSettled|race|any)\s*\(/];for(let m of f){let h=u.match(m);if(!h)continue;let d=u.indexOf(h[0]),p=u.slice(0,d).trim();if(/\b(?:const|let|var)\s+[\w$]+\s*=\s*$/.test(p))continue;if(/[\w$]+\s*=\s*$/.test(p))continue;if(/\breturn\s+$/.test(p))continue;if(/\(\s*$/.test(p)||/,\s*$/.test(p))continue;let y=u.slice(d+h[0].length),g=1,x=h[0].length;while(x<y.length&&g>0){if(y[x]==="(")g++;else if(y[x]===")")g--;x++}let k=y.slice(x).trim();if(/^\.(?:then|catch|finally)\s*\(/.test(k))continue;if(k===""||k.startsWith(";")){let P=l.indexOf(h[0]);t.push({filePath:n.filePath,line:r+1,column:P>=0?P+1:d+1,ruleId:"ts/no-floating-promises",message:"Promise returned by this call is not handled. Add await, return, .catch(), or void.",severity:"error",help:"Either await the promise, return it, add .catch() to handle errors, or use void to explicitly mark as fire-and-forget"});break}}}return t}};var wf={meta:{docs:"Disallow promises in places not designed to handle them (conditionals, logical expressions)"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let y=o.indexOf("*/");if(y>=0)o=o.slice(y+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let y=o.indexOf("*/",a+2);if(y>=0)o=o.slice(0,a)+o.slice(y+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=u.match(/\bif\s*\(\s*(!?)\s*([\w$]+\s*\([^)]*\))/);if(f){let y=f[1],g=f[2];if(/async|Async|fetch|Fetch|load|Load|get|Get|save|Save/.test(g)){let x=u.slice(0,u.indexOf(f[0])),k=u.slice(u.indexOf("if (")+4);if(!/\bawait\s/.test(k)){let P=l.indexOf(g);t.push({filePath:n.filePath,line:r+1,column:P>=0?P+1:1,ruleId:"ts/no-misused-promises",message:"Promise used in conditional expression without await. Promises are always truthy.",severity:"error",help:"Add await before the async call in the condition"})}}}let m=/(?:async|Async|fetch|Fetch|load|Load|get|Get|save|Save|Promise\.)[\w$]*\s*\([^)]*\)/g,h;while((h=m.exec(u))!==null){let y=h.index,g=h[0],x=u.slice(Math.max(0,y-10),y),k=u.slice(y+g.length,Math.min(u.length,y+g.length+10));if(/(?:&&|\|\|)\s*$/.test(x)||/^\s*(?:&&|\|\|)/.test(k)){if(!/\bawait\s*$/.test(x)){let w=l.indexOf(g,Math.max(0,y-5));t.push({filePath:n.filePath,line:r+1,column:w>=0?w+1:y+1,ruleId:"ts/no-misused-promises",message:"Promise used in logical expression without await. This will not work as expected.",severity:"error",help:"Add await before the async call or restructure the logic"})}}let P=u.slice(Math.max(0,y-20),y);if(/\?\s*$/.test(x)||/\?[^:]*$/.test(P)){if(!/\bawait\s*$/.test(x)){let w=l.indexOf(g,Math.max(0,y-5));t.push({filePath:n.filePath,line:r+1,column:w>=0?w+1:y+1,ruleId:"ts/no-misused-promises",message:"Promise used in ternary expression without await.",severity:"error",help:"Add await before the async call"})}}}let d=u.match(/\b(?:while|for)\s*\([^)]*(?:async|Async|fetch|Fetch|load|Load|get|Get)[\w$]*\s*\([^)]*\)/);if(d){if(!/\bawait\s/.test(d[0])){let y=l.indexOf(d[0]);t.push({filePath:n.filePath,line:r+1,column:y>=0?y+1:1,ruleId:"ts/no-misused-promises",message:"Promise used in loop condition without await. This will cause unexpected behavior.",severity:"error",help:"Add await before the async call in the loop condition"})}}let p=u.match(/\.(forEach|map|filter|reduce|every|some|find|findIndex)\s*\(\s*async\s*(?:\(|[\w$]+\s*=>)/);if(p){if(p[1]==="forEach"){let g=l.indexOf(p[0]);t.push({filePath:n.filePath,line:r+1,column:g>=0?g+1:1,ruleId:"ts/no-misused-promises",message:"async callback in forEach - forEach does not wait for promises to resolve.",severity:"error",help:"Use for...of loop with await, or Promise.all() with map()"})}}}return t}};var Rf={meta:{docs:"Disallow require() in TypeScript files; prefer ESM imports"},check:(e,n)=>{let t=[];if(!/\.ts$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let m=l.indexOf("*/");if(m>=0)l=l.slice(m+2),i=!1;else continue}let a=l.indexOf("/*"),c=l.indexOf("//");if(a>=0&&(c===-1||a<c)){let m=l.indexOf("*/",a+2);if(m>=0)l=l.slice(0,a)+l.slice(m+2);else i=!0,l=l.slice(0,a)}if(c>=0)l=l.slice(0,c);let u=l.trim();if(!u)continue;if(/\bimport\s*\(/.test(u))continue;let f=u.indexOf("require(");if(f>=0){t.push({filePath:n.filePath,line:r+1,column:o.indexOf("require(")+1||f+1,ruleId:"ts/no-require-imports",message:"Do not use require() in TypeScript files. Use ESM import syntax instead.",severity:"error"});continue}if(/^import\s+(?:\S.*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF])=\s*require\s*\(/.test(u)){let m=o.indexOf("require(");t.push({filePath:n.filePath,line:r+1,column:m>-1?m+1:1,ruleId:"ts/no-require-imports",message:"Do not use require() in TypeScript files. Use ESM import syntax instead.",severity:"error"})}}return t}};var kf={meta:{docs:"Disallow top-level await in TypeScript/JavaScript files"},check:(e,n)=>{let t=[],s=n.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","js","mjs","cjs"].includes(s))return t;let i=0,r=!1,o=!1,l=!1,a=!1,c=!1,u=!1,f=0,m=1,h=(d)=>{t.push({filePath:n.filePath,line:m,column:d,ruleId:"ts/no-top-level-await",message:"Do not use top-level await",severity:"error"})};for(let d=0;d<e.length;d++){let p=e[d];f++;let y=e[d+1];if(p===`
194
+ `){o=!1,m++,f=0;continue}if(o)continue;if(r){if(p==="*"&&y==="/")r=!1,d++,f++;continue}if(l){if(!u&&p==="\\"){u=!0;continue}if(!u&&p==="'")l=!1;u=!1;continue}if(a){if(!u&&p==="\\"){u=!0;continue}if(!u&&p==='"')a=!1;u=!1;continue}if(c){if(!u&&p==="\\"){u=!0;continue}if(!u&&p==="`")c=!1;u=!1;continue}if(p==="/"&&y==="*"){r=!0,d++,f++;continue}if(p==="/"&&y==="/"){o=!0,d++,f++;continue}if(p==="'"){l=!0;continue}if(p==='"'){a=!0;continue}if(p==="`"){c=!0;continue}if(p==="{"){i++;continue}if(p==="}"){if(i>0)i--;continue}if(p==="a"&&e.slice(d,d+5)==="await"){let g=e.slice(Math.max(0,d-6),d),x=/for\s+$/.test(g),k=d===0||/[^$\w]/.test(e[d-1]),P=/[^$\w]/.test(e[d+5]||" ");if(!x&&k&&P&&i===0)h(f);d+=4,f+=4;continue}}return t}};var $f={meta:{docs:"Disallow `exports =` in TypeScript; prefer ESM export default"},check:(e,n)=>{let t=[],s=n.filePath.split(".").pop()||"";if(!["ts","tsx","mts","cts","d.ts"].includes(s))return t;let i=e.split(/\r?\n/);for(let r=0;r<i.length;r++){let a=i[r].replace(/\/\*.*?\*\//g,"").replace(/\/\/.*$/,"").match(/\bexports\s*=\s*/);if(a)t.push({filePath:n.filePath,line:r+1,column:(a.index||0)+1,ruleId:"ts/no-ts-export-equal",message:"Use ESM `export default` instead of `exports =`",severity:"error"})}return t}};var Pf={meta:{docs:"Disallow assignment of `any` typed values to variables - unsafe assignments bypass type checking"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let x=o.indexOf("*/");if(x>=0)o=o.slice(x+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let x=o.indexOf("*/",a+2);if(x>=0)o=o.slice(0,a)+o.slice(x+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=/(\w+)\s+as\s+any/g,m;while((m=f.exec(u))!==null){let x=m[1],k=m.index,P=u.slice(k+m[0].length).trim(),w=u.slice(0,k).trim();if(/=\s*$/.test(w)&&!/==|===|!=|!==/.test(w)){let M=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:M>=0?M+1:k+1,ruleId:"ts/no-unsafe-assignment",message:"Unsafe assignment: value cast to `any` is being assigned. This bypasses type checking.",severity:"error",help:"Avoid casting to `any` or use a more specific type"})}}let h=["JSON.parse","eval","Function","require"];for(let x of h){let k=new RegExp(`\\b${x.replace(".","\\.")}\\s*\\(`,"g");k.lastIndex=0;while((m=k.exec(u))!==null){let P=m.index,w=u.slice(0,P).trim(),M=w.match(/(?:const|let|var)\s+([\w$]+)\s*=\s*$/);if(M){let E=M[1];if(!new RegExp(`\\b${E}\\s*:\\s*\\w+`).test(u)){let S=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:S>=0?S+1:P+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${x}() without type annotation. This function returns 'any'.`,severity:"error",help:`Add a type annotation to ${E} or use a type assertion with a specific type`})}}let A=w.match(/([\w$.]+)\s*=\s*$/),O=/(?:const|let|var)\s+/.test(w);if(A&&!M&&!O){let E=l.indexOf(m[0]);t.push({filePath:n.filePath,line:r+1,column:E>=0?E+1:P+1,ruleId:"ts/no-unsafe-assignment",message:`Unsafe assignment from ${x}() which returns 'any'.`,severity:"error",help:"Consider adding a type assertion with a specific type"})}}}let d=/(?:const|let|var)\s+([\w$]+)\s*:\s*any\s*=/,p=u.match(d);if(p){let x=p[1],k=l.indexOf(p[0]);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+1:1,ruleId:"ts/no-unsafe-assignment",message:`Variable '${x}' is explicitly typed as 'any'. This defeats TypeScript's type safety.`,severity:"error",help:"Use a more specific type or `unknown` instead of `any`"})}let y=/(?:const|let|var)\s+(?:\{[^}]+\}|\[[^\]]+\])\s*=\s*([\w$]+)/,g=u.match(y);if(g){let x=g[1];if(/^(?:params|query|body|req|res|response|data|result)$/.test(x));}}return t}};var If={meta:{docs:"Prefer nullish coalescing operator (??) over logical OR (||) when checking for null/undefined"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o.split(""),a=l.length,c=0;if(i){let d=o.indexOf("*/");if(d<0)continue;for(let p=0;p<=d+1;p++)l[p]=" ";i=!1,c=d+2}let u=null;for(;c<a;c++){let d=l[c];if(u){if(d==="\\"){if(l[c]=" ",c+1<a)l[c+1]=" ",c++;continue}if(d===u){u=null;continue}l[c]=" ";continue}if(d==="/"&&l[c+1]==="/"){for(let p=c;p<a;p++)l[p]=" ";break}if(d==="/"&&l[c+1]==="*"){let p=o.indexOf("*/",c+2);if(p<0){for(let y=c;y<a;y++)l[y]=" ";i=!0;break}for(let y=c;y<=p+1;y++)l[y]=" ";c=p+1;continue}if(d==='"'||d==="'"||d==="`")u=d}let f=l.join(""),m=/\|\|/g,h;while((h=m.exec(f))!==null){let d=h.index,p=d-1,y=0,g=0,x=0;while(p>=0){let E=f[p];if(E===")")y++;else if(E==="("){if(y===0){p++;break}y--}else if(E==="}")g++;else if(E==="{"){if(g===0){p++;break}g--}else if(E==="]")x++;else if(E==="["){if(x===0){p++;break}x--}else if(y===0&&g===0&&x===0){if(new RegExp("[;,=:?]").test(E)){p++;break}if(E==="&"||E==="|"){p++;break}}p--}if(p<0)p=0;let k=f.slice(p,d).trim();if(/[<>!=]/.test(k))continue;if(/\b(?:true|false)\b/.test(k))continue;let P=d+2,w=P;y=0,g=0,x=0;while(w<f.length){let E=f[w];if(E==="(")y++;else if(E===")"){if(y===0)break;y--}else if(E==="{")g++;else if(E==="}"){if(g===0)break;g--}else if(E==="[")x++;else if(E==="]"){if(x===0)break;x--}else if(y===0&&g===0&&x===0){if(new RegExp("[;,?:]").test(E))break;if(E==="&"||E==="|"&&f[w+1]==="|")break}w++}let M=f.slice(P,w).trim(),A=/^["'`\d]/.test(M)||/^\{/.test(M)||/^[\w$]+\(/.test(M)||/^[\w$.[\]]+$/.test(M),O=/^[\w$]+$/.test(k)||/^[\w$.?[\]()]+$/.test(k);if(A&&O)t.push({filePath:n.filePath,line:r+1,column:d+1,ruleId:"ts/prefer-nullish-coalescing",message:"Prefer nullish coalescing operator (??) over logical OR (||)",severity:"error",help:'Use `??` instead of `||` to only handle null/undefined, not falsy values like 0, "", or false'})}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s,r=new RegExp("(\\b[\\w$.]+)\\s*\\|\\|\\s*([^|&]+?)(?=\\s*[;,)\\]}]|$)","g");i=i.replace(r,(o,l,a)=>{if(/\b(?:true|false)\b/.test(a.trim()))return o;return`${l} ?? ${a}`}),t.push(i)}return t.join(`
195
+ `)}};var vf={meta:{docs:"Prefer optional chaining (?.) over chained logical AND (&&) for property access"},check:(e,n)=>{let t=[];if(!/\.tsx?$/.test(n.filePath))return t;let s=e.split(/\r?\n/),i=!1;for(let r=0;r<s.length;r++){let o=s[r],l=o;if(i){let p=o.indexOf("*/");if(p>=0)o=o.slice(p+2),i=!1;else continue}let a=o.indexOf("/*"),c=o.indexOf("//");if(a>=0&&(c===-1||a<c)){let p=o.indexOf("*/",a+2);if(p>=0)o=o.slice(0,a)+o.slice(p+2);else i=!0,o=o.slice(0,a)}if(c>=0)o=o.slice(0,c);let u=o.replace(/(['"`])(?:(?!\1)[^\\]|\\.)*?\1/g,'""'),f=/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,m;while((m=f.exec(u))!==null){let p=m[1],y=m[2],g=m.index,x=l.indexOf(m[0],Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:x>=0?x+1:g+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for property access: ${p}?.${y}`,severity:"error",help:`Use \`${p}?.${y}\` instead of \`${p} && ${p}.${y}\``})}let h=/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g;h.lastIndex=0;while((m=h.exec(u))!==null){let p=m[1],y=m[2],g=m.index,x=l.indexOf(m[0],Math.max(0,g-5));t.push({filePath:n.filePath,line:r+1,column:x>=0?x+1:g+1,ruleId:"ts/prefer-optional-chain",message:`Prefer optional chaining over && for nested property access: ${p}?.${y}`,severity:"error",help:`Use \`${p}?.${y}\` instead of \`${p} && ${p}.${y}\``})}let d=u.split(/\s*&&\s*/);if(d.length>=3)for(let p=0;p<d.length-2;p++){let y=d[p].trim(),g=d[p+1].trim(),x=d[p+2].trim();if(g.startsWith(`${y}.`)&&x.startsWith(`${g}.`)){let k=l.indexOf(y);t.push({filePath:n.filePath,line:r+1,column:k>=0?k+1:1,ruleId:"ts/prefer-optional-chain",message:"Prefer optional chaining over multiple && checks for nested properties",severity:"error",help:`Use optional chaining like \`${y}?.${g.slice(y.length+1)}?.${x.slice(g.length+1)}\``});break}}}return t},fix:(e)=>{let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/(\b[\w$]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),i=i.replace(/([\w$]+\.[\w$.]+)\s*&&\s*\1\.([\w$]+)/g,"$1?.$2"),t.push(i)}return t.join(`
196
+ `)}};function Jp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Mf=/([a-zA-Z_$][a-zA-Z0-9_$]*\??)\s*:\s*([A-Z][a-zA-Z0-9_$<>[\]|&]*|string|number|boolean|null|undefined|void|never|any|unknown|object|symbol|bigint)/g,Cf={meta:{docs:"Require consistent spacing around type annotation colons",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l;Mf.lastIndex=0;while((l=Mf.exec(r))!==null){if(Jp(r,l.index))continue;let a=l[0],c=a.indexOf(":"),u=l.index+c;if(c>0&&a[c-1]===" "&&!a.startsWith("?")){if(!l[1].endsWith("?")||a[c-1]===" "){if(r[u-1]===" "&&!/\?\s*$/.test(l[1]))t.push({filePath:n.filePath,line:i+1,column:u+1,ruleId:"ts/type-annotation-spacing",message:"Unexpected space before colon in type annotation",severity:"warning"})}}if(u+1<r.length&&r[u+1]!==" "&&r[u+1]!=="\t")t.push({filePath:n.filePath,line:i+1,column:u+2,ruleId:"ts/type-annotation-spacing",message:"Missing space after colon in type annotation",severity:"warning"})}}return t},fix(e){let n=e.split(/\r?\n/),t=[];for(let s of n){let i=s;i=i.replace(/([a-zA-Z_$][a-zA-Z0-9_$]*\??)\s*:\s*([A-Z][a-zA-Z0-9_$<>[\]|&]*|string|number|boolean|null|undefined|void|never|any|unknown|object|symbol|bigint)/g,"$1: $2"),t.push(i)}return t.join(`
197
+ `)}};function Sf(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Ef=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<(\s+)/g,Lf=/(\s+)>(?!=)/g,Yp=/([A-Za-z_$][A-Za-z0-9_$]*)\s*<\s+/g,Xp=/\s+>(?!=)/g,Tf={meta:{docs:"Disallow spaces inside TypeScript generic angle brackets",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;Ef.lastIndex=0;let l;while((l=Ef.exec(r))!==null){let a=l.index+l[1].length,c=r.indexOf("<",a);if(c===-1)continue;if(Sf(r,c))continue;t.push({filePath:n.filePath,line:i+1,column:c+2,ruleId:"ts/type-generic-spacing",message:"Unexpected space after '<' in generic type",severity:"warning"})}Lf.lastIndex=0;while((l=Lf.exec(r))!==null){let a=l.index+l[1].length;if(Sf(r,a))continue;let c=r.slice(0,a);if(!/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(c))continue;t.push({filePath:n.filePath,line:i+1,column:a+1,ruleId:"ts/type-generic-spacing",message:"Unexpected space before '>' in generic type",severity:"warning"})}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i of t){let r=i.trim();if(!r||r.startsWith("//")||r.startsWith("*")||r.startsWith("/*")){s.push(i);continue}let o=i;if(o=o.replace(Yp,(l,a)=>`${a}<`),/[A-Za-z_$][A-Za-z0-9_$]*\s*</.test(o))o=o.replace(Xp,">");s.push(o)}return s.join(`
198
+ `)}};function Qp(e,n){let t=e.slice(0,n);if(t.includes("//"))return!0;let s=(t.match(/'/g)||[]).length,i=(t.match(/"/g)||[]).length,r=(t.match(/`/g)||[]).length;return s%2===1||i%2===1||r%2===1}var Af=/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,Df={meta:{docs:"Require space after colon in named tuple members",recommended:!0},check(e,n){let t=[],s=e.split(/\r?\n/);for(let i=0;i<s.length;i++){let r=s[i],o=r.trim();if(!o||o.startsWith("//")||o.startsWith("*")||o.startsWith("/*"))continue;let l=Of(r);for(let a of l){Af.lastIndex=0;let c;while((c=Af.exec(a.text))!==null){let f=a.start+c.index+c[1].length;if(Qp(r,f))continue;if(!_f(r))continue;t.push({filePath:n.filePath,line:i+1,column:f+2,ruleId:"ts/type-named-tuple-spacing",message:"Missing space after colon in named tuple member",severity:"warning"})}}}return t},fix(e,n){let t=e.split(/\r?\n/),s=[];for(let i of t){let r=i.trim();if(!r||r.startsWith("//")||r.startsWith("*")||r.startsWith("/*")){s.push(i);continue}if(!_f(i)){s.push(i);continue}let o=i,l=Of(i);for(let a=l.length-1;a>=0;a--){let c=l[a],u=c.text.replace(/([a-zA-Z_$][a-zA-Z0-9_$?]*):(\S)/g,"$1: $2");if(u!==c.text)o=o.slice(0,c.start)+u+o.slice(c.start+c.text.length)}s.push(o)}return s.join(`
199
+ `)}};function Of(e){let n=[],t=0,s=-1;for(let i=0;i<e.length;i++)if(e[i]==="["){if(t===0)s=i;t++}else if(e[i]==="]"){if(t--,t===0&&s>=0)n.push({start:s,text:e.slice(s,i+1)}),s=-1}return n}function _f(e){let n=e.trim();return/\btype\s/.test(n)||/:\s*\[/.test(n)||/=\s*\[/.test(n)||/\bas\s/.test(n)||/<[^>]*\[/.test(n)||/\bextends\s/.test(n)||/\bimplements\s/.test(n)}var Ff={name:"ts",rules:{"no-require-imports":b(Rf),"no-top-level-await":b(kf),"no-ts-export-equal":b($f),"no-explicit-any":b(bf),"prefer-nullish-coalescing":b(If),"prefer-optional-chain":b(vf),"no-floating-promises":b(xf),"no-misused-promises":b(wf),"no-unsafe-assignment":b(Pf),"member-delimiter-style":b(yf),"type-annotation-spacing":b(Cf),"type-generic-spacing":b(Tf),"type-named-tuple-spacing":b(Df)}};var Nf={name:"unused-imports",rules:{"no-unused-vars":b(Ye),"no-unused-imports":b(Ye)}};function fr(){return[Oo,Uo,Ha,Va,gf,Ya,Ff,ra,$c,Pc,aa,tl,Ra,Nf,ca]}var mr=null;function Uf(){if(!mr)mr=new st("pickier",{showTags:!1});return mr}function Pt(...e){if(Oe.TRACE)Uf().debug("[pickier:trace]",e)}async function Bf(e,n,t){let s,i=new Promise((r,o)=>{s=setTimeout(()=>o(Error(`Timeout after ${n}ms at ${t}`)),n)});try{let r=await Promise.race([e,i]);return clearTimeout(s),r}catch(r){throw Uf().error(`[pickier:error] ${t} failed:`,r?.message||r),Pt("withTimeout error:",t,r),r}}function zf(e){if(e.length===0)return"";let n=new Map;for(let s of e){let i=n.get(s.filePath)||[];i.push(s),n.set(s.filePath,i)}let t="";for(let[s,i]of n){t+=`
200
+ ${se.bold(`\x1B[4m${s}\x1B[24m`)}
201
+ `;let r;try{r=jf(s,"utf8")}catch{for(let l of i){let a=l.severity==="error"?se.red("error"):se.yellow("warn ");t+=` ${l.line}:${l.column} ${a} ${l.message} ${se.blue(l.ruleId)}
202
+ `}continue}let o=r.split(/\r?\n/);for(let l of i){let a=l.severity==="error"?se.red("!"):se.yellow("!"),c=se.blue(l.ruleId);t+=`
203
+ ${a} ${c}: ${l.message}
204
+ `;let u=2,f=2,m=Math.max(1,l.line-u),h=Math.min(o.length,l.line+f),p=String(h).length;t+=` ${se.gray(" ,-")}${se.gray(`[:${l.line}:${l.column}]`)}
205
+ `;for(let y=m;y<=h;y++){let g=String(y).padStart(p),x=o[y-1]||"";if(y===l.line)t+=` ${se.gray(g)} ${se.gray("|")} ${se.red(",-> ")}${x}
206
+ `;else if(y===l.line+1&&f>0)t+=` ${se.gray(g)} ${se.gray("|")} ${se.red("| ")}${x}
207
+ `;else if(y===l.line+f&&f>1)t+=` ${se.gray(g)} ${se.gray("|")} ${se.red("`-> ")}${x}
208
+ `;else t+=` ${se.gray(g)} ${se.gray("| ")}${x}
209
+ `}if(t+=` ${se.gray(" `----")}
210
+ `,l.help)t+=` ${se.blue("help")}: ${l.help}
211
+ `}}return t}function qf(e){if(e.length===0)return"";let n=new Map;for(let s of e){let i=n.get(s.filePath)||[];i.push(s),n.set(s.filePath,i)}let t="";for(let[s,i]of n){t+=`
212
+ ${se.bold(`\x1B[4m${s}\x1B[24m`)}
213
+ `;for(let r of i){let o=r.severity==="error"?se.red("error"):se.yellow("warn "),a=`${r.line}:${r.column}`.padStart(6),c=60,u=r.message.padEnd(60);t+=`${a} ${o} ${u} ${se.blue(r.ruleId)}
214
+ `}}return t}async function YC(e,n){Pt("runFormat:start",{globs:e,options:n});let t=await Bt(n.config),s=e.length?e:["."],i=jt(s);Pt("patterns",i);let r=new Set((n.ext||t.format.extensions.join(",")).split(",").map((y)=>{let g=y.trim();return g.startsWith(".")?g:`.${g}`})),o=Oe.TIMEOUT_MS,a=i.some((y)=>{let g=y.replace(/\/?\*\*(?:\/\*+)?$/,"");return!(tg(g)?g:ng(process.cwd(),g)).startsWith(process.cwd())})?tt(ot):tt(t.ignores),c=Ut(a),u=[];if(i.length===1&&/\*\*\/\*$/.test(i[0])){let y=i[0].replace(/\/?\*\*\/\*$/,"");try{let{readdirSync:g,statSync:x}=await import("fs"),{join:k}=await import("path"),P=[y];while(P.length){let w=P.pop(),M=g(w);for(let A of M){let O=k(w,A),E=x(O);if(c(O))continue;if(E.isDirectory())P.push(O);else u.push(O)}}}catch{u=await Bf(et(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob")}}else u=await Bf(et(i,{dot:!1,ignore:a,onlyFiles:!0,absolute:!0}),o,"glob");Pt("globbed entries",u.length);let m=u.filter((y)=>{if(c(y))return!1;let g=y.lastIndexOf(".");if(g<0)return!0;let x=y.slice(g);return r.has(x)});Pt("filtered files",m.length);let h=0,d=[];for(let y of m){Pt("format start",Wf(process.cwd(),y));let g=jf(y,"utf8"),x=Us(g,t,y),k=x!==g;if(n.write){if(k)eg(y,x,"utf8")}if(k)d.push(Wf(process.cwd(),y));h++}let p=d.length;if(p>0){for(let y of d)console.log(se.gray(` ${y}`));console.log(n.write?se.gray(`Formatted ${p} of ${h} file(s).`):se.yellow(`${p} of ${h} file(s) need formatting. Run with --write to fix.`))}else if(n.verbose!==void 0?n.verbose:t.verbose)console.log(se.gray(`Checked ${h} files, all formatted.`));return n.check&&p>0?1:0}var dr=null;function ee(){if(!dr)dr=new st("pickier:lint",{showTags:!1});return dr}function ke(...e){if(Oe.TRACE)ee().error("[pickier:trace]",e)}async function lS(e,n,t="untitled",s){if(s?.aborted)throw Error("AbortError");let i=lt(e),r=at(e),o=Mt(t,e,n,i,r);if(s?.aborted)throw Error("AbortError");try{let l=await xr(t,e,n);for(let a of l){if(s?.aborted)throw Error("AbortError");if(Te(a.ruleId,a.line,i))continue;if(r.has(a.line)&&Ks(a.ruleId))continue;o.push({filePath:a.filePath,line:a.line,column:a.column,ruleId:a.ruleId,message:a.message,severity:a.severity,...a.help&&{help:a.help}})}}catch{}return o}async function aS(e,n,t){ke("runLintProgrammatic:start",{globs:e,options:n});let s=await Bt(n.config);if(t?.aborted)throw Error("AbortError");let i=e.length?e:["."],r=jt(i),o=n.ext||s.lint.extensions.join(","),l=new Set(o.split(",").map((S)=>{let C=S.trim();return C.startsWith(".")?C:`.${C}`})),a=Oe.TIMEOUT_MS,u=r.some((S)=>{let C=S.replace(/\/?\*\*\/*\*\*$/,""),L=It(C)?C:vt(process.cwd(),C),F=process.cwd();return L!==F&&!L.startsWith(F+tm)})?tt(ot):tt(s.ignores),f=Ut(u),m=[];if(r.length===1&&!/[*?[\]{}()!]/.test(r[0]))try{if(qs(r[0]).isFile())m=[It(r[0])?r[0]:vt(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let S=r[0].replace(/\/?\*\*\/*\*\*$/,""),C=It(S)?S:vt(process.cwd(),S);try{let L=[C];while(L.length){if(t?.aborted)throw Error("AbortError");let F=L.pop(),T=Xf(F);for(let R of T){let v=em(F,R),I=qs(v);if(f(v))continue;if(I.isDirectory())L.push(v);else m.push(v)}}}catch{m=await qt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob")}}else if(!m.length)m=await qt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob");if(t?.aborted)throw Error("AbortError");let p=0,y=0,g=0,x=0,k=0,P=[];for(let S of m){if(p++,S.replace(/\\/g,"/").includes("/node_modules/")){g++;continue}if(f(S)){x++;continue}if(!yr(S,l)){k++;continue}P.push(S),y++}ke("filter:programmatic",{total:p,included:y,node_modules:g,ignored:x,wrongExt:k});let w=Oe.CONCURRENCY,O=(await sm(P,w,async(S)=>{if(t?.aborted)throw Error("AbortError");let C=Qf(S,"utf8"),L=lt(C),F=at(C),T=Mt(S,C,s,L,F);try{let R=await xr(S,C,s);for(let v of R){if(t?.aborted)throw Error("AbortError");if(Te(v.ruleId,v.line,L))continue;if(F.has(v.line)&&Ks(v.ruleId))continue;T.push({filePath:v.filePath,line:v.line,column:v.column,ruleId:v.ruleId,message:v.message,severity:v.severity,...v.help&&{help:v.help}})}}catch{}{let R=new Set;T=T.filter((v)=>{let I=`${v.line}:${v.column}:${v.ruleId}`;if(R.has(I))return!1;return R.add(I),!0})}if(n.fix){let R=rm(S,C,s,L,F);if(R=im(S,R,s),R!==C){let v=lt(R),I=at(R);if(T=Mt(S,R,s,v,I),!n.dryRun)pr(S,R,"utf8")}}return T})).flat(),E=O.filter((S)=>S.severity==="error").length,D=O.filter((S)=>S.severity==="warning").length;return{errors:E,warnings:D,issues:O}}function sg(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function ig(e){return e.replace(/-([a-z])/g,(n,t)=>t.toUpperCase())}function lt(e){let n=new Map,t=new Set,s=new Map,i=new Map,r=e.split(/\r?\n/),o=new Set;for(let c=0;c<r.length;c++){let u=r[c].trim(),f=c+1,m=u.match(/^\/\/\s*(?:eslint|pickier)-disable-next-line(?:\s+(\S.*))?$/);if(m){let g=m[1]?.replace(/\s+--\s.*$/,""),x=g?g.split(",").map((k)=>k.trim()).filter(Boolean):["*"];if(x.length>0){let k=f+1,P=n.get(k)||new Set;for(let w of x)P.add(w);n.set(k,P)}continue}let h=u.match(/^\/\*\s*(?:eslint|pickier)-disable(?:\s+([^*]+))?\s*\*\//);if(h){let g=h[1]?.trim().replace(/\s+--\s.*$/,"");if(!g||g==="")s.set(f,new Set(["*"])),o.add("*");else{let x=g.split(",").map((P)=>P.trim()).filter(Boolean),k=s.get(f)||new Set;for(let P of x)k.add(P),o.add(P);s.set(f,k)}if(c===0)if(!g||g==="")t.add("*");else{let x=g.split(",").map((k)=>k.trim()).filter(Boolean);for(let k of x)t.add(k)}continue}let d=u.match(/^\/\*\s*(?:eslint|pickier)-enable(?:\s+([^*]+))?\s*\*\//);if(d){let g=d[1]?.trim();if(!g||g==="")i.set(f,new Set(["*"])),o.clear();else{let x=g.split(",").map((P)=>P.trim()).filter(Boolean),k=i.get(f)||new Set;for(let P of x)k.add(P),o.delete(P);i.set(f,k)}continue}let p=u.match(/^\/\/\s*(?:eslint|pickier)-disable(?:\s+(\S.*))?$/);if(p){let g=p[1]?.trim().replace(/\s+--\s.*$/,"");if(!g||g==="")s.set(f,new Set(["*"])),o.add("*");else{let x=g.split(",").map((P)=>P.trim()).filter(Boolean),k=s.get(f)||new Set;for(let P of x)k.add(P),o.add(P);s.set(f,k)}continue}let y=u.match(/^\/\/\s*(?:eslint|pickier)-enable(?:\s+(\S.*))?$/);if(y){let g=y[1]?.trim();if(!g||g==="")i.set(f,new Set(["*"])),o.clear();else{let x=g.split(",").map((P)=>P.trim()).filter(Boolean),k=i.get(f)||new Set;for(let P of x)k.add(P),o.delete(P);i.set(f,k)}}}let l=Array.from(s.keys()).sort((c,u)=>c-u),a=Array.from(i.keys()).sort((c,u)=>c-u);return{nextLine:n,fileLevel:t,rangeDisable:s,rangeEnable:i,sortedDisableLines:l,sortedEnableLines:a}}function Te(e,n,t){if(t instanceof Map){let l=t.get(n);if(!l||l.size===0)return!1;return zt(e,l)}if(t.fileLevel.size>0){if(zt(e,t.fileLevel))return!0}let s=t.nextLine.get(n);if(s&&zt(e,s))return!0;let i=!1,r=0,o=0;while(!0){let l=r<t.sortedDisableLines.length?t.sortedDisableLines[r]:Number.POSITIVE_INFINITY,a=o<t.sortedEnableLines.length?t.sortedEnableLines[o]:Number.POSITIVE_INFINITY,c=Math.min(l,a);if(c>=n)break;if(l===c){let f=t.rangeDisable.get(l);if(zt(e,f))i=!0;r++;continue}let u=t.rangeEnable.get(a);if(u.has("*")||zt(e,u))i=!1;o++}return i}function zt(e,n){if(n.size===0)return!1;if(n.has("*"))return!0;if(n.has(e))return!0;let t=sg(e);if(n.has(t)||n.has(ig(e)))return!0;for(let s of n)if(!s.includes("/")){if(e.endsWith(`/${s}`))return!0}return!1}function Ks(e){return e!=="spaced-comment"&&!e.endsWith("/spaced-comment")}function nm(e,n){if(e.help)return e;let t=n.includes("/")?n.split("/")[1]:n,s;if(t.startsWith("no-"))s=`Remove or refactor this ${t.replace("no-","").replace(/-/g," ")}. Check the rule documentation for more details or disable with: // eslint-disable-next-line ${n}`;else if(t.startsWith("prefer-"))s=`Consider using ${t.replace("prefer-","").replace(/-/g," ")} instead. This is a best practice recommendation. Disable with: // eslint-disable-next-line ${n} if needed`;else if(t.includes("sort")||t.includes("order"))s=`Reorder these items according to the rule requirements, or use --fix to auto-sort. Disable with: // eslint-disable-next-line ${n}`;else if(t.includes("indent")||t.includes("spacing")||t.includes("newline"))s=`Fix the formatting issue. Run with --fix to automatically format. Disable with: // eslint-disable-next-line ${n}`;else s=`Fix this issue or disable the rule with: // eslint-disable-next-line ${n}. Check the rule documentation for more details`;return{...e,help:s}}async function qt(e,n,t){let s,i=new Promise((r,o)=>{s=setTimeout(()=>o(Error(`Timeout after ${n}ms at ${t}`)),n)});try{let r=await Promise.race([e,i]);return clearTimeout(s),r}catch(r){throw ee().error(`[pickier:error] ${t} failed:`,r?.message||r),ke("withTimeout error:",t,r),r}}async function sm(e,n,t){let s=Array(e.length);if(e.length===0)return s;let i=0,r=Math.max(1,Math.min(Math.max(1,n),e.length));async function o(){while(i<e.length){let l=i++;s[l]=await t(e[l],l)}}return await Promise.all(Array.from({length:r},o)),s}var Kf=new WeakMap;function rg(e){let n=fr();if(e.plugins&&e.plugins.length>0){let t=new Set(["pickier","style","regexp","ts"]),s=e.plugins.filter((r)=>typeof r!=="string");n=s.some((r)=>t.has(r.name))?n:[];for(let r of s)n.push(r)}return n}function og(e,n){let t={...e.pluginRules||{}};if(e.rules?.noUnusedCapturingGroup)t["regexp/no-unused-capturing-group"]=e.rules.noUnusedCapturingGroup;let s={"antfu/curly":"style/curly","antfu/if-newline":"style/if-newline","antfu/no-top-level-await":"ts/no-top-level-await"};for(let[i,r]of Object.entries(s))if(t[i])t[r]=t[i];for(let i of Object.keys(e.pluginRules||{}))if(!i.includes("/")){for(let r of n)if(r.rules&&Object.prototype.hasOwnProperty.call(r.rules,i))t[`${r.name}/${i}`]=e.pluginRules[i]}return t}function Vs(e){let n=Kf.get(e);if(n)return n;let t=rg(e),s=og(e,t),i=[],r=[],o=new Set(["no-debugger"]),l=new Set(["no-debugger"]),a=new Set;for(let u of t)for(let f in u.rules){let m=`${u.name}/${f}`,h=Yf(s,m);if(!h.enabled)continue;if(a.has(f))continue;a.add(f);let d=u.rules[f],p={pluginName:u.name,ruleName:f,fullRuleId:m,rule:d,severity:h.severity,options:h.options};if(typeof d?.check==="function")i.push(p);else if(h.severity==="error")i.push(p);if(typeof d?.fix==="function")r.push(p),o.add(m),l.add(f)}let c={checkRules:i,fixRules:r,fixableRuleIds:o,fixableBareRuleNames:l};return Kf.set(e,c),c}function lg(e,n){return/\.(?:sh|bash|zsh|ksh|dash)$/.test(e)||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n)}function ag(e){return/(?:^|[/\\])(?:bun\.lock|bun\.lockb|package-lock\.json|pnpm-lock\.yaml|yarn\.lock|npm-shrinkwrap\.json)$/.test(e)}function br(e,n,t){switch(e.pluginName){case"markdown":return n.endsWith(".md");case"shell":return lg(n,t);case"publint":return/(?:^|[/\\])package\.json$/.test(n);case"lockfile":return ag(n);case"node":case"ts":case"general":case"quality":case"eslint":case"regexp":case"unused-imports":case"perfectionist":return/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(n);default:return!0}}async function xr(e,n,t){let s=[],i=Vs(t),r={filePath:e,config:t};for(let o of i.checkRules){if(!br(o,e,n))continue;let{fullRuleId:l,rule:a,severity:c}=o;if(!a||typeof a.check!=="function"){if(c==="error")s.push({filePath:e,line:1,column:1,ruleId:`${l}-internal`,message:"Rule missing implementation (check function is undefined)",severity:"error"});continue}try{ke("rule:start",l);let u=Oe.RULE_TIMEOUT_MS,f={...r,options:o.options},m=performance.now(),h=await qt(Promise.resolve().then(()=>a.check(n,f)),u,`rule:${l}`),d=performance.now()-m;if(d>u)s.push({filePath:e,line:1,column:1,ruleId:`${l}-internal`,message:`Rule exceeded timeout budget: ${Math.round(d)}ms > ${u}ms`,severity:"error"});ke("rule:end",l,Array.isArray(h)?h.length:0);for(let p of h){let y=nm(p,l);if(c)s.push({...y,severity:c});else s.push(y)}}catch(u){s.push({filePath:e,line:1,column:1,ruleId:`${l}-internal`,message:`Rule threw: ${u?.message||u}`,severity:"error"})}}return s}var cg=/\.(?:[cm]?[jt]sx?|vue|svelte|stx)$/i;function ug(e,n,t){if(!cg.test(t)||!e.includes("`"))return n;let s=e.split(/\r?\n/),i=n.split(/\r?\n/);if(s.length!==i.length)return n;let r=Xe(e),o=0;for(let l=0;l<i.length;l++)if(r[l]&&i[l]!==s[l])i[l]=s[l],o++;return o>0?i.join(`
215
+ `):n}function im(e,n,t){let s=Vs(t),i={filePath:e,config:t},r=n,o=!0,l=0;while(o&&l++<hr){o=!1;for(let a of s.fixRules){if(!br(a,e,r))continue;let c={...i,options:a.options},u=a.rule.fix(r,c),f=a.rule.meta?.editsStringContent?u:ug(r,u,e);if(f!==r)r=f,o=!0}}return r}function rm(e,n,t,s,i){if(!(t.rules.noDebugger==="error"||t.rules.noDebugger==="warn")||!n.includes("debugger"))return n;let o=e.split(".").pop()?.toLowerCase()??"",l=o==="sh"||o==="bash"||o==="zsh"||o==="ksh"||o==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n);if(o==="md"||o==="yaml"||o==="yml"||o==="json"||o==="jsonc"||l)return n;let a=/^\s*debugger\b/,c=wr(n),u=n.split(/\r?\n/),f=[],m=!1;for(let h=0;h<u.length;h++){let d=u[h],p=h+1;if(a.test(d)&&!i.has(p)&&!c.has(p)&&!Te("no-debugger",p,s)){m=!0;continue}f.push(d)}return m?f.join(`
216
+ `):n}function om(e,n,t){if((t.rules?.indent??t.pluginRules?.indent??t.pluginRules?.["style/indent"])==="off")return!1;let i=e.split(".").pop()?.toLowerCase()??"";if(i==="md")return!1;if(i==="stx"||i==="html"||i==="htm"||i==="vue")return!1;if(i==="yaml"||i==="yml")return!1;if(i==="sh"||i==="bash"||i==="zsh"||i==="ksh"||i==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n))return!1;return!0}function fg(e,n,t,s){let i=n.format.indent,r=n.format.indentStyle,o=wr(e),l=e.split(/\r?\n/),a=!1;for(let c=0;c<l.length;c++){let u=l[c],f=c+1;if(s.has(f)||o.has(f)||Te("indent",f,t))continue;let m=0;while(m<u.length&&(u.charCodeAt(m)===32||u.charCodeAt(m)===9))m++;if(m===0)continue;let h=u.slice(0,m);if(!gr(h,i,r,u))continue;let d;if(r==="tabs"){let p=0,y=0;for(let x=0;x<h.length;x++)if(h.charCodeAt(x)===9)y++;else p++;let g=Math.floor(p/i);d="\t".repeat(y+g)}else{let p=0;for(let g=0;g<h.length;g++)if(h.charCodeAt(g)===9)p+=i;else p++;let y=Math.floor(p/i)*i;d=" ".repeat(y)}if(d!==h)l[c]=d+u.slice(m),a=!0}return a?l.join(`
217
+ `):e}function wr(e){let n=new Set;if(!e.includes("`"))return n;let t=[],s="code",i=1,r="",o=0,l=()=>t[t.length-1]==="template";for(let a=0;a<e.length;a++){let c=e[a],u=e[a+1];if(c===`
218
+ `){if(s==="line-comment")s="code";i++,o=a+1,r="";continue}if(l()&&s==="code")n.add(i);switch(s){case"single":case"double":if(c==="\\")a++;else if(s==="single"&&c==="'"||s==="double"&&c==='"')s="code";continue;case"line-comment":continue;case"block-comment":if(c==="*"&&u==="/")a++,s="code";continue;case"regex":if(c==="\\")a++;else if(c==="[")s="regex-class";else if(c==="/")s="code";continue;case"regex-class":if(c==="\\")a++;else if(c==="]")s="regex";continue}if(l()){if(c==="\\"){a++;continue}if(c==="`"){t.pop();continue}if(c==="$"&&u==="{"){t.push("interpolation"),a++;continue}continue}if(c==="`"){t.push("template"),n.add(i);continue}if(c==="'"){s="single";continue}if(c==='"'){s="double";continue}if(c==="/"&&u==="/"){s="line-comment",a++;continue}if(c==="/"&&u==="*"){s="block-comment",a++;continue}if(c==="/"&&Rr(r,e.slice(o,a+1),a-o)){s="regex";continue}if(c==="}"&&t[t.length-1]==="interpolation"){t.pop();continue}if(!/\s/.test(c))r=c}return n}function Vf(e,n){let t=e.match(n);if(!t||t.index===void 0)return null;let s=t.index+t[0].length-1,i=0;for(let r=s;r<e.length;r++)if(e[r]==="(")i++;else if(e[r]===")"){if(i--,i===0)return e.slice(s+1,r)}return null}function Hf(e){let n="",t=0;for(let s of e){if(s==="("){t++;continue}if(s===")"){t=Math.max(0,t-1);continue}if(t===0)n+=s}return n}function Zf(e){let n="",t=0;while(t<e.length){if(e[t]==="/"){if(e[t+1]==="/"||e[t+1]==="*")return n+e.slice(t);let s=e.slice(0,t).trimEnd();if(Rr(s[s.length-1]??"",e,t)){t++;let i=!1;while(t<e.length){if(e[t]==="\\"){t+=2;continue}if(e[t]==="[")i=!0;else if(e[t]==="]")i=!1;else if(e[t]==="/"&&!i){t++;while(t<e.length&&/[gimsuvy]/.test(e[t]))t++;break}t++}continue}}n+=e[t],t++}return n}function Rr(e,n,t){if(e==="")return!0;if("([{,:;!?&|=<>~^+*%-".includes(e))return!0;if(/[A-Za-z_$]/.test(e)){let i=n.slice(0,t).trimEnd();if(/(?:^|[^A-Za-z0-9_$])(?:return|typeof|instanceof|new|delete|void|in|of|yield|await|throw|case)$/.test(i))return!0}return!1}function Gf(e){let n="",t=0,s=null,i=!1;while(t<e.length){let r=e[t],o=e[t+1];if(i){n+=r,i=!1,t++;continue}if(r==="\\"&&s){i=!0,n+=r,t++;continue}if(!s){if(r==='"'){s="double",n+=r,t++;continue}if(r==="'"){s="single",n+=r,t++;continue}if(r==="`"){s="template",n+=r,t++;continue}if(r==="/"&&o==="/")break;if(r==="/"&&o==="*"){t+=2;while(t<e.length){if(e[t]==="*"&&e[t+1]==="/"){t+=2;break}t++}n+=" ";continue}n+=r,t++}else{if(s==="double"&&r==='"'||s==="single"&&r==="'"||s==="template"&&r==="`")s=null;n+=r,t++}}return n}function at(e){let n=new Set,t="code",s=1,i=!1,r=!1,o=!1,l=[];for(let a=0;a<e.length;a++){let c=e[a],u=e[a+1],f=a>0?e[a-1]:"";if(c===`
219
+ `){if(o&&t==="block-comment")n.add(s);else if(!i&&r&&t!=="block-comment")n.add(s);else if(!i&&t==="block-comment")n.add(s);if(s++,i=!1,r=!1,o=t==="block-comment",t==="line-comment")t="code";continue}switch(t){case"code":if(c==="/"&&u==="/")t="line-comment",r=!0,a++;else if(c==="/"&&u==="*"){let m=!1;if(a>0){let h=a-1;while(h>0&&(e[h]===" "||e[h]==="\t"))h--;let d=e[h];if("=([{,;!&|?:~^%+-".includes(d)&&d!==`
220
+ `)m=!0;else if(/[a-z]/.test(d)){let p=e.slice(Math.max(0,h-6),h+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(p))m=!0}}if(m){i=!0,a++;while(a<e.length){if(e[a]==="\\"){a+=2;continue}if(e[a]==="/"){a++;break}if(e[a]===`
221
+ `)break;a++}while(a<e.length&&/[gimsuy]/.test(e[a]))a++;a--}else r=!0,t="block-comment",a++}else if(c==="/"&&u!==void 0){let m=!1;if(a>0){let h=a-1;while(h>0&&(e[h]===" "||e[h]==="\t"))h--;let d=e[h];if("=([{,;!&|?:~^%+-".includes(d)||d===`
222
+ `)m=!0;else if(/[a-z]/.test(d)){let p=e.slice(Math.max(0,h-6),h+1);if(/\b(?:return|case|typeof|void|in|of|new|throw|delete)$/.test(p))m=!0}}if(m){i=!0,a++;while(a<e.length){if(e[a]==="\\"){a+=2;continue}if(e[a]==="/"){a++;break}if(e[a]===`
223
+ `)break;a++}while(a<e.length&&/[gimsuy]/.test(e[a]))a++;a--}else i=!0}else if(c==="'")t="string-single",i=!0;else if(c==='"')t="string-double",i=!0;else if(c==="`")t="string-template",i=!0;else if(c==="{"){if(l.length)l[l.length-1]++;i=!0}else if(c==="}"){if(l.length)if(l[l.length-1]===0)l.pop(),t="string-template";else l[l.length-1]--;i=!0}else if(!/\s/.test(c))i=!0;break;case"string-single":if(c==="\\"){a++;break}if(c==="'")t="code";break;case"string-double":if(c==="\\"){a++;break}if(c==='"')t="code";break;case"string-template":if(c==="\\"){a++;break}if(c==="$"&&u==="{"){l.push(0),t="code",a++;break}if(c==="`")t="code";break;case"line-comment":break;case"block-comment":if(c==="*"&&u==="/")t="code",a++;break}}if(o&&t==="block-comment")n.add(s);else if(!i&&r&&t!=="block-comment")n.add(s);else if(!i&&t==="block-comment")n.add(s);return n}function Mt(e,n,t,s,i){let r=[],o=n.split(/\r?\n/),l=t.format.quotes,a=e.split(".").pop()?.toLowerCase()??"",c=a==="md",u=a==="sh"||a==="bash"||a==="zsh"||a==="ksh"||a==="dash"||/^#!\s*(?:\/usr\/bin\/env\s+)?(?:ba|z|k|da)?sh\b/.test(n),h=(t.rules?.quotes??t.pluginRules?.quotes??t.pluginRules?.["style/quotes"])==="off"||a==="json"||a==="jsonc"||a==="lock"||c||a==="yaml"||a==="yml"||a==="stx"||a==="html"||a==="htm"||a==="vue"||u||e.endsWith("bun.lock"),d=c||a==="yaml"||a==="yml"||a==="json"||a==="jsonc"||u,p=om(e,n,t),y=!1,g=(D)=>D==="warn"?"warning":D==="error"?"error":void 0,x=g(t.rules.noDebugger),k=g(t.rules.noConsole),P=g(t.rules.noTemplateCurlyInString),w=g(t.rules.noCondAssign),M=/\bconsole\.log\s*\(/,A=/^\s*debugger\b/,O=new Set;if(a==="md"){let D=!1;for(let S=0;S<o.length;S++){if(/^(?:`{3,}|~{3,})/.test(o[S].trim())){D=!D;continue}if(D)O.add(S+1)}}let E=wr(n);for(let D=0;D<o.length;D++){let S=o[D],C=D+1;if(i.has(C))continue;if(!h&&!E.has(C)){let T=Gf(Zf(S)),R=Jf(T,l);if(R.length>0&&!y){if(!Te("quotes",C,s))r.push({filePath:e,line:C,column:(R[0]||0)+1,ruleId:"quotes",message:"Inconsistent quote style",severity:"warning",help:`Use ${l} quotes consistently throughout your code. You can change the preferred quote style in your config with format.quotes: '${l==="single"?"double":"single"}'`});y=!0}}let L=0;while(L<S.length&&(S.charCodeAt(L)===32||S.charCodeAt(L)===9))L++;let F=L>0?S.slice(0,L):"";if(p&&F.length>0&&!O.has(C)&&!E.has(C)&&gr(F,t.format.indent,t.format.indentStyle,S)){if(!Te("indent",C,s))r.push({filePath:e,line:C,column:1,ruleId:"indent",message:"Incorrect indentation detected",severity:"warning",help:`Use ${t.format.indentStyle==="spaces"?`${t.format.indent} spaces`:"tabs"} for indentation. Configure with format.indent and format.indentStyle in your config`})}if(!d&&x&&!E.has(C)&&A.test(S)){if(!Te("no-debugger",C,s))r.push({filePath:e,line:C,column:1,ruleId:"no-debugger",message:"Unexpected debugger statement",severity:x,help:"Remove debugger statements before committing code. Use breakpoints in your IDE instead, or run with --fix to auto-remove"})}if(!d&&k&&!E.has(C)&&M.test(S)){let T=S.indexOf("//"),R=S.indexOf("console.");if(T!==-1&&R>T);else{let v=null;for(let I=0;I<S.length;I++){let N=S[I];if(!v){if(N==='"')v="double";else if(N==="'")v="single";else if(N==="`")v="template";else if(S.slice(I).startsWith("console.")){let B=I+1;if(!Te("no-console",C,s))r.push({filePath:e,line:C,column:B,ruleId:"no-console",message:"Unexpected console call",severity:k,help:"Remove console statements before committing. Use a proper logging library or disable this rule if console output is intentional"});break}}else if(v==="double"&&N==='"'||v==="single"&&N==="'"||v==="template"&&N==="`"){let B=0;for(let W=I-1;W>=0&&S[W]==="\\";W--)B++;if(B%2===0)v=null}}}}if(P&&!E.has(C)){let T=S,R=null,v=!1,I=!1,N="",B="";for(let W=0;W<T.length;W++){let _=T[W];if(v){if(B==="\\"){B=_;continue}if(I){if(_==="]")I=!1}else if(_==="[")I=!0;else if(_==="/"){v=!1;while(W+1<T.length&&/[a-z]/i.test(T[W+1]))W++;N="/"}B=_;continue}if(!R){if(_==='"'){R="double",B=_;continue}if(_==="'"){R="single",B=_;continue}if(_==="`"){R="template",B=_;continue}if(_==="/"&&T[W+1]!=="/"&&T[W+1]!=="*"&&Rr(N,T,W)){v=!0,I=!1,B=_;continue}if(_!==" "&&_!=="\t")N=_}else if(R==="double"&&_==='"'||R==="single"&&_==="'"||R==="template"&&_==="`"){if(B!=="\\")R=null}else if(_==="$"&&T[W+1]==="{"&&B!=="\\"&&R!=="template"){if(!Te("no-template-curly-in-string",C,s))r.push({filePath:e,line:C,column:W+1,ruleId:"no-template-curly-in-string",message:"Unexpected template string expression in normal string",severity:P,help:"Change the string quotes from ' or \" to backticks (`) to use template literal interpolation, or escape the $ if you meant to use it literally"});break}B=_}}if(!d&&w&&!E.has(C)){let R=Gf(Zf(S)).replace(/'[^']*'|"[^"]*"/g,'""'),v=(W)=>/[^=!<>]=(?![=>])/.test(W),I=(W)=>{let _=S.match(W);if(_&&_.index!==void 0)return _.index+_[0].length;return Math.max(1,S.indexOf("(")+1)},N=Vf(R,/\b(?:if|while)\s*\(/);if(N){let W=Hf(N);if(v(W)){if(!Te("no-cond-assign",C,s))r.push({filePath:e,line:C,column:I(/\b(?:if|while)\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:w,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}let B=Vf(R,/\bfor\s*\(/);if(B){let W=B.split(";");if(W.length>=2){let _=Hf(W[1]);if(v(_)){if(!Te("no-cond-assign",C,s))r.push({filePath:e,line:C,column:I(/\bfor\s*\(/),ruleId:"no-cond-assign",message:"Unexpected assignment within a conditional expression",severity:w,help:"Use === or == for comparison instead of = (assignment). Wrap intentional assignments in extra parentheses."})}}}}}return r}function cS(e,n,t){let s=lt(n),i=at(n),r=Mt(e,n,t,s,i);try{let o=Vs(t),l={filePath:e,config:t};for(let a of o.checkRules){if(!br(a,e,n))continue;if(!a.rule||typeof a.rule.check!=="function")continue;let c=a.rule.check(n,{...l,options:a.options});for(let u of c){if(Te(u.ruleId,u.line,s))continue;if(i.has(u.line)&&Ks(u.ruleId))continue;let f=nm(u,a.fullRuleId);r.push(a.severity?{...f,severity:a.severity}:f)}}}catch{}return r}async function uS(e,n){ke("runLint:start",{globs:e,options:n});let t=Oe.DIAGNOSTICS;if(t)ee().info("[pickier:diagnostics] Starting lint process...");try{if(t)ee().info("[pickier:diagnostics] Loading config...");let s=await Bt(n.config);ke("config:loaded",{reporter:s.lint.reporter,ext:s.lint.extensions.join(",")});let i=e.length?e:["."],r=jt(i);if(ke("patterns",r),t)ee().info(`[pickier:diagnostics] Patterns to search: ${r.join(", ")}`);let o=n.ext||s.lint.extensions.join(","),l=new Set(o.split(",").map((v)=>{let I=v.trim();return I.startsWith(".")?I:`.${I}`}));if(t)ee().info(`[pickier:diagnostics] File extensions: ${Array.from(l).join(", ")}`);let a=Oe.TIMEOUT_MS;if(t)ee().info(`[pickier:diagnostics] Glob timeout: ${a}ms`);let c=r.some((v)=>{let I=v.replace(/\/?\*\*\/*\*\*$/,""),N=It(I)?I:vt(process.cwd(),I),B=process.cwd();return N!==B&&!N.startsWith(B+tm)}),u=c?tt(ot):tt(s.ignores),f=Ut(u);if(t){if(ee().info(`[pickier:diagnostics] Globbing outside project: ${c}, ignore patterns: ${u.length}`),c)ee().info(`[pickier:diagnostics] Using universal ignores: ${ot.slice(0,5).join(", ")}... (${ot.length} total)`)}let m=[],h=r.length===1&&!/[*?[\]{}()!]/.test(r[0]);if(t)ee().info(`[pickier:diagnostics] Starting file discovery... (nonGlobSingle: ${h})`);if(h)try{if(qs(r[0]).isFile())m=[It(r[0])?r[0]:vt(process.cwd(),r[0])]}catch{}let d=r.length===1&&/\*\*\/*\*$/.test(r[0]);if(!m.length&&d){let v=r[0].replace(/\/?\*\*\/*\*\*$/,"");if(t)ee().info(`[pickier:diagnostics] Using fast directory scan for: ${v}`);try{let N=[It(v)?v:vt(process.cwd(),v)],B=0;while(N.length){let W=N.pop();if(B++,t&&B%100===0)ee().info(`[pickier:diagnostics] Scanned ${B} directories, ${m.length} files found so far...`);let _=Xf(W);for(let z of _){let U=em(W,z),Y=qs(U);if(f(U))continue;if(Y.isDirectory())N.push(U);else m.push(U)}}if(t)ee().info(`[pickier:diagnostics] Fast scan complete: ${B} directories, ${m.length} total files`)}catch(I){if(t)ee().info(`[pickier:diagnostics] Fast scan failed: ${I?.message}, falling back to glob`);m=await qt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob")}}else if(!m.length){if(t)ee().info(`[pickier:diagnostics] Using glob with timeout ${a}ms...`);if(m=await qt(et(r,{dot:!1,ignore:u,onlyFiles:!0,absolute:!0}),a,"glob"),t)ee().info(`[pickier:diagnostics] glob found ${m.length} files`)}if(ke("globbed entries",m.length),t)ee().info(`[pickier:diagnostics] File discovery complete: ${m.length} files found`);if(m.length>1e4){if(ee().warn(`[pickier:warn] Found ${m.length} files. This seems unusually high and may cause memory issues.`),ee().warn("[pickier:warn] Consider checking your ignore patterns or being more specific with your glob pattern."),ee().warn("[pickier:warn] Common culprits: node_modules, build directories, cache folders, or vendor dependencies."),m.length>1e5)return ee().error(`[pickier:error] File count exceeds 100,000 (${m.length}). This will likely cause out-of-memory errors.`),ee().error("[pickier:error] Aborting to prevent crash. Please refine your glob pattern or ignore patterns."),1}if(t)ee().info(`[pickier:diagnostics] Filtering ${m.length} files by extension and ignore patterns...`);let p=0,y=0,g=0,x=0,k=0,P=[];for(let v of m){if(p++,t&&p%1000===0)ee().info(`[pickier:diagnostics] Filtering progress: ${p}/${m.length} files checked, ${y} included...`);if(v.replace(/\\/g,"/").includes("/node_modules/")){g++;continue}if(f(v)){x++;continue}if(!yr(v,l)){k++;continue}P.push(v),y++}if(ke("filter:cli",{total:p,included:y,node_modules:g,ignored:x,wrongExt:k}),ke("filtered files",P.length),t)ee().info("[pickier:diagnostics] Filtering complete:"),ee().info(`[pickier:diagnostics] Total files found: ${p}`),ee().info(`[pickier:diagnostics] Files to lint: ${y}`),ee().info(`[pickier:diagnostics] Excluded (node_modules): ${g}`),ee().info(`[pickier:diagnostics] Excluded (ignored): ${x}`),ee().info(`[pickier:diagnostics] Excluded (wrong extension): ${k}`);if(P.length>5000){if(ee().warn(`[pickier:warn] After filtering, ${P.length} files will be linted. This may take a while and use significant memory.`),P.length>50000)return ee().error(`[pickier:error] ${P.length} files to lint exceeds safe limit (50,000). This will likely cause out-of-memory errors.`),ee().error("[pickier:error] Aborting to prevent crash. Please be more specific with your glob pattern."),ee().error("[pickier:error] Example: Instead of '../stx', try '../stx/src' or '../stx/packages/core'"),1}let w=Oe.CONCURRENCY;if(t)ee().info(`[pickier:diagnostics] Starting to process ${P.length} files with concurrency ${w}...`);let M=0,A=!!n._formatOnly,D=(await sm(P,w,async(v)=>{if(t){if(M++,M===1||M%10===0||M===P.length)ee().info(`[pickier:diagnostics] Processing file ${M}/${P.length}: ${zs(process.cwd(),v)}`)}let I=Qf(v,"utf8");if(A){let z=Us(I,s,v);if(z!==I)if(!n.dryRun)pr(v,z,"utf8");else return[{filePath:v,line:1,column:1,ruleId:"format",message:"File is not formatted",severity:"error",help:"Run pickier format with --write to apply formatting."}];return[]}let N=lt(I),W=/\.(?:ts|js|tsx|jsx|mts|mjs|cts|cjs)$/.test(v)?at(I):new Set,_=Mt(v,I,s,N,W);try{let z=await xr(v,I,s);for(let U of z){if(Te(U.ruleId,U.line,N))continue;if(W.has(U.line)&&Ks(U.ruleId))continue;_.push({filePath:U.filePath,line:U.line,column:U.column,ruleId:U.ruleId,message:U.message,severity:U.severity,...U.help&&{help:U.help}})}}catch{}{let z=new Set;_=_.filter((U)=>{let Y=`${U.line}:${U.column}:${U.ruleId}`;if(z.has(Y))return!1;return z.add(Y),!0})}if(n.fix){let z=rm(v,I,s,N,W);if(z=im(v,z,s),om(v,z,s))z=fg(z,s,lt(z),at(z));if(z!==I){let U=lt(z),Y=at(z);if(_=Mt(v,z,s,U,Y),!n.dryRun)pr(v,z,"utf8");if(n.dryRun&&(n.verbose!==void 0?n.verbose:s.verbose))ee().debug(se.gray(`dry-run: would apply fixes in ${zs(process.cwd(),v)}`))}}return ke("scan done",zs(process.cwd(),v),_.length),_})).flat();if(t)ee().info(`[pickier:diagnostics] Processing complete! Found ${D.length} issues total`);let S=D.filter((v)=>v.severity==="error").length,C=D.filter((v)=>v.severity==="warning").length;if(ke("issues:summary",{errors:S,warnings:C}),t)ee().info(`[pickier:diagnostics] Errors: ${S}, Warnings: ${C}`);let L=n.reporter||s.lint.reporter,F=n.verbose!==void 0?n.verbose:s.verbose;if(L==="json")console.log(JSON.stringify({errors:S,warnings:C,issues:D},null,2));else if(L==="compact")for(let v of D)console.log(`${zs(process.cwd(),v.filePath)}:${v.line}:${v.column} ${v.severity} ${v.ruleId} ${v.message}`);else if(D.length>0)console.log(F?zf(D):qf(D));if(D.length>0&&L!=="json"){let v=S+C,I=v===1?"problem":"problems",N=S===1?"error":"errors",B=C===1?"warning":"warnings",W=Vs(s),_=0,z=0;for(let U of D){let Y=U.ruleId;if(W.fixableRuleIds.has(Y)||W.fixableBareRuleNames.has(Y)){if(U.severity==="error")_++;else if(U.severity==="warning")z++}}if(console.log(),console.log(se.red(`\u2716 ${v} ${I} (${S} ${N}, ${C} ${B})`)),_>0||z>0){let U=_===1?"error":"errors",Y=z===1?"warning":"warnings";console.log(se.gray(` ${_} ${U} and ${z} ${Y} potentially fixable with the \`--fix\` option.`))}}if(F&&L!=="json")console.log(se.gray(`Scanned ${P.length} files, found ${S} errors and ${C} warnings.`));let T=n.maxWarnings??s.lint.maxWarnings,R=Oe.FAIL_ON_WARNINGS;if(S>0)return ke("runLint:end",1),1;if(R&&C>0)return ke("runLint:end",1),1;if(T>=0&&C>T)return ke("runLint:end",1),1;return ke("runLint:end",0),0}catch(s){return ee().error("[pickier:error] runLint failed:",s?.message||s),ke("runLint:exception",s),1}}
224
+ export{YC as a,lS as b,aS as c,xr as d,Mt as e,cS as f,uS as g};