@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 p9=Object.create;var{getPrototypeOf:a9,defineProperty:Q5,getOwnPropertyNames:r9}=Object;var n9=Object.prototype.hasOwnProperty;var J5=($,Z,Q)=>{Q=$!=null?p9(a9($)):{};let J=Z||!$||!$.__esModule?Q5(Q,"default",{value:$,enumerable:!0}):Q;for(let X of r9($))if(!n9.call(J,X))Q5(J,X,{get:()=>$[X],enumerable:!0});return J};var T=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var v=import.meta.require;var E0=T((vW,B1)=>{/*!
3
- Copyright 2013 Lovell Fuller and others.
4
- SPDX-License-Identifier: Apache-2.0
5
- */var A1=($)=>typeof $<"u"&&$!==null,_Z=($)=>typeof $==="object",wZ=($)=>Object.prototype.toString.call($)==="[object Object]",RZ=($)=>typeof $==="function",CZ=($)=>typeof $==="boolean",NZ=($)=>$ instanceof Buffer,PZ=($)=>{if(A1($))switch($.constructor){case Uint8Array:case Uint8ClampedArray:case Int8Array:case Uint16Array:case Int16Array:case Uint32Array:case Int32Array:case Float32Array:case Float64Array:return!0}return!1},DZ=($)=>$ instanceof ArrayBuffer,FZ=($)=>typeof $==="string"&&$.length>0,MZ=($)=>typeof $==="number"&&!Number.isNaN($),IZ=($)=>Number.isInteger($),EZ=($,Z,Q)=>$>=Z&&$<=Q,SZ=($,Z)=>Z.includes($),TZ=($,Z,Q)=>Error(`Expected ${Z} for ${$} but received ${Q} of type ${typeof Q}`),kZ=($,Z)=>{return Z.message=$.message,Z};B1.exports={defined:A1,object:_Z,plainObject:wZ,fn:RZ,bool:CZ,buffer:NZ,typedArray:PZ,arrayBuffer:DZ,string:FZ,number:MZ,integer:IZ,inRange:EZ,inArray:SZ,invalidParameterError:TZ,nativeError:kZ}});var w1=T((OW,_1)=>{var L1=()=>process.platform==="linux",k6=null,xZ=()=>{if(!k6)if(L1()&&process.report){let $=process.report.excludeNetwork;process.report.excludeNetwork=!0,k6=process.report.getReport(),process.report.excludeNetwork=$}else k6={};return k6};_1.exports={isLinux:L1,getReport:xZ}});var C1=T((yW,R1)=>{var C4=v("fs"),vZ=($)=>{let Z=C4.openSync($,"r"),Q=Buffer.alloc(2048),J=C4.readSync(Z,Q,0,2048,0);return C4.close(Z,()=>{}),Q.subarray(0,J)},OZ=($)=>new Promise((Z,Q)=>{C4.open($,"r",(J,X)=>{if(J)Q(J);else{let V=Buffer.alloc(2048);C4.read(X,V,0,2048,0,(K,W)=>{Z(V.subarray(0,W)),C4.close(X,()=>{})})}})});R1.exports={LDD_PATH:"/usr/bin/ldd",SELF_PATH:"/proc/self/exe",readFileSync:vZ,readFile:OZ}});var P1=T((bW,N1)=>{var yZ=($)=>{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),Q=$.readUInt16LE(54),J=$.readUInt16LE(56);for(let X=0;X<J;X++){let V=Z+X*Q;if($.readUInt32LE(V)===3){let W=$.readUInt32LE(V+8),H=$.readUInt32LE(V+32);return $.subarray(W,W+H).toString().replace(/\0.*$/g,"")}}return null};N1.exports={interpreterPath:yZ}});var v6=T((fW,d1)=>{var F1=v("child_process"),{isLinux:N4,getReport:M1}=w1(),{LDD_PATH:x6,SELF_PATH:I1,readFile:I2,readFileSync:E2}=C1(),{interpreterPath:E1}=P1(),S0,T0,k0,e0="",S1=()=>{if(!e0)return new Promise(($)=>{F1.exec("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",(Z,Q)=>{e0=Z?" ":Q,$(e0)})});return e0},T1=()=>{if(!e0)try{e0=F1.execSync("getconf GNU_LIBC_VERSION 2>&1 || true; ldd --version 2>&1 || true",{encoding:"utf8"})}catch($){e0=" "}return e0},m0="glibc",k1=/LIBC[a-z0-9 \-).]*?(\d+\.\d+)/i,q4="musl",bZ=($)=>$.includes("libc.musl-")||$.includes("ld-musl-"),x1=()=>{let $=M1();if($.header&&$.header.glibcVersionRuntime)return m0;if(Array.isArray($.sharedObjects)){if($.sharedObjects.some(bZ))return q4}return null},v1=($)=>{let[Z,Q]=$.split(/[\r\n]+/);if(Z&&Z.includes(m0))return m0;if(Q&&Q.includes(q4))return q4;return null},O1=($)=>{if($){if($.includes("/ld-musl-"))return q4;else if($.includes("/ld-linux-"))return m0}return null},y1=($)=>{if($=$.toString(),$.includes("musl"))return q4;if($.includes("GNU C Library"))return m0;return null},fZ=async()=>{if(T0!==void 0)return T0;T0=null;try{let $=await I2(x6);T0=y1($)}catch($){}return T0},hZ=()=>{if(T0!==void 0)return T0;T0=null;try{let $=E2(x6);T0=y1($)}catch($){}return T0},gZ=async()=>{if(S0!==void 0)return S0;S0=null;try{let $=await I2(I1),Z=E1($);S0=O1(Z)}catch($){}return S0},dZ=()=>{if(S0!==void 0)return S0;S0=null;try{let $=E2(I1),Z=E1($);S0=O1(Z)}catch($){}return S0},b1=async()=>{let $=null;if(N4()){if($=await gZ(),!$){if($=await fZ(),!$)$=x1();if(!$){let Z=await S1();$=v1(Z)}}}return $},f1=()=>{let $=null;if(N4()){if($=dZ(),!$){if($=hZ(),!$)$=x1();if(!$){let Z=T1();$=v1(Z)}}}return $},uZ=async()=>N4()&&await b1()!==m0,mZ=()=>N4()&&f1()!==m0,cZ=async()=>{if(k0!==void 0)return k0;k0=null;try{let Z=(await I2(x6)).match(k1);if(Z)k0=Z[1]}catch($){}return k0},lZ=()=>{if(k0!==void 0)return k0;k0=null;try{let Z=E2(x6).match(k1);if(Z)k0=Z[1]}catch($){}return k0},h1=()=>{let $=M1();if($.header&&$.header.glibcVersionRuntime)return $.header.glibcVersionRuntime;return null},D1=($)=>$.trim().split(/\s+/)[1],g1=($)=>{let[Z,Q,J]=$.split(/[\r\n]+/);if(Z&&Z.includes(m0))return D1(Z);if(Q&&J&&Q.includes(q4))return D1(J);return null},pZ=async()=>{let $=null;if(N4()){if($=await cZ(),!$)$=h1();if(!$){let Z=await S1();$=g1(Z)}}return $},aZ=()=>{let $=null;if(N4()){if($=lZ(),!$)$=h1();if(!$){let Z=T1();$=g1(Z)}}return $};d1.exports={GLIBC:m0,MUSL:q4,family:b1,familySync:f1,isNonGlibcLinux:uZ,isNonGlibcLinuxSync:mZ,version:pZ,versionSync:aZ}});var Z6=T((hW,u1)=>{var rZ=typeof process==="object"&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...$)=>console.error("SEMVER",...$):()=>{};u1.exports=rZ});var O6=T((gW,m1)=>{var nZ=Number.MAX_SAFE_INTEGER||9007199254740991,iZ=["major","premajor","minor","preminor","patch","prepatch","prerelease"];m1.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:nZ,RELEASE_TYPES:iZ,SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}});var Q6=T((x0,c1)=>{var{MAX_SAFE_COMPONENT_LENGTH:S2,MAX_SAFE_BUILD_LENGTH:sZ,MAX_LENGTH:oZ}=O6(),eZ=Z6();x0=c1.exports={};var tZ=x0.re=[],$Q=x0.safeRe=[],N=x0.src=[],ZQ=x0.safeSrc=[],P=x0.t={},QQ=0,T2="[a-zA-Z0-9-]",JQ=[["\\s",1],["\\d",oZ],[T2,sZ]],XQ=($)=>{for(let[Z,Q]of JQ)$=$.split(`${Z}*`).join(`${Z}{0,${Q}}`).split(`${Z}+`).join(`${Z}{1,${Q}}`);return $},E=($,Z,Q)=>{let J=XQ(Z),X=QQ++;eZ($,X,Z),P[$]=X,N[X]=Z,ZQ[X]=J,tZ[X]=new RegExp(Z,Q?"g":void 0),$Q[X]=new RegExp(J,Q?"g":void 0)};E("NUMERICIDENTIFIER","0|[1-9]\\d*");E("NUMERICIDENTIFIERLOOSE","\\d+");E("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${T2}*`);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",`${T2}+`);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,${S2}})(?:\\.(\\d{1,${S2}}))?(?:\\.(\\d{1,${S2}}))?`);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);x0.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);x0.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);x0.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 y6=T((dW,l1)=>{var VQ=Object.freeze({loose:!0}),KQ=Object.freeze({}),WQ=($)=>{if(!$)return KQ;if(typeof $!=="object")return VQ;return $};l1.exports=WQ});var n1=T((uW,r1)=>{var p1=/^[0-9]+$/,a1=($,Z)=>{if(typeof $==="number"&&typeof Z==="number")return $===Z?0:$<Z?-1:1;let Q=p1.test($),J=p1.test(Z);if(Q&&J)$=+$,Z=+Z;return $===Z?0:Q&&!J?-1:J&&!Q?1:$<Z?-1:1},HQ=($,Z)=>a1(Z,$);r1.exports={compareIdentifiers:a1,rcompareIdentifiers:HQ}});var P4=T((mW,s1)=>{var b6=Z6(),{MAX_LENGTH:i1,MAX_SAFE_INTEGER:f6}=O6(),{safeRe:h6,t:g6}=Q6(),qQ=y6(),{compareIdentifiers:k2}=n1();class C0{constructor($,Z){if(Z=qQ(Z),$ instanceof C0)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>i1)throw TypeError(`version is longer than ${i1} characters`);b6("SemVer",$,Z),this.options=Z,this.loose=!!Z.loose,this.includePrerelease=!!Z.includePrerelease;let Q=$.trim().match(Z.loose?h6[g6.LOOSE]:h6[g6.FULL]);if(!Q)throw TypeError(`Invalid Version: ${$}`);if(this.raw=$,this.major=+Q[1],this.minor=+Q[2],this.patch=+Q[3],this.major>f6||this.major<0)throw TypeError("Invalid major version");if(this.minor>f6||this.minor<0)throw TypeError("Invalid minor version");if(this.patch>f6||this.patch<0)throw TypeError("Invalid patch version");if(!Q[4])this.prerelease=[];else this.prerelease=Q[4].split(".").map((J)=>{if(/^[0-9]+$/.test(J)){let X=+J;if(X>=0&&X<f6)return X}return J});this.build=Q[5]?Q[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 C0)){if(typeof $==="string"&&$===this.version)return 0;$=new C0($,this.options)}if($.version===this.version)return 0;return this.compareMain($)||this.comparePre($)}compareMain($){if(!($ instanceof C0))$=new C0($,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 C0))$=new C0($,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 Q=this.prerelease[Z],J=$.prerelease[Z];if(b6("prerelease compare",Z,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return k2(Q,J)}while(++Z)}compareBuild($){if(!($ instanceof C0))$=new C0($,this.options);let Z=0;do{let Q=this.build[Z],J=$.build[Z];if(b6("build compare",Z,Q,J),Q===void 0&&J===void 0)return 0;else if(J===void 0)return 1;else if(Q===void 0)return-1;else if(Q===J)continue;else return k2(Q,J)}while(++Z)}inc($,Z,Q){if($.startsWith("pre")){if(!Z&&Q===!1)throw Error("invalid increment argument: identifier is empty");if(Z){let J=`-${Z}`.match(this.options.loose?h6[g6.PRERELEASELOOSE]:h6[g6.PRERELEASE]);if(!J||J[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,Q);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",Z,Q);break;case"prepatch":this.prerelease.length=0,this.inc("patch",Z,Q),this.inc("pre",Z,Q);break;case"prerelease":if(this.prerelease.length===0)this.inc("patch",Z,Q);this.inc("pre",Z,Q);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 J=Number(Q)?1:0;if(this.prerelease.length===0)this.prerelease=[J];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(".")&&Q===!1)throw Error("invalid increment argument: identifier already exists");this.prerelease.push(J)}}if(Z){let X=[Z,J];if(Q===!1)X=[Z];if(k2(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}}s1.exports=C0});var t1=T((cW,e1)=>{var o1=P4(),YQ=($,Z,Q=!1)=>{if($ instanceof o1)return $;try{return new o1($,Z)}catch(J){if(!Q)return null;throw J}};e1.exports=YQ});var Z$=T((lW,$$)=>{var zQ=P4(),GQ=t1(),{safeRe:d6,t:u6}=Q6(),jQ=($,Z)=>{if($ instanceof zQ)return $;if(typeof $==="number")$=String($);if(typeof $!=="string")return null;Z=Z||{};let Q=null;if(!Z.rtl)Q=$.match(Z.includePrerelease?d6[u6.COERCEFULL]:d6[u6.COERCE]);else{let H=Z.includePrerelease?d6[u6.COERCERTLFULL]:d6[u6.COERCERTL],q;while((q=H.exec($))&&(!Q||Q.index+Q[0].length!==$.length)){if(!Q||q.index+q[0].length!==Q.index+Q[0].length)Q=q;H.lastIndex=q.index+q[1].length+q[2].length}H.lastIndex=-1}if(Q===null)return null;let J=Q[2],X=Q[3]||"0",V=Q[4]||"0",K=Z.includePrerelease&&Q[5]?`-${Q[5]}`:"",W=Z.includePrerelease&&Q[6]?`+${Q[6]}`:"";return GQ(`${J}.${X}.${V}${K}${W}`,Z)};$$.exports=jQ});var Y4=T((pW,J$)=>{var Q$=P4(),UQ=($,Z,Q)=>new Q$($,Q).compare(new Q$(Z,Q));J$.exports=UQ});var x2=T((aW,X$)=>{var AQ=Y4(),BQ=($,Z,Q)=>AQ($,Z,Q)>=0;X$.exports=BQ});var W$=T((rW,K$)=>{class V${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 J=this.map.keys().next().value;this.delete(J)}this.map.set($,Z)}return this}}K$.exports=V$});var q$=T((nW,H$)=>{var LQ=Y4(),_Q=($,Z,Q)=>LQ($,Z,Q)===0;H$.exports=_Q});var z$=T((iW,Y$)=>{var wQ=Y4(),RQ=($,Z,Q)=>wQ($,Z,Q)!==0;Y$.exports=RQ});var j$=T((sW,G$)=>{var CQ=Y4(),NQ=($,Z,Q)=>CQ($,Z,Q)>0;G$.exports=NQ});var A$=T((oW,U$)=>{var PQ=Y4(),DQ=($,Z,Q)=>PQ($,Z,Q)<0;U$.exports=DQ});var L$=T((eW,B$)=>{var FQ=Y4(),MQ=($,Z,Q)=>FQ($,Z,Q)<=0;B$.exports=MQ});var w$=T((tW,_$)=>{var IQ=q$(),EQ=z$(),SQ=j$(),TQ=x2(),kQ=A$(),xQ=L$(),vQ=($,Z,Q,J)=>{switch(Z){case"===":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $===Q;case"!==":if(typeof $==="object")$=$.version;if(typeof Q==="object")Q=Q.version;return $!==Q;case"":case"=":case"==":return IQ($,Q,J);case"!=":return EQ($,Q,J);case">":return SQ($,Q,J);case">=":return TQ($,Q,J);case"<":return kQ($,Q,J);case"<=":return xQ($,Q,J);default:throw TypeError(`Invalid operator: ${Z}`)}};_$.exports=vQ});var M$=T(($H,F$)=>{var J6=Symbol("SemVer ANY");class m6{static get ANY(){return J6}constructor($,Z){if(Z=R$(Z),$ instanceof m6)if($.loose===!!Z.loose)return $;else $=$.value;if($=$.trim().split(/\s+/).join(" "),O2("comparator",$,Z),this.options=Z,this.loose=!!Z.loose,this.parse($),this.semver===J6)this.value="";else this.value=this.operator+this.semver.version;O2("comp",this)}parse($){let Z=this.options.loose?C$[N$.COMPARATORLOOSE]:C$[N$.COMPARATOR],Q=$.match(Z);if(!Q)throw TypeError(`Invalid comparator: ${$}`);if(this.operator=Q[1]!==void 0?Q[1]:"",this.operator==="=")this.operator="";if(!Q[2])this.semver=J6;else this.semver=new P$(Q[2],this.options.loose)}toString(){return this.value}test($){if(O2("Comparator.test",$,this.options.loose),this.semver===J6||$===J6)return!0;if(typeof $==="string")try{$=new P$($,this.options)}catch(Z){return!1}return v2($,this.operator,this.semver,this.options)}intersects($,Z){if(!($ instanceof m6))throw TypeError("a Comparator is required");if(this.operator===""){if(this.value==="")return!0;return new D$($.value,Z).test(this.value)}else if($.operator===""){if($.value==="")return!0;return new D$(this.value,Z).test($.semver)}if(Z=R$(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(v2(this.semver,"<",$.semver,Z)&&this.operator.startsWith(">")&&$.operator.startsWith("<"))return!0;if(v2(this.semver,">",$.semver,Z)&&this.operator.startsWith("<")&&$.operator.startsWith(">"))return!0;return!1}}F$.exports=m6;var R$=y6(),{safeRe:C$,t:N$}=Q6(),v2=w$(),O2=Z6(),P$=P4(),D$=y2()});var y2=T((ZH,T$)=>{var OQ=/\s+/g;class X6{constructor($,Z){if(Z=bQ(Z),$ instanceof X6)if($.loose===!!Z.loose&&$.includePrerelease===!!Z.includePrerelease)return $;else return new X6($.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(OQ," "),this.set=this.raw.split("||").map((Q)=>this.parseRange(Q.trim())).filter((Q)=>Q.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let Q=this.set[0];if(this.set=this.set.filter((J)=>!E$(J[0])),this.set.length===0)this.set=[Q];else if(this.set.length>1){for(let J of this.set)if(J.length===1&&cQ(J[0])){this.set=[J];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 Q=0;Q<Z.length;Q++){if(Q>0)this.formatted+=" ";this.formatted+=Z[Q].toString().trim()}}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange($){let Q=((this.options.includePrerelease&&uQ)|(this.options.loose&&mQ))+":"+$,J=I$.get(Q);if(J)return J;let X=this.options.loose,V=X?J0[e.HYPHENRANGELOOSE]:J0[e.HYPHENRANGE];$=$.replace(V,tQ(this.options.includePrerelease)),g("hyphen replace",$),$=$.replace(J0[e.COMPARATORTRIM],hQ),g("comparator trim",$),$=$.replace(J0[e.TILDETRIM],gQ),g("tilde trim",$),$=$.replace(J0[e.CARETTRIM],dQ),g("caret trim",$);let K=$.split(" ").map((z)=>lQ(z,this.options)).join(" ").split(/\s+/).map((z)=>eQ(z,this.options));if(X)K=K.filter((z)=>{return g("loose invalid filter",z,this.options),!!z.match(J0[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(E$(z))return[z];W.set(z.value,z)}if(W.size>1&&W.has(""))W.delete("");let q=[...W.values()];return I$.set(Q,q),q}intersects($,Z){if(!($ instanceof X6))throw TypeError("a Range is required");return this.set.some((Q)=>{return S$(Q,Z)&&$.set.some((J)=>{return S$(J,Z)&&Q.every((X)=>{return J.every((V)=>{return X.intersects(V,Z)})})})})}test($){if(!$)return!1;if(typeof $==="string")try{$=new fQ($,this.options)}catch(Z){return!1}for(let Z=0;Z<this.set.length;Z++)if($J(this.set[Z],$,this.options))return!0;return!1}}T$.exports=X6;var yQ=W$(),I$=new yQ,bQ=y6(),b2=M$(),g=Z6(),fQ=P4(),{safeRe:J0,t:e,comparatorTrimReplace:hQ,tildeTrimReplace:gQ,caretTrimReplace:dQ}=Q6(),{FLAG_INCLUDE_PRERELEASE:uQ,FLAG_LOOSE:mQ}=O6(),E$=($)=>$.value==="<0.0.0-0",cQ=($)=>$.value==="",S$=($,Z)=>{let Q=!0,J=$.slice(),X=J.pop();while(Q&&J.length)Q=J.every((V)=>{return X.intersects(V,Z)}),X=J.pop();return Q},lQ=($,Z)=>{return $=$.replace(J0[e.BUILD],""),g("comp",$,Z),$=rQ($,Z),g("caret",$),$=pQ($,Z),g("tildes",$),$=iQ($,Z),g("xrange",$),$=oQ($,Z),g("stars",$),$},X0=($)=>!$||$.toLowerCase()==="x"||$==="*",pQ=($,Z)=>{return $.trim().split(/\s+/).map((Q)=>aQ(Q,Z)).join(" ")},aQ=($,Z)=>{let Q=Z.loose?J0[e.TILDELOOSE]:J0[e.TILDE];return $.replace(Q,(J,X,V,K,W)=>{g("tilde",$,J,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})},rQ=($,Z)=>{return $.trim().split(/\s+/).map((Q)=>nQ(Q,Z)).join(" ")},nQ=($,Z)=>{g("caret",$,Z);let Q=Z.loose?J0[e.CARETLOOSE]:J0[e.CARET],J=Z.includePrerelease?"-0":"";return $.replace(Q,(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${J} <${+V+1}.0.0-0`;else if(X0(W))if(V==="0")q=`>=${V}.${K}.0${J} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.0${J} <${+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}${J} <${V}.${K}.${+W+1}-0`;else q=`>=${V}.${K}.${W}${J} <${V}.${+K+1}.0-0`;else q=`>=${V}.${K}.${W} <${+V+1}.0.0-0`;return g("caret return",q),q})},iQ=($,Z)=>{return g("replaceXRanges",$,Z),$.split(/\s+/).map((Q)=>sQ(Q,Z)).join(" ")},sQ=($,Z)=>{$=$.trim();let Q=Z.loose?J0[e.XRANGELOOSE]:J0[e.XRANGE];return $.replace(Q,(J,X,V,K,W,H)=>{g("xRange",$,J,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==="<")J="<0.0.0-0";else J="*";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";J=`${X+V}.${K}.${W}${H}`}else if(z)J=`>=${V}.0.0${H} <${+V+1}.0.0-0`;else if(G)J=`>=${V}.${K}.0${H} <${V}.${+K+1}.0-0`;return g("xRange return",J),J})},oQ=($,Z)=>{return g("replaceStars",$,Z),$.trim().replace(J0[e.STAR],"")},eQ=($,Z)=>{return g("replaceGTE0",$,Z),$.trim().replace(J0[Z.includePrerelease?e.GTE0PRE:e.GTE0],"")},tQ=($)=>(Z,Q,J,X,V,K,W,H,q,z,G,U)=>{if(X0(J))Q="";else if(X0(X))Q=`>=${J}.0.0${$?"-0":""}`;else if(X0(V))Q=`>=${J}.${X}.0${$?"-0":""}`;else if(K)Q=`>=${Q}`;else Q=`>=${Q}${$?"-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`${Q} ${H}`.trim()},$J=($,Z,Q)=>{for(let J=0;J<$.length;J++)if(!$[J].test(Z))return!1;if(Z.prerelease.length&&!Q.includePrerelease){for(let J=0;J<$.length;J++){if(g($[J].semver),$[J].semver===b2.ANY)continue;if($[J].semver.prerelease.length>0){let X=$[J].semver;if(X.major===Z.major&&X.minor===Z.minor&&X.patch===Z.patch)return!0}}return!1}return!0}});var x$=T((QH,k$)=>{var ZJ=y2(),QJ=($,Z,Q)=>{try{Z=new ZJ(Z,Q)}catch(J){return!1}return Z.test($)};k$.exports=QJ});var f2=T((JH,JJ)=>{JJ.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 g2=T((XH,m$)=>{/*!
6
- Copyright 2013 Lovell Fuller and others.
7
- SPDX-License-Identifier: Apache-2.0
8
- */var{spawnSync:c6}=v("child_process"),{createHash:XJ}=v("crypto"),b$=Z$(),VJ=x2(),KJ=x$(),v$=v6(),{config:WJ,engines:O$,optionalDependencies:HJ}=f2(),qJ=process.env.npm_package_config_libvips||WJ.libvips,f$=b$(qJ).version,YJ=["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"],l6={encoding:"utf8",shell:!0},zJ=($)=>{if($ instanceof Error)console.error(`sharp: Installation error: ${$.message}`);else console.log(`sharp: ${$}`)},h$=()=>v$.isNonGlibcLinuxSync()?v$.familySync():"",GJ=()=>`${process.platform}${h$()}-${process.arch}`,D4=()=>{if(g$())return"wasm32";let{npm_config_arch:$,npm_config_platform:Z,npm_config_libc:Q}=process.env,J=typeof Q==="string"?Q:h$();return`${Z||process.platform}${J}-${$||process.arch}`},jJ=()=>{try{return v(`@img/sharp-libvips-dev-${D4()}/include`)}catch{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/include");})()}catch{}}return""},UJ=()=>{try{return (()=>{throw new Error("Cannot require module "+"@img/sharp-libvips-dev/cplusplus");})()}catch{}return""},AJ=()=>{try{return v(`@img/sharp-libvips-dev-${D4()}/lib`)}catch{try{return v(`@img/sharp-libvips-${D4()}/lib`)}catch{}}return""},BJ=()=>{if(process.release?.name==="node"&&process.versions){if(!KJ(process.versions.node,O$.node))return{found:process.versions.node,expected:O$.node}}},g$=()=>{let{CC:$}=process.env;return Boolean($?.endsWith("/emcc"))},LJ=()=>{if(process.platform==="darwin"&&process.arch==="x64")return(c6("sysctl sysctl.proc_translated",l6).stdout||"").trim()==="sysctl.proc_translated: 1";return!1},y$=($)=>XJ("sha512").update($).digest("hex"),_J=()=>{try{let $=y$(`imgsharp-libvips-${D4()}`),Z=b$(HJ[`@img/sharp-libvips-${D4()}`],{includePrerelease:!0}).version;return y$(`${$}npm:${Z}`).slice(0,10)}catch{}return""},wJ=()=>c6(`node-gyp rebuild --directory=src ${g$()?"--nodedir=emscripten":""}`,{...l6,stdio:"inherit"}).status,d$=()=>{if(process.platform!=="win32")return(c6("pkg-config --modversion vips-cpp",{...l6,env:{...process.env,PKG_CONFIG_PATH:u$()}}).stdout||"").trim();else return""},u$=()=>{if(process.platform!=="win32")return[(c6('which brew >/dev/null 2>&1 && brew environment --plain | grep PKG_CONFIG_LIBDIR | cut -d" " -f2',l6).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""},h2=($,Z,Q)=>{if(Q)Q(`Detected ${Z}, skipping search for globally-installed libvips`);return $},RJ=($)=>{if(Boolean(process.env.SHARP_IGNORE_GLOBAL_LIBVIPS)===!0)return h2(!1,"SHARP_IGNORE_GLOBAL_LIBVIPS",$);if(Boolean(process.env.SHARP_FORCE_GLOBAL_LIBVIPS)===!0)return h2(!0,"SHARP_FORCE_GLOBAL_LIBVIPS",$);if(LJ())return h2(!1,"Rosetta",$);let Z=d$();return!!Z&&VJ(Z,f$)};m$.exports={minimumLibvipsVersion:f$,prebuiltPlatforms:YJ,buildPlatformArch:D4,buildSharpLibvipsIncludeDir:jJ,buildSharpLibvipsCPlusPlusDir:UJ,buildSharpLibvipsLibDir:AJ,isUnsupportedNodeRuntime:BJ,runtimePlatformArch:GJ,log:zJ,yarnLocator:_J,spawnRebuild:wJ,globalLibvipsVersion:d$,pkgConfigPath:u$,useGlobalLibvips:RJ}});var K6=T((KH,l$)=>{/*!
9
- Copyright 2013 Lovell Fuller and others.
10
- SPDX-License-Identifier: Apache-2.0
11
- */var{familySync:CJ,versionSync:NJ}=v6(),{runtimePlatformArch:PJ,isUnsupportedNodeRuntime:c$,prebuiltPlatforms:DJ,minimumLibvipsVersion:FJ}=g2(),z4=PJ(),MJ=[`../src/build/Release/sharp-${z4}.node`,"../src/build/Release/sharp-wasm32.node",`@img/sharp-${z4}/sharp.node`,"@img/sharp-wasm32/sharp.node"],d2,F4,V6=[];for(d2 of MJ)try{F4=v(d2);break}catch($){V6.push($)}if(F4&&d2.startsWith("@img/sharp-linux-x64")&&!F4._isUsingX64V2()){let $=Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");$.code="Unsupported CPU",V6.push($),F4=null}if(F4)l$.exports=F4;else{let[$,Z,Q]=["linux","darwin","win32"].map((V)=>z4.startsWith(V)),J=[`Could not load the "sharp" module using the ${z4} runtime`];V6.forEach((V)=>{if(V.code!=="MODULE_NOT_FOUND")J.push(`${V.code}: ${V.message}`)});let X=V6.map((V)=>V.message).join(" ");if(J.push("Possible solutions:"),c$()){let{found:V,expected:K}=c$();J.push("- Please upgrade Node.js:",` Found ${V}`,` Requires ${K}`)}else if(DJ.includes(z4)){let[V,K]=z4.split("-"),W=V.endsWith("musl")?" --libc=musl":"";J.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 J.push(`- Manually install libvips >= ${FJ}`,"- 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}=v(`@img/sharp-libvips-${z4}/package`),K=`${CJ()} ${NJ()}`,W=`${V.musl?"musl":"glibc"} ${V.musl||V.glibc}`;J.push("- Update your OS:",` Found ${K}`,` Requires ${W}`)}catch(V){}if($&&/\/snap\/core[0-9]{2}/.test(X))J.push("- Remove the Node.js Snap, which does not support native modules"," snap remove node");if(Z&&/Incompatible library version/.test(X))J.push("- Update Homebrew:"," brew update && brew upgrade vips");if(V6.some((V)=>V.code==="ERR_DLOPEN_DISABLED"))J.push("- Run Node.js without using the --no-addons flag");if(Q&&/The specified procedure could not be found/.test(X))J.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 J.push("- Consult the installation documentation:"," See https://sharp.pixelplumbing.com/install"),Error(J.join(`
12
- `))}});var a$=T((HH,p$)=>{/*!
13
- Copyright 2013 Lovell Fuller and others.
14
- SPDX-License-Identifier: Apache-2.0
15
- */var IJ=v("util"),u2=v("stream"),EJ=E0();K6();var SJ=IJ.debuglog("sharp"),TJ=($)=>{G4.queue.emit("change",$)},G4=function($,Z){if(arguments.length===1&&!EJ.defined($))throw Error("Invalid input");if(!(this instanceof G4))return new G4($,Z);return u2.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:(Q)=>{this.emit("warning",Q),SJ(Q)},queueListener:TJ},this.options.input=this._createInputDescriptor($,Z,{allowStream:!0}),this};Object.setPrototypeOf(G4.prototype,u2.Duplex.prototype);Object.setPrototypeOf(G4,u2.Duplex);function kJ(){let $=this.constructor.call(),{debuglog:Z,queueListener:Q,...J}=this.options;if($.options=structuredClone(J),$.options.debuglog=Z,$.options.queueListener=Q,this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),$.options.input.buffer=this.options.input.buffer,$.emit("finish")});return $}Object.assign(G4.prototype,{clone:kJ});p$.exports=G4});var i$=T((qH,n$)=>{/*!
16
- Copyright 2013 Lovell Fuller and others.
17
- SPDX-License-Identifier: Apache-2.0
18
- */var j=E0(),t0=K6(),xJ={left:"low",top:"low",low:"low",center:"centre",centre:"centre",right:"high",bottom:"high",high:"high"},vJ=["failOn","limitInputPixels","unlimited","animated","autoOrient","density","ignoreIcc","page","pages","sequentialRead","jp2","openSlide","pdf","raw","svg","tiff","failOnError","openSlideLevel","pdfBackground","tiffSubifd"];function r$($){let Z=vJ.filter((Q)=>j.defined($[Q])).map((Q)=>[Q,$[Q]]);return Z.length?Object.fromEntries(Z):void 0}function OJ($,Z,Q){let J={autoOrient:!1,failOn:"warning",limitInputPixels:268402689,ignoreIcc:!1,unlimited:!1,sequentialRead:!0};if(j.string($))J.file=$;else if(j.buffer($)){if($.length===0)throw Error("Input Buffer is empty");J.buffer=$}else if(j.arrayBuffer($)){if($.byteLength===0)throw Error("Input bit Array is empty");J.buffer=Buffer.from($,0,$.byteLength)}else if(j.typedArray($)){if($.length===0)throw Error("Input Bit Array is empty");J.buffer=Buffer.from($.buffer,$.byteOffset,$.byteLength)}else if(j.plainObject($)&&!j.defined(Z)){if(Z=$,r$(Z))J.buffer=[]}else if(!j.defined($)&&!j.defined(Z)&&j.object(Q)&&Q.allowStream)J.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))J.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"]))J.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))J.autoOrient=Z.autoOrient;else throw j.invalidParameterError("autoOrient","boolean",Z.autoOrient);if(j.defined(Z.density))if(j.inRange(Z.density,1,1e5))J.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))J.ignoreIcc=Z.ignoreIcc;else throw j.invalidParameterError("ignoreIcc","boolean",Z.ignoreIcc);if(j.defined(Z.limitInputPixels))if(j.bool(Z.limitInputPixels))J.limitInputPixels=Z.limitInputPixels?268402689:0;else if(j.integer(Z.limitInputPixels)&&j.inRange(Z.limitInputPixels,0,Number.MAX_SAFE_INTEGER))J.limitInputPixels=Z.limitInputPixels;else throw j.invalidParameterError("limitInputPixels","positive integer",Z.limitInputPixels);if(j.defined(Z.unlimited))if(j.bool(Z.unlimited))J.unlimited=Z.unlimited;else throw j.invalidParameterError("unlimited","boolean",Z.unlimited);if(j.defined(Z.sequentialRead))if(j.bool(Z.sequentialRead))J.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(J.rawWidth=Z.raw.width,J.rawHeight=Z.raw.height,J.rawChannels=Z.raw.channels,$.constructor){case Uint8Array:case Uint8ClampedArray:J.rawDepth="uchar";break;case Int8Array:J.rawDepth="char";break;case Uint16Array:J.rawDepth="ushort";break;case Int16Array:J.rawDepth="short";break;case Uint32Array:J.rawDepth="uint";break;case Int32Array:J.rawDepth="int";break;case Float32Array:J.rawDepth="float";break;case Float64Array:J.rawDepth="double";break;default:J.rawDepth="uchar";break}else throw Error("Expected width, height and channels for raw pixel input");if(J.rawPremultiplied=!1,j.defined(Z.raw.premultiplied))if(j.bool(Z.raw.premultiplied))J.rawPremultiplied=Z.raw.premultiplied;else throw j.invalidParameterError("raw.premultiplied","boolean",Z.raw.premultiplied);if(J.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}`);J.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))J.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))J.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))J.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))J.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))J.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))J.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))J.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))J.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))J.svgHighBitdepth=Z.svg.highBitdepth;else throw j.invalidParameterError("svg.highBitdepth","boolean",Z.svg.highBitdepth)}if(j.object(Z.pdf)&&j.defined(Z.pdf.background))J.pdfBackground=this._getBackgroundColourOption(Z.pdf.background);else if(j.defined(Z.pdfBackground))J.pdfBackground=this._getBackgroundColourOption(Z.pdfBackground);if(j.object(Z.jp2)&&j.defined(Z.jp2.oneshot))if(j.bool(Z.jp2.oneshot))J.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(J.createWidth=Z.create.width,J.createHeight=Z.create.height,J.createChannels=Z.create.channels,J.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}`);J.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(J.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(J.createNoiseMean=128,j.defined(Z.create.noise.mean))if(j.number(Z.create.noise.mean)&&j.inRange(Z.create.noise.mean,0,1e4))J.createNoiseMean=Z.create.noise.mean;else throw j.invalidParameterError("create.noise.mean","number between 0 and 10000",Z.create.noise.mean);if(J.createNoiseSigma=30,j.defined(Z.create.noise.sigma))if(j.number(Z.create.noise.sigma)&&j.inRange(Z.create.noise.sigma,0,1e4))J.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);J.createBackground=this._getBackgroundColourOption(Z.create.background)}else throw Error("Expected valid noise or background to create a new input image");delete J.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(J.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))J.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))J.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)J.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)J.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]))J.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))J.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))J.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))J.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))J.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"]))J.textWrap=Z.text.wrap;else throw j.invalidParameterError("text.wrap","one of: word, char, word-char, none",Z.text.wrap);delete J.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))J.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))J.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))J.joinShim=Z.join.shim;else throw j.invalidParameterError("join.shim","integer between 0 and 100000",Z.join.shim);if(j.defined(Z.join.background))J.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]))J.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]))J.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 J}function yJ($,Z,Q){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($),Q()}else Q(Error("Non-Buffer data on Writable Stream"));else Q(Error("Unexpected data on Writable Stream"))}function bJ(){if(this._isStreamInput())this.options.input.buffer=Buffer.concat(this.options.input.buffer)}function fJ(){return Array.isArray(this.options.input.buffer)}function hJ($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t0.metadata(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)})});else t0.metadata(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{let X=()=>{this._flattenBufferIn(),t0.metadata(this.options,(V,K)=>{if(V)J(j.nativeError(V,Z));else Q(K)})};if(this.writableFinished)X();else this.once("finish",X)});else return new Promise((Q,J)=>{t0.metadata(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})}function gJ($){let Z=Error();if(j.fn($)){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),t0.stats(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)})});else t0.stats(this.options,(Q,J)=>{if(Q)$(j.nativeError(Q,Z));else $(null,J)});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{this.on("finish",function(){this._flattenBufferIn(),t0.stats(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})});else return new Promise((Q,J)=>{t0.stats(this.options,(X,V)=>{if(X)J(j.nativeError(X,Z));else Q(V)})})}n$.exports=($)=>{Object.assign($.prototype,{_inputOptionsFromObject:r$,_createInputDescriptor:OJ,_write:yJ,_flattenBufferIn:bJ,_isStreamInput:fJ,metadata:hJ,stats:gJ}),$.align=xJ}});var Z9=T((YH,$9)=>{/*!
19
- Copyright 2013 Lovell Fuller and others.
20
- SPDX-License-Identifier: Apache-2.0
21
- */var F=E0(),o$={center:0,centre:0,north:1,east:2,south:3,west:4,northeast:5,southeast:6,southwest:7,northwest:8},e$={top:1,right:2,bottom:3,left:4,"right top":5,"right bottom":6,"left bottom":7,"left top":8},s$={background:"background",copy:"copy",repeat:"repeat",mirror:"mirror"},t$={entropy:16,attention:17},m2={nearest:"nearest",linear:"linear",cubic:"cubic",mitchell:"mitchell",lanczos2:"lanczos2",lanczos3:"lanczos3",mks2013:"mks2013",mks2021:"mks2021"},dJ={contain:"contain",cover:"cover",fill:"fill",inside:"inside",outside:"outside"},uJ={contain:"embed",cover:"crop",fill:"ignore_aspect",inside:"max",outside:"min"};function c2($){return $.angle%360!==0||$.rotationAngle!==0}function p6($){return $.width!==-1||$.height!==-1}function mJ($,Z,Q){if(p6(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(F.defined($))if(F.object($)&&!F.defined(Q))Q=$;else if(F.integer($)&&$>0)this.options.width=$;else throw F.invalidParameterError("width","positive integer",$);else this.options.width=-1;if(F.defined(Z))if(F.integer(Z)&&Z>0)this.options.height=Z;else throw F.invalidParameterError("height","positive integer",Z);else this.options.height=-1;if(F.object(Q)){if(F.defined(Q.width))if(F.integer(Q.width)&&Q.width>0)this.options.width=Q.width;else throw F.invalidParameterError("width","positive integer",Q.width);if(F.defined(Q.height))if(F.integer(Q.height)&&Q.height>0)this.options.height=Q.height;else throw F.invalidParameterError("height","positive integer",Q.height);if(F.defined(Q.fit)){let J=uJ[Q.fit];if(F.string(J))this.options.canvas=J;else throw F.invalidParameterError("fit","valid fit",Q.fit)}if(F.defined(Q.position)){let J=F.integer(Q.position)?Q.position:t$[Q.position]||e$[Q.position]||o$[Q.position];if(F.integer(J)&&(F.inRange(J,0,8)||F.inRange(J,16,17)))this.options.position=J;else throw F.invalidParameterError("position","valid position/gravity/strategy",Q.position)}if(this._setBackgroundColourOption("resizeBackground",Q.background),F.defined(Q.kernel))if(F.string(m2[Q.kernel]))this.options.kernel=m2[Q.kernel];else throw F.invalidParameterError("kernel","valid kernel name",Q.kernel);if(F.defined(Q.withoutEnlargement))this._setBooleanOption("withoutEnlargement",Q.withoutEnlargement);if(F.defined(Q.withoutReduction))this._setBooleanOption("withoutReduction",Q.withoutReduction);if(F.defined(Q.fastShrinkOnLoad))this._setBooleanOption("fastShrinkOnLoad",Q.fastShrinkOnLoad)}if(c2(this.options)&&p6(this.options))this.options.rotateBefore=!0;return this}function cJ($){if(F.integer($)&&$>0)this.options.extendTop=$,this.options.extendBottom=$,this.options.extendLeft=$,this.options.extendRight=$;else if(F.object($)){if(F.defined($.top))if(F.integer($.top)&&$.top>=0)this.options.extendTop=$.top;else throw F.invalidParameterError("top","positive integer",$.top);if(F.defined($.bottom))if(F.integer($.bottom)&&$.bottom>=0)this.options.extendBottom=$.bottom;else throw F.invalidParameterError("bottom","positive integer",$.bottom);if(F.defined($.left))if(F.integer($.left)&&$.left>=0)this.options.extendLeft=$.left;else throw F.invalidParameterError("left","positive integer",$.left);if(F.defined($.right))if(F.integer($.right)&&$.right>=0)this.options.extendRight=$.right;else throw F.invalidParameterError("right","positive integer",$.right);if(this._setBackgroundColourOption("extendBackground",$.background),F.defined($.extendWith))if(F.string(s$[$.extendWith]))this.options.extendWith=s$[$.extendWith];else throw F.invalidParameterError("extendWith","one of: background, copy, repeat, mirror",$.extendWith)}else throw F.invalidParameterError("extend","integer or object",$);return this}function lJ($){let Z=p6(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(Q){let J=$[Q];if(F.integer(J)&&J>=0)this.options[Q+(Q==="left"||Q==="top"?"Offset":"")+Z]=J;else throw F.invalidParameterError(Q,"integer",J)},this),c2(this.options)&&!p6(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 pJ($){if(this.options.trimThreshold=10,F.defined($))if(F.object($)){if(F.defined($.background))this._setBackgroundColourOption("trimBackground",$.background);if(F.defined($.threshold))if(F.number($.threshold)&&$.threshold>=0)this.options.trimThreshold=$.threshold;else throw F.invalidParameterError("threshold","positive number",$.threshold);if(F.defined($.lineArt))this._setBooleanOption("trimLineArt",$.lineArt)}else throw F.invalidParameterError("trim","object",$);if(c2(this.options))this.options.rotateBefore=!0;return this}$9.exports=($)=>{Object.assign($.prototype,{resize:mJ,extend:cJ,extract:lJ,trim:pJ}),$.gravity=o$,$.strategy=t$,$.kernel=m2,$.fit=dJ,$.position=e$}});var J9=T((zH,Q9)=>{/*!
22
- Copyright 2013 Lovell Fuller and others.
23
- SPDX-License-Identifier: Apache-2.0
24
- */var f=E0(),l2={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 aJ($){if(!Array.isArray($))throw f.invalidParameterError("images to composite","array",$);return this.options.composite=$.map((Z)=>{if(!f.object(Z))throw f.invalidParameterError("image to composite","object",Z);let Q=this._inputOptionsFromObject(Z),J={input:this._createInputDescriptor(Z.input,Q,{allowStream:!1}),blend:"over",tile:!1,left:0,top:0,hasOffset:!1,gravity:0,premultiplied:!1};if(f.defined(Z.blend))if(f.string(l2[Z.blend]))J.blend=l2[Z.blend];else throw f.invalidParameterError("blend","valid blend name",Z.blend);if(f.defined(Z.tile))if(f.bool(Z.tile))J.tile=Z.tile;else throw f.invalidParameterError("tile","boolean",Z.tile);if(f.defined(Z.left))if(f.integer(Z.left))J.left=Z.left;else throw f.invalidParameterError("left","integer",Z.left);if(f.defined(Z.top))if(f.integer(Z.top))J.top=Z.top;else throw f.invalidParameterError("top","integer",Z.top);if(f.defined(Z.top)!==f.defined(Z.left))throw Error("Expected both left and top to be set");else J.hasOffset=f.integer(Z.top)&&f.integer(Z.left);if(f.defined(Z.gravity))if(f.integer(Z.gravity)&&f.inRange(Z.gravity,0,8))J.gravity=Z.gravity;else if(f.string(Z.gravity)&&f.integer(this.constructor.gravity[Z.gravity]))J.gravity=this.constructor.gravity[Z.gravity];else throw f.invalidParameterError("gravity","valid gravity",Z.gravity);if(f.defined(Z.premultiplied))if(f.bool(Z.premultiplied))J.premultiplied=Z.premultiplied;else throw f.invalidParameterError("premultiplied","boolean",Z.premultiplied);return J}),this}Q9.exports=($)=>{$.prototype.composite=aJ,$.blend=l2}});var H9=T((GH,W9)=>{/*!
25
- Copyright 2013 Lovell Fuller and others.
26
- SPDX-License-Identifier: Apache-2.0
27
- */var A=E0(),X9={integer:"integer",float:"float",approximate:"approximate"};function rJ($,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 nJ(){return this.options.input.autoOrient=!0,this}function iJ($){return this.options.flip=A.bool($)?$:!0,this}function sJ($){return this.options.flop=A.bool($)?$:!0,this}function oJ($,Z){let Q=[].concat(...$);if(Q.length===4&&Q.every(A.number))this.options.affineMatrix=Q;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 eJ($,Z,Q){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(Q))if(A.number(Q)&&A.inRange(Q,0,1e4))this.options.sharpenM2=Q;else throw A.invalidParameterError("jagged","number between 0 and 10000",Q)}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 tJ($){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 $3($){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(X9[$.precision]))this.options.precision=X9[$.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 V9($){if(!A.defined($))this.options.dilateWidth=1;else if(A.integer($)&&$>0)this.options.dilateWidth=$;else throw A.invalidParameterError("dilate","positive integer",V9);return this}function K9($){if(!A.defined($))this.options.erodeWidth=1;else if(A.integer($)&&$>0)this.options.erodeWidth=$;else throw A.invalidParameterError("erode","positive integer",K9);return this}function Z3($){if(this.options.flatten=A.bool($)?$:!0,A.object($))this._setBackgroundColourOption("flattenBackground",$.background);return this}function Q3(){return this.options.unflatten=!0,this}function J3($,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 X3($){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 V3($){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 K3($){return this.normalise($)}function W3($){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 H3($){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,Q)=>Z+Q,0);if($.scale<1)$.scale=1;if(!A.integer($.offset))$.offset=0;return this.options.convKernel=$,this}function q3($,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 Y3($,Z,Q){if(this.options.boolean=this._createInputDescriptor($,Q),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 z3($,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 G3($){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 j3($){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}W9.exports=($)=>{Object.assign($.prototype,{autoOrient:nJ,rotate:rJ,flip:iJ,flop:sJ,affine:oJ,sharpen:eJ,erode:K9,dilate:V9,median:tJ,blur:$3,flatten:Z3,unflatten:Q3,gamma:J3,negate:X3,normalise:V3,normalize:K3,clahe:W3,convolve:H3,threshold:q3,boolean:Y3,linear:z3,recomb:G3,modulate:j3})}});var U9=T((jH,j9)=>{var{defineProperty:n2,getOwnPropertyDescriptor:U3,getOwnPropertyNames:A3}=Object,B3=Object.prototype.hasOwnProperty,L3=($,Z)=>{for(var Q in Z)n2($,Q,{get:Z[Q],enumerable:!0})},_3=($,Z,Q,J)=>{if(Z&&typeof Z==="object"||typeof Z==="function"){for(let X of A3(Z))if(!B3.call($,X)&&X!==Q)n2($,X,{get:()=>Z[X],enumerable:!(J=U3(Z,X))||J.enumerable})}return $},w3=($)=>_3(n2({},"__esModule",{value:!0}),$),q9={};L3(q9,{default:()=>v3});j9.exports=w3(q9);var v0={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]},Y9=Object.create(null);for(let $ in v0)if(Object.hasOwn(v0,$))Y9[v0[$]]=$;var q0={to:{},get:{}};q0.get=function($){let Z=$.slice(0,3).toLowerCase(),Q,J;switch(Z){case"hsl":{Q=q0.get.hsl($),J="hsl";break}case"hwb":{Q=q0.get.hwb($),J="hwb";break}default:{Q=q0.get.rgb($),J="rgb";break}}if(!Q)return null;return{model:J,value:Q}};q0.get.rgb=function($){if(!$)return null;let Z=/^#([a-f\d]{3,4})$/i,Q=/^#([a-f\d]{6})([a-f\d]{2})?$/i,J=/^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(Q)){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(J)){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(v0,W[1]))return null;return K=v0[W[1]],K[3]=1,K}else return null;for(H=0;H<3;H++)K[H]=$4(K[H],0,255);return K[3]=$4(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*)?\)$/,Q=$.match(Z);if(Q){let J=Number.parseFloat(Q[4]),X=(Number.parseFloat(Q[1])%360+360)%360,V=$4(Number.parseFloat(Q[2]),0,100),K=$4(Number.parseFloat(Q[3]),0,100),W=$4(Number.isNaN(J)?1:J,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*)?\)$/,Q=$.match(Z);if(Q){let J=Number.parseFloat(Q[4]),X=(Number.parseFloat(Q[1])%360+360)%360,V=$4(Number.parseFloat(Q[2]),0,100),K=$4(Number.parseFloat(Q[3]),0,100),W=$4(Number.isNaN(J)?1:J,0,1);return[X,V,K,W]}return null};q0.to.hex=function(...$){return"#"+a6($[0])+a6($[1])+a6($[2])+($[3]<1?a6(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),Q=Math.round($[1]/255*100),J=Math.round($[2]/255*100);return $.length<4||$[3]===1?"rgb("+Z+"%, "+Q+"%, "+J+"%)":"rgba("+Z+"%, "+Q+"%, "+J+"%, "+$[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 Y9[$.slice(0,3)]};function $4($,Z,Q){return Math.min(Math.max(Z,$),Q)}function a6($){let Z=Math.round($).toString(16).toUpperCase();return Z.length<2?"0"+Z:Z}var M4=q0,z9={};for(let $ of Object.keys(v0))z9[v0[$]]=$;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"]}},j4=C,c0=0.008856451679035631;function E4($){let Z=$>0.0031308?1.055*$**0.4166666666666667-0.055:$*12.92;return Math.min(Math.max(0,Z),1)}function S4($){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:Q}=C[$];delete C[$].channels,delete C[$].labels,Object.defineProperty(C[$],"channels",{value:Z}),Object.defineProperty(C[$],"labels",{value:Q})}C.rgb.hsl=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.min(Z,Q,J),V=Math.max(Z,Q,J),K=V-X,W,H;switch(V){case X:{W=0;break}case Z:{W=(Q-J)/K;break}case Q:{W=2+(J-Z)/K;break}case J:{W=4+(Z-Q)/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,Q,J,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),Q=G(W),J=G(H),q){case K:{X=J-Q;break}case W:{X=0.3333333333333333+Z-J;break}case H:{X=0.6666666666666666+Q-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],Q=$[1],J=$[2],X=C.rgb.hsl($)[0],V=0.00392156862745098*Math.min(Z,Math.min(Q,J));return J=1-0.00392156862745098*Math.max(Z,Math.max(Q,J)),[X,V*100,J*100]};C.rgb.oklab=function($){let Z=S4($[0]/255),Q=S4($[1]/255),J=S4($[2]/255),X=Math.cbrt(0.4122214708*Z+0.5363325363*Q+0.0514459929*J),V=Math.cbrt(0.2119034982*Z+0.6806995451*Q+0.1073969566*J),K=Math.cbrt(0.0883024619*Z+0.2817188376*Q+0.6299787005*J),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,Q=$[1]/255,J=$[2]/255,X=Math.min(1-Z,1-Q,1-J),V=(1-Z-X)/(1-X)||0,K=(1-Q-X)/(1-X)||0,W=(1-J-X)/(1-X)||0;return[V*100,K*100,W*100,X*100]};function R3($,Z){return($[0]-Z[0])**2+($[1]-Z[1])**2+($[2]-Z[2])**2}C.rgb.keyword=function($){let Z=z9[$];if(Z)return Z;let Q=Number.POSITIVE_INFINITY,J;for(let X of Object.keys(v0)){let V=v0[X],K=R3($,V);if(K<Q)Q=K,J=X}return J};C.keyword.rgb=function($){return v0[$]};C.rgb.xyz=function($){let Z=S4($[0]/255),Q=S4($[1]/255),J=S4($[2]/255),X=Z*0.4124564+Q*0.3575761+J*0.1804375,V=Z*0.2126729+Q*0.7151522+J*0.072175,K=Z*0.0193339+Q*0.119192+J*0.9503041;return[X*100,V*100,K*100]};C.rgb.lab=function($){let Z=C.rgb.xyz($),Q=Z[0],J=Z[1],X=Z[2];Q/=95.047,J/=100,X/=108.883,Q=Q>c0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,J=J>c0?J**0.3333333333333333:7.787*J+0.13793103448275862,X=X>c0?X**0.3333333333333333:7.787*X+0.13793103448275862;let V=116*J-16,K=500*(Q-J),W=200*(J-X);return[V,K,W]};C.hsl.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100,X,V;if(Q===0)return V=J*255,[V,V,V];let K=J<0.5?J*(1+Q):J+Q-J*Q,W=2*J-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],Q=$[1]/100,J=$[2]/100,X=Q,V=Math.max(J,0.01);J*=2,Q*=J<=1?J:2-J,X*=V<=1?V:2-V;let K=(J+Q)/2,W=J===0?2*X/(V+X):2*Q/(J+Q);return[Z,W*100,K*100]};C.hsv.rgb=function($){let Z=$[0]/60,Q=$[1]/100,J=$[2]/100,X=Math.floor(Z)%6,V=Z-Math.floor(Z),K=255*J*(1-Q),W=255*J*(1-Q*V),H=255*J*(1-Q*(1-V));switch(J*=255,X){case 0:return[J,H,K];case 1:return[W,J,K];case 2:return[K,J,H];case 3:return[K,W,J];case 4:return[H,K,J];case 5:return[J,K,W]}};C.hsv.hsl=function($){let Z=$[0],Q=$[1]/100,J=$[2]/100,X=Math.max(J,0.01),V,K;K=(2-Q)*J;let W=(2-Q)*X;return V=Q*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,Q=$[1]/100,J=$[2]/100,X=Q+J,V;if(X>1)Q/=X,J/=X;let K=Math.floor(6*Z),W=1-J;if(V=6*Z-K,(K&1)!==0)V=1-V;let H=Q+V*(W-Q),q,z,G;switch(K){default:case 6:case 0:{q=W,z=H,G=Q;break}case 1:{q=H,z=W,G=Q;break}case 2:{q=Q,z=W,G=H;break}case 3:{q=Q,z=H,G=W;break}case 4:{q=H,z=Q,G=W;break}case 5:{q=W,z=Q,G=H;break}}return[q*255,z*255,G*255]};C.cmyk.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=$[3]/100,V=1-Math.min(1,Z*(1-X)+X),K=1-Math.min(1,Q*(1-X)+X),W=1-Math.min(1,J*(1-X)+X);return[V*255,K*255,W*255]};C.xyz.rgb=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X,V,K;return X=Z*3.2404542+Q*-1.5371385+J*-0.4985314,V=Z*-0.969266+Q*1.8760108+J*0.041556,K=Z*0.0556434+Q*-0.2040259+J*1.0572252,X=E4(X),V=E4(V),K=E4(K),[X*255,V*255,K*255]};C.xyz.lab=function($){let Z=$[0],Q=$[1],J=$[2];Z/=95.047,Q/=100,J/=108.883,Z=Z>c0?Z**0.3333333333333333:7.787*Z+0.13793103448275862,Q=Q>c0?Q**0.3333333333333333:7.787*Q+0.13793103448275862,J=J>c0?J**0.3333333333333333:7.787*J+0.13793103448275862;let X=116*Q-16,V=500*(Z-Q),K=200*(Q-J);return[X,V,K]};C.xyz.oklab=function($){let Z=$[0]/100,Q=$[1]/100,J=$[2]/100,X=Math.cbrt(0.8189330101*Z+0.3618667424*Q-0.1288597137*J),V=Math.cbrt(0.0329845436*Z+0.9293118715*Q+0.0361456387*J),K=Math.cbrt(0.0482003018*Z+0.2643662691*Q+0.633851707*J),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,Q=$[1]/100,J=$[2]/100,X=(0.999999998*Z+0.396337792*Q+0.215803758*J)**3,V=(1.000000008*Z-0.105561342*Q-0.063854175*J)**3,K=(1.000000055*Z-0.089484182*Q-1.291485538*J)**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,Q=$[1]/100,J=$[2]/100,X=(Z+0.3963377774*Q+0.2158037573*J)**3,V=(Z-0.1055613458*Q-0.0638541728*J)**3,K=(Z-0.0894841775*Q-1.291485548*J)**3,W=E4(4.0767416621*X-3.3077115913*V+0.2309699292*K),H=E4(-1.2684380046*X+2.6097574011*V-0.3413193965*K),q=E4(-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],Q=$[1],J=$[2],X,V,K;V=(Z+16)/116,X=Q/500+V,K=V-J/200;let W=V**3,H=X**3,q=K**3;return V=W>c0?W:(V-0.13793103448275862)/7.787,X=H>c0?H:(X-0.13793103448275862)/7.787,K=q>c0?q:(K-0.13793103448275862)/7.787,X*=95.047,V*=100,K*=108.883,[X,V,K]};C.lab.lch=function($){let Z=$[0],Q=$[1],J=$[2],X;if(X=Math.atan2(J,Q)*360/2/Math.PI,X<0)X+=360;let K=Math.sqrt(Q*Q+J*J);return[Z,K,X]};C.lch.lab=function($){let Z=$[0],Q=$[1],X=$[2]/360*2*Math.PI,V=Q*Math.cos(X),K=Q*Math.sin(X);return[Z,V,K]};C.rgb.ansi16=function($,Z=null){let[Q,J,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(J/255)<<1|Math.round(Q/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],Q=$[1],J=$[2];if(Z>>4===Q>>4&&Q>>4===J>>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(Q/255*5)+Math.round(J/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 Q=(Math.trunc($>50)+1)*0.5,J=(Z&1)*Q*255,X=(Z>>1&1)*Q*255,V=(Z>>2&1)*Q*255;return[J,X,V]};C.ansi256.rgb=function($){if($=$[0],$>=232){let V=($-232)*10+8;return[V,V,V]}$-=16;let Z,Q=Math.floor($/36)/5*255,J=Math.floor((Z=$%36)/6)/5*255,X=Z%6/5*255;return[Q,J,X]};C.rgb.hex=function($){let Q=(((Math.round($[0])&255)<<16)+((Math.round($[1])&255)<<8)+(Math.round($[2])&255)).toString(16).toUpperCase();return"000000".slice(Q.length)+Q};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 Q=Z[0];if(Z[0].length===3)Q=[...Q].map((W)=>W+W).join("");let J=Number.parseInt(Q,16),X=J>>16&255,V=J>>8&255,K=J&255;return[X,V,K]};C.rgb.hcg=function($){let Z=$[0]/255,Q=$[1]/255,J=$[2]/255,X=Math.max(Math.max(Z,Q),J),V=Math.min(Math.min(Z,Q),J),K=X-V,W,H=K<1?V/(1-K):0;if(K<=0)W=0;else if(X===Z)W=(Q-J)/K%6;else if(X===Q)W=2+(J-Z)/K;else W=4+(Z-Q)/K;return W/=6,W%=1,[W*360,K*100,H*100]};C.hsl.hcg=function($){let Z=$[1]/100,Q=$[2]/100,J=Q<0.5?2*Z*Q:2*Z*(1-Q),X=0;if(J<1)X=(Q-0.5*J)/(1-J);return[$[0],J*100,X*100]};C.hsv.hcg=function($){let Z=$[1]/100,Q=$[2]/100,J=Z*Q,X=0;if(J<1)X=(Q-J)/(1-J);return[$[0],J*100,X*100]};C.hcg.rgb=function($){let Z=$[0]/360,Q=$[1]/100,J=$[2]/100;if(Q===0)return[J*255,J*255,J*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-Q)*J,[(Q*X[0]+H)*255,(Q*X[1]+H)*255,(Q*X[2]+H)*255]};C.hcg.hsv=function($){let Z=$[1]/100,Q=$[2]/100,J=Z+Q*(1-Z),X=0;if(J>0)X=Z/J;return[$[0],X*100,J*100]};C.hcg.hsl=function($){let Z=$[1]/100,J=$[2]/100*(1-Z)+0.5*Z,X=0;if(J>0&&J<0.5)X=Z/(2*J);else if(J>=0.5&&J<1)X=Z/(2*(1-J));return[$[0],X*100,J*100]};C.hcg.hwb=function($){let Z=$[1]/100,Q=$[2]/100,J=Z+Q*(1-Z);return[$[0],(J-Z)*100,(1-J)*100]};C.hwb.hcg=function($){let Z=$[1]/100,J=1-$[2]/100,X=J-Z,V=0;if(X<1)V=(J-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,J=((Z<<16)+(Z<<8)+Z).toString(16).toUpperCase();return"000000".slice(J.length)+J};C.rgb.gray=function($){return[($[0]+$[1]+$[2])/3/255*100]};function C3(){let $={},Z=Object.keys(j4);for(let{length:Q}=Z,J=0;J<Q;J++)$[Z[J]]={distance:-1,parent:null};return $}function N3($){let Z=C3(),Q=[$];Z[$].distance=0;while(Q.length>0){let J=Q.pop(),X=Object.keys(j4[J]);for(let{length:V}=X,K=0;K<V;K++){let W=X[K],H=Z[W];if(H.distance===-1)H.distance=Z[J].distance+1,H.parent=J,Q.unshift(W)}}return Z}function P3($,Z){return function(Q){return Z($(Q))}}function D3($,Z){let Q=[Z[$].parent,$],J=j4[Z[$].parent][$],X=Z[$].parent;while(Z[X].parent)Q.unshift(Z[X].parent),J=P3(j4[Z[X].parent][X],J),X=Z[X].parent;return J.conversion=Q,J}function F3($){let Z=N3($),Q={},J=Object.keys(Z);for(let{length:X}=J,V=0;V<X;V++){let K=J[V];if(Z[K].parent===null)continue;Q[K]=D3(K,Z)}return Q}var M3=F3,I4={},I3=Object.keys(j4);function E3($){let Z=function(...Q){let J=Q[0];if(J===void 0||J===null)return J;if(J.length>1)Q=J;return $(Q)};if("conversion"in $)Z.conversion=$.conversion;return Z}function S3($){let Z=function(...Q){let J=Q[0];if(J===void 0||J===null)return J;if(J.length>1)Q=J;let X=$(Q);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 I3){I4[$]={},Object.defineProperty(I4[$],"channels",{value:j4[$].channels}),Object.defineProperty(I4[$],"labels",{value:j4[$].labels});let Z=M3($),Q=Object.keys(Z);for(let J of Q){let X=Z[J];I4[$][J]=S3(X),I4[$][J].raw=E3(X)}}var z0=I4,G9=["keyword","gray","hex"],p2={};for(let $ of Object.keys(z0))p2[[...z0[$].labels].sort().join("")]=$;var a2={};function i($,Z){if(!(this instanceof i))return new i($,Z);if(Z&&Z in G9)Z=null;if(Z&&!(Z in z0))throw Error("Unknown model: "+Z);let Q,J;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=M4.get($);if(X===null)throw Error("Unable to parse color from string: "+$);this.model=X.model,J=z0[this.model].channels,this.color=X.value.slice(0,J),this.valpha=typeof X.value[J]==="number"?X.value[J]:1}else if($.length>0){this.model=Z||"rgb",J=z0[this.model].channels;let X=Array.prototype.slice.call($,0,J);this.color=r2(X,J),this.valpha=typeof $[J]==="number"?$[J]: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 p2))throw Error("Unable to parse color from object: "+JSON.stringify($));this.model=p2[V];let{labels:K}=z0[this.model],W=[];for(Q=0;Q<K.length;Q++)W.push($[K[Q]]);this.color=r2(W)}if(a2[this.model]){J=z0[this.model].channels;for(Q=0;Q<J;Q++){let X=a2[this.model][Q];if(X)this.color[Q]=X(this.color[Q])}}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 M4.to?this:this.rgb();Z=Z.round(typeof $==="number"?$:1);let Q=Z.valpha===1?Z.color:[...Z.color,this.valpha];return M4.to[Z.model](...Q)},percentString($){let Z=this.rgb().round(typeof $==="number"?$:1),Q=Z.valpha===1?Z.color:[...Z.color,this.valpha];return M4.to.rgb.percent(...Q)},array(){return this.valpha===1?[...this.color]:[...this.color,this.valpha]},object(){let $={},{channels:Z}=z0[this.model],{labels:Q}=z0[this.model];for(let J=0;J<Z;J++)$[Q[J]]=this.color[J];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(k3($)),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 z0[this.model].keyword(this.color)},hex($){if($!==void 0)return new i($);return M4.to.hex(...this.rgb().round().color)},hexa($){if($!==void 0)return new i($);let Z=this.rgb().round().color,Q=Math.round(this.valpha*255).toString(16).toUpperCase();if(Q.length===1)Q="0"+Q;return M4.to.hex(...Z)+Q},rgbNumber(){let $=this.rgb().color;return($[0]&255)<<16|($[1]&255)<<8|$[2]&255},luminosity(){let $=this.rgb().color,Z=[];for(let[Q,J]of $.entries()){let X=J/255;Z[Q]=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(),Q=$.luminosity();if(Z>Q)return(Z+0.05)/(Q+0.05);return(Q+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(),Q=Z.color[0];return Q=(Q+$)%360,Q=Q<0?360+Q:Q,Z.color[0]=Q,Z},mix($,Z){if(!$||!$.rgb)throw Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof $);let Q=$.rgb(),J=this.rgb(),X=Z===void 0?0.5:Z,V=2*X-1,K=Q.alpha()-J.alpha(),W=((V*K===-1?V:(V+K)/(1+V*K))+1)/2,H=1-W;return i.rgb(W*Q.red()+H*J.red(),W*Q.green()+H*J.green(),W*Q.blue()+H*J.blue(),Q.alpha()*X+J.alpha()*(1-X))}};for(let $ of Object.keys(z0)){if(G9.includes($))continue;let{channels:Z}=z0[$];i.prototype[$]=function(...Q){if(this.model===$)return new i(this);if(Q.length>0)return new i(Q,$);return new i([...x3(z0[this.model][$].raw(this.color)),this.valpha],$)},i[$]=function(...Q){let J=Q[0];if(typeof J==="number")J=r2(Q,Z);return new i(J,$)}}function T3($,Z){return Number($.toFixed(Z))}function k3($){return function(Z){return T3(Z,$)}}function u($,Z,Q){$=Array.isArray($)?$:[$];for(let J of $)(a2[J]||=[])[Z]=Q;return $=$[0],function(J){let X;if(J!==void 0){if(Q)J=Q(J);return X=this[$](),X.color[Z]=J,X}if(X=this[$]().color[Z],Q)X=Q(X);return X}}function p($){return function(Z){return Math.max(0,Math.min($,Z))}}function x3($){return Array.isArray($)?$:[$]}function r2($,Z){for(let Q=0;Q<Z;Q++)if(typeof $[Q]!=="number")$[Q]=0;return $}var v3=i});var B9=T((UH,A9)=>{A9.exports=U9().default});var R9=T((AH,w9)=>{/*!
28
- Copyright 2013 Lovell Fuller and others.
29
- SPDX-License-Identifier: Apache-2.0
30
- */var O3=B9(),l0=E0(),L9={multiband:"multiband","b-w":"b-w",bw:"b-w",cmyk:"cmyk",srgb:"srgb"};function y3($){return this._setBackgroundColourOption("tint",$),this}function b3($){return this.options.greyscale=l0.bool($)?$:!0,this}function f3($){return this.greyscale($)}function h3($){if(!l0.string($))throw l0.invalidParameterError("colourspace","string",$);return this.options.colourspacePipeline=$,this}function g3($){return this.pipelineColourspace($)}function d3($){if(!l0.string($))throw l0.invalidParameterError("colourspace","string",$);return this.options.colourspace=$,this}function u3($){return this.toColourspace($)}function _9($){if(l0.object($)||l0.string($)&&$.length>=3&&$.length<=200){let Z=O3($);return[Z.red(),Z.green(),Z.blue(),Math.round(Z.alpha()*255)]}else throw l0.invalidParameterError("background","object or string",$)}function m3($,Z){if(l0.defined(Z))this.options[$]=_9(Z)}w9.exports=($)=>{Object.assign($.prototype,{tint:y3,greyscale:b3,grayscale:f3,pipelineColourspace:h3,pipelineColorspace:g3,toColourspace:d3,toColorspace:u3,_getBackgroundColourOption:_9,_setBackgroundColourOption:m3}),$.colourspace=L9,$.colorspace=L9}});var N9=T((BH,C9)=>{/*!
31
- Copyright 2013 Lovell Fuller and others.
32
- SPDX-License-Identifier: Apache-2.0
33
- */var O0=E0(),c3={and:"and",or:"or",eor:"eor"};function l3(){return this.options.removeAlpha=!0,this}function p3($){if(O0.defined($))if(O0.number($)&&O0.inRange($,0,1))this.options.ensureAlpha=$;else throw O0.invalidParameterError("alpha","number between 0 and 1",$);else this.options.ensureAlpha=1;return this}function a3($){let Z={red:0,green:1,blue:2,alpha:3};if(Object.keys(Z).includes($))$=Z[$];if(O0.integer($)&&O0.inRange($,0,4))this.options.extractChannel=$;else throw O0.invalidParameterError("channel","integer or one of: red, green, blue, alpha",$);return this}function r3($,Z){if(Array.isArray($))$.forEach(function(Q){this.options.joinChannelIn.push(this._createInputDescriptor(Q,Z))},this);else this.options.joinChannelIn.push(this._createInputDescriptor($,Z));return this}function n3($){if(O0.string($)&&O0.inArray($,["and","or","eor"]))this.options.bandBoolOp=$;else throw O0.invalidParameterError("boolOp","one of: and, or, eor",$);return this}C9.exports=($)=>{Object.assign($.prototype,{removeAlpha:l3,ensureAlpha:p3,extractChannel:a3,joinChannel:r3,bandbool:n3}),$.bool=c3}});var I9=T((LH,M9)=>{/*!
34
- Copyright 2013 Lovell Fuller and others.
35
- SPDX-License-Identifier: Apache-2.0
36
- */var i2=v("path"),Y=E0(),T4=K6(),P9=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"]]),i3=/\.(jp[2x]|j2[kc])$/i,D9=()=>Error("JP2 output requires libvips with support for OpenJPEG"),F9=($)=>1<<31-Math.clz32(Math.ceil(Math.log2($)));function s3($,Z){let Q;if(!Y.string($))Q=Error("Missing output file path");else if(Y.string(this.options.input.file)&&i2.resolve(this.options.input.file)===i2.resolve($))Q=Error("Cannot use same file for input and output");else if(i3.test(i2.extname($))&&!this.constructor.format.jp2k.output.file)Q=D9();if(Q)if(Y.fn(Z))Z(Q);else return Promise.reject(Q);else{this.options.fileOut=$;let J=Error();return this._pipeline(Z,J)}return this}function o3($,Z){if(Y.object($))this._setBooleanOption("resolveWithObject",$.resolveWithObject);else if(this.options.resolveWithObject)this.options.resolveWithObject=!1;this.options.fileOut="";let Q=Error();return this._pipeline(Y.fn($)?$:Z,Q)}function e3(){return this.options.keepMetadata|=1,this}function t3($){if(Y.object($))for(let[Z,Q]of Object.entries($))if(Y.object(Q))for(let[J,X]of Object.entries(Q))if(Y.string(X))this.options.withExif[`exif-${Z.toLowerCase()}-${J}`]=X;else throw Y.invalidParameterError(`${Z}.${J}`,"string",X);else throw Y.invalidParameterError(Z,"object",Q);else throw Y.invalidParameterError("exif","object",$);return this.options.withExifMerge=!1,this.keepExif()}function $X($){return this.withExif($),this.options.withExifMerge=!0,this}function ZX(){return this.options.keepMetadata|=8,this}function QX($,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 JX(){return this.options.keepMetadata|=2,this}function XX($){if(Y.string($)&&$.length>0)this.options.withXmp=$,this.options.keepMetadata|=2;else throw Y.invalidParameterError("xmp","non-empty string",$);return this}function VX(){return this.options.keepMetadata=31,this}function KX($){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 WX($,Z){let Q=P9.get((Y.object($)&&Y.string($.id)?$.id:$).toLowerCase());if(!Q)throw Y.invalidParameterError("format",`one of: ${[...P9.keys()].join(", ")}`,$);return this[Q](Z)}function HX($){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 Q=Y.bool($.trellisQuantization)?$.trellisQuantization:$.trellisQuantisation;if(Y.defined(Q))this._setBooleanOption("jpegTrellisQuantisation",Q);if(Y.defined($.overshootDeringing))this._setBooleanOption("jpegOvershootDeringing",$.overshootDeringing);let J=Y.bool($.optimizeScans)?$.optimizeScans:$.optimiseScans;if(Y.defined(J)){if(this._setBooleanOption("jpegOptimiseScans",J),J)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 qX($){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=F9(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 YX($){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 s2($,this.options),this._updateFormatOut("webp",$)}function zX($){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=F9(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 s2($,this.options),this._updateFormatOut("gif",$)}function GX($){if(!this.constructor.format.jp2k.output.buffer)throw D9();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 s2($,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((Q)=>Y.inRange(Q,0,65535)))Z.delay=$.delay;else throw Y.invalidParameterError("delay","integer or an array of integers between 0 and 65535",$.delay)}function jX($){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 UX($){return this.heif({...$,compression:"av1"})}function AX($){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 BX($){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 s2($,this.options),this._updateFormatOut("jxl",$)}function LX($){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 _X($){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 wX($){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 RX($,Z){if(!(Y.object(Z)&&Z.force===!1))this.options.formatOut=$;return this}function CX($,Z){if(Y.bool(Z))this.options[$]=Z;else throw Y.invalidParameterError($,"boolean",Z)}function NX(){if(!this.options.streamOut){this.options.streamOut=!0;let $=Error();this._pipeline(void 0,$)}}function PX($,Z){if(typeof $==="function"){if(this._isStreamInput())this.on("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(Q,J,X)=>{if(Q)$(Y.nativeError(Q,Z));else $(null,J,X)})});else T4.pipeline(this.options,(Q,J,X)=>{if(Q)$(Y.nativeError(Q,Z));else $(null,J,X)});return this}else if(this.options.streamOut){if(this._isStreamInput()){if(this.once("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(Q,J,X)=>{if(Q)this.emit("error",Y.nativeError(Q,Z));else this.emit("info",X),this.push(J);this.push(null),this.on("end",()=>this.emit("close"))})}),this.streamInFinished)this.emit("finish")}else T4.pipeline(this.options,(Q,J,X)=>{if(Q)this.emit("error",Y.nativeError(Q,Z));else this.emit("info",X),this.push(J);this.push(null),this.on("end",()=>this.emit("close"))});return this}else if(this._isStreamInput())return new Promise((Q,J)=>{this.once("finish",()=>{this._flattenBufferIn(),T4.pipeline(this.options,(X,V,K)=>{if(X)J(Y.nativeError(X,Z));else if(this.options.resolveWithObject)Q({data:V,info:K});else Q(V)})})});else return new Promise((Q,J)=>{T4.pipeline(this.options,(X,V,K)=>{if(X)J(Y.nativeError(X,Z));else if(this.options.resolveWithObject)Q({data:V,info:K});else Q(V)})})}M9.exports=($)=>{Object.assign($.prototype,{toFile:s3,toBuffer:o3,keepExif:e3,withExif:t3,withExifMerge:$X,keepIccProfile:ZX,withIccProfile:QX,keepXmp:JX,withXmp:XX,keepMetadata:VX,withMetadata:KX,toFormat:WX,jpeg:HX,jp2:GX,png:qX,webp:YX,tiff:jX,avif:UX,heif:AX,jxl:BX,gif:zX,raw:LX,tile:_X,timeout:wX,_updateFormatOut:RX,_setBooleanOption:CX,_read:NX,_pipeline:PX})}});var k9=T((_H,T9)=>{/*!
37
- Copyright 2013 Lovell Fuller and others.
38
- SPDX-License-Identifier: Apache-2.0
39
- */var DX=v("events"),r6=v6(),B0=E0(),{runtimePlatformArch:FX}=g2(),V0=K6(),E9=FX(),o2=V0.libvipsVersion(),Z4=V0.format();Z4.heif.output.alias=["avif","heic"];Z4.jpeg.output.alias=["jpe","jpg"];Z4.tiff.output.alias=["tif"];Z4.jp2k.output.alias=["j2c","j2k","jp2","jpx"];var MX={nearest:"nearest",bilinear:"bilinear",bicubic:"bicubic",locallyBoundedBicubic:"lbb",nohalo:"nohalo",vertexSplitQuadraticBasisSpline:"vsqbs"},k4={vips:o2.semver};if(!o2.isGlobal)if(!o2.isWasm)try{k4=v(`@img/sharp-${E9}/versions`)}catch($){try{k4=v(`@img/sharp-libvips-${E9}/versions`)}catch(Z){}}else try{k4=(()=>{throw new Error("Cannot require module "+"@img/sharp-wasm32/versions");})()}catch($){}k4.sharp=f2().version;if(k4.heif&&Z4.heif)Z4.heif.input.fileSuffix=[".avif"],Z4.heif.output.alias=["avif"];function S9($){if(B0.bool($))if($)return V0.cache(50,20,100);else return V0.cache(0,0,0);else if(B0.object($))return V0.cache($.memory,$.files,$.items);else return V0.cache()}S9(!0);function IX($){return V0.concurrency(B0.integer($)?$:null)}if(r6.familySync()===r6.GLIBC&&!V0._isUsingJemalloc())V0.concurrency(1);else if(r6.familySync()===r6.MUSL&&V0.concurrency()===1024)V0.concurrency(v("os").availableParallelism());var EX=new DX.EventEmitter;function SX(){return V0.counters()}function TX($){return V0.simd(B0.bool($)?$:null)}function kX($){if(B0.object($))if(Array.isArray($.operation)&&$.operation.every(B0.string))V0.block($.operation,!0);else throw B0.invalidParameterError("operation","Array<string>",$.operation);else throw B0.invalidParameterError("options","object",$)}function xX($){if(B0.object($))if(Array.isArray($.operation)&&$.operation.every(B0.string))V0.block($.operation,!1);else throw B0.invalidParameterError("operation","Array<string>",$.operation);else throw B0.invalidParameterError("options","object",$)}T9.exports=($)=>{$.cache=S9,$.concurrency=IX,$.counters=SX,$.simd=TX,$.format=Z4,$.interpolators=MX,$.versions=k4,$.queue=EX,$.block=kX,$.unblock=xX}});var v9=T((RH,x9)=>{/*!
40
- Copyright 2013 Lovell Fuller and others.
41
- SPDX-License-Identifier: Apache-2.0
42
- */var p0=a$();i$()(p0);Z9()(p0);J9()(p0);H9()(p0);R9()(p0);N9()(p0);I9()(p0);k9()(p0);x9.exports=p0});var Y6={enabled:!0,ttl:"1h",cacheSystemPrompt:!0,cacheTools:!0,minTokensForCache:1024},i9={low:1024,medium:4096,high:16384,max:1e5},CV={enabled:!1,effort:"medium",interleaved:!0};function X5($,Z){if($.budgetTokens)return $.budgetTokens;let Q=$.effort||"medium",J=i9[Q],X=$.modelMultiplier??(Z.includes("opus")?2:1);return Math.min(J*X,1e5)}function V5($){return $.includes("claude-opus-4")||$.includes("claude-sonnet-4")||$.includes("claude-haiku-4")||$.includes("claude-4")}var NV={"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 s9={maxRetries:3,baseDelayMs:1000,maxDelayMs:30000,jitterFactor:0.2,retryableStatusCodes:[429,500,502,503,504,529],onRetry:void 0};function o9($,Z,Q,J){let X=Z*Math.pow(2,$),V=X*J*(Math.random()*2-1);return Math.min(X+V,Q)}function e9($,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 Q of Z)if($.message.includes(String(Q)))return!0;return!1}function t9($){return new Promise((Z)=>setTimeout(Z,$))}async function K5($,Z={}){let Q={...s9,...Z},J=null;for(let X=0;X<=Q.maxRetries;X++)try{return await $()}catch(V){if(J=V instanceof Error?V:Error(String(V)),X<Q.maxRetries&&e9(J,Q.retryableStatusCodes)){let K=o9(X,Q.baseDelayMs,Q.maxDelayMs,Q.jitterFactor);if(Q.onRetry)Q.onRetry(X+1,J,K);else console.warn(`\x1B[33mRetry ${X+1}/${Q.maxRetries} after ${K}ms: ${J.message}\x1B[0m`);await t9(K)}else throw J}throw J||Error("Max retries exceeded")}var W5={"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 $7($,Z){let Q=W5[$]??W5["claude-sonnet-4-6"],J=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=J/1e6*Q.input,H=X/1e6*Q.cache_read,q=V/1e6*Q.cache_write,z=K/1e6*Q.output,G=W+H+q+z,L=(X+V)/1e6*(Q.input-Q.cache_read);return{costUSD:G,estimatedSavingsUSD:L}}function Z7($,Z){if(!$||!Z.enabled||!Z.cacheSystemPrompt)return typeof $==="string"?$:void 0;if(Array.isArray($)){let Q=[...$];if(Q.length>0){let J=Q[Q.length-1];if(J&&J.type==="text")Q[Q.length-1]={type:"text",text:J.text,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return Q}return[{type:"text",text:$,cache_control:{type:"ephemeral",ttl:Z.ttl}}]}function Q7($,Z){if(!Z.enabled)return $;let Q=[];for(let J=0;J<$.length;J++){let X=$[J],V=[];for(let K=0;K<X.content.length;K++){let W=X.content[K],H=K===X.content.length-1,q=J===$.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)}Q.push({...X,content:V})}if(Q.length>0&&Z.enabled){let J=Q[Q.length-1],X=J.content[J.content.length-1];if(X&&!("cache_control"in X))J.content[J.content.length-1]={...X,cache_control:{type:"ephemeral",ttl:Z.ttl}}}return Q}function J7($){let Z=$.cache_read_input_tokens??0,Q=$.cache_creation_input_tokens??0,J=Z+Q,X=Z>0?1:0,V=Q>0?1:0,K=X+V;return{cacheHits:X,cacheMisses:V,totalCacheReadTokens:Z,totalCacheWriteTokens:Q,cacheHitRate:K>0?X/K:0,estimatedSavingsUSD:0}}async function H5($,Z){let{apiKey:Q,model:J="claude-sonnet-4-6",maxTokens:X=4096,tools:V,systemPrompt:K,cacheConfig:W=Y6,thinking:H,extendedThinking:q,onToken:z,onThinking:G,onRedactedThinking:U,onToolUse:L,signal:B}=Z,_=Date.now(),R=0,w=!0,D=0,I=Q7($,W),S=Z7(K,W),M={model:J,max_tokens:X,messages:I.map((h)=>({role:h.role,content:h.content})),stream:!0};if(S)M.system=S;if(V&&V.length>0)M.tools=V;let k=`${process.env.ANTHROPIC_BASE_URL||"https://api.anthropic.com"}/v1/messages`,l={"Content-Type":"application/json","x-api-key":Q,"anthropic-version":"2023-06-01"};if(((q?.enabled??!1)||H&&H.type!=="disabled")&&V5(J)){let h;if(q?.budgetTokens)h=q.budgetTokens;else if(H?.type==="enabled")h=H.budget_tokens;else{let n0=q?.effort||"medium";h=X5({enabled:!0,effort:n0,modelMultiplier:J.includes("opus")?2:1},J)}h=Math.max(1024,Math.min(h,1e5)),M.thinking={type:"enabled",budget_tokens:h};let D0=["extended-thinking-2025-01-24"];if(q?.interleaved!==!1)D0.push("interleaved-thinking-2025-01-24");l["anthropic-beta"]=D0.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,D0,n0)=>{console.log(`\x1B[33mAPI retry ${h}/3 after ${n0}ms: ${D0.message}\x1B[0m`)}},a0=await K5(async()=>{let h=await fetch(k,{method:"POST",headers:l,body:JSON.stringify(M),signal:B});if(!h.ok&&t.retryableStatusCodes?.includes(h.status)){let D0=await h.text();throw Error(`API error: ${h.status} - ${D0}`)}return h},t);if(!a0.ok){let h=await a0.text();throw Error(`API error: ${a0.status} - ${h}`)}if(!a0.body)throw Error("No response body");let x4=a0.body.getReader(),H6=new TextDecoder,N0=null,y0=[],s={input_tokens:0,output_tokens:0},r0=null,L0=null,b0=null,W0=null,U4="",Z5="";try{let h="";while(!0){let{done:D0,value:n0}=await x4.read();if(D0)break;h+=H6.decode(n0,{stream:!0});let y4=h.split(`
43
- `);h=y4.pop()||"";for(let A4 of y4){if(!A4.startsWith("data: "))continue;let b4=A4.slice(6);if(!b4)continue;try{let O=JSON.parse(b4);switch(O.type){case"message_start":{let y=O.message;N0=y,s=y.usage;break}case"content_block_start":{let y=O.content_block;if(y.type==="text")r0={type:"text",text:""};else if(y.type==="thinking")L0={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:{}},U4="";break}case"content_block_delta":{let y=O.delta;if(y.type==="text_delta"&&r0){let x=y.text;if(r0.text+=x,z?.(x),w)R=Date.now()-_,w=!1}else if(y.type==="thinking_delta"&&L0){let x=y.thinking;L0.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)U4+=y.partial_json;break}case"content_block_stop":{if(r0!==null)y0.push(r0),r0=null;else if(L0!==null)y0.push(L0),L0=null;else if(b0!==null)y0.push(b0),U?.(b0.data),b0=null;else if(W0!==null){try{W0.input=JSON.parse(U4)}catch{W0.input={}}y0.push(W0),L?.({id:W0.id,name:W0.name,input:W0.input}),W0=null,U4=""}break}case"message_delta":{let y=O;if(y.usage)s.output_tokens=y.usage.output_tokens;if(N0&&y.delta?.stop_reason)N0.stop_reason=y.delta.stop_reason;break}case"message_stop":break}}catch{}}}}finally{x4.releaseLock()}if(!N0)throw Error("No message received from API");N0.content=y0;let{costUSD:f0,estimatedSavingsUSD:v4}=$7(J,s),P0=J7(s);P0.estimatedSavingsUSD=v4;let O4=Date.now()-_;return{message:N0,usage:s,cacheMetrics:P0,costUSD:f0,durationMs:O4,ttftMs:R||O4,thinkingTokens:D}}import*as q5 from"readline";var X7={Read:"low",Glob:"low",Grep:"low",Task:"low",Write:"medium",Edit:"medium",NotebookEdit:"medium",Bash:"high"},V7=[/\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 K7($,Z){let Q=X7[$]??"medium";if($==="Bash"){let J=String(Z.command??"");for(let X of V7)if(X.test(J))return"critical";if(/\bsudo\b/.test(J)||/\bchmod\b/.test(J))Q="high"}if($==="Write"||$==="Edit"){let J=String(Z.file_path??Z.path??"");if(/\.(env|pem|key|secret|credentials)/.test(J))Q="high";if(/\/\.ssh\//.test(J)||/\/\.gnupg\//.test(J))Q="critical"}return Q}function W7($,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 s6{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 Q=this.getCacheKey($,Z),J=this.cache[Q];if(J&&Date.now()-J.timestamp<this.cacheTimeout){if(J.decision==="allowAlways")return{decision:"allow",reason:"Previously approved (always)"};if(J.decision==="denyAlways")return{decision:"deny",reason:"Previously denied (always)"}}let X=K7($,Z),V=W7($,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[Q]={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 Q=String(Z.command??"").slice(0,100);return`${$}:${Q}`}return $}async defaultPrompt($){return new Promise((Z)=>{let Q=q5.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";Q.question(`Allow? ${K}: `,(W)=>{switch(Q.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 o6={readOnly:["Read","Glob","Grep","Task"],fileEdit:["Write","Edit","NotebookEdit"],system:["Bash"],network:[]};function TV($){return o6.readOnly.includes($)}function kV($){return o6.fileEdit.includes($)}function xV($){return o6.system.includes($)}var t6={tokenWarningThreshold:0.8,costUpdateInterval:5,toolSummaryInterval:3,envInfoOnStart:!0},e6={WARNING:0.8,CRITICAL:0.9,EMERGENCY:0.95};function H7($){let{current:Z,max:Q,threshold:J=e6.WARNING}=$;if(Q<=0)return"";let X=Z/Q;if(X<J)return"";let V=Q-Z,K=Math.round(X*100),W,H;if(X>=e6.EMERGENCY)W="emergency",H="\uD83D\uDEA8";else if(X>=e6.CRITICAL)W="critical",H="\u26A0\uFE0F";else W="warning",H="\u26A1";let q=[`${H} Token Usage ${W.toUpperCase()}`,"",`Current: ${Z.toLocaleString()} / ${Q.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 q7($){let{cost:Z,previousCost:Q=0,currency:J="USD"}=$,X=Y7(J),V=Y5(Z,X),K=Z-Q,W=Y5(Math.abs(K),X),H=["\uD83D\uDCB0 Cost Update","",`Total: ${V} ${J}`];if(K!==0){let q=K>0?"+":"-";H.push(`This turn: ${q}${W} ${J}`)}return H.join(`
45
- `)}function Y5($,Z){if($<0.01)return`${Z}${$.toFixed(4)}`;else if($<1)return`${Z}${$.toFixed(3)}`;return`${Z}${$.toFixed(2)}`}function Y7($){return{USD:"$",EUR:"\u20AC",GBP:"\xA3",JPY:"\xA5"}[$]||$}function z7($){let{tools:Z,maxDisplay:Q=10}=$;if(Z.length===0)return"No tools used this session.";let J=new Map;for(let W of Z){let H=J.get(W.name)||0;J.set(W.name,H+1)}let X=[...J.entries()].sort((W,H)=>H[1]-W[1]),V=[`\uD83D\uDD27 Tool Usage Summary (${Z.length} total calls)`,""],K=X.slice(0,Q);for(let[W,H]of K)V.push(` \u2022 ${W}: ${H} call${H===1?"":"s"}`);if(X.length>Q){let W=X.length-Q;V.push(` ... and ${W} more tool${W===1?"":"s"}`)}return V.join(`
46
- `)}function G7($){let{workingDirectory:Z,gitStatus:Q,platform:J=process.platform,shell:X=process.env.SHELL||"unknown"}=$,V=["\uD83D\uDCCD Environment Information","",`Working Directory: ${Z}`,`Platform: ${J}`,`Shell: ${X}`];if(Q){if(V.push(""),V.push("Git Status:"),V.push(` Branch: ${Q.branch}`),Q.ahead>0||Q.behind>0)V.push(` Ahead: ${Q.ahead}, Behind: ${Q.behind}`);let K=Q.staged.length+Q.unstaged.length+Q.untracked.length+Q.conflicted.length;if(K>0){if(V.push(` Changes: ${K} file${K===1?"":"s"}`),Q.staged.length>0)V.push(` Staged: ${Q.staged.length}`);if(Q.unstaged.length>0)V.push(` Unstaged: ${Q.unstaged.length}`);if(Q.untracked.length>0)V.push(` Untracked: ${Q.untracked.length}`);if(Q.conflicted.length>0)V.push(` Conflicted: ${Q.conflicted.length}`)}else V.push(" Working tree clean")}return V.join(`
47
- `)}function z5($){let{usage:Z,maxTokens:Q,totalCost:J,previousCost:X,toolsUsed:V,workingDirectory:K,gitStatus:W,turnNumber:H,config:q}=$,z={...t6,...q},G=[],U=Z.input_tokens+Z.output_tokens,L=H7({current:U,max:Q,threshold:z.tokenWarningThreshold});if(L)G.push(L);if(H%z.costUpdateInterval===0){let B=q7({cost:J,previousCost:X});G.push(B)}if(H%z.toolSummaryInterval===0&&V.length>0){let B=z7({tools:V});G.push(B)}if(H===1&&z.envInfoOnStart){let B=G7({workingDirectory:K,gitStatus:W});G.push(B)}if(G.length===0)return"";return["---","System Reminders:","",...G,"---"].join(`
48
- `)}function f4($){if(!$||$.length===0)return 0;return Math.ceil($.length/4)}function G5($){switch($.type){case"text":return f4($.text);case"image":return 100;case"tool_use":let Z=JSON.stringify($.input);return f4($.name)+f4(Z)+10;case"tool_result":if(typeof $.content==="string")return f4($.content)+10;return $.content.reduce((Q,J)=>Q+G5(J),0)+10;case"thinking":return f4($.thinking);default:return 0}}function j7($){return 4+$.content.reduce((J,X)=>J+G5(X),0)}function $2($){if(!$||$.length===0)return 0;return $.reduce((Z,Q)=>Z+j7(Q),0)}function U7($){let Z=[];for(let Q of $.content)switch(Q.type){case"text":Z.push(Q.text);break;case"tool_use":Z.push(`[Tool: ${Q.name}(${JSON.stringify(Q.input)})]`);break;case"tool_result":let J=typeof Q.content==="string"?Q.content:Q.content.map((X)=>X.type==="text"?X.text:"[content]").join("");Z.push(`[Result: ${J.slice(0,500)}${J.length>500?"...":""}]`);break;case"thinking":Z.push(`[Thinking: ${Q.thinking.slice(0,200)}...]`);break}return Z.join(`
49
- `)}function A7($){let Z=new Map;for(let Q of $)for(let J of Q.content)if(J.type==="tool_use")Z.set(J.id,{use:J});for(let Q of $)for(let J of Q.content)if(J.type==="tool_result"){let X=Z.get(J.tool_use_id);if(X)X.result=J}return Z}async function B7($){if(!$||$.length===0)return"";let Z=[];Z.push(`[Context Summary: ${$.length} messages compacted]
50
- `);let Q=[];for(let X=0;X<$.length;X++){let V=$[X];if(!V)continue;let K=V.role.toUpperCase(),W=U7(V);for(let q of V.content)if(q.type==="tool_use")Q.push(`${q.name}`);let H=W.length>300?`${W.slice(0,300)}...`:W;Z.push(`${K}: ${H}
51
- `)}if(Q.length>0){let X=Q.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 J=Z.join("");if(J.length>8000)J=J.slice(0,8000)+`
54
- ...[truncated]`;return J}async function Z2($,Z,Q={}){let{keepFirst:J=1,keepLast:X=5,preserveToolPairs:V=!0}=Q,K=$2($);if(K<=Z)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};if($.length<=J+X)return{messages:$,messagesRemoved:0,tokensBefore:K,tokensAfter:K,didCompact:!1};let W=$.slice(0,J),H=$.slice(J,-X),q=$.slice(-X),G={role:"user",content:[{type:"text",text:`[Previous context has been compacted for continuity]
55
-
56
- ${await B7(H)}`}]},U=[];if(V&&H.length>0){let R=A7(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=$2(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 j5($,Z,Q=0.9){if($.length<8)return!1;let J=$2($),X=Math.floor(Z*Q);return J>=X}function Q2($){if(!$.didCompact)return{reductionPercent:0,tokensSaved:0};let Z=$.tokensBefore-$.tokensAfter,Q=Z/$.tokensBefore*100;return{reductionPercent:Math.round(Q*100)/100,tokensSaved:Z}}async function pV($,Z){let{apiKey:Q,model:J="claude-sonnet-4-6",maxTokens:X=4096,systemPrompt:V,tools:K,permissionMode:W,workingDirectory:H,gitStatus:q=null,reminderConfig:z,cacheConfig:G=Y6,thinking:U,extendedThinking:L,onText:B,onThinking:_,onToolUse:R,onToolResult:w,onMetrics:D,onReminder:I,onPermissionRequest:S,signal:M}=Z,d=new s6(W,S),k=[...$],l=[],K0=[],t=0,a0=0,x4=0,H6=0,N0=0,y0=0,s={cacheHits:0,cacheMisses:0,totalCacheReadTokens:0,totalCacheWriteTokens:0,cacheHitRate:0,estimatedSavingsUSD:0},r0={...t6,...z},L0=!0;while(L0){if(M?.aborted)break;x4++;let b0=l[l.length-1],W0=z5({usage:b0?.usage??{input_tokens:0,output_tokens:0},maxTokens:X,totalCost:t,previousCost:H6,toolsUsed:K0,workingDirectory:H,gitStatus:q,turnNumber:x4,config:r0});if(W0)I?.(W0);if(j5(k,X)){let O=await Z2(k,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){k.length=0,k.push(...O.messages),N0++;let y=O.tokensBefore-O.tokensAfter;y0+=y;let x=Q2(O);console.log(`Context compacted: ${x.reductionPercent}% reduction, ${x.tokensSaved} tokens saved`)}}let U4=L7(k,V,W0),Z5=await H5(U4,{apiKey:Q,model:J,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:M}),{message:f0,usage:v4,cacheMetrics:P0,costUSD:O4,durationMs:h,ttftMs:D0}=Z5,n0={model:J,messageCount:k.length,messageTokens:v4.input_tokens+v4.output_tokens,usage:v4,cacheMetrics:P0,durationMs:h,ttftMs:D0,costUSD:O4,stopReason:f0.stop_reason,requestId:f0.id};if(l.push(n0),H6=t,t+=O4,a0+=h,P0)s.cacheHits+=P0.cacheHits,s.cacheMisses+=P0.cacheMisses,s.totalCacheReadTokens+=P0.totalCacheReadTokens,s.totalCacheWriteTokens+=P0.totalCacheWriteTokens,s.estimatedSavingsUSD+=P0.estimatedSavingsUSD;let y4=s.cacheHits+s.cacheMisses;if(s.cacheHitRate=y4>0?s.cacheHits/y4:0,D?.(n0),k.push({role:"assistant",content:f0.content}),f0.stop_reason==="end_turn"||f0.stop_reason==="stop_sequence"){L0=!1;break}if(f0.stop_reason==="max_tokens"){let O=await Z2(k,X,{keepFirst:0,keepLast:3,preserveToolPairs:!0});if(O.didCompact&&O.tokensAfter<O.tokensBefore){k.length=0,k.push(...O.messages),N0++;let y=O.tokensBefore-O.tokensAfter;y0+=y;let x=Q2(O);console.log(`Context compacted: ${x.reductionPercent}% reduction, ${x.tokensSaved} tokens saved`);continue}else{L0=!1;break}}let A4=f0.content.filter((O)=>O.type==="tool_use");if(K0.push(...A4),A4.length===0){L0=!1;break}let b4=[];if(M?.aborted);else{let O=A4.map(async(x)=>{let i6=K.find((h0)=>h0.name===x.name);if(!i6)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 q6=await d.checkPermission(i6.name,x.input);if(q6.decision==="deny"||q6.decision==="denyAlways")return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Permission denied for tool "${x.name}"${q6.reason?`: ${q6.reason}`:""}`,is_error:!0},toolResult:null};try{let h0=await i6.handler(x.input,{workingDirectory:H,permissionMode:W,abortSignal:M});return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:h0.content,is_error:h0.is_error},toolResult:{id:x.id,result:h0}}}catch(h0){let l9=h0 instanceof Error?h0.message:String(h0);return{toolUseId:x.id,result:{type:"tool_result",tool_use_id:x.id,content:`Error: ${l9}`,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)}k.push({role:"user",content:b4})}return{messages:k,metrics:l,totalCost:t,totalDuration:a0,totalCacheMetrics:s,compactionCount:N0,totalTokensCompacted:y0}}function L7($,Z,Q){if(Q&&$.length>0){let J=[...$];for(let X=J.length-1;X>=0;X--){let V=J[X];if(V&&V.role==="user"){let K={role:"user",content:Array.isArray(V.content)?_7(V.content,Q):[{type:"text",text:`${String(V.content)}
57
-
58
- ${Q}`}]};J[X]=K;break}}return J}return $}function _7($,Z){if($.length>0){let J=$[$.length-1];if(J&&J.type==="text"){let X={type:"text",text:`${J.text}
59
-
60
- ${Z}`};return[...$.slice(0,-1),X]}}let Q={type:"text",text:`
61
-
62
- ${Z}`};return[...$,Q]}function J2($){if($<0.01)return`$${$.toFixed(4)}`;return`$${$.toFixed(2)}`}function aV($){let Z=J2($.costUSD),Q=`${$.usage.input_tokens.toLocaleString()} input, ${$.usage.output_tokens.toLocaleString()} output`;if($.usage.cache_read_input_tokens||$.usage.cache_creation_input_tokens){let J=$.usage.cache_read_input_tokens?.toLocaleString()??"0",X=$.usage.cache_creation_input_tokens?.toLocaleString()??"0";return`Cost: ${Z} | Tokens: ${Q} | Cache: ${J} read, ${X} write`}return`Cost: ${Z} | Tokens: ${Q}`}function rV($){let Z=J2($.costUSD),Q=$.usage.input_tokens+$.usage.output_tokens;return`Cost: ${Z} | Tokens: ${Q.toLocaleString()}`}function nV($){let Z=J2($.estimatedSavingsUSD);return`Cache: ${($.cacheHitRate*100).toFixed(1)}% hit rate | ${$.totalCacheReadTokens.toLocaleString()} read | ${$.totalCacheWriteTokens.toLocaleString()} written | Saved: ${Z}`}import{homedir as w7}from"os";import{join as g0}from"path";class R7{sessionsDir;currentSessionId=null;currentSessionFile=null;writeQueue=Promise.resolve();constructor($){this.sessionsDir=$??g0(w7(),".claude","sessions")}async init(){try{await Bun.write(g0(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=g0(this.sessionsDir,`${Z}.jsonl`);let Q={id:Z,created:Date.now(),updated:Date.now(),model:$.model,workingDirectory:$.workingDirectory,agentName:$.agentName,agentColor:$.agentColor,teamName:$.teamName};await this.appendEntry(Q);let J={type:"context",timestamp:Date.now(),workingDirectory:$.workingDirectory};return await this.appendEntry(J),Z}async resumeSession($){let Z=g0(this.sessionsDir,`${$}.jsonl`);try{let Q=await Bun.file(Z).text();if(!Q)return null;let J=Q.trim().split(`
63
- `),X=[];for(let V of J)try{X.push(JSON.parse(V))}catch{}return this.parseSessionEntries(X)}catch{return null}}parseSessionEntries($){let Z=null,Q=[],J=[],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":Q.push(W.data);break;case"tool_use":J.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:Q,tools:J,metrics:X,context:V}}async appendEntry($){if(!this.currentSessionFile)return;this.writeQueue=this.writeQueue.then(async()=>{let Z=JSON.stringify($)+`
64
- `,Q=Bun.file(this.currentSessionFile),J=await Q.exists()?await Q.text():"";await Bun.write(this.currentSessionFile,J+Z)}),await this.writeQueue}async saveMessage($){let Z={type:"message",timestamp:Date.now(),data:$};await this.appendEntry(Z),await this.updateTimestamp()}async saveToolUse($,Z,Q,J,X){let V={type:"tool_use",timestamp:Date.now(),toolId:$,toolName:Z,input:Q,result:J,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),Q=[];try{let X=[...new Bun.Glob("*.jsonl").scanSync(this.sessionsDir)],V=await Promise.all(X.map(async(K)=>{let W=g0(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)Q.push(q)}}catch{}return Q}async getSessionSummary($,Z){let Q=Z??g0(this.sessionsDir,`${$}.jsonl`);try{let J=await Bun.file(Q).text();if(!J)return null;let X=J.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,Q){let J=await this.resumeSession($);if(!J)throw Error(`Session not found: ${$}`);let X,V;switch(Z){case"jsonl":{let W=g0(this.sessionsDir,`${$}.jsonl`);X=await Bun.file(W).text(),V="jsonl";break}case"json":{X=JSON.stringify(J,null,2),V="json";break}case"markdown":{X=this.sessionToMarkdown(J),V="md";break}default:throw Error(`Unsupported format: ${Z}`)}let K=Q??g0(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 Q of $.messages){let J=Q.role==="user"?"**User**":"**Claude**";Z.push(`### ${J}`),Z.push("");for(let X of Q.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 Q=$.metrics.reduce((V,K)=>V+K.costUSD,0),J=$.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:** $${Q.toFixed(4)}`),Z.push(`- **Total Input Tokens:** ${J.toLocaleString()}`),Z.push(`- **Total Output Tokens:** ${X.toLocaleString()}`),Z.push(`- **API Calls:** ${$.metrics.length}`)}return Z.join(`
66
- `)}async deleteSession($){let Z=g0(this.sessionsDir,`${$}.jsonl`);try{if(await Bun.file(Z).exists()){let{unlink:J}=await import("fs/promises");return await J(Z),!0}return!1}catch{return!1}}}function C7($){let Z=new Date($.created),Q=new Date($.updated),J=N7(Q),X=[];X.push(`\x1B[1m${$.id}\x1B[0m (${J})`),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 N7($){let Q=new Date().getTime()-$.getTime(),J=Math.floor(Q/60000),X=Math.floor(Q/3600000),V=Math.floor(Q/86400000);if(J<1)return"just now";if(J<60)return`${J}m ago`;if(X<24)return`${X}h ago`;if(V<7)return`${V}d ago`;return $.toLocaleDateString()}function eV($){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(C7(Z)),console.log("");console.log("To resume a session:"),console.log(" claude-remake --resume <session-id>")}import{dlopen as P7,suffix as D7}from"bun:ffi";import{join as X4,dirname as U5}from"path";import{fileURLToPath as A5}from"url";var J4=null;function B5(){if(J4)return J4;let $=U5(A5(import.meta.url)),Z=[X4($,"..","..","native"),X4($,"..","native")],Q=["index.darwin-arm64.node","index.darwin-x64.node","index.node"];for(let X of Z)for(let V of Q){let K=X4(X,V);try{let W=v(K);if(W&&(W.highlightCode||W.highlight_code))return J4={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},J4}catch{continue}}let J=Z.map((X)=>X4(X,`claude_code_native.${D7}`));for(let X of J)try{return J4=P7(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,J4}catch{continue}return console.warn("Native module not available, using JS fallback"),L5()}function JK(){try{return B5(),J4!==null}catch{return!1}}function L5(){return{highlight_code:($,Z)=>{let Q=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"]),J=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(Q.has(q))return`${X.keyword}${q}${X.default}`;if(J.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,Q)=>{let H=$.split(`
72
- `),q=Z.split(`
73
- `),z="",G=0,U=0,L=0;if(Q?.file_path)z+=`\x1B[38;2;143;161;179m${Q.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 k=0;k<=q.length;k++)if(d===0||k===0)_[d][k]=0;else if(H[d-1]===q[k-1])_[d][k]=_[d-1][k-1]+1;else _[d][k]=Math.max(_[d-1][k],_[d][k-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,M=0;while(I<H.length||S<q.length){while(M<B.length&&I<H.length&&S<q.length&&H[I]===B[M]&&q[S]===B[M])I++,S++,M++;let d=I+1,k=S+1,l=0,K0=0,t=[];while(I<H.length&&(M>=B.length||H[I]!==B[M]))t.push(`\x1B[38;2;191;97;106m-${H[I]}\x1B[0m`),I++,l++,U++;while(S<q.length&&(M>=B.length||q[S]!==B[M]))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} +${k},${K0} @@\x1B[0m
75
- `,z+=t.join(`
76
- `)+`
77
- `}return{output:z,additions:G,deletions:U,hunks:L}},search_files:($,Z,Q)=>{return{matches:[],total_count:0,files_searched:0}},count_tokens:($)=>{return Math.ceil($.length/4)},calculate_diff:($,Z)=>{let Q=$.split(`
78
- `),J=Z.split(`
79
- `),X=[];if($!==Z)X.push({oldStart:1,oldLines:Q.length,newStart:1,newLines:J.length,content:`- ${Q.join(`
80
- - `)}
81
- + ${J.join(`
82
- + `)}`});return X},compact_content:($,Z,Q="truncate")=>{let X=Z*4;if($.length<=X)return $;switch(Q){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=[],Q=new Map,J=v("fs");for(let X of $)try{if(!J.existsSync(X.filePath)){Z.push(`File not found: ${X.filePath}`);continue}if(!Q.has(X.filePath)){let K=J.readFileSync(X.filePath,"utf-8");Q.set(X.filePath,K)}let V=Q.get(X.filePath);if(!V.includes(X.oldString)){Z.push(`String not found in ${X.filePath}: "${F7(X.oldString,50)}"`);continue}if(!X.replaceAll){let K=(V.match(new RegExp(X2(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=[],Q=new Map,J=v("fs");for(let X of $)try{if(!J.existsSync(X.filePath))continue;let V=J.readFileSync(X.filePath,"utf-8"),K=X.replaceAll?(V.match(new RegExp(X2(X.oldString),"g"))||[]).length:1;Q.set(X.filePath,(Q.get(X.filePath)||0)+K)}catch{}for(let[X,V]of Q)Z.push({filePath:X,replacementCount:V});return Z},apply_multi_edits:($)=>{let Z=L5().validate_multi_edits($);if(Z.length>0)return{success:!1,filesModified:[],totalReplacements:0,error:Z.join(`
93
- `),rolledBack:!1};let Q=new Map,J=new Set($.map((H)=>H.filePath)),X=v("fs");for(let H of J)try{Q.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 Q)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(X2(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=Q.get(H);if(q!==z)try{Bun.write(H,q),W.push(H)}catch(G){for(let[U,L]of Q)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 Q of $)if(Q.tool_use)for(let J of Q.tool_use)Z[J.name]=(Z[J.name]||0)+1;return Z},find_tool_pairs:($,Z)=>{let Q={};for(let J of $)if(J.tool_use&&J.tool_use.length>=2)for(let X=0;X<J.tool_use.length-1;X++){let V=J.tool_use[X]?.name,K=J.tool_use[X+1]?.name;if(V&&K){if(!Q[V])Q[V]={};Q[V][K]=(Q[V][K]||0)+1}}return Q},find_common_patterns:($)=>{let Z=[],Q=new Map,J=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}`;Q.set(H,(Q.get(H)||0)+1),J++}}for(let[X,V]of Q){let[K,W]=X.split("|");Z.push({tools:[K,W],count:V,percentage:J>0?V/J*100:0})}return Z.sort((X,V)=>V.count-X.count).slice(0,10)}}}var V4=B5();function XK($,Z){return V4.highlight_code($,Z)}function VK($){return V4.highlight_markdown($)}function KK($,Z,Q){return V4.highlight_diff($,Z,Q)}function WK($,Z){return V4.calculate_diff($,Z)}function V2($){return V4.validate_multi_edits($)}function _5($){return V4.preview_multi_edits($)}function w5($){return V4.apply_multi_edits($)}function F7($,Z){if($.length<=Z)return $;return $.slice(0,Z)+"..."}function X2($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var z6=null;function M7(){if(z6)return z6;let $=U5(A5(import.meta.url)),Z=process.platform==="darwin"?"libquant_rust.dylib":process.platform==="linux"?"libquant_rust.so":"quant_rust.dll",Q=[X4($,"..","..","node_modules","@ebowwa","quant-rust","native",`${process.platform}-${process.arch}`,Z),X4($,"..","..","..","@ebowwa","quant-rust","native",`${process.platform}-${process.arch}`,Z),X4($,"..","..","node_modules","@ebowwa","quant-rust","target","release",Z)];for(let J of Q)try{let{existsSync:X}=v("fs");if(!X(J))continue;let{dlopen:V,FFIType:K,ptr:W}=v("bun:ffi");return z6=V(J,{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,z6}catch{continue}return null}var b=M7();function i0($){if(!$)throw Error(b?.quant_last_error()||"Unknown quant error");return JSON.parse($)}function h4($){let{ptr:Z}=v("bun:ffi"),Q=new Float64Array($);return{buffer:Q,ptr:Z(Q)}}function HK(){if(!b)return"not available";return b.quant_version()}function qK(){return b!==null}function YK($,Z,Q,J,X,V){if(!b)return{timestamp:$,open:Z,high:Q,low:J,close:X,volume:V};let K=b.quant_ohlcv_new(BigInt($),Z,Q,J,X,V);return i0(K)}function zK($,Z,Q){if(!b){let X=$*Z;return{pool_yes:$,pool_no:Z,k:X,fee:Q,price_yes:Z/X,price_no:$/X}}let J=b.quant_amm_new($,Z,Q);return i0(J)}function GK($,Z,Q,J){if(!b){let W=typeof Q==="string"?Q==="yes":Q,H=$*Z;if(W){let q=H/($+J);return Math.abs(q-Z)}else{let q=H/(Z+J);return Math.abs(q-$)}}let X=typeof Q==="string"?Q==="yes":Q,V=b.quant_amm_calculate_cost($,Z,X,J),K=i0(V);return Math.abs(K.cost)}function jK($,Z,Q,J){if(!b){let K=typeof Q==="string"?Q==="yes":Q,W=$*Z,H=K?Z/W:$/W,q=K?$+J:$,z=K?Z:Z+J,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 Q==="string"?Q==="yes":Q,V=b.quant_amm_price_impact($,Z,X,J);return i0(V)}function UK($,Z,Q){if(!b){let X=Math.exp($/Q),V=Math.exp(Z/Q),K=X+V,W=X/K,H=V/K;return{yes_price:W,no_price:H,spread:Math.abs(W-H)}}let J=b.quant_lmsr_price($,Z,Q);return i0(J)}function AK($,Z,Q,J,X){if(!b){let W=typeof J==="string"?J==="yes":J,H=Q*Math.log(Math.exp($/Q)+Math.exp(Z/Q)),q=W?$+X:$,z=W?Z:Z+X,G=Q*Math.log(Math.exp(q/Q)+Math.exp(z/Q));return{cost:G-H,avg_price:(G-H)/X}}let V=typeof J==="string"?J==="yes":J,K=b.quant_lmsr_cost($,Z,Q,V,X);return i0(K)}function BK($,Z){if(!b){let J=$+Z,X=J<1;return{has_arbitrage:X,yes_price:$,no_price:Z,total:J,profit_per_share:X?1-J:0}}let Q=b.quant_detect_arbitrage($,Z);return i0(Q)}var I7={probability:0,decimal:1,american:2};function LK($,Z){if(!b){let J;switch(Z){case"probability":J=$;break;case"decimal":J=1/$;break;case"american":J=$>0?100/($+100):-$/(-$+100);break}let X=1/J,V=J>=0.5?-100/(J-1):(1-J)/J*100;return{probability:J,decimal_odds:X,american_odds:Math.round(V)}}let Q=b.quant_convert_odds($,I7[Z]??0);return i0(Q)}function _K($){if($.length===0)return NaN;if(!b)return $.reduce((Q,J)=>Q+J,0)/$.length;let{ptr:Z}=h4($);return b.quant_mean(Z,$.length)}function wK($){if($.length===0)return NaN;if(!b){let Q=$.reduce((X,V)=>X+V,0)/$.length,J=$.map((X)=>Math.pow(X-Q,2));return Math.sqrt(J.reduce((X,V)=>X+V,0)/$.length)}let{ptr:Z}=h4($);return b.quant_std_dev(Z,$.length)}function RK($){if($.length===0)return NaN;if(!b){let Q=$.reduce((X,V)=>X+V,0)/$.length;return $.map((X)=>Math.pow(X-Q,2)).reduce((X,V)=>X+V,0)/$.length}let{ptr:Z}=h4($);return b.quant_variance(Z,$.length)}function CK($,Z){if($.length===0||Z.length===0||$.length!==Z.length)return NaN;if(!b){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+Math.pow(G-V,2),0)/X,q=Z.reduce((z,G)=>z+Math.pow(G-K,2),0)/X;return W/Math.sqrt(H*q)}let{ptr:Q}=h4($),{ptr:J}=h4(Z);return b.quant_correlation(Q,J,$.length)}var K2=($,Z,Q)=>{let J=$ instanceof RegExp?R5($,Q):$,X=Z instanceof RegExp?R5(Z,Q):Z,V=J!==null&&X!=null&&E7(J,X,Q);return V&&{start:V[0],end:V[1],pre:Q.slice(0,V[0]),body:Q.slice(V[0]+J.length,V[1]),post:Q.slice(V[1]+X.length)}},R5=($,Z)=>{let Q=Z.match($);return Q?Q[0]:null},E7=($,Z,Q)=>{let J,X,V,K=void 0,W,H=Q.indexOf($),q=Q.indexOf(Z,H+1),z=H;if(H>=0&&q>0){if($===Z)return[H,q];J=[],V=Q.length;while(z>=0&&!W){if(z===H)J.push(z),H=Q.indexOf($,z+1);else if(J.length===1){let G=J.pop();if(G!==void 0)W=[G,q]}else{if(X=J.pop(),X!==void 0&&X<V)V=X,K=q;q=Q.indexOf(Z,z+1)}z=H<q&&H>=0?H:q}if(J.length&&K!==void 0)W=[V,K]}return W};var C5="\x00SLASH"+Math.random()+"\x00",N5="\x00OPEN"+Math.random()+"\x00",H2="\x00CLOSE"+Math.random()+"\x00",P5="\x00COMMA"+Math.random()+"\x00",D5="\x00PERIOD"+Math.random()+"\x00",S7=new RegExp(C5,"g"),T7=new RegExp(N5,"g"),k7=new RegExp(H2,"g"),x7=new RegExp(P5,"g"),v7=new RegExp(D5,"g"),O7=/\\\\/g,y7=/\\{/g,b7=/\\}/g,f7=/\\,/g,h7=/\\./g,g7=1e5;function W2($){return!isNaN($)?parseInt($,10):$.charCodeAt(0)}function d7($){return $.replace(O7,C5).replace(y7,N5).replace(b7,H2).replace(f7,P5).replace(h7,D5)}function u7($){return $.replace(S7,"\\").replace(T7,"{").replace(k7,"}").replace(x7,",").replace(v7,".")}function F5($){if(!$)return[""];let Z=[],Q=K2("{","}",$);if(!Q)return $.split(",");let{pre:J,body:X,post:V}=Q,K=J.split(",");K[K.length-1]+="{"+X+"}";let W=F5(V);if(V.length)K[K.length-1]+=W.shift(),K.push.apply(K,W);return Z.push.apply(Z,K),Z}function M5($,Z={}){if(!$)return[];let{max:Q=g7}=Z;if($.slice(0,2)==="{}")$="\\{\\}"+$.slice(2);return g4(d7($),Q,!0).map(u7)}function m7($){return"{"+$+"}"}function c7($){return/^-?0\d/.test($)}function l7($,Z){return $<=Z}function p7($,Z){return $>=Z}function g4($,Z,Q){let J=[],X=K2("{","}",$);if(!X)return[$];let V=X.pre,K=X.post.length?g4(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];J.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+H2+X.post,g4($,Z,!0);return[$]}let G;if(q)G=X.body.split(/\.\./);else if(G=F5(X.body),G.length===1&&G[0]!==void 0){if(G=g4(G[0],Z,!1).map(m7),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=W2(G[0]),B=W2(G[1]),_=Math.max(G[0].length,G[1].length),R=G.length===3&&G[2]!==void 0?Math.abs(W2(G[2])):1,w=l7;if(B<L)R*=-1,w=p7;let I=G.some(c7);U=[];for(let S=L;w(S,B);S+=R){let M;if(H){if(M=String.fromCharCode(S),M==="\\")M=""}else if(M=String(S),I){let d=_-M.length;if(d>0){let k=Array(d+1).join("0");if(S<0)M="-"+k+M.slice(1);else M=k+M}}U.push(M)}}else{U=[];for(let L=0;L<G.length;L++)U.push.apply(U,g4(G[L],Z,!1))}for(let L=0;L<U.length;L++)for(let B=0;B<K.length&&J.length<Z;B++){let _=V+U[L]+K[B];if(!Q||q||_)J.push(_)}}return J}var d4=($)=>{if(typeof $!=="string")throw TypeError("invalid pattern");if($.length>65536)throw TypeError("pattern is too long")};var a7={"[: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]},u4=($)=>$.replace(/[[\]\\-]/g,"\\$&"),r7=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),I5=($)=>$.join(""),E5=($,Z)=>{let Q=Z;if($.charAt(Q)!=="[")throw Error("not in a brace expression");let J=[],X=[],V=Q+1,K=!1,W=!1,H=!1,q=!1,z=Q,G="";$:while(V<$.length){let _=$.charAt(V);if((_==="!"||_==="^")&&V===Q+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(a7))if($.startsWith(R,V)){if(G)return["$.",!1,$.length-Q,!0];if(V+=R.length,I)X.push(w);else J.push(w);W=W||D;continue $}}if(H=!1,G){if(_>G)J.push(u4(G)+"-"+u4(_));else if(_===G)J.push(u4(_));G="",V++;continue}if($.startsWith("-]",V+1)){J.push(u4(_+"-")),V+=2;continue}if($.startsWith("-",V+1)){G=_,V+=2;continue}J.push(u4(_)),V++}if(z<V)return["",!1,0,!1];if(!J.length&&!X.length)return["$.",!1,$.length-Q,!0];if(X.length===0&&J.length===1&&/^\\?.$/.test(J[0])&&!q){let _=J[0].length===2?J[0].slice(-1):J[0];return[r7(_),!1,z-Q,!1]}let U="["+(q?"^":"")+I5(J)+"]",L="["+(q?"":"^")+I5(X)+"]";return[J.length&&X.length?"("+U+"|"+L+")":J.length?U:L,W,z-Q,!0]};var _0=($,{windowsPathsNoEscape:Z=!1,magicalBraces:Q=!0}={})=>{if(Q)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,n7=new Set(["!","?","+","*","@"]),q2=($)=>n7.has($),S5=($)=>q2($.type),i7=new Map([["!",["@"]],["?",["?","@"]],["@",["@"]],["*",["*","+","?","@"]],["+",["+","@"]]]),s7=new Map([["!",["?"]],["@",["?"]],["+",["?","*"]]]),o7=new Map([["!",["?","@"]],["?",["?","@"]],["@",["?","@"]],["*",["*","+","?","@"]],["+",["+","@","?","*"]]]),T5=new Map([["!",new Map([["!","@"]])],["?",new Map([["*","*"],["+","*"]])],["@",new Map([["!","!"],["?","?"],["@","@"],["*","*"],["+","+"]])],["+",new Map([["?","*"],["*","*"]])]]),e7="(?!(?:^|/)\\.\\.?(?:$|/))",G6="(?!\\.)",t7=new Set(["[","."]),$8=new Set(["..","."]),Z8=new Set("().*{}+?[]^$\\!"),Q8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Y2="[^/]",k5=Y2+"*?",x5=Y2+"+?",J8=0;class B4{type;#$;#J;#X=!1;#Z=[];#K;#P;#_;#z=!1;#W;#G;#Y=!1;id=++J8;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,Q={}){if(this.type=$,$)this.#J=!0;if(this.#K=Z,this.#$=this.#K?this.#K.#$:this,this.#W=this.#$===this?Q:this.#$.#W,this.#_=this.#$===this?[]:this.#$.#_,$==="!"&&!this.#$.#z)this.#_.push(this);this.#P=this.#K?this.#K.#Z.length:0}get hasMagic(){if(this.#J!==void 0)return this.#J;for(let $ of this.#Z){if(typeof $==="string")continue;if($.type||$.hasMagic)return this.#J=!0}return this.#J}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=$,Q=Z.#K;while(Q){for(let J=Z.#P+1;!Q.type&&J<Q.#Z.length;J++)for(let X of $.#Z){if(typeof X==="string")throw Error("string part in extglob AST??");X.copyIn(Q.#Z[J])}Z=Q,Q=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 Q=$.#Z[Z];if(!(Q instanceof H0&&Q.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 Q of this.#Z)Z.copyIn(Q);return Z}static#V($,Z,Q,J,X){let V=J.maxExtglobRecursion??2,K=!1,W=!1,H=-1,q=!1;if(Z.type===null){let B=Q,_="";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(!J.noext&&q2(R)&&$.charAt(B)==="("&&X<=V){Z.push(_),_="";let D=new H0(R,Z);B=H0.#V($,D,B,J,X+1),Z.push(D);continue}_+=R}return Z.push(_),B}let z=Q+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(!J.noext&&q2(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,J,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.#J=void 0,Z.#Z=[$.substring(Q-1)],z}#w($){return this.#C($,s7)}#C($,Z=i7){if(!$||typeof $!=="object"||$.type!==null||$.#Z.length!==1||this.type===null)return!1;let Q=$.#Z[0];if(!Q||typeof Q!=="object"||Q.type===null)return!1;return this.#U(Q.type,Z)}#U($,Z=o7){return!!Z.get(this.type)?.includes($)}#A($,Z){let Q=$.#Z[0],J=new H0(null,Q,this.options);J.#Z.push(""),Q.push(J),this.#M($,Z)}#M($,Z){let Q=$.#Z[0];this.#Z.splice(Z,1,...Q.#Z);for(let J of Q.#Z)if(typeof J==="object")J.#K=this;this.#G=void 0}#B($){return!!T5.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=T5.get(this.type),Q=$.#Z[0],J=Z?.get(Q.type);if(!J)return!1;this.#Z=Q.#Z;for(let X of this.#Z)if(typeof X==="object")X.#K=this;this.type=J,this.#G=void 0,this.#Y=!1}static fromGlob($,Z={}){let Q=new H0(null,void 0,Z);return H0.#V($,Q,0,Z,0),Q}toMMPattern(){if(this!==this.#$)return this.#$.toMMPattern();let $=this.toString(),[Z,Q,J,X]=this.toRegExpSource();if(!(J||this.#J||this.#W.nocase&&!this.#W.nocaseMagicOnly&&$.toUpperCase()!==$.toLowerCase()))return Q;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(!S5(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.#J,W):U.toRegExpSource($);return this.#J=this.#J||_,this.#X=this.#X||R,L}).join(""),q="";if(this.isStart()){if(typeof this.#Z[0]==="string"){if(!(this.#Z.length===1&&$8.has(this.#Z[0]))){let L=t7,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?e7:_?G6:""}}}let z="";if(this.isEnd()&&this.#$.#z&&this.#K?.type==="!")z="(?:$|\\/)";return[q+H+z,_0(H),this.#J=!!this.#J,this.#X]}let Q=this.type==="*"||this.type==="+",J=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.#J=void 0,[W,_0(this.toString()),!1,!1]}let V=!Q||$||Z||!G6?"":this.#L(!0);if(V===X)V="";if(V)X=`(?:${X})(?:${V})*?`;let K="";if(this.type==="!"&&this.#Y)K=(this.isStart()&&!Z?G6:"")+x5;else{let W=this.type==="!"?"))"+(this.isStart()&&!Z&&!$?G6:"")+k5+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&V?")":this.type==="*"&&V?")?":`)${this.type}`;K=J+X+W}return[K,_0(X),this.#J=!!this.#J,this.#X]}#j(){if(!S5(this)){for(let $ of this.#Z)if(typeof $==="object")$.#j()}else{let $=0,Z=!1;do{Z=!0;for(let Q=0;Q<this.#Z.length;Q++){let J=this.#Z[Q];if(typeof J==="object"){if(J.#j(),this.#C(J))Z=!1,this.#M(J,Q);else if(this.#w(J))Z=!1,this.#A(J,Q);else if(this.#N(J))Z=!1,this.#D(J)}}}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[Q,J,X,V]=Z.toRegExpSource($);return this.#X=this.#X||V,Q}).filter((Z)=>!(this.isStart()&&this.isEnd())||!!Z).join("|")}static#R($,Z,Q=!1){let J=!1,X="",V=!1,K=!1;for(let W=0;W<$.length;W++){let H=$.charAt(W);if(J){J=!1,X+=(Z8.has(H)?"\\":"")+H;continue}if(H==="*"){if(K)continue;K=!0,X+=Q&&/^[*]+$/.test($)?x5:k5,Z=!0;continue}else K=!1;if(H==="\\"){if(W===$.length-1)X+="\\\\";else J=!0;continue}if(H==="["){let[q,z,G,U]=E5($,W);if(G){X+=q,V=V||z,W+=G-1,Z=Z||U;continue}}if(H==="?"){X+=Y2,Z=!0;continue}X+=Q8(H)}return[X,_0($),!!Z,V]}}H0=B4;var L4=($,{windowsPathsNoEscape:Z=!1,magicalBraces:Q=!1}={})=>{if(Q)return Z?$.replace(/[?*()[\]{}]/g,"[$&]"):$.replace(/[?*()[\]\\{}]/g,"\\$&");return Z?$.replace(/[?*()[\]]/g,"[$&]"):$.replace(/[?*()[\]\\]/g,"\\$&")};var $0=($,Z,Q={})=>{if(d4(Z),!Q.nocomment&&Z.charAt(0)==="#")return!1;return new j0(Z,Q).match($)},X8=/^\*+([^+@!?\*\[\(]*)$/,V8=($)=>(Z)=>!Z.startsWith(".")&&Z.endsWith($),K8=($)=>(Z)=>Z.endsWith($),W8=($)=>{return $=$.toLowerCase(),(Z)=>!Z.startsWith(".")&&Z.toLowerCase().endsWith($)},H8=($)=>{return $=$.toLowerCase(),(Z)=>Z.toLowerCase().endsWith($)},q8=/^\*+\.\*+$/,Y8=($)=>!$.startsWith(".")&&$.includes("."),z8=($)=>$!=="."&&$!==".."&&$.includes("."),G8=/^\.\*+$/,j8=($)=>$!=="."&&$!==".."&&$.startsWith("."),U8=/^\*+$/,A8=($)=>$.length!==0&&!$.startsWith("."),B8=($)=>$.length!==0&&$!=="."&&$!=="..",L8=/^\?+([^+@!?\*\[\(]*)?$/,_8=([$,Z=""])=>{let Q=y5([$]);if(!Z)return Q;return Z=Z.toLowerCase(),(J)=>Q(J)&&J.toLowerCase().endsWith(Z)},w8=([$,Z=""])=>{let Q=b5([$]);if(!Z)return Q;return Z=Z.toLowerCase(),(J)=>Q(J)&&J.toLowerCase().endsWith(Z)},R8=([$,Z=""])=>{let Q=b5([$]);return!Z?Q:(J)=>Q(J)&&J.endsWith(Z)},C8=([$,Z=""])=>{let Q=y5([$]);return!Z?Q:(J)=>Q(J)&&J.endsWith(Z)},y5=([$])=>{let Z=$.length;return(Q)=>Q.length===Z&&!Q.startsWith(".")},b5=([$])=>{let Z=$.length;return(Q)=>Q.length===Z&&Q!=="."&&Q!==".."},f5=typeof process==="object"&&process?typeof process.env==="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",v5={win32:{sep:"\\"},posix:{sep:"/"}},N8=f5==="win32"?v5.win32.sep:v5.posix.sep;$0.sep=N8;var m=Symbol("globstar **");$0.GLOBSTAR=m;var P8="[^/]",D8=P8+"*?",F8="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",M8="(?:(?!(?:\\/|^)\\.).)*?",I8=($,Z={})=>(Q)=>$0(Q,$,Z);$0.filter=I8;var G0=($,Z={})=>Object.assign({},$,Z),E8=($)=>{if(!$||typeof $!=="object"||!Object.keys($).length)return $0;let Z=$0;return Object.assign((J,X,V={})=>Z(J,X,G0($,V)),{Minimatch:class extends Z.Minimatch{constructor(X,V={}){super(X,G0($,V))}static defaults(X){return Z.defaults(G0($,X)).Minimatch}},AST:class extends Z.AST{constructor(X,V,K={}){super(X,V,G0($,K))}static fromGlob(X,V={}){return Z.AST.fromGlob(X,G0($,V))}},unescape:(J,X={})=>Z.unescape(J,G0($,X)),escape:(J,X={})=>Z.escape(J,G0($,X)),filter:(J,X={})=>Z.filter(J,G0($,X)),defaults:(J)=>Z.defaults(G0($,J)),makeRe:(J,X={})=>Z.makeRe(J,G0($,X)),braceExpand:(J,X={})=>Z.braceExpand(J,G0($,X)),match:(J,X,V={})=>Z.match(J,X,G0($,V)),sep:Z.sep,GLOBSTAR:m})};$0.defaults=E8;var h5=($,Z={})=>{if(d4($),Z.nobrace||!/\{(?:(?!\{).)*\}/.test($))return[$];return M5($,{max:Z.braceExpandMax})};$0.braceExpand=h5;var S8=($,Z={})=>new j0($,Z).makeRe();$0.makeRe=S8;var T8=($,Z,Q={})=>{let J=new j0(Z,Q);if($=$.filter((X)=>J.match(X)),J.options.nonull&&!$.length)$.push(Z);return $};$0.match=T8;var O5=/[?*]|[+@!]\(.*?\)|\[|\]/,k8=($)=>$.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");class j0{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;maxGlobstarRecursion;regexp;constructor($,Z={}){d4($),Z=Z||{},this.options=Z,this.maxGlobstarRecursion=Z.maxGlobstarRecursion??200,this.pattern=$,this.platform=Z.platform||f5,this.isWindows=this.platform==="win32";let Q="allowWindowsEscape";if(this.windowsPathsNoEscape=!!Z.windowsPathsNoEscape||Z[Q]===!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 Q=this.globSet.map((X)=>this.slashSplit(X));this.globParts=this.preprocess(Q),this.debug(this.pattern,this.globParts);let J=this.globParts.map((X,V,K)=>{if(this.isWindows&&this.windowsNoMagicRoot){let W=X[0]===""&&X[1]===""&&(X[2]==="?"||!O5.test(X[2]))&&!O5.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,J),this.set=J.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 Q=0;Q<$.length;Q++)for(let J=0;J<$[Q].length;J++)if($[Q][J]==="**")$[Q][J]="*"}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 Q=-1;while((Q=Z.indexOf("**",Q+1))!==-1){let J=Q;while(Z[J+1]==="**")J++;if(J!==Q)Z.splice(Q,J-Q)}return Z})}levelOneOptimize($){return $.map((Z)=>{return Z=Z.reduce((Q,J)=>{let X=Q[Q.length-1];if(J==="**"&&X==="**")return Q;if(J===".."){if(X&&X!==".."&&X!=="."&&X!=="**")return Q.pop(),Q}return Q.push(J),Q},[]),Z.length===0?[""]:Z})}levelTwoFileOptimize($){if(!Array.isArray($))$=this.slashSplit($);let Z=!1;do{if(Z=!1,!this.preserveMultipleSlashes){for(let J=1;J<$.length-1;J++){let X=$[J];if(J===1&&X===""&&$[0]==="")continue;if(X==="."||X==="")Z=!0,$.splice(J,1),J--}if($[0]==="."&&$.length===2&&($[1]==="."||$[1]===""))Z=!0,$.pop()}let Q=0;while((Q=$.indexOf("..",Q+1))!==-1){let J=$[Q-1];if(J&&J!=="."&&J!==".."&&J!=="**")Z=!0,$.splice(Q-1,2),Q-=2}}while(Z);return $.length===0?[""]:$}firstPhasePreProcess($){let Z=!1;do{Z=!1;for(let Q of $){let J=-1;while((J=Q.indexOf("**",J+1))!==-1){let V=J;while(Q[V+1]==="**")V++;if(V>J)Q.splice(J+1,V-J);let K=Q[J+1],W=Q[J+2],H=Q[J+3];if(K!=="..")continue;if(!W||W==="."||W===".."||!H||H==="."||H==="..")continue;Z=!0,Q.splice(J,1);let q=Q.slice(0);q[J]="**",$.push(q),J--}if(!this.preserveMultipleSlashes){for(let V=1;V<Q.length-1;V++){let K=Q[V];if(V===1&&K===""&&Q[0]==="")continue;if(K==="."||K==="")Z=!0,Q.splice(V,1),V--}if(Q[0]==="."&&Q.length===2&&(Q[1]==="."||Q[1]===""))Z=!0,Q.pop()}let X=0;while((X=Q.indexOf("..",X+1))!==-1){let V=Q[X-1];if(V&&V!=="."&&V!==".."&&V!=="**"){Z=!0;let W=X===1&&Q[X+1]==="**"?["."]:[];if(Q.splice(X-1,2,...W),Q.length===0)Q.push("");X-=2}}}}while(Z);return $}secondPhasePreProcess($){for(let Z=0;Z<$.length-1;Z++)for(let Q=Z+1;Q<$.length;Q++){let J=this.partsMatch($[Z],$[Q],!this.preserveMultipleSlashes);if(J){$[Z]=[],$[Q]=J;break}}return $.filter((Z)=>Z.length)}partsMatch($,Z,Q=!1){let J=0,X=0,V=[],K="";while(J<$.length&&X<Z.length)if($[J]===Z[X])V.push(K==="b"?Z[X]:$[J]),J++,X++;else if(Q&&$[J]==="**"&&Z[X]===$[J+1])V.push($[J]),J++;else if(Q&&Z[X]==="**"&&$[J]===Z[X+1])V.push(Z[X]),X++;else if($[J]==="*"&&Z[X]&&(this.options.dot||!Z[X].startsWith("."))&&Z[X]!=="**"){if(K==="b")return!1;K="a",V.push($[J]),J++,X++}else if(Z[X]==="*"&&$[J]&&(this.options.dot||!$[J].startsWith("."))&&$[J]!=="**"){if(K==="a")return!1;K="b",V.push(Z[X]),J++,X++}else return!1;return $.length===Z.length&&V}parseNegate(){if(this.nonegate)return;let $=this.pattern,Z=!1,Q=0;for(let J=0;J<$.length&&$.charAt(J)==="!";J++)Z=!Z,Q++;if(Q)this.pattern=$.slice(Q);this.negate=Z}matchOne($,Z,Q=!1){let J=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,J=z}}let{optimizationLevel:V=1}=this.options;if(V>=2)$=this.levelTwoFileOptimize($);if(Z.includes(m))return this.#$($,Z,Q,J,X);return this.#X($,Z,Q,J,X)}#$($,Z,Q,J,X){let V=Z.indexOf(m,X),K=Z.lastIndexOf(m),[W,H,q]=Q?[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(J,J+W.length);if(!this.#X(w,W,Q,0,0))return!1;J+=W.length,X+=W.length}let z=0;if(q.length){if(q.length+J>$.length)return!1;let w=$.length-q.length;if(this.#X($,q,Q,w,0))z=q.length;else{if($[$.length-1]!==""||J+q.length===$.length)return!1;if(w--,!this.#X($,q,Q,w,0))return!1;z=q.length+1}}if(!H.length){let w=!!z;for(let D=J;D<$.length-z;D++){let I=String($[D]);if(w=!0,I==="."||I===".."||!this.options.dot&&I.startsWith("."))return!1}return Q||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.#J($,G,J,0,Q,0,!!z)}#J($,Z,Q,J,X,V,K){let W=Z[J];if(!W){for(let z=Q;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(Q<=q){if(this.#X($.slice(0,Q+H.length),H,X,Q,0)&&V<this.maxGlobstarRecursion){let U=this.#J($,Z,Q+H.length,J+1,X,V+1,K);if(U!==!1)return U}let G=$[Q];if(G==="."||G===".."||!this.options.dot&&G.startsWith("."))return!1;Q++}return X||null}#X($,Z,Q,J,X){let V,K,W,H;for(V=J,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 Q;else if(K===W)return V===H-1&&$[V]==="";else throw Error("wtf?")}braceExpand(){return h5(this.pattern,this.options)}parse($){d4($);let Z=this.options;if($==="**")return m;if($==="")return"";let Q,J=null;if(Q=$.match(U8))J=Z.dot?B8:A8;else if(Q=$.match(X8))J=(Z.nocase?Z.dot?H8:W8:Z.dot?K8:V8)(Q[1]);else if(Q=$.match(L8))J=(Z.nocase?Z.dot?w8:_8:Z.dot?R8:C8)(Q);else if(Q=$.match(q8))J=Z.dot?z8:Y8;else if(Q=$.match(G8))J=j8;let X=B4.fromGlob($,this.options).toMMPattern();if(J&&typeof X==="object")Reflect.defineProperty(X,"test",{value:J});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,Q=Z.noglobstar?D8:Z.dot?F8:M8,J=new Set(Z.nocase?["i"]:[]),X=$.map((W)=>{let H=W.map((z)=>{if(z instanceof RegExp)for(let G of z.flags.split(""))J.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]="(?:\\/|"+Q+"\\/)?"+U;else H[G]=Q;else if(U===void 0)H[G-1]=L+"(?:\\/|\\/"+Q+")?";else if(U!==m)H[G-1]=L+"(?:\\/|\\/"+Q+"\\/)"+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,[...J].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 Q=this.options;if(this.isWindows)$=$.split("\\").join("/");let J=this.slashSplit($);this.debug(this.pattern,"split",J);let X=this.set;this.debug(this.pattern,"set",X);let V=J[J.length-1];if(!V)for(let K=J.length-2;!V&&K>=0;K--)V=J[K];for(let K=0;K<X.length;K++){let W=X[K],H=J;if(Q.matchBase&&W.length===1)H=[V];if(this.matchOne(H,W,Z)){if(Q.flipNegate)return!0;return!this.negate}}if(Q.flipNegate)return!1;return this.negate}static defaults($){return $0.defaults($).Minimatch}}$0.AST=B4;$0.Minimatch=j0;$0.escape=L4;$0.unescape=_0;import{fileURLToPath as zZ}from"url";var x8=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,d5=new Set,z2=typeof process=="object"&&process?process:{},u5=($,Z,Q,J)=>{typeof z2.emitWarning=="function"?z2.emitWarning($,Z,Q,J):console.error(`[${Q}] ${Z}: ${$}`)},U6=globalThis.AbortController,g5=globalThis.AbortSignal;if(typeof U6>"u"){g5=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(Q,J){this._onabort.push(J)}},U6=class{constructor(){Z()}signal=new g5;abort(Q){if(!this.signal.aborted){this.signal.reason=Q,this.signal.aborted=!0;for(let J of this.signal._onabort)J(Q);this.signal.onabort?.(Q)}}};let $=z2.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",Z=()=>{$&&($=!1,u5("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 v8=($)=>!d5.has($),cK=Symbol("type"),s0=($)=>$&&$===Math.floor($)&&$>0&&isFinite($),m5=($)=>s0($)?$<=Math.pow(2,8)?Uint8Array:$<=Math.pow(2,16)?Uint16Array:$<=Math.pow(2,32)?Uint32Array:$<=Number.MAX_SAFE_INTEGER?j6:null:null,j6=class extends Array{constructor($){super($),this.fill(0)}},O8=class ${heap;length;static#$=!1;static create(Z){let Q=m5(Z);if(!Q)return[];$.#$=!0;let J=new $(Z,Q);return $.#$=!1,J}constructor(Z,Q){if(!$.#$)throw TypeError("instantiate Stack using Stack.create(n)");this.heap=new Q(Z),this.length=0}push(Z){this.heap[this.length++]=Z}pop(){return this.heap[--this.length]}},m4=class ${#$;#J;#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;#M;#B;#N;#D;#j;#L;#R;#I;#Q;#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.#M,isBackgroundFetch:(Q)=>Z.#q(Q),backgroundFetch:(Q,J,X,V)=>Z.#m(Q,J,X,V),moveToTail:(Q)=>Z.#b(Q),indexes:(Q)=>Z.#T(Q),rindexes:(Q)=>Z.#k(Q),isStale:(Q)=>Z.#F(Q)}}get max(){return this.#$}get maxSize(){return this.#J}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:Q=0,ttl:J,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:M,allowStaleOnFetchAbort:d,ignoreFetchAbort:k,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??x8,Q!==0&&!s0(Q))throw TypeError("max option must be a nonnegative integer");let K0=Q?m5(Q):Array;if(!K0)throw Error("invalid max value: "+Q);if(this.#$=Q,this.#J=B,this.maxEntrySize=_||this.#J,this.sizeCalculation=R,this.sizeCalculation){if(!this.#J&&!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(Q).fill(void 0),this.#V=Array(Q).fill(void 0),this.#w=new K0(Q),this.#C=new K0(Q),this.#U=0,this.#A=0,this.#M=O8.create(Q),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.#Q=!!this.#K,this.noDisposeOnSet=!!U,this.noUpdateTTL=!!L,this.noDeleteOnFetchRejection=!!I,this.allowStaleOnFetchRejection=!!M,this.allowStaleOnFetchAbort=!!d,this.ignoreFetchAbort=!!k,this.maxEntrySize!==0){if(this.#J!==0&&!s0(this.#J))throw TypeError("maxSize must be a positive integer if specified");if(!s0(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=s0(X)||X===0?X:1,this.ttlAutopurge=!!V,this.ttl=J||0,this.ttl){if(!s0(this.ttl))throw TypeError("ttl must be a positive integer if specified");this.#x()}if(this.#$===0&&this.ttl===0&&this.#J===0)throw TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#$&&!this.#J){let t="LRU_CACHE_UNBOUNDED";v8(t)&&(d5.add(t),u5("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 j6(this.#$),Q=new j6(this.#$);this.#j=Z,this.#D=Q;let J=this.ttlAutopurge?Array(this.#$):void 0;this.#L=J,this.#h=(K,W,H=this.#z.now())=>{if(Q[K]=W!==0?H:0,Z[K]=W,J?.[K]&&(clearTimeout(J[K]),J[K]=void 0),W!==0&&J){let q=setTimeout(()=>{this.#F(K)&&this.#S(this.#H[K],"expire")},W+1);q.unref&&q.unref(),J[K]=q}},this.#E=(K)=>{Q[K]=Z[K]!==0?this.#z.now():0},this.#v=(K,W)=>{if(Z[W]){let H=Z[W],q=Q[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=Q[W];if(!H||!q)return 1/0;let z=(X||V())-q;return H-z},this.#F=(K)=>{let W=Q[K],H=Z[K];return!!H&&!!W&&(X||V())-W>H}}#E=()=>{};#v=()=>{};#h=()=>{};#F=()=>!1;#l(){let Z=new j6(this.#$);this.#G=0,this.#N=Z,this.#f=(Q)=>{this.#G-=Z[Q],Z[Q]=0},this.#g=(Q,J,X,V)=>{if(this.#q(J))return 0;if(!s0(X))if(V){if(typeof V!="function")throw TypeError("sizeCalculation must be a function");if(X=V(J,Q),!s0(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=(Q,J,X)=>{if(Z[Q]=J,this.#J){let V=this.#J-Z[Q];for(;this.#G>V;)this.#u(!0)}this.#G+=Z[Q],X&&(X.entrySize=J,X.totalCalculatedSize=this.#G)}}#f=(Z)=>{};#y=(Z,Q,J)=>{};#g=(Z,Q,J,X)=>{if(J||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 Q=this.#A;!(!this.#d(Q)||((Z||!this.#F(Q))&&(yield Q),Q===this.#U));)Q=this.#C[Q]}*#k({allowStale:Z=this.allowStale}={}){if(this.#W)for(let Q=this.#U;!(!this.#d(Q)||((Z||!this.#F(Q))&&(yield Q),Q===this.#A));)Q=this.#w[Q]}#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.#k())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 Q=this.#H[Z];Q!==void 0&&!this.#q(this.#V[Z])&&(yield Q)}}*rkeys(){for(let Z of this.#k()){let Q=this.#H[Z];Q!==void 0&&!this.#q(this.#V[Z])&&(yield Q)}}*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.#k())this.#V[Z]!==void 0&&!this.#q(this.#V[Z])&&(yield this.#V[Z])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(Z,Q={}){for(let J of this.#T()){let X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;if(V!==void 0&&Z(V,this.#H[J],this))return this.get(this.#H[J],Q)}}forEach(Z,Q=this){for(let J of this.#T()){let X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(Q,V,this.#H[J],this)}}rforEach(Z,Q=this){for(let J of this.#k()){let X=this.#V[J],V=this.#q(X)?X.__staleWhileFetching:X;V!==void 0&&Z.call(Q,V,this.#H[J],this)}}purgeStale(){let Z=!1;for(let Q of this.#k({allowStale:!0}))this.#F(Q)&&(this.#S(this.#H[Q],"expire"),Z=!0);return Z}info(Z){let Q=this.#Y.get(Z);if(Q===void 0)return;let J=this.#V[Q],X=this.#q(J)?J.__staleWhileFetching:J;if(X===void 0)return;let V={value:X};if(this.#j&&this.#D){let K=this.#j[Q],W=this.#D[Q];if(K&&W){let H=K-(this.#z.now()-W);V.ttl=H,V.start=Date.now()}}return this.#N&&(V.size=this.#N[Q]),V}dump(){let Z=[];for(let Q of this.#T({allowStale:!0})){let J=this.#H[Q],X=this.#V[Q],V=this.#q(X)?X.__staleWhileFetching:X;if(V===void 0||J===void 0)continue;let K={value:V};if(this.#j&&this.#D){K.ttl=this.#j[Q];let W=this.#z.now()-this.#D[Q];K.start=Math.floor(Date.now()-W)}this.#N&&(K.size=this.#N[Q]),Z.unshift([J,K])}return Z}load(Z){this.clear();for(let[Q,J]of Z){if(J.start){let X=Date.now()-J.start;J.start=this.#z.now()-X}this.set(Q,J.value,J)}}set(Z,Q,J={}){if(Q===void 0)return this.delete(Z),this;let{ttl:X=this.ttl,start:V,noDisposeOnSet:K=this.noDisposeOnSet,sizeCalculation:W=this.sizeCalculation,status:H}=J,{noUpdateTTL:q=this.noUpdateTTL}=J,z=this.#g(Z,Q,J.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.#M.length!==0?this.#M.pop():this.#W===this.#$?this.#u(!1):this.#W,this.#H[G]=Z,this.#V[G]=Q,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?.(Q,Z,"add");else{this.#b(G);let U=this.#V[G];if(Q!==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.#Q&&this.#B?.push([L,Z,"set"]))}else K||(this.#R&&this.#X?.(U,Z,"set"),this.#Q&&this.#B?.push([U,Z,"set"]));if(this.#f(G),this.#y(G,z,H),this.#V[G]=Q,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?.(Q,Z,Q===U?"update":"replace")}if(X!==0&&!this.#j&&this.#x(),this.#j&&(q||this.#h(G,X,V),H&&this.#v(H,G)),!K&&this.#Q&&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.#Q&&this.#B){let Z=this.#B,Q;for(;Q=Z?.shift();)this.#K?.(...Q)}}}#u(Z){let Q=this.#U,J=this.#H[Q],X=this.#V[Q];return this.#I&&this.#q(X)?X.__abortController.abort(Error("evicted")):(this.#R||this.#Q)&&(this.#R&&this.#X?.(X,J,"evict"),this.#Q&&this.#B?.push([X,J,"evict"])),this.#f(Q),this.#L?.[Q]&&(clearTimeout(this.#L[Q]),this.#L[Q]=void 0),Z&&(this.#H[Q]=void 0,this.#V[Q]=void 0,this.#M.push(Q)),this.#W===1?(this.#U=this.#A=0,this.#M.length=0):this.#U=this.#w[Q],this.#Y.delete(J),this.#W--,Q}has(Z,Q={}){let{updateAgeOnHas:J=this.updateAgeOnHas,status:X}=Q,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.#F(V))X&&(X.has="stale",this.#v(X,V));else return J&&this.#E(V),X&&(X.has="hit",this.#v(X,V)),!0}else X&&(X.has="miss");return!1}peek(Z,Q={}){let{allowStale:J=this.allowStale}=Q,X=this.#Y.get(Z);if(X===void 0||!J&&this.#F(X))return;let V=this.#V[X];return this.#q(V)?V.__staleWhileFetching:V}#m(Z,Q,J,X){let V=Q===void 0?void 0:this.#V[Q];if(this.#q(V))return V;let K=new U6,{signal:W}=J;W?.addEventListener("abort",()=>K.abort(W.reason),{signal:K.signal});let H={signal:K.signal,options:J,context:X},q=(_,R=!1)=>{let{aborted:w}=K.signal,D=J.ignoreFetchAbort&&_!==void 0,I=J.ignoreFetchAbort||!!(J.allowStaleOnFetchAbort&&_!==void 0);if(J.status&&(w&&!R?(J.status.fetchAborted=!0,J.status.fetchError=K.signal.reason,D&&(J.status.fetchAbortIgnored=!0)):J.status.fetchResolved=!0),w&&!D&&!R)return G(K.signal.reason,I);let S=L,M=this.#V[Q];return(M===L||D&&R&&M===void 0)&&(_===void 0?S.__staleWhileFetching!==void 0?this.#V[Q]=S.__staleWhileFetching:this.#S(Z,"fetch"):(J.status&&(J.status.fetchUpdated=!0),this.set(Z,_,H.options))),_},z=(_)=>(J.status&&(J.status.fetchRejected=!0,J.status.fetchError=_),G(_,!1)),G=(_,R)=>{let{aborted:w}=K.signal,D=w&&J.allowStaleOnFetchAbort,I=D||J.allowStaleOnFetchRejection,S=I||J.noDeleteOnFetchRejection,M=L;if(this.#V[Q]===L&&(!S||!R&&M.__staleWhileFetching===void 0?this.#S(Z,"fetch"):D||(this.#V[Q]=M.__staleWhileFetching)),I)return J.status&&M.__staleWhileFetching!==void 0&&(J.status.returnedStale=!0),M.__staleWhileFetching;if(M.__returned===M)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",()=>{(!J.ignoreFetchAbort||J.allowStaleOnFetchAbort)&&(_(void 0),J.allowStaleOnFetchAbort&&(_=(D)=>q(D,!0)))})};J.status&&(J.status.fetchDispatched=!0);let L=new Promise(U).then(q,z),B=Object.assign(L,{__abortController:K,__staleWhileFetching:V,__returned:void 0});return Q===void 0?(this.set(Z,B,{...H.options,status:void 0}),Q=this.#Y.get(Z)):this.#V[Q]=B,B}#q(Z){if(!this.#I)return!1;let Q=Z;return!!Q&&Q instanceof Promise&&Q.hasOwnProperty("__staleWhileFetching")&&Q.__abortController instanceof U6}async fetch(Z,Q={}){let{allowStale:J=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}=Q;if(!this.#I)return w&&(w.fetch="get"),this.get(Z,{allowStale:J,updateAgeOnGet:X,noDeleteOnStaleGet:V,status:w});let I={allowStale:J,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 M=this.#m(Z,S,I,_);return M.__returned=M}else{let M=this.#V[S];if(this.#q(M)){let K0=J&&M.__staleWhileFetching!==void 0;return w&&(w.fetch="inflight",K0&&(w.returnedStale=!0)),K0?M.__staleWhileFetching:M.__returned=M}let d=this.#F(S);if(!R&&!d)return w&&(w.fetch="hit"),this.#b(S),X&&this.#E(S),w&&this.#v(w,S),M;let k=this.#m(Z,S,I,_),l=k.__staleWhileFetching!==void 0&&J;return w&&(w.fetch=d?"stale":"refresh",l&&d&&(w.returnedStale=!0)),l?k.__staleWhileFetching:k.__returned=k}}async forceFetch(Z,Q={}){let J=await this.fetch(Z,Q);if(J===void 0)throw Error("fetch() returned undefined");return J}memo(Z,Q={}){let J=this.#_;if(!J)throw Error("no memoMethod provided to constructor");let{context:X,forceRefresh:V,...K}=Q,W=this.get(Z,K);if(!V&&W!==void 0)return W;let H=J(Z,W,{options:K,context:X});return this.set(Z,H,K),H}get(Z,Q={}){let{allowStale:J=this.allowStale,updateAgeOnGet:X=this.updateAgeOnGet,noDeleteOnStaleGet:V=this.noDeleteOnStaleGet,status:K}=Q,W=this.#Y.get(Z);if(W!==void 0){let H=this.#V[W],q=this.#q(H);return K&&this.#v(K,W),this.#F(W)?(K&&(K.get="stale"),q?(K&&J&&H.__staleWhileFetching!==void 0&&(K.returnedStale=!0),J?H.__staleWhileFetching:void 0):(V||this.#S(Z,"expire"),K&&J&&(K.returnedStale=!0),J?H:void 0)):(K&&(K.get="hit"),q?H.__staleWhileFetching:(this.#b(W),X&&this.#E(W),H))}else K&&(K.get="miss")}#c(Z,Q){this.#C[Q]=Z,this.#w[Z]=Q}#b(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,Q){let J=!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),J=!0,this.#W===1)this.#p(Q);else{this.#f(X);let V=this.#V[X];if(this.#q(V)?V.__abortController.abort(Error("deleted")):(this.#R||this.#Q)&&(this.#R&&this.#X?.(V,Z,Q),this.#Q&&this.#B?.push([V,Z,Q])),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.#M.push(X)}}if(this.#Q&&this.#B?.length){let X=this.#B,V;for(;V=X?.shift();)this.#K?.(...V)}return J}clear(){return this.#p("delete")}#p(Z){for(let Q of this.#k({allowStale:!0})){let J=this.#V[Q];if(this.#q(J))J.__abortController.abort(Error("deleted"));else{let X=this.#H[Q];this.#R&&this.#X?.(J,X,Z),this.#Q&&this.#B?.push([J,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 Q of this.#L??[])Q!==void 0&&clearTimeout(Q);this.#L?.fill(void 0)}if(this.#N&&this.#N.fill(0),this.#U=0,this.#A=0,this.#M.length=0,this.#G=0,this.#W=0,this.#Q&&this.#B){let Q=this.#B,J;for(;J=Q?.shift();)this.#K?.(...J)}}};import{posix as p8,win32 as C2}from"path";import{fileURLToPath as a8}from"url";import{lstatSync as r8,readdir as n8,readdirSync as i8,readlinkSync as s8,realpathSync as o8}from"fs";import*as e8 from"fs";import{lstat as $Z,readdir as ZZ,readlink as QZ,realpath as JZ}from"fs/promises";import{EventEmitter as L2}from"events";import r5 from"stream";import{StringDecoder as y8}from"string_decoder";var c5=typeof process==="object"&&process?process:{stdout:null,stderr:null},b8=($)=>!!$&&typeof $==="object"&&($ instanceof W4||$ instanceof r5||f8($)||h8($)),f8=($)=>!!$&&typeof $==="object"&&$ instanceof L2&&typeof $.pipe==="function"&&$.pipe!==r5.Writable.prototype.pipe,h8=($)=>!!$&&typeof $==="object"&&$ instanceof L2&&typeof $.write==="function"&&typeof $.end==="function",d0=Symbol("EOF"),u0=Symbol("maybeEmitEnd"),o0=Symbol("emittedEnd"),A6=Symbol("emittingEnd"),c4=Symbol("emittedError"),B6=Symbol("closed"),l5=Symbol("read"),L6=Symbol("flush"),p5=Symbol("flushChunk"),w0=Symbol("encoding"),_4=Symbol("decoder"),a=Symbol("flowing"),l4=Symbol("paused"),w4=Symbol("resume"),r=Symbol("buffer"),Z0=Symbol("pipes"),n=Symbol("bufferLength"),G2=Symbol("bufferPush"),_6=Symbol("bufferShift"),o=Symbol("objectMode"),c=Symbol("destroyed"),j2=Symbol("error"),U2=Symbol("emitData"),a5=Symbol("emitEnd"),A2=Symbol("emitEnd2"),F0=Symbol("async"),B2=Symbol("abort"),w6=Symbol("aborted"),p4=Symbol("signal"),K4=Symbol("dataListeners"),Y0=Symbol("discarded"),a4=($)=>Promise.resolve().then($),g8=($)=>$(),d8=($)=>$==="end"||$==="finish"||$==="prefinish",u8=($)=>$ instanceof ArrayBuffer||!!$&&typeof $==="object"&&$.constructor&&$.constructor.name==="ArrayBuffer"&&$.byteLength>=0,m8=($)=>!Buffer.isBuffer($)&&ArrayBuffer.isView($);class _2{src;dest;opts;ondrain;constructor($,Z,Q){this.src=$,this.dest=Z,this.opts=Q,this.ondrain=()=>$[w4](),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 n5 extends _2{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor($,Z,Q){super($,Z,Q);this.proxyErrors=(J)=>this.dest.emit("error",J),$.on("error",this.proxyErrors)}}var c8=($)=>!!$.objectMode,l8=($)=>!$.objectMode&&!!$.encoding&&$.encoding!=="buffer";class W4 extends L2{[a]=!1;[l4]=!1;[Z0]=[];[r]=[];[o];[w0];[F0];[_4];[d0]=!1;[o0]=!1;[A6]=!1;[B6]=!1;[c4]=null;[n]=0;[c]=!1;[p4];[w6]=!1;[K4]=0;[Y0]=!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(c8(Z))this[o]=!0,this[w0]=null;else if(l8(Z))this[w0]=Z.encoding,this[o]=!1;else this[o]=!1,this[w0]=null;if(this[F0]=!!Z.async,this[_4]=this[w0]?new y8(this[w0]):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:Q}=Z;if(Q)if(this[p4]=Q,Q.aborted)this[B2]();else Q.addEventListener("abort",()=>this[B2]())}get bufferLength(){return this[n]}get encoding(){return this[w0]}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]||!!$}[B2](){this[w6]=!0,this.emit("abort",this[p4]?.reason),this.destroy(this[p4]?.reason)}get aborted(){return this[w6]}set aborted($){}write($,Z,Q){if(this[w6])return!1;if(this[d0])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")Q=Z,Z="utf8";if(!Z)Z="utf8";let J=this[F0]?a4:g8;if(!this[o]&&!Buffer.isBuffer($)){if(m8($))$=Buffer.from($.buffer,$.byteOffset,$.byteLength);else if(u8($))$=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[L6](!0);if(this[a])this.emit("data",$);else this[G2]($);if(this[n]!==0)this.emit("readable");if(Q)J(Q);return this[a]}if(!$.length){if(this[n]!==0)this.emit("readable");if(Q)J(Q);return this[a]}if(typeof $==="string"&&!(Z===this[w0]&&!this[_4]?.lastNeed))$=Buffer.from($,Z);if(Buffer.isBuffer($)&&this[w0])$=this[_4].write($);if(this[a]&&this[n]!==0)this[L6](!0);if(this[a])this.emit("data",$);else this[G2]($);if(this[n]!==0)this.emit("readable");if(Q)J(Q);return this[a]}read($){if(this[c])return null;if(this[Y0]=!1,this[n]===0||$===0||$&&$>this[n])return this[u0](),null;if(this[o])$=null;if(this[r].length>1&&!this[o])this[r]=[this[w0]?this[r].join(""):Buffer.concat(this[r],this[n])];let Z=this[l5]($||null,this[r][0]);return this[u0](),Z}[l5]($,Z){if(this[o])this[_6]();else{let Q=Z;if($===Q.length||$===null)this[_6]();else if(typeof Q==="string")this[r][0]=Q.slice($),Z=Q.slice(0,$),this[n]-=$;else this[r][0]=Q.subarray($),Z=Q.subarray(0,$),this[n]-=$}if(this.emit("data",Z),!this[r].length&&!this[d0])this.emit("drain");return Z}end($,Z,Q){if(typeof $==="function")Q=$,$=void 0;if(typeof Z==="function")Q=Z,Z="utf8";if($!==void 0)this.write($,Z);if(Q)this.once("end",Q);if(this[d0]=!0,this.writable=!1,this[a]||!this[l4])this[u0]();return this}[w4](){if(this[c])return;if(!this[K4]&&!this[Z0].length)this[Y0]=!0;if(this[l4]=!1,this[a]=!0,this.emit("resume"),this[r].length)this[L6]();else if(this[d0])this[u0]();else this.emit("drain")}resume(){return this[w4]()}pause(){this[a]=!1,this[l4]=!0,this[Y0]=!1}get destroyed(){return this[c]}get flowing(){return this[a]}get paused(){return this[l4]}[G2]($){if(this[o])this[n]+=1;else this[n]+=$.length;this[r].push($)}[_6](){if(this[o])this[n]-=1;else this[n]-=this[r][0].length;return this[r].shift()}[L6]($=!1){do;while(this[p5](this[_6]())&&this[r].length);if(!$&&!this[r].length&&!this[d0])this.emit("drain")}[p5]($){return this.emit("data",$),this[a]}pipe($,Z){if(this[c])return $;this[Y0]=!1;let Q=this[o0];if(Z=Z||{},$===c5.stdout||$===c5.stderr)Z.end=!1;else Z.end=Z.end!==!1;if(Z.proxyErrors=!!Z.proxyErrors,Q){if(Z.end)$.end()}else if(this[Z0].push(!Z.proxyErrors?new _2(this,$,Z):new n5(this,$,Z)),this[F0])a4(()=>this[w4]());else this[w4]();return $}unpipe($){let Z=this[Z0].find((Q)=>Q.dest===$);if(Z){if(this[Z0].length===1){if(this[a]&&this[K4]===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 Q=super.on($,Z);if($==="data"){if(this[Y0]=!1,this[K4]++,!this[Z0].length&&!this[a])this[w4]()}else if($==="readable"&&this[n]!==0)super.emit("readable");else if(d8($)&&this[o0])super.emit($),this.removeAllListeners($);else if($==="error"&&this[c4]){let J=Z;if(this[F0])a4(()=>J.call(this,this[c4]));else J.call(this,this[c4])}return Q}removeListener($,Z){return this.off($,Z)}off($,Z){let Q=super.off($,Z);if($==="data"){if(this[K4]=this.listeners("data").length,this[K4]===0&&!this[Y0]&&!this[Z0].length)this[a]=!1}return Q}removeAllListeners($){let Z=super.removeAllListeners($);if($==="data"||$===void 0){if(this[K4]=0,!this[Y0]&&!this[Z0].length)this[a]=!1}return Z}get emittedEnd(){return this[o0]}[u0](){if(!this[A6]&&!this[o0]&&!this[c]&&this[r].length===0&&this[d0]){if(this[A6]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[B6])this.emit("close");this[A6]=!1}}emit($,...Z){let Q=Z[0];if($!=="error"&&$!=="close"&&$!==c&&this[c])return!1;else if($==="data")return!this[o]&&!Q?!1:this[F0]?(a4(()=>this[U2](Q)),!0):this[U2](Q);else if($==="end")return this[a5]();else if($==="close"){if(this[B6]=!0,!this[o0]&&!this[c])return!1;let X=super.emit("close");return this.removeAllListeners("close"),X}else if($==="error"){this[c4]=Q,super.emit(j2,Q);let X=!this[p4]||this.listeners("error").length?super.emit("error",Q):!1;return this[u0](),X}else if($==="resume"){let X=super.emit("resume");return this[u0](),X}else if($==="finish"||$==="prefinish"){let X=super.emit($);return this.removeAllListeners($),X}let J=super.emit($,...Z);return this[u0](),J}[U2]($){for(let Q of this[Z0])if(Q.dest.write($)===!1)this.pause();let Z=this[Y0]?!1:super.emit("data",$);return this[u0](),Z}[a5](){if(this[o0])return!1;return this[o0]=!0,this.readable=!1,this[F0]?(a4(()=>this[A2]()),!0):this[A2]()}[A2](){if(this[_4]){let Z=this[_4].end();if(Z){for(let Q of this[Z0])Q.dest.write(Z);if(!this[Y0])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",(Q)=>{if($.push(Q),!this[o])$.dataLength+=Q.length}),await Z,$}async concat(){if(this[o])throw Error("cannot concat in objectMode");let $=await this.collect();return this[w0]?$.join(""):Buffer.concat($,$.dataLength)}async promise(){return new Promise(($,Z)=>{this.on(c,()=>Z(Error("stream destroyed"))),this.on("error",(Q)=>Z(Q)),this.on("end",()=>$())})}[Symbol.asyncIterator](){this[Y0]=!1;let $=!1,Z=async()=>{return this.pause(),$=!0,{value:void 0,done:!0}};return{next:()=>{if($)return Z();let J=this.read();if(J!==null)return Promise.resolve({done:!1,value:J});if(this[d0])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[d0]})},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[Y0]=!1;let $=!1,Z=()=>{return this.pause(),this.off(j2,Z),this.off(c,Z),this.off("end",Z),$=!0,{done:!0,value:void 0}},Q=()=>{if($)return Z();let J=this.read();return J===null?Z():{done:!1,value:J}};return this.once("end",Z),this.once(j2,Z),this.once(c,Z),{next:Q,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[Y0]=!0,this[r].length=0,this[n]=0;let Z=this;if(typeof Z.close==="function"&&!this[B6])Z.close();if($)this.emit("error",$);else this.emit(c);return this}static get isStream(){return b8}}var t8=o8.native,n4={lstatSync:r8,readdir:n8,readdirSync:i8,readlinkSync:s8,realpathSync:t8,promises:{lstat:$Z,readdir:ZZ,readlink:QZ,realpath:JZ}},t5=($)=>!$||$===n4||$===e8?n4:{...n4,...$,promises:{...n4.promises,...$.promises||{}}},$1=/^\\\\\?\\([a-z]:)\\?$/i,XZ=($)=>$.replace(/\//g,"\\").replace($1,"$1\\"),VZ=/[\\\/]/,A0=0,Z1=1,Q1=2,M0=4,J1=6,X1=8,H4=10,V1=12,U0=15,r4=~U0,w2=16,i5=32,i4=64,R0=128,R6=256,N6=512,s5=i4|R0|N6,KZ=1023,R2=($)=>$.isFile()?X1:$.isDirectory()?M0:$.isSymbolicLink()?H4:$.isCharacterDevice()?Q1:$.isBlockDevice()?J1:$.isSocket()?V1:$.isFIFO()?Z1:A0,o5=new m4({max:4096}),s4=($)=>{let Z=o5.get($);if(Z)return Z;let Q=$.normalize("NFKD");return o5.set($,Q),Q},e5=new m4({max:4096}),C6=($)=>{let Z=e5.get($);if(Z)return Z;let Q=s4($.toLowerCase());return e5.set($,Q),Q};class N2 extends m4{constructor(){super({max:256})}}class K1 extends m4{constructor($=16384){super({maxSize:$,sizeCalculation:(Z)=>Z.length+1})}}var W1=Symbol("PathScurry setAsCwd");class Q0{name;root;roots;parent;nocase;isCWD=!1;#$;#J;get dev(){return this.#J}#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}#M;get ctime(){return this.#M}#B;get birthtime(){return this.#B}#N;#D;#j;#L;#R;#I;#Q;#O;#x;#E;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor($,Z=A0,Q,J,X,V,K){if(this.name=$,this.#N=X?C6($):s4($),this.#Q=Z&KZ,this.nocase=X,this.roots=J,this.root=Q||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.#$=t5(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($),J=$.substring(Z.length).split(this.splitSep);return Z?this.getRoot(Z).#v(J):this.#v(J)}#v($){let Z=this;for(let Q of $)Z=Z.child(Q);return Z}children(){let $=this.#O.get(this);if($)return $;let Z=Object.assign([],{provisional:0});return this.#O.set(this,Z),this.#Q&=~w2,Z}child($,Z){if($===""||$===".")return this;if($==="..")return this.parent||this;let Q=this.children(),J=this.nocase?C6($):s4($);for(let W of Q)if(W.#N===J)return W;let X=this.parent?this.sep:"",V=this.#j?this.#j+X+$:void 0,K=this.newChild($,A0,{...Z,parent:this,fullpath:V});if(!this.canReaddir())K.#Q|=R0;return Q.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 Q=Z.relative();return Q+(!Q||!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 Q=Z.relativePosix();return Q+(!Q||!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 J=Z.fullpath()+(!Z.parent?"":this.sep)+$;return this.#j=J}fullpathPosix(){if(this.#L!==void 0)return this.#L;if(this.sep==="/")return this.#L=this.fullpath();if(!this.parent){let J=this.fullpath().replace(/\\/g,"/");if(/^[a-z]:\//i.test(J))return this.#L=`//?/${J}`;else return this.#L=J}let $=this.parent,Z=$.fullpathPosix(),Q=Z+(!Z||!$.parent?"":"/")+this.name;return this.#L=Q}isUnknown(){return(this.#Q&U0)===A0}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.#Q&U0)===X1}isDirectory(){return(this.#Q&U0)===M0}isCharacterDevice(){return(this.#Q&U0)===Q1}isBlockDevice(){return(this.#Q&U0)===J1}isFIFO(){return(this.#Q&U0)===Z1}isSocket(){return(this.#Q&U0)===V1}isSymbolicLink(){return(this.#Q&H4)===H4}lstatCached(){return this.#Q&i5?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.#Q&U0;return!($!==A0&&$!==H4||this.#Q&R6||this.#Q&R0)}calledReaddir(){return!!(this.#Q&w2)}isENOENT(){return!!(this.#Q&R0)}isNamed($){return!this.nocase?this.#N===s4($):this.#N===C6($)}async readlink(){let $=this.#x;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=await this.#$.promises.readlink(this.fullpath()),Q=(await this.parent.realpath())?.resolve(Z);if(Q)return this.#x=Q}catch(Z){this.#k(Z.code);return}}readlinkSync(){let $=this.#x;if($)return $;if(!this.canReadlink())return;if(!this.parent)return;try{let Z=this.#$.readlinkSync(this.fullpath()),Q=this.parent.realpathSync()?.resolve(Z);if(Q)return this.#x=Q}catch(Z){this.#k(Z.code);return}}#h($){this.#Q|=w2;for(let Z=$.provisional;Z<$.length;Z++){let Q=$[Z];if(Q)Q.#F()}}#F(){if(this.#Q&R0)return;this.#Q=(this.#Q|R0)&r4,this.#l()}#l(){let $=this.children();$.provisional=0;for(let Z of $)Z.#F()}#f(){this.#Q|=N6,this.#y()}#y(){if(this.#Q&i4)return;let $=this.#Q;if(($&U0)===M0)$&=r4;this.#Q=$|i4,this.#l()}#g($=""){if($==="ENOTDIR"||$==="EPERM")this.#y();else if($==="ENOENT")this.#F();else this.children().provisional=0}#T($=""){if($==="ENOTDIR")this.parent.#y();else if($==="ENOENT")this.#F()}#k($=""){let Z=this.#Q;if(Z|=R6,$==="ENOENT")Z|=R0;if($==="EINVAL"||$==="UNKNOWN")Z&=r4;if(this.#Q=Z,$==="ENOTDIR"&&this.parent)this.parent.#y()}#d($,Z){return this.#m($,Z)||this.#u($,Z)}#u($,Z){let Q=R2($),J=this.newChild($.name,Q,{parent:this}),X=J.#Q&U0;if(X!==M0&&X!==H4&&X!==A0)J.#Q|=i4;return Z.unshift(J),Z.provisional++,J}#m($,Z){for(let Q=Z.provisional;Q<Z.length;Q++){let J=Z[Q];if((this.nocase?C6($.name):s4($.name))!==J.#N)continue;return this.#q($,J,Q,Z)}}#q($,Z,Q,J){let X=Z.name;if(Z.#Q=Z.#Q&r4|R2($),X!==$.name)Z.name=$.name;if(Q!==J.provisional){if(Q===J.length-1)J.pop();else J.splice(Q,1);J.unshift(Z)}return J.provisional++,Z}async lstat(){if((this.#Q&R0)===0)try{return this.#c(await this.#$.promises.lstat(this.fullpath())),this}catch($){this.#T($.code)}}lstatSync(){if((this.#Q&R0)===0)try{return this.#c(this.#$.lstatSync(this.fullpath())),this}catch($){this.#T($.code)}}#c($){let{atime:Z,atimeMs:Q,birthtime:J,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=Q,this.#B=J,this.#C=X,this.#z=V,this.#Y=K,this.#M=W,this.#w=H,this.#J=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=R2($);if(this.#Q=this.#Q&r4|I|i5,I!==A0&&I!==M0&&I!==H4)this.#Q|=i4}#b=[];#S=!1;#p($){this.#S=!1;let Z=this.#b.slice();this.#b.length=0,Z.forEach((Q)=>Q(null,$))}readdirCB($,Z=!1){if(!this.canReaddir()){if(Z)$(null,[]);else queueMicrotask(()=>$(null,[]));return}let Q=this.children();if(this.calledReaddir()){let X=Q.slice(0,Q.provisional);if(Z)$(null,X);else queueMicrotask(()=>$(null,X));return}if(this.#b.push($),this.#S)return;this.#S=!0;let J=this.fullpath();this.#$.readdir(J,{withFileTypes:!0},(X,V)=>{if(X)this.#g(X.code),Q.provisional=0;else{for(let K of V)this.#d(K,Q);this.#h(Q)}this.#p(Q.slice(0,Q.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 Q=()=>{};this.#a=new Promise((J)=>Q=J);try{for(let J of await this.#$.promises.readdir(Z,{withFileTypes:!0}))this.#d(J,$);this.#h($)}catch(J){this.#g(J.code),$.provisional=0}this.#a=void 0,Q()}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 Q of this.#$.readdirSync(Z,{withFileTypes:!0}))this.#d(Q,$);this.#h($)}catch(Q){this.#g(Q.code),$.provisional=0}return $.slice(0,$.provisional)}canReaddir(){if(this.#Q&s5)return!1;let $=U0&this.#Q;if(!($===A0||$===M0||$===H4))return!1;return!0}shouldWalk($,Z){return(this.#Q&M0)===M0&&!(this.#Q&s5)&&!$.has(this)&&(!Z||Z(this))}async realpath(){if(this.#E)return this.#E;if((N6|R6|R0)&this.#Q)return;try{let $=await this.#$.promises.realpath(this.fullpath());return this.#E=this.resolve($)}catch($){this.#f()}}realpathSync(){if(this.#E)return this.#E;if((N6|R6|R0)&this.#Q)return;try{let $=this.#$.realpathSync(this.fullpath());return this.#E=this.resolve($)}catch($){this.#f()}}[W1]($){if($===this)return;$.isCWD=!1,this.isCWD=!0;let Z=new Set([]),Q=[],J=this;while(J&&J.parent)Z.add(J),J.#R=Q.join(this.sep),J.#I=Q.join("/"),J=J.parent,Q.push("..");J=$;while(J&&J.parent&&!Z.has(J))J.#R=void 0,J.#I=void 0,J=J.parent}}class P6 extends Q0{sep="\\";splitSep=VZ;constructor($,Z=A0,Q,J,X,V,K){super($,Z,Q,J,X,V,K)}newChild($,Z=A0,Q={}){return new P6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),Q)}getRootString($){return C2.parse($).root}getRoot($){if($=XZ($.toUpperCase()),$===this.root.name)return this.root;for(let[Z,Q]of Object.entries(this.roots))if(this.sameRoot($,Z))return this.roots[$]=Q;return this.roots[$]=new o4($,this).root}sameRoot($,Z=this.root.name){return $=$.toUpperCase().replace(/\//g,"\\").replace($1,"$1\\"),$===Z}}class D6 extends Q0{splitSep="/";sep="/";constructor($,Z=A0,Q,J,X,V,K){super($,Z,Q,J,X,V,K)}getRootString($){return $.startsWith("/")?"/":""}getRoot($){return this.root}newChild($,Z=A0,Q={}){return new D6($,Z,this.root,this.roots,this.nocase,this.childrenCache(),Q)}}class P2{root;rootPath;roots;cwd;#$;#J;#X;nocase;#Z;constructor($=process.cwd(),Z,Q,{nocase:J,childrenCacheSize:X=16384,fs:V=n4}={}){if(this.#Z=t5(V),$ instanceof URL||$.startsWith("file://"))$=a8($);let K=Z.resolve($);this.roots=Object.create(null),this.rootPath=this.parseRootPath(K),this.#$=new N2,this.#J=new N2,this.#X=new K1(X);let W=K.substring(this.rootPath.length).split(Q);if(W.length===1&&!W[0])W.pop();if(J===void 0)throw TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=J,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 Q=this.#$.get(Z);if(Q!==void 0)return Q;let J=this.cwd.resolve(Z).fullpath();return this.#$.set(Z,J),J}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 Q=this.#J.get(Z);if(Q!==void 0)return Q;let J=this.cwd.resolve(Z).fullpathPosix();return this.#J.set(Z,J),J}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 Q0))Z=$,$=this.cwd;let{withFileTypes:Q}=Z;if(!$.canReaddir())return[];else{let J=await $.readdir();return Q?J:J.map((X)=>X.name)}}readdirSync($=this.cwd,Z={withFileTypes:!0}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0}=Z;if(!$.canReaddir())return[];else if(Q)return $.readdirSync();else return $.readdirSync().map((J)=>J.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 Q0))Z=$.withFileTypes,$=this.cwd;let Q=await $.readlink();return Z?Q:Q?.fullpath()}readlinkSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=$.readlinkSync();return Z?Q:Q?.fullpath()}async realpath($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=await $.realpath();return Z?Q:Q?.fullpath()}realpathSync($=this.cwd,{withFileTypes:Z}={withFileTypes:!1}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$.withFileTypes,$=this.cwd;let Q=$.realpathSync();return Z?Q:Q?.fullpath()}async walk($=this.cwd,Z={}){if(typeof $==="string")$=this.cwd.resolve($);else if(!($ instanceof Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(Q?$:$.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(Q?R:R.fullpath());if(J&&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 Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=[];if(!X||X($))K.push(Q?$:$.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(Q?z:z.fullpath());let G=z;if(z.isSymbolicLink()){if(!(J&&(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 Q0))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 Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z;if(!X||X($))yield Q?$:$.fullpath();let K=new Set([$]);for(let W of K){let H=W.readdirSync();for(let q of H){if(!X||X(q))yield Q?q:q.fullpath();let z=q;if(q.isSymbolicLink()){if(!(J&&(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 Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=new W4({objectMode:!0});if(!X||X($))K.write(Q?$:$.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(J&&!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(Q?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 Q0))Z=$,$=this.cwd;let{withFileTypes:Q=!0,follow:J=!1,filter:X,walkFilter:V}=Z,K=new W4({objectMode:!0}),W=new Set;if(!X||X($))K.write(Q?$:$.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(Q?B:B.fullpath()))G=!0}q--;for(let B of L){let _=B;if(B.isSymbolicLink()){if(!(J&&(_=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[W1](Z)}}class o4 extends P2{sep="\\";constructor($=process.cwd(),Z={}){let{nocase:Q=!0}=Z;super($,C2,"\\",{...Z,nocase:Q});this.nocase=Q;for(let J=this.cwd;J;J=J.parent)J.nocase=this.nocase}parseRootPath($){return C2.parse($).root.toUpperCase()}newRoot($){return new P6(this.rootPath,M0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")||$.startsWith("\\")||/^[a-z]:(\/|\\)/i.test($)}}class e4 extends P2{sep="/";constructor($=process.cwd(),Z={}){let{nocase:Q=!1}=Z;super($,p8,"/",{...Z,nocase:Q});this.nocase=Q}parseRootPath($){return"/"}newRoot($){return new D6(this.rootPath,M0,void 0,this.roots,this.nocase,this.childrenCache(),{fs:$})}isAbsolute($){return $.startsWith("/")}}class F6 extends e4{constructor($=process.cwd(),Z={}){let{nocase:Q=!0}=Z;super($,{...Z,nocase:Q})}}var XW=process.platform==="win32"?P6:D6,H1=process.platform==="win32"?o4:process.platform==="darwin"?F6:e4;var WZ=($)=>$.length>=1,HZ=($)=>$.length>=1;class R4{#$;#J;#X;length;#Z;#K;#P;#_;#z;#W;#G=!0;constructor($,Z,Q,J){if(!WZ($))throw TypeError("empty pattern list");if(!HZ(Z))throw TypeError("empty glob list");if(Z.length!==$.length)throw TypeError("mismatched pattern list and glob list lengths");if(this.length=$.length,Q<0||Q>=this.length)throw TypeError("index out of range");if(this.#$=$,this.#J=Z,this.#X=Q,this.#Z=J,this.#X===0){if(this.isUNC()){let[X,V,K,W,...H]=this.#$,[q,z,G,U,...L]=this.#J;if(H[0]==="")H.shift(),L.shift();let B=[X,V,K,W,""].join("/"),_=[q,z,G,U,""].join("/");this.#$=[B,...H],this.#J=[_,...L],this.length=this.#$.length}else if(this.isDrive()||this.isAbsolute()){let[X,...V]=this.#$,[K,...W]=this.#J;if(V[0]==="")V.shift(),W.shift();let H=X+"/",q=K+"/";this.#$=[H,...V],this.#J=[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.#J[0]+this.#J.slice(1).join("/"):this.#J.join("/"):this.#J.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 R4(this.#$,this.#J,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 qZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class t4{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor($,{nobrace:Z,nocase:Q,noext:J,noglobstar:X,platform:V=qZ}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=V,this.mmopts={dot:!0,nobrace:Z,nocase:Q,noext:J,noglobstar:X,optimizationLevel:2,platform:V,nocomment:!0,nonegate:!0};for(let K of $)this.add(K)}add($){let Z=new j0($,this.mmopts);for(let Q=0;Q<Z.set.length;Q++){let J=Z.set[Q],X=Z.globParts[Q];if(!J||!X)throw Error("invalid pattern object");while(J[0]==="."&&X[0]===".")J.shift(),X.shift();let V=new R4(J,X,0,this.platform),K=new j0(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(),Q=`${Z}/`,J=$.relative()||".",X=`${J}/`;for(let V of this.relative)if(V.match(J)||V.match(X))return!0;for(let V of this.absolute)if(V.match(Z)||V.match(Q))return!0;return!1}childrenIgnored($){let Z=$.fullpath()+"/",Q=($.relative()||".")+"/";for(let J of this.relativeChildren)if(J.match(Q))return!0;for(let J of this.absoluteChildren)if(J.match(Z))return!0;return!1}}class D2{store;constructor($=new Map){this.store=$}copy(){return new D2(new Map(this.store))}hasWalked($,Z){return this.store.get($.fullpath())?.has(Z.globString())}storeWalked($,Z){let Q=$.fullpath(),J=this.store.get(Q);if(J)J.add(Z.globString());else this.store.set(Q,new Set([Z.globString()]))}}class q1{store=new Map;add($,Z,Q){let J=(Z?2:0)|(Q?1:0),X=this.store.get($);this.store.set($,X===void 0?J:J&X)}entries(){return[...this.store.entries()].map(([$,Z])=>[$,!!(Z&2),!!(Z&1)])}}class Y1{store=new Map;add($,Z){if(!$.canReaddir())return;let Q=this.store.get($);if(Q){if(!Q.find((J)=>J.globString()===Z.globString()))Q.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 $6{hasWalkedCache;matches=new q1;subwalks=new Y1;patterns;follow;dot;opts;constructor($,Z){this.opts=$,this.follow=!!$.follow,this.dot=!!$.dot,this.hasWalkedCache=Z?Z.copy():new D2}processPatterns($,Z){this.patterns=Z;let Q=Z.map((J)=>[$,J]);for(let[J,X]of Q){this.hasWalkedCache.storeWalked(J,X);let V=X.root(),K=X.isAbsolute()&&this.opts.absolute!==!1;if(V){J=J.resolve(V==="/"&&this.opts.root!==void 0?this.opts.root:V);let z=X.rest();if(!z){this.matches.add(J,!0,!1);continue}else X=z}if(J.isENOENT())continue;let W,H,q=!1;while(typeof(W=X.pattern())==="string"&&(H=X.rest()))J=J.resolve(W),X=H,q=!0;if(W=X.pattern(),H=X.rest(),q){if(this.hasWalkedCache.hasWalked(J,X))continue;this.hasWalkedCache.storeWalked(J,X)}if(typeof W==="string"){let z=W===".."||W===""||W===".";this.matches.add(J.resolve(W),K,z);continue}else if(W===m){if(!J.isSymbolicLink()||this.follow||X.checkFollowGlobstar())this.subwalks.add(J,X);let z=H?.pattern(),G=H?.rest();if(!H||(z===""||z===".")&&!G)this.matches.add(J,K,z===""||z===".");else if(z===".."){let U=J.parent||J;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(J,X)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new $6(this.opts,this.hasWalkedCache)}filterEntries($,Z){let Q=this.subwalks.get($),J=this.child();for(let X of Z)for(let V of Q){let K=V.isAbsolute(),W=V.pattern(),H=V.rest();if(W===m)J.testGlobstar(X,V,H,K);else if(W instanceof RegExp)J.testRegExp(X,W,H,K);else J.testString(X,W,H,K)}return J}testGlobstar($,Z,Q,J){if(this.dot||!$.name.startsWith(".")){if(!Z.hasMore())this.matches.add($,J,!1);if($.canReaddir()){if(this.follow||!$.isSymbolicLink())this.subwalks.add($,Z);else if($.isSymbolicLink()){if(Q&&Z.checkFollowGlobstar())this.subwalks.add($,Q);else if(Z.markFollowGlobstar())this.subwalks.add($,Z)}}}if(Q){let X=Q.pattern();if(typeof X==="string"&&X!==".."&&X!==""&&X!==".")this.testString($,X,Q.rest(),J);else if(X===".."){let V=$.parent||$;this.subwalks.add(V,Q)}else if(X instanceof RegExp)this.testRegExp($,X,Q.rest(),J)}}testRegExp($,Z,Q,J){if(!Z.test($.name))return;if(!Q)this.matches.add($,J,!1);else this.subwalks.add($,Q)}testString($,Z,Q,J){if(!$.isNamed(Z))return;if(!Q)this.matches.add($,J,!1);else this.subwalks.add($,Q)}}var YZ=($,Z)=>typeof $==="string"?new t4([$],Z):Array.isArray($)?new t4($,Z):$;class F2{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#$=[];#J;#X;signal;maxDepth;includeChildMatches;constructor($,Z,Q){if(this.patterns=$,this.path=Z,this.opts=Q,this.#X=!Q.posix&&Q.platform==="win32"?"\\":"/",this.includeChildMatches=Q.includeChildMatches!==!1,Q.ignore||!this.includeChildMatches){if(this.#J=YZ(Q.ignore??[],Q),!this.includeChildMatches&&typeof this.#J.add!=="function")throw Error("cannot ignore child matches, ignore lacks add() method.")}if(this.maxDepth=Q.maxDepth||1/0,Q.signal)this.signal=Q.signal,this.signal.addEventListener("abort",()=>{this.#$.length=0})}#Z($){return this.seen.has($)||!!this.#J?.ignored?.($)}#K($){return!!this.#J?.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 Q;if(this.opts.realpath){if(Q=$.realpathCached()||await $.realpath(),!Q)return;$=Q}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 Q;if(this.opts.realpath){if(Q=$.realpathCached()||$.realpathSync(),!Q)return;$=Q}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.#J?.add){let X=`${$.relativePosix()}/**`;this.#J.add(X)}let Q=this.opts.absolute===void 0?Z:this.opts.absolute;this.seen.add($);let J=this.opts.mark&&$.isDirectory()?this.#X:"";if(this.opts.withFileTypes)this.matchEmit($);else if(Q){let X=this.opts.posix?$.fullpathPosix():$.fullpath();this.matchEmit(X+J)}else{let X=this.opts.posix?$.relativePosix():$.relative(),V=this.opts.dotRelative&&!X.startsWith(".."+this.#X)?"."+this.#X:"";this.matchEmit(!X?"."+J:V+X+J)}}async match($,Z,Q){let J=await this.matchCheck($,Q);if(J)this.matchFinish(J,Z)}matchSync($,Z,Q){let J=this.matchCheckSync($,Q);if(J)this.matchFinish(J,Z)}walkCB($,Z,Q){if(this.signal?.aborted)Q();this.walkCB2($,Z,new $6(this.opts),Q)}walkCB2($,Z,Q,J){if(this.#K($))return J();if(this.signal?.aborted)J();if(this.paused){this.onResume(()=>this.walkCB2($,Z,Q,J));return}Q.processPatterns($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,W,H).then(()=>V())}for(let K of Q.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let W=K.readdirCached();if(K.calledReaddir())this.walkCB3(K,W,Q,V);else K.readdirCB((H,q)=>this.walkCB3(K,q,Q,V),!0)}V()}walkCB3($,Z,Q,J){Q=Q.filterEntries($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;X++,this.match(K,W,H).then(()=>V())}for(let[K,W]of Q.subwalks.entries())X++,this.walkCB2(K,W,Q.child(),V);V()}walkCBSync($,Z,Q){if(this.signal?.aborted)Q();this.walkCB2Sync($,Z,new $6(this.opts),Q)}walkCB2Sync($,Z,Q,J){if(this.#K($))return J();if(this.signal?.aborted)J();if(this.paused){this.onResume(()=>this.walkCB2Sync($,Z,Q,J));return}Q.processPatterns($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,W,H)}for(let K of Q.subwalkTargets()){if(this.maxDepth!==1/0&&K.depth()>=this.maxDepth)continue;X++;let W=K.readdirSync();this.walkCB3Sync(K,W,Q,V)}V()}walkCB3Sync($,Z,Q,J){Q=Q.filterEntries($,Z);let X=1,V=()=>{if(--X===0)J()};for(let[K,W,H]of Q.matches.entries()){if(this.#Z(K))continue;this.matchSync(K,W,H)}for(let[K,W]of Q.subwalks.entries())X++,this.walkCB2Sync(K,W,Q.child(),V);V()}}class M6 extends F2{matches=new Set;constructor($,Z,Q){super($,Z,Q)}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 I6 extends F2{results;constructor($,Z,Q){super($,Z,Q);this.results=new W4({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 GZ=typeof process==="object"&&process&&typeof process.platform==="string"?process.platform:"linux";class I0{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=zZ(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||GZ,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"?o4:Z.platform==="darwin"?F6:Z.platform?e4:H1;this.scurry=new W(this.cwd,{nocase:Z.nocase,fs:Z.fs})}this.nocase=this.scurry.nocase;let Q=this.platform==="darwin"||this.platform==="win32",J={...Z,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:Q,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 j0(W,J)),[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 R4(W,q,0,this.platform)})}async walk(){return[...await new M6(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 M6(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 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}).stream()}streamSync(){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}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}}var M2=($,Z={})=>{if(!Array.isArray($))$=[$];for(let Q of $)if(new j0(Q,Z).hasMagic())return!0;return!1};function S6($,Z={}){return new I0($,Z).streamSync()}function G1($,Z={}){return new I0($,Z).stream()}function j1($,Z={}){return new I0($,Z).walkSync()}async function z1($,Z={}){return new I0($,Z).walk()}function T6($,Z={}){return new I0($,Z).iterateSync()}function U1($,Z={}){return new I0($,Z).iterate()}var jZ=S6,UZ=Object.assign(G1,{sync:S6}),AZ=T6,BZ=Object.assign(U1,{sync:T6}),LZ=Object.assign(j1,{stream:S6,iterate:T6}),E6=Object.assign(z1,{glob:z1,globSync:j1,sync:LZ,globStream:G1,stream:UZ,globStreamSync:S6,streamSync:jZ,globIterate:U1,iterate:BZ,globIterateSync:T6,iterateSync:AZ,Glob:I0,hasMagic:M2,escape:L4,unescape:_0});E6.glob=E6;var Q4=J5(v9(),1),vX=new Set(["png","jpg","jpeg","gif","webp"]),OX=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"]),yX=25000,bX=5242880,O9=3932160,y9=400,fX=20,hX=[{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 gX($){if($.length<4)return null;for(let{signature:Z,mimeType:Q}of hX){let J=!0;for(let X=0;X<Z.length;X++)if($[X]!==Z[X]){J=!1;break}if(J){if(Q==="image/webp"){if($.length>=12&&$[8]===87&&$[9]===69&&$[10]===66&&$[11]===80)return"image/webp";continue}return Q}}return null}async function b9($,Z=yX,Q){let J=Bun.file($),X=Buffer.from(await J.arrayBuffer());if(X.length===0)throw Error(`Image file is empty: ${$}`);if(X.length>bX)throw Error(`Image file too large: ${$} (${(X.length/1024/1024).toFixed(2)}MB > 5MB limit)`);if(!gX(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>O9){let _=Math.sqrt(O9/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 dX(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(y9,y9,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:fX}).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 dX($,Z){let Q=Math.floor(Z*0.8/0.125),J=Math.floor(Q*0.75),V=await Q4.default($).metadata(),K=$.length;if(K<=J)return $;let W=Math.sqrt(J/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 f9($){let Z=$.toLowerCase().replace(/^\./,"");return vX.has(Z)}function h9($){let Z=$.toLowerCase().replace(/^\./,"");return OX.has(Z)}function g9($){return{type:"image",source:{type:"base64",data:$.base64,media_type:$.mediaType}}}function d9($){let Z=$.dimensions,Q=Z?.originalWidth&&Z?.originalHeight?` (${Z.originalWidth}x${Z.originalHeight}${Z.displayWidth!==Z.originalWidth?` \u2192 ${Z.displayWidth}x${Z.displayHeight}`:""})`:"";return`[Image: ${$.mediaType}${Q}, ${($.originalSize/1024).toFixed(1)}KB original]`}import*as n6 from"path";var uX={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 Q=$.file_path,J=$.offset||1,X=$.limit||2000;try{let V=n6.extname(Q).toLowerCase().slice(1);if(f9(V))return await mX(Q,Z.abortSignal);if(h9(V))return{content:`Binary file detected: ${Q}
116
- This file type (${V}) is not supported for text reading.`,is_error:!0};let K=Bun.file(Q);if(!await K.exists())return{content:`Error: File not found: ${Q}`,is_error:!0};let H=(await K.text()).split(`
117
- `),q=Math.max(0,J-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: ${Q} 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 mX($,Z){try{let Q=await b9($,25000,Z),J=g9(Q);return{content:`${d9(Q)}
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(Q){return{content:`Error reading image: ${Q instanceof Error?Q.message:String(Q)}`,is_error:!0}}}var cX={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:Q,content:J}=$;try{return await Bun.write(Q,J),{content:`Successfully wrote to ${Q}`}}catch(X){return{content:`Error writing file: ${X instanceof Error?X.message:String(X)}`,is_error:!0}}}},lX={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:Q,old_string:J,new_string:X}=$,V=$.replace_all||!1;try{let W=await Bun.file(Q).text();if(V){let H=W;W=W.split(J).join(X);let q=(H.match(new RegExp(pX(J),"g"))||[]).length;if(q===0)return{content:"Error: String not found in file",is_error:!0};return await Bun.write(Q,W),{content:`Successfully replaced ${q} occurrences`}}else{let H=W.indexOf(J);if(H===-1)return{content:"Error: String not found in file",is_error:!0};if(W.indexOf(J,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(J,X),await Bun.write(Q,W),{content:`Successfully edited ${Q}`}}}catch(K){return{content:`Error editing file: ${K instanceof Error?K.message:String(K)}`,is_error:!0}}}};function pX($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var aX={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 Q=$.command,J=$.timeout||120000;try{let X=Bun.spawnSync(["sh","-c",Q],{cwd:Z.workingDirectory,timeout:J,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}}}},rX={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 Q=$.pattern,J=$.path||Z.workingDirectory;try{let X=await E6(Q,{cwd:J,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}}}},nX={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 Q=$.pattern,J=$.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(Q,J);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}}}},iX={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:Q,prompt:J,description:X}=$,V=$.model||"haiku",K=$.resume,W=$.run_in_background,H=K||`${Q.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",J];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}}}},sX={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 Q=$.task_id,J=$.block??!0,X=$.timeout??30000;try{let V=`${Z.workingDirectory}/.claude/tasks/${Q}.json`,K=Bun.file(V);if(!await K.exists())return{content:`Task not found: ${Q}. Use /tasks to list available tasks.`,is_error:!0};let W=await K.json();if(J&&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:Q,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:Q,status:"timeout",message:`Task still running after ${X}ms`},null,2)}}return{content:JSON.stringify({task_id:Q,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}}}},oX={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 Q=$.questions;try{let J=Q.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:Q,formatted:J,message:"Questions prepared for user response"},null,2)}}catch(J){return{content:`Error preparing questions: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},eX={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 Q=$.allowedPrompts;try{let J=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(J);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:J,planLength:V.length,allowedPrompts:Q||[],message:"Plan is ready for user review. ExitPlanMode will request user approval."},null,2)}}catch(J){return{content:`Error entering plan mode: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},tX={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 Q=$.allowedPrompts;try{let J=`${Z.workingDirectory}/.claude/plan.md`,X=Bun.file(J);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:J,planPreview:V.slice(0,500)+(V.length>500?"...":""),allowedPrompts:Q||[],message:"Plan submitted for user approval."},null,2)}}catch(J){return{content:`Error exiting plan mode: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},$V={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:Q,args:J}=$;try{let X=`${Z.workingDirectory}/.claude/skills`,V=`${process.env.HOME||""}/.claude/skills`,K=[`${X}/${Q}.md`,`${X}/${Q}/skill.md`,`${V}/${Q}.md`,`${V}/${Q}/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: ${Q}. 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:Q,args:J,skillFile:W,content:q,message:`Skill "${Q}" 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}}}},ZV={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 Q=$.task_id;try{let J=`${Z.workingDirectory}/.claude/tasks/${Q}.json`,X=Bun.file(J);if(!await X.exists())return{content:`Task not found: ${Q}`,is_error:!0};let V=await X.json();if(V.status!=="running")return{content:JSON.stringify({task_id:Q,status:V.status,message:`Task is already ${V.status}`},null,2)};return V.status="stopped",await Bun.write(J,JSON.stringify(V,null,2)),{content:JSON.stringify({task_id:Q,status:"stopped",message:"Task stopped successfully"},null,2)}}catch(J){return{content:`Error stopping task: ${J instanceof Error?J.message:String(J)}`,is_error:!0}}}},QV={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 Q=$.edits,J=$.dry_run||!1;try{if(!Array.isArray(Q)||Q.length===0)return{content:"Error: edits must be a non-empty array",is_error:!0};let X=[];for(let W=0;W<Q.length;W++){let H=Q[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(J){let W=_5(X),H=V2(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=V2(X);if(V.length>0)return{content:`Validation failed:
240
- ${V.join(`
241
- `)}`,is_error:!0};let K=w5(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}}}},JV={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:Q,cell_id:J,cell_number:X,new_source:V}=$,K=$.cell_type||"code",W=$.edit_mode||"replace";try{let H=Bun.file(Q);if(!await H.exists())return{content:`Error: Notebook not found: ${Q}`,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(J){if(z=q.cells.findIndex((G)=>G.id===J),z===-1)return{content:`Error: Cell with ID "${J}" 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(Q,JSON.stringify(q,null,1)),{content:JSON.stringify({success:!0,message:`Successfully ${W}d cell in ${Q}`,cellCount:q.cells.length})}}catch(H){return{content:`Error editing notebook: ${H instanceof Error?H.message:String(H)}`,is_error:!0}}}},XV={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:Q,prompt:J}=$;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(Q.startsWith("http://")||Q.startsWith("https://")){let U=await fetch(Q);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(Q);if(!await U.exists())return{content:`Error: Image file not found: ${Q}`,is_error:!0};K=Buffer.from(await U.arrayBuffer()).toString("base64");let B=n6.extname(Q).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:J}]}]},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}}}},VV={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:Q,prompt:J}=$;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(Q.startsWith("http://")||Q.startsWith("https://")){let U=await fetch(Q);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(Q);if(!await U.exists())return{content:`Error: Image file not found: ${Q}`,is_error:!0};K=Buffer.from(await U.arrayBuffer()).toString("base64");let B=n6.extname(Q).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:J}]}]},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}}}},KV=[uX,cX,lX,QV,aX,rX,nX,iX,sX,ZV,oX,eX,tX,$V,JV,VV,XV];function FH($){return KV.find((Z)=>Z.name===$)}import{spawn as WV}from"child_process";import e2 from"ws";class t2{static MCPClient=t2;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=WV(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,Q)=>{let J={...this.config.headers},X=new e2($,{headers:J,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}`),Q(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)Q(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 Q=++this.requestId,J={jsonrpc:"2.0",id:Q,method:$,params:Z};return new Promise((X,V)=>{this.pendingRequests.set(Q,{resolve:X,reject:V});let K=JSON.stringify(J);if(this.websocket&&this.websocket.readyState===e2.OPEN)this.websocket.send(K);else if(this.process?.stdin?.writable)this.process.stdin.write(K+`
247
- `);else{this.pendingRequests.delete(Q),V(Error("No active connection to send request"));return}setTimeout(()=>{if(this.pendingRequests.has(Q))this.pendingRequests.delete(Q),V(Error(`Request timeout for ${$}`))},this.config.timeout||120000)})}notify($,Z){let J=JSON.stringify({jsonrpc:"2.0",method:$,params:Z});if(this.websocket&&this.websocket.readyState===e2.OPEN)this.websocket.send(J);else if(this.process?.stdin?.writable)this.process.stdin.write(J+`
248
- `)}handleData($){this.buffer+=$;let Z=this.buffer.split(`
249
- `);this.buffer=Z.pop()||"";for(let Q of Z){if(!Q.trim())continue;try{let J=JSON.parse(Q);if(J.id!==void 0){let X=this.pendingRequests.get(J.id);if(X)if(this.pendingRequests.delete(J.id),J.error)X.reject(Error(J.error.message));else X.resolve(J.result)}}catch(J){this.log(`Parse error: ${J}`)}}}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 SH($,Z){let Q=new Map;for(let[J,X]of Object.entries($)){if(X.disabled)continue;let V=new t2({name:J,config:X,onLog:Z});try{await V.connect(),Q.set(J,V)}catch(K){let W=K instanceof Error?K.message:String(K);Z?.(`[MCP:${J}] Failed to connect: ${W}`)}}return Q}import{spawn as HV}from"child_process";class qV{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,Q]of Object.entries($))for(let J of Q)this.register(Z,J)}async execute($,Z){let Q=this.hooks.get($);if(!Q||Q.length===0)return{decision:"allow"};let J={...Z,event:$,timestamp:Date.now()};for(let X of Q){if(X.enabled===!1)continue;let V=await this.executeHook(X,J);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 Q=$.timeout||this.timeout;try{return await new Promise((X,V)=>{let K=HV($.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"})},Q)})}catch(J){return{decision:"allow",reason:`Hook execution failed: ${J instanceof Error?J.message:String(J)}`}}}getHooks($){return this.hooks.get($)||[]}clear($){if($)this.hooks.delete($);else this.hooks.clear()}}var xH={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}},vH={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."},OH={ALLOW:0,DENY:1,BLOCK:2};import{readFileSync as YV,existsSync as u9,readdirSync as zV}from"fs";import{join as GV}from"path";function jV($,Z="project"){if(!u9($))return null;let Q=YV($,"utf-8"),J=$.split("/").pop()?.replace(/\.md$/i,"")||"unknown",X=Q.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);if(!X)return{path:$,name:J,description:"",prompt:Q.trim(),source:Z};let V=X[1]??"",K=X[2]??"",W=UV(V);return{path:$,name:W.name||J,description:W.description||"",prompt:K.trim(),tools:W.tools,model:W.model,color:W.color,source:Z}}function UV($){let Z={},Q=$.split(`
264
- `);for(let J of Q){let X=J.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 AV{skills=new Map;loadFromDirectory($,Z="project"){if(!u9($))return 0;let Q=0,J=zV($);for(let X of J)if(X.endsWith(".md")){let V=jV(GV($,X),Z);if(V)this.skills.set(V.name,V),Q++}return Q}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 gH($){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 dH=[{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 uH($){return $.match(/^\/(\w+)(?:\s+(.*))?$/)?.[1]??null}function mH($){return $.match(/^\/\w+\s+(.*)$/)?.[1]??""}import{spawn as $5}from"child_process";import{mkdirSync as m9,rmSync as BV,existsSync as c9,readFileSync as LV}from"fs";import{join as W6}from"path";class _V{teams=new Map;teammates=new Map;messageQueue=new Map;storagePath;constructor($="~/.claude/teams"){if(this.storagePath=$.replace("~",process.env.HOME||""),!c9(this.storagePath))m9(this.storagePath,{recursive:!0});this.loadTeams()}createTeam($){let Z={...$,status:"active"};this.teams.set($.name,Z);for(let Q of $.teammates)this.teammates.set(Q.teammateId,Q);return this.persistTeam(Z).catch((Q)=>{console.error(`Failed to persist team ${$.name}:`,Q)}),Z}getTeam($){return this.teams.get($)}listTeams(){return Array.from(this.teams.values())}deleteTeam($){let Z=this.teams.get($);if(Z){for(let J of Z.teammates)this.teammates.delete(J.teammateId),this.messageQueue.delete(J.teammateId);this.teams.delete($);let Q=W6(this.storagePath,$);try{BV(Q,{recursive:!0,force:!0})}catch(J){console.error(`Failed to delete team directory ${Q}:`,J)}}}getTeammate($){return this.teammates.get($)}updateTeammateStatus($,Z){let Q=this.teammates.get($);if(Q)Q.status=Z}async spawnTeammate($,Z={}){let{session:Q,workingDir:J=process.cwd()}=Z;if(!process.env.TMUX)await this.spawnInTerminal($,{session:Q,workingDir:J});else await this.spawnInTmux($,{session:Q,workingDir:J});this.updateTeammateStatus($.teammateId,"in_progress")}async spawnInTerminal($,Z){let Q=["bun","run","src/cli.ts","--teammate-mode","--agent-id",$.teammateId,"--agent-name",$.name,"--team-name",$.teamName,"--agent-color",$.color];if($.planModeRequired)Q.push("--permission-mode","plan");if(process.platform==="darwin"){let J=`
320
- tell application "Terminal"
321
- do script "cd ${Z.workingDir} && ${Q.join(" ")}"
322
- activate
323
- end tell
324
- `;$5("osascript",["-e",J])}else $5("xterm",["-e",Q.join(" ")])}async spawnInTmux($,Z){let Q=Z.session||process.env.TMUX?.split(",")[0]?.split(":")[0]||"claude";await this.tmuxCommand(["split-window","-t",Q,"-c",Z.workingDir]);let J=await this.tmuxCommand(["display-message","-p","#{pane_id}"]);if(J)$.paneId=J.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 Q=$5("tmux",$),J="";Q.stdout?.on("data",(X)=>{J+=X.toString()}),Q.on("close",()=>{Z(J)})})}broadcast($,Z,Q){let J=this.teams.get($);if(!J)return;let X={type:"broadcast",from:Q||"system",content:Z,timestamp:Date.now()};for(let V of J.teammates){if(Q&&V.teammateId===Q)continue;let K=this.messageQueue.get(V.teammateId)||[];K.push(X),this.messageQueue.set(V.teammateId,K)}}sendDirect($,Z,Q){let J={type:"direct",from:Z,to:$,content:Q,timestamp:Date.now()},X=this.messageQueue.get($)||[];X.push(J),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=W6(this.storagePath,$.name),Q=W6(Z,"config.json");if(!c9(Z))m9(Z,{recursive:!0});await Bun.write(W6(Z,".gitkeep"),"");let J={name:$.name,description:$.description,teammates:$.teammates,taskListId:$.taskListId,status:$.status,coordination:$.coordination,updatedAt:Date.now()};await Bun.write(Q,JSON.stringify(J,null,2))}loadTeams(){let $=new Bun.Glob("**/config.json");try{let Z=Array.from($.scanSync(this.storagePath));for(let Q of Z)try{let J=W6(this.storagePath,Q);if(Bun.file(J).size===0)continue;let K=LV(J,"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(J){}}catch(Z){if(Z.code!=="ENOENT");}}async persistAllTeams(){let $=Array.from(this.teams.values()).map((Z)=>this.persistTeam(Z));await Promise.all($)}}var rH={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 wV(){return`teammate_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function nH($){return{...$,teammateId:wV(),status:"pending"}}
349
- export{v as a,Y6 as b,i9 as c,CV as d,X5 as e,V5 as f,NV as g,$7 as h,Z7 as i,Q7 as j,J7 as k,H5 as l,K7 as m,W7 as n,s6 as o,o6 as p,TV as q,kV as r,xV as s,pV as t,J2 as u,aV as v,rV as w,nV as x,R7 as y,C7 as z,eV as A,B5 as B,JK as C,V4 as D,XK as E,VK as F,KK as G,WK as H,V2 as I,_5 as J,w5 as K,b as L,HK as M,qK as N,YK as O,zK as P,GK as Q,jK as R,UK as S,AK as T,BK as U,LK as V,_K as W,wK as X,RK as Y,CK as Z,uX as _,cX as $,lX as aa,aX as ba,rX as ca,nX as da,iX as ea,sX as fa,oX as ga,eX as ha,tX as ia,$V as ja,ZV as ka,QV as la,JV as ma,XV as na,VV as oa,KV as pa,FH as qa,t2 as ra,SH as sa,qV as ta,xH as ua,vH as va,OH as wa,jV as xa,AV as ya,gH as za,dH as Aa,uH as Ba,mH as Ca,_V as Da,rH as Ea,wV as Fa,nH as Ga};