@ebowwa/coder 0.2.1 → 0.7.64

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 (401) hide show
  1. package/README.md +31 -32
  2. package/dist/core/__tests__/permissions.test.d.ts +12 -0
  3. package/dist/core/__tests__/permissions.test.d.ts.map +1 -0
  4. package/dist/core/__tests__/permissions.test.js +851 -0
  5. package/dist/core/agent-loop/__tests__/compaction.test.d.ts +5 -0
  6. package/dist/core/agent-loop/__tests__/compaction.test.d.ts.map +1 -0
  7. package/dist/core/agent-loop/__tests__/compaction.test.js +209 -0
  8. package/dist/core/agent-loop/__tests__/formatters.test.d.ts +5 -0
  9. package/dist/core/agent-loop/__tests__/formatters.test.d.ts.map +1 -0
  10. package/dist/core/agent-loop/__tests__/formatters.test.js +195 -0
  11. package/dist/core/agent-loop/__tests__/index.test.d.ts +5 -0
  12. package/dist/core/agent-loop/__tests__/index.test.d.ts.map +1 -0
  13. package/dist/core/agent-loop/__tests__/index.test.js +121 -0
  14. package/dist/core/agent-loop/__tests__/loop-state.test.d.ts +5 -0
  15. package/dist/core/agent-loop/__tests__/loop-state.test.d.ts.map +1 -0
  16. package/dist/core/agent-loop/__tests__/loop-state.test.js +340 -0
  17. package/dist/core/agent-loop/__tests__/message-builder.test.d.ts +5 -0
  18. package/dist/core/agent-loop/__tests__/message-builder.test.d.ts.map +1 -0
  19. package/dist/core/agent-loop/__tests__/message-builder.test.js +178 -0
  20. package/dist/core/agent-loop/__tests__/tool-executor.test.d.ts +5 -0
  21. package/dist/core/agent-loop/__tests__/tool-executor.test.d.ts.map +1 -0
  22. package/dist/core/agent-loop/__tests__/tool-executor.test.js +331 -0
  23. package/dist/core/agent-loop/compaction.d.ts +39 -0
  24. package/dist/core/agent-loop/compaction.d.ts.map +1 -0
  25. package/dist/core/agent-loop/compaction.js +51 -0
  26. package/dist/core/agent-loop/formatters.d.ts +21 -0
  27. package/dist/core/agent-loop/formatters.d.ts.map +1 -0
  28. package/dist/core/agent-loop/formatters.js +42 -0
  29. package/dist/core/agent-loop/index.d.ts +25 -0
  30. package/dist/core/agent-loop/index.d.ts.map +1 -0
  31. package/dist/core/agent-loop/index.js +83 -0
  32. package/dist/core/agent-loop/loop-state.d.ts +74 -0
  33. package/dist/core/agent-loop/loop-state.d.ts.map +1 -0
  34. package/dist/core/agent-loop/loop-state.js +147 -0
  35. package/dist/core/agent-loop/message-builder.d.ts +13 -0
  36. package/dist/core/agent-loop/message-builder.d.ts.map +1 -0
  37. package/dist/core/agent-loop/message-builder.js +49 -0
  38. package/dist/core/agent-loop/tool-executor.d.ts +23 -0
  39. package/dist/core/agent-loop/tool-executor.d.ts.map +1 -0
  40. package/dist/core/agent-loop/tool-executor.js +152 -0
  41. package/dist/core/agent-loop/turn-executor.d.ts +57 -0
  42. package/dist/core/agent-loop/turn-executor.d.ts.map +1 -0
  43. package/dist/core/agent-loop/turn-executor.js +124 -0
  44. package/dist/core/agent-loop/types.d.ts +141 -0
  45. package/dist/core/agent-loop/types.d.ts.map +1 -0
  46. package/dist/core/agent-loop/types.js +4 -0
  47. package/dist/core/agent-loop.d.ts +17 -0
  48. package/dist/core/agent-loop.d.ts.map +1 -0
  49. package/dist/core/agent-loop.js +16 -0
  50. package/dist/core/api-client-impl.d.ts +62 -0
  51. package/dist/core/api-client-impl.d.ts.map +1 -0
  52. package/dist/core/api-client-impl.js +479 -0
  53. package/dist/core/api-client.d.ts +6 -0
  54. package/dist/core/api-client.d.ts.map +1 -0
  55. package/dist/core/api-client.js +5 -0
  56. package/dist/core/checkpoints.d.ts +128 -0
  57. package/dist/core/checkpoints.d.ts.map +1 -0
  58. package/dist/core/checkpoints.js +438 -0
  59. package/dist/core/claude-md.d.ts +71 -0
  60. package/dist/core/claude-md.d.ts.map +1 -0
  61. package/dist/core/claude-md.js +198 -0
  62. package/dist/core/cognitive-security/hooks.d.ts +138 -0
  63. package/dist/core/cognitive-security/hooks.d.ts.map +1 -0
  64. package/dist/core/cognitive-security/hooks.js +389 -0
  65. package/dist/core/cognitive-security/index.d.ts +751 -0
  66. package/dist/core/cognitive-security/index.d.ts.map +1 -0
  67. package/dist/core/cognitive-security/index.js +1123 -0
  68. package/dist/core/cognitive-security/middleware.d.ts +136 -0
  69. package/dist/core/cognitive-security/middleware.d.ts.map +1 -0
  70. package/dist/core/cognitive-security/middleware.js +376 -0
  71. package/dist/core/config-loader.d.ts +127 -0
  72. package/dist/core/config-loader.d.ts.map +1 -0
  73. package/dist/core/config-loader.js +219 -0
  74. package/dist/core/context-compaction.d.ts +87 -0
  75. package/dist/core/context-compaction.d.ts.map +1 -0
  76. package/dist/core/context-compaction.js +428 -0
  77. package/dist/core/git-status.d.ts +25 -0
  78. package/dist/core/git-status.d.ts.map +1 -0
  79. package/dist/core/git-status.js +204 -0
  80. package/dist/core/image.d.ts +69 -0
  81. package/dist/core/image.d.ts.map +1 -0
  82. package/dist/core/image.js +290 -0
  83. package/dist/core/image.test.d.ts +2 -0
  84. package/dist/core/image.test.d.ts.map +1 -0
  85. package/dist/core/image.test.js +149 -0
  86. package/dist/core/models.d.ts +123 -0
  87. package/dist/core/models.d.ts.map +1 -0
  88. package/dist/core/models.js +325 -0
  89. package/dist/core/permissions.d.ts +81 -0
  90. package/dist/core/permissions.d.ts.map +1 -0
  91. package/dist/core/permissions.js +327 -0
  92. package/dist/core/retry.d.ts +25 -0
  93. package/dist/core/retry.d.ts.map +1 -0
  94. package/dist/core/retry.js +121 -0
  95. package/dist/core/session-store.d.ts +9 -0
  96. package/dist/core/session-store.d.ts.map +1 -0
  97. package/dist/core/session-store.js +10 -0
  98. package/dist/core/sessions/export.d.ts +47 -0
  99. package/dist/core/sessions/export.d.ts.map +1 -0
  100. package/dist/core/sessions/export.js +256 -0
  101. package/dist/core/sessions/index.d.ts +132 -0
  102. package/dist/core/sessions/index.d.ts.map +1 -0
  103. package/dist/core/sessions/index.js +442 -0
  104. package/dist/core/sessions/metadata.d.ts +77 -0
  105. package/dist/core/sessions/metadata.d.ts.map +1 -0
  106. package/dist/core/sessions/metadata.js +233 -0
  107. package/dist/core/sessions/persistence.d.ts +72 -0
  108. package/dist/core/sessions/persistence.d.ts.map +1 -0
  109. package/dist/core/sessions/persistence.js +201 -0
  110. package/dist/core/sessions/types.d.ts +110 -0
  111. package/dist/core/sessions/types.d.ts.map +1 -0
  112. package/dist/core/sessions/types.js +4 -0
  113. package/dist/core/stream-highlighter.d.ts +18 -0
  114. package/dist/core/stream-highlighter.d.ts.map +1 -0
  115. package/dist/core/stream-highlighter.js +916 -0
  116. package/dist/core/system-reminders.d.ts +89 -0
  117. package/dist/core/system-reminders.d.ts.map +1 -0
  118. package/dist/core/system-reminders.js +285 -0
  119. package/dist/ecosystem/hooks/__tests__/index.test.d.ts +5 -0
  120. package/dist/ecosystem/hooks/__tests__/index.test.d.ts.map +1 -0
  121. package/dist/ecosystem/hooks/__tests__/index.test.js +458 -0
  122. package/dist/ecosystem/hooks/index.d.ts +59 -0
  123. package/dist/ecosystem/hooks/index.d.ts.map +1 -0
  124. package/dist/ecosystem/hooks/index.js +294 -0
  125. package/dist/ecosystem/hooks/prompt-evaluator.d.ts +32 -0
  126. package/dist/ecosystem/hooks/prompt-evaluator.d.ts.map +1 -0
  127. package/dist/ecosystem/hooks/prompt-evaluator.js +229 -0
  128. package/dist/ecosystem/skills/index.d.ts +55 -0
  129. package/dist/ecosystem/skills/index.d.ts.map +1 -0
  130. package/dist/ecosystem/skills/index.js +258 -0
  131. package/dist/ecosystem/tools/__tests__/index.test.d.ts +7 -0
  132. package/dist/ecosystem/tools/__tests__/index.test.d.ts.map +1 -0
  133. package/dist/ecosystem/tools/__tests__/index.test.js +856 -0
  134. package/dist/ecosystem/tools/index.d.ts +24 -0
  135. package/dist/ecosystem/tools/index.d.ts.map +1 -0
  136. package/dist/ecosystem/tools/index.js +1709 -0
  137. package/dist/index.d.ts +24 -0
  138. package/dist/index.d.ts.map +1 -0
  139. package/dist/index.js +32 -2
  140. package/dist/interfaces/mcp/client.d.ts +40 -0
  141. package/dist/interfaces/mcp/client.d.ts.map +1 -0
  142. package/dist/interfaces/mcp/client.js +309 -0
  143. package/dist/interfaces/ui/index.d.ts +36 -0
  144. package/dist/interfaces/ui/index.d.ts.map +1 -0
  145. package/dist/interfaces/ui/index.js +61 -0
  146. package/dist/interfaces/ui/spinner.d.ts +140 -0
  147. package/dist/interfaces/ui/spinner.d.ts.map +1 -0
  148. package/dist/interfaces/ui/spinner.js +342 -0
  149. package/dist/interfaces/ui/terminal/cli/index.d.ts +12 -0
  150. package/dist/interfaces/ui/terminal/cli/index.d.ts.map +1 -0
  151. package/dist/interfaces/ui/terminal/cli/index.js +167 -0
  152. package/dist/interfaces/ui/terminal/shared/args.d.ts +39 -0
  153. package/dist/interfaces/ui/terminal/shared/args.d.ts.map +1 -0
  154. package/dist/interfaces/ui/terminal/shared/args.js +176 -0
  155. package/dist/interfaces/ui/terminal/shared/index.d.ts +11 -0
  156. package/dist/interfaces/ui/terminal/shared/index.d.ts.map +1 -0
  157. package/dist/interfaces/ui/terminal/shared/index.js +16 -0
  158. package/dist/interfaces/ui/terminal/shared/loading-state.d.ts +124 -0
  159. package/dist/interfaces/ui/terminal/shared/loading-state.d.ts.map +1 -0
  160. package/dist/interfaces/ui/terminal/shared/loading-state.js +246 -0
  161. package/dist/interfaces/ui/terminal/shared/query.d.ts +22 -0
  162. package/dist/interfaces/ui/terminal/shared/query.d.ts.map +1 -0
  163. package/dist/interfaces/ui/terminal/shared/query.js +100 -0
  164. package/dist/interfaces/ui/terminal/shared/setup.d.ts +33 -0
  165. package/dist/interfaces/ui/terminal/shared/setup.d.ts.map +1 -0
  166. package/dist/interfaces/ui/terminal/shared/setup.js +226 -0
  167. package/dist/interfaces/ui/terminal/shared/status-line.d.ts +117 -0
  168. package/dist/interfaces/ui/terminal/shared/status-line.d.ts.map +1 -0
  169. package/dist/interfaces/ui/terminal/shared/status-line.js +267 -0
  170. package/dist/interfaces/ui/terminal/shared/system-prompt.d.ts +38 -0
  171. package/dist/interfaces/ui/terminal/shared/system-prompt.d.ts.map +1 -0
  172. package/dist/interfaces/ui/terminal/shared/system-prompt.js +102 -0
  173. package/dist/interfaces/ui/terminal/tui/HelpPanel.d.ts +39 -0
  174. package/dist/interfaces/ui/terminal/tui/HelpPanel.d.ts.map +1 -0
  175. package/dist/interfaces/ui/terminal/tui/HelpPanel.js +215 -0
  176. package/dist/interfaces/ui/terminal/tui/InputContext.d.ts +91 -0
  177. package/dist/interfaces/ui/terminal/tui/InputContext.d.ts.map +1 -0
  178. package/dist/interfaces/ui/terminal/tui/InputContext.js +154 -0
  179. package/dist/interfaces/ui/terminal/tui/InputField.d.ts +18 -0
  180. package/dist/interfaces/ui/terminal/tui/InputField.d.ts.map +1 -0
  181. package/dist/interfaces/ui/terminal/tui/InputField.js +41 -0
  182. package/dist/interfaces/ui/terminal/tui/InteractiveTUI.d.ts +16 -0
  183. package/dist/interfaces/ui/terminal/tui/InteractiveTUI.d.ts.map +1 -0
  184. package/dist/interfaces/ui/terminal/tui/InteractiveTUI.js +451 -0
  185. package/dist/interfaces/ui/terminal/tui/MessageArea.d.ts +10 -0
  186. package/dist/interfaces/ui/terminal/tui/MessageArea.d.ts.map +1 -0
  187. package/dist/interfaces/ui/terminal/tui/MessageArea.js +91 -0
  188. package/dist/interfaces/ui/terminal/tui/MessageStore.d.ts +48 -0
  189. package/dist/interfaces/ui/terminal/tui/MessageStore.d.ts.map +1 -0
  190. package/dist/interfaces/ui/terminal/tui/MessageStore.js +151 -0
  191. package/dist/interfaces/ui/terminal/tui/StatusBar.d.ts +9 -0
  192. package/dist/interfaces/ui/terminal/tui/StatusBar.d.ts.map +1 -0
  193. package/dist/interfaces/ui/terminal/tui/StatusBar.js +36 -0
  194. package/dist/interfaces/ui/terminal/tui/commands.d.ts +21 -0
  195. package/dist/interfaces/ui/terminal/tui/commands.d.ts.map +1 -0
  196. package/dist/interfaces/ui/terminal/tui/commands.js +359 -0
  197. package/dist/interfaces/ui/terminal/tui/components/InteractiveElements.d.ts +115 -0
  198. package/dist/interfaces/ui/terminal/tui/components/InteractiveElements.d.ts.map +1 -0
  199. package/dist/interfaces/ui/terminal/tui/components/InteractiveElements.js +306 -0
  200. package/dist/interfaces/ui/terminal/tui/components/MultilineInput.d.ts +92 -0
  201. package/dist/interfaces/ui/terminal/tui/components/MultilineInput.d.ts.map +1 -0
  202. package/dist/interfaces/ui/terminal/tui/components/MultilineInput.js +399 -0
  203. package/dist/interfaces/ui/terminal/tui/components/PaneManager.d.ts +59 -0
  204. package/dist/interfaces/ui/terminal/tui/components/PaneManager.d.ts.map +1 -0
  205. package/dist/interfaces/ui/terminal/tui/components/PaneManager.js +139 -0
  206. package/dist/interfaces/ui/terminal/tui/components/Sidebar.d.ts +68 -0
  207. package/dist/interfaces/ui/terminal/tui/components/Sidebar.d.ts.map +1 -0
  208. package/dist/interfaces/ui/terminal/tui/components/Sidebar.js +340 -0
  209. package/dist/interfaces/ui/terminal/tui/components/index.d.ts +23 -0
  210. package/dist/interfaces/ui/terminal/tui/components/index.d.ts.map +1 -0
  211. package/dist/interfaces/ui/terminal/tui/components/index.js +51 -0
  212. package/dist/interfaces/ui/terminal/tui/console.d.ts +20 -0
  213. package/dist/interfaces/ui/terminal/tui/console.d.ts.map +1 -0
  214. package/dist/interfaces/ui/terminal/tui/console.js +46 -0
  215. package/dist/interfaces/ui/terminal/tui/index.d.ts +20 -0
  216. package/dist/interfaces/ui/terminal/tui/index.d.ts.map +1 -0
  217. package/dist/interfaces/ui/terminal/tui/index.js +28 -0
  218. package/dist/interfaces/ui/terminal/tui/run.d.ts +13 -0
  219. package/dist/interfaces/ui/terminal/tui/run.d.ts.map +1 -0
  220. package/dist/interfaces/ui/terminal/tui/run.js +31 -0
  221. package/dist/interfaces/ui/terminal/tui/spinner.d.ts +44 -0
  222. package/dist/interfaces/ui/terminal/tui/spinner.d.ts.map +1 -0
  223. package/dist/interfaces/ui/terminal/tui/spinner.js +59 -0
  224. package/dist/interfaces/ui/terminal/tui/tui-app.d.ts +39 -0
  225. package/dist/interfaces/ui/terminal/tui/tui-app.d.ts.map +1 -0
  226. package/dist/interfaces/ui/terminal/tui/tui-app.js +198 -0
  227. package/dist/interfaces/ui/terminal/tui/tui-footer.d.ts +167 -0
  228. package/dist/interfaces/ui/terminal/tui/tui-footer.d.ts.map +1 -0
  229. package/dist/interfaces/ui/terminal/tui/tui-footer.js +330 -0
  230. package/dist/interfaces/ui/terminal/tui/types.d.ts +165 -0
  231. package/dist/interfaces/ui/terminal/tui/types.d.ts.map +1 -0
  232. package/dist/interfaces/ui/terminal/tui/types.js +5 -0
  233. package/dist/interfaces/ui/terminal/tui/useInputHandler.d.ts +23 -0
  234. package/dist/interfaces/ui/terminal/tui/useInputHandler.d.ts.map +1 -0
  235. package/dist/interfaces/ui/terminal/tui/useInputHandler.js +72 -0
  236. package/dist/interfaces/ui/terminal/tui/useNativeInput.d.ts +90 -0
  237. package/dist/interfaces/ui/terminal/tui/useNativeInput.d.ts.map +1 -0
  238. package/dist/interfaces/ui/terminal/tui/useNativeInput.js +188 -0
  239. package/dist/native/index.d.ts +480 -0
  240. package/dist/native/index.d.ts.map +1 -0
  241. package/dist/native/index.js +1625 -0
  242. package/dist/teammates/index.d.ts +161 -0
  243. package/dist/teammates/index.d.ts.map +1 -0
  244. package/dist/teammates/index.js +827 -0
  245. package/dist/types/index.d.ts +482 -0
  246. package/dist/types/index.d.ts.map +1 -0
  247. package/dist/types/index.js +52 -0
  248. package/native/README.md +5 -5
  249. package/native/index.darwin-arm64.node +0 -0
  250. package/native/index.node +0 -0
  251. package/native/package.json +4 -4
  252. package/package.json +33 -16
  253. package/packages/src/core/__tests__/permissions.test.ts +1091 -0
  254. package/packages/src/core/agent-loop/__tests__/compaction.test.ts +280 -0
  255. package/packages/src/core/agent-loop/__tests__/formatters.test.ts +234 -0
  256. package/packages/src/core/agent-loop/__tests__/index.test.ts +162 -0
  257. package/packages/src/core/agent-loop/__tests__/loop-state.test.ts +413 -0
  258. package/packages/src/core/agent-loop/__tests__/message-builder.test.ts +229 -0
  259. package/packages/src/core/agent-loop/__tests__/tool-executor.test.ts +457 -0
  260. package/packages/src/core/agent-loop/compaction.ts +88 -0
  261. package/packages/src/core/agent-loop/formatters.ts +50 -0
  262. package/packages/src/core/agent-loop/index.ts +135 -0
  263. package/packages/src/core/agent-loop/loop-state.ts +187 -0
  264. package/packages/src/core/agent-loop/message-builder.ts +62 -0
  265. package/packages/src/core/agent-loop/tool-executor.ts +211 -0
  266. package/packages/src/core/agent-loop/turn-executor.ts +222 -0
  267. package/packages/src/core/agent-loop/types.ts +148 -0
  268. package/packages/src/core/agent-loop.ts +18 -0
  269. package/packages/src/core/api-client-impl.ts +619 -0
  270. package/packages/src/core/api-client.ts +6 -0
  271. package/packages/src/core/checkpoints.ts +606 -0
  272. package/packages/src/core/claude-md.ts +272 -0
  273. package/packages/src/core/cognitive-security/hooks.ts +590 -0
  274. package/packages/src/core/cognitive-security/index.ts +2041 -0
  275. package/packages/src/core/cognitive-security/middleware.ts +536 -0
  276. package/packages/src/core/config-loader.ts +324 -0
  277. package/packages/src/core/context-compaction.ts +578 -0
  278. package/packages/src/core/git-status.ts +262 -0
  279. package/packages/src/core/image.test.ts +180 -0
  280. package/packages/src/core/image.ts +350 -0
  281. package/packages/src/core/lmdb.db +0 -0
  282. package/packages/src/core/lmdb.db-lock +0 -0
  283. package/packages/src/core/models.ts +430 -0
  284. package/packages/src/core/normalizers/todo +4 -0
  285. package/packages/src/core/permissions.ts +431 -0
  286. package/packages/src/core/retry.ts +170 -0
  287. package/packages/src/core/session-store.ts +36 -0
  288. package/packages/src/core/sessions/export.ts +329 -0
  289. package/packages/src/core/sessions/index.ts +587 -0
  290. package/packages/src/core/sessions/metadata.ts +309 -0
  291. package/packages/src/core/sessions/persistence.ts +244 -0
  292. package/packages/src/core/sessions/types.ts +169 -0
  293. package/packages/src/core/stream-highlighter.ts +1123 -0
  294. package/packages/src/core/system-reminders.ts +402 -0
  295. package/packages/src/core/todo +8 -0
  296. package/packages/src/ecosystem/hooks/__tests__/index.test.ts +561 -0
  297. package/packages/src/ecosystem/hooks/index.ts +341 -0
  298. package/packages/src/ecosystem/hooks/prompt-evaluator.ts +300 -0
  299. package/packages/src/ecosystem/skills/index.ts +295 -0
  300. package/packages/src/ecosystem/tools/__tests__/index.test.ts +1335 -0
  301. package/packages/src/ecosystem/tools/index.ts +1877 -0
  302. package/packages/src/index.ts +120 -0
  303. package/packages/src/interfaces/mcp/client.ts +389 -0
  304. package/packages/src/interfaces/ui/Screenshot 2026-03-02 at 9.23.10/342/200/257PM.png +0 -0
  305. package/packages/src/interfaces/ui/Screenshot 2026-03-03 at 10.55.11/342/200/257AM.png +0 -0
  306. package/packages/src/interfaces/ui/index.ts +161 -0
  307. package/packages/src/interfaces/ui/lmdb.db +0 -0
  308. package/packages/src/interfaces/ui/lmdb.db-lock +0 -0
  309. package/packages/src/interfaces/ui/spinner.ts +451 -0
  310. package/packages/src/interfaces/ui/terminal/cli/index.ts +228 -0
  311. package/packages/src/interfaces/ui/terminal/lmdb.db +0 -0
  312. package/packages/src/interfaces/ui/terminal/lmdb.db-lock +0 -0
  313. package/packages/src/interfaces/ui/terminal/shared/args.ts +222 -0
  314. package/packages/src/interfaces/ui/terminal/shared/index.ts +71 -0
  315. package/packages/src/interfaces/ui/terminal/shared/loading-state.ts +322 -0
  316. package/packages/src/interfaces/ui/terminal/shared/query.ts +146 -0
  317. package/packages/src/interfaces/ui/terminal/shared/setup.ts +295 -0
  318. package/packages/src/interfaces/ui/terminal/shared/status-line.ts +358 -0
  319. package/packages/src/interfaces/ui/terminal/shared/system-prompt.ts +146 -0
  320. package/packages/src/interfaces/ui/terminal/tui/HelpPanel.tsx +262 -0
  321. package/packages/src/interfaces/ui/terminal/tui/InputContext.tsx +232 -0
  322. package/packages/src/interfaces/ui/terminal/tui/InputField.tsx +62 -0
  323. package/packages/src/interfaces/ui/terminal/tui/InteractiveTUI.tsx +537 -0
  324. package/packages/src/interfaces/ui/terminal/tui/MessageArea.tsx +107 -0
  325. package/packages/src/interfaces/ui/terminal/tui/MessageStore.tsx +240 -0
  326. package/packages/src/interfaces/ui/terminal/tui/StatusBar.tsx +54 -0
  327. package/packages/src/interfaces/ui/terminal/tui/commands.ts +438 -0
  328. package/packages/src/interfaces/ui/terminal/tui/components/InteractiveElements.tsx +584 -0
  329. package/packages/src/interfaces/ui/terminal/tui/components/MultilineInput.tsx +614 -0
  330. package/packages/src/interfaces/ui/terminal/tui/components/PaneManager.tsx +333 -0
  331. package/packages/src/interfaces/ui/terminal/tui/components/Sidebar.tsx +604 -0
  332. package/packages/src/interfaces/ui/terminal/tui/components/index.ts +118 -0
  333. package/packages/src/interfaces/ui/terminal/tui/console.ts +49 -0
  334. package/packages/src/interfaces/ui/terminal/tui/index.ts +90 -0
  335. package/packages/src/interfaces/ui/terminal/tui/run.tsx +42 -0
  336. package/packages/src/interfaces/ui/terminal/tui/spinner.ts +69 -0
  337. package/packages/src/interfaces/ui/terminal/tui/tui-app.tsx +390 -0
  338. package/packages/src/interfaces/ui/terminal/tui/tui-footer.ts +422 -0
  339. package/packages/src/interfaces/ui/terminal/tui/types.ts +186 -0
  340. package/packages/src/interfaces/ui/terminal/tui/useInputHandler.ts +104 -0
  341. package/packages/src/interfaces/ui/terminal/tui/useNativeInput.ts +239 -0
  342. package/packages/src/lmdb.db +0 -0
  343. package/packages/src/lmdb.db-lock +0 -0
  344. package/packages/src/native/index.ts +2345 -0
  345. package/packages/src/teammates/index.ts +982 -0
  346. package/packages/src/types/index.ts +722 -0
  347. package/dist/cli.js +0 -148
  348. package/dist/index-0pkak453.js +0 -136
  349. package/dist/index-0qd0x8b4.js +0 -110
  350. package/dist/index-0x3kprq6.js +0 -240
  351. package/dist/index-1eawy937.js +0 -308
  352. package/dist/index-24m2aygy.js +0 -240
  353. package/dist/index-29xcjnne.js +0 -280
  354. package/dist/index-2avyytn5.js +0 -349
  355. package/dist/index-4ms367ey.js +0 -136
  356. package/dist/index-4w2t3b0m.js +0 -240
  357. package/dist/index-4xfgd8nz.js +0 -261
  358. package/dist/index-5acjp9gc.js +0 -157
  359. package/dist/index-5s15hr56.js +0 -136
  360. package/dist/index-6e4wf341.js +0 -349
  361. package/dist/index-6fvnkedw.js +0 -240
  362. package/dist/index-6rqpmd4g.js +0 -128
  363. package/dist/index-77ckwnbm.js +0 -280
  364. package/dist/index-9knxy49k.js +0 -128
  365. package/dist/index-9zrnw4zx.js +0 -128
  366. package/dist/index-bk21w99v.js +0 -280
  367. package/dist/index-c41n76fv.js +0 -240
  368. package/dist/index-cb4ppjdt.js +0 -255
  369. package/dist/index-cfb2edt6.js +0 -240
  370. package/dist/index-cmfa38hh.js +0 -308
  371. package/dist/index-datjz8q1.js +0 -257
  372. package/dist/index-eadf4wvn.js +0 -240
  373. package/dist/index-em5k0m3z.js +0 -345
  374. package/dist/index-gh8r333a.js +0 -110
  375. package/dist/index-gkx6k2tr.js +0 -261
  376. package/dist/index-h5cabfks.js +0 -155
  377. package/dist/index-hcrpwyy3.js +0 -261
  378. package/dist/index-hk7fwwa8.js +0 -257
  379. package/dist/index-jb8cw7f8.js +0 -136
  380. package/dist/index-kbyw4th1.js +0 -347
  381. package/dist/index-kgj5gqnm.js +0 -345
  382. package/dist/index-mdf6xp1z.js +0 -255
  383. package/dist/index-mrhv8kvc.js +0 -280
  384. package/dist/index-mt4743dd.js +0 -161
  385. package/dist/index-qnwsg97q.js +0 -240
  386. package/dist/index-qwdy6x44.js +0 -261
  387. package/dist/index-rmj77261.js +0 -157
  388. package/dist/index-sbbw1a61.js +0 -349
  389. package/dist/index-svy5bcpn.js +0 -345
  390. package/dist/index-tvmy7tm9.js +0 -261
  391. package/dist/index-tzz4vzkj.js +0 -312
  392. package/dist/index-vz80zmhe.js +0 -110
  393. package/dist/index-wed2fk67.js +0 -240
  394. package/dist/index-wksgzz8e.js +0 -280
  395. package/dist/index-wn2m4wma.js +0 -240
  396. package/dist/index-xha05vjc.js +0 -257
  397. package/dist/index-yc6eh8p8.js +0 -136
  398. package/dist/index-ycjxx9ft.js +0 -240
  399. package/dist/index-z0gzd0fc.js +0 -110
  400. package/dist/index-z8cwtf8j.js +0 -240
  401. package/dist/index-zy5mtt00.js +0 -128
@@ -1,349 +0,0 @@
1
- // @bun
2
- var r9=Object.create;var{getPrototypeOf:n9,defineProperty:Q5,getOwnPropertyNames:i9}=Object;var s9=Object.prototype.hasOwnProperty;var X5=($,Z,J)=>{J=$!=null?r9(n9($)):{};let Q=Z||!$||!$.__esModule?Q5(J,"default",{value:$,enumerable:!0}):J;for(let X of i9($))if(!s9.call(Q,X))Q5(Q,X,{get:()=>$[X],enumerable:!0});return Q};var T=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var k=import.meta.require;var S0=T((yW,_1)=>{/*!
3
- Copyright 2013 Lovell Fuller and others.
4
- SPDX-License-Identifier: Apache-2.0
5
- */var L1=($)=>typeof $<"u"&&$!==null,RZ=($)=>typeof $==="object",CZ=($)=>Object.prototype.toString.call($)==="[object Object]",NZ=($)=>typeof $==="function",PZ=($)=>typeof $==="boolean",DZ=($)=>$ instanceof Buffer,MZ=($)=>{if(L1($))switch($.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},FZ=($)=>$ instanceof ArrayBuffer,IZ=($)=>typeof $==="string"&&$.length>0,EZ=($)=>typeof $==="number"&&!Number.isNaN($),SZ=($)=>Number.isInteger($),TZ=($,Z,J)=>$>=Z&&$<=J,vZ=($,Z)=>Z.includes($),xZ=($,Z,J)=>Error(`Expected ${Z} for ${$} but received ${J} of type ${typeof J}`),kZ=($,Z)=>{return Z.message=$.message,Z};_1.exports={defined:L1,object:RZ,plainObject:CZ,fn:NZ,bool:PZ,buffer:DZ,typedArray:MZ,arrayBuffer:FZ,string:IZ,number:EZ,integer:SZ,inRange:TZ,inArray:vZ,invalidParameterError:xZ,nativeError:kZ}});var C1=T((fW,R1)=>{var w1=()=>process.platform==="linux",x6=null,OZ=()=>{if(!x6)if(w1()&&process.report){let $=process.report.excludeNetwork;process.report.excludeNetwork=!0,x6=process.report.getReport(),process.report.excludeNetwork=$}else x6={};return x6};R1.exports={isLinux:w1,getReport:OZ}});var P1=T((bW,N1)=>{var N4=k("fs"),yZ=($)=>{let Z=N4.openSync($,"r"),J=Buffer.alloc(2048),Q=N4.readSync(Z,J,0,2048,0);return N4.close(Z,()=>{}),J.subarray(0,Q)},fZ=($)=>new Promise((Z,J)=>{N4.open($,"r",(Q,X)=>{if(Q)J(Q);else{let V=Buffer.alloc(2048);N4.read(X,V,0,2048,0,(K,W)=>{Z(V.subarray(0,W)),N4.close(X,()=>{})})}})});N1.exports={LDD_PATH:"/usr/bin/ldd",SELF_PATH:"/proc/self/exe",readFileSync:yZ,readFile:fZ}});var M1=T((hW,D1)=>{var bZ=($)=>{if($.length<64)return null;if($.readUInt32BE(0)!==2135247942)return null;if($.readUInt8(4)!==2)return null;if($.readUInt8(5)!==1)return null;let Z=$.readUInt32LE(32),J=$.readUInt16LE(54),Q=$.readUInt16LE(56);for(let X=0;X<Q;X++){let V=Z+X*J;if($.readUInt32LE(V)===3){let W=$.readUInt32LE(V+8),H=$.readUInt32LE(V+32);return $.subarray(W,W+H).toString().replace(/\0.*$/g,"")}}return null};D1.exports={interpreterPath:bZ}});var O6=T((gW,m1)=>{var I1=k("child_process"),{isLinux:P4,getReport:E1}=C1(),{LDD_PATH:k6,SELF_PATH:S1,readFile:E2,readFileSync:S2}=P1(),{interpreterPath:T1}=M1(),T0,v0,x0,t0="",v1=()=>{if(!t0)return new Promise(($)=>{I1.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(Z,J)=>{t0=Z?" ":J,$(t0)})});return t0},x1=()=>{if(!t0)try{t0=I1.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch($){t0=" "}return t0},c0="glibc",k1=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,Y4="musl",hZ=($)=>$.includes("libc.musl-")||$.includes("ld-musl-"),O1=()=>{let $=E1();if($.header&&$.header.glibcVersionRuntime)return c0;if(Array.isArray($.sharedObjects)){if($.sharedObjects.some(hZ))return Y4}return null},y1=($)=>{let[Z,J]=$.split(/[\r\n]+/);if(Z&&Z.includes(c0))return c0;if(J&&J.includes(Y4))return Y4;return null},f1=($)=>{if($){if($.includes("/ld-musl-"))return Y4;else if($.includes("/ld-linux-"))return c0}return null},b1=($)=>{if($=$.toString(),$.includes("musl"))return Y4;if($.includes("GNU C Library"))return c0;return null},gZ=async()=>{if(v0!==void 0)return v0;v0=null;try{let $=await E2(k6);v0=b1($)}catch($){}return v0},dZ=()=>{if(v0!==void 0)return v0;v0=null;try{let $=S2(k6);v0=b1($)}catch($){}return v0},uZ=async()=>{if(T0!==void 0)return T0;T0=null;try{let $=await E2(S1),Z=T1($);T0=f1(Z)}catch($){}return T0},mZ=()=>{if(T0!==void 0)return T0;T0=null;try{let $=S2(S1),Z=T1($);T0=f1(Z)}catch($){}return T0},h1=async()=>{let $=null;if(P4()){if($=await uZ(),!$){if($=await gZ(),!$)$=O1();if(!$){let Z=await v1();$=y1(Z)}}}return $},g1=()=>{let $=null;if(P4()){if($=mZ(),!$){if($=dZ(),!$)$=O1();if(!$){let Z=x1();$=y1(Z)}}}return $},cZ=async()=>P4()&&await h1()!==c0,lZ=()=>P4()&&g1()!==c0,pZ=async()=>{if(x0!==void 0)return x0;x0=null;try{let Z=(await E2(k6)).match(k1);if(Z)x0=Z[1]}catch($){}return x0},aZ=()=>{if(x0!==void 0)return x0;x0=null;try{let Z=S2(k6).match(k1);if(Z)x0=Z[1]}catch($){}return x0},d1=()=>{let $=E1();if($.header&&$.header.glibcVersionRuntime)return $.header.glibcVersionRuntime;return null},F1=($)=>$.trim().split(/\s+/)[1],u1=($)=>{let[Z,J,Q]=$.split(/[\r\n]+/);if(Z&&Z.includes(c0))return F1(Z);if(J&&Q&&J.includes(Y4))return F1(Q);return null},rZ=async()=>{let $=null;if(P4()){if($=await pZ(),!$)$=d1();if(!$){let Z=await v1();$=u1(Z)}}return $},nZ=()=>{let $=null;if(P4()){if($=aZ(),!$)$=d1();if(!$){let Z=x1();$=u1(Z)}}return $};m1.exports={GLIBC:c0,MUSL:Y4,family:h1,familySync:g1,isNonGlibcLinux:cZ,isNonGlibcLinuxSync:lZ,version:rZ,versionSync:nZ}});var J6=T((dW,c1)=>{var iZ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};c1.exports=iZ});var y6=T((uW,l1)=>{var sZ=Number.MAX_SAFE_INTEGER||9007199254740991,oZ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];l1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:sZ,RELEASE_TYPES:oZ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Q6=T((k0,p1)=>{var{MAX_SAFE_COMPONENT_LENGTH:T2,MAX_SAFE_BUILD_LENGTH:eZ,MAX_LENGTH:tZ}=y6(),$J=J6();k0=p1.exports={};var ZJ=k0.re=[],JJ=k0.safeRe=[],N=k0.src=[],QJ=k0.safeSrc=[],P=k0.t={},XJ=0,v2="[a-zA-Z0-9-]",VJ=[["\\s",1],["\\d",tZ],[v2,eZ]],KJ=($)=>{for(let[Z,J]of VJ)$=$.split(`${Z}*`).join(`${Z}{0,${J}}`).split(`${Z}+`).join(`${Z}{1,${J}}`);return $},E=($,Z,J)=>{let Q=KJ(Z),X=XJ++;$J($,X,Z),P[$]=X,N[X]=Z,QJ[X]=Q,ZJ[X]=new RegExp(Z,J?"g":void 0),JJ[X]=new RegExp(Q,J?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${v2}*`);E("MAINVERSION",`(${N[P.NUMERICIDENTIFIER]})\\.(${N[P.NUMERICIDENTIFIER]})\\.(${N[P.NUMERICIDENTIFIER]})`);E("MAINVERSIONLOOSE",`(${N[P.NUMERICIDENTIFIERLOOSE]})\\.(${N[P.NUMERICIDENTIFIERLOOSE]})\\.(${N[P.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASEIDENTIFIER",`(?:${N[P.NONNUMERICIDENTIFIER]}|${N[P.NUMERICIDENTIFIER]})`);E("PRERELEASEIDENTIFIERLOOSE",`(?:${N[P.NONNUMERICIDENTIFIER]}|${N[P.NUMERICIDENTIFIERLOOSE]})`);E("PRERELEASE",`(?:-(${N[P.PRERELEASEIDENTIFIER]}(?:\\.${N[P.PRERELEASEIDENTIFIER]})*))`);E("PRERELEASELOOSE",`(?:-?(${N[P.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${N[P.PRERELEASEIDENTIFIERLOOSE]})*))`);E("BUILDIDENTIFIER",`${v2}+`);E("BUILD",`(?:\\+(${N[P.BUILDIDENTIFIER]}(?:\\.${N[P.BUILDIDENTIFIER]})*))`);E("FULLPLAIN",`v?${N[P.MAINVERSION]}${N[P.PRERELEASE]}?${N[P.BUILD]}?`);E("FULL",`^${N[P.FULLPLAIN]}$`);E("LOOSEPLAIN",`[v=\\s]*${N[P.MAINVERSIONLOOSE]}${N[P.PRERELEASELOOSE]}?${N[P.BUILD]}?`);E("LOOSE",`^${N[P.LOOSEPLAIN]}$`);E("GTLT","((?:<|>)?=?)");E("XRANGEIDENTIFIERLOOSE",`${N[P.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);E("XRANGEIDENTIFIER",`${N[P.NUMERICIDENTIFIER]}|x|X|\\*`);E("XRANGEPLAIN",`[v=\\s]*(${N[P.XRANGEIDENTIFIER]})(?:\\.(${N[P.XRANGEIDENTIFIER]})(?:\\.(${N[P.XRANGEIDENTIFIER]})(?:${N[P.PRERELEASE]})?${N[P.BUILD]}?)?)?`);E("XRANGEPLAINLOOSE",`[v=\\s]*(${N[P.XRANGEIDENTIFIERLOOSE]})(?:\\.(${N[P.XRANGEIDENTIFIERLOOSE]})(?:\\.(${N[P.XRANGEIDENTIFIERLOOSE]})(?:${N[P.PRERELEASELOOSE]})?${N[P.BUILD]}?)?)?`);E("XRANGE",`^${N[P.GTLT]}\\s*${N[P.XRANGEPLAIN]}$`);E("XRANGELOOSE",`^${N[P.GTLT]}\\s*${N[P.XRANGEPLAINLOOSE]}$`);E("COERCEPLAIN",`(^|[^\\d])(\\d{1,${T2}})(?:\\.(\\d{1,${T2}}))?(?:\\.(\\d{1,${T2}}))?`);E("COERCE",`${N[P.COERCEPLAIN]}(?:$|[^\\d])`);E("COERCEFULL",N[P.COERCEPLAIN]+`(?:${N[P.PRERELEASE]})?(?:${N[P.BUILD]})?(?:$|[^\\d])`);E("COERCERTL",N[P.COERCE],!0);E("COERCERTLFULL",N[P.COERCEFULL],!0);E("LONETILDE","(?:~>?)");E("TILDETRIM",`(\\s*)${N[P.LONETILDE]}\\s+`,!0);k0.tildeTrimReplace="$1~";E("TILDE",`^${N[P.LONETILDE]}${N[P.XRANGEPLAIN]}$`);E("TILDELOOSE",`^${N[P.LONETILDE]}${N[P.XRANGEPLAINLOOSE]}$`);E("LONECARET","(?:\\^)");E("CARETTRIM",`(\\s*)${N[P.LONECARET]}\\s+`,!0);k0.caretTrimReplace="$1^";E("CARET",`^${N[P.LONECARET]}${N[P.XRANGEPLAIN]}$`);E("CARETLOOSE",`^${N[P.LONECARET]}${N[P.XRANGEPLAINLOOSE]}$`);E("COMPARATORLOOSE",`^${N[P.GTLT]}\\s*(${N[P.LOOSEPLAIN]})$|^$`);E("COMPARATOR",`^${N[P.GTLT]}\\s*(${N[P.FULLPLAIN]})$|^$`);E("COMPARATORTRIM",`(\\s*)${N[P.GTLT]}\\s*(${N[P.LOOSEPLAIN]}|${N[P.XRANGEPLAIN]})`,!0);k0.comparatorTrimReplace="$1$2$3";E("HYPHENRANGE",`^\\s*(${N[P.XRANGEPLAIN]})\\s+-\\s+(${N[P.XRANGEPLAIN]})\\s*$`);E("HYPHENRANGELOOSE",`^\\s*(${N[P.XRANGEPLAINLOOSE]})\\s+-\\s+(${N[P.XRANGEPLAINLOOSE]})\\s*$`);E("STAR","(<|>)?=?\\s*\\*");E("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$");E("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")});var f6=T((mW,a1)=>{var WJ=Object.freeze({loose:!0}),HJ=Object.freeze({}),qJ=($)=>{if(!$)return HJ;if(typeof $!=="object")return WJ;return $};a1.exports=qJ});var s1=T((cW,i1)=>{var r1=/^[0-9]+$/,n1=($,Z)=>{if(typeof $==="number"&&typeof Z==="number")return $===Z?0:$<Z?-1:1;let J=r1.test($),Q=r1.test(Z);if(J&&Q)$=+$,Z=+Z;return $===Z?0:J&&!Q?-1:Q&&!J?1:$<Z?-1:1},YJ=($,Z)=>n1(Z,$);i1.exports={compareIdentifiers:n1,rcompareIdentifiers:YJ}});var D4=T((lW,e1)=>{var b6=J6(),{MAX_LENGTH:o1,MAX_SAFE_INTEGER:h6}=y6(),{safeRe:g6,t:d6}=Q6(),zJ=f6(),{compareIdentifiers:x2}=s1();class N0{constructor($,Z){if(Z=zJ(Z),$ instanceof N0)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else $=$.version;else if(typeof $!=="string")throw TypeError(`Invalid version. Must be a string. Got type "${typeof $}".`);if($.length>o1)throw TypeError(`version is longer than ${o1} characters`);b6("SemVer",$,Z),this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease;let J=$.trim().match(Z.loose?g6[d6.LOOSE]:g6[d6.FULL]);if(!J)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+J[1],this.minor=+J[2],this.patch=+J[3],this.major>h6||this.major<0)throw TypeError("Invalid major version");if(this.minor>h6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>h6||this.patch<0)throw TypeError("Invalid patch version");if(!J[4])this.prerelease=[];else this.prerelease=J[4].split(".").map((Q)=>{if(/^[0-9]+$/.test(Q)){let X=+Q;if(X>=0&&X<h6)return X}return Q});this.build=J[5]?J[5].split("."):[],this.format()}format(){if(this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length)this.version+=`-${this.prerelease.join(".")}`;return this.version}toString(){return this.version}compare($){if(b6("SemVer.compare",this.version,this.options,$),!($ instanceof N0)){if(typeof $==="string"&&$===this.version)return 0;$=new N0($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof N0))$=new N0($,this.options);if(this.major<$.major)return-1;if(this.major>$.major)return 1;if(this.minor<$.minor)return-1;if(this.minor>$.minor)return 1;if(this.patch<$.patch)return-1;if(this.patch>$.patch)return 1;return 0}comparePre($){if(!($ instanceof N0))$=new N0($,this.options);if(this.prerelease.length&&!$.prerelease.length)return-1;else if(!this.prerelease.length&&$.prerelease.length)return 1;else if(!this.prerelease.length&&!$.prerelease.length)return 0;let Z=0;do{let J=this.prerelease[Z],Q=$.prerelease[Z];if(b6("prerelease compare",Z,J,Q),J===void 0&&Q===void 0)return 0;else if(Q===void 0)return 1;else if(J===void 0)return-1;else if(J===Q)continue;else return x2(J,Q)}while(++Z)}compareBuild($){if(!($ instanceof N0))$=new N0($,this.options);let Z=0;do{let J=this.build[Z],Q=$.build[Z];if(b6("build compare",Z,J,Q),J===void 0&&Q===void 0)return 0;else if(Q===void 0)return 1;else if(J===void 0)return-1;else if(J===Q)continue;else return x2(J,Q)}while(++Z)}inc($,Z,J){if($.startsWith("pre")){if(!Z&&J===!1)throw Error("invalid increment argument: identifier is empty");if(Z){let Q=`-${Z}`.match(this.options.loose?g6[d6.PRERELEASELOOSE]:g6[d6.PRERELEASE]);if(!Q||Q[1]!==Z)throw Error(`invalid identifier: ${Z}`)}}switch($){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",Z,J);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",Z,J);break;case"prepatch":this.prerelease.length=0,this.inc("patch",Z,J),this.inc("pre",Z,J);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",Z,J);this.inc("pre",Z,J);break;case"release":if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":if(this.minor!==0||this.patch!==0||this.prerelease.length===0)this.major++;this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":if(this.patch!==0||this.prerelease.length===0)this.minor++;this.patch=0,this.prerelease=[];break;case"patch":if(this.prerelease.length===0)this.patch++;this.prerelease=[];break;case"pre":{let Q=Number(J)?1:0;if(this.prerelease.length===0)this.prerelease=[Q];else{let X=this.prerelease.length;while(--X>=0)if(typeof this.prerelease[X]==="number")this.prerelease[X]++,X=-2;if(X===-1){if(Z===this.prerelease.join(".")&&J===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(Q)}}if(Z){let X=[Z,Q];if(J===!1)X=[Z];if(x2(this.prerelease[0],Z)===0){if(isNaN(this.prerelease[1]))this.prerelease=X}else this.prerelease=X}break}default:throw Error(`invalid increment argument: ${$}`)}if(this.raw=this.format(),this.build.length)this.raw+=`+${this.build.join(".")}`;return this}}e1.exports=N0});var Z$=T((pW,$$)=>{var t1=D4(),GJ=($,Z,J=!1)=>{if($ instanceof t1)return $;try{return new t1($,Z)}catch(Q){if(!J)return null;throw Q}};$$.exports=GJ});var Q$=T((aW,J$)=>{var jJ=D4(),UJ=Z$(),{safeRe:u6,t:m6}=Q6(),AJ=($,Z)=>{if($ instanceof jJ)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;Z=Z||{};let J=null;if(!Z.rtl)J=$.match(Z.includePrerelease?u6[m6.COERCEFULL]:u6[m6.COERCE]);else{let H=Z.includePrerelease?u6[m6.COERCERTLFULL]:u6[m6.COERCERTL],q;while((q=H.exec($))&&(!J||J.index+J[0].length!==$.length)){if(!J||q.index+q[0].length!==J.index+J[0].length)J=q;H.lastIndex=q.index+q[1].length+q[2].length}H.lastIndex=-1}if(J===null)return null;let Q=J[2],X=J[3]||"0",V=J[4]||"0",K=Z.includePrerelease&&J[5]?`-${J[5]}`:"",W=Z.includePrerelease&&J[6]?`+${J[6]}`:"";return UJ(`${Q}.${X}.${V}${K}${W}`,Z)};J$.exports=AJ});var z4=T((rW,V$)=>{var X$=D4(),BJ=($,Z,J)=>new X$($,J).compare(new X$(Z,J));V$.exports=BJ});var k2=T((nW,K$)=>{var LJ=z4(),_J=($,Z,J)=>LJ($,Z,J)>=0;K$.exports=_J});var q$=T((iW,H$)=>{class W${constructor(){this.max=1000,this.map=new Map}get($){let Z=this.map.get($);if(Z===void 0)return;else return this.map.delete($),this.map.set($,Z),Z}delete($){return this.map.delete($)}set($,Z){if(!this.delete($)&&Z!==void 0){if(this.map.size>=this.max){let Q=this.map.keys().next().value;this.delete(Q)}this.map.set($,Z)}return this}}H$.exports=W$});var z$=T((sW,Y$)=>{var wJ=z4(),RJ=($,Z,J)=>wJ($,Z,J)===0;Y$.exports=RJ});var j$=T((oW,G$)=>{var CJ=z4(),NJ=($,Z,J)=>CJ($,Z,J)!==0;G$.exports=NJ});var A$=T((eW,U$)=>{var PJ=z4(),DJ=($,Z,J)=>PJ($,Z,J)>0;U$.exports=DJ});var L$=T((tW,B$)=>{var MJ=z4(),FJ=($,Z,J)=>MJ($,Z,J)<0;B$.exports=FJ});var w$=T(($H,_$)=>{var IJ=z4(),EJ=($,Z,J)=>IJ($,Z,J)<=0;_$.exports=EJ});var C$=T((ZH,R$)=>{var SJ=z$(),TJ=j$(),vJ=A$(),xJ=k2(),kJ=L$(),OJ=w$(),yJ=($,Z,J,Q)=>{switch(Z){case"===":if(typeof $==="object")$=$.version;if(typeof J==="object")J=J.version;return $===J;case"!==":if(typeof $==="object")$=$.version;if(typeof J==="object")J=J.version;return $!==J;case"":case"=":case"==":return SJ($,J,Q);case"!=":return TJ($,J,Q);case">":return vJ($,J,Q);case">=":return xJ($,J,Q);case"<":return kJ($,J,Q);case"<=":return OJ($,J,Q);default:throw TypeError(`Invalid operator: ${Z}`)}};R$.exports=yJ});var E$=T((JH,I$)=>{var X6=Symbol("SemVer ANY");class c6{static get ANY(){return X6}constructor($,Z){if(Z=N$(Z),$ instanceof c6)if($.loose===!!Z.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),y2("comparator",$,Z),this.options=Z,this.loose=!!Z.loose,this.parse($),this.semver===X6)this.value="";else this.value=this.operator+this.semver.version;y2("comp",this)}parse($){let Z=this.options.loose?P$[D$.COMPARATORLOOSE]:P$[D$.COMPARATOR],J=$.match(Z);if(!J)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=J[1]!==void 0?J[1]:"",this.operator==="=")this.operator="";if(!J[2])this.semver=X6;else this.semver=new M$(J[2],this.options.loose)}toString(){return this.value}test($){if(y2("Comparator.test",$,this.options.loose),this.semver===X6||$===X6)return!0;if(typeof $==="string")try{$=new M$($,this.options)}catch(Z){return!1}return O2($,this.operator,this.semver,this.options)}intersects($,Z){if(!($ instanceof c6))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new F$($.value,Z).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new F$(this.value,Z).test($.semver)}if(Z=N$(Z),Z.includePrerelease&&(this.value==="<0.0.0-0"||$.value==="<0.0.0-0"))return!1;if(!Z.includePrerelease&&(this.value.startsWith("<0.0.0")||$.value.startsWith("<0.0.0")))return!1;if(this.operator.startsWith(">")&&$.operator.startsWith(">"))return!0;if(this.operator.startsWith("<")&&$.operator.startsWith("<"))return!0;if(this.semver.version===$.semver.version&&this.operator.includes("=")&&$.operator.includes("="))return!0;if(O2(this.semver,"<",$.semver,Z)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(O2(this.semver,">",$.semver,Z)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}I$.exports=c6;var N$=f6(),{safeRe:P$,t:D$}=Q6(),O2=C$(),y2=J6(),M$=D4(),F$=f2()});var f2=T((QH,x$)=>{var fJ=/\s+/g;class V6{constructor($,Z){if(Z=hJ(Z),$ instanceof V6)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else return new V6($.raw,Z);if($ instanceof b2)return this.raw=$.value,this.set=[[$]],this.formatted=void 0,this;if(this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease,this.raw=$.trim().replace(fJ," "),this.set=this.raw.split("||").map((J)=>this.parseRange(J.trim())).filter((J)=>J.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let J=this.set[0];if(this.set=this.set.filter((Q)=>!T$(Q[0])),this.set.length===0)this.set=[J];else if(this.set.length>1){for(let Q of this.set)if(Q.length===1&&pJ(Q[0])){this.set=[Q];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted="";for(let $=0;$<this.set.length;$++){if($>0)this.formatted+="||";let Z=this.set[$];for(let J=0;J<Z.length;J++){if(J>0)this.formatted+=" ";this.formatted+=Z[J].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let J=((this.options.includePrerelease&&cJ)|(this.options.loose&&lJ))+":"+$,Q=S$.get(J);if(Q)return Q;let X=this.options.loose,V=X?Q0[e.HYPHENRANGELOOSE]:Q0[e.HYPHENRANGE];$=$.replace(V,Z3(this.options.includePrerelease)),g("hyphen replace",$),$=$.replace(Q0[e.COMPARATORTRIM],dJ),g("comparator trim",$),$=$.replace(Q0[e.TILDETRIM],uJ),g("tilde trim",$),$=$.replace(Q0[e.CARETTRIM],mJ),g("caret trim",$);let K=$.split(" ").map((z)=>aJ(z,this.options)).join(" ").split(/\s+/).map((z)=>$3(z,this.options));if(X)K=K.filter((z)=>{return g("loose invalid filter",z,this.options),!!z.match(Q0[e.COMPARATORLOOSE])});g("range list",K);let W=new Map,H=K.map((z)=>new b2(z,this.options));for(let z of H){if(T$(z))return[z];W.set(z.value,z)}if(W.size>1&&W.has(""))W.delete("");let q=[...W.values()];return S$.set(J,q),q}intersects($,Z){if(!($ instanceof V6))throw TypeError("a Range is required");return this.set.some((J)=>{return v$(J,Z)&&$.set.some((Q)=>{return v$(Q,Z)&&J.every((X)=>{return Q.every((V)=>{return X.intersects(V,Z)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new gJ($,this.options)}catch(Z){return!1}for(let Z=0;Z<this.set.length;Z++)if(J3(this.set[Z],$,this.options))return!0;return!1}}x$.exports=V6;var bJ=q$(),S$=new bJ,hJ=f6(),b2=E$(),g=J6(),gJ=D4(),{safeRe:Q0,t:e,comparatorTrimReplace:dJ,tildeTrimReplace:uJ,caretTrimReplace:mJ}=Q6(),{FLAG_INCLUDE_PRERELEASE:cJ,FLAG_LOOSE:lJ}=y6(),T$=($)=>$.value==="<0.0.0-0",pJ=($)=>$.value==="",v$=($,Z)=>{let J=!0,Q=$.slice(),X=Q.pop();while(J&&Q.length)J=Q.every((V)=>{return X.intersects(V,Z)}),X=Q.pop();return J},aJ=($,Z)=>{return $=$.replace(Q0[e.BUILD],""),g("comp",$,Z),$=iJ($,Z),g("caret",$),$=rJ($,Z),g("tildes",$),$=oJ($,Z),g("xrange",$),$=tJ($,Z),g("stars",$),$},X0=($)=>!$||$.toLowerCase()==="x"||$==="*",rJ=($,Z)=>{return $.trim().split(/\s+/).map((J)=>nJ(J,Z)).join(" ")},nJ=($,Z)=>{let J=Z.loose?Q0[e.TILDELOOSE]:Q0[e.TILDE];return $.replace(J,(Q,X,V,K,W)=>{g("tilde",$,Q,X,V,K,W);let H;if(X0(X))H="";else if(X0(V))H=`>=${X}.0.0 <${+X+1}.0.0-0`;else if(X0(K))H=`>=${X}.${V}.0 <${X}.${+V+1}.0-0`;else if(W)g("replaceTilde pr",W),H=`>=${X}.${V}.${K}-${W} <${X}.${+V+1}.0-0`;else H=`>=${X}.${V}.${K} <${X}.${+V+1}.0-0`;return g("tilde return",H),H})},iJ=($,Z)=>{return $.trim().split(/\s+/).map((J)=>sJ(J,Z)).join(" ")},sJ=($,Z)=>{g("caret",$,Z);let J=Z.loose?Q0[e.CARETLOOSE]:Q0[e.CARET],Q=Z.includePrerelease?"-0":"";return $.replace(J,(X,V,K,W,H)=>{g("caret",$,X,V,K,W,H);let q;if(X0(V))q="";else if(X0(K))q=`>=${V}.0.0${Q} <${+V+1}.0.0-0`;else if(X0(W))if(V==="0")q=`>=${V}.${K}.0${Q} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.0${Q} <${+V+1}.0.0-0`;else if(H)if(g("replaceCaret pr",H),V==="0")if(K==="0")q=`>=${V}.${K}.${W}-${H} <${V}.${K}.${+W+1}-0`;else q=`>=${V}.${K}.${W}-${H} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.${W}-${H} <${+V+1}.0.0-0`;else if(g("no pr"),V==="0")if(K==="0")q=`>=${V}.${K}.${W}${Q} <${V}.${K}.${+W+1}-0`;else q=`>=${V}.${K}.${W}${Q} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.${W} <${+V+1}.0.0-0`;return g("caret return",q),q})},oJ=($,Z)=>{return g("replaceXRanges",$,Z),$.split(/\s+/).map((J)=>eJ(J,Z)).join(" ")},eJ=($,Z)=>{$=$.trim();let J=Z.loose?Q0[e.XRANGELOOSE]:Q0[e.XRANGE];return $.replace(J,(Q,X,V,K,W,H)=>{g("xRange",$,Q,X,V,K,W,H);let q=X0(V),z=q||X0(K),G=z||X0(W),U=G;if(X==="="&&U)X="";if(H=Z.includePrerelease?"-0":"",q)if(X===">"||X==="<")Q="<0.0.0-0";else Q="*";else if(X&&U){if(z)K=0;if(W=0,X===">")if(X=">=",z)V=+V+1,K=0,W=0;else K=+K+1,W=0;else if(X==="<=")if(X="<",z)V=+V+1;else K=+K+1;if(X==="<")H="-0";Q=`${X+V}.${K}.${W}${H}`}else if(z)Q=`>=${V}.0.0${H} <${+V+1}.0.0-0`;else if(G)Q=`>=${V}.${K}.0${H} <${V}.${+K+1}.0-0`;return g("xRange return",Q),Q})},tJ=($,Z)=>{return g("replaceStars",$,Z),$.trim().replace(Q0[e.STAR],"")},$3=($,Z)=>{return g("replaceGTE0",$,Z),$.trim().replace(Q0[Z.includePrerelease?e.GTE0PRE:e.GTE0],"")},Z3=($)=>(Z,J,Q,X,V,K,W,H,q,z,G,U)=>{if(X0(Q))J="";else if(X0(X))J=`>=${Q}.0.0${$?"-0":""}`;else if(X0(V))J=`>=${Q}.${X}.0${$?"-0":""}`;else if(K)J=`>=${J}`;else J=`>=${J}${$?"-0":""}`;if(X0(q))H="";else if(X0(z))H=`<${+q+1}.0.0-0`;else if(X0(G))H=`<${q}.${+z+1}.0-0`;else if(U)H=`<=${q}.${z}.${G}-${U}`;else if($)H=`<${q}.${z}.${+G+1}-0`;else H=`<=${H}`;return`${J} ${H}`.trim()},J3=($,Z,J)=>{for(let Q=0;Q<$.length;Q++)if(!$[Q].test(Z))return!1;if(Z.prerelease.length&&!J.includePrerelease){for(let Q=0;Q<$.length;Q++){if(g($[Q].semver),$[Q].semver===b2.ANY)continue;if($[Q].semver.prerelease.length>0){let X=$[Q].semver;if(X.major===Z.major&&X.minor===Z.minor&&X.patch===Z.patch)return!0}}return!1}return!0}});var O$=T((XH,k$)=>{var Q3=f2(),X3=($,Z,J)=>{try{Z=new Q3(Z,J)}catch(Q){return!1}return Z.test($)};k$.exports=X3});var h2=T((VH,V3)=>{V3.exports={name:"sharp",description:"High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, GIF, AVIF and TIFF images",version:"0.34.5",author:"Lovell Fuller <npm@lovell.info>",homepage:"https://sharp.pixelplumbing.com",contributors:["Pierre Inglebert <pierre.inglebert@gmail.com>","Jonathan Ong <jonathanrichardong@gmail.com>","Chanon Sajjamanochai <chanon.s@gmail.com>","Juliano Julio <julianojulio@gmail.com>","Daniel Gasienica <daniel@gasienica.ch>","Julian Walker <julian@fiftythree.com>","Amit Pitaru <pitaru.amit@gmail.com>","Brandon Aaron <hello.brandon@aaron.sh>","Andreas Lind <andreas@one.com>","Maurus Cuelenaere <mcuelenaere@gmail.com>","Linus Unneb\xE4ck <linus@folkdatorn.se>","Victor Mateevitsi <mvictoras@gmail.com>","Alaric Holloway <alaric.holloway@gmail.com>","Bernhard K. Weisshuhn <bkw@codingforce.com>","Chris Riley <criley@primedia.com>","David Carley <dacarley@gmail.com>","John Tobin <john@limelightmobileinc.com>","Kenton Gray <kentongray@gmail.com>","Felix B\xFCnemann <Felix.Buenemann@gmail.com>","Samy Al Zahrani <samyalzahrany@gmail.com>","Chintan Thakkar <lemnisk8@gmail.com>","F. Orlando Galashan <frulo@gmx.de>","Kleis Auke Wolthuizen <info@kleisauke.nl>","Matt Hirsch <mhirsch@media.mit.edu>","Matthias Thoemmes <thoemmes@gmail.com>","Patrick Paskaris <patrick@paskaris.gr>","J\xE9r\xE9my Lal <kapouer@melix.org>","Rahul Nanwani <r.nanwani@gmail.com>","Alice Monday <alice0meta@gmail.com>","Kristo Jorgenson <kristo.jorgenson@gmail.com>","YvesBos <yves_bos@outlook.com>","Guy Maliar <guy@tailorbrands.com>","Nicolas Coden <nicolas@ncoden.fr>","Matt Parrish <matt.r.parrish@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Matthew McEachen <matthew+github@mceachen.org>","Jarda Kot\u011B\u0161ovec <jarda.kotesovec@gmail.com>","Kenric D'Souza <kenric.dsouza@gmail.com>","Oleh Aleinyk <oleg.aleynik@gmail.com>","Marcel Bretschneider <marcel.bretschneider@gmail.com>","Andrea Bianco <andrea.bianco@unibas.ch>","Rik Heywood <rik@rik.org>","Thomas Parisot <hi@oncletom.io>","Nathan Graves <nathanrgraves+github@gmail.com>","Tom Lokhorst <tom@lokhorst.eu>","Espen Hovlandsdal <espen@hovlandsdal.com>","Sylvain Dumont <sylvain.dumont35@gmail.com>","Alun Davies <alun.owain.davies@googlemail.com>","Aidan Hoolachan <ajhoolachan21@gmail.com>","Axel Eirola <axel.eirola@iki.fi>","Freezy <freezy@xbmc.org>","Daiz <taneli.vatanen@gmail.com>","Julian Aubourg <j@ubourg.net>","Keith Belovay <keith@picthrive.com>","Michael B. Klein <mbklein@gmail.com>","Jordan Prudhomme <jordan@raboland.fr>","Ilya Ovdin <iovdin@gmail.com>","Andargor <andargor@yahoo.com>","Paul Neave <paul.neave@gmail.com>","Brendan Kennedy <brenwken@gmail.com>","Brychan Bennett-Odlum <git@brychan.io>","Edward Silverton <e.silverton@gmail.com>","Roman Malieiev <aromaleev@gmail.com>","Tomas Szabo <tomas.szabo@deftomat.com>","Robert O'Rourke <robert@o-rourke.org>","Guillermo Alfonso Varela Chouci\xF1o <guillevch@gmail.com>","Christian Flintrup <chr@gigahost.dk>","Manan Jadhav <manan@motionden.com>","Leon Radley <leon@radley.se>","alza54 <alza54@thiocod.in>","Jacob Smith <jacob@frende.me>","Michael Nutt <michael@nutt.im>","Brad Parham <baparham@gmail.com>","Taneli Vatanen <taneli.vatanen@gmail.com>","Joris Dugu\xE9 <zaruike10@gmail.com>","Chris Banks <christopher.bradley.banks@gmail.com>","Ompal Singh <ompal.hitm09@gmail.com>","Brodan <christopher.hranj@gmail.com>","Ankur Parihar <ankur.github@gmail.com>","Brahim Ait elhaj <brahima@gmail.com>","Mart Jansink <m.jansink@gmail.com>","Lachlan Newman <lachnewman007@gmail.com>","Dennis Beatty <dennis@dcbeatty.com>","Ingvar Stepanyan <me@rreverser.com>","Don Denton <don@happycollision.com>"],scripts:{build:"node install/build.js",install:"node install/check.js || npm run build",clean:"rm -rf src/build/ .nyc_output/ coverage/ test/fixtures/output.*",test:"npm run lint && npm run test-unit",lint:"npm run lint-cpp && npm run lint-js && npm run lint-types","lint-cpp":"cpplint --quiet src/*.h src/*.cc","lint-js":"biome lint","lint-types":"tsd --files ./test/types/sharp.test-d.ts","test-leak":"./test/leak/leak.sh","test-unit":"node --experimental-test-coverage test/unit.mjs","package-from-local-build":"node npm/from-local-build.js","package-release-notes":"node npm/release-notes.js","docs-build":"node docs/build.mjs","docs-serve":"cd docs && npm start","docs-publish":"cd docs && npm run build && npx firebase-tools deploy --project pixelplumbing --only hosting:pixelplumbing-sharp"},type:"commonjs",main:"lib/index.js",types:"lib/index.d.ts",files:["install","lib","src/*.{cc,h,gyp}"],repository:{type:"git",url:"git://github.com/lovell/sharp.git"},keywords:["jpeg","png","webp","avif","tiff","gif","svg","jp2","dzi","image","resize","thumbnail","crop","embed","libvips","vips"],dependencies:{"@img/colour":"^1.0.0","detect-libc":"^2.1.2",semver:"^7.7.3"},optionalDependencies:{"@img/sharp-darwin-arm64":"0.34.5","@img/sharp-darwin-x64":"0.34.5","@img/sharp-libvips-darwin-arm64":"1.2.4","@img/sharp-libvips-darwin-x64":"1.2.4","@img/sharp-libvips-linux-arm":"1.2.4","@img/sharp-libvips-linux-arm64":"1.2.4","@img/sharp-libvips-linux-ppc64":"1.2.4","@img/sharp-libvips-linux-riscv64":"1.2.4","@img/sharp-libvips-linux-s390x":"1.2.4","@img/sharp-libvips-linux-x64":"1.2.4","@img/sharp-libvips-linuxmusl-arm64":"1.2.4","@img/sharp-libvips-linuxmusl-x64":"1.2.4","@img/sharp-linux-arm":"0.34.5","@img/sharp-linux-arm64":"0.34.5","@img/sharp-linux-ppc64":"0.34.5","@img/sharp-linux-riscv64":"0.34.5","@img/sharp-linux-s390x":"0.34.5","@img/sharp-linux-x64":"0.34.5","@img/sharp-linuxmusl-arm64":"0.34.5","@img/sharp-linuxmusl-x64":"0.34.5","@img/sharp-wasm32":"0.34.5","@img/sharp-win32-arm64":"0.34.5","@img/sharp-win32-ia32":"0.34.5","@img/sharp-win32-x64":"0.34.5"},devDependencies:{"@biomejs/biome":"^2.3.4","@cpplint/cli":"^0.1.0","@emnapi/runtime":"^1.7.0","@img/sharp-libvips-dev":"1.2.4","@img/sharp-libvips-dev-wasm32":"1.2.4","@img/sharp-libvips-win32-arm64":"1.2.4","@img/sharp-libvips-win32-ia32":"1.2.4","@img/sharp-libvips-win32-x64":"1.2.4","@types/node":"*",emnapi:"^1.7.0","exif-reader":"^2.0.2","extract-zip":"^2.0.1",icc:"^3.0.0","jsdoc-to-markdown":"^9.1.3","node-addon-api":"^8.5.0","node-gyp":"^11.5.0","tar-fs":"^3.1.1",tsd:"^0.33.0"},license:"Apache-2.0",engines:{node:"^18.17.0 || ^20.3.0 || >=21.0.0"},config:{libvips:">=8.17.3"},funding:{url:"https://opencollective.com/libvips"}}});var d2=T((KH,l$)=>{/*!
6
- Copyright 2013 Lovell Fuller and others.
7
- SPDX-License-Identifier: Apache-2.0
8
- */var{spawnSync:l6}=k("child_process"),{createHash:K3}=k("crypto"),h$=Q$(),W3=k2(),H3=O$(),y$=O6(),{config:q3,engines:f$,optionalDependencies:Y3}=h2(),z3=process.env.npm_package_config_libvips||q3.libvips,g$=h$(z3).version,G3=["darwin-arm64","darwin-x64","linux-arm","linux-arm64","linux-ppc64","linux-riscv64","linux-s390x","linux-x64","linuxmusl-arm64","linuxmusl-x64","win32-arm64","win32-ia32","win32-x64"],p6={encoding:"utf8",shell:!0},j3=($)=>{if($ instanceof Error)console.error(`sharp: Installation error: ${$.message}`);else console.log(`sharp: ${$}`)},d$=()=>y$.isNonGlibcLinuxSync()?y$.familySync():"",U3=()=>`${process.platform}${d$()}-${process.arch}`,M4=()=>{if(u$())return"wasm32";let{npm_config_arch:$,npm_config_platform:Z,npm_config_libc:J}=process.env,Q=typeof J==="string"?J:d$();return`${Z||process.platform}${Q}-${$||process.arch}`},A3=()=>{try{return k(`@img/sharp-libvips-dev-${M4()}/include`)}catch{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/include");})()}catch{}}return""},B3=()=>{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/cplusplus");})()}catch{}return""},L3=()=>{try{return k(`@img/sharp-libvips-dev-${M4()}/lib`)}catch{try{return k(`@img/sharp-libvips-${M4()}/lib`)}catch{}}return""},_3=()=>{if(process.release?.name==="node"&&process.versions){if(!H3(process.versions.node,f$.node))return{found:process.versions.node,expected:f$.node}}},u$=()=>{let{CC:$}=process.env;return Boolean($?.endsWith("/emcc"))},w3=()=>{if(process.platform==="darwin"&&process.arch==="x64")return(l6("sysctl sysctl.proc_translated",p6).stdout||"").trim()==="sysctl.proc_translated: 1";return!1},b$=($)=>K3("sha512").update($).digest("hex"),R3=()=>{try{let $=b$(`imgsharp-libvips-${M4()}`),Z=h$(Y3[`@img/sharp-libvips-${M4()}`],{includePrerelease:!0}).version;return b$(`${$}npm:${Z}`).slice(0,10)}catch{}return""},C3=()=>l6(`node-gyp rebuild --directory=src ${u$()?"--nodedir=emscripten":""}`,{...p6,stdio:"inherit"}).status,m$=()=>{if(process.platform!=="win32")return(l6("pkg-config --modversion vips-cpp",{...p6,env:{...process.env,PKG_CONFIG_PATH:c$()}}).stdout||"").trim();else return""},c$=()=>{if(process.platform!=="win32")return[(l6('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',p6).stdout||"").trim(),process.env.PKG_CONFIG_PATH,"/usr/local/lib/pkgconfig","/usr/lib/pkgconfig","/usr/local/libdata/pkgconfig","/usr/libdata/pkgconfig"].filter(Boolean).join(":");else return""},g2=($,Z,J)=>{if(J)J(`Detected ${Z}, skipping search for globally-installed libvips`);return $},N3=($)=>{if(Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)===!0)return g2(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",$);if(Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)===!0)return g2(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",$);if(w3())return g2(!1,"Rosetta",$);let Z=m$();return!!Z&&W3(Z,g$)};l$.exports={minimumLibvipsVersion:g$,prebuiltPlatforms:G3,buildPlatformArch:M4,buildSharpLibvipsIncludeDir:A3,buildSharpLibvipsCPlusPlusDir:B3,buildSharpLibvipsLibDir:L3,isUnsupportedNodeRuntime:_3,runtimePlatformArch:U3,log:j3,yarnLocator:R3,spawnRebuild:C3,globalLibvipsVersion:m$,pkgConfigPath:c$,useGlobalLibvips:N3}});var W6=T((HH,a$)=>{/*!
9
- Copyright 2013 Lovell Fuller and others.
10
- SPDX-License-Identifier: Apache-2.0
11
- */var{familySync:P3,versionSync:D3}=O6(),{runtimePlatformArch:M3,isUnsupportedNodeRuntime:p$,prebuiltPlatforms:F3,minimumLibvipsVersion:I3}=d2(),G4=M3(),E3=[`../src/build/Release/sharp-${G4}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${G4}/sharp.node`,"@img/sharp-wasm32/sharp.node"],u2,F4,K6=[];for(u2 of E3)try{F4=k(u2);break}catch($){K6.push($)}if(F4&&u2.startsWith("@img/sharp-linux-x64")&&!F4._isUsingX64V2()){let $=Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");$.code="Unsupported CPU",K6.push($),F4=null}if(F4)a$.exports=F4;else{let[$,Z,J]=["linux","darwin","win32"].map((V)=>G4.startsWith(V)),Q=[`Could not load the "sharp" module using the ${G4} runtime`];K6.forEach((V)=>{if(V.code!=="MODULE_NOT_FOUND")Q.push(`${V.code}: ${V.message}`)});let X=K6.map((V)=>V.message).join(" ");if(Q.push("Possible solutions:"),p$()){let{found:V,expected:K}=p$();Q.push("- Please upgrade Node.js:",` Found ${V}`,` Requires ${K}`)}else if(F3.includes(G4)){let[V,K]=G4.split("-"),W=V.endsWith("musl")?" --libc=musl":"";Q.push("- Ensure optional dependencies can be installed:"," npm install --include=optional sharp","- Ensure your package manager supports multi-platform installation:"," See https://sharp.pixelplumbing.com/install#cross-platform","- Add platform-specific dependencies:",` npm install --os=${V.replace("musl","")}${W} --cpu=${K} sharp`)}else Q.push(`- Manually install libvips >= ${I3}`,"- Add experimental WebAssembly-based dependencies:"," npm install --cpu=wasm32 sharp"," npm install @img/sharp-wasm32");if($&&/(symbol not found|CXXABI_)/i.test(X))try{let{config:V}=k(`@img/sharp-libvips-${G4}/package`),K=`${P3()} ${D3()}`,W=`${V.musl?"musl":"glibc"} ${V.musl||V.glibc}`;Q.push("- Update your OS:",` Found ${K}`,` Requires ${W}`)}catch(V){}if($&&/\/snap\/core[0-9]{2}/.test(X))Q.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node");if(Z&&/Incompatible library version/.test(X))Q.push("- Update Homebrew:"," brew update && brew upgrade vips");if(K6.some((V)=>V.code==="ERR_DLOPEN_DISABLED"))Q.push("- Run Node.js without using the --no-addons flag");if(J&&/The specified procedure could not be found/.test(X))Q.push("- Using the canvas package on Windows?"," See https://sharp.pixelplumbing.com/install#canvas-and-windows","- Check for outdated versions of sharp in the dependency tree:"," npm ls sharp");throw Q.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),Error(Q.join(`
12
- `))}});var n$=T((YH,r$)=>{/*!
13
- Copyright 2013 Lovell Fuller and others.
14
- SPDX-License-Identifier: Apache-2.0
15
- */var S3=k("util"),m2=k("stream"),T3=S0();W6();var v3=S3.debuglog("sharp"),x3=($)=>{j4.queue.emit("change",$)},j4=function($,Z){if(arguments.length===1&&!T3.defined($))throw Error("Invalid input");if(!(this instanceof j4))return new j4($,Z);return m2.Duplex.call(this),this.options={topOffsetPre:-1,leftOffsetPre:-1,widthPre:-1,heightPre:-1,topOffsetPost:-1,leftOffsetPost:-1,widthPost:-1,heightPost:-1,width:-1,height:-1,canvas:"crop",position:0,resizeBackground:[0,0,0,255],angle:0,rotationAngle:0,rotationBackground:[0,0,0,255],rotateBefore:!1,orientBefore:!1,flip:!1,flop:!1,extendTop:0,extendBottom:0,extendLeft:0,extendRight:0,extendBackground:[0,0,0,255],extendWith:"background",withoutEnlargement:!1,withoutReduction:!1,affineMatrix:[],affineBackground:[0,0,0,255],affineIdx:0,affineIdy:0,affineOdx:0,affineOdy:0,affineInterpolator:this.constructor.interpolators.bilinear,kernel:"lanczos3",fastShrinkOnLoad:!0,tint:[-1,0,0,0],flatten:!1,flattenBackground:[0,0,0],unflatten:!1,negate:!1,negateAlpha:!0,medianSize:0,blurSigma:0,precision:"integer",minAmpl:0.2,sharpenSigma:0,sharpenM1:1,sharpenM2:2,sharpenX1:2,sharpenY2:10,sharpenY3:20,threshold:0,thresholdGrayscale:!0,trimBackground:[],trimThreshold:-1,trimLineArt:!1,dilateWidth:0,erodeWidth:0,gamma:0,gammaOut:0,greyscale:!1,normalise:!1,normaliseLower:1,normaliseUpper:99,claheWidth:0,claheHeight:0,claheMaxSlope:3,brightness:1,saturation:1,hue:0,lightness:0,booleanBufferIn:null,booleanFileIn:"",joinChannelIn:[],extractChannel:-1,removeAlpha:!1,ensureAlpha:-1,colourspace:"srgb",colourspacePipeline:"last",composite:[],fileOut:"",formatOut:"input",streamOut:!1,keepMetadata:0,withMetadataOrientation:-1,withMetadataDensity:0,withIccProfile:"",withExif:{},withExifMerge:!0,withXmp:"",resolveWithObject:!1,loop:-1,delay:[],jpegQuality:80,jpegProgressive:!1,jpegChromaSubsampling:"4:2:0",jpegTrellisQuantisation:!1,jpegOvershootDeringing:!1,jpegOptimiseScans:!1,jpegOptimiseCoding:!0,jpegQuantisationTable:0,pngProgressive:!1,pngCompressionLevel:6,pngAdaptiveFiltering:!1,pngPalette:!1,pngQuality:100,pngEffort:7,pngBitdepth:8,pngDither:1,jp2Quality:80,jp2TileHeight:512,jp2TileWidth:512,jp2Lossless:!1,jp2ChromaSubsampling:"4:4:4",webpQuality:80,webpAlphaQuality:100,webpLossless:!1,webpNearLossless:!1,webpSmartSubsample:!1,webpSmartDeblock:!1,webpPreset:"default",webpEffort:4,webpMinSize:!1,webpMixed:!1,gifBitdepth:8,gifEffort:7,gifDither:1,gifInterFrameMaxError:0,gifInterPaletteMaxError:3,gifKeepDuplicateFrames:!1,gifReuse:!0,gifProgressive:!1,tiffQuality:80,tiffCompression:"jpeg",tiffBigtiff:!1,tiffPredictor:"horizontal",tiffPyramid:!1,tiffMiniswhite:!1,tiffBitdepth:8,tiffTile:!1,tiffTileHeight:256,tiffTileWidth:256,tiffXres:1,tiffYres:1,tiffResolutionUnit:"inch",heifQuality:50,heifLossless:!1,heifCompression:"av1",heifEffort:4,heifChromaSubsampling:"4:4:4",heifBitdepth:8,jxlDistance:1,jxlDecodingTier:0,jxlEffort:7,jxlLossless:!1,rawDepth:"uchar",tileSize:256,tileOverlap:0,tileContainer:"fs",tileLayout:"dz",tileFormat:"last",tileDepth:"last",tileAngle:0,tileSkipBlanks:-1,tileBackground:[255,255,255,255],tileCentre:!1,tileId:"https://example.com/iiif",tileBasename:"",timeoutSeconds:0,linearA:[],linearB:[],pdfBackground:[255,255,255,255],debuglog:(J)=>{this.emit("warning",J),v3(J)},queueListener:x3},this.options.input=this._createInputDescriptor($,Z,{allowStream:!0}),this};Object.setPrototypeOf(j4.prototype,m2.Duplex.prototype);Object.setPrototypeOf(j4,m2.Duplex);function k3(){let $=this.constructor.call(),{debuglog:Z,queueListener:J,...Q}=this.options;if($.options=structuredClone(Q),$.options.debuglog=Z,$.options.queueListener=J,this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$.options.input.buffer=this.options.input.buffer,$.emit("finish")});return $}Object.assign(j4.prototype,{clone:k3});r$.exports=j4});var o$=T((zH,s$)=>{/*!
16
- Copyright 2013 Lovell Fuller and others.
17
- SPDX-License-Identifier: Apache-2.0
18
- */var j=S0(),$4=W6(),O3={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},y3=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function i$($){let Z=y3.filter((J)=>j.defined($[J])).map((J)=>[J,$[J]]);return Z.length?Object.fromEntries(Z):void 0}function f3($,Z,J){let Q={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(j.string($))Q.file=$;else if(j.buffer($)){if($.length===0)throw Error("Input Buffer is empty");Q.buffer=$}else if(j.arrayBuffer($)){if($.byteLength===0)throw Error("Input bit Array is empty");Q.buffer=Buffer.from($,0,$.byteLength)}else if(j.typedArray($)){if($.length===0)throw Error("Input Bit Array is empty");Q.buffer=Buffer.from($.buffer,$.byteOffset,$.byteLength)}else if(j.plainObject($)&&!j.defined(Z)){if(Z=$,i$(Z))Q.buffer=[]}else if(!j.defined($)&&!j.defined(Z)&&j.object(J)&&J.allowStream)Q.buffer=[];else if(Array.isArray($))if($.length>1)if(!this.options.joining)this.options.joining=!0,this.options.join=$.map((X)=>this._createInputDescriptor(X));else throw Error("Recursive join is unsupported");else throw Error("Expected at least two images to join");else throw Error(`Unsupported input '${$}' of type ${typeof $}${j.defined(Z)?` when also providing options of type ${typeof Z}`:""}`);if(j.object(Z)){if(j.defined(Z.failOnError))if(j.bool(Z.failOnError))Q.failOn=Z.failOnError?"warning":"none";else throw j.invalidParameterError("failOnError","boolean",Z.failOnError);if(j.defined(Z.failOn))if(j.string(Z.failOn)&&j.inArray(Z.failOn,["none","truncated","error","warning"]))Q.failOn=Z.failOn;else throw j.invalidParameterError("failOn","one of: none, truncated, error, warning",Z.failOn);if(j.defined(Z.autoOrient))if(j.bool(Z.autoOrient))Q.autoOrient=Z.autoOrient;else throw j.invalidParameterError("autoOrient","boolean",Z.autoOrient);if(j.defined(Z.density))if(j.inRange(Z.density,1,1e5))Q.density=Z.density;else throw j.invalidParameterError("density","number between 1 and 100000",Z.density);if(j.defined(Z.ignoreIcc))if(j.bool(Z.ignoreIcc))Q.ignoreIcc=Z.ignoreIcc;else throw j.invalidParameterError("ignoreIcc","boolean",Z.ignoreIcc);if(j.defined(Z.limitInputPixels))if(j.bool(Z.limitInputPixels))Q.limitInputPixels=Z.limitInputPixels?268402689:0;else if(j.integer(Z.limitInputPixels)&&j.inRange(Z.limitInputPixels,0,Number.MAX_SAFE_INTEGER))Q.limitInputPixels=Z.limitInputPixels;else throw j.invalidParameterError("limitInputPixels","positive integer",Z.limitInputPixels);if(j.defined(Z.unlimited))if(j.bool(Z.unlimited))Q.unlimited=Z.unlimited;else throw j.invalidParameterError("unlimited","boolean",Z.unlimited);if(j.defined(Z.sequentialRead))if(j.bool(Z.sequentialRead))Q.sequentialRead=Z.sequentialRead;else throw j.invalidParameterError("sequentialRead","boolean",Z.sequentialRead);if(j.defined(Z.raw)){if(j.object(Z.raw)&&j.integer(Z.raw.width)&&Z.raw.width>0&&j.integer(Z.raw.height)&&Z.raw.height>0&&j.integer(Z.raw.channels)&&j.inRange(Z.raw.channels,1,4))switch(Q.rawWidth=Z.raw.width,Q.rawHeight=Z.raw.height,Q.rawChannels=Z.raw.channels,$.constructor){case Uint8Array:case Uint8ClampedArray:Q.rawDepth="uchar";break;case Int8Array:Q.rawDepth="char";break;case Uint16Array:Q.rawDepth="ushort";break;case Int16Array:Q.rawDepth="short";break;case Uint32Array:Q.rawDepth="uint";break;case Int32Array:Q.rawDepth="int";break;case Float32Array:Q.rawDepth="float";break;case Float64Array:Q.rawDepth="double";break;default:Q.rawDepth="uchar";break}else throw Error("Expected width, height and channels for raw pixel input");if(Q.rawPremultiplied=!1,j.defined(Z.raw.premultiplied))if(j.bool(Z.raw.premultiplied))Q.rawPremultiplied=Z.raw.premultiplied;else throw j.invalidParameterError("raw.premultiplied","boolean",Z.raw.premultiplied);if(Q.rawPageHeight=0,j.defined(Z.raw.pageHeight))if(j.integer(Z.raw.pageHeight)&&Z.raw.pageHeight>0&&Z.raw.pageHeight<=Z.raw.height){if(Z.raw.height%Z.raw.pageHeight!==0)throw Error(`Expected raw.height ${Z.raw.height} to be a multiple of raw.pageHeight ${Z.raw.pageHeight}`);Q.rawPageHeight=Z.raw.pageHeight}else throw j.invalidParameterError("raw.pageHeight","positive integer",Z.raw.pageHeight)}if(j.defined(Z.animated))if(j.bool(Z.animated))Q.pages=Z.animated?-1:1;else throw j.invalidParameterError("animated","boolean",Z.animated);if(j.defined(Z.pages))if(j.integer(Z.pages)&&j.inRange(Z.pages,-1,1e5))Q.pages=Z.pages;else throw j.invalidParameterError("pages","integer between -1 and 100000",Z.pages);if(j.defined(Z.page))if(j.integer(Z.page)&&j.inRange(Z.page,0,1e5))Q.page=Z.page;else throw j.invalidParameterError("page","integer between 0 and 100000",Z.page);if(j.object(Z.openSlide)&&j.defined(Z.openSlide.level))if(j.integer(Z.openSlide.level)&&j.inRange(Z.openSlide.level,0,256))Q.openSlideLevel=Z.openSlide.level;else throw j.invalidParameterError("openSlide.level","integer between 0 and 256",Z.openSlide.level);else if(j.defined(Z.level))if(j.integer(Z.level)&&j.inRange(Z.level,0,256))Q.openSlideLevel=Z.level;else throw j.invalidParameterError("level","integer between 0 and 256",Z.level);if(j.object(Z.tiff)&&j.defined(Z.tiff.subifd))if(j.integer(Z.tiff.subifd)&&j.inRange(Z.tiff.subifd,-1,1e5))Q.tiffSubifd=Z.tiff.subifd;else throw j.invalidParameterError("tiff.subifd","integer between -1 and 100000",Z.tiff.subifd);else if(j.defined(Z.subifd))if(j.integer(Z.subifd)&&j.inRange(Z.subifd,-1,1e5))Q.tiffSubifd=Z.subifd;else throw j.invalidParameterError("subifd","integer between -1 and 100000",Z.subifd);if(j.object(Z.svg)){if(j.defined(Z.svg.stylesheet))if(j.string(Z.svg.stylesheet))Q.svgStylesheet=Z.svg.stylesheet;else throw j.invalidParameterError("svg.stylesheet","string",Z.svg.stylesheet);if(j.defined(Z.svg.highBitdepth))if(j.bool(Z.svg.highBitdepth))Q.svgHighBitdepth=Z.svg.highBitdepth;else throw j.invalidParameterError("svg.highBitdepth","boolean",Z.svg.highBitdepth)}if(j.object(Z.pdf)&&j.defined(Z.pdf.background))Q.pdfBackground=this._getBackgroundColourOption(Z.pdf.background);else if(j.defined(Z.pdfBackground))Q.pdfBackground=this._getBackgroundColourOption(Z.pdfBackground);if(j.object(Z.jp2)&&j.defined(Z.jp2.oneshot))if(j.bool(Z.jp2.oneshot))Q.jp2Oneshot=Z.jp2.oneshot;else throw j.invalidParameterError("jp2.oneshot","boolean",Z.jp2.oneshot);if(j.defined(Z.create))if(j.object(Z.create)&&j.integer(Z.create.width)&&Z.create.width>0&&j.integer(Z.create.height)&&Z.create.height>0&&j.integer(Z.create.channels)){if(Q.createWidth=Z.create.width,Q.createHeight=Z.create.height,Q.createChannels=Z.create.channels,Q.createPageHeight=0,j.defined(Z.create.pageHeight))if(j.integer(Z.create.pageHeight)&&Z.create.pageHeight>0&&Z.create.pageHeight<=Z.create.height){if(Z.create.height%Z.create.pageHeight!==0)throw Error(`Expected create.height ${Z.create.height} to be a multiple of create.pageHeight ${Z.create.pageHeight}`);Q.createPageHeight=Z.create.pageHeight}else throw j.invalidParameterError("create.pageHeight","positive integer",Z.create.pageHeight);if(j.defined(Z.create.noise)){if(!j.object(Z.create.noise))throw Error("Expected noise to be an object");if(Z.create.noise.type!=="gaussian")throw Error("Only gaussian noise is supported at the moment");if(Q.createNoiseType=Z.create.noise.type,!j.inRange(Z.create.channels,1,4))throw j.invalidParameterError("create.channels","number between 1 and 4",Z.create.channels);if(Q.createNoiseMean=128,j.defined(Z.create.noise.mean))if(j.number(Z.create.noise.mean)&&j.inRange(Z.create.noise.mean,0,1e4))Q.createNoiseMean=Z.create.noise.mean;else throw j.invalidParameterError("create.noise.mean","number between 0 and 10000",Z.create.noise.mean);if(Q.createNoiseSigma=30,j.defined(Z.create.noise.sigma))if(j.number(Z.create.noise.sigma)&&j.inRange(Z.create.noise.sigma,0,1e4))Q.createNoiseSigma=Z.create.noise.sigma;else throw j.invalidParameterError("create.noise.sigma","number between 0 and 10000",Z.create.noise.sigma)}else if(j.defined(Z.create.background)){if(!j.inRange(Z.create.channels,3,4))throw j.invalidParameterError("create.channels","number between 3 and 4",Z.create.channels);Q.createBackground=this._getBackgroundColourOption(Z.create.background)}else throw Error("Expected valid noise or background to create a new input image");delete Q.buffer}else throw Error("Expected valid width, height and channels to create a new input image");if(j.defined(Z.text))if(j.object(Z.text)&&j.string(Z.text.text)){if(Q.textValue=Z.text.text,j.defined(Z.text.height)&&j.defined(Z.text.dpi))throw Error("Expected only one of dpi or height");if(j.defined(Z.text.font))if(j.string(Z.text.font))Q.textFont=Z.text.font;else throw j.invalidParameterError("text.font","string",Z.text.font);if(j.defined(Z.text.fontfile))if(j.string(Z.text.fontfile))Q.textFontfile=Z.text.fontfile;else throw j.invalidParameterError("text.fontfile","string",Z.text.fontfile);if(j.defined(Z.text.width))if(j.integer(Z.text.width)&&Z.text.width>0)Q.textWidth=Z.text.width;else throw j.invalidParameterError("text.width","positive integer",Z.text.width);if(j.defined(Z.text.height))if(j.integer(Z.text.height)&&Z.text.height>0)Q.textHeight=Z.text.height;else throw j.invalidParameterError("text.height","positive integer",Z.text.height);if(j.defined(Z.text.align))if(j.string(Z.text.align)&&j.string(this.constructor.align[Z.text.align]))Q.textAlign=this.constructor.align[Z.text.align];else throw j.invalidParameterError("text.align","valid alignment",Z.text.align);if(j.defined(Z.text.justify))if(j.bool(Z.text.justify))Q.textJustify=Z.text.justify;else throw j.invalidParameterError("text.justify","boolean",Z.text.justify);if(j.defined(Z.text.dpi))if(j.integer(Z.text.dpi)&&j.inRange(Z.text.dpi,1,1e6))Q.textDpi=Z.text.dpi;else throw j.invalidParameterError("text.dpi","integer between 1 and 1000000",Z.text.dpi);if(j.defined(Z.text.rgba))if(j.bool(Z.text.rgba))Q.textRgba=Z.text.rgba;else throw j.invalidParameterError("text.rgba","bool",Z.text.rgba);if(j.defined(Z.text.spacing))if(j.integer(Z.text.spacing)&&j.inRange(Z.text.spacing,-1e6,1e6))Q.textSpacing=Z.text.spacing;else throw j.invalidParameterError("text.spacing","integer between -1000000 and 1000000",Z.text.spacing);if(j.defined(Z.text.wrap))if(j.string(Z.text.wrap)&&j.inArray(Z.text.wrap,["word","char","word-char","none"]))Q.textWrap=Z.text.wrap;else throw j.invalidParameterError("text.wrap","one of: word, char, word-char, none",Z.text.wrap);delete Q.buffer}else throw Error("Expected a valid string to create an image with text.");if(j.defined(Z.join))if(j.defined(this.options.join)){if(j.defined(Z.join.animated))if(j.bool(Z.join.animated))Q.joinAnimated=Z.join.animated;else throw j.invalidParameterError("join.animated","boolean",Z.join.animated);if(j.defined(Z.join.across))if(j.integer(Z.join.across)&&j.inRange(Z.join.across,1,1e6))Q.joinAcross=Z.join.across;else throw j.invalidParameterError("join.across","integer between 1 and 100000",Z.join.across);if(j.defined(Z.join.shim))if(j.integer(Z.join.shim)&&j.inRange(Z.join.shim,0,1e6))Q.joinShim=Z.join.shim;else throw j.invalidParameterError("join.shim","integer between 0 and 100000",Z.join.shim);if(j.defined(Z.join.background))Q.joinBackground=this._getBackgroundColourOption(Z.join.background);if(j.defined(Z.join.halign))if(j.string(Z.join.halign)&&j.string(this.constructor.align[Z.join.halign]))Q.joinHalign=this.constructor.align[Z.join.halign];else throw j.invalidParameterError("join.halign","valid alignment",Z.join.halign);if(j.defined(Z.join.valign))if(j.string(Z.join.valign)&&j.string(this.constructor.align[Z.join.valign]))Q.joinValign=this.constructor.align[Z.join.valign];else throw j.invalidParameterError("join.valign","valid alignment",Z.join.valign)}else throw Error("Expected input to be an array of images to join")}else if(j.defined(Z))throw Error(`Invalid input options ${Z}`);return Q}function b3($,Z,J){if(Array.isArray(this.options.input.buffer))if(j.buffer($)){if(this.options.input.buffer.length===0)this.on("finish",()=>{this.streamInFinished=!0});this.options.input.buffer.push($),J()}else J(Error("Non-Buffer data on Writable Stream"));else J(Error("Unexpected data on Writable Stream"))}function h3(){if(this._isStreamInput())this.options.input.buffer=Buffer.concat(this.options.input.buffer)}function g3(){return Array.isArray(this.options.input.buffer)}function d3($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$4.metadata(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)})});else $4.metadata(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)});return this}else if(this._isStreamInput())return new Promise((J,Q)=>{let X=()=>{this._flattenBufferIn(),$4.metadata(this.options,(V,K)=>{if(V)Q(j.nativeError(V,Z));else J(K)})};if(this.writableFinished)X();else this.once("finish",X)});else return new Promise((J,Q)=>{$4.metadata(this.options,(X,V)=>{if(X)Q(j.nativeError(X,Z));else J(V)})})}function u3($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$4.stats(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)})});else $4.stats(this.options,(J,Q)=>{if(J)$(j.nativeError(J,Z));else $(null,Q)});return this}else if(this._isStreamInput())return new Promise((J,Q)=>{this.on("finish",function(){this._flattenBufferIn(),$4.stats(this.options,(X,V)=>{if(X)Q(j.nativeError(X,Z));else J(V)})})});else return new Promise((J,Q)=>{$4.stats(this.options,(X,V)=>{if(X)Q(j.nativeError(X,Z));else J(V)})})}s$.exports=($)=>{Object.assign($.prototype,{_inputOptionsFromObject:i$,_createInputDescriptor:f3,_write:b3,_flattenBufferIn:h3,_isStreamInput:g3,metadata:d3,stats:u3}),$.align=O3}});var Q9=T((GH,J9)=>{/*!
19
- Copyright 2013 Lovell Fuller and others.
20
- SPDX-License-Identifier: Apache-2.0
21
- */var M=S0(),t$={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},$9={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},e$={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},Z9={entropy:16,attention:17},c2={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},m3={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},c3={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function l2($){return $.angle%360!==0||$.rotationAngle!==0}function a6($){return $.width!==-1||$.height!==-1}function l3($,Z,J){if(a6(this.options))this.options.debuglog("ignoring previous resize options");if(this.options.widthPost!==-1)this.options.debuglog("operation order will be: extract, resize, extract");if(M.defined($))if(M.object($)&&!M.defined(J))J=$;else if(M.integer($)&&$>0)this.options.width=$;else throw M.invalidParameterError("width","positive integer",$);else this.options.width=-1;if(M.defined(Z))if(M.integer(Z)&&Z>0)this.options.height=Z;else throw M.invalidParameterError("height","positive integer",Z);else this.options.height=-1;if(M.object(J)){if(M.defined(J.width))if(M.integer(J.width)&&J.width>0)this.options.width=J.width;else throw M.invalidParameterError("width","positive integer",J.width);if(M.defined(J.height))if(M.integer(J.height)&&J.height>0)this.options.height=J.height;else throw M.invalidParameterError("height","positive integer",J.height);if(M.defined(J.fit)){let Q=c3[J.fit];if(M.string(Q))this.options.canvas=Q;else throw M.invalidParameterError("fit","valid fit",J.fit)}if(M.defined(J.position)){let Q=M.integer(J.position)?J.position:Z9[J.position]||$9[J.position]||t$[J.position];if(M.integer(Q)&&(M.inRange(Q,0,8)||M.inRange(Q,16,17)))this.options.position=Q;else throw M.invalidParameterError("position","valid position/gravity/strategy",J.position)}if(this._setBackgroundColourOption("resizeBackground",J.background),M.defined(J.kernel))if(M.string(c2[J.kernel]))this.options.kernel=c2[J.kernel];else throw M.invalidParameterError("kernel","valid kernel name",J.kernel);if(M.defined(J.withoutEnlargement))this._setBooleanOption("withoutEnlargement",J.withoutEnlargement);if(M.defined(J.withoutReduction))this._setBooleanOption("withoutReduction",J.withoutReduction);if(M.defined(J.fastShrinkOnLoad))this._setBooleanOption("fastShrinkOnLoad",J.fastShrinkOnLoad)}if(l2(this.options)&&a6(this.options))this.options.rotateBefore=!0;return this}function p3($){if(M.integer($)&&$>0)this.options.extendTop=$,this.options.extendBottom=$,this.options.extendLeft=$,this.options.extendRight=$;else if(M.object($)){if(M.defined($.top))if(M.integer($.top)&&$.top>=0)this.options.extendTop=$.top;else throw M.invalidParameterError("top","positive integer",$.top);if(M.defined($.bottom))if(M.integer($.bottom)&&$.bottom>=0)this.options.extendBottom=$.bottom;else throw M.invalidParameterError("bottom","positive integer",$.bottom);if(M.defined($.left))if(M.integer($.left)&&$.left>=0)this.options.extendLeft=$.left;else throw M.invalidParameterError("left","positive integer",$.left);if(M.defined($.right))if(M.integer($.right)&&$.right>=0)this.options.extendRight=$.right;else throw M.invalidParameterError("right","positive integer",$.right);if(this._setBackgroundColourOption("extendBackground",$.background),M.defined($.extendWith))if(M.string(e$[$.extendWith]))this.options.extendWith=e$[$.extendWith];else throw M.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",$.extendWith)}else throw M.invalidParameterError("extend","integer or object",$);return this}function a3($){let Z=a6(this.options)||this.options.widthPre!==-1?"Post":"Pre";if(this.options[`width${Z}`]!==-1)this.options.debuglog("ignoring previous extract options");if(["left","top","width","height"].forEach(function(J){let Q=$[J];if(M.integer(Q)&&Q>=0)this.options[J+(J==="left"||J==="top"?"Offset":"")+Z]=Q;else throw M.invalidParameterError(J,"integer",Q)},this),l2(this.options)&&!a6(this.options)){if(this.options.widthPre===-1||this.options.widthPost===-1)this.options.rotateBefore=!0}if(this.options.input.autoOrient)this.options.orientBefore=!0;return this}function r3($){if(this.options.trimThreshold=10,M.defined($))if(M.object($)){if(M.defined($.background))this._setBackgroundColourOption("trimBackground",$.background);if(M.defined($.threshold))if(M.number($.threshold)&&$.threshold>=0)this.options.trimThreshold=$.threshold;else throw M.invalidParameterError("threshold","positive number",$.threshold);if(M.defined($.lineArt))this._setBooleanOption("trimLineArt",$.lineArt)}else throw M.invalidParameterError("trim","object",$);if(l2(this.options))this.options.rotateBefore=!0;return this}J9.exports=($)=>{Object.assign($.prototype,{resize:l3,extend:p3,extract:a3,trim:r3}),$.gravity=t$,$.strategy=Z9,$.kernel=c2,$.fit=m3,$.position=$9}});var V9=T((jH,X9)=>{/*!
22
- Copyright 2013 Lovell Fuller and others.
23
- SPDX-License-Identifier: Apache-2.0
24
- */var b=S0(),p2={clear:"clear",source:"source",over:"over",in:"in",out:"out",atop:"atop",dest:"dest","dest-over":"dest-over","dest-in":"dest-in","dest-out":"dest-out","dest-atop":"dest-atop",xor:"xor",add:"add",saturate:"saturate",multiply:"multiply",screen:"screen",overlay:"overlay",darken:"darken",lighten:"lighten","colour-dodge":"colour-dodge","color-dodge":"colour-dodge","colour-burn":"colour-burn","color-burn":"colour-burn","hard-light":"hard-light","soft-light":"soft-light",difference:"difference",exclusion:"exclusion"};function n3($){if(!Array.isArray($))throw b.invalidParameterError("images to composite","array",$);return this.options.composite=$.map((Z)=>{if(!b.object(Z))throw b.invalidParameterError("image to composite","object",Z);let J=this._inputOptionsFromObject(Z),Q={input:this._createInputDescriptor(Z.input,J,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(b.defined(Z.blend))if(b.string(p2[Z.blend]))Q.blend=p2[Z.blend];else throw b.invalidParameterError("blend","valid blend name",Z.blend);if(b.defined(Z.tile))if(b.bool(Z.tile))Q.tile=Z.tile;else throw b.invalidParameterError("tile","boolean",Z.tile);if(b.defined(Z.left))if(b.integer(Z.left))Q.left=Z.left;else throw b.invalidParameterError("left","integer",Z.left);if(b.defined(Z.top))if(b.integer(Z.top))Q.top=Z.top;else throw b.invalidParameterError("top","integer",Z.top);if(b.defined(Z.top)!==b.defined(Z.left))throw Error("Expected both left and top to be set");else Q.hasOffset=b.integer(Z.top)&&b.integer(Z.left);if(b.defined(Z.gravity))if(b.integer(Z.gravity)&&b.inRange(Z.gravity,0,8))Q.gravity=Z.gravity;else if(b.string(Z.gravity)&&b.integer(this.constructor.gravity[Z.gravity]))Q.gravity=this.constructor.gravity[Z.gravity];else throw b.invalidParameterError("gravity","valid gravity",Z.gravity);if(b.defined(Z.premultiplied))if(b.bool(Z.premultiplied))Q.premultiplied=Z.premultiplied;else throw b.invalidParameterError("premultiplied","boolean",Z.premultiplied);return Q}),this}X9.exports=($)=>{$.prototype.composite=n3,$.blend=p2}});var Y9=T((UH,q9)=>{/*!
25
- Copyright 2013 Lovell Fuller and others.
26
- SPDX-License-Identifier: Apache-2.0
27
- */var A=S0(),K9={integer:"integer",float:"float",approximate:"approximate"};function i3($,Z){if(!A.defined($))return this.autoOrient();if(this.options.angle||this.options.rotationAngle)this.options.debuglog("ignoring previous rotate options"),this.options.angle=0,this.options.rotationAngle=0;if(A.integer($)&&!($%90))this.options.angle=$;else if(A.number($)){if(this.options.rotationAngle=$,A.object(Z)&&Z.background)this._setBackgroundColourOption("rotationBackground",Z.background)}else throw A.invalidParameterError("angle","numeric",$);return this}function s3(){return this.options.input.autoOrient=!0,this}function o3($){return this.options.flip=A.bool($)?$:!0,this}function e3($){return this.options.flop=A.bool($)?$:!0,this}function t3($,Z){let J=[].concat(...$);if(J.length===4&&J.every(A.number))this.options.affineMatrix=J;else throw A.invalidParameterError("matrix","1x4 or 2x2 array",$);if(A.defined(Z))if(A.object(Z)){if(this._setBackgroundColourOption("affineBackground",Z.background),A.defined(Z.idx))if(A.number(Z.idx))this.options.affineIdx=Z.idx;else throw A.invalidParameterError("options.idx","number",Z.idx);if(A.defined(Z.idy))if(A.number(Z.idy))this.options.affineIdy=Z.idy;else throw A.invalidParameterError("options.idy","number",Z.idy);if(A.defined(Z.odx))if(A.number(Z.odx))this.options.affineOdx=Z.odx;else throw A.invalidParameterError("options.odx","number",Z.odx);if(A.defined(Z.ody))if(A.number(Z.ody))this.options.affineOdy=Z.ody;else throw A.invalidParameterError("options.ody","number",Z.ody);if(A.defined(Z.interpolator))if(A.inArray(Z.interpolator,Object.values(this.constructor.interpolators)))this.options.affineInterpolator=Z.interpolator;else throw A.invalidParameterError("options.interpolator","valid interpolator name",Z.interpolator)}else throw A.invalidParameterError("options","object",Z);return this}function $Q($,Z,J){if(!A.defined($))this.options.sharpenSigma=-1;else if(A.bool($))this.options.sharpenSigma=$?-1:0;else if(A.number($)&&A.inRange($,0.01,1e4)){if(this.options.sharpenSigma=$,A.defined(Z))if(A.number(Z)&&A.inRange(Z,0,1e4))this.options.sharpenM1=Z;else throw A.invalidParameterError("flat","number between 0 and 10000",Z);if(A.defined(J))if(A.number(J)&&A.inRange(J,0,1e4))this.options.sharpenM2=J;else throw A.invalidParameterError("jagged","number between 0 and 10000",J)}else if(A.plainObject($)){if(A.number($.sigma)&&A.inRange($.sigma,0.000001,10))this.options.sharpenSigma=$.sigma;else throw A.invalidParameterError("options.sigma","number between 0.000001 and 10",$.sigma);if(A.defined($.m1))if(A.number($.m1)&&A.inRange($.m1,0,1e6))this.options.sharpenM1=$.m1;else throw A.invalidParameterError("options.m1","number between 0 and 1000000",$.m1);if(A.defined($.m2))if(A.number($.m2)&&A.inRange($.m2,0,1e6))this.options.sharpenM2=$.m2;else throw A.invalidParameterError("options.m2","number between 0 and 1000000",$.m2);if(A.defined($.x1))if(A.number($.x1)&&A.inRange($.x1,0,1e6))this.options.sharpenX1=$.x1;else throw A.invalidParameterError("options.x1","number between 0 and 1000000",$.x1);if(A.defined($.y2))if(A.number($.y2)&&A.inRange($.y2,0,1e6))this.options.sharpenY2=$.y2;else throw A.invalidParameterError("options.y2","number between 0 and 1000000",$.y2);if(A.defined($.y3))if(A.number($.y3)&&A.inRange($.y3,0,1e6))this.options.sharpenY3=$.y3;else throw A.invalidParameterError("options.y3","number between 0 and 1000000",$.y3)}else throw A.invalidParameterError("sigma","number between 0.01 and 10000",$);return this}function ZQ($){if(!A.defined($))this.options.medianSize=3;else if(A.integer($)&&A.inRange($,1,1000))this.options.medianSize=$;else throw A.invalidParameterError("size","integer between 1 and 1000",$);return this}function JQ($){let Z;if(A.number($))Z=$;else if(A.plainObject($)){if(!A.number($.sigma))throw A.invalidParameterError("options.sigma","number between 0.3 and 1000",Z);if(Z=$.sigma,"precision"in $)if(A.string(K9[$.precision]))this.options.precision=K9[$.precision];else throw A.invalidParameterError("precision","one of: integer, float, approximate",$.precision);if("minAmplitude"in $)if(A.number($.minAmplitude)&&A.inRange($.minAmplitude,0.001,1))this.options.minAmpl=$.minAmplitude;else throw A.invalidParameterError("minAmplitude","number between 0.001 and 1",$.minAmplitude)}if(!A.defined($))this.options.blurSigma=-1;else if(A.bool($))this.options.blurSigma=$?-1:0;else if(A.number(Z)&&A.inRange(Z,0.3,1000))this.options.blurSigma=Z;else throw A.invalidParameterError("sigma","number between 0.3 and 1000",Z);return this}function W9($){if(!A.defined($))this.options.dilateWidth=1;else if(A.integer($)&&$>0)this.options.dilateWidth=$;else throw A.invalidParameterError("dilate","positive integer",W9);return this}function H9($){if(!A.defined($))this.options.erodeWidth=1;else if(A.integer($)&&$>0)this.options.erodeWidth=$;else throw A.invalidParameterError("erode","positive integer",H9);return this}function QQ($){if(this.options.flatten=A.bool($)?$:!0,A.object($))this._setBackgroundColourOption("flattenBackground",$.background);return this}function XQ(){return this.options.unflatten=!0,this}function VQ($,Z){if(!A.defined($))this.options.gamma=2.2;else if(A.number($)&&A.inRange($,1,3))this.options.gamma=$;else throw A.invalidParameterError("gamma","number between 1.0 and 3.0",$);if(!A.defined(Z))this.options.gammaOut=this.options.gamma;else if(A.number(Z)&&A.inRange(Z,1,3))this.options.gammaOut=Z;else throw A.invalidParameterError("gammaOut","number between 1.0 and 3.0",Z);return this}function KQ($){if(this.options.negate=A.bool($)?$:!0,A.plainObject($)&&"alpha"in $)if(!A.bool($.alpha))throw A.invalidParameterError("alpha","should be boolean value",$.alpha);else this.options.negateAlpha=$.alpha;return this}function WQ($){if(A.plainObject($)){if(A.defined($.lower))if(A.number($.lower)&&A.inRange($.lower,0,99))this.options.normaliseLower=$.lower;else throw A.invalidParameterError("lower","number between 0 and 99",$.lower);if(A.defined($.upper))if(A.number($.upper)&&A.inRange($.upper,1,100))this.options.normaliseUpper=$.upper;else throw A.invalidParameterError("upper","number between 1 and 100",$.upper)}if(this.options.normaliseLower>=this.options.normaliseUpper)throw A.invalidParameterError("range","lower to be less than upper",`${this.options.normaliseLower} >= ${this.options.normaliseUpper}`);return this.options.normalise=!0,this}function HQ($){return this.normalise($)}function qQ($){if(A.plainObject($)){if(A.integer($.width)&&$.width>0)this.options.claheWidth=$.width;else throw A.invalidParameterError("width","integer greater than zero",$.width);if(A.integer($.height)&&$.height>0)this.options.claheHeight=$.height;else throw A.invalidParameterError("height","integer greater than zero",$.height);if(A.defined($.maxSlope))if(A.integer($.maxSlope)&&A.inRange($.maxSlope,0,100))this.options.claheMaxSlope=$.maxSlope;else throw A.invalidParameterError("maxSlope","integer between 0 and 100",$.maxSlope)}else throw A.invalidParameterError("options","plain object",$);return this}function YQ($){if(!A.object($)||!Array.isArray($.kernel)||!A.integer($.width)||!A.integer($.height)||!A.inRange($.width,3,1001)||!A.inRange($.height,3,1001)||$.height*$.width!==$.kernel.length)throw Error("Invalid convolution kernel");if(!A.integer($.scale))$.scale=$.kernel.reduce((Z,J)=>Z+J,0);if($.scale<1)$.scale=1;if(!A.integer($.offset))$.offset=0;return this.options.convKernel=$,this}function zQ($,Z){if(!A.defined($))this.options.threshold=128;else if(A.bool($))this.options.threshold=$?128:0;else if(A.integer($)&&A.inRange($,0,255))this.options.threshold=$;else throw A.invalidParameterError("threshold","integer between 0 and 255",$);if(!A.object(Z)||Z.greyscale===!0||Z.grayscale===!0)this.options.thresholdGrayscale=!0;else this.options.thresholdGrayscale=!1;return this}function GQ($,Z,J){if(this.options.boolean=this._createInputDescriptor($,J),A.string(Z)&&A.inArray(Z,["and","or","eor"]))this.options.booleanOp=Z;else throw A.invalidParameterError("operator","one of: and, or, eor",Z);return this}function jQ($,Z){if(!A.defined($)&&A.number(Z))$=1;else if(A.number($)&&!A.defined(Z))Z=0;if(!A.defined($))this.options.linearA=[];else if(A.number($))this.options.linearA=[$];else if(Array.isArray($)&&$.length&&$.every(A.number))this.options.linearA=$;else throw A.invalidParameterError("a","number or array of numbers",$);if(!A.defined(Z))this.options.linearB=[];else if(A.number(Z))this.options.linearB=[Z];else if(Array.isArray(Z)&&Z.length&&Z.every(A.number))this.options.linearB=Z;else throw A.invalidParameterError("b","number or array of numbers",Z);if(this.options.linearA.length!==this.options.linearB.length)throw Error("Expected a and b to be arrays of the same length");return this}function UQ($){if(!Array.isArray($))throw A.invalidParameterError("inputMatrix","array",$);if($.length!==3&&$.length!==4)throw A.invalidParameterError("inputMatrix","3x3 or 4x4 array",$.length);let Z=$.flat().map(Number);if(Z.length!==9&&Z.length!==16)throw A.invalidParameterError("inputMatrix","cardinality of 9 or 16",Z.length);return this.options.recombMatrix=Z,this}function AQ($){if(!A.plainObject($))throw A.invalidParameterError("options","plain object",$);if("brightness"in $)if(A.number($.brightness)&&$.brightness>=0)this.options.brightness=$.brightness;else throw A.invalidParameterError("brightness","number above zero",$.brightness);if("saturation"in $)if(A.number($.saturation)&&$.saturation>=0)this.options.saturation=$.saturation;else throw A.invalidParameterError("saturation","number above zero",$.saturation);if("hue"in $)if(A.integer($.hue))this.options.hue=$.hue%360;else throw A.invalidParameterError("hue","number",$.hue);if("lightness"in $)if(A.number($.lightness))this.options.lightness=$.lightness;else throw A.invalidParameterError("lightness","number",$.lightness);return this}q9.exports=($)=>{Object.assign($.prototype,{autoOrient:s3,rotate:i3,flip:o3,flop:e3,affine:t3,sharpen:$Q,erode:H9,dilate:W9,median:ZQ,blur:JQ,flatten:QQ,unflatten:XQ,gamma:VQ,negate:KQ,normalise:WQ,normalize:HQ,clahe:qQ,convolve:YQ,threshold:zQ,boolean:GQ,linear:jQ,recomb:UQ,modulate:AQ})}});var B9=T((AH,A9)=>{var{defineProperty:i2,getOwnPropertyDescriptor:BQ,getOwnPropertyNames:LQ}=Object,_Q=Object.prototype.hasOwnProperty,wQ=($,Z)=>{for(var J in Z)i2($,J,{get:Z[J],enumerable:!0})},RQ=($,Z,J,Q)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(let X of LQ(Z))if(!_Q.call($,X)&&X!==J)i2($,X,{get:()=>Z[X],enumerable:!(Q=BQ(Z,X))||Q.enumerable})}return $},CQ=($)=>RQ(i2({},"__esModule",{value:!0}),$),z9={};wQ(z9,{default:()=>yQ});A9.exports=CQ(z9);var O0={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},G9=Object.create(null);for(let $ in O0)if(Object.hasOwn(O0,$))G9[O0[$]]=$;var q0={to:{},get:{}};q0.get=function($){let Z=$.slice(0,3).toLowerCase(),J,Q;switch(Z){case"hsl":{J=q0.get.hsl($),Q="hsl";break}case"hwb":{J=q0.get.hwb($),Q="hwb";break}default:{J=q0.get.rgb($),Q="rgb";break}}if(!J)return null;return{model:Q,value:J}};q0.get.rgb=function($){if(!$)return null;let Z=/^#([a-f\d]{3,4})$/i,J=/^#([a-f\d]{6})([a-f\d]{2})?$/i,Q=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,X=/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/,V=/^(\w+)$/,K=[0,0,0,1],W,H,q;if(W=$.match(J)){q=W[2],W=W[1];for(H=0;H<3;H++){let z=H*2;K[H]=Number.parseInt(W.slice(z,z+2),16)}if(q)K[3]=Number.parseInt(q,16)/255}else if(W=$.match(Z)){W=W[1],q=W[3];for(H=0;H<3;H++)K[H]=Number.parseInt(W[H]+W[H],16);if(q)K[3]=Number.parseInt(q+q,16)/255}else if(W=$.match(Q)){for(H=0;H<3;H++)K[H]=Number.parseInt(W[H+1],10);if(W[4])K[3]=W[5]?Number.parseFloat(W[4])*0.01:Number.parseFloat(W[4])}else if(W=$.match(X)){for(H=0;H<3;H++)K[H]=Math.round(Number.parseFloat(W[H+1])*2.55);if(W[4])K[3]=W[5]?Number.parseFloat(W[4])*0.01:Number.parseFloat(W[4])}else if(W=$.match(V)){if(W[1]==="transparent")return[0,0,0,0];if(!Object.hasOwn(O0,W[1]))return null;return K=O0[W[1]],K[3]=1,K}else return null;for(H=0;H<3;H++)K[H]=Z4(K[H],0,255);return K[3]=Z4(K[3],0,1),K};q0.get.hsl=function($){if(!$)return null;let Z=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,J=$.match(Z);if(J){let Q=Number.parseFloat(J[4]),X=(Number.parseFloat(J[1])%360+360)%360,V=Z4(Number.parseFloat(J[2]),0,100),K=Z4(Number.parseFloat(J[3]),0,100),W=Z4(Number.isNaN(Q)?1:Q,0,1);return[X,V,K,W]}return null};q0.get.hwb=function($){if(!$)return null;let Z=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,J=$.match(Z);if(J){let Q=Number.parseFloat(J[4]),X=(Number.parseFloat(J[1])%360+360)%360,V=Z4(Number.parseFloat(J[2]),0,100),K=Z4(Number.parseFloat(J[3]),0,100),W=Z4(Number.isNaN(Q)?1:Q,0,1);return[X,V,K,W]}return null};q0.to.hex=function(...$){return"#"+r6($[0])+r6($[1])+r6($[2])+($[3]<1?r6(Math.round($[3]*255)):"")};q0.to.rgb=function(...$){return $.length<4||$[3]===1?"rgb("+Math.round($[0])+", "+Math.round($[1])+", "+Math.round($[2])+")":"rgba("+Math.round($[0])+", "+Math.round($[1])+", "+Math.round($[2])+", "+$[3]+")"};q0.to.rgb.percent=function(...$){let Z=Math.round($[0]/255*100),J=Math.round($[1]/255*100),Q=Math.round($[2]/255*100);return $.length<4||$[3]===1?"rgb("+Z+"%, "+J+"%, "+Q+"%)":"rgba("+Z+"%, "+J+"%, "+Q+"%, "+$[3]+")"};q0.to.hsl=function(...$){return $.length<4||$[3]===1?"hsl("+$[0]+", "+$[1]+"%, "+$[2]+"%)":"hsla("+$[0]+", "+$[1]+"%, "+$[2]+"%, "+$[3]+")"};q0.to.hwb=function(...$){let Z="";if($.length>=4&&$[3]!==1)Z=", "+$[3];return"hwb("+$[0]+", "+$[1]+"%, "+$[2]+"%"+Z+")"};q0.to.keyword=function(...$){return G9[$.slice(0,3)]};function Z4($,Z,J){return Math.min(Math.max(Z,$),J)}function r6($){let Z=Math.round($).toString(16).toUpperCase();return Z.length<2?"0"+Z:Z}var I4=q0,j9={};for(let $ of Object.keys(O0))j9[O0[$]]=$;var C={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},U4=C,l0=0.008856451679035631;function S4($){let Z=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92;return Math.min(Math.max(0,Z),1)}function T4($){return $>0.04045?(($+0.055)/1.055)**2.4:$/12.92}for(let $ of Object.keys(C)){if(!("channels"in C[$]))throw Error("missing channels property: "+$);if(!("labels"in C[$]))throw Error("missing channel labels property: "+$);if(C[$].labels.length!==C[$].channels)throw Error("channel and label counts mismatch: "+$);let{channels:Z,labels:J}=C[$];delete C[$].channels,delete C[$].labels,Object.defineProperty(C[$],"channels",{value:Z}),Object.defineProperty(C[$],"labels",{value:J})}C.rgb.hsl=function($){let Z=$[0]/255,J=$[1]/255,Q=$[2]/255,X=Math.min(Z,J,Q),V=Math.max(Z,J,Q),K=V-X,W,H;switch(V){case X:{W=0;break}case Z:{W=(J-Q)/K;break}case J:{W=2+(Q-Z)/K;break}case Q:{W=4+(Z-J)/K;break}}if(W=Math.min(W*60,360),W<0)W+=360;let q=(X+V)/2;if(V===X)H=0;else if(q<=0.5)H=K/(V+X);else H=K/(2-V-X);return[W,H*100,q*100]};C.rgb.hsv=function($){let Z,J,Q,X,V,K=$[0]/255,W=$[1]/255,H=$[2]/255,q=Math.max(K,W,H),z=q-Math.min(K,W,H),G=function(U){return(q-U)/6/z+0.5};if(z===0)X=0,V=0;else{switch(V=z/q,Z=G(K),J=G(W),Q=G(H),q){case K:{X=Q-J;break}case W:{X=0.3333333333333333+Z-Q;break}case H:{X=0.6666666666666666+J-Z;break}}if(X<0)X+=1;else if(X>1)X-=1}return[X*360,V*100,q*100]};C.rgb.hwb=function($){let Z=$[0],J=$[1],Q=$[2],X=C.rgb.hsl($)[0],V=0.00392156862745098*Math.min(Z,Math.min(J,Q));return Q=1-0.00392156862745098*Math.max(Z,Math.max(J,Q)),[X,V*100,Q*100]};C.rgb.oklab=function($){let Z=T4($[0]/255),J=T4($[1]/255),Q=T4($[2]/255),X=Math.cbrt(0.4122214708*Z+0.5363325363*J+0.0514459929*Q),V=Math.cbrt(0.2119034982*Z+0.6806995451*J+0.1073969566*Q),K=Math.cbrt(0.0883024619*Z+0.2817188376*J+0.6299787005*Q),W=0.2104542553*X+0.793617785*V-0.0040720468*K,H=1.9779984951*X-2.428592205*V+0.4505937099*K,q=0.0259040371*X+0.7827717662*V-0.808675766*K;return[W*100,H*100,q*100]};C.rgb.cmyk=function($){let Z=$[0]/255,J=$[1]/255,Q=$[2]/255,X=Math.min(1-Z,1-J,1-Q),V=(1-Z-X)/(1-X)||0,K=(1-J-X)/(1-X)||0,W=(1-Q-X)/(1-X)||0;return[V*100,K*100,W*100,X*100]};function NQ($,Z){return($[0]-Z[0])**2+($[1]-Z[1])**2+($[2]-Z[2])**2}C.rgb.keyword=function($){let Z=j9[$];if(Z)return Z;let J=Number.POSITIVE_INFINITY,Q;for(let X of Object.keys(O0)){let V=O0[X],K=NQ($,V);if(K<J)J=K,Q=X}return Q};C.keyword.rgb=function($){return O0[$]};C.rgb.xyz=function($){let Z=T4($[0]/255),J=T4($[1]/255),Q=T4($[2]/255),X=Z*0.4124564+J*0.3575761+Q*0.1804375,V=Z*0.2126729+J*0.7151522+Q*0.072175,K=Z*0.0193339+J*0.119192+Q*0.9503041;return[X*100,V*100,K*100]};C.rgb.lab=function($){let Z=C.rgb.xyz($),J=Z[0],Q=Z[1],X=Z[2];J/=95.047,Q/=100,X/=108.883,J=J>l0?J**0.3333333333333333:7.787*J+0.13793103448275862,Q=Q>l0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,X=X>l0?X**0.3333333333333333:7.787*X+0.13793103448275862;let V=116*Q-16,K=500*(J-Q),W=200*(Q-X);return[V,K,W]};C.hsl.rgb=function($){let Z=$[0]/360,J=$[1]/100,Q=$[2]/100,X,V;if(J===0)return V=Q*255,[V,V,V];let K=Q<0.5?Q*(1+J):Q+J-Q*J,W=2*Q-K,H=[0,0,0];for(let q=0;q<3;q++){if(X=Z+0.3333333333333333*-(q-1),X<0)X++;if(X>1)X--;if(6*X<1)V=W+(K-W)*6*X;else if(2*X<1)V=K;else if(3*X<2)V=W+(K-W)*(0.6666666666666666-X)*6;else V=W;H[q]=V*255}return H};C.hsl.hsv=function($){let Z=$[0],J=$[1]/100,Q=$[2]/100,X=J,V=Math.max(Q,0.01);Q*=2,J*=Q<=1?Q:2-Q,X*=V<=1?V:2-V;let K=(Q+J)/2,W=Q===0?2*X/(V+X):2*J/(Q+J);return[Z,W*100,K*100]};C.hsv.rgb=function($){let Z=$[0]/60,J=$[1]/100,Q=$[2]/100,X=Math.floor(Z)%6,V=Z-Math.floor(Z),K=255*Q*(1-J),W=255*Q*(1-J*V),H=255*Q*(1-J*(1-V));switch(Q*=255,X){case 0:return[Q,H,K];case 1:return[W,Q,K];case 2:return[K,Q,H];case 3:return[K,W,Q];case 4:return[H,K,Q];case 5:return[Q,K,W]}};C.hsv.hsl=function($){let Z=$[0],J=$[1]/100,Q=$[2]/100,X=Math.max(Q,0.01),V,K;K=(2-J)*Q;let W=(2-J)*X;return V=J*X,V/=W<=1?W:2-W,V=V||0,K/=2,[Z,V*100,K*100]};C.hwb.rgb=function($){let Z=$[0]/360,J=$[1]/100,Q=$[2]/100,X=J+Q,V;if(X>1)J/=X,Q/=X;let K=Math.floor(6*Z),W=1-Q;if(V=6*Z-K,(K&1)!==0)V=1-V;let H=J+V*(W-J),q,z,G;switch(K){default:case 6:case 0:{q=W,z=H,G=J;break}case 1:{q=H,z=W,G=J;break}case 2:{q=J,z=W,G=H;break}case 3:{q=J,z=H,G=W;break}case 4:{q=H,z=J,G=W;break}case 5:{q=W,z=J,G=H;break}}return[q*255,z*255,G*255]};C.cmyk.rgb=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=$[3]/100,V=1-Math.min(1,Z*(1-X)+X),K=1-Math.min(1,J*(1-X)+X),W=1-Math.min(1,Q*(1-X)+X);return[V*255,K*255,W*255]};C.xyz.rgb=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X,V,K;return X=Z*3.2404542+J*-1.5371385+Q*-0.4985314,V=Z*-0.969266+J*1.8760108+Q*0.041556,K=Z*0.0556434+J*-0.2040259+Q*1.0572252,X=S4(X),V=S4(V),K=S4(K),[X*255,V*255,K*255]};C.xyz.lab=function($){let Z=$[0],J=$[1],Q=$[2];Z/=95.047,J/=100,Q/=108.883,Z=Z>l0?Z**0.3333333333333333:7.787*Z+0.13793103448275862,J=J>l0?J**0.3333333333333333:7.787*J+0.13793103448275862,Q=Q>l0?Q**0.3333333333333333:7.787*Q+0.13793103448275862;let X=116*J-16,V=500*(Z-J),K=200*(J-Q);return[X,V,K]};C.xyz.oklab=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=Math.cbrt(0.8189330101*Z+0.3618667424*J-0.1288597137*Q),V=Math.cbrt(0.0329845436*Z+0.9293118715*J+0.0361456387*Q),K=Math.cbrt(0.0482003018*Z+0.2643662691*J+0.633851707*Q),W=0.2104542553*X+0.793617785*V-0.0040720468*K,H=1.9779984951*X-2.428592205*V+0.4505937099*K,q=0.0259040371*X+0.7827717662*V-0.808675766*K;return[W*100,H*100,q*100]};C.oklab.oklch=function($){return C.lab.lch($)};C.oklab.xyz=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=(0.999999998*Z+0.396337792*J+0.215803758*Q)**3,V=(1.000000008*Z-0.105561342*J-0.063854175*Q)**3,K=(1.000000055*Z-0.089484182*J-1.291485538*Q)**3,W=1.227013851*X-0.55779998*V+0.281256149*K,H=-0.040580178*X+1.11225687*V-0.071676679*K,q=-0.076381285*X-0.421481978*V+1.58616322*K;return[W*100,H*100,q*100]};C.oklab.rgb=function($){let Z=$[0]/100,J=$[1]/100,Q=$[2]/100,X=(Z+0.3963377774*J+0.2158037573*Q)**3,V=(Z-0.1055613458*J-0.0638541728*Q)**3,K=(Z-0.0894841775*J-1.291485548*Q)**3,W=S4(4.0767416621*X-3.3077115913*V+0.2309699292*K),H=S4(-1.2684380046*X+2.6097574011*V-0.3413193965*K),q=S4(-0.0041960863*X-0.7034186147*V+1.707614701*K);return[W*255,H*255,q*255]};C.oklch.oklab=function($){return C.lch.lab($)};C.lab.xyz=function($){let Z=$[0],J=$[1],Q=$[2],X,V,K;V=(Z+16)/116,X=J/500+V,K=V-Q/200;let W=V**3,H=X**3,q=K**3;return V=W>l0?W:(V-0.13793103448275862)/7.787,X=H>l0?H:(X-0.13793103448275862)/7.787,K=q>l0?q:(K-0.13793103448275862)/7.787,X*=95.047,V*=100,K*=108.883,[X,V,K]};C.lab.lch=function($){let Z=$[0],J=$[1],Q=$[2],X;if(X=Math.atan2(Q,J)*360/2/Math.PI,X<0)X+=360;let K=Math.sqrt(J*J+Q*Q);return[Z,K,X]};C.lch.lab=function($){let Z=$[0],J=$[1],X=$[2]/360*2*Math.PI,V=J*Math.cos(X),K=J*Math.sin(X);return[Z,V,K]};C.rgb.ansi16=function($,Z=null){let[J,Q,X]=$,V=Z===null?C.rgb.hsv($)[2]:Z;if(V=Math.round(V/50),V===0)return 30;let K=30+(Math.round(X/255)<<2|Math.round(Q/255)<<1|Math.round(J/255));if(V===2)K+=60;return K};C.hsv.ansi16=function($){return C.rgb.ansi16(C.hsv.rgb($),$[2])};C.rgb.ansi256=function($){let Z=$[0],J=$[1],Q=$[2];if(Z>>4===J>>4&&J>>4===Q>>4){if(Z<8)return 16;if(Z>248)return 231;return Math.round((Z-8)/247*24)+232}return 16+36*Math.round(Z/255*5)+6*Math.round(J/255*5)+Math.round(Q/255*5)};C.ansi16.rgb=function($){$=$[0];let Z=$%10;if(Z===0||Z===7){if($>50)Z+=3.5;return Z=Z/10.5*255,[Z,Z,Z]}let J=(Math.trunc($>50)+1)*0.5,Q=(Z&1)*J*255,X=(Z>>1&1)*J*255,V=(Z>>2&1)*J*255;return[Q,X,V]};C.ansi256.rgb=function($){if($=$[0],$>=232){let V=($-232)*10+8;return[V,V,V]}$-=16;let Z,J=Math.floor($/36)/5*255,Q=Math.floor((Z=$%36)/6)/5*255,X=Z%6/5*255;return[J,Q,X]};C.rgb.hex=function($){let J=(((Math.round($[0])&255)<<16)+((Math.round($[1])&255)<<8)+(Math.round($[2])&255)).toString(16).toUpperCase();return"000000".slice(J.length)+J};C.hex.rgb=function($){let Z=$.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!Z)return[0,0,0];let J=Z[0];if(Z[0].length===3)J=[...J].map((W)=>W+W).join("");let Q=Number.parseInt(J,16),X=Q>>16&255,V=Q>>8&255,K=Q&255;return[X,V,K]};C.rgb.hcg=function($){let Z=$[0]/255,J=$[1]/255,Q=$[2]/255,X=Math.max(Math.max(Z,J),Q),V=Math.min(Math.min(Z,J),Q),K=X-V,W,H=K<1?V/(1-K):0;if(K<=0)W=0;else if(X===Z)W=(J-Q)/K%6;else if(X===J)W=2+(Q-Z)/K;else W=4+(Z-J)/K;return W/=6,W%=1,[W*360,K*100,H*100]};C.hsl.hcg=function($){let Z=$[1]/100,J=$[2]/100,Q=J<0.5?2*Z*J:2*Z*(1-J),X=0;if(Q<1)X=(J-0.5*Q)/(1-Q);return[$[0],Q*100,X*100]};C.hsv.hcg=function($){let Z=$[1]/100,J=$[2]/100,Q=Z*J,X=0;if(Q<1)X=(J-Q)/(1-Q);return[$[0],Q*100,X*100]};C.hcg.rgb=function($){let Z=$[0]/360,J=$[1]/100,Q=$[2]/100;if(J===0)return[Q*255,Q*255,Q*255];let X=[0,0,0],V=Z%1*6,K=V%1,W=1-K,H=0;switch(Math.floor(V)){case 0:{X[0]=1,X[1]=K,X[2]=0;break}case 1:{X[0]=W,X[1]=1,X[2]=0;break}case 2:{X[0]=0,X[1]=1,X[2]=K;break}case 3:{X[0]=0,X[1]=W,X[2]=1;break}case 4:{X[0]=K,X[1]=0,X[2]=1;break}default:X[0]=1,X[1]=0,X[2]=W}return H=(1-J)*Q,[(J*X[0]+H)*255,(J*X[1]+H)*255,(J*X[2]+H)*255]};C.hcg.hsv=function($){let Z=$[1]/100,J=$[2]/100,Q=Z+J*(1-Z),X=0;if(Q>0)X=Z/Q;return[$[0],X*100,Q*100]};C.hcg.hsl=function($){let Z=$[1]/100,Q=$[2]/100*(1-Z)+0.5*Z,X=0;if(Q>0&&Q<0.5)X=Z/(2*Q);else if(Q>=0.5&&Q<1)X=Z/(2*(1-Q));return[$[0],X*100,Q*100]};C.hcg.hwb=function($){let Z=$[1]/100,J=$[2]/100,Q=Z+J*(1-Z);return[$[0],(Q-Z)*100,(1-Q)*100]};C.hwb.hcg=function($){let Z=$[1]/100,Q=1-$[2]/100,X=Q-Z,V=0;if(X<1)V=(Q-X)/(1-X);return[$[0],X*100,V*100]};C.apple.rgb=function($){return[$[0]/65535*255,$[1]/65535*255,$[2]/65535*255]};C.rgb.apple=function($){return[$[0]/255*65535,$[1]/255*65535,$[2]/255*65535]};C.gray.rgb=function($){return[$[0]/100*255,$[0]/100*255,$[0]/100*255]};C.gray.hsl=function($){return[0,0,$[0]]};C.gray.hsv=C.gray.hsl;C.gray.hwb=function($){return[0,100,$[0]]};C.gray.cmyk=function($){return[0,0,0,$[0]]};C.gray.lab=function($){return[$[0],0,0]};C.gray.hex=function($){let Z=Math.round($[0]/100*255)&255,Q=((Z<<16)+(Z<<8)+Z).toString(16).toUpperCase();return"000000".slice(Q.length)+Q};C.rgb.gray=function($){return[($[0]+$[1]+$[2])/3/255*100]};function PQ(){let $={},Z=Object.keys(U4);for(let{length:J}=Z,Q=0;Q<J;Q++)$[Z[Q]]={distance:-1,parent:null};return $}function DQ($){let Z=PQ(),J=[$];Z[$].distance=0;while(J.length>0){let Q=J.pop(),X=Object.keys(U4[Q]);for(let{length:V}=X,K=0;K<V;K++){let W=X[K],H=Z[W];if(H.distance===-1)H.distance=Z[Q].distance+1,H.parent=Q,J.unshift(W)}}return Z}function MQ($,Z){return function(J){return Z($(J))}}function FQ($,Z){let J=[Z[$].parent,$],Q=U4[Z[$].parent][$],X=Z[$].parent;while(Z[X].parent)J.unshift(Z[X].parent),Q=MQ(U4[Z[X].parent][X],Q),X=Z[X].parent;return Q.conversion=J,Q}function IQ($){let Z=DQ($),J={},Q=Object.keys(Z);for(let{length:X}=Q,V=0;V<X;V++){let K=Q[V];if(Z[K].parent===null)continue;J[K]=FQ(K,Z)}return J}var EQ=IQ,E4={},SQ=Object.keys(U4);function TQ($){let Z=function(...J){let Q=J[0];if(Q===void 0||Q===null)return Q;if(Q.length>1)J=Q;return $(J)};if("conversion"in $)Z.conversion=$.conversion;return Z}function vQ($){let Z=function(...J){let Q=J[0];if(Q===void 0||Q===null)return Q;if(Q.length>1)J=Q;let X=$(J);if(typeof X==="object")for(let{length:V}=X,K=0;K<V;K++)X[K]=Math.round(X[K]);return X};if("conversion"in $)Z.conversion=$.conversion;return Z}for(let $ of SQ){E4[$]={},Object.defineProperty(E4[$],"channels",{value:U4[$].channels}),Object.defineProperty(E4[$],"labels",{value:U4[$].labels});let Z=EQ($),J=Object.keys(Z);for(let Q of J){let X=Z[Q];E4[$][Q]=vQ(X),E4[$][Q].raw=TQ(X)}}var G0=E4,U9=["keyword","gray","hex"],a2={};for(let $ of Object.keys(G0))a2[[...G0[$].labels].sort().join("")]=$;var r2={};function i($,Z){if(!(this instanceof i))return new i($,Z);if(Z&&Z in U9)Z=null;if(Z&&!(Z in G0))throw Error("Unknown model: "+Z);let J,Q;if($==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if($ instanceof i)this.model=$.model,this.color=[...$.color],this.valpha=$.valpha;else if(typeof $==="string"){let X=I4.get($);if(X===null)throw Error("Unable to parse color from string: "+$);this.model=X.model,Q=G0[this.model].channels,this.color=X.value.slice(0,Q),this.valpha=typeof X.value[Q]==="number"?X.value[Q]:1}else if($.length>0){this.model=Z||"rgb",Q=G0[this.model].channels;let X=Array.prototype.slice.call($,0,Q);this.color=n2(X,Q),this.valpha=typeof $[Q]==="number"?$[Q]:1}else if(typeof $==="number")this.model="rgb",this.color=[$>>16&255,$>>8&255,$&255],this.valpha=1;else{this.valpha=1;let X=Object.keys($);if("alpha"in $)X.splice(X.indexOf("alpha"),1),this.valpha=typeof $.alpha==="number"?$.alpha:0;let V=X.sort().join("");if(!(V in a2))throw Error("Unable to parse color from object: "+JSON.stringify($));this.model=a2[V];let{labels:K}=G0[this.model],W=[];for(J=0;J<K.length;J++)W.push($[K[J]]);this.color=n2(W)}if(r2[this.model]){Q=G0[this.model].channels;for(J=0;J<Q;J++){let X=r2[this.model][J];if(X)this.color[J]=X(this.color[J])}}if(this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze)Object.freeze(this)}i.prototype={toString(){return this.string()},toJSON(){return this[this.model]()},string($){let Z=this.model in I4.to?this:this.rgb();Z=Z.round(typeof $==="number"?$:1);let J=Z.valpha===1?Z.color:[...Z.color,this.valpha];return I4.to[Z.model](...J)},percentString($){let Z=this.rgb().round(typeof $==="number"?$:1),J=Z.valpha===1?Z.color:[...Z.color,this.valpha];return I4.to.rgb.percent(...J)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let $={},{channels:Z}=G0[this.model],{labels:J}=G0[this.model];for(let Q=0;Q<Z;Q++)$[J[Q]]=this.color[Q];if(this.valpha!==1)$.alpha=this.valpha;return $},unitArray(){let $=this.rgb().color;if($[0]/=255,$[1]/=255,$[2]/=255,this.valpha!==1)$.push(this.valpha);return $},unitObject(){let $=this.rgb().object();if($.r/=255,$.g/=255,$.b/=255,this.valpha!==1)$.alpha=this.valpha;return $},round($){return $=Math.max($||0,0),new i([...this.color.map(kQ($)),this.valpha],this.model)},alpha($){if($!==void 0)return new i([...this.color,Math.max(0,Math.min(1,$))],this.model);return this.valpha},red:u("rgb",0,p(255)),green:u("rgb",1,p(255)),blue:u("rgb",2,p(255)),hue:u(["hsl","hsv","hsl","hwb","hcg"],0,($)=>($%360+360)%360),saturationl:u("hsl",1,p(100)),lightness:u("hsl",2,p(100)),saturationv:u("hsv",1,p(100)),value:u("hsv",2,p(100)),chroma:u("hcg",1,p(100)),gray:u("hcg",2,p(100)),white:u("hwb",1,p(100)),wblack:u("hwb",2,p(100)),cyan:u("cmyk",0,p(100)),magenta:u("cmyk",1,p(100)),yellow:u("cmyk",2,p(100)),black:u("cmyk",3,p(100)),x:u("xyz",0,p(95.047)),y:u("xyz",1,p(100)),z:u("xyz",2,p(108.833)),l:u("lab",0,p(100)),a:u("lab",1),b:u("lab",2),keyword($){if($!==void 0)return new i($);return G0[this.model].keyword(this.color)},hex($){if($!==void 0)return new i($);return I4.to.hex(...this.rgb().round().color)},hexa($){if($!==void 0)return new i($);let Z=this.rgb().round().color,J=Math.round(this.valpha*255).toString(16).toUpperCase();if(J.length===1)J="0"+J;return I4.to.hex(...Z)+J},rgbNumber(){let $=this.rgb().color;return($[0]&255)<<16|($[1]&255)<<8|$[2]&255},luminosity(){let $=this.rgb().color,Z=[];for(let[J,Q]of $.entries()){let X=Q/255;Z[J]=X<=0.04045?X/12.92:((X+0.055)/1.055)**2.4}return 0.2126*Z[0]+0.7152*Z[1]+0.0722*Z[2]},contrast($){let Z=this.luminosity(),J=$.luminosity();if(Z>J)return(Z+0.05)/(J+0.05);return(J+0.05)/(Z+0.05)},level($){let Z=this.contrast($);if(Z>=7)return"AAA";return Z>=4.5?"AA":""},isDark(){let $=this.rgb().color;return($[0]*2126+$[1]*7152+$[2]*722)/1e4<128},isLight(){return!this.isDark()},negate(){let $=this.rgb();for(let Z=0;Z<3;Z++)$.color[Z]=255-$.color[Z];return $},lighten($){let Z=this.hsl();return Z.color[2]+=Z.color[2]*$,Z},darken($){let Z=this.hsl();return Z.color[2]-=Z.color[2]*$,Z},saturate($){let Z=this.hsl();return Z.color[1]+=Z.color[1]*$,Z},desaturate($){let Z=this.hsl();return Z.color[1]-=Z.color[1]*$,Z},whiten($){let Z=this.hwb();return Z.color[1]+=Z.color[1]*$,Z},blacken($){let Z=this.hwb();return Z.color[2]+=Z.color[2]*$,Z},grayscale(){let $=this.rgb().color,Z=$[0]*0.3+$[1]*0.59+$[2]*0.11;return i.rgb(Z,Z,Z)},fade($){return this.alpha(this.valpha-this.valpha*$)},opaquer($){return this.alpha(this.valpha+this.valpha*$)},rotate($){let Z=this.hsl(),J=Z.color[0];return J=(J+$)%360,J=J<0?360+J:J,Z.color[0]=J,Z},mix($,Z){if(!$||!$.rgb)throw Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof $);let J=$.rgb(),Q=this.rgb(),X=Z===void 0?0.5:Z,V=2*X-1,K=J.alpha()-Q.alpha(),W=((V*K===-1?V:(V+K)/(1+V*K))+1)/2,H=1-W;return i.rgb(W*J.red()+H*Q.red(),W*J.green()+H*Q.green(),W*J.blue()+H*Q.blue(),J.alpha()*X+Q.alpha()*(1-X))}};for(let $ of Object.keys(G0)){if(U9.includes($))continue;let{channels:Z}=G0[$];i.prototype[$]=function(...J){if(this.model===$)return new i(this);if(J.length>0)return new i(J,$);return new i([...OQ(G0[this.model][$].raw(this.color)),this.valpha],$)},i[$]=function(...J){let Q=J[0];if(typeof Q==="number")Q=n2(J,Z);return new i(Q,$)}}function xQ($,Z){return Number($.toFixed(Z))}function kQ($){return function(Z){return xQ(Z,$)}}function u($,Z,J){$=Array.isArray($)?$:[$];for(let Q of $)(r2[Q]||=[])[Z]=J;return $=$[0],function(Q){let X;if(Q!==void 0){if(J)Q=J(Q);return X=this[$](),X.color[Z]=Q,X}if(X=this[$]().color[Z],J)X=J(X);return X}}function p($){return function(Z){return Math.max(0,Math.min($,Z))}}function OQ($){return Array.isArray($)?$:[$]}function n2($,Z){for(let J=0;J<Z;J++)if(typeof $[J]!=="number")$[J]=0;return $}var yQ=i});var _9=T((BH,L9)=>{L9.exports=B9().default});var N9=T((LH,C9)=>{/*!
28
- Copyright 2013 Lovell Fuller and others.
29
- SPDX-License-Identifier: Apache-2.0
30
- */var fQ=_9(),p0=S0(),w9={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function bQ($){return this._setBackgroundColourOption("tint",$),this}function hQ($){return this.options.greyscale=p0.bool($)?$:!0,this}function gQ($){return this.greyscale($)}function dQ($){if(!p0.string($))throw p0.invalidParameterError("colourspace","string",$);return this.options.colourspacePipeline=$,this}function uQ($){return this.pipelineColourspace($)}function mQ($){if(!p0.string($))throw p0.invalidParameterError("colourspace","string",$);return this.options.colourspace=$,this}function cQ($){return this.toColourspace($)}function R9($){if(p0.object($)||p0.string($)&&$.length>=3&&$.length<=200){let Z=fQ($);return[Z.red(),Z.green(),Z.blue(),Math.round(Z.alpha()*255)]}else throw p0.invalidParameterError("background","object or string",$)}function lQ($,Z){if(p0.defined(Z))this.options[$]=R9(Z)}C9.exports=($)=>{Object.assign($.prototype,{tint:bQ,greyscale:hQ,grayscale:gQ,pipelineColourspace:dQ,pipelineColorspace:uQ,toColourspace:mQ,toColorspace:cQ,_getBackgroundColourOption:R9,_setBackgroundColourOption:lQ}),$.colourspace=w9,$.colorspace=w9}});var D9=T((_H,P9)=>{/*!
31
- Copyright 2013 Lovell Fuller and others.
32
- SPDX-License-Identifier: Apache-2.0
33
- */var y0=S0(),pQ={and:"and",or:"or",eor:"eor"};function aQ(){return this.options.removeAlpha=!0,this}function rQ($){if(y0.defined($))if(y0.number($)&&y0.inRange($,0,1))this.options.ensureAlpha=$;else throw y0.invalidParameterError("alpha","number between 0 and 1",$);else this.options.ensureAlpha=1;return this}function nQ($){let Z={red:0,green:1,blue:2,alpha:3};if(Object.keys(Z).includes($))$=Z[$];if(y0.integer($)&&y0.inRange($,0,4))this.options.extractChannel=$;else throw y0.invalidParameterError("channel","integer or one of: red, green, blue, alpha",$);return this}function iQ($,Z){if(Array.isArray($))$.forEach(function(J){this.options.joinChannelIn.push(this._createInputDescriptor(J,Z))},this);else this.options.joinChannelIn.push(this._createInputDescriptor($,Z));return this}function sQ($){if(y0.string($)&&y0.inArray($,["and","or","eor"]))this.options.bandBoolOp=$;else throw y0.invalidParameterError("boolOp","one of: and, or, eor",$);return this}P9.exports=($)=>{Object.assign($.prototype,{removeAlpha:aQ,ensureAlpha:rQ,extractChannel:nQ,joinChannel:iQ,bandbool:sQ}),$.bool=pQ}});var S9=T((wH,E9)=>{/*!
34
- Copyright 2013 Lovell Fuller and others.
35
- SPDX-License-Identifier: Apache-2.0
36
- */var s2=k("path"),Y=S0(),v4=W6(),M9=new Map([["heic","heif"],["heif","heif"],["avif","avif"],["jpeg","jpeg"],["jpg","jpeg"],["jpe","jpeg"],["tile","tile"],["dz","tile"],["png","png"],["raw","raw"],["tiff","tiff"],["tif","tiff"],["webp","webp"],["gif","gif"],["jp2","jp2"],["jpx","jp2"],["j2k","jp2"],["j2c","jp2"],["jxl","jxl"]]),oQ=/\.(jp[2x]|j2[kc])$/i,F9=()=>Error("JP2 output requires libvips with support for OpenJPEG"),I9=($)=>1<<31-Math.clz32(Math.ceil(Math.log2($)));function eQ($,Z){let J;if(!Y.string($))J=Error("Missing output file path");else if(Y.string(this.options.input.file)&&s2.resolve(this.options.input.file)===s2.resolve($))J=Error("Cannot use same file for input and output");else if(oQ.test(s2.extname($))&&!this.constructor.format.jp2k.output.file)J=F9();if(J)if(Y.fn(Z))Z(J);else return Promise.reject(J);else{this.options.fileOut=$;let Q=Error();return this._pipeline(Z,Q)}return this}function tQ($,Z){if(Y.object($))this._setBooleanOption("resolveWithObject",$.resolveWithObject);else if(this.options.resolveWithObject)this.options.resolveWithObject=!1;this.options.fileOut="";let J=Error();return this._pipeline(Y.fn($)?$:Z,J)}function $X(){return this.options.keepMetadata|=1,this}function ZX($){if(Y.object($))for(let[Z,J]of Object.entries($))if(Y.object(J))for(let[Q,X]of Object.entries(J))if(Y.string(X))this.options.withExif[`exif-${Z.toLowerCase()}-${Q}`]=X;else throw Y.invalidParameterError(`${Z}.${Q}`,"string",X);else throw Y.invalidParameterError(Z,"object",J);else throw Y.invalidParameterError("exif","object",$);return this.options.withExifMerge=!1,this.keepExif()}function JX($){return this.withExif($),this.options.withExifMerge=!0,this}function QX(){return this.options.keepMetadata|=8,this}function XX($,Z){if(Y.string($))this.options.withIccProfile=$;else throw Y.invalidParameterError("icc","string",$);if(this.keepIccProfile(),Y.object(Z)){if(Y.defined(Z.attach))if(Y.bool(Z.attach)){if(!Z.attach)this.options.keepMetadata&=-9}else throw Y.invalidParameterError("attach","boolean",Z.attach)}return this}function VX(){return this.options.keepMetadata|=2,this}function KX($){if(Y.string($)&&$.length>0)this.options.withXmp=$,this.options.keepMetadata|=2;else throw Y.invalidParameterError("xmp","non-empty string",$);return this}function WX(){return this.options.keepMetadata=31,this}function HX($){if(this.keepMetadata(),this.withIccProfile("srgb"),Y.object($)){if(Y.defined($.orientation))if(Y.integer($.orientation)&&Y.inRange($.orientation,1,8))this.options.withMetadataOrientation=$.orientation;else throw Y.invalidParameterError("orientation","integer between 1 and 8",$.orientation);if(Y.defined($.density))if(Y.number($.density)&&$.density>0)this.options.withMetadataDensity=$.density;else throw Y.invalidParameterError("density","positive number",$.density);if(Y.defined($.icc))this.withIccProfile($.icc);if(Y.defined($.exif))this.withExifMerge($.exif)}return this}function qX($,Z){let J=M9.get((Y.object($)&&Y.string($.id)?$.id:$).toLowerCase());if(!J)throw Y.invalidParameterError("format",`one of: ${[...M9.keys()].join(", ")}`,$);return this[J](Z)}function YX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.jpegQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.progressive))this._setBooleanOption("jpegProgressive",$.progressive);if(Y.defined($.chromaSubsampling))if(Y.string($.chromaSubsampling)&&Y.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jpegChromaSubsampling=$.chromaSubsampling;else throw Y.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);let Z=Y.bool($.optimizeCoding)?$.optimizeCoding:$.optimiseCoding;if(Y.defined(Z))this._setBooleanOption("jpegOptimiseCoding",Z);if(Y.defined($.mozjpeg))if(Y.bool($.mozjpeg)){if($.mozjpeg)this.options.jpegTrellisQuantisation=!0,this.options.jpegOvershootDeringing=!0,this.options.jpegOptimiseScans=!0,this.options.jpegProgressive=!0,this.options.jpegQuantisationTable=3}else throw Y.invalidParameterError("mozjpeg","boolean",$.mozjpeg);let J=Y.bool($.trellisQuantization)?$.trellisQuantization:$.trellisQuantisation;if(Y.defined(J))this._setBooleanOption("jpegTrellisQuantisation",J);if(Y.defined($.overshootDeringing))this._setBooleanOption("jpegOvershootDeringing",$.overshootDeringing);let Q=Y.bool($.optimizeScans)?$.optimizeScans:$.optimiseScans;if(Y.defined(Q)){if(this._setBooleanOption("jpegOptimiseScans",Q),Q)this.options.jpegProgressive=!0}let X=Y.number($.quantizationTable)?$.quantizationTable:$.quantisationTable;if(Y.defined(X))if(Y.integer(X)&&Y.inRange(X,0,8))this.options.jpegQuantisationTable=X;else throw Y.invalidParameterError("quantisationTable","integer between 0 and 8",X)}return this._updateFormatOut("jpeg",$)}function zX($){if(Y.object($)){if(Y.defined($.progressive))this._setBooleanOption("pngProgressive",$.progressive);if(Y.defined($.compressionLevel))if(Y.integer($.compressionLevel)&&Y.inRange($.compressionLevel,0,9))this.options.pngCompressionLevel=$.compressionLevel;else throw Y.invalidParameterError("compressionLevel","integer between 0 and 9",$.compressionLevel);if(Y.defined($.adaptiveFiltering))this._setBooleanOption("pngAdaptiveFiltering",$.adaptiveFiltering);let Z=$.colours||$.colors;if(Y.defined(Z))if(Y.integer(Z)&&Y.inRange(Z,2,256))this.options.pngBitdepth=I9(Z);else throw Y.invalidParameterError("colours","integer between 2 and 256",Z);if(Y.defined($.palette))this._setBooleanOption("pngPalette",$.palette);else if([$.quality,$.effort,$.colours,$.colors,$.dither].some(Y.defined))this._setBooleanOption("pngPalette",!0);if(this.options.pngPalette){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,0,100))this.options.pngQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 0 and 100",$.quality);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,1,10))this.options.pngEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 1 and 10",$.effort);if(Y.defined($.dither))if(Y.number($.dither)&&Y.inRange($.dither,0,1))this.options.pngDither=$.dither;else throw Y.invalidParameterError("dither","number between 0.0 and 1.0",$.dither)}}return this._updateFormatOut("png",$)}function GX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.webpQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.alphaQuality))if(Y.integer($.alphaQuality)&&Y.inRange($.alphaQuality,0,100))this.options.webpAlphaQuality=$.alphaQuality;else throw Y.invalidParameterError("alphaQuality","integer between 0 and 100",$.alphaQuality);if(Y.defined($.lossless))this._setBooleanOption("webpLossless",$.lossless);if(Y.defined($.nearLossless))this._setBooleanOption("webpNearLossless",$.nearLossless);if(Y.defined($.smartSubsample))this._setBooleanOption("webpSmartSubsample",$.smartSubsample);if(Y.defined($.smartDeblock))this._setBooleanOption("webpSmartDeblock",$.smartDeblock);if(Y.defined($.preset))if(Y.string($.preset)&&Y.inArray($.preset,["default","photo","picture","drawing","icon","text"]))this.options.webpPreset=$.preset;else throw Y.invalidParameterError("preset","one of: default, photo, picture, drawing, icon, text",$.preset);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,0,6))this.options.webpEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 0 and 6",$.effort);if(Y.defined($.minSize))this._setBooleanOption("webpMinSize",$.minSize);if(Y.defined($.mixed))this._setBooleanOption("webpMixed",$.mixed)}return o2($,this.options),this._updateFormatOut("webp",$)}function jX($){if(Y.object($)){if(Y.defined($.reuse))this._setBooleanOption("gifReuse",$.reuse);if(Y.defined($.progressive))this._setBooleanOption("gifProgressive",$.progressive);let Z=$.colours||$.colors;if(Y.defined(Z))if(Y.integer(Z)&&Y.inRange(Z,2,256))this.options.gifBitdepth=I9(Z);else throw Y.invalidParameterError("colours","integer between 2 and 256",Z);if(Y.defined($.effort))if(Y.number($.effort)&&Y.inRange($.effort,1,10))this.options.gifEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 1 and 10",$.effort);if(Y.defined($.dither))if(Y.number($.dither)&&Y.inRange($.dither,0,1))this.options.gifDither=$.dither;else throw Y.invalidParameterError("dither","number between 0.0 and 1.0",$.dither);if(Y.defined($.interFrameMaxError))if(Y.number($.interFrameMaxError)&&Y.inRange($.interFrameMaxError,0,32))this.options.gifInterFrameMaxError=$.interFrameMaxError;else throw Y.invalidParameterError("interFrameMaxError","number between 0.0 and 32.0",$.interFrameMaxError);if(Y.defined($.interPaletteMaxError))if(Y.number($.interPaletteMaxError)&&Y.inRange($.interPaletteMaxError,0,256))this.options.gifInterPaletteMaxError=$.interPaletteMaxError;else throw Y.invalidParameterError("interPaletteMaxError","number between 0.0 and 256.0",$.interPaletteMaxError);if(Y.defined($.keepDuplicateFrames))if(Y.bool($.keepDuplicateFrames))this._setBooleanOption("gifKeepDuplicateFrames",$.keepDuplicateFrames);else throw Y.invalidParameterError("keepDuplicateFrames","boolean",$.keepDuplicateFrames)}return o2($,this.options),this._updateFormatOut("gif",$)}function UX($){if(!this.constructor.format.jp2k.output.buffer)throw F9();if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.jp2Quality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.lossless))if(Y.bool($.lossless))this.options.jp2Lossless=$.lossless;else throw Y.invalidParameterError("lossless","boolean",$.lossless);if(Y.defined($.tileWidth))if(Y.integer($.tileWidth)&&Y.inRange($.tileWidth,1,32768))this.options.jp2TileWidth=$.tileWidth;else throw Y.invalidParameterError("tileWidth","integer between 1 and 32768",$.tileWidth);if(Y.defined($.tileHeight))if(Y.integer($.tileHeight)&&Y.inRange($.tileHeight,1,32768))this.options.jp2TileHeight=$.tileHeight;else throw Y.invalidParameterError("tileHeight","integer between 1 and 32768",$.tileHeight);if(Y.defined($.chromaSubsampling))if(Y.string($.chromaSubsampling)&&Y.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.jp2ChromaSubsampling=$.chromaSubsampling;else throw Y.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling)}return this._updateFormatOut("jp2",$)}function o2($,Z){if(Y.object($)&&Y.defined($.loop))if(Y.integer($.loop)&&Y.inRange($.loop,0,65535))Z.loop=$.loop;else throw Y.invalidParameterError("loop","integer between 0 and 65535",$.loop);if(Y.object($)&&Y.defined($.delay))if(Y.integer($.delay)&&Y.inRange($.delay,0,65535))Z.delay=[$.delay];else if(Array.isArray($.delay)&&$.delay.every(Y.integer)&&$.delay.every((J)=>Y.inRange(J,0,65535)))Z.delay=$.delay;else throw Y.invalidParameterError("delay","integer or an array of integers between 0 and 65535",$.delay)}function AX($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.tiffQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.bitdepth))if(Y.integer($.bitdepth)&&Y.inArray($.bitdepth,[1,2,4,8]))this.options.tiffBitdepth=$.bitdepth;else throw Y.invalidParameterError("bitdepth","1, 2, 4 or 8",$.bitdepth);if(Y.defined($.tile))this._setBooleanOption("tiffTile",$.tile);if(Y.defined($.tileWidth))if(Y.integer($.tileWidth)&&$.tileWidth>0)this.options.tiffTileWidth=$.tileWidth;else throw Y.invalidParameterError("tileWidth","integer greater than zero",$.tileWidth);if(Y.defined($.tileHeight))if(Y.integer($.tileHeight)&&$.tileHeight>0)this.options.tiffTileHeight=$.tileHeight;else throw Y.invalidParameterError("tileHeight","integer greater than zero",$.tileHeight);if(Y.defined($.miniswhite))this._setBooleanOption("tiffMiniswhite",$.miniswhite);if(Y.defined($.pyramid))this._setBooleanOption("tiffPyramid",$.pyramid);if(Y.defined($.xres))if(Y.number($.xres)&&$.xres>0)this.options.tiffXres=$.xres;else throw Y.invalidParameterError("xres","number greater than zero",$.xres);if(Y.defined($.yres))if(Y.number($.yres)&&$.yres>0)this.options.tiffYres=$.yres;else throw Y.invalidParameterError("yres","number greater than zero",$.yres);if(Y.defined($.compression))if(Y.string($.compression)&&Y.inArray($.compression,["none","jpeg","deflate","packbits","ccittfax4","lzw","webp","zstd","jp2k"]))this.options.tiffCompression=$.compression;else throw Y.invalidParameterError("compression","one of: none, jpeg, deflate, packbits, ccittfax4, lzw, webp, zstd, jp2k",$.compression);if(Y.defined($.bigtiff))this._setBooleanOption("tiffBigtiff",$.bigtiff);if(Y.defined($.predictor))if(Y.string($.predictor)&&Y.inArray($.predictor,["none","horizontal","float"]))this.options.tiffPredictor=$.predictor;else throw Y.invalidParameterError("predictor","one of: none, horizontal, float",$.predictor);if(Y.defined($.resolutionUnit))if(Y.string($.resolutionUnit)&&Y.inArray($.resolutionUnit,["inch","cm"]))this.options.tiffResolutionUnit=$.resolutionUnit;else throw Y.invalidParameterError("resolutionUnit","one of: inch, cm",$.resolutionUnit)}return this._updateFormatOut("tiff",$)}function BX($){return this.heif({...$,compression:"av1"})}function LX($){if(Y.object($)){if(Y.string($.compression)&&Y.inArray($.compression,["av1","hevc"]))this.options.heifCompression=$.compression;else throw Y.invalidParameterError("compression","one of: av1, hevc",$.compression);if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.heifQuality=$.quality;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);if(Y.defined($.lossless))if(Y.bool($.lossless))this.options.heifLossless=$.lossless;else throw Y.invalidParameterError("lossless","boolean",$.lossless);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,0,9))this.options.heifEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 0 and 9",$.effort);if(Y.defined($.chromaSubsampling))if(Y.string($.chromaSubsampling)&&Y.inArray($.chromaSubsampling,["4:2:0","4:4:4"]))this.options.heifChromaSubsampling=$.chromaSubsampling;else throw Y.invalidParameterError("chromaSubsampling","one of: 4:2:0, 4:4:4",$.chromaSubsampling);if(Y.defined($.bitdepth))if(Y.integer($.bitdepth)&&Y.inArray($.bitdepth,[8,10,12])){if($.bitdepth!==8&&this.constructor.versions.heif)throw Y.invalidParameterError("bitdepth when using prebuilt binaries",8,$.bitdepth);this.options.heifBitdepth=$.bitdepth}else throw Y.invalidParameterError("bitdepth","8, 10 or 12",$.bitdepth)}else throw Y.invalidParameterError("options","Object",$);return this._updateFormatOut("heif",$)}function _X($){if(Y.object($)){if(Y.defined($.quality))if(Y.integer($.quality)&&Y.inRange($.quality,1,100))this.options.jxlDistance=$.quality>=30?0.1+(100-$.quality)*0.09:0.017666666666666667*$.quality*$.quality-1.15*$.quality+25;else throw Y.invalidParameterError("quality","integer between 1 and 100",$.quality);else if(Y.defined($.distance))if(Y.number($.distance)&&Y.inRange($.distance,0,15))this.options.jxlDistance=$.distance;else throw Y.invalidParameterError("distance","number between 0.0 and 15.0",$.distance);if(Y.defined($.decodingTier))if(Y.integer($.decodingTier)&&Y.inRange($.decodingTier,0,4))this.options.jxlDecodingTier=$.decodingTier;else throw Y.invalidParameterError("decodingTier","integer between 0 and 4",$.decodingTier);if(Y.defined($.lossless))if(Y.bool($.lossless))this.options.jxlLossless=$.lossless;else throw Y.invalidParameterError("lossless","boolean",$.lossless);if(Y.defined($.effort))if(Y.integer($.effort)&&Y.inRange($.effort,1,9))this.options.jxlEffort=$.effort;else throw Y.invalidParameterError("effort","integer between 1 and 9",$.effort)}return o2($,this.options),this._updateFormatOut("jxl",$)}function wX($){if(Y.object($)){if(Y.defined($.depth))if(Y.string($.depth)&&Y.inArray($.depth,["char","uchar","short","ushort","int","uint","float","complex","double","dpcomplex"]))this.options.rawDepth=$.depth;else throw Y.invalidParameterError("depth","one of: char, uchar, short, ushort, int, uint, float, complex, double, dpcomplex",$.depth)}return this._updateFormatOut("raw")}function RX($){if(Y.object($)){if(Y.defined($.size))if(Y.integer($.size)&&Y.inRange($.size,1,8192))this.options.tileSize=$.size;else throw Y.invalidParameterError("size","integer between 1 and 8192",$.size);if(Y.defined($.overlap))if(Y.integer($.overlap)&&Y.inRange($.overlap,0,8192)){if($.overlap>this.options.tileSize)throw Y.invalidParameterError("overlap",`<= size (${this.options.tileSize})`,$.overlap);this.options.tileOverlap=$.overlap}else throw Y.invalidParameterError("overlap","integer between 0 and 8192",$.overlap);if(Y.defined($.container))if(Y.string($.container)&&Y.inArray($.container,["fs","zip"]))this.options.tileContainer=$.container;else throw Y.invalidParameterError("container","one of: fs, zip",$.container);if(Y.defined($.layout))if(Y.string($.layout)&&Y.inArray($.layout,["dz","google","iiif","iiif3","zoomify"]))this.options.tileLayout=$.layout;else throw Y.invalidParameterError("layout","one of: dz, google, iiif, iiif3, zoomify",$.layout);if(Y.defined($.angle))if(Y.integer($.angle)&&!($.angle%90))this.options.tileAngle=$.angle;else throw Y.invalidParameterError("angle","positive/negative multiple of 90",$.angle);if(this._setBackgroundColourOption("tileBackground",$.background),Y.defined($.depth))if(Y.string($.depth)&&Y.inArray($.depth,["onepixel","onetile","one"]))this.options.tileDepth=$.depth;else throw Y.invalidParameterError("depth","one of: onepixel, onetile, one",$.depth);if(Y.defined($.skipBlanks))if(Y.integer($.skipBlanks)&&Y.inRange($.skipBlanks,-1,65535))this.options.tileSkipBlanks=$.skipBlanks;else throw Y.invalidParameterError("skipBlanks","integer between -1 and 255/65535",$.skipBlanks);else if(Y.defined($.layout)&&$.layout==="google")this.options.tileSkipBlanks=5;let Z=Y.bool($.center)?$.center:$.centre;if(Y.defined(Z))this._setBooleanOption("tileCentre",Z);if(Y.defined($.id))if(Y.string($.id))this.options.tileId=$.id;else throw Y.invalidParameterError("id","string",$.id);if(Y.defined($.basename))if(Y.string($.basename))this.options.tileBasename=$.basename;else throw Y.invalidParameterError("basename","string",$.basename)}if(Y.inArray(this.options.formatOut,["jpeg","png","webp"]))this.options.tileFormat=this.options.formatOut;else if(this.options.formatOut!=="input")throw Y.invalidParameterError("format","one of: jpeg, png, webp",this.options.formatOut);return this._updateFormatOut("dz")}function CX($){if(!Y.plainObject($))throw Y.invalidParameterError("options","object",$);if(Y.integer($.seconds)&&Y.inRange($.seconds,0,3600))this.options.timeoutSeconds=$.seconds;else throw Y.invalidParameterError("seconds","integer between 0 and 3600",$.seconds);return this}function NX($,Z){if(!(Y.object(Z)&&Z.force===!1))this.options.formatOut=$;return this}function PX($,Z){if(Y.bool(Z))this.options[$]=Z;else throw Y.invalidParameterError($,"boolean",Z)}function DX(){if(!this.options.streamOut){this.options.streamOut=!0;let $=Error();this._pipeline(void 0,$)}}function MX($,Z){if(typeof $==="function"){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),v4.pipeline(this.options,(J,Q,X)=>{if(J)$(Y.nativeError(J,Z));else $(null,Q,X)})});else v4.pipeline(this.options,(J,Q,X)=>{if(J)$(Y.nativeError(J,Z));else $(null,Q,X)});return this}else if(this.options.streamOut){if(this._isStreamInput()){if(this.once("finish",()=>{this._flattenBufferIn(),v4.pipeline(this.options,(J,Q,X)=>{if(J)this.emit("error",Y.nativeError(J,Z));else this.emit("info",X),this.push(Q);this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished)this.emit("finish")}else v4.pipeline(this.options,(J,Q,X)=>{if(J)this.emit("error",Y.nativeError(J,Z));else this.emit("info",X),this.push(Q);this.push(null),this.on("end",()=>this.emit("close"))});return this}else if(this._isStreamInput())return new Promise((J,Q)=>{this.once("finish",()=>{this._flattenBufferIn(),v4.pipeline(this.options,(X,V,K)=>{if(X)Q(Y.nativeError(X,Z));else if(this.options.resolveWithObject)J({data:V,info:K});else J(V)})})});else return new Promise((J,Q)=>{v4.pipeline(this.options,(X,V,K)=>{if(X)Q(Y.nativeError(X,Z));else if(this.options.resolveWithObject)J({data:V,info:K});else J(V)})})}E9.exports=($)=>{Object.assign($.prototype,{toFile:eQ,toBuffer:tQ,keepExif:$X,withExif:ZX,withExifMerge:JX,keepIccProfile:QX,withIccProfile:XX,keepXmp:VX,withXmp:KX,keepMetadata:WX,withMetadata:HX,toFormat:qX,jpeg:YX,jp2:UX,png:zX,webp:GX,tiff:AX,avif:BX,heif:LX,jxl:_X,gif:jX,raw:wX,tile:RX,timeout:CX,_updateFormatOut:NX,_setBooleanOption:PX,_read:DX,_pipeline:MX})}});var k9=T((RH,x9)=>{/*!
37
- Copyright 2013 Lovell Fuller and others.
38
- SPDX-License-Identifier: Apache-2.0
39
- */var FX=k("events"),n6=O6(),L0=S0(),{runtimePlatformArch:IX}=d2(),V0=W6(),T9=IX(),e2=V0.libvipsVersion(),J4=V0.format();J4.heif.output.alias=["avif","heic"];J4.jpeg.output.alias=["jpe","jpg"];J4.tiff.output.alias=["tif"];J4.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var EX={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},x4={vips:e2.semver};if(!e2.isGlobal)if(!e2.isWasm)try{x4=k(`@img/sharp-${T9}/versions`)}catch($){try{x4=k(`@img/sharp-libvips-${T9}/versions`)}catch(Z){}}else try{x4=(()=>{throw new Error("Cannot require module "+"@img/sharp-wasm32/versions");})()}catch($){}x4.sharp=h2().version;if(x4.heif&&J4.heif)J4.heif.input.fileSuffix=[".avif"],J4.heif.output.alias=["avif"];function v9($){if(L0.bool($))if($)return V0.cache(50,20,100);else return V0.cache(0,0,0);else if(L0.object($))return V0.cache($.memory,$.files,$.items);else return V0.cache()}v9(!0);function SX($){return V0.concurrency(L0.integer($)?$:null)}if(n6.familySync()===n6.GLIBC&&!V0._isUsingJemalloc())V0.concurrency(1);else if(n6.familySync()===n6.MUSL&&V0.concurrency()===1024)V0.concurrency(k("os").availableParallelism());var TX=new FX.EventEmitter;function vX(){return V0.counters()}function xX($){return V0.simd(L0.bool($)?$:null)}function kX($){if(L0.object($))if(Array.isArray($.operation)&&$.operation.every(L0.string))V0.block($.operation,!0);else throw L0.invalidParameterError("operation","Array<string>",$.operation);else throw L0.invalidParameterError("options","object",$)}function OX($){if(L0.object($))if(Array.isArray($.operation)&&$.operation.every(L0.string))V0.block($.operation,!1);else throw L0.invalidParameterError("operation","Array<string>",$.operation);else throw L0.invalidParameterError("options","object",$)}x9.exports=($)=>{$.cache=v9,$.concurrency=SX,$.counters=vX,$.simd=xX,$.format=J4,$.interpolators=EX,$.versions=x4,$.queue=TX,$.block=kX,$.unblock=OX}});var y9=T((NH,O9)=>{/*!
40
- Copyright 2013 Lovell Fuller and others.
41
- SPDX-License-Identifier: Apache-2.0
42
- */var a0=n$();o$()(a0);Q9()(a0);V9()(a0);Y9()(a0);N9()(a0);D9()(a0);S9()(a0);k9()(a0);O9.exports=a0});var z6={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},o9={low:1024,medium:4096,high:16384,max:1e5},PV={enabled:!1,effort:"medium",interleaved:!0};function V5($,Z){if($.budgetTokens)return $.budgetTokens;let J=$.effort||"medium",Q=o9[J],X=$.modelMultiplier??(Z.includes("opus")?2:1);return Math.min(Q*X,1e5)}function K5($){return $.includes("claude-opus-4")||$.includes("claude-sonnet-4")||$.includes("claude-haiku-4")||$.includes("claude-4")}var DV={"claude-opus-4-6":{input:15,output:75,cache_write:18.75,cache_read:1.5},"claude-sonnet-4-6":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-haiku-4-5":{input:0.8,output:4,cache_write:1,cache_read:0.08}};var e9={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,jitterFactor:0.2,retryableStatusCodes:[429,500,502,503,504,529],onRetry:void 0};function t9($,Z,J,Q){let X=Z*Math.pow(2,$),V=X*Q*(Math.random()*2-1);return Math.min(X+V,J)}function $7($,Z){if($.message.includes("429")||$.message.includes("rate limit"))return!0;if($.message.includes("500")||$.message.includes("502")||$.message.includes("503")||$.message.includes("504"))return!0;if($.message.includes("ECONNREFUSED")||$.message.includes("ENOTFOUND")||$.message.includes("ETIMEDOUT")||$.message.includes("network")||$.message.includes("fetch failed"))return!0;for(let J of Z)if($.message.includes(String(J)))return!0;return!1}function Z7($){return new Promise((Z)=>setTimeout(Z,$))}async function W5($,Z={}){let J={...e9,...Z},Q=null;for(let X=0;X<=J.maxRetries;X++)try{return await $()}catch(V){if(Q=V instanceof Error?V:Error(String(V)),X<J.maxRetries&&$7(Q,J.retryableStatusCodes)){let K=t9(X,J.baseDelayMs,J.maxDelayMs,J.jitterFactor);if(J.onRetry)J.onRetry(X+1,Q,K);else console.warn(`\x1B[33mRetry ${X+1}/${J.maxRetries} after ${K}ms: ${Q.message}\x1B[0m`);await Z7(K)}else throw Q}throw Q||Error("Max retries exceeded")}var H5={"claude-opus-4-6":{input:15,output:75,cache_write:18.75,cache_read:1.5},"claude-sonnet-4-6":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-haiku-4-5":{input:0.8,output:4,cache_write:1,cache_read:0.08},"claude-3-5-sonnet":{input:3,output:15,cache_write:3.75,cache_read:0.3},"claude-3-5-haiku":{input:0.8,output:4,cache_write:1,cache_read:0.08},"claude-3-opus":{input:15,output:75,cache_write:18.75,cache_read:1.5}};function J7($,Z){let J=H5[$]??H5["claude-sonnet-4-6"],Q=Z.input_tokens-(Z.cache_read_input_tokens??0),X=Z.cache_read_input_tokens??0,V=Z.cache_creation_input_tokens??0,K=Z.output_tokens,W=Q/1e6*J.input,H=X/1e6*J.cache_read,q=V/1e6*J.cache_write,z=K/1e6*J.output,G=W+H+q+z,L=(X+V)/1e6*(J.input-J.cache_read);return{costUSD:G,estimatedSavingsUSD:L}}function Q7($,Z){if(!$||!Z.enabled||!Z.cacheSystemPrompt)return typeof $==="string"?$:void 0;if(Array.isArray($)){let J=[...$];if(J.length>0){let Q=J[J.length-1];if(Q&&Q.type==="text")J[J.length-1]={type:"text",text:Q.text,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return J}return[{type:"text",text:$,cache_control:{type:"ephemeral",ttl:Z.ttl}}]}function X7($,Z){if(!Z.enabled)return $;let J=[];for(let Q=0;Q<$.length;Q++){let X=$[Q],V=[];for(let K=0;K<X.content.length;K++){let W=X.content[K],H=K===X.content.length-1,q=Q===$.length-1;if(W.type==="text"&&W.text.length>=Z.minTokensForCache*4&&!W.cache_control&&(H||q))V.push({...W,cache_control:{type:"ephemeral",ttl:Z.ttl}});else V.push(W)}J.push({...X,content:V})}if(J.length>0&&Z.enabled){let Q=J[J.length-1],X=Q.content[Q.content.length-1];if(X&&!("cache_control"in X))Q.content[Q.content.length-1]={...X,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return J}function V7($){let Z=$.cache_read_input_tokens??0,J=$.cache_creation_input_tokens??0,Q=Z+J,X=Z>0?1:0,V=J>0?1:0,K=X+V;return{cacheHits:X,cacheMisses:V,totalCacheReadTokens:Z,totalCacheWriteTokens:J,cacheHitRate:K>0?X/K:0,estimatedSavingsUSD:0}}async function q5($,Z){let{apiKey:J,model:Q="claude-sonnet-4-6",maxTokens:X=4096,tools:V,systemPrompt:K,cacheConfig:W=z6,thinking:H,extendedThinking:q,onToken:z,onThinking:G,onRedactedThinking:U,onToolUse:L,signal:B}=Z,_=Date.now(),R=0,w=!0,D=0,I=X7($,W),S=Q7(K,W),F={model:Q,max_tokens:X,messages:I.map((h)=>({role:h.role,content:h.content})),stream:!0};if(S)F.system=S;if(V&&V.length>0)F.tools=V;let v=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,l={"Content-Type":"application/json","x-api-key":J,"anthropic-version":"2023-06-01"};if(((q?.enabled??!1)||H&&H.type!=="disabled")&&K5(Q)){let h;if(q?.budgetTokens)h=q.budgetTokens;else if(H?.type==="enabled")h=H.budget_tokens;else{let i0=q?.effort||"medium";h=V5({enabled:!0,effort:i0,modelMultiplier:Q.includes("opus")?2:1},Q)}h=Math.max(1024,Math.min(h,1e5)),F.thinking={type:"enabled",budget_tokens:h};let M0=["extended-thinking-2025-01-24"];if(q?.interleaved!==!1)M0.push("interleaved-thinking-2025-01-24");l["anthropic-beta"]=M0.join(",")}else l["anthropic-beta"]="max-tokens-3-5-sonnet-2024-07-15";let t={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,retryableStatusCodes:[429,500,502,503,504,529],onRetry:(h,M0,i0)=>{console.log(`\x1B[33mAPI retry ${h}/3 after ${i0}ms: ${M0.message}\x1B[0m`)}},r0=await W5(async()=>{let h=await fetch(v,{method:"POST",headers:l,body:JSON.stringify(F),signal:B});if(!h.ok&&t.retryableStatusCodes?.includes(h.status)){let M0=await h.text();throw Error(`API error: ${h.status} - ${M0}`)}return h},t);if(!r0.ok){let h=await r0.text();throw Error(`API error: ${r0.status} - ${h}`)}if(!r0.body)throw Error("No response body");let k4=r0.body.getReader(),q6=new TextDecoder,P0=null,f0=[],s={input_tokens:0,output_tokens:0},n0=null,_0=null,b0=null,W0=null,A4="",J5="";try{let h="";while(!0){let{done:M0,value:i0}=await k4.read();if(M0)break;h+=q6.decode(i0,{stream:!0});let f4=h.split(`
43
- `);h=f4.pop()||"";for(let B4 of f4){if(!B4.startsWith("data: "))continue;let b4=B4.slice(6);if(!b4)continue;try{let O=JSON.parse(b4);switch(O.type){case"message_start":{let y=O.message;P0=y,s=y.usage;break}case"content_block_start":{let y=O.content_block;if(y.type==="text")n0={type:"text",text:""};else if(y.type==="thinking")_0={type:"thinking",thinking:""};else if(y.type==="redacted_thinking")b0={type:"redacted_thinking",data:""};else if(y.type==="tool_use")W0={type:"tool_use",id:y.id,name:y.name,input:{}},A4="";break}case"content_block_delta":{let y=O.delta;if(y.type==="text_delta"&&n0){let x=y.text;if(n0.text+=x,z?.(x),w)R=Date.now()-_,w=!1}else if(y.type==="thinking_delta"&&_0){let x=y.thinking;_0.thinking+=x,G?.(x),D+=Math.ceil(x.length/4)}else if(y.type==="redacted_thinking_delta"&&b0){let x=y.data;b0.data+=x,U?.(x),D+=Math.ceil(x.length/4)}else if(y.type==="input_json_delta"&&W0)A4+=y.partial_json;break}case"content_block_stop":{if(n0!==null)f0.push(n0),n0=null;else if(_0!==null)f0.push(_0),_0=null;else if(b0!==null)f0.push(b0),U?.(b0.data),b0=null;else if(W0!==null){try{W0.input=JSON.parse(A4)}catch{W0.input={}}f0.push(W0),L?.({id:W0.id,name:W0.name,input:W0.input}),W0=null,A4=""}break}case"message_delta":{let y=O;if(y.usage)s.output_tokens=y.usage.output_tokens;if(P0&&y.delta?.stop_reason)P0.stop_reason=y.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{k4.releaseLock()}if(!P0)throw Error("No message received from API");P0.content=f0;let{costUSD:h0,estimatedSavingsUSD:O4}=J7(Q,s),D0=V7(s);D0.estimatedSavingsUSD=O4;let y4=Date.now()-_;return{message:P0,usage:s,cacheMetrics:D0,costUSD:h0,durationMs:y4,ttftMs:R||y4,thinkingTokens:D}}import*as Y5 from"readline";var K7={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},W7=[/\brm\s+-rf\b/,/\brm\s+-r\b/,/\brm\s+[^-]/,/\bgit\s+push\s+--force\b/,/\bgit\s+reset\s+--hard\b/,/\bgit\s+clean\s+-fd\b/,/\bdrop\b/i,/\bdelete\b/i,/\btruncate\b/i,/\bformat\b/i,/\bdd\s+if=/,/\bshred\b/,/\b:\(\)\{\s*:\|:\s*&\s*\};\s*:\b/];function H7($,Z){let J=K7[$]??"medium";if($==="Bash"){let Q=String(Z.command??"");for(let X of W7)if(X.test(Q))return"critical";if(/\bsudo\b/.test(Q)||/\bchmod\b/.test(Q))J="high"}if($==="Write"||$==="Edit"){let Q=String(Z.file_path??Z.path??"");if(/\.(env|pem|key|secret|credentials)/.test(Q))J="high";if(/\/\.ssh\//.test(Q)||/\/\.gnupg\//.test(Q))J="critical"}return J}function q7($,Z){switch($){case"Read":return`Read file: ${Z.file_path??"unknown"}`;case"Write":return`Write file: ${Z.file_path??"unknown"} (${String(Z.content??"").length} chars)`;case"Edit":return`Edit file: ${Z.file_path??"unknown"}`;case"Bash":return`Execute: ${String(Z.command??"").slice(0,100)}${String(Z.command??"").length>100?"...":""}`;case"Glob":return`Find files: ${Z.pattern??"*"}`;case"Grep":return`Search: "${Z.pattern??""}" in ${Z.path??"."}`;case"Task":return`Spawn agent: ${Z.subagent_type??"unknown"}`;default:return`Use tool: ${$}`}}class o6{cache={};cacheTimeout=300000;promptCallback;mode;constructor($="default",Z){this.mode=$,this.promptCallback=Z??this.defaultPrompt.bind(this)}async checkPermission($,Z){if(this.mode==="bypassPermissions")return{decision:"allow"};if(this.mode==="dontAsk")return{decision:"deny",reason:"Permission mode is dontAsk"};if(this.mode==="acceptEdits"){if(["Read","Write","Edit","Glob","Grep"].includes($))return{decision:"allow"}}if(this.mode==="plan"){if(["Read","Glob","Grep","Task"].includes($))return{decision:"allow"};return{decision:"deny",reason:"Plan mode - write operations disabled"}}let J=this.getCacheKey($,Z),Q=this.cache[J];if(Q&&Date.now()-Q.timestamp<this.cacheTimeout){if(Q.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(Q.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let X=H7($,Z),V=q7($,Z),K={toolName:$,toolInput:Z,riskLevel:X,description:V,file:Z.file_path??Z.path,command:$==="Bash"?Z.command:void 0};if(this.mode==="interactive"||this.mode==="default"){let W=await this.promptCallback(K);if(W.decision==="allowAlways"||W.decision==="denyAlways")this.cache[J]={decision:W.decision,timestamp:Date.now()};return W}return{decision:"allow"}}getCacheKey($,Z){if(["Read","Write","Edit"].includes($))return`${$}:${Z.file_path??Z.path??"unknown"}`;if($==="Bash"){let J=String(Z.command??"").slice(0,100);return`${$}:${J}`}return $}async defaultPrompt($){return new Promise((Z)=>{let J=Y5.createInterface({input:process.stdin,output:process.stdout}),X={low:"\x1B[32m",medium:"\x1B[33m",high:"\x1B[31m",critical:"\x1B[35m"}[$.riskLevel]??"\x1B[0m",V="\x1B[0m";if(console.log(""),console.log("\x1B[36m\u2501\u2501\u2501 Permission Required \u2501\u2501\u2501\x1B[0m"),console.log(`Tool: \x1B[1m${$.toolName}\x1B[0m`),console.log(`Risk: ${X}${$.riskLevel.toUpperCase()}\x1B[0m`),console.log(`Action: ${$.description}`),$.file)console.log(`File: ${$.file}`);if($.command)console.log(`Command: ${$.command.slice(0,200)}${$.command.length>200?"...":""}`);console.log("");let K="[y]es / [n]o / [a]lways / [d]eny always";J.question(`Allow? ${K}: `,(W)=>{switch(J.close(),W.trim().toLowerCase()){case"y":case"yes":Z({decision:"allow"});break;case"a":case"always":Z({decision:"allowAlways"});break;case"d":case"deny":case"deny always":Z({decision:"denyAlways"});break;case"n":case"no":default:Z({decision:"deny"});break}})})}clearCache(){this.cache={}}setMode($){this.mode=$,this.clearCache()}}var e6={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function xV($){return e6.readOnly.includes($)}function kV($){return e6.fileEdit.includes($)}function OV($){return e6.system.includes($)}var $2={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},t6={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function Y7($){let{current:Z,max:J,threshold:Q=t6.WARNING}=$;if(J<=0)return"";let X=Z/J;if(X<Q)return"";let V=J-Z,K=Math.round(X*100),W,H;if(X>=t6.EMERGENCY)W="emergency",H="\uD83D\uDEA8";else if(X>=t6.CRITICAL)W="critical",H="\u26A0\uFE0F";else W="warning",H="\u26A1";let q=[`${H} Token Usage ${W.toUpperCase()}`,"",`Current: ${Z.toLocaleString()} / ${J.toLocaleString()} tokens (${K}%)`,`Remaining: ${V.toLocaleString()} tokens`];if(W==="emergency")q.push(""),q.push("Consider summarizing or compacting the conversation to continue.");else if(W==="critical")q.push(""),q.push("Approaching token limit. Consider wrapping up soon.");return q.join(`
44
- `)}function z7($){let{cost:Z,previousCost:J=0,currency:Q="USD"}=$,X=G7(Q),V=z5(Z,X),K=Z-J,W=z5(Math.abs(K),X),H=["\uD83D\uDCB0 Cost Update","",`Total: ${V} ${Q}`];if(K!==0){let q=K>0?"+":"-";H.push(`This turn: ${q}${W} ${Q}`)}return H.join(`
45
- `)}function z5($,Z){if($<0.01)return`${Z}${$.toFixed(4)}`;else if($<1)return`${Z}${$.toFixed(3)}`;return`${Z}${$.toFixed(2)}`}function G7($){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[$]||$}function j7($){let{tools:Z,maxDisplay:J=10}=$;if(Z.length===0)return"No tools used this session.";let Q=new Map;for(let W of Z){let H=Q.get(W.name)||0;Q.set(W.name,H+1)}let X=[...Q.entries()].sort((W,H)=>H[1]-W[1]),V=[`\uD83D\uDD27 Tool Usage Summary (${Z.length} total calls)`,""],K=X.slice(0,J);for(let[W,H]of K)V.push(` \u2022 ${W}: ${H} call${H===1?"":"s"}`);if(X.length>J){let W=X.length-J;V.push(` ... and ${W} more tool${W===1?"":"s"}`)}return V.join(`
46
- `)}function U7($){let{workingDirectory:Z,gitStatus:J,platform:Q=process.platform,shell:X=process.env.SHELL||"unknown"}=$,V=["\uD83D\uDCCD Environment Information","",`Working Directory: ${Z}`,`Platform: ${Q}`,`Shell: ${X}`];if(J){if(V.push(""),V.push("Git Status:"),V.push(` Branch: ${J.branch}`),J.ahead>0||J.behind>0)V.push(` Ahead: ${J.ahead}, Behind: ${J.behind}`);let K=J.staged.length+J.unstaged.length+J.untracked.length+J.conflicted.length;if(K>0){if(V.push(` Changes: ${K} file${K===1?"":"s"}`),J.staged.length>0)V.push(` Staged: ${J.staged.length}`);if(J.unstaged.length>0)V.push(` Unstaged: ${J.unstaged.length}`);if(J.untracked.length>0)V.push(` Untracked: ${J.untracked.length}`);if(J.conflicted.length>0)V.push(` Conflicted: ${J.conflicted.length}`)}else V.push(" Working tree clean")}return V.join(`
47
- `)}function G5($){let{usage:Z,maxTokens:J,totalCost:Q,previousCost:X,toolsUsed:V,workingDirectory:K,gitStatus:W,turnNumber:H,config:q}=$,z={...$2,...q},G=[],U=Z.input_tokens+Z.output_tokens,L=Y7({current:U,max:J,threshold:z.tokenWarningThreshold});if(L)G.push(L);if(H%z.costUpdateInterval===0){let B=z7({cost:Q,previousCost:X});G.push(B)}if(H%z.toolSummaryInterval===0&&V.length>0){let B=j7({tools:V});G.push(B)}if(H===1&&z.envInfoOnStart){let B=U7({workingDirectory:K,gitStatus:W});G.push(B)}if(G.length===0)return"";return["---","System Reminders:","",...G,"---"].join(`
48
- `)}function h4($){if(!$||$.length===0)return 0;return Math.ceil($.length/4)}function j5($){switch($.type){case"text":return h4($.text);case"image":return 100;case"tool_use":let Z=JSON.stringify($.input);return h4($.name)+h4(Z)+10;case"tool_result":if(typeof $.content==="string")return h4($.content)+10;return $.content.reduce((J,Q)=>J+j5(Q),0)+10;case"thinking":return h4($.thinking);default:return 0}}function A7($){return 4+$.content.reduce((Q,X)=>Q+j5(X),0)}function Z2($){if(!$||$.length===0)return 0;return $.reduce((Z,J)=>Z+A7(J),0)}function B7($){let Z=[];for(let J of $.content)switch(J.type){case"text":Z.push(J.text);break;case"tool_use":Z.push(`[Tool: ${J.name}(${JSON.stringify(J.input)})]`);break;case"tool_result":let Q=typeof J.content==="string"?J.content:J.content.map((X)=>X.type==="text"?X.text:"[content]").join("");Z.push(`[Result: ${Q.slice(0,500)}${Q.length>500?"...":""}]`);break;case"thinking":Z.push(`[Thinking: ${J.thinking.slice(0,200)}...]`);break}return Z.join(`
49
- `)}function L7($){let Z=new Map;for(let J of $)for(let Q of J.content)if(Q.type==="tool_use")Z.set(Q.id,{use:Q});for(let J of $)for(let Q of J.content)if(Q.type==="tool_result"){let X=Z.get(Q.tool_use_id);if(X)X.result=Q}return Z}async function _7($){if(!$||$.length===0)return"";let Z=[];Z.push(`[Context Summary: ${$.length} messages compacted]
50
- `);let J=[];for(let X=0;X<$.length;X++){let V=$[X];if(!V)continue;let K=V.role.toUpperCase(),W=B7(V);for(let q of V.content)if(q.type==="tool_use")J.push(`${q.name}`);let H=W.length>300?`${W.slice(0,300)}...`:W;Z.push(`${K}: ${H}
51
- `)}if(J.length>0){let X=J.reduce((K,W)=>{return K[W]=(K[W]||0)+1,K},{}),V=Object.entries(X).map(([K,W])=>`${K}(${W})`).join(", ");Z.push(`
52
- Tools used: ${V}
53
- `)}let Q=Z.join("");if(Q.length>8000)Q=Q.slice(0,8000)+`
54
- ...[truncated]`;return Q}async function J2($,Z,J={}){let{keepFirst:Q=1,keepLast:X=5,preserveToolPairs:V=!0}=J,K=Z2($);if(K<=Z)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};if($.length<=Q+X)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};let W=$.slice(0,Q),H=$.slice(Q,-X),q=$.slice(-X),G={role:"user",content:[{type:"text",text:`[Previous context has been compacted for continuity]
55
-
56
- ${await _7(H)}`}]},U=[];if(V&&H.length>0){let R=L7(H),w=Array.from(R.values()).slice(-3).filter((D)=>D.result&&!D.result.is_error);for(let D of w)if(U.push(D.use),D.result)U.push(D.result)}let L=[...W,G];if(U.length>0)L.push({role:"assistant",content:U.filter((R)=>R.type==="tool_use")}),L.push({role:"user",content:U.filter((R)=>R.type==="tool_result")});L.push(...q);let B=Z2(L),_=$.length-L.length;return console.log(`Context compaction: ${$.length} -> ${L.length} messages, ${K} -> ${B} tokens`),{messages:L,messagesRemoved:_,tokensBefore:K,tokensAfter:B,didCompact:!0}}function U5($,Z,J=0.9){if($.length<8)return!1;let Q=Z2($),X=Math.floor(Z*J);return Q>=X}function Q2($){if(!$.didCompact)return{reductionPercent:0,tokensSaved:0};let Z=$.tokensBefore-$.tokensAfter,J=Z/$.tokensBefore*100;return{reductionPercent:Math.round(J*100)/100,tokensSaved:Z}}async function rV($,Z){let{apiKey:J,model:Q="claude-sonnet-4-6",maxTokens:X=4096,systemPrompt:V,tools:K,permissionMode:W,workingDirectory:H,gitStatus:q=null,reminderConfig:z,cacheConfig:G=z6,thinking:U,extendedThinking:L,onText:B,onThinking:_,onToolUse:R,onToolResult:w,onMetrics:D,onReminder:I,onPermissionRequest:S,signal:F}=Z,d=new o6(W,S),v=[...$],l=[],K0=[],t=0,r0=0,k4=0,q6=0,P0=0,f0=0,s={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},n0={...$2,...z},_0=!0;while(_0){if(F?.aborted)break;k4++;let b0=l[l.length-1],W0=G5({usage:b0?.usage??{input_tokens:0,output_tokens:0},maxTokens:X,totalCost:t,previousCost:q6,toolsUsed:K0,workingDirectory:H,gitStatus:q,turnNumber:k4,config:n0});if(W0)I?.(W0);if(U5(v,X)){let O=await J2(v,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){v.length=0,v.push(...O.messages),P0++;let y=O.tokensBefore-O.tokensAfter;f0+=y;let x=Q2(O);console.log(`Context compacted: ${x.reductionPercent}% reduction, ${x.tokensSaved} tokens saved`)}}let A4=w7(v,V,W0),J5=await q5(A4,{apiKey:J,model:Q,maxTokens:X,systemPrompt:V,cacheConfig:G,thinking:U,extendedThinking:L,tools:K.map((O)=>({name:O.name,description:O.description,input_schema:O.input_schema})),onToken:B,onThinking:_,onToolUse:R,signal:F}),{message:h0,usage:O4,cacheMetrics:D0,costUSD:y4,durationMs:h,ttftMs:M0}=J5,i0={model:Q,messageCount:v.length,messageTokens:O4.input_tokens+O4.output_tokens,usage:O4,cacheMetrics:D0,durationMs:h,ttftMs:M0,costUSD:y4,stopReason:h0.stop_reason,requestId:h0.id};if(l.push(i0),q6=t,t+=y4,r0+=h,D0)s.cacheHits+=D0.cacheHits,s.cacheMisses+=D0.cacheMisses,s.totalCacheReadTokens+=D0.totalCacheReadTokens,s.totalCacheWriteTokens+=D0.totalCacheWriteTokens,s.estimatedSavingsUSD+=D0.estimatedSavingsUSD;let f4=s.cacheHits+s.cacheMisses;if(s.cacheHitRate=f4>0?s.cacheHits/f4:0,D?.(i0),v.push({role:"assistant",content:h0.content}),h0.stop_reason==="end_turn"||h0.stop_reason==="stop_sequence"){_0=!1;break}if(h0.stop_reason==="max_tokens"){let O=await J2(v,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){v.length=0,v.push(...O.messages),P0++;let y=O.tokensBefore-O.tokensAfter;f0+=y;let x=Q2(O);console.log(`Context compacted: ${x.reductionPercent}% reduction, ${x.tokensSaved} tokens saved`);continue}else{_0=!1;break}}let B4=h0.content.filter((O)=>O.type==="tool_use");if(K0.push(...B4),B4.length===0){_0=!1;break}let b4=[];if(F?.aborted);else{let O=B4.map(async(x)=>{let s6=K.find((g0)=>g0.name===x.name);if(!s6)return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Error: Unknown tool "${x.name}"`,is_error:!0},toolResult:null};let Y6=await d.checkPermission(s6.name,x.input);if(Y6.decision==="deny"||Y6.decision==="denyAlways")return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Permission denied for tool "${x.name}"${Y6.reason?`: ${Y6.reason}`:""}`,is_error:!0},toolResult:null};try{let g0=await s6.handler(x.input,{workingDirectory:H,permissionMode:W,abortSignal:F});return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:g0.content,is_error:g0.is_error},toolResult:{id:x.id,result:g0}}}catch(g0){let a9=g0 instanceof Error?g0.message:String(g0);return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Error: ${a9}`,is_error:!0},toolResult:null}}}),y=await Promise.all(O);for(let x of y)if(b4.push(x.result),x.toolResult)w?.(x.toolResult)}v.push({role:"user",content:b4})}return{messages:v,metrics:l,totalCost:t,totalDuration:r0,totalCacheMetrics:s,compactionCount:P0,totalTokensCompacted:f0}}function w7($,Z,J){if(J&&$.length>0){let Q=[...$];for(let X=Q.length-1;X>=0;X--){let V=Q[X];if(V&&V.role==="user"){let K={role:"user",content:Array.isArray(V.content)?R7(V.content,J):[{type:"text",text:`${String(V.content)}
57
-
58
- ${J}`}]};Q[X]=K;break}}return Q}return $}function R7($,Z){if($.length>0){let Q=$[$.length-1];if(Q&&Q.type==="text"){let X={type:"text",text:`${Q.text}
59
-
60
- ${Z}`};return[...$.slice(0,-1),X]}}let J={type:"text",text:`
61
-
62
- ${Z}`};return[...$,J]}function X2($){if($<0.01)return`$${$.toFixed(4)}`;return`$${$.toFixed(2)}`}function nV($){let Z=X2($.costUSD),J=`${$.usage.input_tokens.toLocaleString()} input, ${$.usage.output_tokens.toLocaleString()} output`;if($.usage.cache_read_input_tokens||$.usage.cache_creation_input_tokens){let Q=$.usage.cache_read_input_tokens?.toLocaleString()??"0",X=$.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${Z} | Tokens: ${J} | Cache: ${Q} read, ${X} write`}return`Cost: ${Z} | Tokens: ${J}`}function iV($){let Z=X2($.costUSD),J=$.usage.input_tokens+$.usage.output_tokens;return`Cost: ${Z} | Tokens: ${J.toLocaleString()}`}function sV($){let Z=X2($.estimatedSavingsUSD);return`Cache: ${($.cacheHitRate*100).toFixed(1)}% hit rate | ${$.totalCacheReadTokens.toLocaleString()} read | ${$.totalCacheWriteTokens.toLocaleString()} written | Saved: ${Z}`}import{homedir as C7}from"os";import{join as d0}from"path";class N7{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor($){this.sessionsDir=$??d0(C7(),".claude","sessions")}async init(){try{await Bun.write(d0(this.sessionsDir,".gitkeep"),"")}catch{}}generateSessionId(){let $=Date.now().toString(36),Z=Math.random().toString(36).slice(2,8);return`${$}-${Z}`}async createSession($){await this.init();let Z=this.generateSessionId();this.currentSessionId=Z,this.currentSessionFile=d0(this.sessionsDir,`${Z}.jsonl`);let J={id:Z,created:Date.now(),updated:Date.now(),model:$.model,workingDirectory:$.workingDirectory,agentName:$.agentName,agentColor:$.agentColor,teamName:$.teamName};await this.appendEntry(J);let Q={type:"context",timestamp:Date.now(),workingDirectory:$.workingDirectory};return await this.appendEntry(Q),Z}async resumeSession($){let Z=d0(this.sessionsDir,`${$}.jsonl`);try{let J=await Bun.file(Z).text();if(!J)return null;let Q=J.trim().split(`
63
- `),X=[];for(let V of Q)try{X.push(JSON.parse(V))}catch{}return this.parseSessionEntries(X)}catch{return null}}parseSessionEntries($){let Z=null,J=[],Q=[],X=[],V=null;for(let K of $){if(!("type"in K)&&"id"in K&&"created"in K){Z=K;continue}if("type"in K){let W=K;switch(W.type){case"message":J.push(W.data);break;case"tool_use":Q.push(W);break;case"metrics":X.push(W.data);break;case"context":V=W;break}}}if(!Z)Z={id:"unknown",created:Date.now(),updated:Date.now(),model:"claude-sonnet-4-6",workingDirectory:process.cwd()};return{metadata:Z,messages:J,tools:Q,metrics:X,context:V}}async appendEntry($){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let Z=JSON.stringify($)+`
64
- `,J=Bun.file(this.currentSessionFile),Q=await J.exists()?await J.text():"";await Bun.write(this.currentSessionFile,Q+Z)}),await this.writeQueue}async saveMessage($){let Z={type:"message",timestamp:Date.now(),data:$};await this.appendEntry(Z),await this.updateTimestamp()}async saveToolUse($,Z,J,Q,X){let V={type:"tool_use",timestamp:Date.now(),toolId:$,toolName:Z,input:J,result:Q,isError:X};await this.appendEntry(V)}async saveMetrics($){let Z={type:"metrics",timestamp:Date.now(),data:$};await this.appendEntry(Z)}async updateTimestamp(){if(!this.currentSessionFile||!this.currentSessionId)return}async listSessions($=20){await this.init();let Z=Bun.file(this.sessionsDir),J=[];try{let X=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],V=await Promise.all(X.map(async(K)=>{let W=d0(this.sessionsDir,K),H=await Bun.file(W).stat();return{file:K,fullPath:W,mtime:H?.mtime??new Date(0)}}));V.sort((K,W)=>W.mtime.getTime()-K.mtime.getTime());for(let{file:K,fullPath:W}of V.slice(0,$)){let H=K.replace(".jsonl",""),q=await this.getSessionSummary(H,W);if(q)J.push(q)}}catch{}return J}async getSessionSummary($,Z){let J=Z??d0(this.sessionsDir,`${$}.jsonl`);try{let Q=await Bun.file(J).text();if(!Q)return null;let X=Q.trim().split(`
65
- `),V=null,K=0,W=0,H=0,q=0,z;for(let G of X)try{let U=JSON.parse(G);if(U.id&&U.created)V=U;else if(U.type==="message"){K++;let L=U.data;if(!z&&L.role==="user"){let B=L.content.find((_)=>_.type==="text");if(B&&"text"in B){if(z=B.text.slice(0,100),B.text.length>100)z+="..."}}}else if(U.type==="metrics")W+=U.data.costUSD,H+=U.data.usage.input_tokens,q+=U.data.usage.output_tokens}catch{}if(!V)return null;return{id:$,created:V.created,updated:V.updated,model:V.model,messageCount:K,totalCost:W,totalTokens:{input:H,output:q},firstMessage:z,workingDirectory:V.workingDirectory}}catch{return null}}getCurrentSessionId(){return this.currentSessionId}async exportSession($,Z,J){let Q=await this.resumeSession($);if(!Q)throw Error(`Session not found: ${$}`);let X,V;switch(Z){case"jsonl":{let W=d0(this.sessionsDir,`${$}.jsonl`);X=await Bun.file(W).text(),V="jsonl";break}case"json":{X=JSON.stringify(Q,null,2),V="json";break}case"markdown":{X=this.sessionToMarkdown(Q),V="md";break}default:throw Error(`Unsupported format: ${Z}`)}let K=J??d0(process.cwd(),`session-${$}.${V}`);return await Bun.write(K,X),K}sessionToMarkdown($){let Z=[];Z.push(`# Session: ${$.metadata.id}`),Z.push(""),Z.push(`**Created:** ${new Date($.metadata.created).toISOString()}`),Z.push(`**Model:** ${$.metadata.model}`),Z.push(`**Working Directory:** ${$.metadata.workingDirectory}`),Z.push(""),Z.push("## Conversation"),Z.push("");for(let J of $.messages){let Q=J.role==="user"?"**User**":"**Claude**";Z.push(`### ${Q}`),Z.push("");for(let X of J.content)if(X.type==="text")Z.push(X.text),Z.push("");else if(X.type==="tool_use"){let V=X;Z.push(`\`\`\`tool:${V.name}`),Z.push(JSON.stringify(V.input,null,2)),Z.push("```"),Z.push("")}else if(X.type==="tool_result"){let V=X;Z.push(`**Result**${V.is_error?" (error)":""}:`),Z.push("```"),Z.push(typeof V.content==="string"?V.content:JSON.stringify(V.content,null,2)),Z.push("```"),Z.push("")}}if($.metrics.length>0){Z.push("## Metrics"),Z.push("");let J=$.metrics.reduce((V,K)=>V+K.costUSD,0),Q=$.metrics.reduce((V,K)=>V+K.usage.input_tokens,0),X=$.metrics.reduce((V,K)=>V+K.usage.output_tokens,0);Z.push(`- **Total Cost:** $${J.toFixed(4)}`),Z.push(`- **Total Input Tokens:** ${Q.toLocaleString()}`),Z.push(`- **Total Output Tokens:** ${X.toLocaleString()}`),Z.push(`- **API Calls:** ${$.metrics.length}`)}return Z.join(`
66
- `)}async deleteSession($){let Z=d0(this.sessionsDir,`${$}.jsonl`);try{if(await Bun.file(Z).exists()){let{unlink:Q}=await import("fs/promises");return await Q(Z),!0}return!1}catch{return!1}}}function P7($){let Z=new Date($.created),J=new Date($.updated),Q=D7(J),X=[];X.push(`\x1B[1m${$.id}\x1B[0m (${Q})`),X.push(` Model: ${$.model} | Messages: ${$.messageCount}`);let V=$.totalCost<0.01?`$${$.totalCost.toFixed(4)}`:`$${$.totalCost.toFixed(2)}`;if(X.push(` Cost: ${V} | Tokens: ${$.totalTokens.input.toLocaleString()} in, ${$.totalTokens.output.toLocaleString()} out`),$.firstMessage)X.push(` Preview: ${$.firstMessage}`);return X.push(` Directory: ${$.workingDirectory}`),X.join(`
67
- `)}function D7($){let J=new Date().getTime()-$.getTime(),Q=Math.floor(J/60000),X=Math.floor(J/3600000),V=Math.floor(J/86400000);if(Q<1)return"just now";if(Q<60)return`${Q}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return $.toLocaleDateString()}function $K($){if($.length===0){console.log("No sessions found."),console.log(`
68
- Start a new conversation to create a session.`);return}console.log(`\x1B[1mRecent Sessions (${$.length})\x1B[0m
69
- `);for(let Z of $)console.log(P7(Z)),console.log("");console.log("To resume a session:"),console.log(" claude-remake --resume <session-id>")}import{dlopen as M7,suffix as F7}from"bun:ffi";import{join as V4,dirname as B5}from"path";import{fileURLToPath as L5}from"url";var X4=null;function _5(){if(X4)return X4;let $=B5(L5(import.meta.url)),Z=[V4($,"..","..","native"),V4($,"..","native")],J=["index.darwin-arm64.node","index.darwin-x64.node","index.node"];for(let X of Z)for(let V of J){let K=V4(X,V);try{let W=k(K);if(W&&(W.highlightCode||W.highlight_code))return X4={highlight_code:W.highlightCode||W.highlight_code,highlight_markdown:W.highlightMarkdown||W.highlight_markdown,highlight_diff:W.highlightDiff||W.highlight_diff,search_files:W.searchFiles||W.search_files,count_tokens:W.countTokens||W.count_tokens,calculate_diff:W.calculateDiff||W.calculate_diff,compact_content:W.compactContent||W.compact_content,count_tool_use:W.countToolUse||W.count_tool_use,find_tool_pairs:W.findToolPairs||W.find_tool_pairs,find_common_patterns:W.findCommonPatterns||W.find_common_patterns,validate_multi_edits:W.validateMultiEdits||W.validate_multi_edits,preview_multi_edits:W.previewMultiEdits||W.preview_multi_edits,apply_multi_edits:W.applyMultiEdits||W.apply_multi_edits},X4}catch{continue}}let Q=Z.map((X)=>V4(X,`claude_code_native.${F7}`));for(let X of Q)try{return X4=M7(X,{highlight_code:{args:["cstring","cstring"],returns:"pointer"},highlight_markdown:{args:["cstring"],returns:"pointer"},highlight_diff:{args:["cstring","cstring","pointer"],returns:"pointer"},search_files:{args:["cstring","cstring","pointer"],returns:"pointer"},count_tokens:{args:["cstring"],returns:"u32"},calculate_diff:{args:["cstring","cstring"],returns:"pointer"},compact_content:{args:["cstring","u32","cstring"],returns:"pointer"}}).symbols,X4}catch{continue}return console.warn("Native module not available, using JS fallback"),w5()}function VK(){try{return _5(),X4!==null}catch{return!1}}function w5(){return{highlight_code:($,Z)=>{let J=new Set(["function","const","let","var","return","if","else","for","while","class","interface","type","import","export","from","async","await","try","catch","throw","new","this","extends","implements","static","public","private","protected","readonly","abstract","enum","namespace"]),Q=new Set(["string","number","boolean","void","null","undefined","any","never","object","symbol","bigint","true","false"]),X={reset:"\x1B[0m",keyword:"\x1B[38;2;180;142;173m",string:"\x1B[38;2;163;190;140m",number:"\x1B[38;2;208;135;112m",type:"\x1B[38;2;191;97;106m",function:"\x1B[38;2;143;161;179m",comment:"\x1B[38;2;108;153;139m",default:"\x1B[38;2;192;197;206m"};return{html:$.split(`
70
- `).map((W)=>{if(W.trim().startsWith("//")||W.trim().startsWith("#"))return`${X.comment}${W}${X.reset}`;let H=W.replace(/(["'`])(?:(?!\1)[^\\]|\\.)*?\1/g,(q)=>{return`${X.string}${q}${X.default}`});return H=H.replace(/\b(\d+\.?\d*)\b/g,`${X.number}$1${X.default}`),H=H.replace(/\b([a-z]+)\b/gi,(q)=>{if(J.has(q))return`${X.keyword}${q}${X.default}`;if(Q.has(q))return`${X.type}${q}${X.default}`;return q}),H=H.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(/g,(q,z)=>{return`${X.function}${z}${X.default}(`}),H}).join(`
71
- `)+X.reset,theme:"fallback"}},highlight_markdown:($)=>{return{html:$+"\x1B[0m",theme:"fallback"}},highlight_diff:($,Z,J)=>{let H=$.split(`
72
- `),q=Z.split(`
73
- `),z="",G=0,U=0,L=0;if(J?.file_path)z+=`\x1B[38;2;143;161;179m${J.file_path}\x1B[0m
74
- `;let B=[],_=Array.from({length:H.length+1},()=>Array.from({length:q.length+1},()=>0));for(let d=0;d<=H.length;d++)for(let v=0;v<=q.length;v++)if(d===0||v===0)_[d][v]=0;else if(H[d-1]===q[v-1])_[d][v]=_[d-1][v-1]+1;else _[d][v]=Math.max(_[d-1][v],_[d][v-1]);let R=H.length,w=q.length,D=new Set;while(R>0&&w>0)if(H[R-1]===q[w-1])D.add(`${R-1}:${w-1}`),B.unshift(H[R-1]),R--,w--;else if(_[R-1][w]>_[R][w-1])R--;else w--;let I=0,S=0,F=0;while(I<H.length||S<q.length){while(F<B.length&&I<H.length&&S<q.length&&H[I]===B[F]&&q[S]===B[F])I++,S++,F++;let d=I+1,v=S+1,l=0,K0=0,t=[];while(I<H.length&&(F>=B.length||H[I]!==B[F]))t.push(`\x1B[38;2;191;97;106m-${H[I]}\x1B[0m`),I++,l++,U++;while(S<q.length&&(F>=B.length||q[S]!==B[F]))t.push(`\x1B[38;2;163;190;140m+${q[S]}\x1B[0m`),S++,K0++,G++;if(l>0||K0>0)L++,z+=`\x1B[38;2;108;153;139m@@ -${d},${l} +${v},${K0} @@\x1B[0m
75
- `,z+=t.join(`
76
- `)+`
77
- `}return{output:z,additions:G,deletions:U,hunks:L}},search_files:($,Z,J)=>{return{matches:[],total_count:0,files_searched:0}},count_tokens:($)=>{return Math.ceil($.length/4)},calculate_diff:($,Z)=>{let J=$.split(`
78
- `),Q=Z.split(`
79
- `),X=[];if($!==Z)X.push({oldStart:1,oldLines:J.length,newStart:1,newLines:Q.length,content:`- ${J.join(`
80
- - `)}
81
- + ${Q.join(`
82
- + `)}`});return X},compact_content:($,Z,J="truncate")=>{let X=Z*4;if($.length<=X)return $;switch(J){case"truncate":return $.slice(0,X/2)+`
83
-
84
- ... [truncated] ...
85
-
86
- `+$.slice(-X/2);case"summarize":let V=Math.floor(X/4);return`=== BEGINNING ===
87
- `+$.slice(0,V)+`
88
-
89
- === END ===
90
- `+$.slice(-V);case"extract":return $.split(`
91
- `).filter((H)=>H.trim().startsWith("#")||H.trim().startsWith("function")||H.trim().startsWith("const")||H.trim().startsWith("class")||H.trim().startsWith("export")||H.trim().startsWith("import")).slice(0,X/50).join(`
92
- `);default:return $.slice(0,X)}},validate_multi_edits:($)=>{let Z=[],J=new Map,Q=k("fs");for(let X of $)try{if(!Q.existsSync(X.filePath)){Z.push(`File not found: ${X.filePath}`);continue}if(!J.has(X.filePath)){let K=Q.readFileSync(X.filePath,"utf-8");J.set(X.filePath,K)}let V=J.get(X.filePath);if(!V.includes(X.oldString)){Z.push(`String not found in ${X.filePath}: "${I7(X.oldString,50)}"`);continue}if(!X.replaceAll){let K=(V.match(new RegExp(V2(X.oldString),"g"))||[]).length;if(K>1)Z.push(`String appears ${K} times in ${X.filePath}. Use replaceAll or provide more context.`)}}catch(V){Z.push(`Error reading ${X.filePath}: ${V}`)}return Z},preview_multi_edits:($)=>{let Z=[],J=new Map,Q=k("fs");for(let X of $)try{if(!Q.existsSync(X.filePath))continue;let V=Q.readFileSync(X.filePath,"utf-8"),K=X.replaceAll?(V.match(new RegExp(V2(X.oldString),"g"))||[]).length:1;J.set(X.filePath,(J.get(X.filePath)||0)+K)}catch{}for(let[X,V]of J)Z.push({filePath:X,replacementCount:V});return Z},apply_multi_edits:($)=>{let Z=w5().validate_multi_edits($);if(Z.length>0)return{success:!1,filesModified:[],totalReplacements:0,error:Z.join(`
93
- `),rolledBack:!1};let J=new Map,Q=new Set($.map((H)=>H.filePath)),X=k("fs");for(let H of Q)try{J.set(H,X.readFileSync(H,"utf-8"))}catch(q){return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to backup ${H}: ${q}`,rolledBack:!1}}let V=new Map;for(let[H,q]of J)V.set(H,q);let K=0;for(let H of $){let q=V.get(H.filePath);if(!q)continue;if(H.replaceAll){let z=(q.match(new RegExp(V2(H.oldString),"g"))||[]).length;V.set(H.filePath,q.split(H.oldString).join(H.newString)),K+=z}else V.set(H.filePath,q.replace(H.oldString,H.newString)),K+=1}let W=[];for(let[H,q]of V){let z=J.get(H);if(q!==z)try{Bun.write(H,q),W.push(H)}catch(G){for(let[U,L]of J)try{Bun.write(U,L)}catch{}return{success:!1,filesModified:[],totalReplacements:0,error:`Failed to write ${H}: ${G}. All changes rolled back.`,rolledBack:!0}}}return{success:!0,filesModified:W,totalReplacements:K,error:void 0,rolledBack:!1}},count_tool_use:($)=>{let Z={};for(let J of $)if(J.tool_use)for(let Q of J.tool_use)Z[Q.name]=(Z[Q.name]||0)+1;return Z},find_tool_pairs:($,Z)=>{let J={};for(let Q of $)if(Q.tool_use&&Q.tool_use.length>=2)for(let X=0;X<Q.tool_use.length-1;X++){let V=Q.tool_use[X]?.name,K=Q.tool_use[X+1]?.name;if(V&&K){if(!J[V])J[V]={};J[V][K]=(J[V][K]||0)+1}}return J},find_common_patterns:($)=>{let Z=[],J=new Map,Q=0;for(let X of $)if(X.tool_use&&X.tool_use.length>=2)for(let V=0;V<X.tool_use.length-1;V++){let K=X.tool_use[V]?.name,W=X.tool_use[V+1]?.name;if(K&&W){let H=`${K}|${W}`;J.set(H,(J.get(H)||0)+1),Q++}}for(let[X,V]of J){let[K,W]=X.split("|");Z.push({tools:[K,W],count:V,percentage:Q>0?V/Q*100:0})}return Z.sort((X,V)=>V.count-X.count).slice(0,10)}}}var K4=_5();function KK($,Z){return K4.highlight_code($,Z)}function WK($){return K4.highlight_markdown($)}function HK($,Z,J){return K4.highlight_diff($,Z,J)}function qK($,Z){return K4.calculate_diff($,Z)}function K2($){return K4.validate_multi_edits($)}function R5($){return K4.preview_multi_edits($)}function C5($){return K4.apply_multi_edits($)}function I7($,Z){if($.length<=Z)return $;return $.slice(0,Z)+"..."}function V2($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var G6=null;function E7(){if(G6)return G6;let $=B5(L5(import.meta.url)),Z=process.platform==="darwin"?"libquant_rust.dylib":process.platform==="linux"?"libquant_rust.so":"quant_rust.dll",J=[V4($,"..","..","node_modules","@ebowwa","quant-rust","native",`${process.platform}-${process.arch}`,Z),V4($,"..","..","..","@ebowwa","quant-rust","native",`${process.platform}-${process.arch}`,Z),V4($,"..","..","node_modules","@ebowwa","quant-rust","target","release",Z)];for(let Q of J)try{let{existsSync:X}=k("fs");if(!X(Q))continue;let{dlopen:V,FFIType:K,ptr:W}=k("bun:ffi");return G6=V(Q,{quant_version:{returns:K.cstring,args:[]},quant_last_error:{returns:K.cstring,args:[]},quant_clear_error:{returns:K.void,args:[]},quant_ohlcv_new:{returns:K.cstring,args:[K.u64,K.f64,K.f64,K.f64,K.f64,K.f64]},quant_amm_new:{returns:K.cstring,args:[K.f64,K.f64,K.f64]},quant_amm_calculate_cost:{returns:K.cstring,args:[K.f64,K.f64,K.bool,K.f64]},quant_amm_price_impact:{returns:K.cstring,args:[K.f64,K.f64,K.bool,K.f64]},quant_lmsr_price:{returns:K.cstring,args:[K.f64,K.f64,K.f64]},quant_lmsr_cost:{returns:K.cstring,args:[K.f64,K.f64,K.f64,K.bool,K.f64]},quant_detect_arbitrage:{returns:K.cstring,args:[K.f64,K.f64]},quant_convert_odds:{returns:K.cstring,args:[K.f64,K.i32]},quant_mean:{returns:K.f64,args:[K.ptr,K.usize]},quant_std_dev:{returns:K.f64,args:[K.ptr,K.usize]},quant_variance:{returns:K.f64,args:[K.ptr,K.usize]},quant_correlation:{returns:K.f64,args:[K.ptr,K.ptr,K.usize]},quant_free_string:{returns:K.void,args:[K.ptr]}}).symbols,G6}catch{continue}return null}var f=E7();function s0($){if(!$)throw Error(f?.quant_last_error()||"Unknown quant error");return JSON.parse($)}function g4($){let{ptr:Z}=k("bun:ffi"),J=new Float64Array($);return{buffer:J,ptr:Z(J)}}var A5=!1;function Y0(){if(!A5)console.warn("\x1B[33m[quant] WARNING: Rust native module not loaded, using JS fallback\x1B[0m"),A5=!0}function YK(){if(!f)return Y0(),"JS_FALLBACK (rust failed)";return f.quant_version()}function zK(){return f!==null}function GK($,Z,J,Q,X,V){if(!f)return Y0(),{timestamp:$,open:Z,high:J,low:Q,close:X,volume:V};let K=f.quant_ohlcv_new(BigInt($),Z,J,Q,X,V);return s0(K)}function jK($,Z,J){if(!f){Y0();let X=$*Z;return{pool_yes:$,pool_no:Z,k:X,fee:J,price_yes:Z/X,price_no:$/X}}let Q=f.quant_amm_new($,Z,J);return s0(Q)}function UK($,Z,J,Q){if(!f){Y0();let W=typeof J==="string"?J==="yes":J,H=$*Z;if(W)return H/($+Q)-Z;return H/(Z+Q)-$}let X=typeof J==="string"?J==="yes":J,V=f.quant_amm_calculate_cost($,Z,X,Q),K=s0(V);return Math.abs(K.cost)}function AK($,Z,J,Q){if(!f){Y0();let K=typeof J==="string"?J==="yes":J,W=$*Z,H=K?Z/W:$/W,q=K?$+Q:$,z=K?Z:Z+Q,G=K?z/W:q/W;return{price_before:H,price_after:G,price_impact:Math.abs(G-H)/H,slippage:Math.abs(G-H)}}let X=typeof J==="string"?J==="yes":J,V=f.quant_amm_price_impact($,Z,X,Q);return s0(V)}function BK($,Z,J){if(!f){Y0();let X=Math.exp($/J),V=Math.exp(Z/J),K=X+V;return{yes_price:X/K,no_price:V/K,spread:Math.abs(X-V)/K}}let Q=f.quant_lmsr_price($,Z,J);return s0(Q)}function LK($,Z,J,Q,X){if(!f){Y0();let W=typeof Q==="string"?Q==="yes":Q,H=J*Math.log(Math.exp($/J)+Math.exp(Z/J)),q=W?$+X:$,z=W?Z:Z+X,G=J*Math.log(Math.exp(q/J)+Math.exp(z/J));return{cost:G-H,avg_price:(G-H)/X}}let V=typeof Q==="string"?Q==="yes":Q,K=f.quant_lmsr_cost($,Z,J,V,X);return s0(K)}function _K($,Z){if(!f){Y0();let Q=$+Z;return{has_arbitrage:Q<1,yes_price:$,no_price:Z,total_price:Q,profit_per_share:Q<1?1-Q:0,profit_bps:Q<1?(1-Q)*1e4:0}}let J=f.quant_detect_arbitrage($,Z);return s0(J)}var S7={probability:0,decimal:1,american:2};function wK($,Z){if(!f){Y0();let Q;switch(Z){case"probability":Q=$;break;case"decimal":Q=1/$;break;case"american":Q=$>0?100/($+100):-$/(-$+100);break}let X=Q>=0.5?Math.round(-100/(Q-1)):Math.round((1-Q)/Q*100);return{probability:Q,decimal_odds:1/Q,american_odds:X}}let J=f.quant_convert_odds($,S7[Z]??0);return s0(J)}function RK($){if($.length===0)return NaN;if(!f)return Y0(),$.reduce((J,Q)=>J+Q,0)/$.length;let{ptr:Z}=g4($);return f.quant_mean(Z,$.length)}function CK($){if($.length===0)return NaN;if(!f){Y0();let J=$.reduce((Q,X)=>Q+X,0)/$.length;return Math.sqrt($.reduce((Q,X)=>Q+(X-J)**2,0)/$.length)}let{ptr:Z}=g4($);return f.quant_std_dev(Z,$.length)}function NK($){if($.length===0)return NaN;if(!f){Y0();let J=$.reduce((Q,X)=>Q+X,0)/$.length;return $.reduce((Q,X)=>Q+(X-J)**2,0)/$.length}let{ptr:Z}=g4($);return f.quant_variance(Z,$.length)}function PK($,Z){if($.length===0||Z.length===0||$.length!==Z.length)return NaN;if(!f){Y0();let X=$.length,V=$.reduce((z,G)=>z+G,0)/X,K=Z.reduce((z,G)=>z+G,0)/X,W=$.reduce((z,G,U)=>z+(G-V)*(Z[U]-K),0)/X,H=$.reduce((z,G)=>z+(G-V)**2,0)/X,q=Z.reduce((z,G)=>z+(G-K)**2,0)/X;return W/Math.sqrt(H*q)}let{ptr:J}=g4($),{ptr:Q}=g4(Z);return f.quant_correlation(J,Q,$.length)}var W2=($,Z,J)=>{let Q=$ instanceof RegExp?N5($,J):$,X=Z instanceof RegExp?N5(Z,J):Z,V=Q!==null&&X!=null&&T7(Q,X,J);return V&&{start:V[0],end:V[1],pre:J.slice(0,V[0]),body:J.slice(V[0]+Q.length,V[1]),post:J.slice(V[1]+X.length)}},N5=($,Z)=>{let J=Z.match($);return J?J[0]:null},T7=($,Z,J)=>{let Q,X,V,K=void 0,W,H=J.indexOf($),q=J.indexOf(Z,H+1),z=H;if(H>=0&&q>0){if($===Z)return[H,q];Q=[],V=J.length;while(z>=0&&!W){if(z===H)Q.push(z),H=J.indexOf($,z+1);else if(Q.length===1){let G=Q.pop();if(G!==void 0)W=[G,q]}else{if(X=Q.pop(),X!==void 0&&X<V)V=X,K=q;q=J.indexOf(Z,z+1)}z=H<q&&H>=0?H:q}if(Q.length&&K!==void 0)W=[V,K]}return W};var P5="\x00SLASH"+Math.random()+"\x00",D5="\x00OPEN"+Math.random()+"\x00",q2="\x00CLOSE"+Math.random()+"\x00",M5="\x00COMMA"+Math.random()+"\x00",F5="\x00PERIOD"+Math.random()+"\x00",v7=new RegExp(P5,"g"),x7=new RegExp(D5,"g"),k7=new RegExp(q2,"g"),O7=new RegExp(M5,"g"),y7=new RegExp(F5,"g"),f7=/\\\\/g,b7=/\\{/g,h7=/\\}/g,g7=/\\,/g,d7=/\\./g,u7=1e5;function H2($){return!isNaN($)?parseInt($,10):$.charCodeAt(0)}function m7($){return $.replace(f7,P5).replace(b7,D5).replace(h7,q2).replace(g7,M5).replace(d7,F5)}function c7($){return $.replace(v7,"\\").replace(x7,"{").replace(k7,"}").replace(O7,",").replace(y7,".")}function I5($){if(!$)return[""];let Z=[],J=W2("{","}",$);if(!J)return $.split(",");let{pre:Q,body:X,post:V}=J,K=Q.split(",");K[K.length-1]+="{"+X+"}";let W=I5(V);if(V.length)K[K.length-1]+=W.shift(),K.push.apply(K,W);return Z.push.apply(Z,K),Z}function E5($,Z={}){if(!$)return[];let{max:J=u7}=Z;if($.slice(0,2)==="{}")$="\\{\\}"+$.slice(2);return d4(m7($),J,!0).map(c7)}function l7($){return"{"+$+"}"}function p7($){return/^-?0\d/.test($)}function a7($,Z){return $<=Z}function r7($,Z){return $>=Z}function d4($,Z,J){let Q=[],X=W2("{","}",$);if(!X)return[$];let V=X.pre,K=X.post.length?d4(X.post,Z,!1):[""];if(/\$$/.test(X.pre))for(let W=0;W<K.length&&W<Z;W++){let H=V+"{"+X.body+"}"+K[W];Q.push(H)}else{let W=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(X.body),H=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(X.body),q=W||H,z=X.body.indexOf(",")>=0;if(!q&&!z){if(X.post.match(/,(?!,).*\}/))return $=X.pre+"{"+X.body+q2+X.post,d4($,Z,!0);return[$]}let G;if(q)G=X.body.split(/\.\./);else if(G=I5(X.body),G.length===1&&G[0]!==void 0){if(G=d4(G[0],Z,!1).map(l7),G.length===1)return K.map((L)=>X.pre+G[0]+L)}let U;if(q&&G[0]!==void 0&&G[1]!==void 0){let L=H2(G[0]),B=H2(G[1]),_=Math.max(G[0].length,G[1].length),R=G.length===3&&G[2]!==void 0?Math.abs(H2(G[2])):1,w=a7;if(B<L)R*=-1,w=r7;let I=G.some(p7);U=[];for(let S=L;w(S,B);S+=R){let F;if(H){if(F=String.fromCharCode(S),F==="\\")F=""}else if(F=String(S),I){let d=_-F.length;if(d>0){let v=Array(d+1).join("0");if(S<0)F="-"+v+F.slice(1);else F=v+F}}U.push(F)}}else{U=[];for(let L=0;L<G.length;L++)U.push.apply(U,d4(G[L],Z,!1))}for(let L=0;L<U.length;L++)for(let B=0;B<K.length&&Q.length<Z;B++){let _=V+U[L]+K[B];if(!J||q||_)Q.push(_)}}return Q}var u4=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var n7={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},m4=($)=>$.replace(/[[\]\\-]/g,"\\$&"),i7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),S5=($)=>$.join(""),T5=($,Z)=>{let J=Z;if($.charAt(J)!=="[")throw Error("not in a brace expression");let Q=[],X=[],V=J+1,K=!1,W=!1,H=!1,q=!1,z=J,G="";$:while(V<$.length){let _=$.charAt(V);if((_==="!"||_==="^")&&V===J+1){q=!0,V++;continue}if(_==="]"&&K&&!H){z=V+1;break}if(K=!0,_==="\\"){if(!H){H=!0,V++;continue}}if(_==="["&&!H){for(let[R,[w,D,I]]of Object.entries(n7))if($.startsWith(R,V)){if(G)return["$.",!1,$.length-J,!0];if(V+=R.length,I)X.push(w);else Q.push(w);W=W||D;continue $}}if(H=!1,G){if(_>G)Q.push(m4(G)+"-"+m4(_));else if(_===G)Q.push(m4(_));G="",V++;continue}if($.startsWith("-]",V+1)){Q.push(m4(_+"-")),V+=2;continue}if($.startsWith("-",V+1)){G=_,V+=2;continue}Q.push(m4(_)),V++}if(z<V)return["",!1,0,!1];if(!Q.length&&!X.length)return["$.",!1,$.length-J,!0];if(X.length===0&&Q.length===1&&/^\\?.$/.test(Q[0])&&!q){let _=Q[0].length===2?Q[0].slice(-1):Q[0];return[i7(_),!1,z-J,!1]}let U="["+(q?"^":"")+S5(Q)+"]",L="["+(q?"":"^")+S5(X)+"]";return[Q.length&&X.length?"("+U+"|"+L+")":Q.length?U:L,W,z-J,!0]};var w0=($,{windowsPathsNoEscape:Z=!1,magicalBraces:J=!0}={})=>{if(J)return Z?$.replace(/\[([^\/\\])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1");return Z?$.replace(/\[([^\/\\{}])\]/g,"$1"):$.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1")};var H0,s7=new Set(["!","?","+","*","@"]),Y2=($)=>s7.has($),v5=($)=>Y2($.type),o7=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),e7=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),t7=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),x5=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),$8="(?!(?:^|/)\\.\\.?(?:$|/))",j6="(?!\\.)",Z8=new Set(["[","."]),J8=new Set(["..","."]),Q8=new Set("().*{}+?[]^$\\!"),X8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),z2="[^/]",k5=z2+"*?",O5=z2+"+?",V8=0;class L4{type;#$;#Q;#X=!1;#Z=[];#K;#P;#_;#z=!1;#W;#G;#Y=!1;id=++V8;get depth(){return(this.#K?.depth??-1)+1}[Symbol.for("nodejs.util.inspect.custom")](){return{"@@type":"AST",id:this.id,type:this.type,root:this.#$.id,parent:this.#K?.id,depth:this.depth,partsLength:this.#Z.length,parts:this.#Z}}constructor($,Z,J={}){if(this.type=$,$)this.#Q=!0;if(this.#K=Z,this.#$=this.#K?this.#K.#$:this,this.#W=this.#$===this?J:this.#$.#W,this.#_=this.#$===this?[]:this.#$.#_,$==="!"&&!this.#$.#z)this.#_.push(this);this.#P=this.#K?this.#K.#Z.length:0}get hasMagic(){if(this.#Q!==void 0)return this.#Q;for(let $ of this.#Z){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#Q=!0}return this.#Q}toString(){if(this.#G!==void 0)return this.#G;if(!this.type)return this.#G=this.#Z.map(($)=>String($)).join("");else return this.#G=this.type+"("+this.#Z.map(($)=>String($)).join("|")+")"}#H(){if(this!==this.#$)throw Error("should only call on root");if(this.#z)return this;this.toString(),this.#z=!0;let $;while($=this.#_.pop()){if($.type!=="!")continue;let Z=$,J=Z.#K;while(J){for(let Q=Z.#P+1;!J.type&&Q<J.#Z.length;Q++)for(let X of $.#Z){if(typeof X==="string")throw Error("string part in extglob AST??");X.copyIn(J.#Z[Q])}Z=J,J=Z.#K}}return this}push(...$){for(let Z of $){if(Z==="")continue;if(typeof Z!=="string"&&!(Z instanceof H0&&Z.#K===this))throw Error("invalid part: "+Z);this.#Z.push(Z)}}toJSON(){let $=this.type===null?this.#Z.slice().map((Z)=>typeof Z==="string"?Z:Z.toJSON()):[this.type,...this.#Z.map((Z)=>Z.toJSON())];if(this.isStart()&&!this.type)$.unshift([]);if(this.isEnd()&&(this===this.#$||this.#$.#z&&this.#K?.type==="!"))$.push({});return $}isStart(){if(this.#$===this)return!0;if(!this.#K?.isStart())return!1;if(this.#P===0)return!0;let $=this.#K;for(let Z=0;Z<this.#P;Z++){let J=$.#Z[Z];if(!(J instanceof H0&&J.type==="!"))return!1}return!0}isEnd(){if(this.#$===this)return!0;if(this.#K?.type==="!")return!0;if(!this.#K?.isEnd())return!1;if(!this.type)return this.#K?.isEnd();let $=this.#K?this.#K.#Z.length:0;return this.#P===$-1}copyIn($){if(typeof $==="string")this.push($);else this.push($.clone(this))}clone($){let Z=new H0(this.type,$);for(let J of this.#Z)Z.copyIn(J);return Z}static#V($,Z,J,Q,X){let V=Q.maxExtglobRecursion??2,K=!1,W=!1,H=-1,q=!1;if(Z.type===null){let B=J,_="";while(B<$.length){let R=$.charAt(B++);if(K||R==="\\"){K=!K,_+=R;continue}if(W){if(B===H+1){if(R==="^"||R==="!")q=!0}else if(R==="]"&&!(B===H+2&&q))W=!1;_+=R;continue}else if(R==="["){W=!0,H=B,q=!1,_+=R;continue}if(!Q.noext&&Y2(R)&&$.charAt(B)==="("&&X<=V){Z.push(_),_="";let D=new H0(R,Z);B=H0.#V($,D,B,Q,X+1),Z.push(D);continue}_+=R}return Z.push(_),B}let z=J+1,G=new H0(null,Z),U=[],L="";while(z<$.length){let B=$.charAt(z++);if(K||B==="\\"){K=!K,L+=B;continue}if(W){if(z===H+1){if(B==="^"||B==="!")q=!0}else if(B==="]"&&!(z===H+2&&q))W=!1;L+=B;continue}else if(B==="["){W=!0,H=z,q=!1,L+=B;continue}if(!Q.noext&&Y2(B)&&$.charAt(z)==="("&&(X<=V||Z&&Z.#U(B))){let R=Z&&Z.#U(B)?0:1;G.push(L),L="";let w=new H0(B,G);G.push(w),z=H0.#V($,w,z,Q,X+R);continue}if(B==="|"){G.push(L),L="",U.push(G),G=new H0(null,Z);continue}if(B===")"){if(L===""&&Z.#Z.length===0)Z.#Y=!0;return G.push(L),L="",Z.push(...U,G),z}L+=B}return Z.type=null,Z.#Q=void 0,Z.#Z=[$.substring(J-1)],z}#w($){return this.#C($,e7)}#C($,Z=o7){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null)return!1;let J=$.#Z[0];if(!J||typeof J!=="object"||J.type===null)return!1;return this.#U(J.type,Z)}#U($,Z=t7){return!!Z.get(this.type)?.includes($)}#A($,Z){let J=$.#Z[0],Q=new H0(null,J,this.options);Q.#Z.push(""),J.push(Q),this.#F($,Z)}#F($,Z){let J=$.#Z[0];this.#Z.splice(Z,1,...J.#Z);for(let Q of J.#Z)if(typeof Q==="object")Q.#K=this;this.#G=void 0}#B($){return!!x5.get(this.type)?.has($)}#N($){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null||this.#Z.length!==1)return!1;let Z=$.#Z[0];if(!Z||typeof Z!=="object"||Z.type===null)return!1;return this.#B(Z.type)}#D($){let Z=x5.get(this.type),J=$.#Z[0],Q=Z?.get(J.type);if(!Q)return!1;this.#Z=J.#Z;for(let X of this.#Z)if(typeof X==="object")X.#K=this;this.type=Q,this.#G=void 0,this.#Y=!1}static fromGlob($,Z={}){let J=new H0(null,void 0,Z);return H0.#V($,J,0,Z,0),J}toMMPattern(){if(this!==this.#$)return this.#$.toMMPattern();let $=this.toString(),[Z,J,Q,X]=this.toRegExpSource();if(!(Q||this.#Q||this.#W.nocase&&!this.#W.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return J;let K=(this.#W.nocase?"i":"")+(X?"u":"");return Object.assign(new RegExp(`^${Z}$`,K),{_src:Z,_glob:$})}get options(){return this.#W}toRegExpSource($){let Z=$??!!this.#W.dot;if(this.#$===this)this.#j(),this.#H();if(!v5(this)){let W=this.isStart()&&this.isEnd()&&!this.#Z.some((U)=>typeof U!=="string"),H=this.#Z.map((U)=>{let[L,B,_,R]=typeof U==="string"?H0.#R(U,this.#Q,W):U.toRegExpSource($);return this.#Q=this.#Q||_,this.#X=this.#X||R,L}).join(""),q="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&J8.has(this.#Z[0]))){let L=Z8,B=Z&&L.has(H.charAt(0))||H.startsWith("\\.")&&L.has(H.charAt(2))||H.startsWith("\\.\\.")&&L.has(H.charAt(4)),_=!Z&&!$&&L.has(H.charAt(0));q=B?$8:_?j6:""}}}let z="";if(this.isEnd()&&this.#$.#z&&this.#K?.type==="!")z="(?:$|\\/)";return[q+H+z,w0(H),this.#Q=!!this.#Q,this.#X]}let J=this.type==="*"||this.type==="+",Q=this.type==="!"?"(?:(?!(?:":"(?:",X=this.#L(Z);if(this.isStart()&&this.isEnd()&&!X&&this.type!=="!"){let W=this.toString(),H=this;return H.#Z=[W],H.type=null,H.#Q=void 0,[W,w0(this.toString()),!1,!1]}let V=!J||$||Z||!j6?"":this.#L(!0);if(V===X)V="";if(V)X=`(?:${X})(?:${V})*?`;let K="";if(this.type==="!"&&this.#Y)K=(this.isStart()&&!Z?j6:"")+O5;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!$?j6:"")+k5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;K=Q+X+W}return[K,w0(X),this.#Q=!!this.#Q,this.#X]}#j(){if(!v5(this)){for(let $ of this.#Z)if(typeof $==="object")$.#j()}else{let $=0,Z=!1;do{Z=!0;for(let J=0;J<this.#Z.length;J++){let Q=this.#Z[J];if(typeof Q==="object"){if(Q.#j(),this.#C(Q))Z=!1,this.#F(Q,J);else if(this.#w(Q))Z=!1,this.#A(Q,J);else if(this.#N(Q))Z=!1,this.#D(Q)}}}while(!Z&&++$<10)}this.#G=void 0}#L($){return this.#Z.map((Z)=>{if(typeof Z==="string")throw Error("string type in extglob ast??");let[J,Q,X,V]=Z.toRegExpSource($);return this.#X=this.#X||V,J}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#R($,Z,J=!1){let Q=!1,X="",V=!1,K=!1;for(let W=0;W<$.length;W++){let H=$.charAt(W);if(Q){Q=!1,X+=(Q8.has(H)?"\\":"")+H;continue}if(H==="*"){if(K)continue;K=!0,X+=J&&/^[*]+$/.test($)?O5:k5,Z=!0;continue}else K=!1;if(H==="\\"){if(W===$.length-1)X+="\\\\";else Q=!0;continue}if(H==="["){let[q,z,G,U]=T5($,W);if(G){X+=q,V=V||z,W+=G-1,Z=Z||U;continue}}if(H==="?"){X+=z2,Z=!0;continue}X+=X8(H)}return[X,w0($),!!Z,V]}}H0=L4;var _4=($,{windowsPathsNoEscape:Z=!1,magicalBraces:J=!1}={})=>{if(J)return Z?$.replace(/[?*()[\]{}]/g,"[$&]"):$.replace(/[?*()[\]\\{}]/g,"\\$&");return Z?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var $0=($,Z,J={})=>{if(u4(Z),!J.nocomment&&Z.charAt(0)==="#")return!1;return new U0(Z,J).match($)},K8=/^\*+([^+@!?\*\[\(]*)$/,W8=($)=>(Z)=>!Z.startsWith(".")&&Z.endsWith($),H8=($)=>(Z)=>Z.endsWith($),q8=($)=>{return $=$.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith($)},Y8=($)=>{return $=$.toLowerCase(),(Z)=>Z.toLowerCase().endsWith($)},z8=/^\*+\.\*+$/,G8=($)=>!$.startsWith(".")&&$.includes("."),j8=($)=>$!=="."&&$!==".."&&$.includes("."),U8=/^\.\*+$/,A8=($)=>$!=="."&&$!==".."&&$.startsWith("."),B8=/^\*+$/,L8=($)=>$.length!==0&&!$.startsWith("."),_8=($)=>$.length!==0&&$!=="."&&$!=="..",w8=/^\?+([^+@!?\*\[\(]*)?$/,R8=([$,Z=""])=>{let J=b5([$]);if(!Z)return J;return Z=Z.toLowerCase(),(Q)=>J(Q)&&Q.toLowerCase().endsWith(Z)},C8=([$,Z=""])=>{let J=h5([$]);if(!Z)return J;return Z=Z.toLowerCase(),(Q)=>J(Q)&&Q.toLowerCase().endsWith(Z)},N8=([$,Z=""])=>{let J=h5([$]);return!Z?J:(Q)=>J(Q)&&Q.endsWith(Z)},P8=([$,Z=""])=>{let J=b5([$]);return!Z?J:(Q)=>J(Q)&&Q.endsWith(Z)},b5=([$])=>{let Z=$.length;return(J)=>J.length===Z&&!J.startsWith(".")},h5=([$])=>{let Z=$.length;return(J)=>J.length===Z&&J!=="."&&J!==".."},g5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",y5={win32:{sep:"\\"},posix:{sep:"/"}},D8=g5==="win32"?y5.win32.sep:y5.posix.sep;$0.sep=D8;var m=Symbol("globstar **");$0.GLOBSTAR=m;var M8="[^/]",F8=M8+"*?",I8="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",E8="(?:(?!(?:\\/|^)\\.).)*?",S8=($,Z={})=>(J)=>$0(J,$,Z);$0.filter=S8;var j0=($,Z={})=>Object.assign({},$,Z),T8=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return $0;let Z=$0;return Object.assign((Q,X,V={})=>Z(Q,X,j0($,V)),{Minimatch:class extends Z.Minimatch{constructor(X,V={}){super(X,j0($,V))}static defaults(X){return Z.defaults(j0($,X)).Minimatch}},AST:class extends Z.AST{constructor(X,V,K={}){super(X,V,j0($,K))}static fromGlob(X,V={}){return Z.AST.fromGlob(X,j0($,V))}},unescape:(Q,X={})=>Z.unescape(Q,j0($,X)),escape:(Q,X={})=>Z.escape(Q,j0($,X)),filter:(Q,X={})=>Z.filter(Q,j0($,X)),defaults:(Q)=>Z.defaults(j0($,Q)),makeRe:(Q,X={})=>Z.makeRe(Q,j0($,X)),braceExpand:(Q,X={})=>Z.braceExpand(Q,j0($,X)),match:(Q,X,V={})=>Z.match(Q,X,j0($,V)),sep:Z.sep,GLOBSTAR:m})};$0.defaults=T8;var d5=($,Z={})=>{if(u4($),Z.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return E5($,{max:Z.braceExpandMax})};$0.braceExpand=d5;var v8=($,Z={})=>new U0($,Z).makeRe();$0.makeRe=v8;var x8=($,Z,J={})=>{let Q=new U0(Z,J);if($=$.filter((X)=>Q.match(X)),Q.options.nonull&&!$.length)$.push(Z);return $};$0.match=x8;var f5=/[?*]|[+@!]\(.*?\)|\[|\]/,k8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class U0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor($,Z={}){u4($),Z=Z||{},this.options=Z,this.maxGlobstarRecursion=Z.maxGlobstarRecursion??200,this.pattern=$,this.platform=Z.platform||g5,this.isWindows=this.platform==="win32";let J="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z[J]===!1,this.windowsPathsNoEscape)this.pattern=this.pattern.replace(/\\/g,"/");this.preserveMultipleSlashes=!!Z.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!Z.nonegate,this.comment=!1,this.empty=!1,this.partial=!!Z.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=Z.windowsNoMagicRoot!==void 0?Z.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let $ of this.set)for(let Z of $)if(typeof Z!=="string")return!0;return!1}debug(...$){}make(){let $=this.pattern,Z=this.options;if(!Z.nocomment&&$.charAt(0)==="#"){this.comment=!0;return}if(!$){this.empty=!0;return}if(this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],Z.debug)this.debug=(...X)=>console.error(...X);this.debug(this.pattern,this.globSet);let J=this.globSet.map((X)=>this.slashSplit(X));this.globParts=this.preprocess(J),this.debug(this.pattern,this.globParts);let Q=this.globParts.map((X,V,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=X[0]===""&&X[1]===""&&(X[2]==="?"||!f5.test(X[2]))&&!f5.test(X[3]),H=/^[a-z]:/i.test(X[0]);if(W)return[...X.slice(0,4),...X.slice(4).map((q)=>this.parse(q))];else if(H)return[X[0],...X.slice(1).map((q)=>this.parse(q))]}return X.map((W)=>this.parse(W))});if(this.debug(this.pattern,Q),this.set=Q.filter((X)=>X.indexOf(!1)===-1),this.isWindows)for(let X=0;X<this.set.length;X++){let V=this.set[X];if(V[0]===""&&V[1]===""&&this.globParts[X][2]==="?"&&typeof V[3]==="string"&&/^[a-z]:$/i.test(V[3]))V[2]="?"}this.debug(this.pattern,this.set)}preprocess($){if(this.options.noglobstar){for(let J=0;J<$.length;J++)for(let Q=0;Q<$[J].length;Q++)if($[J][Q]==="**")$[J][Q]="*"}let{optimizationLevel:Z=1}=this.options;if(Z>=2)$=this.firstPhasePreProcess($),$=this.secondPhasePreProcess($);else if(Z>=1)$=this.levelOneOptimize($);else $=this.adjascentGlobstarOptimize($);return $}adjascentGlobstarOptimize($){return $.map((Z)=>{let J=-1;while((J=Z.indexOf("**",J+1))!==-1){let Q=J;while(Z[Q+1]==="**")Q++;if(Q!==J)Z.splice(J,Q-J)}return Z})}levelOneOptimize($){return $.map((Z)=>{return Z=Z.reduce((J,Q)=>{let X=J[J.length-1];if(Q==="**"&&X==="**")return J;if(Q===".."){if(X&&X!==".."&&X!=="."&&X!=="**")return J.pop(),J}return J.push(Q),J},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let Q=1;Q<$.length-1;Q++){let X=$[Q];if(Q===1&&X===""&&$[0]==="")continue;if(X==="."||X==="")Z=!0,$.splice(Q,1),Q--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Z=!0,$.pop()}let J=0;while((J=$.indexOf("..",J+1))!==-1){let Q=$[J-1];if(Q&&Q!=="."&&Q!==".."&&Q!=="**")Z=!0,$.splice(J-1,2),J-=2}}while(Z);return $.length===0?[""]:$}firstPhasePreProcess($){let Z=!1;do{Z=!1;for(let J of $){let Q=-1;while((Q=J.indexOf("**",Q+1))!==-1){let V=Q;while(J[V+1]==="**")V++;if(V>Q)J.splice(Q+1,V-Q);let K=J[Q+1],W=J[Q+2],H=J[Q+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!H||H==="."||H==="..")continue;Z=!0,J.splice(Q,1);let q=J.slice(0);q[Q]="**",$.push(q),Q--}if(!this.preserveMultipleSlashes){for(let V=1;V<J.length-1;V++){let K=J[V];if(V===1&&K===""&&J[0]==="")continue;if(K==="."||K==="")Z=!0,J.splice(V,1),V--}if(J[0]==="."&&J.length===2&&(J[1]==="."||J[1]===""))Z=!0,J.pop()}let X=0;while((X=J.indexOf("..",X+1))!==-1){let V=J[X-1];if(V&&V!=="."&&V!==".."&&V!=="**"){Z=!0;let W=X===1&&J[X+1]==="**"?["."]:[];if(J.splice(X-1,2,...W),J.length===0)J.push("");X-=2}}}}while(Z);return $}secondPhasePreProcess($){for(let Z=0;Z<$.length-1;Z++)for(let J=Z+1;J<$.length;J++){let Q=this.partsMatch($[Z],$[J],!this.preserveMultipleSlashes);if(Q){$[Z]=[],$[J]=Q;break}}return $.filter((Z)=>Z.length)}partsMatch($,Z,J=!1){let Q=0,X=0,V=[],K="";while(Q<$.length&&X<Z.length)if($[Q]===Z[X])V.push(K==="b"?Z[X]:$[Q]),Q++,X++;else if(J&&$[Q]==="**"&&Z[X]===$[Q+1])V.push($[Q]),Q++;else if(J&&Z[X]==="**"&&$[Q]===Z[X+1])V.push(Z[X]),X++;else if($[Q]==="*"&&Z[X]&&(this.options.dot||!Z[X].startsWith("."))&&Z[X]!=="**"){if(K==="b")return!1;K="a",V.push($[Q]),Q++,X++}else if(Z[X]==="*"&&$[Q]&&(this.options.dot||!$[Q].startsWith("."))&&$[Q]!=="**"){if(K==="a")return!1;K="b",V.push(Z[X]),Q++,X++}else return!1;return $.length===Z.length&&V}parseNegate(){if(this.nonegate)return;let $=this.pattern,Z=!1,J=0;for(let Q=0;Q<$.length&&$.charAt(Q)==="!";Q++)Z=!Z,J++;if(J)this.pattern=$.slice(J);this.negate=Z}matchOne($,Z,J=!1){let Q=0,X=0;if(this.isWindows){let K=typeof $[0]==="string"&&/^[a-z]:$/i.test($[0]),W=!K&&$[0]===""&&$[1]===""&&$[2]==="?"&&/^[a-z]:$/i.test($[3]),H=typeof Z[0]==="string"&&/^[a-z]:$/i.test(Z[0]),q=!H&&Z[0]===""&&Z[1]===""&&Z[2]==="?"&&typeof Z[3]==="string"&&/^[a-z]:$/i.test(Z[3]),z=W?3:K?0:void 0,G=q?3:H?0:void 0;if(typeof z==="number"&&typeof G==="number"){let[U,L]=[$[z],Z[G]];if(U.toLowerCase()===L.toLowerCase())Z[G]=U,X=G,Q=z}}let{optimizationLevel:V=1}=this.options;if(V>=2)$=this.levelTwoFileOptimize($);if(Z.includes(m))return this.#$($,Z,J,Q,X);return this.#X($,Z,J,Q,X)}#$($,Z,J,Q,X){let V=Z.indexOf(m,X),K=Z.lastIndexOf(m),[W,H,q]=J?[Z.slice(X,V),Z.slice(V+1),[]]:[Z.slice(X,V),Z.slice(V+1,K),Z.slice(K+1)];if(W.length){let w=$.slice(Q,Q+W.length);if(!this.#X(w,W,J,0,0))return!1;Q+=W.length,X+=W.length}let z=0;if(q.length){if(q.length+Q>$.length)return!1;let w=$.length-q.length;if(this.#X($,q,J,w,0))z=q.length;else{if($[$.length-1]!==""||Q+q.length===$.length)return!1;if(w--,!this.#X($,q,J,w,0))return!1;z=q.length+1}}if(!H.length){let w=!!z;for(let D=Q;D<$.length-z;D++){let I=String($[D]);if(w=!0,I==="."||I===".."||!this.options.dot&&I.startsWith("."))return!1}return J||w}let G=[[[],0]],U=G[0],L=0,B=[0];for(let w of H)if(w===m)B.push(L),U=[[],0],G.push(U);else U[0].push(w),L++;let _=G.length-1,R=$.length-z;for(let w of G)w[1]=R-(B[_--]+w[0].length);return!!this.#Q($,G,Q,0,J,0,!!z)}#Q($,Z,J,Q,X,V,K){let W=Z[Q];if(!W){for(let z=J;z<$.length;z++){K=!0;let G=$[z];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1}return K}let[H,q]=W;while(J<=q){if(this.#X($.slice(0,J+H.length),H,X,J,0)&&V<this.maxGlobstarRecursion){let U=this.#Q($,Z,J+H.length,Q+1,X,V+1,K);if(U!==!1)return U}let G=$[J];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1;J++}return X||null}#X($,Z,J,Q,X){let V,K,W,H;for(V=Q,K=X,H=$.length,W=Z.length;V<H&&K<W;V++,K++){this.debug("matchOne loop");let q=Z[K],z=$[V];if(this.debug(Z,q,z),q===!1||q===m)return!1;let G;if(typeof q==="string")G=z===q,this.debug("string match",q,z,G);else G=q.test(z),this.debug("pattern match",q,z,G);if(!G)return!1}if(V===H&&K===W)return!0;else if(V===H)return J;else if(K===W)return V===H-1&&$[V]==="";else throw Error("wtf?")}braceExpand(){return d5(this.pattern,this.options)}parse($){u4($);let Z=this.options;if($==="**")return m;if($==="")return"";let J,Q=null;if(J=$.match(B8))Q=Z.dot?_8:L8;else if(J=$.match(K8))Q=(Z.nocase?Z.dot?Y8:q8:Z.dot?H8:W8)(J[1]);else if(J=$.match(w8))Q=(Z.nocase?Z.dot?C8:R8:Z.dot?N8:P8)(J);else if(J=$.match(z8))Q=Z.dot?j8:G8;else if(J=$.match(U8))Q=A8;let X=L4.fromGlob($,this.options).toMMPattern();if(Q&&typeof X==="object")Reflect.defineProperty(X,"test",{value:Q});return X}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let $=this.set;if(!$.length)return this.regexp=!1,this.regexp;let Z=this.options,J=Z.noglobstar?F8:Z.dot?I8:E8,Q=new Set(Z.nocase?["i"]:[]),X=$.map((W)=>{let H=W.map((z)=>{if(z instanceof RegExp)for(let G of z.flags.split(""))Q.add(G);return typeof z==="string"?k8(z):z===m?m:z._src});H.forEach((z,G)=>{let U=H[G+1],L=H[G-1];if(z!==m||L===m)return;if(L===void 0)if(U!==void 0&&U!==m)H[G+1]="(?:\\/|"+J+"\\/)?"+U;else H[G]=J;else if(U===void 0)H[G-1]=L+"(?:\\/|\\/"+J+")?";else if(U!==m)H[G-1]=L+"(?:\\/|\\/"+J+"\\/)"+U,H[G+1]=m});let q=H.filter((z)=>z!==m);if(this.partial&&q.length>=1){let z=[];for(let G=1;G<=q.length;G++)z.push(q.slice(0,G).join("/"));return"(?:"+z.join("|")+")"}return q.join("/")}).join("|"),[V,K]=$.length>1?["(?:",")"]:["",""];if(X="^"+V+X+K+"$",this.partial)X="^(?:\\/|"+V+X.slice(1,-1)+K+")$";if(this.negate)X="^(?!"+X+").+$";try{this.regexp=new RegExp(X,[...Q].join(""))}catch(W){this.regexp=!1}return this.regexp}slashSplit($){if(this.preserveMultipleSlashes)return $.split("/");else if(this.isWindows&&/^\/\/[^\/]+/.test($))return["",...$.split(/\/+/)];else return $.split(/\/+/)}match($,Z=this.partial){if(this.debug("match",$,this.pattern),this.comment)return!1;if(this.empty)return $==="";if($==="/"&&Z)return!0;let J=this.options;if(this.isWindows)$=$.split("\\").join("/");let Q=this.slashSplit($);this.debug(this.pattern,"split",Q);let X=this.set;this.debug(this.pattern,"set",X);let V=Q[Q.length-1];if(!V)for(let K=Q.length-2;!V&&K>=0;K--)V=Q[K];for(let K=0;K<X.length;K++){let W=X[K],H=Q;if(J.matchBase&&W.length===1)H=[V];if(this.matchOne(H,W,Z)){if(J.flipNegate)return!0;return!this.negate}}if(J.flipNegate)return!1;return this.negate}static defaults($){return $0.defaults($).Minimatch}}$0.AST=L4;$0.Minimatch=U0;$0.escape=_4;$0.unescape=w0;import{fileURLToPath as jZ}from"url";var O8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,m5=new Set,G2=typeof process=="object"&&process?process:{},c5=($,Z,J,Q)=>{typeof G2.emitWarning=="function"?G2.emitWarning($,Z,J,Q):console.error(`[${J}] ${Z}: ${$}`)},A6=globalThis.AbortController,u5=globalThis.AbortSignal;if(typeof A6>"u"){u5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(J,Q){this._onabort.push(Q)}},A6=class{constructor(){Z()}signal=new u5;abort(J){if(!this.signal.aborted){this.signal.reason=J,this.signal.aborted=!0;for(let Q of this.signal._onabort)Q(J);this.signal.onabort?.(J)}}};let $=G2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{$&&($=!1,c5("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",Z))}}var y8=($)=>!m5.has($),pK=Symbol("type"),o0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),l5=($)=>o0($)?$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?U6:null:null,U6=class extends Array{constructor($){super($),this.fill(0)}},f8=class ${heap;length;static#$=!1;static create(Z){let J=l5(Z);if(!J)return[];$.#$=!0;let Q=new $(Z,J);return $.#$=!1,Q}constructor(Z,J){if(!$.#$)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new J(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}},c4=class ${#$;#Q;#X;#Z;#K;#P;#_;#z;get perf(){return this.#z}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#W;#G;#Y;#H;#V;#w;#C;#U;#A;#F;#B;#N;#D;#j;#L;#R;#I;#J;#O;static unsafeExposeInternals(Z){return{starts:Z.#D,ttls:Z.#j,autopurgeTimers:Z.#L,sizes:Z.#N,keyMap:Z.#Y,keyList:Z.#H,valList:Z.#V,next:Z.#w,prev:Z.#C,get head(){return Z.#U},get tail(){return Z.#A},free:Z.#F,isBackgroundFetch:(J)=>Z.#q(J),backgroundFetch:(J,Q,X,V)=>Z.#m(J,Q,X,V),moveToTail:(J)=>Z.#f(J),indexes:(J)=>Z.#T(J),rindexes:(J)=>Z.#v(J),isStale:(J)=>Z.#M(J)}}get max(){return this.#$}get maxSize(){return this.#Q}get calculatedSize(){return this.#G}get size(){return this.#W}get fetchMethod(){return this.#P}get memoMethod(){return this.#_}get dispose(){return this.#X}get onInsert(){return this.#Z}get disposeAfter(){return this.#K}constructor(Z){let{max:J=0,ttl:Q,ttlResolution:X=1,ttlAutopurge:V,updateAgeOnGet:K,updateAgeOnHas:W,allowStale:H,dispose:q,onInsert:z,disposeAfter:G,noDisposeOnSet:U,noUpdateTTL:L,maxSize:B=0,maxEntrySize:_=0,sizeCalculation:R,fetchMethod:w,memoMethod:D,noDeleteOnFetchRejection:I,noDeleteOnStaleGet:S,allowStaleOnFetchRejection:F,allowStaleOnFetchAbort:d,ignoreFetchAbort:v,perf:l}=Z;if(l!==void 0&&typeof l?.now!="function")throw TypeError("perf option must have a now() method if specified");if(this.#z=l??O8,J!==0&&!o0(J))throw TypeError("max option must be a nonnegative integer");let K0=J?l5(J):Array;if(!K0)throw Error("invalid max value: "+J);if(this.#$=J,this.#Q=B,this.maxEntrySize=_||this.#Q,this.sizeCalculation=R,this.sizeCalculation){if(!this.#Q&&!this.maxEntrySize)throw TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw TypeError("sizeCalculation set to non-function")}if(D!==void 0&&typeof D!="function")throw TypeError("memoMethod must be a function if defined");if(this.#_=D,w!==void 0&&typeof w!="function")throw TypeError("fetchMethod must be a function if specified");if(this.#P=w,this.#I=!!w,this.#Y=new Map,this.#H=Array(J).fill(void 0),this.#V=Array(J).fill(void 0),this.#w=new K0(J),this.#C=new K0(J),this.#U=0,this.#A=0,this.#F=f8.create(J),this.#W=0,this.#G=0,typeof q=="function"&&(this.#X=q),typeof z=="function"&&(this.#Z=z),typeof G=="function"?(this.#K=G,this.#B=[]):(this.#K=void 0,this.#B=void 0),this.#R=!!this.#X,this.#O=!!this.#Z,this.#J=!!this.#K,this.noDisposeOnSet=!!U,this.noUpdateTTL=!!L,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!F,this.allowStaleOnFetchAbort=!!d,this.ignoreFetchAbort=!!v,this.maxEntrySize!==0){if(this.#Q!==0&&!o0(this.#Q))throw TypeError("maxSize must be a positive integer if specified");if(!o0(this.maxEntrySize))throw TypeError("maxEntrySize must be a positive integer if specified");this.#l()}if(this.allowStale=!!H,this.noDeleteOnStaleGet=!!S,this.updateAgeOnGet=!!K,this.updateAgeOnHas=!!W,this.ttlResolution=o0(X)||X===0?X:1,this.ttlAutopurge=!!V,this.ttl=Q||0,this.ttl){if(!o0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#x()}if(this.#$===0&&this.ttl===0&&this.#Q===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#$&&!this.#Q){let t="LRU_CACHE_UNBOUNDED";y8(t)&&(m5.add(t),c5("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",t,$))}}getRemainingTTL(Z){return this.#Y.has(Z)?1/0:0}#x(){let Z=new U6(this.#$),J=new U6(this.#$);this.#j=Z,this.#D=J;let Q=this.ttlAutopurge?Array(this.#$):void 0;this.#L=Q,this.#h=(K,W,H=this.#z.now())=>{if(J[K]=W!==0?H:0,Z[K]=W,Q?.[K]&&(clearTimeout(Q[K]),Q[K]=void 0),W!==0&&Q){let q=setTimeout(()=>{this.#M(K)&&this.#S(this.#H[K],"expire")},W+1);q.unref&&q.unref(),Q[K]=q}},this.#E=(K)=>{J[K]=Z[K]!==0?this.#z.now():0},this.#k=(K,W)=>{if(Z[W]){let H=Z[W],q=J[W];if(!H||!q)return;K.ttl=H,K.start=q,K.now=X||V();let z=K.now-q;K.remainingTTL=H-z}};let X=0,V=()=>{let K=this.#z.now();if(this.ttlResolution>0){X=K;let W=setTimeout(()=>X=0,this.ttlResolution);W.unref&&W.unref()}return K};this.getRemainingTTL=(K)=>{let W=this.#Y.get(K);if(W===void 0)return 0;let H=Z[W],q=J[W];if(!H||!q)return 1/0;let z=(X||V())-q;return H-z},this.#M=(K)=>{let W=J[K],H=Z[K];return!!H&&!!W&&(X||V())-W>H}}#E=()=>{};#k=()=>{};#h=()=>{};#M=()=>!1;#l(){let Z=new U6(this.#$);this.#G=0,this.#N=Z,this.#b=(J)=>{this.#G-=Z[J],Z[J]=0},this.#g=(J,Q,X,V)=>{if(this.#q(Q))return 0;if(!o0(X))if(V){if(typeof V!="function")throw TypeError("sizeCalculation must be a function");if(X=V(Q,J),!o0(X))throw TypeError("sizeCalculation return invalid (expect positive integer)")}else throw TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return X},this.#y=(J,Q,X)=>{if(Z[J]=Q,this.#Q){let V=this.#Q-Z[J];for(;this.#G>V;)this.#u(!0)}this.#G+=Z[J],X&&(X.entrySize=Q,X.totalCalculatedSize=this.#G)}}#b=(Z)=>{};#y=(Z,J,Q)=>{};#g=(Z,J,Q,X)=>{if(Q||X)throw TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#T({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#A;!(!this.#d(J)||((Z||!this.#M(J))&&(yield J),J===this.#U));)J=this.#C[J]}*#v({allowStale:Z=this.allowStale}={}){if(this.#W)for(let J=this.#U;!(!this.#d(J)||((Z||!this.#M(J))&&(yield J),J===this.#A));)J=this.#w[J]}#d(Z){return Z!==void 0&&this.#Y.get(this.#H[Z])===Z}*entries(){for(let Z of this.#T())this.#V[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield[this.#H[Z],this.#V[Z]])}*rentries(){for(let Z of this.#v())this.#V[Z]!==void 0&&this.#H[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield[this.#H[Z],this.#V[Z]])}*keys(){for(let Z of this.#T()){let J=this.#H[Z];J!==void 0&&!this.#q(this.#V[Z])&&(yield J)}}*rkeys(){for(let Z of this.#v()){let J=this.#H[Z];J!==void 0&&!this.#q(this.#V[Z])&&(yield J)}}*values(){for(let Z of this.#T())this.#V[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield this.#V[Z])}*rvalues(){for(let Z of this.#v())this.#V[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield this.#V[Z])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,J={}){for(let Q of this.#T()){let X=this.#V[Q],V=this.#q(X)?X.__staleWhileFetching:X;if(V!==void 0&&Z(V,this.#H[Q],this))return this.get(this.#H[Q],J)}}forEach(Z,J=this){for(let Q of this.#T()){let X=this.#V[Q],V=this.#q(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(J,V,this.#H[Q],this)}}rforEach(Z,J=this){for(let Q of this.#v()){let X=this.#V[Q],V=this.#q(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(J,V,this.#H[Q],this)}}purgeStale(){let Z=!1;for(let J of this.#v({allowStale:!0}))this.#M(J)&&(this.#S(this.#H[J],"expire"),Z=!0);return Z}info(Z){let J=this.#Y.get(Z);if(J===void 0)return;let Q=this.#V[J],X=this.#q(Q)?Q.__staleWhileFetching:Q;if(X===void 0)return;let V={value:X};if(this.#j&&this.#D){let K=this.#j[J],W=this.#D[J];if(K&&W){let H=K-(this.#z.now()-W);V.ttl=H,V.start=Date.now()}}return this.#N&&(V.size=this.#N[J]),V}dump(){let Z=[];for(let J of this.#T({allowStale:!0})){let Q=this.#H[J],X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;if(V===void 0||Q===void 0)continue;let K={value:V};if(this.#j&&this.#D){K.ttl=this.#j[J];let W=this.#z.now()-this.#D[J];K.start=Math.floor(Date.now()-W)}this.#N&&(K.size=this.#N[J]),Z.unshift([Q,K])}return Z}load(Z){this.clear();for(let[J,Q]of Z){if(Q.start){let X=Date.now()-Q.start;Q.start=this.#z.now()-X}this.set(J,Q.value,Q)}}set(Z,J,Q={}){if(J===void 0)return this.delete(Z),this;let{ttl:X=this.ttl,start:V,noDisposeOnSet:K=this.noDisposeOnSet,sizeCalculation:W=this.sizeCalculation,status:H}=Q,{noUpdateTTL:q=this.noUpdateTTL}=Q,z=this.#g(Z,J,Q.size||0,W);if(this.maxEntrySize&&z>this.maxEntrySize)return H&&(H.set="miss",H.maxEntrySizeExceeded=!0),this.#S(Z,"set"),this;let G=this.#W===0?void 0:this.#Y.get(Z);if(G===void 0)G=this.#W===0?this.#A:this.#F.length!==0?this.#F.pop():this.#W===this.#$?this.#u(!1):this.#W,this.#H[G]=Z,this.#V[G]=J,this.#Y.set(Z,G),this.#w[this.#A]=G,this.#C[G]=this.#A,this.#A=G,this.#W++,this.#y(G,z,H),H&&(H.set="add"),q=!1,this.#O&&this.#Z?.(J,Z,"add");else{this.#f(G);let U=this.#V[G];if(J!==U){if(this.#I&&this.#q(U)){U.__abortController.abort(Error("replaced"));let{__staleWhileFetching:L}=U;L!==void 0&&!K&&(this.#R&&this.#X?.(L,Z,"set"),this.#J&&this.#B?.push([L,Z,"set"]))}else K||(this.#R&&this.#X?.(U,Z,"set"),this.#J&&this.#B?.push([U,Z,"set"]));if(this.#b(G),this.#y(G,z,H),this.#V[G]=J,H){H.set="replace";let L=U&&this.#q(U)?U.__staleWhileFetching:U;L!==void 0&&(H.oldValue=L)}}else H&&(H.set="update");this.#O&&this.onInsert?.(J,Z,J===U?"update":"replace")}if(X!==0&&!this.#j&&this.#x(),this.#j&&(q||this.#h(G,X,V),H&&this.#k(H,G)),!K&&this.#J&&this.#B){let U=this.#B,L;for(;L=U?.shift();)this.#K?.(...L)}return this}pop(){try{for(;this.#W;){let Z=this.#V[this.#U];if(this.#u(!0),this.#q(Z)){if(Z.__staleWhileFetching)return Z.__staleWhileFetching}else if(Z!==void 0)return Z}}finally{if(this.#J&&this.#B){let Z=this.#B,J;for(;J=Z?.shift();)this.#K?.(...J)}}}#u(Z){let J=this.#U,Q=this.#H[J],X=this.#V[J];return this.#I&&this.#q(X)?X.__abortController.abort(Error("evicted")):(this.#R||this.#J)&&(this.#R&&this.#X?.(X,Q,"evict"),this.#J&&this.#B?.push([X,Q,"evict"])),this.#b(J),this.#L?.[J]&&(clearTimeout(this.#L[J]),this.#L[J]=void 0),Z&&(this.#H[J]=void 0,this.#V[J]=void 0,this.#F.push(J)),this.#W===1?(this.#U=this.#A=0,this.#F.length=0):this.#U=this.#w[J],this.#Y.delete(Q),this.#W--,J}has(Z,J={}){let{updateAgeOnHas:Q=this.updateAgeOnHas,status:X}=J,V=this.#Y.get(Z);if(V!==void 0){let K=this.#V[V];if(this.#q(K)&&K.__staleWhileFetching===void 0)return!1;if(this.#M(V))X&&(X.has="stale",this.#k(X,V));else return Q&&this.#E(V),X&&(X.has="hit",this.#k(X,V)),!0}else X&&(X.has="miss");return!1}peek(Z,J={}){let{allowStale:Q=this.allowStale}=J,X=this.#Y.get(Z);if(X===void 0||!Q&&this.#M(X))return;let V=this.#V[X];return this.#q(V)?V.__staleWhileFetching:V}#m(Z,J,Q,X){let V=J===void 0?void 0:this.#V[J];if(this.#q(V))return V;let K=new A6,{signal:W}=Q;W?.addEventListener("abort",()=>K.abort(W.reason),{signal:K.signal});let H={signal:K.signal,options:Q,context:X},q=(_,R=!1)=>{let{aborted:w}=K.signal,D=Q.ignoreFetchAbort&&_!==void 0,I=Q.ignoreFetchAbort||!!(Q.allowStaleOnFetchAbort&&_!==void 0);if(Q.status&&(w&&!R?(Q.status.fetchAborted=!0,Q.status.fetchError=K.signal.reason,D&&(Q.status.fetchAbortIgnored=!0)):Q.status.fetchResolved=!0),w&&!D&&!R)return G(K.signal.reason,I);let S=L,F=this.#V[J];return(F===L||D&&R&&F===void 0)&&(_===void 0?S.__staleWhileFetching!==void 0?this.#V[J]=S.__staleWhileFetching:this.#S(Z,"fetch"):(Q.status&&(Q.status.fetchUpdated=!0),this.set(Z,_,H.options))),_},z=(_)=>(Q.status&&(Q.status.fetchRejected=!0,Q.status.fetchError=_),G(_,!1)),G=(_,R)=>{let{aborted:w}=K.signal,D=w&&Q.allowStaleOnFetchAbort,I=D||Q.allowStaleOnFetchRejection,S=I||Q.noDeleteOnFetchRejection,F=L;if(this.#V[J]===L&&(!S||!R&&F.__staleWhileFetching===void 0?this.#S(Z,"fetch"):D||(this.#V[J]=F.__staleWhileFetching)),I)return Q.status&&F.__staleWhileFetching!==void 0&&(Q.status.returnedStale=!0),F.__staleWhileFetching;if(F.__returned===F)throw _},U=(_,R)=>{let w=this.#P?.(Z,V,H);w&&w instanceof Promise&&w.then((D)=>_(D===void 0?void 0:D),R),K.signal.addEventListener("abort",()=>{(!Q.ignoreFetchAbort||Q.allowStaleOnFetchAbort)&&(_(void 0),Q.allowStaleOnFetchAbort&&(_=(D)=>q(D,!0)))})};Q.status&&(Q.status.fetchDispatched=!0);let L=new Promise(U).then(q,z),B=Object.assign(L,{__abortController:K,__staleWhileFetching:V,__returned:void 0});return J===void 0?(this.set(Z,B,{...H.options,status:void 0}),J=this.#Y.get(Z)):this.#V[J]=B,B}#q(Z){if(!this.#I)return!1;let J=Z;return!!J&&J instanceof Promise&&J.hasOwnProperty("__staleWhileFetching")&&J.__abortController instanceof A6}async fetch(Z,J={}){let{allowStale:Q=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,ttl:K=this.ttl,noDisposeOnSet:W=this.noDisposeOnSet,size:H=0,sizeCalculation:q=this.sizeCalculation,noUpdateTTL:z=this.noUpdateTTL,noDeleteOnFetchRejection:G=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:U=this.allowStaleOnFetchRejection,ignoreFetchAbort:L=this.ignoreFetchAbort,allowStaleOnFetchAbort:B=this.allowStaleOnFetchAbort,context:_,forceRefresh:R=!1,status:w,signal:D}=J;if(!this.#I)return w&&(w.fetch="get"),this.get(Z,{allowStale:Q,updateAgeOnGet:X,noDeleteOnStaleGet:V,status:w});let I={allowStale:Q,updateAgeOnGet:X,noDeleteOnStaleGet:V,ttl:K,noDisposeOnSet:W,size:H,sizeCalculation:q,noUpdateTTL:z,noDeleteOnFetchRejection:G,allowStaleOnFetchRejection:U,allowStaleOnFetchAbort:B,ignoreFetchAbort:L,status:w,signal:D},S=this.#Y.get(Z);if(S===void 0){w&&(w.fetch="miss");let F=this.#m(Z,S,I,_);return F.__returned=F}else{let F=this.#V[S];if(this.#q(F)){let K0=Q&&F.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",K0&&(w.returnedStale=!0)),K0?F.__staleWhileFetching:F.__returned=F}let d=this.#M(S);if(!R&&!d)return w&&(w.fetch="hit"),this.#f(S),X&&this.#E(S),w&&this.#k(w,S),F;let v=this.#m(Z,S,I,_),l=v.__staleWhileFetching!==void 0&&Q;return w&&(w.fetch=d?"stale":"refresh",l&&d&&(w.returnedStale=!0)),l?v.__staleWhileFetching:v.__returned=v}}async forceFetch(Z,J={}){let Q=await this.fetch(Z,J);if(Q===void 0)throw Error("fetch() returned undefined");return Q}memo(Z,J={}){let Q=this.#_;if(!Q)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:V,...K}=J,W=this.get(Z,K);if(!V&&W!==void 0)return W;let H=Q(Z,W,{options:K,context:X});return this.set(Z,H,K),H}get(Z,J={}){let{allowStale:Q=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:K}=J,W=this.#Y.get(Z);if(W!==void 0){let H=this.#V[W],q=this.#q(H);return K&&this.#k(K,W),this.#M(W)?(K&&(K.get="stale"),q?(K&&Q&&H.__staleWhileFetching!==void 0&&(K.returnedStale=!0),Q?H.__staleWhileFetching:void 0):(V||this.#S(Z,"expire"),K&&Q&&(K.returnedStale=!0),Q?H:void 0)):(K&&(K.get="hit"),q?H.__staleWhileFetching:(this.#f(W),X&&this.#E(W),H))}else K&&(K.get="miss")}#c(Z,J){this.#C[J]=Z,this.#w[Z]=J}#f(Z){Z!==this.#A&&(Z===this.#U?this.#U=this.#w[Z]:this.#c(this.#C[Z],this.#w[Z]),this.#c(this.#A,Z),this.#A=Z)}delete(Z){return this.#S(Z,"delete")}#S(Z,J){let Q=!1;if(this.#W!==0){let X=this.#Y.get(Z);if(X!==void 0)if(this.#L?.[X]&&(clearTimeout(this.#L?.[X]),this.#L[X]=void 0),Q=!0,this.#W===1)this.#p(J);else{this.#b(X);let V=this.#V[X];if(this.#q(V)?V.__abortController.abort(Error("deleted")):(this.#R||this.#J)&&(this.#R&&this.#X?.(V,Z,J),this.#J&&this.#B?.push([V,Z,J])),this.#Y.delete(Z),this.#H[X]=void 0,this.#V[X]=void 0,X===this.#A)this.#A=this.#C[X];else if(X===this.#U)this.#U=this.#w[X];else{let K=this.#C[X];this.#w[K]=this.#w[X];let W=this.#w[X];this.#C[W]=this.#C[X]}this.#W--,this.#F.push(X)}}if(this.#J&&this.#B?.length){let X=this.#B,V;for(;V=X?.shift();)this.#K?.(...V)}return Q}clear(){return this.#p("delete")}#p(Z){for(let J of this.#v({allowStale:!0})){let Q=this.#V[J];if(this.#q(Q))Q.__abortController.abort(Error("deleted"));else{let X=this.#H[J];this.#R&&this.#X?.(Q,X,Z),this.#J&&this.#B?.push([Q,X,Z])}}if(this.#Y.clear(),this.#V.fill(void 0),this.#H.fill(void 0),this.#j&&this.#D){this.#j.fill(0),this.#D.fill(0);for(let J of this.#L??[])J!==void 0&&clearTimeout(J);this.#L?.fill(void 0)}if(this.#N&&this.#N.fill(0),this.#U=0,this.#A=0,this.#F.length=0,this.#G=0,this.#W=0,this.#J&&this.#B){let J=this.#B,Q;for(;Q=J?.shift();)this.#K?.(...Q)}}};import{posix as r8,win32 as N2}from"path";import{fileURLToPath as n8}from"url";import{lstatSync as i8,readdir as s8,readdirSync as o8,readlinkSync as e8,realpathSync as t8}from"fs";import*as $Z from"fs";import{lstat as JZ,readdir as QZ,readlink as XZ,realpath as VZ}from"fs/promises";import{EventEmitter as _2}from"events";import i5 from"stream";import{StringDecoder as b8}from"string_decoder";var p5=typeof process==="object"&&process?process:{stdout:null,stderr:null},h8=($)=>!!$&&typeof $==="object"&&($ instanceof H4||$ instanceof i5||g8($)||d8($)),g8=($)=>!!$&&typeof $==="object"&&$ instanceof _2&&typeof $.pipe==="function"&&$.pipe!==i5.Writable.prototype.pipe,d8=($)=>!!$&&typeof $==="object"&&$ instanceof _2&&typeof $.write==="function"&&typeof $.end==="function",u0=Symbol("EOF"),m0=Symbol("maybeEmitEnd"),e0=Symbol("emittedEnd"),B6=Symbol("emittingEnd"),l4=Symbol("emittedError"),L6=Symbol("closed"),a5=Symbol("read"),_6=Symbol("flush"),r5=Symbol("flushChunk"),R0=Symbol("encoding"),w4=Symbol("decoder"),a=Symbol("flowing"),p4=Symbol("paused"),R4=Symbol("resume"),r=Symbol("buffer"),Z0=Symbol("pipes"),n=Symbol("bufferLength"),j2=Symbol("bufferPush"),w6=Symbol("bufferShift"),o=Symbol("objectMode"),c=Symbol("destroyed"),U2=Symbol("error"),A2=Symbol("emitData"),n5=Symbol("emitEnd"),B2=Symbol("emitEnd2"),F0=Symbol("async"),L2=Symbol("abort"),R6=Symbol("aborted"),a4=Symbol("signal"),W4=Symbol("dataListeners"),z0=Symbol("discarded"),r4=($)=>Promise.resolve().then($),u8=($)=>$(),m8=($)=>$==="end"||$==="finish"||$==="prefinish",c8=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,l8=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class w2{src;dest;opts;ondrain;constructor($,Z,J){this.src=$,this.dest=Z,this.opts=J,this.ondrain=()=>$[R4](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors($){}end(){if(this.unpipe(),this.opts.end)this.dest.end()}}class s5 extends w2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Z,J){super($,Z,J);this.proxyErrors=(Q)=>this.dest.emit("error",Q),$.on("error",this.proxyErrors)}}var p8=($)=>!!$.objectMode,a8=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class H4 extends _2{[a]=!1;[p4]=!1;[Z0]=[];[r]=[];[o];[R0];[F0];[w4];[u0]=!1;[e0]=!1;[B6]=!1;[L6]=!1;[l4]=null;[n]=0;[c]=!1;[a4];[R6]=!1;[W4]=0;[z0]=!1;writable=!0;readable=!0;constructor(...$){let Z=$[0]||{};super();if(Z.objectMode&&typeof Z.encoding==="string")throw TypeError("Encoding and objectMode may not be used together");if(p8(Z))this[o]=!0,this[R0]=null;else if(a8(Z))this[R0]=Z.encoding,this[o]=!1;else this[o]=!1,this[R0]=null;if(this[F0]=!!Z.async,this[w4]=this[R0]?new b8(this[R0]):null,Z&&Z.debugExposeBuffer===!0)Object.defineProperty(this,"buffer",{get:()=>this[r]});if(Z&&Z.debugExposePipes===!0)Object.defineProperty(this,"pipes",{get:()=>this[Z0]});let{signal:J}=Z;if(J)if(this[a4]=J,J.aborted)this[L2]();else J.addEventListener("abort",()=>this[L2]())}get bufferLength(){return this[n]}get encoding(){return this[R0]}set encoding($){throw Error("Encoding must be set at instantiation time")}setEncoding($){throw Error("Encoding must be set at instantiation time")}get objectMode(){return this[o]}set objectMode($){throw Error("objectMode must be set at instantiation time")}get["async"](){return this[F0]}set["async"]($){this[F0]=this[F0]||!!$}[L2](){this[R6]=!0,this.emit("abort",this[a4]?.reason),this.destroy(this[a4]?.reason)}get aborted(){return this[R6]}set aborted($){}write($,Z,J){if(this[R6])return!1;if(this[u0])throw Error("write after end");if(this[c])return this.emit("error",Object.assign(Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;if(typeof Z==="function")J=Z,Z="utf8";if(!Z)Z="utf8";let Q=this[F0]?r4:u8;if(!this[o]&&!Buffer.isBuffer($)){if(l8($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(c8($))$=Buffer.from($);else if(typeof $!=="string")throw Error("Non-contiguous data written to non-objectMode stream")}if(this[o]){if(this[a]&&this[n]!==0)this[_6](!0);if(this[a])this.emit("data",$);else this[j2]($);if(this[n]!==0)this.emit("readable");if(J)Q(J);return this[a]}if(!$.length){if(this[n]!==0)this.emit("readable");if(J)Q(J);return this[a]}if(typeof $==="string"&&!(Z===this[R0]&&!this[w4]?.lastNeed))$=Buffer.from($,Z);if(Buffer.isBuffer($)&&this[R0])$=this[w4].write($);if(this[a]&&this[n]!==0)this[_6](!0);if(this[a])this.emit("data",$);else this[j2]($);if(this[n]!==0)this.emit("readable");if(J)Q(J);return this[a]}read($){if(this[c])return null;if(this[z0]=!1,this[n]===0||$===0||$&&$>this[n])return this[m0](),null;if(this[o])$=null;if(this[r].length>1&&!this[o])this[r]=[this[R0]?this[r].join(""):Buffer.concat(this[r],this[n])];let Z=this[a5]($||null,this[r][0]);return this[m0](),Z}[a5]($,Z){if(this[o])this[w6]();else{let J=Z;if($===J.length||$===null)this[w6]();else if(typeof J==="string")this[r][0]=J.slice($),Z=J.slice(0,$),this[n]-=$;else this[r][0]=J.subarray($),Z=J.subarray(0,$),this[n]-=$}if(this.emit("data",Z),!this[r].length&&!this[u0])this.emit("drain");return Z}end($,Z,J){if(typeof $==="function")J=$,$=void 0;if(typeof Z==="function")J=Z,Z="utf8";if($!==void 0)this.write($,Z);if(J)this.once("end",J);if(this[u0]=!0,this.writable=!1,this[a]||!this[p4])this[m0]();return this}[R4](){if(this[c])return;if(!this[W4]&&!this[Z0].length)this[z0]=!0;if(this[p4]=!1,this[a]=!0,this.emit("resume"),this[r].length)this[_6]();else if(this[u0])this[m0]();else this.emit("drain")}resume(){return this[R4]()}pause(){this[a]=!1,this[p4]=!0,this[z0]=!1}get destroyed(){return this[c]}get flowing(){return this[a]}get paused(){return this[p4]}[j2]($){if(this[o])this[n]+=1;else this[n]+=$.length;this[r].push($)}[w6](){if(this[o])this[n]-=1;else this[n]-=this[r][0].length;return this[r].shift()}[_6]($=!1){do;while(this[r5](this[w6]())&&this[r].length);if(!$&&!this[r].length&&!this[u0])this.emit("drain")}[r5]($){return this.emit("data",$),this[a]}pipe($,Z){if(this[c])return $;this[z0]=!1;let J=this[e0];if(Z=Z||{},$===p5.stdout||$===p5.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,J){if(Z.end)$.end()}else if(this[Z0].push(!Z.proxyErrors?new w2(this,$,Z):new s5(this,$,Z)),this[F0])r4(()=>this[R4]());else this[R4]();return $}unpipe($){let Z=this[Z0].find((J)=>J.dest===$);if(Z){if(this[Z0].length===1){if(this[a]&&this[W4]===0)this[a]=!1;this[Z0]=[]}else this[Z0].splice(this[Z0].indexOf(Z),1);Z.unpipe()}}addListener($,Z){return this.on($,Z)}on($,Z){let J=super.on($,Z);if($==="data"){if(this[z0]=!1,this[W4]++,!this[Z0].length&&!this[a])this[R4]()}else if($==="readable"&&this[n]!==0)super.emit("readable");else if(m8($)&&this[e0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[l4]){let Q=Z;if(this[F0])r4(()=>Q.call(this,this[l4]));else Q.call(this,this[l4])}return J}removeListener($,Z){return this.off($,Z)}off($,Z){let J=super.off($,Z);if($==="data"){if(this[W4]=this.listeners("data").length,this[W4]===0&&!this[z0]&&!this[Z0].length)this[a]=!1}return J}removeAllListeners($){let Z=super.removeAllListeners($);if($==="data"||$===void 0){if(this[W4]=0,!this[z0]&&!this[Z0].length)this[a]=!1}return Z}get emittedEnd(){return this[e0]}[m0](){if(!this[B6]&&!this[e0]&&!this[c]&&this[r].length===0&&this[u0]){if(this[B6]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[L6])this.emit("close");this[B6]=!1}}emit($,...Z){let J=Z[0];if($!=="error"&&$!=="close"&&$!==c&&this[c])return!1;else if($==="data")return!this[o]&&!J?!1:this[F0]?(r4(()=>this[A2](J)),!0):this[A2](J);else if($==="end")return this[n5]();else if($==="close"){if(this[L6]=!0,!this[e0]&&!this[c])return!1;let X=super.emit("close");return this.removeAllListeners("close"),X}else if($==="error"){this[l4]=J,super.emit(U2,J);let X=!this[a4]||this.listeners("error").length?super.emit("error",J):!1;return this[m0](),X}else if($==="resume"){let X=super.emit("resume");return this[m0](),X}else if($==="finish"||$==="prefinish"){let X=super.emit($);return this.removeAllListeners($),X}let Q=super.emit($,...Z);return this[m0](),Q}[A2]($){for(let J of this[Z0])if(J.dest.write($)===!1)this.pause();let Z=this[z0]?!1:super.emit("data",$);return this[m0](),Z}[n5](){if(this[e0])return!1;return this[e0]=!0,this.readable=!1,this[F0]?(r4(()=>this[B2]()),!0):this[B2]()}[B2](){if(this[w4]){let Z=this[w4].end();if(Z){for(let J of this[Z0])J.dest.write(Z);if(!this[z0])super.emit("data",Z)}}for(let Z of this[Z0])Z.end();let $=super.emit("end");return this.removeAllListeners("end"),$}async collect(){let $=Object.assign([],{dataLength:0});if(!this[o])$.dataLength=0;let Z=this.promise();return this.on("data",(J)=>{if($.push(J),!this[o])$.dataLength+=J.length}),await Z,$}async concat(){if(this[o])throw Error("cannot concat in objectMode");let $=await this.collect();return this[R0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Z)=>{this.on(c,()=>Z(Error("stream destroyed"))),this.on("error",(J)=>Z(J)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[z0]=!1;let $=!1,Z=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Z();let Q=this.read();if(Q!==null)return Promise.resolve({done:!1,value:Q});if(this[u0])return Z();let X,V,K=(z)=>{this.off("data",W),this.off("end",H),this.off(c,q),Z(),V(z)},W=(z)=>{this.off("error",K),this.off("end",H),this.off(c,q),this.pause(),X({value:z,done:!!this[u0]})},H=()=>{this.off("error",K),this.off("data",W),this.off(c,q),Z(),X({done:!0,value:void 0})},q=()=>K(Error("stream destroyed"));return new Promise((z,G)=>{V=G,X=z,this.once(c,q),this.once("error",K),this.once("end",H),this.once("data",W)})},throw:Z,return:Z,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[z0]=!1;let $=!1,Z=()=>{return this.pause(),this.off(U2,Z),this.off(c,Z),this.off("end",Z),$=!0,{done:!0,value:void 0}},J=()=>{if($)return Z();let Q=this.read();return Q===null?Z():{done:!1,value:Q}};return this.once("end",Z),this.once(U2,Z),this.once(c,Z),{next:J,throw:Z,return:Z,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy($){if(this[c]){if($)this.emit("error",$);else this.emit(c);return this}this[c]=!0,this[z0]=!0,this[r].length=0,this[n]=0;let Z=this;if(typeof Z.close==="function"&&!this[L6])Z.close();if($)this.emit("error",$);else this.emit(c);return this}static get isStream(){return h8}}var ZZ=t8.native,i4={lstatSync:i8,readdir:s8,readdirSync:o8,readlinkSync:e8,realpathSync:ZZ,promises:{lstat:JZ,readdir:QZ,readlink:XZ,realpath:VZ}},Z1=($)=>!$||$===i4||$===$Z?i4:{...i4,...$,promises:{...i4.promises,...$.promises||{}}},J1=/^\\\\\?\\([a-z]:)\\?$/i,KZ=($)=>$.replace(/\//g,"\\").replace(J1,"$1\\"),WZ=/[\\\/]/,B0=0,Q1=1,X1=2,I0=4,V1=6,K1=8,q4=10,W1=12,A0=15,n4=~A0,R2=16,o5=32,s4=64,C0=128,C6=256,P6=512,e5=s4|C0|P6,HZ=1023,C2=($)=>$.isFile()?K1:$.isDirectory()?I0:$.isSymbolicLink()?q4:$.isCharacterDevice()?X1:$.isBlockDevice()?V1:$.isSocket()?W1:$.isFIFO()?Q1:B0,t5=new c4({max:4096}),o4=($)=>{let Z=t5.get($);if(Z)return Z;let J=$.normalize("NFKD");return t5.set($,J),J},$1=new c4({max:4096}),N6=($)=>{let Z=$1.get($);if(Z)return Z;let J=o4($.toLowerCase());return $1.set($,J),J};class P2 extends c4{constructor(){super({max:256})}}class H1 extends c4{constructor($=16384){super({maxSize:$,sizeCalculation:(Z)=>Z.length+1})}}var q1=Symbol("PathScurry setAsCwd");class J0{name;root;roots;parent;nocase;isCWD=!1;#$;#Q;get dev(){return this.#Q}#X;get mode(){return this.#X}#Z;get nlink(){return this.#Z}#K;get uid(){return this.#K}#P;get gid(){return this.#P}#_;get rdev(){return this.#_}#z;get blksize(){return this.#z}#W;get ino(){return this.#W}#G;get size(){return this.#G}#Y;get blocks(){return this.#Y}#H;get atimeMs(){return this.#H}#V;get mtimeMs(){return this.#V}#w;get ctimeMs(){return this.#w}#C;get birthtimeMs(){return this.#C}#U;get atime(){return this.#U}#A;get mtime(){return this.#A}#F;get ctime(){return this.#F}#B;get birthtime(){return this.#B}#N;#D;#j;#L;#R;#I;#J;#O;#x;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Z=B0,J,Q,X,V,K){if(this.name=$,this.#N=X?N6($):o4($),this.#J=Z&HZ,this.nocase=X,this.roots=Q,this.root=J||this,this.#O=V,this.#j=K.fullpath,this.#R=K.relative,this.#I=K.relativePosix,this.parent=K.parent,this.parent)this.#$=this.parent.#$;else this.#$=Z1(K.fs)}depth(){if(this.#D!==void 0)return this.#D;if(!this.parent)return this.#D=0;return this.#D=this.parent.depth()+1}childrenCache(){return this.#O}resolve($){if(!$)return this;let Z=this.getRootString($),Q=$.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#k(Q):this.#k(Q)}#k($){let Z=this;for(let J of $)Z=Z.child(J);return Z}children(){let $=this.#O.get(this);if($)return $;let Z=Object.assign([],{provisional:0});return this.#O.set(this,Z),this.#J&=~R2,Z}child($,Z){if($===""||$===".")return this;if($==="..")return this.parent||this;let J=this.children(),Q=this.nocase?N6($):o4($);for(let W of J)if(W.#N===Q)return W;let X=this.parent?this.sep:"",V=this.#j?this.#j+X+$:void 0,K=this.newChild($,B0,{...Z,parent:this,fullpath:V});if(!this.canReaddir())K.#J|=C0;return J.push(K),K}relative(){if(this.isCWD)return"";if(this.#R!==void 0)return this.#R;let $=this.name,Z=this.parent;if(!Z)return this.#R=this.name;let J=Z.relative();return J+(!J||!Z.parent?"":this.sep)+$}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#I!==void 0)return this.#I;let $=this.name,Z=this.parent;if(!Z)return this.#I=this.fullpathPosix();let J=Z.relativePosix();return J+(!J||!Z.parent?"":"/")+$}fullpath(){if(this.#j!==void 0)return this.#j;let $=this.name,Z=this.parent;if(!Z)return this.#j=this.name;let Q=Z.fullpath()+(!Z.parent?"":this.sep)+$;return this.#j=Q}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let Q=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(Q))return this.#L=`//?/${Q}`;else return this.#L=Q}let $=this.parent,Z=$.fullpathPosix(),J=Z+(!Z||!$.parent?"":"/")+this.name;return this.#L=J}isUnknown(){return(this.#J&A0)===B0}isType($){return this[`is${$}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#J&A0)===K1}isDirectory(){return(this.#J&A0)===I0}isCharacterDevice(){return(this.#J&A0)===X1}isBlockDevice(){return(this.#J&A0)===V1}isFIFO(){return(this.#J&A0)===Q1}isSocket(){return(this.#J&A0)===W1}isSymbolicLink(){return(this.#J&q4)===q4}lstatCached(){return this.#J&o5?this:void 0}readlinkCached(){return this.#x}realpathCached(){return this.#E}readdirCached(){let $=this.children();return $.slice(0,$.provisional)}canReadlink(){if(this.#x)return!0;if(!this.parent)return!1;let $=this.#J&A0;return!($!==B0&&$!==q4||this.#J&C6||this.#J&C0)}calledReaddir(){return!!(this.#J&R2)}isENOENT(){return!!(this.#J&C0)}isNamed($){return!this.nocase?this.#N===o4($):this.#N===N6($)}async readlink(){let $=this.#x;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#$.promises.readlink(this.fullpath()),J=(await this.parent.realpath())?.resolve(Z);if(J)return this.#x=J}catch(Z){this.#v(Z.code);return}}readlinkSync(){let $=this.#x;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#$.readlinkSync(this.fullpath()),J=this.parent.realpathSync()?.resolve(Z);if(J)return this.#x=J}catch(Z){this.#v(Z.code);return}}#h($){this.#J|=R2;for(let Z=$.provisional;Z<$.length;Z++){let J=$[Z];if(J)J.#M()}}#M(){if(this.#J&C0)return;this.#J=(this.#J|C0)&n4,this.#l()}#l(){let $=this.children();$.provisional=0;for(let Z of $)Z.#M()}#b(){this.#J|=P6,this.#y()}#y(){if(this.#J&s4)return;let $=this.#J;if(($&A0)===I0)$&=n4;this.#J=$|s4,this.#l()}#g($=""){if($==="ENOTDIR"||$==="EPERM")this.#y();else if($==="ENOENT")this.#M();else this.children().provisional=0}#T($=""){if($==="ENOTDIR")this.parent.#y();else if($==="ENOENT")this.#M()}#v($=""){let Z=this.#J;if(Z|=C6,$==="ENOENT")Z|=C0;if($==="EINVAL"||$==="UNKNOWN")Z&=n4;if(this.#J=Z,$==="ENOTDIR"&&this.parent)this.parent.#y()}#d($,Z){return this.#m($,Z)||this.#u($,Z)}#u($,Z){let J=C2($),Q=this.newChild($.name,J,{parent:this}),X=Q.#J&A0;if(X!==I0&&X!==q4&&X!==B0)Q.#J|=s4;return Z.unshift(Q),Z.provisional++,Q}#m($,Z){for(let J=Z.provisional;J<Z.length;J++){let Q=Z[J];if((this.nocase?N6($.name):o4($.name))!==Q.#N)continue;return this.#q($,Q,J,Z)}}#q($,Z,J,Q){let X=Z.name;if(Z.#J=Z.#J&n4|C2($),X!==$.name)Z.name=$.name;if(J!==Q.provisional){if(J===Q.length-1)Q.pop();else Q.splice(J,1);Q.unshift(Z)}return Q.provisional++,Z}async lstat(){if((this.#J&C0)===0)try{return this.#c(await this.#$.promises.lstat(this.fullpath())),this}catch($){this.#T($.code)}}lstatSync(){if((this.#J&C0)===0)try{return this.#c(this.#$.lstatSync(this.fullpath())),this}catch($){this.#T($.code)}}#c($){let{atime:Z,atimeMs:J,birthtime:Q,birthtimeMs:X,blksize:V,blocks:K,ctime:W,ctimeMs:H,dev:q,gid:z,ino:G,mode:U,mtime:L,mtimeMs:B,nlink:_,rdev:R,size:w,uid:D}=$;this.#U=Z,this.#H=J,this.#B=Q,this.#C=X,this.#z=V,this.#Y=K,this.#F=W,this.#w=H,this.#Q=q,this.#P=z,this.#W=G,this.#X=U,this.#A=L,this.#V=B,this.#Z=_,this.#_=R,this.#G=w,this.#K=D;let I=C2($);if(this.#J=this.#J&n4|I|o5,I!==B0&&I!==I0&&I!==q4)this.#J|=s4}#f=[];#S=!1;#p($){this.#S=!1;let Z=this.#f.slice();this.#f.length=0,Z.forEach((J)=>J(null,$))}readdirCB($,Z=!1){if(!this.canReaddir()){if(Z)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let J=this.children();if(this.calledReaddir()){let X=J.slice(0,J.provisional);if(Z)$(null,X);else queueMicrotask(()=>$(null,X));return}if(this.#f.push($),this.#S)return;this.#S=!0;let Q=this.fullpath();this.#$.readdir(Q,{withFileTypes:!0},(X,V)=>{if(X)this.#g(X.code),J.provisional=0;else{for(let K of V)this.#d(K,J);this.#h(J)}this.#p(J.slice(0,J.provisional));return})}#a;async readdir(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Z=this.fullpath();if(this.#a)await this.#a;else{let J=()=>{};this.#a=new Promise((Q)=>J=Q);try{for(let Q of await this.#$.promises.readdir(Z,{withFileTypes:!0}))this.#d(Q,$);this.#h($)}catch(Q){this.#g(Q.code),$.provisional=0}this.#a=void 0,J()}return $.slice(0,$.provisional)}readdirSync(){if(!this.canReaddir())return[];let $=this.children();if(this.calledReaddir())return $.slice(0,$.provisional);let Z=this.fullpath();try{for(let J of this.#$.readdirSync(Z,{withFileTypes:!0}))this.#d(J,$);this.#h($)}catch(J){this.#g(J.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#J&e5)return!1;let $=A0&this.#J;if(!($===B0||$===I0||$===q4))return!1;return!0}shouldWalk($,Z){return(this.#J&I0)===I0&&!(this.#J&e5)&&!$.has(this)&&(!Z||Z(this))}async realpath(){if(this.#E)return this.#E;if((P6|C6|C0)&this.#J)return;try{let $=await this.#$.promises.realpath(this.fullpath());return this.#E=this.resolve($)}catch($){this.#b()}}realpathSync(){if(this.#E)return this.#E;if((P6|C6|C0)&this.#J)return;try{let $=this.#$.realpathSync(this.fullpath());return this.#E=this.resolve($)}catch($){this.#b()}}[q1]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Z=new Set([]),J=[],Q=this;while(Q&&Q.parent)Z.add(Q),Q.#R=J.join(this.sep),Q.#I=J.join("/"),Q=Q.parent,J.push("..");Q=$;while(Q&&Q.parent&&!Z.has(Q))Q.#R=void 0,Q.#I=void 0,Q=Q.parent}}class D6 extends J0{sep="\\";splitSep=WZ;constructor($,Z=B0,J,Q,X,V,K){super($,Z,J,Q,X,V,K)}newChild($,Z=B0,J={}){return new D6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),J)}getRootString($){return N2.parse($).root}getRoot($){if($=KZ($.toUpperCase()),$===this.root.name)return this.root;for(let[Z,J]of Object.entries(this.roots))if(this.sameRoot($,Z))return this.roots[$]=J;return this.roots[$]=new e4($,this).root}sameRoot($,Z=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace(J1,"$1\\"),$===Z}}class M6 extends J0{splitSep="/";sep="/";constructor($,Z=B0,J,Q,X,V,K){super($,Z,J,Q,X,V,K)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Z=B0,J={}){return new M6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),J)}}class D2{root;rootPath;roots;cwd;#$;#Q;#X;nocase;#Z;constructor($=process.cwd(),Z,J,{nocase:Q,childrenCacheSize:X=16384,fs:V=i4}={}){if(this.#Z=Z1(V),$ instanceof URL||$.startsWith("file://"))$=n8($);let K=Z.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#$=new P2,this.#Q=new P2,this.#X=new H1(X);let W=K.substring(this.rootPath.length).split(J);if(W.length===1&&!W[0])W.pop();if(Q===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=Q,this.root=this.newRoot(this.#Z),this.roots[this.rootPath]=this.root;let H=this.root,q=W.length-1,z=Z.sep,G=this.rootPath,U=!1;for(let L of W){let B=q--;H=H.child(L,{relative:Array(B).fill("..").join(z),relativePosix:Array(B).fill("..").join("/"),fullpath:G+=(U?"":z)+L}),U=!0}this.cwd=H}depth($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.depth()}childrenCache(){return this.#X}resolve(...$){let Z="";for(let X=$.length-1;X>=0;X--){let V=$[X];if(!V||V===".")continue;if(Z=Z?`${V}/${Z}`:V,this.isAbsolute(V))break}let J=this.#$.get(Z);if(J!==void 0)return J;let Q=this.cwd.resolve(Z).fullpath();return this.#$.set(Z,Q),Q}resolvePosix(...$){let Z="";for(let X=$.length-1;X>=0;X--){let V=$[X];if(!V||V===".")continue;if(Z=Z?`${V}/${Z}`:V,this.isAbsolute(V))break}let J=this.#Q.get(Z);if(J!==void 0)return J;let Q=this.cwd.resolve(Z).fullpathPosix();return this.#Q.set(Z,Q),Q}relative($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relative()}relativePosix($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.relativePosix()}basename($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.name}dirname($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return($.parent||$).fullpath()}async readdir($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J}=Z;if(!$.canReaddir())return[];else{let Q=await $.readdir();return J?Q:Q.map((X)=>X.name)}}readdirSync($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J=!0}=Z;if(!$.canReaddir())return[];else if(J)return $.readdirSync();else return $.readdirSync().map((Q)=>Q.name)}async lstat($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstat()}lstatSync($=this.cwd){if(typeof $==="string")$=this.cwd.resolve($);return $.lstatSync()}async readlink($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$.withFileTypes,$=this.cwd;let J=await $.readlink();return Z?J:J?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$.withFileTypes,$=this.cwd;let J=$.readlinkSync();return Z?J:J?.fullpath()}async realpath($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$.withFileTypes,$=this.cwd;let J=await $.realpath();return Z?J:J?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$.withFileTypes,$=this.cwd;let J=$.realpathSync();return Z?J:J?.fullpath()}async walk($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(J?$:$.fullpath());let W=new Set,H=(z,G)=>{W.add(z),z.readdirCB((U,L)=>{if(U)return G(U);let B=L.length;if(!B)return G();let _=()=>{if(--B===0)G()};for(let R of L){if(!X||X(R))K.push(J?R:R.fullpath());if(Q&&R.isSymbolicLink())R.realpath().then((w)=>w?.isUnknown()?w.lstat():w).then((w)=>w?.shouldWalk(W,V)?H(w,_):_());else if(R.shouldWalk(W,V))H(R,_);else _()}},!0)},q=$;return new Promise((z,G)=>{H(q,(U)=>{if(U)return G(U);z(K)})})}walkSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(J?$:$.fullpath());let W=new Set([$]);for(let H of W){let q=H.readdirSync();for(let z of q){if(!X||X(z))K.push(J?z:z.fullpath());let G=z;if(z.isSymbolicLink()){if(!(Q&&(G=z.realpathSync())))continue;if(G.isUnknown())G.lstatSync()}if(G.shouldWalk(W,V))W.add(G)}}return K}[Symbol.asyncIterator](){return this.iterate()}iterate($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;return this.stream($,Z)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z;if(!X||X($))yield J?$:$.fullpath();let K=new Set([$]);for(let W of K){let H=W.readdirSync();for(let q of H){if(!X||X(q))yield J?q:q.fullpath();let z=q;if(q.isSymbolicLink()){if(!(Q&&(z=q.realpathSync())))continue;if(z.isUnknown())z.lstatSync()}if(z.shouldWalk(K,V))K.add(z)}}}stream($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=new H4({objectMode:!0});if(!X||X($))K.write(J?$:$.fullpath());let W=new Set,H=[$],q=0,z=()=>{let G=!1;while(!G){let U=H.shift();if(!U){if(q===0)K.end();return}q++,W.add(U);let L=(_,R,w=!1)=>{if(_)return K.emit("error",_);if(Q&&!w){let D=[];for(let I of R)if(I.isSymbolicLink())D.push(I.realpath().then((S)=>S?.isUnknown()?S.lstat():S));if(D.length){Promise.all(D).then(()=>L(null,R,!0));return}}for(let D of R)if(D&&(!X||X(D))){if(!K.write(J?D:D.fullpath()))G=!0}q--;for(let D of R){let I=D.realpathCached()||D;if(I.shouldWalk(W,V))H.push(I)}if(G&&!K.flowing)K.once("drain",z);else if(!B)z()},B=!0;U.readdirCB(L,!0),B=!1}};return z(),K}streamSync($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof J0))Z=$,$=this.cwd;let{withFileTypes:J=!0,follow:Q=!1,filter:X,walkFilter:V}=Z,K=new H4({objectMode:!0}),W=new Set;if(!X||X($))K.write(J?$:$.fullpath());let H=[$],q=0,z=()=>{let G=!1;while(!G){let U=H.shift();if(!U){if(q===0)K.end();return}q++,W.add(U);let L=U.readdirSync();for(let B of L)if(!X||X(B)){if(!K.write(J?B:B.fullpath()))G=!0}q--;for(let B of L){let _=B;if(B.isSymbolicLink()){if(!(Q&&(_=B.realpathSync())))continue;if(_.isUnknown())_.lstatSync()}if(_.shouldWalk(W,V))H.push(_)}}if(G&&!K.flowing)K.once("drain",z)};return z(),K}chdir($=this.cwd){let Z=this.cwd;this.cwd=typeof $==="string"?this.cwd.resolve($):$,this.cwd[q1](Z)}}class e4 extends D2{sep="\\";constructor($=process.cwd(),Z={}){let{nocase:J=!0}=Z;super($,N2,"\\",{...Z,nocase:J});this.nocase=J;for(let Q=this.cwd;Q;Q=Q.parent)Q.nocase=this.nocase}parseRootPath($){return N2.parse($).root.toUpperCase()}newRoot($){return new D6(this.rootPath,I0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class t4 extends D2{sep="/";constructor($=process.cwd(),Z={}){let{nocase:J=!1}=Z;super($,r8,"/",{...Z,nocase:J});this.nocase=J}parseRootPath($){return"/"}newRoot($){return new M6(this.rootPath,I0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class F6 extends t4{constructor($=process.cwd(),Z={}){let{nocase:J=!0}=Z;super($,{...Z,nocase:J})}}var KW=process.platform==="win32"?D6:M6,Y1=process.platform==="win32"?e4:process.platform==="darwin"?F6:t4;var qZ=($)=>$.length>=1,YZ=($)=>$.length>=1;class C4{#$;#Q;#X;length;#Z;#K;#P;#_;#z;#W;#G=!0;constructor($,Z,J,Q){if(!qZ($))throw TypeError("empty pattern list");if(!YZ(Z))throw TypeError("empty glob list");if(Z.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,J<0||J>=this.length)throw TypeError("index out of range");if(this.#$=$,this.#Q=Z,this.#X=J,this.#Z=Q,this.#X===0){if(this.isUNC()){let[X,V,K,W,...H]=this.#$,[q,z,G,U,...L]=this.#Q;if(H[0]==="")H.shift(),L.shift();let B=[X,V,K,W,""].join("/"),_=[q,z,G,U,""].join("/");this.#$=[B,...H],this.#Q=[_,...L],this.length=this.#$.length}else if(this.isDrive()||this.isAbsolute()){let[X,...V]=this.#$,[K,...W]=this.#Q;if(V[0]==="")V.shift(),W.shift();let H=X+"/",q=K+"/";this.#$=[H,...V],this.#Q=[q,...W],this.length=this.#$.length}}}pattern(){return this.#$[this.#X]}isString(){return typeof this.#$[this.#X]==="string"}isGlobstar(){return this.#$[this.#X]===m}isRegExp(){return this.#$[this.#X]instanceof RegExp}globString(){return this.#P=this.#P||(this.#X===0?this.isAbsolute()?this.#Q[0]+this.#Q.slice(1).join("/"):this.#Q.join("/"):this.#Q.slice(this.#X).join("/"))}hasMore(){return this.length>this.#X+1}rest(){if(this.#K!==void 0)return this.#K;if(!this.hasMore())return this.#K=null;return this.#K=new C4(this.#$,this.#Q,this.#X+1,this.#Z),this.#K.#W=this.#W,this.#K.#z=this.#z,this.#K.#_=this.#_,this.#K}isUNC(){let $=this.#$;return this.#z!==void 0?this.#z:this.#z=this.#Z==="win32"&&this.#X===0&&$[0]===""&&$[1]===""&&typeof $[2]==="string"&&!!$[2]&&typeof $[3]==="string"&&!!$[3]}isDrive(){let $=this.#$;return this.#_!==void 0?this.#_:this.#_=this.#Z==="win32"&&this.#X===0&&this.length>1&&typeof $[0]==="string"&&/^[a-z]:$/i.test($[0])}isAbsolute(){let $=this.#$;return this.#W!==void 0?this.#W:this.#W=$[0]===""&&$.length>1||this.isDrive()||this.isUNC()}root(){let $=this.#$[0];return typeof $==="string"&&this.isAbsolute()&&this.#X===0?$:""}checkFollowGlobstar(){return!(this.#X===0||!this.isGlobstar()||!this.#G)}markFollowGlobstar(){if(this.#X===0||!this.isGlobstar()||!this.#G)return!1;return this.#G=!1,!0}}var zZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class $6{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Z,nocase:J,noext:Q,noglobstar:X,platform:V=zZ}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:Z,nocase:J,noext:Q,noglobstar:X,optimizationLevel:2,platform:V,nocomment:!0,nonegate:!0};for(let K of $)this.add(K)}add($){let Z=new U0($,this.mmopts);for(let J=0;J<Z.set.length;J++){let Q=Z.set[J],X=Z.globParts[J];if(!Q||!X)throw Error("invalid pattern object");while(Q[0]==="."&&X[0]===".")Q.shift(),X.shift();let V=new C4(Q,X,0,this.platform),K=new U0(V.globString(),this.mmopts),W=X[X.length-1]==="**",H=V.isAbsolute();if(H)this.absolute.push(K);else this.relative.push(K);if(W)if(H)this.absoluteChildren.push(K);else this.relativeChildren.push(K)}}ignored($){let Z=$.fullpath(),J=`${Z}/`,Q=$.relative()||".",X=`${Q}/`;for(let V of this.relative)if(V.match(Q)||V.match(X))return!0;for(let V of this.absolute)if(V.match(Z)||V.match(J))return!0;return!1}childrenIgnored($){let Z=$.fullpath()+"/",J=($.relative()||".")+"/";for(let Q of this.relativeChildren)if(Q.match(J))return!0;for(let Q of this.absoluteChildren)if(Q.match(Z))return!0;return!1}}class M2{store;constructor($=new Map){this.store=$}copy(){return new M2(new Map(this.store))}hasWalked($,Z){return this.store.get($.fullpath())?.has(Z.globString())}storeWalked($,Z){let J=$.fullpath(),Q=this.store.get(J);if(Q)Q.add(Z.globString());else this.store.set(J,new Set([Z.globString()]))}}class z1{store=new Map;add($,Z,J){let Q=(Z?2:0)|(J?1:0),X=this.store.get($);this.store.set($,X===void 0?Q:Q&X)}entries(){return[...this.store.entries()].map(([$,Z])=>[$,!!(Z&2),!!(Z&1)])}}class G1{store=new Map;add($,Z){if(!$.canReaddir())return;let J=this.store.get($);if(J){if(!J.find((Q)=>Q.globString()===Z.globString()))J.push(Z)}else this.store.set($,[Z])}get($){let Z=this.store.get($);if(!Z)throw Error("attempting to walk unknown path");return Z}entries(){return this.keys().map(($)=>[$,this.store.get($)])}keys(){return[...this.store.keys()].filter(($)=>$.canReaddir())}}class Z6{hasWalkedCache;matches=new z1;subwalks=new G1;patterns;follow;dot;opts;constructor($,Z){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Z?Z.copy():new M2}processPatterns($,Z){this.patterns=Z;let J=Z.map((Q)=>[$,Q]);for(let[Q,X]of J){this.hasWalkedCache.storeWalked(Q,X);let V=X.root(),K=X.isAbsolute()&&this.opts.absolute!==!1;if(V){Q=Q.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let z=X.rest();if(!z){this.matches.add(Q,!0,!1);continue}else X=z}if(Q.isENOENT())continue;let W,H,q=!1;while(typeof(W=X.pattern())==="string"&&(H=X.rest()))Q=Q.resolve(W),X=H,q=!0;if(W=X.pattern(),H=X.rest(),q){if(this.hasWalkedCache.hasWalked(Q,X))continue;this.hasWalkedCache.storeWalked(Q,X)}if(typeof W==="string"){let z=W===".."||W===""||W===".";this.matches.add(Q.resolve(W),K,z);continue}else if(W===m){if(!Q.isSymbolicLink()||this.follow||X.checkFollowGlobstar())this.subwalks.add(Q,X);let z=H?.pattern(),G=H?.rest();if(!H||(z===""||z===".")&&!G)this.matches.add(Q,K,z===""||z===".");else if(z===".."){let U=Q.parent||Q;if(!G)this.matches.add(U,K,!0);else if(!this.hasWalkedCache.hasWalked(U,G))this.subwalks.add(U,G)}}else if(W instanceof RegExp)this.subwalks.add(Q,X)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new Z6(this.opts,this.hasWalkedCache)}filterEntries($,Z){let J=this.subwalks.get($),Q=this.child();for(let X of Z)for(let V of J){let K=V.isAbsolute(),W=V.pattern(),H=V.rest();if(W===m)Q.testGlobstar(X,V,H,K);else if(W instanceof RegExp)Q.testRegExp(X,W,H,K);else Q.testString(X,W,H,K)}return Q}testGlobstar($,Z,J,Q){if(this.dot||!$.name.startsWith(".")){if(!Z.hasMore())this.matches.add($,Q,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Z);else if($.isSymbolicLink()){if(J&&Z.checkFollowGlobstar())this.subwalks.add($,J);else if(Z.markFollowGlobstar())this.subwalks.add($,Z)}}}if(J){let X=J.pattern();if(typeof X==="string"&&X!==".."&&X!==""&&X!==".")this.testString($,X,J.rest(),Q);else if(X===".."){let V=$.parent||$;this.subwalks.add(V,J)}else if(X instanceof RegExp)this.testRegExp($,X,J.rest(),Q)}}testRegExp($,Z,J,Q){if(!Z.test($.name))return;if(!J)this.matches.add($,Q,!1);else this.subwalks.add($,J)}testString($,Z,J,Q){if(!$.isNamed(Z))return;if(!J)this.matches.add($,Q,!1);else this.subwalks.add($,J)}}var GZ=($,Z)=>typeof $==="string"?new $6([$],Z):Array.isArray($)?new $6($,Z):$;class F2{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#$=[];#Q;#X;signal;maxDepth;includeChildMatches;constructor($,Z,J){if(this.patterns=$,this.path=Z,this.opts=J,this.#X=!J.posix&&J.platform==="win32"?"\\":"/",this.includeChildMatches=J.includeChildMatches!==!1,J.ignore||!this.includeChildMatches){if(this.#Q=GZ(J.ignore??[],J),!this.includeChildMatches&&typeof this.#Q.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=J.maxDepth||1/0,J.signal)this.signal=J.signal,this.signal.addEventListener("abort",()=>{this.#$.length=0})}#Z($){return this.seen.has($)||!!this.#Q?.ignored?.($)}#K($){return!!this.#Q?.childrenIgnored?.($)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let $=void 0;while(!this.paused&&($=this.#$.shift()))$()}onResume($){if(this.signal?.aborted)return;if(!this.paused)$();else this.#$.push($)}async matchCheck($,Z){if(Z&&this.opts.nodir)return;let J;if(this.opts.realpath){if(J=$.realpathCached()||await $.realpath(),!J)return;$=J}let X=$.isUnknown()||this.opts.stat?await $.lstat():$;if(this.opts.follow&&this.opts.nodir&&X?.isSymbolicLink()){let V=await X.realpath();if(V&&(V.isUnknown()||this.opts.stat))await V.lstat()}return this.matchCheckTest(X,Z)}matchCheckTest($,Z){return $&&(this.maxDepth===1/0||$.depth()<=this.maxDepth)&&(!Z||$.canReaddir())&&(!this.opts.nodir||!$.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!$.isSymbolicLink()||!$.realpathCached()?.isDirectory())&&!this.#Z($)?$:void 0}matchCheckSync($,Z){if(Z&&this.opts.nodir)return;let J;if(this.opts.realpath){if(J=$.realpathCached()||$.realpathSync(),!J)return;$=J}let X=$.isUnknown()||this.opts.stat?$.lstatSync():$;if(this.opts.follow&&this.opts.nodir&&X?.isSymbolicLink()){let V=X.realpathSync();if(V&&(V?.isUnknown()||this.opts.stat))V.lstatSync()}return this.matchCheckTest(X,Z)}matchFinish($,Z){if(this.#Z($))return;if(!this.includeChildMatches&&this.#Q?.add){let X=`${$.relativePosix()}/**`;this.#Q.add(X)}let J=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add($);let Q=this.opts.mark&&$.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit($);else if(J){let X=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(X+Q)}else{let X=this.opts.posix?$.relativePosix():$.relative(),V=this.opts.dotRelative&&!X.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!X?"."+Q:V+X+Q)}}async match($,Z,J){let Q=await this.matchCheck($,J);if(Q)this.matchFinish(Q,Z)}matchSync($,Z,J){let Q=this.matchCheckSync($,J);if(Q)this.matchFinish(Q,Z)}walkCB($,Z,J){if(this.signal?.aborted)J();this.walkCB2($,Z,new Z6(this.opts),J)}walkCB2($,Z,J,Q){if(this.#K($))return Q();if(this.signal?.aborted)Q();if(this.paused){this.onResume(()=>this.walkCB2($,Z,J,Q));return}J.processPatterns($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,W,H]of J.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,W,H).then(()=>V())}for(let K of J.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,J,V);else K.readdirCB((H,q)=>this.walkCB3(K,q,J,V),!0)}V()}walkCB3($,Z,J,Q){J=J.filterEntries($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,W,H]of J.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,W,H).then(()=>V())}for(let[K,W]of J.subwalks.entries())X++,this.walkCB2(K,W,J.child(),V);V()}walkCBSync($,Z,J){if(this.signal?.aborted)J();this.walkCB2Sync($,Z,new Z6(this.opts),J)}walkCB2Sync($,Z,J,Q){if(this.#K($))return Q();if(this.signal?.aborted)Q();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Z,J,Q));return}J.processPatterns($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,W,H]of J.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,W,H)}for(let K of J.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let W=K.readdirSync();this.walkCB3Sync(K,W,J,V)}V()}walkCB3Sync($,Z,J,Q){J=J.filterEntries($,Z);let X=1,V=()=>{if(--X===0)Q()};for(let[K,W,H]of J.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,W,H)}for(let[K,W]of J.subwalks.entries())X++,this.walkCB2Sync(K,W,J.child(),V);V()}}class I6 extends F2{matches=new Set;constructor($,Z,J){super($,Z,J)}matchEmit($){this.matches.add($)}async walk(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())await this.path.lstat();return await new Promise(($,Z)=>{this.walkCB(this.path,this.patterns,()=>{if(this.signal?.aborted)Z(this.signal.reason);else $(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}}class E6 extends F2{results;constructor($,Z,J){super($,Z,J);this.results=new H4({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit($){if(this.results.write($),!this.results.flowing)this.pause()}stream(){let $=this.path;if($.isUnknown())$.lstat().then(()=>{this.walkCB($,this.patterns,()=>this.results.end())});else this.walkCB($,this.patterns,()=>this.results.end());return this.results}streamSync(){if(this.path.isUnknown())this.path.lstatSync();return this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}}var UZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class E0{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor($,Z){if(!Z)throw TypeError("glob options required");if(this.withFileTypes=!!Z.withFileTypes,this.signal=Z.signal,this.follow=!!Z.follow,this.dot=!!Z.dot,this.dotRelative=!!Z.dotRelative,this.nodir=!!Z.nodir,this.mark=!!Z.mark,!Z.cwd)this.cwd="";else if(Z.cwd instanceof URL||Z.cwd.startsWith("file://"))Z.cwd=jZ(Z.cwd);if(this.cwd=Z.cwd||"",this.root=Z.root,this.magicalBraces=!!Z.magicalBraces,this.nobrace=!!Z.nobrace,this.noext=!!Z.noext,this.realpath=!!Z.realpath,this.absolute=Z.absolute,this.includeChildMatches=Z.includeChildMatches!==!1,this.noglobstar=!!Z.noglobstar,this.matchBase=!!Z.matchBase,this.maxDepth=typeof Z.maxDepth==="number"?Z.maxDepth:1/0,this.stat=!!Z.stat,this.ignore=Z.ignore,this.withFileTypes&&this.absolute!==void 0)throw Error("cannot set absolute and withFileTypes:true");if(typeof $==="string")$=[$];if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z.allowWindowsEscape===!1,this.windowsPathsNoEscape)$=$.map((W)=>W.replace(/\\/g,"/"));if(this.matchBase){if(Z.noglobstar)throw TypeError("base matching requires globstar");$=$.map((W)=>W.includes("/")?W:`./**/${W}`)}if(this.pattern=$,this.platform=Z.platform||UZ,this.opts={...Z,platform:this.platform},Z.scurry){if(this.scurry=Z.scurry,Z.nocase!==void 0&&Z.nocase!==Z.scurry.nocase)throw Error("nocase option contradicts provided scurry option")}else{let W=Z.platform==="win32"?e4:Z.platform==="darwin"?F6:Z.platform?t4:Y1;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let J=this.platform==="darwin"||this.platform==="win32",Q={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:J,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},X=this.pattern.map((W)=>new U0(W,Q)),[V,K]=X.reduce((W,H)=>{return W[0].push(...H.set),W[1].push(...H.globParts),W},[[],[]]);this.patterns=V.map((W,H)=>{let q=K[H];if(!q)throw Error("invalid pattern object");return new C4(W,q,0,this.platform)})}async walk(){return[...await new I6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new I6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new E6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new E6(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var I2=($,Z={})=>{if(!Array.isArray($))$=[$];for(let J of $)if(new U0(J,Z).hasMagic())return!0;return!1};function T6($,Z={}){return new E0($,Z).streamSync()}function U1($,Z={}){return new E0($,Z).stream()}function A1($,Z={}){return new E0($,Z).walkSync()}async function j1($,Z={}){return new E0($,Z).walk()}function v6($,Z={}){return new E0($,Z).iterateSync()}function B1($,Z={}){return new E0($,Z).iterate()}var AZ=T6,BZ=Object.assign(U1,{sync:T6}),LZ=v6,_Z=Object.assign(B1,{sync:v6}),wZ=Object.assign(A1,{stream:T6,iterate:v6}),S6=Object.assign(j1,{glob:j1,globSync:A1,sync:wZ,globStream:U1,stream:BZ,globStreamSync:T6,streamSync:AZ,globIterate:B1,iterate:_Z,globIterateSync:v6,iterateSync:LZ,Glob:E0,hasMagic:I2,escape:_4,unescape:w0});S6.glob=S6;var Q4=X5(y9(),1),yX=new Set(["png","jpg","jpeg","gif","webp"]),fX=new Set(["mp3","wav","flac","ogg","aac","m4a","wma","aiff","opus","mp4","avi","mov","wmv","flv","mkv","webm","m4v","mpeg","mpg","zip","rar","tar","gz","bz2","7z","xz","z","tgz","iso","exe","dll","so","dylib","app","msi","deb","rpm","bin","dat","db","sqlite","sqlite3","mdb","idx","doc","docx","xls","xlsx","ppt","pptx","odt","ods","odp","ttf","otf","woff","woff2","eot","psd","ai","eps","sketch","fig","xd","blend","obj","3ds","max","class","jar","war","pyc","pyo","rlib","swf","fla"]),bX=25000,hX=5242880,f9=3932160,b9=400,gX=20,dX=[{signature:[137,80,78,71],mimeType:"image/png"},{signature:[255,216,255],mimeType:"image/jpeg"},{signature:[71,73,70,56],mimeType:"image/gif"},{signature:[82,73,70,70],mimeType:"image/webp"}];function uX($){if($.length<4)return null;for(let{signature:Z,mimeType:J}of dX){let Q=!0;for(let X=0;X<Z.length;X++)if($[X]!==Z[X]){Q=!1;break}if(Q){if(J==="image/webp"){if($.length>=12&&$[8]===87&&$[9]===69&&$[10]===66&&$[11]===80)return"image/webp";continue}return J}}return null}async function h9($,Z=bX,J){let Q=Bun.file($),X=Buffer.from(await Q.arrayBuffer());if(X.length===0)throw Error(`Image file is empty: ${$}`);if(X.length>hX)throw Error(`Image file too large: ${$} (${(X.length/1024/1024).toFixed(2)}MB > 5MB limit)`);if(!uX(X))throw Error(`Unsupported image format: ${$}`);let K=Q4.default(X),W=await K.metadata(),H={originalWidth:W.width,originalHeight:W.height},q=(W.width||0)*(W.height||0);if(q>f9){let _=Math.sqrt(f9/q),R=Math.round((W.width||1)*_),w=Math.round((W.height||1)*_);K=Q4.default(X).resize(R,w,{fit:"inside",withoutEnlargement:!0})}let z=W.format||"jpeg",G;if(z==="png")G=await K.png().toBuffer();else if(z==="webp")G=await K.webp().toBuffer();else if(z==="gif")G=await K.gif().toBuffer();else G=await K.jpeg({quality:85}).toBuffer(),z="jpeg";let U=G.toString("base64");if(Math.ceil(U.length*0.125)>Z)try{let _=await mX(X,Z),R=_.toString("base64"),w=await Q4.default(_).metadata();return{type:"image",base64:R,mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:W.width,originalHeight:W.height,displayWidth:w.width,displayHeight:w.height}}}catch(_){let R=await Q4.default(X).resize(b9,b9,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:gX}).toBuffer(),w=await Q4.default(R).metadata();return{type:"image",base64:R.toString("base64"),mediaType:"image/jpeg",originalSize:X.length,dimensions:{originalWidth:W.width,originalHeight:W.height,displayWidth:w.width,displayHeight:w.height}}}return{type:"image",base64:U,mediaType:z==="jpeg"?"image/jpeg":z==="png"?"image/png":z==="gif"?"image/gif":z==="webp"?"image/webp":"image/jpeg",originalSize:X.length,dimensions:{originalWidth:W.width,originalHeight:W.height,displayWidth:W.width,displayHeight:W.height}}}async function mX($,Z){let J=Math.floor(Z*0.8/0.125),Q=Math.floor(J*0.75),V=await Q4.default($).metadata(),K=$.length;if(K<=Q)return $;let W=Math.sqrt(Q/K),H=Math.round((V.width||1)*W),q=Math.round((V.height||1)*W);return Q4.default($).resize(H,q,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:70}).toBuffer()}function g9($){let Z=$.toLowerCase().replace(/^\./,"");return yX.has(Z)}function d9($){let Z=$.toLowerCase().replace(/^\./,"");return fX.has(Z)}function u9($){return{type:"image",source:{type:"base64",data:$.base64,media_type:$.mediaType}}}function m9($){let Z=$.dimensions,J=Z?.originalWidth&&Z?.originalHeight?` (${Z.originalWidth}x${Z.originalHeight}${Z.displayWidth!==Z.originalWidth?` \u2192 ${Z.displayWidth}x${Z.displayHeight}`:""})`:"";return`[Image: ${$.mediaType}${J}, ${($.originalSize/1024).toFixed(1)}KB original]`}import*as i6 from"path";var cX={name:"Read",description:`Reads a file from the local filesystem. You can access any file directly by using this tool.
94
-
95
- Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid.
96
-
97
- This tool allows Claude Code to read images (PNG, JPG, JPEG, GIF, WEBP) and PDF files.
98
-
99
- Usage:
100
- - The file_path parameter must be an absolute path, not a relative path
101
- - By default, reads up to 2000 lines starting from the beginning of the file
102
- - You can optionally specify line offset and limit (especially handy for long files)
103
- - Any lines longer than 2000 characters will be truncated
104
- - Results are returned using cat -n format, with line numbers starting at 1
105
-
106
- This tool can read images (PNG, JPG, JPEG, GIF, WEBP). When reading images, the tool displays them visually.
107
-
108
- For PDF files:
109
- - Get the pages parameter to read specific page ranges (e.g., pages: "1-5")
110
- - Maximum 20 pages per request
111
- - For large PDFs (more than 10 pages), you MUST provide the pages parameter to read specific page ranges.
112
-
113
- Try to read the whole file by default, but for particularly large files, you should consider reading the file in chunks.
114
-
115
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`,input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to read"},offset:{type:"number",description:"The line number to start reading from (1-based)"},limit:{type:"number",description:"The number of lines to read"},pages:{type:"string",description:'Page range for PDF files (e.g., "1-5")'}},required:["file_path"]},handler:async($,Z)=>{let J=$.file_path,Q=$.offset||1,X=$.limit||2000;try{let V=i6.extname(J).toLowerCase().slice(1);if(g9(V))return await lX(J,Z.abortSignal);if(d9(V))return{content:`Binary file detected: ${J}
116
- This file type (${V}) is not supported for text reading.`,is_error:!0};let K=Bun.file(J);if(!await K.exists())return{content:`Error: File not found: ${J}`,is_error:!0};let H=(await K.text()).split(`
117
- `),q=Math.max(0,Q-1),z=Math.min(H.length,q+X),G=H.slice(q,z),U=z<H.length,B=G.map((_,R)=>`${q+R+1} ${_}`).join(`
118
- `);if(U)B+=`
119
-
120
- > WARNING: ${J} is ${H.length} lines (limit: ${X}). Only the first ${X} lines were loaded.`;return{content:B}}catch(V){return{content:`Error reading file: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}};async function lX($,Z){try{let J=await h9($,25000,Z),Q=u9(J);return{content:`${m9(J)}
121
-
122
- Note: Image content was read but cannot be displayed through this API proxy. When using native Anthropic API, the image would be included for visual analysis.`}}catch(J){return{content:`Error reading image: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}var pX={name:"Write",description:"Writes a file to the local filesystem. This tool will overwrite the existing file if there is one at the provided path.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to write"},content:{type:"string",description:"The content to write to the file"}},required:["file_path","content"]},handler:async($,Z)=>{let{file_path:J,content:Q}=$;try{return await Bun.write(J,Q),{content:`Successfully wrote to ${J}`}}catch(X){return{content:`Error writing file: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},aX={name:"Edit",description:"Performs exact string replacements in files. Use this tool to modify existing files.",input_schema:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to modify"},old_string:{type:"string",description:"The text to replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default false)"}},required:["file_path","old_string","new_string"]},handler:async($,Z)=>{let{file_path:J,old_string:Q,new_string:X}=$,V=$.replace_all||!1;try{let W=await Bun.file(J).text();if(V){let H=W;W=W.split(Q).join(X);let q=(H.match(new RegExp(rX(Q),"g"))||[]).length;if(q===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(J,W),{content:`Successfully replaced ${q} occurrences`}}else{let H=W.indexOf(Q);if(H===-1)return{content:"Error: String not found in file",is_error:!0};if(W.indexOf(Q,H+1)!==-1)return{content:"Error: String appears multiple times in file. Use replace_all or provide more context.",is_error:!0};return W=W.replace(Q,X),await Bun.write(J,W),{content:`Successfully edited ${J}`}}}catch(K){return{content:`Error editing file: ${K instanceof Error?K.message:String(K)}`,is_error:!0}}}};function rX($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var nX={name:"Bash",description:"Executes a given bash command with optional timeout. Working directory persists between commands.",input_schema:{type:"object",properties:{command:{type:"string",description:"The command to execute"},timeout:{type:"number",description:"Optional timeout in milliseconds (max 600000)"},description:{type:"string",description:"Clear, concise description of what this command does"}},required:["command"]},handler:async($,Z)=>{let J=$.command,Q=$.timeout||120000;try{let X=Bun.spawnSync(["sh","-c",J],{cwd:Z.workingDirectory,timeout:Q,maxBuffer:31457280}),V=X.stdout?.toString()||"",K=X.stderr?.toString()||"";if(X.exitCode!==0)return{content:`Exit code: ${X.exitCode}
123
- ${V}
124
- ${K}`.trim(),is_error:!0};return{content:V||"(no output)"}}catch(X){return{content:`Error executing command: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},iX={name:"Glob",description:"Fast file pattern matching tool that works with any codebase size. Supports glob patterns.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The glob pattern to match files"},path:{type:"string",description:"The directory to search (default: current directory)"}},required:["pattern"]},handler:async($,Z)=>{let J=$.pattern,Q=$.path||Z.workingDirectory;try{let X=await S6(J,{cwd:Q,absolute:!0,nodir:!0});if(X.length===0)return{content:"No files found matching pattern"};return{content:X.sort().join(`
125
- `)}}catch(X){return{content:`Error searching files: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},sX={name:"Grep",description:"A powerful search tool built on ripgrep. Supports full regex syntax.",input_schema:{type:"object",properties:{pattern:{type:"string",description:"The regular expression pattern to search for"},path:{type:"string",description:"File or directory to search"},glob:{type:"string",description:"Glob pattern to filter files"},output_mode:{type:"string",enum:["content","files_with_matches","count"],description:"Output mode (default: content)"},"-i:":{type:"boolean",description:"Case insensitive search"},"-C:":{type:"number",description:"Context lines around match"},head_limit:{type:"number",description:"Maximum number of results"}},required:["pattern"]},handler:async($,Z)=>{let J=$.pattern,Q=$.path||Z.workingDirectory,X=$.glob,V=$.output_mode||"content",K=$["-i:"],W=$["-C:"],H=$.head_limit;try{let q=["--json"];if(K)q.push("-i");if(W)q.push("-C",String(W));if(X)q.push("--glob",X);if(V==="files_with_matches")q.push("--files-with-matches");if(V==="count")q.push("--count");q.push(J,Q);let G=Bun.spawnSync(["rg",...q],{cwd:Z.workingDirectory,maxBuffer:10485760}).stdout?.toString()||"";if(!G.trim())return{content:"No matches found"};if(V==="content"){let U=G.trim().split(`
126
- `),L=[];for(let B of U.slice(0,H||100))try{let _=JSON.parse(B);if(_.type==="match"){let R=_.data?.path?.text||"",w=_.data?.line_number||0,D=_.data?.lines?.text||"";L.push(`${R}:${w}:${D.trim()}`)}}catch{L.push(B)}return{content:L.join(`
127
- `)||"No matches found"}}return{content:G.trim()}}catch(q){return{content:`Error searching: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},oX={name:"Task",description:`Launch a new agent to handle complex, multi-step tasks autonomously.
128
-
129
- The Task tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
130
-
131
- Available agent types and their tools:
132
- - Bash: Command execution specialist for running bash commands. Use for git operations, command execution, and other terminal tasks.
133
- - general-purpose: General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks.
134
- - Explore: Fast agent specialized for exploring codebases. Use to quickly find files by patterns, search code for keywords, or answer questions about the codebase.
135
- - Plan: Software architect agent for designing implementation plans. Returns step-by-step plans, identifies critical files and considers architectural trade-offs.
136
-
137
- When using the Task tool, you must specify a subagent_type parameter to select the agent type.
138
-
139
- Usage notes:
140
- - Always include a short description (3-5 words) summarizing what the agent will do
141
- - Launch multiple agents concurrently whenever possible to maximize performance
142
- - Agents can be resumed using the "resume" parameter by passing the agent ID from a previous invocation.`,input_schema:{type:"object",properties:{subagent_type:{type:"string",enum:["Bash","general-purpose","Explore","Plan"],description:"The agent type to launch"},description:{type:"string",description:"A short (3-5 word) description of what the agent will do"},prompt:{type:"string",description:"The task for the agent to perform"},resume:{type:"string",description:"Resume a previous agent by its ID"},model:{type:"string",enum:["sonnet","opus","haiku"],description:"Model for the subagent (default: haiku for quick tasks)"},run_in_background:{type:"boolean",description:"Run the agent in the background"}},required:["subagent_type","prompt"]},handler:async($,Z)=>{let{subagent_type:J,prompt:Q,description:X}=$,V=$.model||"haiku",K=$.resume,W=$.run_in_background,H=K||`${J.toLowerCase()}-${Date.now().toString(36)}`;try{let q=process.env.ANTHROPIC_API_KEY||process.env.CLAUDE_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN||process.env.Z_AI_API_KEY||"";if(!q)return{content:"Error: No API key available for subagent. Set ANTHROPIC_API_KEY, CLAUDE_API_KEY, ANTHROPIC_AUTH_TOKEN, or Z_AI_API_KEY environment variable.",is_error:!0};let z={haiku:"claude-haiku-4-5",sonnet:"claude-sonnet-4-6",opus:"claude-opus-4-6"},G=z[V]||z.haiku,U=[import.meta.dir+"/../../dist/cli.js",import.meta.dir+"/../cli.ts",process.cwd()+"/dist/cli.js",process.cwd()+"/src/cli.ts"],L=null;for(let D of U)try{if(await Bun.file(D).exists()){L=D;break}}catch{}if(!L)return{content:`Error: Could not find CLI. Tried:
143
- ${U.join(`
144
- `)}`,is_error:!0};let B=["run",L,"-m",G,"-p",Z.permissionMode,"-q",Q];if(W)return Bun.spawn(["bun",...B],{cwd:Z.workingDirectory,detached:!0,stdio:["ignore","pipe","pipe"],env:{...process.env,ANTHROPIC_API_KEY:q}}).unref(),{content:JSON.stringify({agentId:H,status:"running",message:`Agent started in background. Use TaskOutput tool with task_id: "${H}" to check results.`,description:X||"Background task"})};let _=Bun.spawnSync(["bun",...B],{cwd:Z.workingDirectory,timeout:300000,maxBuffer:10485760,env:{...process.env,ANTHROPIC_API_KEY:q}}),R=_.stdout?.toString()||"",w=_.stderr?.toString()||"";if(_.exitCode!==0)return{content:`Agent failed with exit code ${_.exitCode}
145
- ${w}
146
- ${R}`.trim(),is_error:!0};return{content:JSON.stringify({agentId:H,status:"completed",output:R,description:X||"Task completed"})}}catch(q){return{content:`Error running subagent: ${q instanceof Error?q.message:String(q)}`,is_error:!0}}}},eX={name:"TaskOutput",description:`Retrieves output from a running or completed task (background shell, agent, or remote session).
147
-
148
- Takes a task_id parameter identifying the task.
149
- Returns the task output along with status information.
150
- Use block=true (default) to wait for task completion.
151
- Use block=false for non-blocking check of current status.
152
-
153
- Task IDs can be found using the /tasks command
154
- Works with all task types: background shells, async agents, and remote sessions`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The task ID to get output from"},block:{type:"boolean",description:"Whether to wait for completion (default: true)",default:!0},timeout:{type:"number",description:"Max wait time in ms (default: 30000, max: 600000)",default:30000,minimum:0,maximum:600000}},required:["task_id"]},handler:async($,Z)=>{let J=$.task_id,Q=$.block??!0,X=$.timeout??30000;try{let V=`${Z.workingDirectory}/.claude/tasks/${J}.json`,K=Bun.file(V);if(!await K.exists())return{content:`Task not found: ${J}. Use /tasks to list available tasks.`,is_error:!0};let W=await K.json();if(Q&&W.status==="running"){let H=Date.now();while(Date.now()-H<X){await new Promise((z)=>setTimeout(z,1000));let q=Bun.file(V);if(await q.exists()){let z=await q.json();if(z.status!=="running")return{content:JSON.stringify({task_id:J,status:z.status,output:z.output,error:z.error,duration:z.endTime?z.endTime-z.startTime:null},null,2)}}}return{content:JSON.stringify({task_id:J,status:"timeout",message:`Task still running after ${X}ms`},null,2)}}return{content:JSON.stringify({task_id:J,status:W.status,output:W.output,error:W.error,duration:W.endTime?W.endTime-W.startTime:null},null,2)}}catch(V){return{content:`Error getting task output: ${V instanceof Error?V.message:String(V)}`,is_error:!0}}}},tX={name:"AskUserQuestion",description:`Use this tool when you need to ask the user questions during execution.
155
-
156
- This allows you to:
157
- 1. Gather user preferences or requirements
158
- 2. Clarify ambiguous instructions
159
- 3. Get decisions on implementation choices
160
- 4. Offer choices to the user about what direction to take
161
-
162
- Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
163
-
164
- The options array should have 2-4 options. Each option should be a distinct, mutually exclusive choice.
165
- The preview feature allows showing markdown content in a side-by-side layout.
166
-
167
- User can always select "Other" to provide custom text input.`,input_schema:{type:"object",properties:{questions:{type:"array",description:"Questions to ask the user (1-4 questions)",items:{type:"object",properties:{question:{type:"string",description:"The complete question to ask the user"},header:{type:"string",description:"Very short label displayed as a chip/tag (max 12 chars)"},options:{type:"array",description:"The available choices (2-4 options)",items:{type:"object",properties:{label:{type:"string",description:"The display text for this option (5 words max)"},description:{type:"string",description:"Explanation of what this option means"},markdown:{type:"string",description:"Optional preview content shown in a monospace box"}},required:["label","description"]},minItems:2,maxItems:4},multiSelect:{type:"boolean",description:"Allow selecting multiple options (default: false)",default:!1}},required:["question","header","options"]},minItems:1,maxItems:4}},required:["questions"]},handler:async($,Z)=>{let J=$.questions;try{let Q=J.map((X,V)=>{let K=X.options.map((W,H)=>{let q=` ${H+1}. ${W.label}`;if(W.description)q+=` - ${W.description}`;return q}).join(`
168
- `);return`## Question ${V+1}: [${X.header}]
169
- ${X.question}
170
-
171
- Options:
172
- ${K}${X.multiSelect?`
173
- (multi-select enabled)`:""}`}).join(`
174
-
175
- ---
176
-
177
- `);return{content:JSON.stringify({type:"user_question",questions:J,formatted:Q,message:"Questions prepared for user response"},null,2)}}catch(Q){return{content:`Error preparing questions: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},$V={name:"EnterPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
178
-
179
- How This Tool Works:
180
- - You should have already written your plan to the plan file specified in the plan mode system message
181
- - This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote
182
- - This tool simply signals that you're done planning and ready for the user to review and approve
183
-
184
- When to Use This Tool:
185
- IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code. For research tasks where you're gathering information, searching files, reading files or in general trying to understand the codebase - do NOT use this tool.
186
-
187
- Plan mode note: In plan mode, use this tool to clarify requirements or choose between approaches BEFORE finalizing your plan. Do NOT use this tool if your plan is ready - that's what ExitPlanMode is for.
188
-
189
- Examples:
190
- - "Search for and understand the implementation of vim mode" - Do NOT use this tool
191
- - "Help me implement yank mode for vim" - Use EnterPlanMode
192
-
193
- Important notes:
194
- - NEVER run additional commands to read or explore code, besides git bash commands
195
- - NEVER use the TodoWrite or Task tools
196
- - DO NOT commit files that likely contain secrets (.env, credentials.json, etc.)
197
- - If you discover unexpected state like unfamiliar files, branches, or configuration, investigate before deleting or overwriting`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to (e.g., 'Bash')"},prompt:{type:"string",description:"Semantic description of the action (e.g., 'run tests', 'install dependencies')"}},required:["tool","prompt"]}}},required:[]},handler:async($,Z)=>{let J=$.allowedPrompts;try{let Q=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(Q);if(!await X.exists())return{content:"Error: No plan file found. Please write your plan to .claude/plan.md first.",is_error:!0};let V=await X.text();return{content:JSON.stringify({type:"plan_ready",planFile:Q,planLength:V.length,allowedPrompts:J||[],message:"Plan is ready for user review. ExitPlanMode will request user approval."},null,2)}}catch(Q){return{content:`Error entering plan mode: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},ZV={name:"ExitPlanMode",description:`Use this tool when you are in plan mode and have finished writing your plan to the plan file and are ready for user approval.
198
-
199
- This tool does NOT take the plan content as a parameter - it will read the plan from the file you wrote.
200
- This tool simply signals that you're done planning and ready for the user to review and approve.
201
-
202
- IMPORTANT: Only use this tool when the task requires planning the implementation steps of a task that requires writing code.
203
- ExitPlanMode inherently requests user approval of the plan.`,input_schema:{type:"object",properties:{allowedPrompts:{type:"array",description:"Prompt-based permissions needed to implement the plan",items:{type:"object",properties:{tool:{type:"string",description:"The tool this prompt applies to"},prompt:{type:"string",description:"Semantic description of the action"}},required:["tool","prompt"]}}},required:[]},handler:async($,Z)=>{let J=$.allowedPrompts;try{let Q=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(Q);if(!await X.exists())return{content:"Error: No plan file found at .claude/plan.md",is_error:!0};let V=await X.text();return{content:JSON.stringify({type:"exit_plan_mode",status:"awaiting_approval",planFile:Q,planPreview:V.slice(0,500)+(V.length>500?"...":""),allowedPrompts:J||[],message:"Plan submitted for user approval."},null,2)}}catch(Q){return{content:`Error exiting plan mode: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},JV={name:"Skill",description:`Execute a skill within the main conversation.
204
-
205
- When users ask you to perform tasks, check if any of the available skills match. Skills provide specialized capabilities and domain knowledge.
206
-
207
- When users reference a "slash command" or "/<something>" (e.g., "/commit", "/review-pr"), they are referring to a skill. Use this tool to invoke it.
208
-
209
- How to invoke:
210
- - Use this tool with the skill name and optional arguments
211
- - Examples:
212
- - skill: "commit" - invoke the commit skill
213
- - skill: "review-pr", args: "123" - invoke with arguments
214
- - Use fully qualified name for namespaced skills: skill: "ms-office-suite:pdf"
215
-
216
- Available skills are listed in system-reminder messages in the conversation.
217
- When a skill matches the user's request, this is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task.
218
-
219
- Important:
220
- - NEVER mention a skill without actually calling this tool
221
- - Do not invoke a skill that is already running
222
- - Do not use this tool for built-in CLI commands (like /help, /clear)`,input_schema:{type:"object",properties:{skill:{type:"string",description:"The skill name (e.g., 'commit', 'review-pr', or fully qualified 'namespace:skill')"},args:{type:"string",description:"Optional arguments for the skill"}},required:["skill"]},handler:async($,Z)=>{let{skill:J,args:Q}=$;try{let X=`${Z.workingDirectory}/.claude/skills`,V=`${process.env.HOME||""}/.claude/skills`,K=[`${X}/${J}.md`,`${X}/${J}/skill.md`,`${V}/${J}.md`,`${V}/${J}/skill.md`],W=null;for(let z of K)if(await Bun.file(z).exists()){W=z;break}if(!W)return{content:`Skill not found: ${J}. Available skills can be listed with /help.`,is_error:!0};let q=await Bun.file(W).text();return{content:JSON.stringify({type:"skill_invocation",skill:J,args:Q,skillFile:W,content:q,message:`Skill "${J}" loaded. Follow the instructions in the skill content.`},null,2)}}catch(X){return{content:`Error invoking skill: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},QV={name:"TaskStop",description:`Stops a running background task by its ID.
223
- Takes a task_id parameter identifying the task to stop.
224
- Returns a success or failure status.
225
- Use this tool to terminate a long-running task.`,input_schema:{type:"object",properties:{task_id:{type:"string",description:"The ID of the background task to stop"},shell_id:{type:"string",description:"Deprecated: use task_id instead"}},required:["task_id"]},handler:async($,Z)=>{let J=$.task_id;try{let Q=`${Z.workingDirectory}/.claude/tasks/${J}.json`,X=Bun.file(Q);if(!await X.exists())return{content:`Task not found: ${J}`,is_error:!0};let V=await X.json();if(V.status!=="running")return{content:JSON.stringify({task_id:J,status:V.status,message:`Task is already ${V.status}`},null,2)};return V.status="stopped",await Bun.write(Q,JSON.stringify(V,null,2)),{content:JSON.stringify({task_id:J,status:"stopped",message:"Task stopped successfully"},null,2)}}catch(Q){return{content:`Error stopping task: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}},XV={name:"MultiEdit",description:`Performs atomic multi-file editing with rollback on failure.
226
-
227
- This tool allows you to edit multiple files simultaneously in a single atomic operation.
228
- If any edit fails, all changes are automatically rolled back to maintain consistency.
229
-
230
- Key features:
231
- - Validates all edits before applying (files exist, strings found)
232
- - Creates automatic backups before editing
233
- - Applies all edits atomically (all-or-nothing)
234
- - Rolls back on any failure
235
-
236
- Use this when you need to make coordinated changes across multiple files and want
237
- to ensure either all changes succeed or none are applied.
238
-
239
- IMPORTANT: You MUST read the files first before using this tool. Only edit files you have already read.`,input_schema:{type:"object",properties:{edits:{type:"array",description:"Array of edit operations to apply atomically",items:{type:"object",properties:{file_path:{type:"string",description:"The absolute path to the file to edit"},old_string:{type:"string",description:"The text to find and replace"},new_string:{type:"string",description:"The text to replace it with"},replace_all:{type:"boolean",description:"Replace all occurrences (default: false)"}},required:["file_path","old_string","new_string"]}},dry_run:{type:"boolean",description:"Preview changes without applying them (default: false)"}},required:["edits"]},handler:async($,Z)=>{let J=$.edits,Q=$.dry_run||!1;try{if(!Array.isArray(J)||J.length===0)return{content:"Error: edits must be a non-empty array",is_error:!0};let X=[];for(let W=0;W<J.length;W++){let H=J[W];if(!H||!H.file_path||!H.old_string||H.new_string===void 0)return{content:`Error: Edit at index ${W} is missing required fields (file_path, old_string, new_string)`,is_error:!0};X.push({filePath:H.file_path,oldString:H.old_string,newString:H.new_string,replaceAll:H.replace_all||!1})}if(Q){let W=R5(X),H=K2(X);if(H.length>0)return{content:JSON.stringify({valid:!1,errors:H,preview:W},null,2),is_error:!0};return{content:JSON.stringify({valid:!0,preview:W,total_files:W.length,total_replacements:W.reduce((q,z)=>q+z.replacementCount,0),message:"Dry run successful - no changes applied"},null,2)}}let V=K2(X);if(V.length>0)return{content:`Validation failed:
240
- ${V.join(`
241
- `)}`,is_error:!0};let K=C5(X);if(K.success)return{content:JSON.stringify({success:!0,files_modified:K.filesModified,total_replacements:K.totalReplacements,message:`Successfully applied ${K.totalReplacements} replacement(s) across ${K.filesModified.length} file(s)`},null,2)};else return{content:JSON.stringify({success:!1,error:K.error,rolled_back:K.rolledBack,files_modified:K.filesModified},null,2),is_error:!0}}catch(X){return{content:`Error applying multi-edit: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},VV={name:"NotebookEdit",description:`Completely replaces the contents of a specific cell in a Jupyter notebook (.ipynb file) with new source.
242
-
243
- Jupyter notebooks are interactive documents that combine code, text, and visualizations. The notebook_path parameter must be an absolute path, not a relative path. The cell_number is 0-indexed. Use edit_mode=insert to add a new cell at the index specified by cell_number. Use edit_mode=delete to delete the cell at the index specified by cell_number.`,input_schema:{type:"object",properties:{notebook_path:{type:"string",description:"The absolute path to the Jupyter notebook file to edit"},cell_id:{type:"string",description:"The ID of the cell to edit (optional, alternative to cell_number)"},cell_number:{type:"number",description:"The index of the cell to edit (0-indexed)"},new_source:{type:"string",description:"The new source for the cell"},cell_type:{type:"string",enum:["code","markdown"],description:"The type of the cell (code or markdown). Defaults to code."},edit_mode:{type:"string",enum:["replace","insert","delete"],description:"The type of edit to perform (replace, insert, delete)"}},required:["notebook_path"]},handler:async($,Z)=>{let{notebook_path:J,cell_id:Q,cell_number:X,new_source:V}=$,K=$.cell_type||"code",W=$.edit_mode||"replace";try{let H=Bun.file(J);if(!await H.exists())return{content:`Error: Notebook not found: ${J}`,is_error:!0};let q=await H.json();if(!q.cells||!Array.isArray(q.cells))return{content:"Error: Invalid notebook format - no cells array",is_error:!0};let z;if(Q){if(z=q.cells.findIndex((G)=>G.id===Q),z===-1)return{content:`Error: Cell with ID "${Q}" not found`,is_error:!0}}else if(X!==void 0){if(z=X,z<0||z>=q.cells.length)if(W==="insert")z=q.cells.length;else return{content:`Error: Cell number ${z} out of range (0-${q.cells.length-1})`,is_error:!0}}else if(W!=="insert")return{content:"Error: Must specify either cell_id or cell_number",is_error:!0};else z=q.cells.length;switch(W){case"delete":{q.cells.splice(z,1);break}case"insert":{let G={id:`cell-${Date.now()}`,cell_type:K,source:V||"",metadata:{},...K==="code"?{outputs:[],execution_count:null}:{}};q.cells.splice(z,0,G);break}case"replace":default:{if(V===void 0)return{content:"Error: new_source is required for replace mode",is_error:!0};let G=q.cells[z];if(!G)return{content:`Error: Cell at index ${z} not found`,is_error:!0};q.cells[z]={...G,source:V,cell_type:K,...K==="code"?{execution_count:null}:{}};break}}return await Bun.write(J,JSON.stringify(q,null,1)),{content:JSON.stringify({success:!0,message:`Successfully ${W}d cell in ${J}`,cellCount:q.cells.length})}}catch(H){return{content:`Error editing notebook: ${H instanceof Error?H.message:String(H)}`,is_error:!0}}}},KV={name:"tempglmvision",description:"Analyze images using GLM-4.6V vision model. Use this tool when you need to analyze, describe, or extract information from images. Supports PNG, JPG, JPEG, GIF, and WEBP formats. Accepts both local file paths and remote URLs.",input_schema:{type:"object",properties:{imageSource:{type:"string",description:"Local file path or remote URL to the image (supports PNG, JPG, JPEG, GIF, WEBP)"},prompt:{type:"string",description:"Detailed text prompt describing what to analyze, extract, or understand from the image."}},required:["imageSource","prompt"]},handler:async($,Z)=>{let{imageSource:J,prompt:Q}=$;try{let X=process.env.ANTHROPIC_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN;if(!X)return{content:"Error: No API key found. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.",is_error:!0};let V=process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com",K,W;if(J.startsWith("http://")||J.startsWith("https://")){let U=await fetch(J);if(!U.ok)return{content:`Error fetching image: ${U.status} ${U.statusText}`,is_error:!0};K=Buffer.from(await U.arrayBuffer()).toString("base64");let B=U.headers.get("content-type");if(B?.includes("image/png"))W="image/png";else if(B?.includes("image/gif"))W="image/gif";else if(B?.includes("image/webp"))W="image/webp";else W="image/jpeg"}else{let U=Bun.file(J);if(!await U.exists())return{content:`Error: Image file not found: ${J}`,is_error:!0};K=Buffer.from(await U.arrayBuffer()).toString("base64");let B=i6.extname(J).toLowerCase();if(B===".png")W="image/png";else if(B===".gif")W="image/gif";else if(B===".webp")W="image/webp";else W="image/jpeg"}let H={model:"glm-5",max_tokens:4096,messages:[{role:"user",content:[{type:"image",source:{type:"base64",media_type:W,data:K}},{type:"text",text:Q}]}]},q=await fetch(`${V}/v1/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":X,"anthropic-version":"2023-06-01"},body:JSON.stringify(H),signal:Z.abortSignal});if(!q.ok){let U=await q.text();return{content:`Vision API error: ${q.status} - ${U}`,is_error:!0}}let z=await q.json();if(z.error)return{content:`Vision API error: ${z.error.message}`,is_error:!0};return{content:z.content?.filter((U)=>U.type==="text").map((U)=>U.text).join(`
244
- `)||"No text content in vision response"}}catch(X){return{content:`Error analyzing image: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},WV={name:"mcp__4_5v_mcp__analyze_image",description:"Analyze an image using advanced AI vision models with comprehensive understanding capabilities. Supports PNG, JPG, JPEG, GIF, and WEBP formats. Accepts both local file paths and remote URLs.",input_schema:{type:"object",properties:{imageSource:{type:"string",description:"Local file path or remote URL to the image (supports PNG, JPG, JPEG, GIF, WEBP)"},prompt:{type:"string",description:"Detailed text prompt describing what to analyze, extract, or understand from the image. For front-end code replication, describe layout structure, color style, main components, and interactive elements."}},required:["imageSource","prompt"]},handler:async($,Z)=>{let{imageSource:J,prompt:Q}=$;try{let X=process.env.ANTHROPIC_API_KEY||process.env.ANTHROPIC_AUTH_TOKEN;if(!X)return{content:"Error: No API key found. Set ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN.",is_error:!0};let V=process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com",K,W;if(J.startsWith("http://")||J.startsWith("https://")){let U=await fetch(J);if(!U.ok)return{content:`Error fetching image: ${U.status} ${U.statusText}`,is_error:!0};K=Buffer.from(await U.arrayBuffer()).toString("base64");let B=U.headers.get("content-type");if(B?.includes("image/png"))W="image/png";else if(B?.includes("image/gif"))W="image/gif";else if(B?.includes("image/webp"))W="image/webp";else W="image/jpeg"}else{let U=Bun.file(J);if(!await U.exists())return{content:`Error: Image file not found: ${J}`,is_error:!0};K=Buffer.from(await U.arrayBuffer()).toString("base64");let B=i6.extname(J).toLowerCase();if(B===".png")W="image/png";else if(B===".gif")W="image/gif";else if(B===".webp")W="image/webp";else W="image/jpeg"}let H={model:"glm-5",max_tokens:4096,messages:[{role:"user",content:[{type:"image",source:{type:"base64",media_type:W,data:K}},{type:"text",text:Q}]}]},q=await fetch(`${V}/v1/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":X,"anthropic-version":"2023-06-01"},body:JSON.stringify(H),signal:Z.abortSignal});if(!q.ok){let U=await q.text();return{content:`Vision API error: ${q.status} - ${U}`,is_error:!0}}let z=await q.json();if(z.error)return{content:`Vision API error: ${z.error.message}`,is_error:!0};return{content:z.content?.filter((U)=>U.type==="text").map((U)=>U.text).join(`
245
- `)||"No text content in vision response"}}catch(X){return{content:`Error analyzing image: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},HV=[cX,pX,aX,XV,nX,iX,sX,oX,eX,QV,tX,$V,ZV,JV,VV,WV,KV];function IH($){return HV.find((Z)=>Z.name===$)}import{spawn as qV}from"child_process";import t2 from"ws";class $5{static MCPClient=$5;name;config;connected=!1;tools=[];process=null;websocket=null;requestId=0;pendingRequests=new Map;buffer="";onLog;constructor($){this.name=$.name,this.config=$.config,this.onLog=$.onLog}async connect(){if(this.config.type==="stdio")await this.connectStdio();else if(this.config.type==="http"||this.config.type==="sse")await this.connectHttp();else if(this.config.type==="ws")await this.connectWebSocket()}async connectStdio(){if(!this.config.command)throw Error("No command specified for stdio transport");this.log(`Starting stdio transport: ${this.config.command}`),this.process=qV(this.config.command,this.config.args||[],{env:{...process.env,...this.config.env},stdio:["pipe","pipe","pipe"]}),this.process.stdout?.on("data",($)=>{this.handleData($.toString())}),this.process.stderr?.on("data",($)=>{this.log(`stderr: ${$.toString()}`)}),this.process.on("error",($)=>{this.log(`Process error: ${$.message}`)}),this.process.on("close",($)=>{this.log(`Process closed with code ${$}`),this.connected=!1}),await new Promise(($)=>setTimeout($,100)),await this.initialize()}async connectHttp(){if(!this.config.url)throw Error("No URL specified for HTTP transport");this.log(`Starting HTTP transport: ${this.config.url}`);try{let $=await fetch(this.config.url,{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{protocolVersion:"2024-11-05",capabilities:{},clientInfo:{name:"claude-code-remake",version:"0.1.0"}}})});if(!$.ok)throw Error(`HTTP error: ${$.status}`);let Z=await $.json();this.connected=!0,await this.loadTools()}catch($){let Z=$ instanceof Error?$.message:String($);throw Error(`Failed to connect to HTTP server: ${Z}`)}}async connectWebSocket(){if(!this.config.url)throw Error("No URL specified for WebSocket transport");let $=this.config.url;return this.log(`Starting WebSocket transport: ${$}`),new Promise((Z,J)=>{let Q={...this.config.headers},X=new t2($,{headers:Q,handshakeTimeout:this.config.timeout||30000});X.on("open",()=>{this.log("WebSocket connection established"),this.websocket=X,this.connected=!0,this.initialize().then(()=>Z()).catch((V)=>{let K=V instanceof Error?V.message:String(V);this.log(`Initialization failed: ${K}`),J(V)})}),X.on("message",(V,K)=>{let W=K?V.toString():V.toString();this.handleData(W)}),X.on("error",(V)=>{if(this.log(`WebSocket error: ${V.message}`),!this.connected)J(Error(`WebSocket connection failed: ${V.message}`))}),X.on("close",(V,K)=>{this.log(`WebSocket closed: code=${V}, reason=${K.toString()}`),this.connected=!1,this.websocket=null;for(let[W,H]of this.pendingRequests)this.pendingRequests.delete(W),H.reject(Error(`WebSocket closed: ${K.toString()}`))}),X.on("ping",()=>{X.pong()})})}async initialize(){let $=await this.request("initialize",{protocolVersion:"2024-11-05",capabilities:{tools:{},resources:{},prompts:{}},clientInfo:{name:"claude-code-remake",version:"0.1.0"}});this.log(`Initialized with: ${JSON.stringify($)}`),this.connected=!0,this.notify("notifications/initialized",{}),await this.loadTools()}async loadTools(){try{let $=await this.request("tools/list",{});this.tools=$.tools.map((Z)=>({name:Z.name,description:Z.description,inputSchema:Z.inputSchema})),this.log(`Loaded ${this.tools.length} tools`)}catch($){this.log(`Failed to load tools: ${$}`)}}async callTool($,Z){return{content:(await this.request("tools/call",{name:$,arguments:Z})).content.filter((X)=>X.type==="text").map((X)=>X.text||"").join(`
246
- `)}}async request($,Z){let J=++this.requestId,Q={jsonrpc:"2.0",id:J,method:$,params:Z};return new Promise((X,V)=>{this.pendingRequests.set(J,{resolve:X,reject:V});let K=JSON.stringify(Q);if(this.websocket&&this.websocket.readyState===t2.OPEN)this.websocket.send(K);else if(this.process?.stdin?.writable)this.process.stdin.write(K+`
247
- `);else{this.pendingRequests.delete(J),V(Error("No active connection to send request"));return}setTimeout(()=>{if(this.pendingRequests.has(J))this.pendingRequests.delete(J),V(Error(`Request timeout for ${$}`))},this.config.timeout||120000)})}notify($,Z){let Q=JSON.stringify({jsonrpc:"2.0",method:$,params:Z});if(this.websocket&&this.websocket.readyState===t2.OPEN)this.websocket.send(Q);else if(this.process?.stdin?.writable)this.process.stdin.write(Q+`
248
- `)}handleData($){this.buffer+=$;let Z=this.buffer.split(`
249
- `);this.buffer=Z.pop()||"";for(let J of Z){if(!J.trim())continue;try{let Q=JSON.parse(J);if(Q.id!==void 0){let X=this.pendingRequests.get(Q.id);if(X)if(this.pendingRequests.delete(Q.id),Q.error)X.reject(Error(Q.error.message));else X.resolve(Q.result)}}catch(Q){this.log(`Parse error: ${Q}`)}}}async close(){if(this.websocket)this.websocket.close(),this.websocket=null;if(this.process)this.process.kill(),this.process=null;this.connected=!1}log($){this.onLog?.(`[MCP:${this.name}] ${$}`)}}async function vH($,Z){let J=new Map;for(let[Q,X]of Object.entries($)){if(X.disabled)continue;let V=new $5({name:Q,config:X,onLog:Z});try{await V.connect(),J.set(Q,V)}catch(K){let W=K instanceof Error?K.message:String(K);Z?.(`[MCP:${Q}] Failed to connect: ${W}`)}}return J}import{spawn as YV}from"child_process";class zV{hooks=new Map;timeout;constructor($=60000){this.timeout=$}register($,Z){if(!this.hooks.has($))this.hooks.set($,[]);this.hooks.get($)?.push(Z)}registerAll($){for(let[Z,J]of Object.entries($))for(let Q of J)this.register(Z,Q)}async execute($,Z){let J=this.hooks.get($);if(!J||J.length===0)return{decision:"allow"};let Q={...Z,event:$,timestamp:Date.now()};for(let X of J){if(X.enabled===!1)continue;let V=await this.executeHook(X,Q);if(V.decision==="deny"||V.decision==="block")return V;if(V.modified_input)Object.assign(Z,V.modified_input)}return{decision:"allow"}}async executeHook($,Z){let J=$.timeout||this.timeout;try{return await new Promise((X,V)=>{let K=YV($.command,[],{shell:!0,stdio:["pipe","pipe","pipe"]}),W="",H="";K.stdout?.on("data",(q)=>{W+=q.toString()}),K.stderr?.on("data",(q)=>{H+=q.toString()}),K.on("close",(q)=>{if(q===0)try{let z=JSON.parse(W);X(z)}catch{X({decision:"allow"})}else if(q===1)X({decision:"deny",reason:H||"Hook denied execution"});else if(q===2)X({decision:"block",reason:H||"Hook blocked execution"});else X({decision:"allow"})}),K.on("error",(q)=>{X({decision:"allow",reason:`Hook error: ${q.message}`})}),K.stdin?.write(JSON.stringify(Z)),K.stdin?.end(),setTimeout(()=>{K.kill(),X({decision:"allow",reason:"Hook timeout"})},J)})}catch(Q){return{decision:"allow",reason:`Hook execution failed: ${Q instanceof Error?Q.message:String(Q)}`}}}getHooks($){return this.hooks.get($)||[]}clear($){if($)this.hooks.delete($);else this.hooks.clear()}}var OH={validateWrite:{event:"PreToolUse",command:`node -e '
250
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
251
- if (input.tool_name === "Write") {
252
- const path = input.tool_input.file_path;
253
- if (path.includes("..") || path.startsWith("/etc/")) {
254
- console.log(JSON.stringify({ decision: "deny", reason: "Unsafe path" }));
255
- process.exit(1);
256
- }
257
- }
258
- console.log(JSON.stringify({ decision: "allow" }));
259
- '`,timeout:5000,enabled:!1},logToolUse:{event:"PostToolUse",command:`node -e '
260
- const input = JSON.parse(require("fs").readFileSync(0, "utf8"));
261
- console.error(\`[LOG] Tool: \${input.tool_name}\`);
262
- console.log(JSON.stringify({ decision: "allow" }));
263
- '`,timeout:5000,enabled:!1}},yH={PreToolUse:"Before a tool is executed. Can modify input or deny execution.",PostToolUse:"After a tool successfully executes. Can process result.",PostToolUseFailure:"After a tool fails. Can handle error or retry.",Stop:"When the agent stops (end_turn, max_tokens, error).",UserPromptSubmit:"When user submits a prompt. Can modify or reject.",SessionStart:"When a new session starts.",SessionEnd:"When a session ends.",Notification:"When a notification is sent.",ConfigChange:"When configuration changes.",WorktreeCreate:"When a git worktree is created."},fH={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as GV,existsSync as c9,readdirSync as jV}from"fs";import{join as UV}from"path";function AV($,Z="project"){if(!c9($))return null;let J=GV($,"utf-8"),Q=$.split("/").pop()?.replace(/\.md$/i,"")||"unknown",X=J.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!X)return{path:$,name:Q,description:"",prompt:J.trim(),source:Z};let V=X[1]??"",K=X[2]??"",W=BV(V);return{path:$,name:W.name||Q,description:W.description||"",prompt:K.trim(),tools:W.tools,model:W.model,color:W.color,source:Z}}function BV($){let Z={},J=$.split(`
264
- `);for(let Q of J){let X=Q.match(/^(\w+):\s*(.*)$/);if(X){let V=X[1];if(!V)continue;let K=X[2]??"";if(K.startsWith("["))try{Z[V]=JSON.parse(K)}catch{Z[V]=K}else if(K==="true")Z[V]=!0;else if(K==="false")Z[V]=!1;else if(/^\d+$/.test(K))Z[V]=parseInt(K,10);else if(/^\d+\.\d+$/.test(K))Z[V]=parseFloat(K);else Z[V]=K}}return Z}class LV{skills=new Map;loadFromDirectory($,Z="project"){if(!c9($))return 0;let J=0,Q=jV($);for(let X of Q)if(X.endsWith(".md")){let V=AV(UV($,X),Z);if(V)this.skills.set(V.name,V),J++}return J}get($){return this.skills.get($)}getAll(){return Array.from(this.skills.values())}has($){return this.skills.has($)}getNames(){return Array.from(this.skills.keys())}}function uH($){return`
265
- <skill-loading>
266
- You are operating with the "${$.name}" skill loaded.
267
-
268
- ${$.description?`Description: ${$.description}
269
- `:""}
270
- ${$.prompt}
271
- </skill-loading>
272
- `.trim()}var mH=[{path:"built-in://commit",name:"commit",description:"Create a git commit with the staged changes",prompt:`Analyze the staged changes and create a git commit.
273
-
274
- Steps:
275
- 1. Run \`git diff --staged\` to see staged changes
276
- 2. Run \`git log --oneline -5\` to understand commit message style
277
- 3. Create a commit message following conventional commits format
278
- 4. Include "Co-Authored-By: Claude <noreply@anthropic.com>" if applicable
279
- 5. Run \`git commit\` with the message`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://review-pr",name:"review-pr",description:"Review a pull request",prompt:`Review the current pull request and provide feedback.
280
-
281
- Steps:
282
- 1. Use \`gh pr view\` to get PR details
283
- 2. Use \`gh pr diff\` to see the changes
284
- 3. Analyze the code for:
285
- - Bugs and potential issues
286
- - Code quality and style
287
- - Test coverage
288
- - Documentation
289
- 4. Provide constructive feedback
290
- 5. Approve or request changes as appropriate`,tools:["Bash"],model:"sonnet",source:"built-in"},{path:"built-in://mcp-builder",name:"mcp-builder",description:"Guide for creating MCP servers",prompt:`Help the user build MCP (Model Context Protocol) servers.
291
-
292
- MCP servers enable LLMs to interact with external services through well-designed tools.
293
-
294
- Key concepts:
295
- 1. Use FastMCP (Python) or MCP SDK (TypeScript)
296
- 2. Define tools with clear input schemas
297
- 3. Return structured content
298
- 4. Handle errors gracefully
299
-
300
- Transport types:
301
- - stdio: Local process communication
302
- - HTTP: REST API with JSON-RPC
303
- - SSE: Server-Sent Events for streaming
304
- - WebSocket: Bidirectional communication`,tools:["Read","Write","Edit","Bash"],model:"sonnet",source:"built-in"},{path:"built-in://claude-hooks",name:"claude-hooks",description:"Guide for Claude Code hooks",prompt:`Help the user configure Claude Code hooks.
305
-
306
- Hooks are user-defined shell commands that execute at specific points during Claude Code's lifecycle.
307
-
308
- Available events:
309
- - PreToolUse: Before a tool executes
310
- - PostToolUse: After a tool succeeds
311
- - PostToolUseFailure: After a tool fails
312
- - Stop: When agent stops
313
- - UserPromptSubmit: When user submits prompt
314
- - SessionStart/SessionEnd: Session lifecycle
315
-
316
- Exit codes:
317
- - 0: Allow execution
318
- - 1: Deny and show stderr
319
- - 2: Block silently`,tools:["Read","Write","Edit"],model:"sonnet",source:"built-in"}];function cH($){return $.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function lH($){return $.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as Z5}from"child_process";import{mkdirSync as l9,rmSync as _V,existsSync as p9,readFileSync as wV}from"fs";import{join as H6}from"path";class RV{teams=new Map;teammates=new Map;messageQueue=new Map;storagePath;constructor($="~/.claude/teams"){if(this.storagePath=$.replace("~",process.env.HOME||""),!p9(this.storagePath))l9(this.storagePath,{recursive:!0});this.loadTeams()}createTeam($){let Z={...$,status:"active"};this.teams.set($.name,Z);for(let J of $.teammates)this.teammates.set(J.teammateId,J);return this.persistTeam(Z).catch((J)=>{console.error(`Failed to persist team ${$.name}:`,J)}),Z}getTeam($){return this.teams.get($)}listTeams(){return Array.from(this.teams.values())}deleteTeam($){let Z=this.teams.get($);if(Z){for(let Q of Z.teammates)this.teammates.delete(Q.teammateId),this.messageQueue.delete(Q.teammateId);this.teams.delete($);let J=H6(this.storagePath,$);try{_V(J,{recursive:!0,force:!0})}catch(Q){console.error(`Failed to delete team directory ${J}:`,Q)}}}getTeammate($){return this.teammates.get($)}updateTeammateStatus($,Z){let J=this.teammates.get($);if(J)J.status=Z}async spawnTeammate($,Z={}){let{session:J,workingDir:Q=process.cwd()}=Z;if(!process.env.TMUX)await this.spawnInTerminal($,{session:J,workingDir:Q});else await this.spawnInTmux($,{session:J,workingDir:Q});this.updateTeammateStatus($.teammateId,"in_progress")}async spawnInTerminal($,Z){let J=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName,"--agent-color",$.color];if($.planModeRequired)J.push("--permission-mode","plan");if(process.platform==="darwin"){let Q=`
320
- tell application "Terminal"
321
- do script "cd ${Z.workingDir} && ${J.join(" ")}"
322
- activate
323
- end tell
324
- `;Z5("osascript",["-e",Q])}else Z5("xterm",["-e",J.join(" ")])}async spawnInTmux($,Z){let J=Z.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",J,"-c",Z.workingDir]);let Q=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(Q)$.paneId=Q.trim();let X=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName];await this.tmuxCommand(["send-keys","-t",$.paneId||"",X.join(" "),"Enter"])}async tmuxCommand($){return new Promise((Z)=>{let J=Z5("tmux",$),Q="";J.stdout?.on("data",(X)=>{Q+=X.toString()}),J.on("close",()=>{Z(Q)})})}broadcast($,Z,J){let Q=this.teams.get($);if(!Q)return;let X={type:"broadcast",from:J||"system",content:Z,timestamp:Date.now()};for(let V of Q.teammates){if(J&&V.teammateId===J)continue;let K=this.messageQueue.get(V.teammateId)||[];K.push(X),this.messageQueue.set(V.teammateId,K)}}sendDirect($,Z,J){let Q={type:"direct",from:Z,to:$,content:J,timestamp:Date.now()},X=this.messageQueue.get($)||[];X.push(Q),this.messageQueue.set($,X)}getMessages($){let Z=this.messageQueue.get($)||[];return this.messageQueue.delete($),Z}hasMessages($){let Z=this.messageQueue.get($);return Z!==void 0&&Z.length>0}peekMessages($){return this.messageQueue.get($)||[]}clearMessages($){this.messageQueue.delete($)}getMessageCount($){return this.messageQueue.get($)?.length||0}async persistTeam($){let Z=H6(this.storagePath,$.name),J=H6(Z,"config.json");if(!p9(Z))l9(Z,{recursive:!0});await Bun.write(H6(Z,".gitkeep"),"");let Q={name:$.name,description:$.description,teammates:$.teammates,taskListId:$.taskListId,status:$.status,coordination:$.coordination,updatedAt:Date.now()};await Bun.write(J,JSON.stringify(Q,null,2))}loadTeams(){let $=new Bun.Glob("**/config.json");try{let Z=Array.from($.scanSync(this.storagePath));for(let J of Z)try{let Q=H6(this.storagePath,J);if(Bun.file(Q).size===0)continue;let K=wV(Q,"utf-8"),W=JSON.parse(K);if(!W.name||!W.teammates||!Array.isArray(W.teammates))continue;let H={name:W.name,description:W.description||"",teammates:W.teammates,taskListId:W.taskListId||"",status:W.status||"active",coordination:W.coordination||{dependencyOrder:[],communicationProtocol:"broadcast",taskAssignmentStrategy:"manual"}};this.teams.set(H.name,H);for(let q of H.teammates)this.teammates.set(q.teammateId,q)}catch(Q){}}catch(Z){if(Z.code!=="ENOENT");}}async persistAllTeams(){let $=Array.from(this.teams.values()).map((Z)=>this.persistTeam(Z));await Promise.all($)}}var iH={architect:($)=>({name:"architect",teamName:$,color:"blue",prompt:`You are an architect on the ${$} team.
325
- Your role is to design and plan the technical architecture.
326
- Focus on:
327
- - System design and component relationships
328
- - API contracts and interfaces
329
- - Data models and schemas
330
- - Trade-offs and design decisions`,planModeRequired:!0,status:"pending"}),implementer:($)=>({name:"implementer",teamName:$,color:"green",prompt:`You are an implementer on the ${$} team.
331
- Your role is to write clean, working code based on the architecture.
332
- Focus on:
333
- - Implementing the designed architecture
334
- - Writing tests
335
- - Following coding standards
336
- - Handling edge cases`,planModeRequired:!1,status:"pending"}),reviewer:($)=>({name:"reviewer",teamName:$,color:"yellow",prompt:`You are a code reviewer on the ${$} team.
337
- Your role is to review code changes and provide feedback.
338
- Focus on:
339
- - Code quality and readability
340
- - Potential bugs and issues
341
- - Performance considerations
342
- - Test coverage`,planModeRequired:!1,status:"pending"}),tester:($)=>({name:"tester",teamName:$,color:"orange",prompt:`You are a tester on the ${$} team.
343
- Your role is to ensure features work correctly.
344
- Focus on:
345
- - Writing comprehensive tests
346
- - Finding edge cases
347
- - Verifying requirements
348
- - Reporting bugs`,planModeRequired:!1,status:"pending"})};function CV(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function sH($){return{...$,teammateId:CV(),status:"pending"}}
349
- export{k as a,z6 as b,o9 as c,PV as d,V5 as e,K5 as f,DV as g,J7 as h,Q7 as i,X7 as j,V7 as k,q5 as l,H7 as m,q7 as n,o6 as o,e6 as p,xV as q,kV as r,OV as s,rV as t,X2 as u,nV as v,iV as w,sV as x,N7 as y,P7 as z,$K as A,_5 as B,VK as C,K4 as D,KK as E,WK as F,HK as G,qK as H,K2 as I,R5 as J,C5 as K,f as L,YK as M,zK as N,GK as O,jK as P,UK as Q,AK as R,BK as S,LK as T,_K as U,wK as V,RK as W,CK as X,NK as Y,PK as Z,cX as _,pX as $,aX as aa,nX as ba,iX as ca,sX as da,oX as ea,eX as fa,tX as ga,$V as ha,ZV as ia,JV as ja,QV as ka,XV as la,VV as ma,KV as na,WV as oa,HV as pa,IH as qa,$5 as ra,vH as sa,zV as ta,OH as ua,yH as va,fH as wa,AV as xa,LV as ya,uH as za,mH as Aa,cH as Ba,lH as Ca,RV as Da,iH as Ea,CV as Fa,sH as Ga};