@slycode/slycode 0.2.21 → 0.2.23

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 (271) hide show
  1. package/dist/bridge/api.d.ts +2 -1
  2. package/dist/bridge/api.js +114 -1
  3. package/dist/bridge/api.js.map +1 -1
  4. package/dist/bridge/git-utils.d.ts +9 -0
  5. package/dist/bridge/git-utils.js +49 -0
  6. package/dist/bridge/git-utils.js.map +1 -0
  7. package/dist/bridge/index.js +8 -2
  8. package/dist/bridge/index.js.map +1 -1
  9. package/dist/bridge/provider-utils.d.ts +10 -0
  10. package/dist/bridge/provider-utils.js +5 -1
  11. package/dist/bridge/provider-utils.js.map +1 -1
  12. package/dist/bridge/response-store.d.ts +46 -0
  13. package/dist/bridge/response-store.js +95 -0
  14. package/dist/bridge/response-store.js.map +1 -0
  15. package/dist/bridge/session-manager.d.ts +33 -1
  16. package/dist/bridge/session-manager.js +191 -2
  17. package/dist/bridge/session-manager.js.map +1 -1
  18. package/dist/bridge/types.d.ts +41 -0
  19. package/dist/data/scaffold-templates/tutorial-project/documentation/kanban.json +1 -1
  20. package/dist/messaging/bridge-client.d.ts +7 -3
  21. package/dist/messaging/bridge-client.js +26 -5
  22. package/dist/messaging/bridge-client.js.map +1 -1
  23. package/dist/messaging/index.js +149 -30
  24. package/dist/messaging/index.js.map +1 -1
  25. package/dist/messaging/state.d.ts +3 -0
  26. package/dist/messaging/state.js +13 -0
  27. package/dist/messaging/state.js.map +1 -1
  28. package/dist/messaging/types.d.ts +3 -0
  29. package/dist/scripts/kanban.js +448 -2
  30. package/dist/store/actions/checkpoint.md +1 -1
  31. package/dist/store/actions/context.md +1 -1
  32. package/dist/store/actions/create-card.md +1 -1
  33. package/dist/store/actions/deep-design.md +13 -3
  34. package/dist/store/actions/design-requirements.md +11 -1
  35. package/dist/store/actions/explore.md +1 -1
  36. package/dist/store/actions/onboard.md +2 -4
  37. package/dist/store/actions/summarize.md +1 -1
  38. package/dist/store/skills/kanban/SKILL.md +77 -3
  39. package/dist/web/.next/BUILD_ID +1 -1
  40. package/dist/web/.next/app-path-routes-manifest.json +1 -0
  41. package/dist/web/.next/build-manifest.json +2 -2
  42. package/dist/web/.next/prerender-manifest.json +3 -3
  43. package/dist/web/.next/routes-manifest.json +6 -0
  44. package/dist/web/.next/server/app/_global-error.html +2 -2
  45. package/dist/web/.next/server/app/_global-error.rsc +1 -1
  46. package/dist/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  47. package/dist/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  48. package/dist/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  49. package/dist/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  50. package/dist/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  51. package/dist/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  52. package/dist/web/.next/server/app/_not-found.html +1 -1
  53. package/dist/web/.next/server/app/_not-found.rsc +10 -10
  54. package/dist/web/.next/server/app/_not-found.segments/_full.segment.rsc +10 -10
  55. package/dist/web/.next/server/app/_not-found.segments/_head.segment.rsc +4 -4
  56. package/dist/web/.next/server/app/_not-found.segments/_index.segment.rsc +5 -5
  57. package/dist/web/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  58. package/dist/web/.next/server/app/_not-found.segments/_not-found.segment.rsc +3 -3
  59. package/dist/web/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  60. package/dist/web/.next/server/app/api/areas/route.js +1 -1
  61. package/dist/web/.next/server/app/api/areas/route.js.nft.json +1 -1
  62. package/dist/web/.next/server/app/api/bridge/[...path]/route.js +1 -1
  63. package/dist/web/.next/server/app/api/bridge/[...path]/route.js.nft.json +1 -1
  64. package/dist/web/.next/server/app/api/changelog/route/app-paths-manifest.json +3 -0
  65. package/dist/web/.next/server/app/api/changelog/route/build-manifest.json +11 -0
  66. package/dist/web/.next/server/app/api/changelog/route/server-reference-manifest.json +4 -0
  67. package/dist/web/.next/server/app/api/changelog/route.js +7 -0
  68. package/dist/web/.next/server/app/api/changelog/route.js.map +5 -0
  69. package/dist/web/.next/server/app/api/changelog/route.js.nft.json +1 -0
  70. package/dist/web/.next/server/app/api/changelog/route_client-reference-manifest.js +2 -0
  71. package/dist/web/.next/server/app/api/cli-assets/assistant/route.js +1 -1
  72. package/dist/web/.next/server/app/api/cli-assets/assistant/route.js.nft.json +1 -1
  73. package/dist/web/.next/server/app/api/cli-assets/fix/route.js +1 -1
  74. package/dist/web/.next/server/app/api/cli-assets/fix/route.js.nft.json +1 -1
  75. package/dist/web/.next/server/app/api/cli-assets/import/route.js +1 -1
  76. package/dist/web/.next/server/app/api/cli-assets/import/route.js.nft.json +1 -1
  77. package/dist/web/.next/server/app/api/cli-assets/route.js +2 -2
  78. package/dist/web/.next/server/app/api/cli-assets/route.js.nft.json +1 -1
  79. package/dist/web/.next/server/app/api/cli-assets/store/preview/route.js +1 -1
  80. package/dist/web/.next/server/app/api/cli-assets/store/preview/route.js.nft.json +1 -1
  81. package/dist/web/.next/server/app/api/cli-assets/store/route.js +2 -2
  82. package/dist/web/.next/server/app/api/cli-assets/store/route.js.nft.json +1 -1
  83. package/dist/web/.next/server/app/api/cli-assets/sync/route.js +1 -1
  84. package/dist/web/.next/server/app/api/cli-assets/sync/route.js.nft.json +1 -1
  85. package/dist/web/.next/server/app/api/cli-assets/updates/route.js +2 -2
  86. package/dist/web/.next/server/app/api/cli-assets/updates/route.js.nft.json +1 -1
  87. package/dist/web/.next/server/app/api/dashboard/route.js +2 -2
  88. package/dist/web/.next/server/app/api/dashboard/route.js.nft.json +1 -1
  89. package/dist/web/.next/server/app/api/events/route.js +1 -1
  90. package/dist/web/.next/server/app/api/events/route.js.nft.json +1 -1
  91. package/dist/web/.next/server/app/api/file/route.js +1 -1
  92. package/dist/web/.next/server/app/api/file/route.js.nft.json +1 -1
  93. package/dist/web/.next/server/app/api/git-status/route.js +1 -1
  94. package/dist/web/.next/server/app/api/git-status/route.js.nft.json +1 -1
  95. package/dist/web/.next/server/app/api/kanban/route.js +1 -1
  96. package/dist/web/.next/server/app/api/kanban/route.js.nft.json +1 -1
  97. package/dist/web/.next/server/app/api/kanban/stream/route.js +1 -1
  98. package/dist/web/.next/server/app/api/kanban/stream/route.js.nft.json +1 -1
  99. package/dist/web/.next/server/app/api/projects/[id]/route.js +2 -2
  100. package/dist/web/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
  101. package/dist/web/.next/server/app/api/projects/analyze/route.js +1 -1
  102. package/dist/web/.next/server/app/api/projects/analyze/route.js.nft.json +1 -1
  103. package/dist/web/.next/server/app/api/projects/reorder/route.js +2 -2
  104. package/dist/web/.next/server/app/api/projects/reorder/route.js.nft.json +1 -1
  105. package/dist/web/.next/server/app/api/projects/route.js +2 -2
  106. package/dist/web/.next/server/app/api/projects/route.js.nft.json +1 -1
  107. package/dist/web/.next/server/app/api/providers/route.js +1 -1
  108. package/dist/web/.next/server/app/api/providers/route.js.nft.json +1 -1
  109. package/dist/web/.next/server/app/api/scheduler/route.js +1 -1
  110. package/dist/web/.next/server/app/api/scheduler/route.js.nft.json +1 -1
  111. package/dist/web/.next/server/app/api/search/route.js +1 -1
  112. package/dist/web/.next/server/app/api/search/route.js.nft.json +1 -1
  113. package/dist/web/.next/server/app/api/settings/route.js +1 -1
  114. package/dist/web/.next/server/app/api/settings/route.js.nft.json +1 -1
  115. package/dist/web/.next/server/app/api/sly-actions/invalidate/route.js +1 -1
  116. package/dist/web/.next/server/app/api/sly-actions/invalidate/route.js.nft.json +1 -1
  117. package/dist/web/.next/server/app/api/sly-actions/route.js +1 -1
  118. package/dist/web/.next/server/app/api/sly-actions/route.js.nft.json +1 -1
  119. package/dist/web/.next/server/app/api/sly-actions/stream/route.js +1 -1
  120. package/dist/web/.next/server/app/api/sly-actions/stream/route.js.nft.json +1 -1
  121. package/dist/web/.next/server/app/api/system-stats/route.js +1 -1
  122. package/dist/web/.next/server/app/api/system-stats/route.js.nft.json +1 -1
  123. package/dist/web/.next/server/app/api/terminal-classes/route.js +1 -1
  124. package/dist/web/.next/server/app/api/terminal-classes/route.js.nft.json +1 -1
  125. package/dist/web/.next/server/app/api/transcribe/route.js +5 -5
  126. package/dist/web/.next/server/app/api/transcribe/route.js.nft.json +1 -1
  127. package/dist/web/.next/server/app/api/version-check/route.js +1 -1
  128. package/dist/web/.next/server/app/api/version-check/route.js.nft.json +1 -1
  129. package/dist/web/.next/server/app/page.js +1 -1
  130. package/dist/web/.next/server/app/page.js.nft.json +1 -1
  131. package/dist/web/.next/server/app/page_client-reference-manifest.js +1 -1
  132. package/dist/web/.next/server/app/project/[id]/page.js +2 -2
  133. package/dist/web/.next/server/app/project/[id]/page.js.nft.json +1 -1
  134. package/dist/web/.next/server/app/project/[id]/page_client-reference-manifest.js +1 -1
  135. package/dist/web/.next/server/app-paths-manifest.json +1 -0
  136. package/dist/web/.next/server/chunks/{[externals]__c6831f39._.js → [externals]__78e522ea._.js} +2 -2
  137. package/dist/web/.next/server/chunks/{[root-of-the-server]__1ec21ccc._.js → [root-of-the-server]__029203cd._.js} +3 -3
  138. package/dist/web/.next/server/chunks/{[root-of-the-server]__4297cb97._.js → [root-of-the-server]__0d6d4443._.js} +1 -1
  139. package/dist/web/.next/server/chunks/[root-of-the-server]__172ad0b1._.js +18 -0
  140. package/dist/web/.next/server/chunks/[root-of-the-server]__1c5f4ef9._.js +3 -0
  141. package/dist/web/.next/server/chunks/[root-of-the-server]__1cab11f0._.js +3 -0
  142. package/dist/web/.next/server/chunks/{[root-of-the-server]__0f69c28a._.js → [root-of-the-server]__1eb3f172._.js} +2 -2
  143. package/dist/web/.next/server/chunks/[root-of-the-server]__22cba275._.js +3 -0
  144. package/dist/web/.next/server/chunks/[root-of-the-server]__2543e413._.js +3 -0
  145. package/dist/web/.next/server/chunks/[root-of-the-server]__2c42a835._.js +3 -0
  146. package/dist/web/.next/server/chunks/[root-of-the-server]__2ed0ff47._.js +3 -0
  147. package/dist/web/.next/server/chunks/[root-of-the-server]__35454eea._.js +27 -0
  148. package/dist/web/.next/server/chunks/[root-of-the-server]__35768b56._.js +3 -0
  149. package/dist/web/.next/server/chunks/[root-of-the-server]__3880228a._.js +3 -0
  150. package/dist/web/.next/server/chunks/[root-of-the-server]__42322d88._.js +3 -0
  151. package/dist/web/.next/server/chunks/{[root-of-the-server]__d0f4efec._.js → [root-of-the-server]__5152eeff._.js} +3 -3
  152. package/dist/web/.next/server/chunks/[root-of-the-server]__527c7f57._.js +3 -0
  153. package/dist/web/.next/server/chunks/[root-of-the-server]__5c5dac4b._.js +3 -0
  154. package/dist/web/.next/server/chunks/[root-of-the-server]__5cb130f2._.js +3 -0
  155. package/dist/web/.next/server/chunks/[root-of-the-server]__68927e75._.js +3 -0
  156. package/dist/web/.next/server/chunks/[root-of-the-server]__719517c7._.js +3 -0
  157. package/dist/web/.next/server/chunks/[root-of-the-server]__73cf49c2._.js +3 -0
  158. package/dist/web/.next/server/chunks/{[root-of-the-server]__f5dae2ad._.js → [root-of-the-server]__7af4ab09._.js} +1 -1
  159. package/dist/web/.next/server/chunks/{[root-of-the-server]__4244617a._.js → [root-of-the-server]__7e6860e0._.js} +3 -3
  160. package/dist/web/.next/server/chunks/[root-of-the-server]__88bf5e22._.js +3 -0
  161. package/dist/web/.next/server/chunks/{[root-of-the-server]__f97e93fa._.js → [root-of-the-server]__8b4259cb._.js} +3 -3
  162. package/dist/web/.next/server/chunks/[root-of-the-server]__92f81907._.js +3 -0
  163. package/dist/web/.next/server/chunks/[root-of-the-server]__967603e9._.js +3 -0
  164. package/dist/web/.next/server/chunks/[root-of-the-server]__9e4bd28f._.js +3 -0
  165. package/dist/web/.next/server/chunks/[root-of-the-server]__a259539f._.js +3 -0
  166. package/dist/web/.next/server/chunks/[root-of-the-server]__ba1d2e56._.js +3 -0
  167. package/dist/web/.next/server/chunks/[root-of-the-server]__c942d872._.js +3 -0
  168. package/dist/web/.next/server/chunks/[root-of-the-server]__d7893622._.js +3 -0
  169. package/dist/web/.next/server/chunks/{[root-of-the-server]__3b9d3e43._.js → [root-of-the-server]__d843611b._.js} +6 -6
  170. package/dist/web/.next/server/chunks/[root-of-the-server]__f4d2627f._.js +3 -0
  171. package/dist/web/.next/server/chunks/[root-of-the-server]__f597835d._.js +3 -0
  172. package/dist/web/.next/server/chunks/{[root-of-the-server]__cf14e306._.js → [root-of-the-server]__fe8b9abd._.js} +1 -1
  173. package/dist/web/.next/server/chunks/_next-internal_server_app_api_changelog_route_actions_d6e239bf.js +3 -0
  174. package/dist/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_18324462.js +1 -1
  175. package/dist/web/.next/server/chunks/src_677020aa._.js +1 -1
  176. package/dist/web/.next/server/chunks/src_lib_scheduler_ts_03988e3e._.js +1 -1
  177. package/dist/web/.next/server/chunks/src_lib_scheduler_ts_7120457c._.js +1 -1
  178. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__1f5fc489._.js +4 -3
  179. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__43d93717._.js +3 -0
  180. package/dist/web/.next/server/chunks/ssr/{[root-of-the-server]__077f472c._.js → [root-of-the-server]__6183d28c._.js} +1 -1
  181. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__90f82e6d._.js +3 -0
  182. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__bcbe4bf2._.js +4 -3
  183. package/dist/web/.next/server/chunks/ssr/src_components_Dashboard_tsx_efc4dc27._.js +1 -1
  184. package/dist/web/.next/server/chunks/ssr/src_components_c4135402._.js +1 -1
  185. package/dist/web/.next/server/chunks/ssr/src_contexts_VoiceContext_tsx_cfba7292._.js +1 -1
  186. package/dist/web/.next/server/chunks/ssr/src_lib_registry_ts_2fc87c9c._.js +1 -1
  187. package/dist/web/.next/server/pages/404.html +1 -1
  188. package/dist/web/.next/server/pages/500.html +2 -2
  189. package/dist/web/.next/server/server-reference-manifest.js +1 -1
  190. package/dist/web/.next/server/server-reference-manifest.json +1 -1
  191. package/dist/web/.next/static/chunks/293449b828207656.css +1 -0
  192. package/dist/web/.next/static/chunks/{f55f3c8c1a52f80c.js → 3859477038c381ad.js} +1 -1
  193. package/dist/web/.next/static/chunks/3a5721af09d1c753.js +5 -0
  194. package/dist/web/.next/static/chunks/{8fb2a99c64580de7.js → 98311243e9a5a0ec.js} +1 -1
  195. package/dist/web/.next/static/chunks/{b8e0c1aeea4a14bc.js → a47f36b030917d1f.js} +1 -1
  196. package/dist/web/.next/static/chunks/d60c422421920130.js +5 -0
  197. package/dist/web/.next/static/chunks/{4049cceee6a49323.js → fa78afe3ceed998b.js} +1 -1
  198. package/dist/web/src/app/api/changelog/route.ts +45 -0
  199. package/dist/web/src/app/api/kanban/route.ts +52 -12
  200. package/dist/web/src/app/api/projects/analyze/route.ts +12 -2
  201. package/dist/web/src/app/api/projects/route.ts +1 -11
  202. package/dist/web/src/app/api/providers/route.ts +4 -0
  203. package/dist/web/src/components/ActivityFeed.tsx +3 -0
  204. package/dist/web/src/components/BranchTab.tsx +115 -0
  205. package/dist/web/src/components/ChangelogModal.tsx +234 -0
  206. package/dist/web/src/components/ClaudeTerminalPanel.tsx +124 -70
  207. package/dist/web/src/components/Dashboard.tsx +11 -0
  208. package/dist/web/src/components/GlobalClaudePanel.tsx +6 -0
  209. package/dist/web/src/components/ProjectKanban.tsx +38 -8
  210. package/dist/web/src/components/VersionUpdateToast.tsx +6 -4
  211. package/dist/web/src/components/VoiceControlBar.tsx +1 -1
  212. package/dist/web/src/lib/paths.ts +14 -0
  213. package/dist/web/src/lib/scheduler.ts +2 -1
  214. package/dist/web/src/lib/types.ts +24 -0
  215. package/dist/web/tsconfig.tsbuildinfo +1 -1
  216. package/package.json +1 -1
  217. package/templates/changelog.json +242 -0
  218. package/templates/kanban-seed.json +1 -1
  219. package/templates/store/actions/checkpoint.md +1 -1
  220. package/templates/store/actions/context.md +1 -1
  221. package/templates/store/actions/create-card.md +1 -1
  222. package/templates/store/actions/deep-design.md +13 -3
  223. package/templates/store/actions/design-requirements.md +11 -1
  224. package/templates/store/actions/explore.md +1 -1
  225. package/templates/store/actions/onboard.md +2 -4
  226. package/templates/store/actions/summarize.md +1 -1
  227. package/templates/store/skills/kanban/SKILL.md +77 -3
  228. package/templates/tutorial-project/documentation/kanban.json +1 -1
  229. package/templates/updates/actions/checkpoint.md +1 -1
  230. package/templates/updates/actions/context.md +1 -1
  231. package/templates/updates/actions/create-card.md +1 -1
  232. package/templates/updates/actions/deep-design.md +13 -3
  233. package/templates/updates/actions/design-requirements.md +11 -1
  234. package/templates/updates/actions/explore.md +1 -1
  235. package/templates/updates/actions/onboard.md +2 -4
  236. package/templates/updates/actions/summarize.md +1 -1
  237. package/templates/updates/skills/kanban/SKILL.md +77 -3
  238. package/dist/web/.next/server/chunks/[root-of-the-server]__09aec55a._.js +0 -3
  239. package/dist/web/.next/server/chunks/[root-of-the-server]__12f6cd6f._.js +0 -3
  240. package/dist/web/.next/server/chunks/[root-of-the-server]__15fc9266._.js +0 -18
  241. package/dist/web/.next/server/chunks/[root-of-the-server]__198f01e0._.js +0 -3
  242. package/dist/web/.next/server/chunks/[root-of-the-server]__279e9bf3._.js +0 -3
  243. package/dist/web/.next/server/chunks/[root-of-the-server]__2b639eab._.js +0 -3
  244. package/dist/web/.next/server/chunks/[root-of-the-server]__2d1f0ed9._.js +0 -3
  245. package/dist/web/.next/server/chunks/[root-of-the-server]__3f239285._.js +0 -3
  246. package/dist/web/.next/server/chunks/[root-of-the-server]__47dd878e._.js +0 -3
  247. package/dist/web/.next/server/chunks/[root-of-the-server]__5b8c9374._.js +0 -3
  248. package/dist/web/.next/server/chunks/[root-of-the-server]__5e08b942._.js +0 -3
  249. package/dist/web/.next/server/chunks/[root-of-the-server]__6ffce934._.js +0 -3
  250. package/dist/web/.next/server/chunks/[root-of-the-server]__71bb3374._.js +0 -3
  251. package/dist/web/.next/server/chunks/[root-of-the-server]__7603305e._.js +0 -3
  252. package/dist/web/.next/server/chunks/[root-of-the-server]__7c476ad6._.js +0 -3
  253. package/dist/web/.next/server/chunks/[root-of-the-server]__846ca56f._.js +0 -3
  254. package/dist/web/.next/server/chunks/[root-of-the-server]__98d88050._.js +0 -3
  255. package/dist/web/.next/server/chunks/[root-of-the-server]__b273cc05._.js +0 -3
  256. package/dist/web/.next/server/chunks/[root-of-the-server]__b90bbd70._.js +0 -3
  257. package/dist/web/.next/server/chunks/[root-of-the-server]__d5272169._.js +0 -3
  258. package/dist/web/.next/server/chunks/[root-of-the-server]__d56e68cb._.js +0 -3
  259. package/dist/web/.next/server/chunks/[root-of-the-server]__d6362272._.js +0 -3
  260. package/dist/web/.next/server/chunks/[root-of-the-server]__de1277ee._.js +0 -27
  261. package/dist/web/.next/server/chunks/[root-of-the-server]__e88a19d2._.js +0 -3
  262. package/dist/web/.next/server/chunks/[root-of-the-server]__f3e501b6._.js +0 -3
  263. package/dist/web/.next/server/chunks/[root-of-the-server]__f59af2bc._.js +0 -3
  264. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__9ac6ea25._.js +0 -3
  265. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__dfe2728c._.js +0 -3
  266. package/dist/web/.next/static/chunks/3d5195b57fc05540.js +0 -4
  267. package/dist/web/.next/static/chunks/59fb302a5bfd2dc0.js +0 -4
  268. package/dist/web/.next/static/chunks/747f5e5f9dcf2621.css +0 -1
  269. /package/dist/web/.next/static/{0sPAbk-Qw-InZ0rdHjHnC → aN-jqftQVvSm0qVskLybH}/_buildManifest.js +0 -0
  270. /package/dist/web/.next/static/{0sPAbk-Qw-InZ0rdHjHnC → aN-jqftQVvSm0qVskLybH}/_clientMiddlewareManifest.json +0 -0
  271. /package/dist/web/.next/static/{0sPAbk-Qw-InZ0rdHjHnC → aN-jqftQVvSm0qVskLybH}/_ssgManifest.js +0 -0
@@ -1,3 +1,3 @@
1
1
  module.exports=[76535,e=>{"use strict";var r=e.i(46277);let t=async e=>{let t=await (0,r.loadSharedConfigFiles)(e);return((...e)=>{let r={};for(let t of e)for(let[e,i]of Object.entries(t))void 0!==r[e]?Object.assign(r[e],i):r[e]=i;return r})(t.configFile,t.credentialsFile)};e.s(["parseKnownFiles",0,t],76535)},66680,(e,r,t)=>{r.exports=e.x("node:crypto",()=>require("node:crypto"))},1346,e=>{"use strict";e.s([],58014),e.i(58014);var r=e.i(81355),t=e.i(76535),i=e.i(60400),n=e.i(9212),s=e.i(39866);let o=e=>(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_NAMED_PROVIDER","p"),a=async(t,a,c,d,g={},u)=>{c.logger?.debug("@aws-sdk/credential-provider-ini - resolveAssumeRoleCredentials (STS)");let f=a[t],{source_profile:_,region:p}=f;if(!c.roleAssumer){let{getDefaultRoleAssumer:r}=await e.A(43109);c.roleAssumer=r({...c.clientConfig,credentialProviderLogger:c.logger,parentClientConfig:{...d,...c?.parentClientConfig,region:p??c?.parentClientConfig?.region??d?.region}},c.clientPlugins)}if(_&&_ in g)throw new i.CredentialsProviderError(`Detected a cycle attempting to resolve credentials for profile ${(0,r.getProfileName)(c)}. Profiles visited: `+Object.keys(g).join(", "),{logger:c.logger});c.logger?.debug(`@aws-sdk/credential-provider-ini - finding credential resolver using ${_?`source_profile=[${_}]`:`profile=[${t}]`}`);let h=_?u(_,a,c,d,{...g,[_]:!0},l(a[_]??{})):(await ((r,t,n)=>{let a={EcsContainer:async r=>{let{fromHttp:t}=await e.A(93306),{fromContainerMetadata:i}=await e.A(14277);return n?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer"),async()=>(0,s.chain)(t(r??{}),i(r))().then(o)},Ec2InstanceMetadata:async r=>{n?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");let{fromInstanceMetadata:t}=await e.A(14277);return async()=>t(r)().then(o)},Environment:async r=>{n?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");let{fromEnv:t}=await e.A(31605);return async()=>t(r)().then(o)}};if(r in a)return a[r];throw new i.CredentialsProviderError(`Unsupported credential source in profile ${t}. Got ${r}, expected EcsContainer or Ec2InstanceMetadata or Environment.`,{logger:n})})(f.credential_source,t,c.logger)(c))();if(l(f))return h.then(e=>(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"));{let e={RoleArn:f.role_arn,RoleSessionName:f.role_session_name||`aws-sdk-js-${Date.now()}`,ExternalId:f.external_id,DurationSeconds:parseInt(f.duration_seconds||"3600",10)},{mfa_serial:r}=f;if(r){if(!c.mfaCodeProvider)throw new i.CredentialsProviderError(`Profile ${t} requires multi-factor authentication, but no MFA code callback was provided.`,{logger:c.logger,tryNextLink:!1});e.SerialNumber=r,e.TokenCode=await c.mfaCodeProvider(r)}let s=await h;return c.roleAssumer(s,e).then(e=>(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_SOURCE_PROFILE","o"))}},l=e=>!e.role_arn&&!!e.credential_source;var c=e.i(89073),d=e.i(49487),g=e.i(66680),u=e.i(2157),f=e.i(60526),_=e.i(50227);class p{profileData;init;callerClientConfig;static REFRESH_THRESHOLD=3e5;constructor(e,r,t){this.profileData=e,this.init=r,this.callerClientConfig=t}async loadCredentials(){let e=await this.loadToken();if(!e)throw new i.CredentialsProviderError(`Failed to load a token for session ${this.loginSession}, please re-authenticate using aws login`,{tryNextLink:!1,logger:this.logger});let r=e.accessToken,t=Date.now();return new Date(r.expiresAt).getTime()-t<=p.REFRESH_THRESHOLD?this.refresh(e):{accessKeyId:r.accessKeyId,secretAccessKey:r.secretAccessKey,sessionToken:r.sessionToken,accountId:r.accountId,expiration:new Date(r.expiresAt)}}get logger(){return this.init?.logger}get loginSession(){return this.profileData.login_session}async refresh(r){let t,{SigninClient:n,CreateOAuth2TokenCommand:s}=await e.A(54608),{logger:o,userAgentAppId:a}=this.callerClientConfig??{},l=(t=this.callerClientConfig?.requestHandler,t?.metadata?.handlerProtocol==="h2")?void 0:this.callerClientConfig?.requestHandler,c=new n({credentials:{accessKeyId:"",secretAccessKey:""},region:this.profileData.region??await this.callerClientConfig?.region?.()??process.env.AWS_REGION,requestHandler:l,logger:o,userAgentAppId:a,...this.init?.clientConfig});this.createDPoPInterceptor(c.middlewareStack);let d={tokenInput:{clientId:r.clientId,refreshToken:r.refreshToken,grantType:"refresh_token"}};try{let e=await c.send(new s(d)),{accessKeyId:t,secretAccessKey:n,sessionToken:o}=e.tokenOutput?.accessToken??{},{refreshToken:a,expiresIn:l}=e.tokenOutput??{};if(!t||!n||!o||!a)throw new i.CredentialsProviderError("Token refresh response missing required fields",{logger:this.logger,tryNextLink:!1});let g=new Date(Date.now()+(l??900)*1e3),u={...r,accessToken:{...r.accessToken,accessKeyId:t,secretAccessKey:n,sessionToken:o,expiresAt:g.toISOString()},refreshToken:a};await this.saveToken(u);let f=u.accessToken;return{accessKeyId:f.accessKeyId,secretAccessKey:f.secretAccessKey,sessionToken:f.sessionToken,accountId:f.accountId,expiration:g}}catch(e){if("AccessDeniedException"===e.name){let r;switch(e.error){case"TOKEN_EXPIRED":r="Your session has expired. Please reauthenticate.";break;case"USER_CREDENTIALS_CHANGED":r="Unable to refresh credentials because of a change in your password. Please reauthenticate with your new password.";break;case"INSUFFICIENT_PERMISSIONS":r="Unable to refresh credentials due to insufficient permissions. You may be missing permission for the 'CreateOAuth2Token' action.";break;default:r=`Failed to refresh token: ${String(e)}. Please re-authenticate using \`aws login\``}throw new i.CredentialsProviderError(r,{logger:this.logger,tryNextLink:!1})}throw new i.CredentialsProviderError(`Failed to refresh token: ${String(e)}. Please re-authenticate using aws login`,{logger:this.logger})}}async loadToken(){let e=this.getTokenFilePath();try{let r;try{r=await (0,d.readFile)(e,{ignoreCache:this.init?.ignoreCache})}catch{r=await u.promises.readFile(e,"utf8")}let t=JSON.parse(r),n=["accessToken","clientId","refreshToken","dpopKey"].filter(e=>!t[e]);if(t.accessToken?.accountId||n.push("accountId"),n.length>0)throw new i.CredentialsProviderError(`Token validation failed, missing fields: ${n.join(", ")}`,{logger:this.logger,tryNextLink:!1});return t}catch(r){throw new i.CredentialsProviderError(`Failed to load token from ${e}: ${String(r)}`,{logger:this.logger,tryNextLink:!1})}}async saveToken(e){let r=this.getTokenFilePath(),t=(0,_.dirname)(r);try{await u.promises.mkdir(t,{recursive:!0})}catch(e){}await u.promises.writeFile(r,JSON.stringify(e,null,2),"utf8")}getTokenFilePath(){let e=process.env.AWS_LOGIN_CACHE_DIRECTORY??(0,_.join)((0,f.homedir)(),".aws","login","cache"),r=Buffer.from(this.loginSession,"utf8"),t=(0,g.createHash)("sha256").update(r).digest("hex");return(0,_.join)(e,`${t}.json`)}derToRawSignature(e){let r=2;if(2!==e[2])throw Error("Invalid DER signature");r++;let t=e[r++],i=e.subarray(r,r+t);if(2!==e[r+=t])throw Error("Invalid DER signature");r++;let n=e[r++],s=e.subarray(r,r+n);i=0===i[0]?i.subarray(1):i,s=0===s[0]?s.subarray(1):s;let o=Buffer.concat([Buffer.alloc(32-i.length),i]),a=Buffer.concat([Buffer.alloc(32-s.length),s]);return Buffer.concat([o,a])}createDPoPInterceptor(e){e.add(e=>async r=>{if(c.HttpRequest.isInstance(r.request)){let e=r.request,t=`${e.protocol}//${e.hostname}${e.port?`:${e.port}`:""}${e.path}`,i=await this.generateDpop(e.method,t);e.headers={...e.headers,DPoP:i}}return e(r)},{step:"finalizeRequest",name:"dpopInterceptor",override:!0})}async generateDpop(e="POST",r){let t=await this.loadToken();try{let i=(0,g.createPrivateKey)({key:t.dpopKey,format:"pem",type:"sec1"}),n=(0,g.createPublicKey)(i).export({format:"der",type:"spki"}),s=-1;for(let e=0;e<n.length;e++)if(4===n[e]){s=e;break}let o=n.slice(s+1,s+33),a=n.slice(s+33,s+65),l={alg:"ES256",typ:"dpop+jwt",jwk:{kty:"EC",crv:"P-256",x:o.toString("base64url"),y:a.toString("base64url")}},c={jti:crypto.randomUUID(),htm:e,htu:r,iat:Math.floor(Date.now()/1e3)},d=Buffer.from(JSON.stringify(l)).toString("base64url"),u=Buffer.from(JSON.stringify(c)).toString("base64url"),f=`${d}.${u}`,_=(0,g.sign)("sha256",Buffer.from(f),i),p=this.derToRawSignature(_).toString("base64url");return`${f}.${p}`}catch(e){throw new i.CredentialsProviderError(`Failed to generate Dpop proof: ${e instanceof Error?e.message:String(e)}`,{logger:this.logger,tryNextLink:!1})}}}let h=async(e,s,o)=>{let a,l=await (a={...s,profile:e},async({callerClientConfig:e}={})=>{a?.logger?.debug?.("@aws-sdk/credential-providers - fromLoginCredentials");let s=await (0,t.parseKnownFiles)(a||{}),o=(0,r.getProfileName)({profile:a?.profile??e?.profile}),l=s[o];if(!l?.login_session)throw new i.CredentialsProviderError(`Profile ${o} does not contain login_session.`,{tryNextLink:!0,logger:a?.logger});let c=new p(l,a,e),d=await c.loadCredentials();return(0,n.setCredentialFeature)(d,"CREDENTIALS_LOGIN","AD")})({callerClientConfig:o});return(0,n.setCredentialFeature)(l,"CREDENTIALS_PROFILE_LOGIN","AC")},y=async(r,t)=>e.A(85365).then(({fromProcess:e})=>e({...r,profile:t})().then(e=>(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_PROCESS","v"))),w=async(r,t,i={},s)=>{let{fromSSO:o}=await e.A(14115);return o({profile:r,logger:i.logger,parentClientConfig:i.parentClientConfig,clientConfig:i.clientConfig})({callerClientConfig:s}).then(e=>t.sso_session?(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_SSO","r"):(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_SSO_LEGACY","t"))},C=e=>!!e&&"object"==typeof e&&"string"==typeof e.aws_access_key_id&&"string"==typeof e.aws_secret_access_key&&["undefined","string"].indexOf(typeof e.aws_session_token)>-1&&["undefined","string"].indexOf(typeof e.aws_account_id)>-1,E=async(e,r)=>{r?.logger?.debug("@aws-sdk/credential-provider-ini - resolveStaticCredentials");let t={accessKeyId:e.aws_access_key_id,secretAccessKey:e.aws_secret_access_key,sessionToken:e.aws_session_token,...e.aws_credential_scope&&{credentialScope:e.aws_credential_scope},...e.aws_account_id&&{accountId:e.aws_account_id}};return(0,n.setCredentialFeature)(t,"CREDENTIALS_PROFILE","n")},k=async(r,t,i)=>e.A(52170).then(({fromTokenFile:e})=>e({webIdentityTokenFile:r.web_identity_token_file,roleArn:r.role_arn,roleSessionName:r.role_session_name,roleAssumerWithWebIdentity:t.roleAssumerWithWebIdentity,logger:t.logger,parentClientConfig:t.parentClientConfig})({callerClientConfig:i}).then(e=>(0,n.setCredentialFeature)(e,"CREDENTIALS_PROFILE_STS_WEB_ID_TOKEN","q"))),m=async(e,r,t,n,s={},o=!1)=>{let l=r[e];if(Object.keys(s).length>0&&C(l))return E(l,t);if(o||((e,{profile:r="default",logger:t}={})=>!!e&&"object"==typeof e&&"string"==typeof e.role_arn&&["undefined","string"].indexOf(typeof e.role_session_name)>-1&&["undefined","string"].indexOf(typeof e.external_id)>-1&&["undefined","string"].indexOf(typeof e.mfa_serial)>-1&&(((e,{profile:r,logger:t})=>{let i="string"==typeof e.source_profile&&void 0===e.credential_source;return i&&t?.debug?.(` ${r} isAssumeRoleWithSourceProfile source_profile=${e.source_profile}`),i})(e,{profile:r,logger:t})||((e,{profile:r,logger:t})=>{let i="string"==typeof e.credential_source&&void 0===e.source_profile;return i&&t?.debug?.(` ${r} isCredentialSourceProfile credential_source=${e.credential_source}`),i})(e,{profile:r,logger:t})))(l,{profile:e,logger:t.logger}))return a(e,r,t,n,s,m);if(C(l))return E(l,t);if(l&&"object"==typeof l&&"string"==typeof l.web_identity_token_file&&"string"==typeof l.role_arn&&["undefined","string"].indexOf(typeof l.role_session_name)>-1)return k(l,t,n);if(l&&"object"==typeof l&&"string"==typeof l.credential_process)return y(t,e);if(l&&("string"==typeof l.sso_start_url||"string"==typeof l.sso_account_id||"string"==typeof l.sso_session||"string"==typeof l.sso_region||"string"==typeof l.sso_role_name))return await w(e,l,t,n);if(l&&l.login_session)return h(e,t,n);throw new i.CredentialsProviderError(`Could not resolve credentials using profile: [${e}] in configuration/credentials file(s).`,{logger:t.logger})},I=(e={})=>async({callerClientConfig:i}={})=>{e.logger?.debug("@aws-sdk/credential-provider-ini - fromIni");let n=await (0,t.parseKnownFiles)(e);return m((0,r.getProfileName)({profile:e.profile??i?.profile}),n,e,i)};e.s(["fromIni",0,I],24518),e.i(24518),e.s(["fromIni",0,I],1346)},31605,e=>{e.v(r=>Promise.all(["server/chunks/node_modules_@aws-sdk_credential-provider-env_dist-es_index_55d96139.js"].map(r=>e.l(r))).then(()=>r(97301)))},43109,e=>{e.v(r=>Promise.all(["server/chunks/node_modules_9fc3887b._.js","server/chunks/node_modules_@aws-sdk_nested-clients_dist-es_submodules_sts_index_c78619b3.js"].map(r=>e.l(r))).then(()=>r(90222)))},54608,e=>{e.v(r=>Promise.all(["server/chunks/node_modules_@smithy_smithy-client_dist-es_create-aggregated-client_db42850b.js","server/chunks/node_modules_c58ca22f._.js","server/chunks/node_modules_@aws-sdk_nested-clients_dist-es_submodules_signin_index_6712dec9.js"].map(r=>e.l(r))).then(()=>r(20083)))}];
2
2
 
3
- //# sourceMappingURL=%5Broot-of-the-server%5D__cf14e306._.js.map
3
+ //# sourceMappingURL=%5Broot-of-the-server%5D__fe8b9abd._.js.map
@@ -0,0 +1,3 @@
1
+ module.exports=[22679,(e,o,d)=>{}];
2
+
3
+ //# sourceMappingURL=_next-internal_server_app_api_changelog_route_actions_d6e239bf.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[69497,e=>{"use strict";var t=e.i(47909),a=e.i(74017),r=e.i(96250),n=e.i(59756),o=e.i(61916),i=e.i(74677),s=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),g=e.i(70101),f=e.i(74838),h=e.i(10372),m=e.i(93695);e.i(52474);var w=e.i(220),R=e.i(89171),y=e.i(22734),v=e.i(14747),b=e.i(32695),E=e.i(1365),x=e.i(71741);let k={backlog:[],design:[],implementation:[],testing:[],done:[]};function C(e){return(e.backlog?.length||0)+(e.design?.length||0)+(e.implementation?.length||0)+(e.testing?.length||0)+(e.done?.length||0)}function N(e){return Array.isArray(e)?[...e].sort((e,t)=>e.order-t.order).map((e,t)=>({...e,order:(t+1)*10})):[]}async function O(e){try{return(await y.promises.stat(e)).mtime}catch{return null}}async function S(e,t,a){try{let a=await (0,x.getTieredBackupPath)(e,t,3);await y.promises.unlink(a)}catch{}for(let a=2;a>=1;a--){let r=await (0,x.getTieredBackupPath)(e,t,a),n=await (0,x.getTieredBackupPath)(e,t,a+1);try{await y.promises.rename(r,n)}catch{}}let r=await (0,x.getTieredBackupPath)(e,t,1);await y.promises.writeFile(r,a)}async function j(e,t){try{let a;try{a=await y.promises.readFile(t,"utf-8");let e=JSON.parse(a);if(0===C(e.stages||{}))return}catch{return}let r=Date.now(),n=await (0,x.getArchiveDir)(e);for(let[t,o]of(await y.promises.mkdir(n,{recursive:!0}),Object.entries(x.BACKUP_TIERS))){let n=await (0,x.getTieredBackupPath)(e,t,1),i=await O(n);(!i||r-i.getTime()>=o)&&await S(e,t,a)}}catch(e){console.error("Failed to update tiered backups:",e)}}async function P(e){try{for(let t of(await (0,x.getLegacyBackupPaths)(e)))try{await y.promises.unlink(t),console.log(`Cleaned up legacy backup: ${t}`)}catch{}}catch(e){console.error("Failed to cleanup legacy backups:",e)}}async function A(e){let{searchParams:t}=new URL(e.url),a=t.get("projectId");if(!a)return R.NextResponse.json({error:"projectId required"},{status:400});try{let e=await (0,x.getKanbanPath)(a);try{let t=await y.promises.readFile(e,"utf-8"),a=JSON.parse(t);for(let e of Object.values(a.stages))for(let t of e)if(t.automation?.enabled&&t.automation.schedule&&"recurring"===t.automation.scheduleType){let e=(0,b.getNextRun)(t.automation.schedule,"recurring");e&&(t.automation.nextRun=e.toISOString())}return R.NextResponse.json(a)}catch{return R.NextResponse.json({project_id:a,stages:k,last_updated:new Date().toISOString()})}}catch(e){if(e instanceof x.ProjectResolutionError)return R.NextResponse.json({error:e.message},{status:404});return console.error("Failed to get kanban:",e),R.NextResponse.json({error:"Failed to load kanban"},{status:500})}}async function T(e){try{var t;let a,{projectId:r,stages:n,changedCardIds:o}=await e.json(),i=n;if(!r)return R.NextResponse.json({error:"projectId required"},{status:400});if(!i||"object"!=typeof i)return R.NextResponse.json({error:"stages must be an object"},{status:400});try{a=await (0,x.getKanbanPath)(r)}catch(e){if(e instanceof x.ProjectResolutionError)return R.NextResponse.json({error:e.message},{status:404});throw e}let s=C(i);if(0===s)try{let e=await y.promises.readFile(a,"utf-8"),t=JSON.parse(e),r=C(t.stages||{});if(r>0)return console.warn(`BLOCKED: Attempted to save empty kanban (would wipe ${r} cards)`),R.NextResponse.json({error:"Refusing to save empty kanban - would delete existing cards"},{status:400})}catch{}if(await j(r,a),await P(r),o&&o.length>0)try{let e=await y.promises.readFile(a,"utf-8"),t=JSON.parse(e).stages||k,r=new Map;for(let[e,t]of Object.entries(i))for(let a of t||[])o.includes(a.id)&&r.set(a.id,{card:{...a,last_modified_by:"web"},stage:e});let n={backlog:[...t.backlog||[]],design:[...t.design||[]],implementation:[...t.implementation||[]],testing:[...t.testing||[]],done:[...t.done||[]]};for(let e of o)for(let t of Object.keys(n))n[t]=n[t].filter(t=>t.id!==e);for(let[,{card:e,stage:t}]of r)n[t]=[...n[t],e];i=n}catch{}let l=(t=i,{backlog:N(t.backlog||[]),design:N(t.design||[]),implementation:N(t.implementation||[]),testing:N(t.testing||[]),done:N(t.done||[])}),d={project_id:r,stages:l,last_updated:new Date().toISOString()},u=null;try{let e=await y.promises.readFile(a,"utf-8");u=JSON.parse(e).stages}catch{}if(await y.promises.mkdir(v.default.dirname(a),{recursive:!0}),await y.promises.writeFile(a,JSON.stringify(d,null,2)),u){let e=new Map;for(let[t,a]of Object.entries(u))for(let r of a||[])e.set(r.id,{card:r,stage:t});let t=o?"web":void 0;for(let[a,n]of Object.entries(l))for(let i of n||[]){let n=e.get(i.id);try{n?n.stage!==a?(0,E.appendEvent)({type:"card_moved",project:r,card:i.id,detail:`Card '${i.title}' moved from ${n.stage} to ${a}`,...t&&{source:t},timestamp:new Date().toISOString()}):o?.includes(i.id)&&(0,E.appendEvent)({type:"card_updated",project:r,card:i.id,detail:`Card '${i.title}' updated`,source:"web",timestamp:new Date().toISOString()}):(0,E.appendEvent)({type:"card_created",project:r,card:i.id,detail:`Card '${i.title}' created in ${a}`,...t&&{source:t},timestamp:new Date().toISOString()})}catch{}}}return R.NextResponse.json({success:!0,last_updated:d.last_updated})}catch(e){return console.error("Failed to save kanban:",e),R.NextResponse.json({error:"Failed to save"},{status:500})}}e.s(["GET",()=>A,"POST",()=>T],97891);var _=e.i(97891);let I=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/kanban/route",pathname:"/api/kanban",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/kanban/route.ts",nextConfigOutput:"standalone",userland:_}),{workAsyncStorage:D,workUnitAsyncStorage:F,serverHooks:U}=I;function H(){return(0,r.patchFetch)({workAsyncStorage:D,workUnitAsyncStorage:F})}async function $(e,t,r){I.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let R="/api/kanban/route";R=R.replace(/\/index$/,"")||"/";let y=await I.prepare(e,t,{srcPage:R,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:v,params:b,nextConfig:E,parsedUrl:x,isDraftMode:k,prerenderManifest:C,routerServerContext:N,isOnDemandRevalidate:O,revalidateOnlyGenerated:S,resolvedPathname:j,clientReferenceManifest:P,serverActionsManifest:A}=y,T=(0,s.normalizeAppPath)(R),_=!!(C.dynamicRoutes[T]||C.routes[j]),D=async()=>((null==N?void 0:N.render404)?await N.render404(e,t,x,!1):t.end("This page could not be found"),null);if(_&&!k){let e=!!C.routes[j],t=C.dynamicRoutes[T];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await D();throw new m.NoFallbackError}}let F=null;!_||I.isDev||k||(F="/index"===(F=j)?"/":F);let U=!0===I.isDev||!_,H=_&&!U;A&&P&&(0,i.setManifestsSingleton)({page:R,clientReferenceManifest:P,serverActionsManifest:A});let $=e.method||"GET",q=(0,o.getTracer)(),M=q.getActiveScopeSpan(),B={params:b,prerenderManifest:C,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>I.onRequestError(e,t,r,n,N)},sharedContext:{buildId:v}},K=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),J=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let i=async e=>I.handle(J,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=q.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=a.get("next.route");if(r){let t=`${$} ${r}`;e.setAttributes({"next.route":r,"http.route":r,"next.span_name":t}),e.updateName(t)}else e.updateName(`${$} ${R}`)}),s=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var o,l;let d=async({previousCacheEntry:a})=>{try{if(!s&&O&&S&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let o=await i(n);e.fetchMetrics=B.renderOpts.fetchMetrics;let l=B.renderOpts.pendingWaitUntil;l&&r.waitUntil&&(r.waitUntil(l),l=void 0);let d=B.renderOpts.collectedTags;if(!_)return await (0,p.sendResponse)(K,L,o,B.renderOpts.pendingWaitUntil),null;{let e=await o.blob(),t=(0,g.toNodeOutgoingHttpHeaders)(o.headers);d&&(t[h.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,r=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:w.CachedRouteKind.APP_ROUTE,status:o.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:r}}}}catch(t){throw(null==a?void 0:a.isStale)&&await I.onRequestError(e,t,{routerKind:"App Router",routePath:R,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:O})},!1,N),t}},u=await I.handleResponse({req:e,nextConfig:E,cacheKey:F,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:C,isRoutePPREnabled:!1,isOnDemandRevalidate:O,revalidateOnlyGenerated:S,responseGenerator:d,waitUntil:r.waitUntil,isMinimalMode:s});if(!_)return null;if((null==u||null==(o=u.value)?void 0:o.kind)!==w.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});s||t.setHeader("x-nextjs-cache",O?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),k&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,g.fromNodeOutgoingHttpHeaders)(u.value.headers);return s&&_||m.delete(h.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,f.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(K,L,new Response(u.value.body,{headers:m,status:u.value.status||200})),null};M?await l(M):await q.withPropagatedContext(e.headers,()=>q.trace(u.BaseServerSpan.handleRequest,{spanName:`${$} ${R}`,kind:o.SpanKind.SERVER,attributes:{"http.method":$,"http.target":e.url}},l))}catch(t){if(t instanceof m.NoFallbackError||await I.onRequestError(e,t,{routerKind:"App Router",routePath:T,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:O})},!1,N),_)throw t;return await (0,p.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>$,"patchFetch",()=>H,"routeModule",()=>I,"serverHooks",()=>U,"workAsyncStorage",()=>D,"workUnitAsyncStorage",()=>F],69497)}];
1
+ module.exports=[69497,e=>{"use strict";var t=e.i(47909),a=e.i(74017),r=e.i(96250),n=e.i(59756),i=e.i(61916),o=e.i(74677),s=e.i(69741),l=e.i(16795),d=e.i(87718),u=e.i(95169),c=e.i(47587),p=e.i(66012),f=e.i(70101),g=e.i(74838),h=e.i(10372),m=e.i(93695);e.i(52474);var w=e.i(220),R=e.i(89171),y=e.i(22734),v=e.i(14747),b=e.i(32695),E=e.i(1365),x=e.i(71741);let k={backlog:[],design:[],implementation:[],testing:[],done:[]};function O(e){return(e.backlog?.length||0)+(e.design?.length||0)+(e.implementation?.length||0)+(e.testing?.length||0)+(e.done?.length||0)}function C(e){return Array.isArray(e)?[...e].sort((e,t)=>e.order-t.order).map((e,t)=>({...e,order:(t+1)*10})):[]}async function N(e){try{return(await y.promises.stat(e)).mtime}catch{return null}}async function S(e,t,a){try{let a=await (0,x.getTieredBackupPath)(e,t,3);await y.promises.unlink(a)}catch{}for(let a=2;a>=1;a--){let r=await (0,x.getTieredBackupPath)(e,t,a),n=await (0,x.getTieredBackupPath)(e,t,a+1);try{await y.promises.rename(r,n)}catch{}}let r=await (0,x.getTieredBackupPath)(e,t,1);await y.promises.writeFile(r,a)}async function j(e,t){try{let a;try{a=await y.promises.readFile(t,"utf-8");let e=JSON.parse(a);if(0===O(e.stages||{}))return}catch{return}let r=Date.now(),n=await (0,x.getArchiveDir)(e);for(let[t,i]of(await y.promises.mkdir(n,{recursive:!0}),Object.entries(x.BACKUP_TIERS))){let n=await (0,x.getTieredBackupPath)(e,t,1),o=await N(n);(!o||r-o.getTime()>=i)&&await S(e,t,a)}}catch(e){console.error("Failed to update tiered backups:",e)}}async function _(e){try{for(let t of(await (0,x.getLegacyBackupPaths)(e)))try{await y.promises.unlink(t),console.log(`Cleaned up legacy backup: ${t}`)}catch{}}catch(e){console.error("Failed to cleanup legacy backups:",e)}}async function P(e){let{searchParams:t}=new URL(e.url),a=t.get("projectId");if(!a)return R.NextResponse.json({error:"projectId required"},{status:400});try{let e=await (0,x.getKanbanPath)(a);try{let t=await y.promises.readFile(e,"utf-8"),a=JSON.parse(t);for(let e of Object.values(a.stages))for(let t of e)if(t.automation?.enabled&&t.automation.schedule&&"recurring"===t.automation.scheduleType){let e=(0,b.getNextRun)(t.automation.schedule,"recurring");e&&(t.automation.nextRun=e.toISOString())}return R.NextResponse.json(a)}catch{return R.NextResponse.json({project_id:a,stages:k,last_updated:new Date().toISOString()})}}catch(e){if(e instanceof x.ProjectResolutionError)return R.NextResponse.json({error:e.message},{status:404});return console.error("Failed to get kanban:",e),R.NextResponse.json({error:"Failed to load kanban"},{status:500})}}async function A(e){try{var t;let a,{projectId:r,stages:n,changedCardIds:i,changedCards:o}=await e.json(),s=n;if(!r)return R.NextResponse.json({error:"projectId required"},{status:400});if(!s||"object"!=typeof s)return R.NextResponse.json({error:"stages must be an object"},{status:400});try{a=await (0,x.getKanbanPath)(r)}catch(e){if(e instanceof x.ProjectResolutionError)return R.NextResponse.json({error:e.message},{status:404});throw e}let l=O(s);if(0===l)try{let e=await y.promises.readFile(a,"utf-8"),t=JSON.parse(e),r=O(t.stages||{});if(r>0)return console.warn(`BLOCKED: Attempted to save empty kanban (would wipe ${r} cards)`),R.NextResponse.json({error:"Refusing to save empty kanban - would delete existing cards"},{status:400})}catch{}await j(r,a),await _(r);let d=o?.map(e=>e.id)??i;if(d&&d.length>0)try{let e=await y.promises.readFile(a,"utf-8"),t=JSON.parse(e).stages||k,r=new Map;if(o)for(let e of o)r.set(e.id,e.type);let n=new Map;for(let[,e]of Object.entries(t))for(let t of e||[])n.set(t.id,t);let i=new Map;for(let[e,t]of Object.entries(s))for(let a of t||[])if(d.includes(a.id)){let t,o=r.get(a.id)||"edit";if("move"===o){let e=n.get(a.id);if(!e)continue;t={...e,order:a.order,updated_at:a.updated_at,last_modified_by:"web"}}else t={...a,last_modified_by:"web"};i.set(a.id,{card:t,stage:e})}let l={backlog:[...t.backlog||[]],design:[...t.design||[]],implementation:[...t.implementation||[]],testing:[...t.testing||[]],done:[...t.done||[]]};for(let e of d)for(let t of Object.keys(l))l[t]=l[t].filter(t=>t.id!==e);for(let[,{card:e,stage:t}]of i)l[t]=[...l[t],e];s=l}catch{}let u=(t=s,{backlog:C(t.backlog||[]),design:C(t.design||[]),implementation:C(t.implementation||[]),testing:C(t.testing||[]),done:C(t.done||[])}),c={project_id:r,stages:u,last_updated:new Date().toISOString()},p=null;try{let e=await y.promises.readFile(a,"utf-8");p=JSON.parse(e).stages}catch{}if(await y.promises.mkdir(v.default.dirname(a),{recursive:!0}),await y.promises.writeFile(a,JSON.stringify(c,null,2)),p){let e=new Map;for(let[t,a]of Object.entries(p))for(let r of a||[])e.set(r.id,{card:r,stage:t});let t=i?"web":void 0;for(let[a,n]of Object.entries(u))for(let o of n||[]){let n=e.get(o.id);try{n?n.stage!==a?(0,E.appendEvent)({type:"card_moved",project:r,card:o.id,detail:`Card '${o.title}' moved from ${n.stage} to ${a}`,...t&&{source:t},timestamp:new Date().toISOString()}):i?.includes(o.id)&&(0,E.appendEvent)({type:"card_updated",project:r,card:o.id,detail:`Card '${o.title}' updated`,source:"web",timestamp:new Date().toISOString()}):(0,E.appendEvent)({type:"card_created",project:r,card:o.id,detail:`Card '${o.title}' created in ${a}`,...t&&{source:t},timestamp:new Date().toISOString()})}catch{}}}return R.NextResponse.json({success:!0,last_updated:c.last_updated,stages:u})}catch(e){return console.error("Failed to save kanban:",e),R.NextResponse.json({error:"Failed to save"},{status:500})}}e.s(["GET",()=>P,"POST",()=>A],97891);var T=e.i(97891);let I=new t.AppRouteRouteModule({definition:{kind:a.RouteKind.APP_ROUTE,page:"/api/kanban/route",pathname:"/api/kanban",filename:"route",bundlePath:""},distDir:".next",relativeProjectDir:"",resolvedPagePath:"[project]/src/app/api/kanban/route.ts",nextConfigOutput:"standalone",userland:T}),{workAsyncStorage:D,workUnitAsyncStorage:F,serverHooks:U}=I;function H(){return(0,r.patchFetch)({workAsyncStorage:D,workUnitAsyncStorage:F})}async function $(e,t,r){I.isDev&&(0,n.addRequestMeta)(e,"devRequestTimingInternalsEnd",process.hrtime.bigint());let R="/api/kanban/route";R=R.replace(/\/index$/,"")||"/";let y=await I.prepare(e,t,{srcPage:R,multiZoneDraftMode:!1});if(!y)return t.statusCode=400,t.end("Bad Request"),null==r.waitUntil||r.waitUntil.call(r,Promise.resolve()),null;let{buildId:v,params:b,nextConfig:E,parsedUrl:x,isDraftMode:k,prerenderManifest:O,routerServerContext:C,isOnDemandRevalidate:N,revalidateOnlyGenerated:S,resolvedPathname:j,clientReferenceManifest:_,serverActionsManifest:P}=y,A=(0,s.normalizeAppPath)(R),T=!!(O.dynamicRoutes[A]||O.routes[j]),D=async()=>((null==C?void 0:C.render404)?await C.render404(e,t,x,!1):t.end("This page could not be found"),null);if(T&&!k){let e=!!O.routes[j],t=O.dynamicRoutes[A];if(t&&!1===t.fallback&&!e){if(E.experimental.adapterPath)return await D();throw new m.NoFallbackError}}let F=null;!T||I.isDev||k||(F="/index"===(F=j)?"/":F);let U=!0===I.isDev||!T,H=T&&!U;P&&_&&(0,o.setManifestsSingleton)({page:R,clientReferenceManifest:_,serverActionsManifest:P});let $=e.method||"GET",q=(0,i.getTracer)(),M=q.getActiveScopeSpan(),B={params:b,prerenderManifest:O,renderOpts:{experimental:{authInterrupts:!!E.experimental.authInterrupts},cacheComponents:!!E.cacheComponents,supportsDynamicResponse:U,incrementalCache:(0,n.getRequestMeta)(e,"incrementalCache"),cacheLifeProfiles:E.cacheLife,waitUntil:r.waitUntil,onClose:e=>{t.on("close",e)},onAfterTaskError:void 0,onInstrumentationRequestError:(t,a,r,n)=>I.onRequestError(e,t,r,n,C)},sharedContext:{buildId:v}},K=new l.NodeNextRequest(e),L=new l.NodeNextResponse(t),J=d.NextRequestAdapter.fromNodeNextRequest(K,(0,d.signalFromNodeResponse)(t));try{let o=async e=>I.handle(J,B).finally(()=>{if(!e)return;e.setAttributes({"http.status_code":t.statusCode,"next.rsc":!1});let a=q.getRootSpanAttributes();if(!a)return;if(a.get("next.span_type")!==u.BaseServerSpan.handleRequest)return void console.warn(`Unexpected root span type '${a.get("next.span_type")}'. Please report this Next.js issue https://github.com/vercel/next.js`);let r=a.get("next.route");if(r){let t=`${$} ${r}`;e.setAttributes({"next.route":r,"http.route":r,"next.span_name":t}),e.updateName(t)}else e.updateName(`${$} ${R}`)}),s=!!(0,n.getRequestMeta)(e,"minimalMode"),l=async n=>{var i,l;let d=async({previousCacheEntry:a})=>{try{if(!s&&N&&S&&!a)return t.statusCode=404,t.setHeader("x-nextjs-cache","REVALIDATED"),t.end("This page could not be found"),null;let i=await o(n);e.fetchMetrics=B.renderOpts.fetchMetrics;let l=B.renderOpts.pendingWaitUntil;l&&r.waitUntil&&(r.waitUntil(l),l=void 0);let d=B.renderOpts.collectedTags;if(!T)return await (0,p.sendResponse)(K,L,i,B.renderOpts.pendingWaitUntil),null;{let e=await i.blob(),t=(0,f.toNodeOutgoingHttpHeaders)(i.headers);d&&(t[h.NEXT_CACHE_TAGS_HEADER]=d),!t["content-type"]&&e.type&&(t["content-type"]=e.type);let a=void 0!==B.renderOpts.collectedRevalidate&&!(B.renderOpts.collectedRevalidate>=h.INFINITE_CACHE)&&B.renderOpts.collectedRevalidate,r=void 0===B.renderOpts.collectedExpire||B.renderOpts.collectedExpire>=h.INFINITE_CACHE?void 0:B.renderOpts.collectedExpire;return{value:{kind:w.CachedRouteKind.APP_ROUTE,status:i.status,body:Buffer.from(await e.arrayBuffer()),headers:t},cacheControl:{revalidate:a,expire:r}}}}catch(t){throw(null==a?void 0:a.isStale)&&await I.onRequestError(e,t,{routerKind:"App Router",routePath:R,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:N})},!1,C),t}},u=await I.handleResponse({req:e,nextConfig:E,cacheKey:F,routeKind:a.RouteKind.APP_ROUTE,isFallback:!1,prerenderManifest:O,isRoutePPREnabled:!1,isOnDemandRevalidate:N,revalidateOnlyGenerated:S,responseGenerator:d,waitUntil:r.waitUntil,isMinimalMode:s});if(!T)return null;if((null==u||null==(i=u.value)?void 0:i.kind)!==w.CachedRouteKind.APP_ROUTE)throw Object.defineProperty(Error(`Invariant: app-route received invalid cache entry ${null==u||null==(l=u.value)?void 0:l.kind}`),"__NEXT_ERROR_CODE",{value:"E701",enumerable:!1,configurable:!0});s||t.setHeader("x-nextjs-cache",N?"REVALIDATED":u.isMiss?"MISS":u.isStale?"STALE":"HIT"),k&&t.setHeader("Cache-Control","private, no-cache, no-store, max-age=0, must-revalidate");let m=(0,f.fromNodeOutgoingHttpHeaders)(u.value.headers);return s&&T||m.delete(h.NEXT_CACHE_TAGS_HEADER),!u.cacheControl||t.getHeader("Cache-Control")||m.get("Cache-Control")||m.set("Cache-Control",(0,g.getCacheControlHeader)(u.cacheControl)),await (0,p.sendResponse)(K,L,new Response(u.value.body,{headers:m,status:u.value.status||200})),null};M?await l(M):await q.withPropagatedContext(e.headers,()=>q.trace(u.BaseServerSpan.handleRequest,{spanName:`${$} ${R}`,kind:i.SpanKind.SERVER,attributes:{"http.method":$,"http.target":e.url}},l))}catch(t){if(t instanceof m.NoFallbackError||await I.onRequestError(e,t,{routerKind:"App Router",routePath:A,routeType:"route",revalidateReason:(0,c.getRevalidateReason)({isStaticGeneration:H,isOnDemandRevalidate:N})},!1,C),T)throw t;return await (0,p.sendResponse)(K,L,new Response(null,{status:500})),null}}e.s(["handler",()=>$,"patchFetch",()=>H,"routeModule",()=>I,"serverHooks",()=>U,"workAsyncStorage",()=>D,"workUnitAsyncStorage",()=>F],69497)}];
2
2
 
3
3
  //# sourceMappingURL=node_modules_next_dist_esm_build_templates_app-route_18324462.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[23322,e=>{"use strict";async function s(){{let{startScheduler:s}=await e.A(30177);s()}}e.s(["register",()=>s])},30177,e=>{e.v(s=>Promise.all(["server/chunks/[externals]__c6831f39._.js","server/chunks/src_lib_scheduler_ts_03988e3e._.js"].map(s=>e.l(s))).then(()=>s(92739)))}];
1
+ module.exports=[23322,e=>{"use strict";async function s(){{let{startScheduler:s}=await e.A(30177);s()}}e.s(["register",()=>s])},30177,e=>{e.v(s=>Promise.all(["server/chunks/[externals]__78e522ea._.js","server/chunks/src_lib_scheduler_ts_03988e3e._.js"].map(s=>e.l(s))).then(()=>s(92739)))}];
2
2
 
3
3
  //# sourceMappingURL=src_677020aa._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[92739,t=>{"use strict";var e=t.i(22734),r=t.i(14747),i=t.i(46786);function s(t){return Date.UTC(t.y,t.m-1,t.d,t.h,t.i,t.s)}function a(t,e){return t.y===e.y&&t.m===e.m&&t.d===e.d&&t.h===e.h&&t.i===e.i&&t.s===e.s}function n(t,e,r){return o(function(t,e){let r=new Date(Date.parse(t));if(isNaN(r))throw Error("Invalid ISO8601 passed to timezone parser.");let i=t.substring(9);return i.includes("Z")||i.includes("+")||i.includes("-")?l(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),"Etc/UTC"):l(r.getFullYear(),r.getMonth()+1,r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),e)}(t,e),r)}function o(t,e){let r=new Date(s(t)),i=h(r,t.tz),n=s(t),o=s(i),l=new Date(r.getTime()+(n-o)),u=h(l,t.tz);if(a(u,t)){let e=new Date(l.getTime()-36e5);return a(h(e,t.tz),t)?e:l}let d=new Date(l.getTime()+s(t)-s(u));if(a(h(d,t.tz),t))return d;if(e)throw Error("Invalid date passed to fromTZ()");return l.getTime()>d.getTime()?l:d}function h(t,e){let r;try{r=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(t)}catch(r){let t=r instanceof Error?r.message:String(r);throw RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${t}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let t of r)("year"===t.type||"month"===t.type||"day"===t.type||"hour"===t.type||"minute"===t.type||"second"===t.type)&&(i[t.type]=parseInt(t.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return 24===i.hour&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function l(t,e,r,i,s,a,n){return{y:t,m:e,d:r,h:i,i:s,s:a,tz:n}}var u=[1,2,4,8,16],d=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(t,e,r){this.pattern=t,this.timezone=e,this.mode=r?.mode??"auto",this.alternativeWeekdays=r?.alternativeWeekdays??!1,this.sloppyRanges=r?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!("string"==typeof this.pattern||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let t=this.pattern.match(/\S+/g)||[""],e=t.length;if(t.length<5||t.length>7)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if("auto"!==this.mode){let t;switch(this.mode){case"5-part":t=5;break;case"6-part":t=6;break;case"7-part":t=7;break;case"5-or-6-parts":t=[5,6];break;case"6-or-7-parts":t=[6,7];break;default:t=0}if(!(Array.isArray(t)?t.includes(e):e===t)){let r=Array.isArray(t)?t.join(" or "):t.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${r} parts, but pattern '${this.pattern}' has ${e} parts.`)}}if(5===t.length&&t.unshift("0"),6===t.length&&t.push("*"),"LW"===t[3].toUpperCase()?(this.lastWeekday=!0,t[3]=""):t[3].toUpperCase().indexOf("L")>=0&&(t[3]=t[3].replace(/L/gi,""),this.lastDayOfMonth=!0),"*"==t[3]&&(this.starDOM=!0),"*"==t[6]&&(this.starYear=!0),t[4].length>=3&&(t[4]=this.replaceAlphaMonths(t[4])),t[5].length>=3&&(t[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(t[5]):this.replaceAlphaDays(t[5])),t[5].startsWith("+")&&(this.useAndLogic=!0,t[5]=t[5].substring(1),""===t[5]))throw TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch("*"==t[5]&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(t[0]=t[0].replace(/\?/g,"*"),t[1]=t[1].replace(/\?/g,"*"),t[2]=t[2].replace(/\?/g,"*"),t[3]=t[3].replace(/\?/g,"*"),t[4]=t[4].replace(/\?/g,"*"),t[5]=t[5].replace(/\?/g,"*"),t[6]&&(t[6]=t[6].replace(/\?/g,"*"))),this.mode){case"5-part":t[0]="0",t[6]="*";break;case"6-part":case"5-or-6-parts":t[6]="*"}this.throwAtIllegalCharacters(t),this.partToArray("second",t[0],0,1),this.partToArray("minute",t[1],0,1),this.partToArray("hour",t[2],0,1),this.partToArray("day",t[3],-1,1),this.partToArray("month",t[4],-1,1);let r=this.alternativeWeekdays?-1:0;this.partToArray("dayOfWeek",t[5],r,63),this.partToArray("year",t[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(t,e,r,i){let s=this[t],a="day"===t&&this.lastDayOfMonth,n="day"===t&&this.lastWeekday;if(""===e&&!a&&!n)throw TypeError("CronPattern: configuration entry "+t+" ("+e+") is empty, check for trailing spaces.");if("*"===e)return s.fill(i);let o=e.split(",");if(o.length>1)for(let e=0;e<o.length;e++)this.partToArray(t,o[e],r,i);else -1!==e.indexOf("-")&&-1!==e.indexOf("/")?this.handleRangeWithStepping(e,t,r,i):-1!==e.indexOf("-")?this.handleRange(e,t,r,i):-1!==e.indexOf("/")?this.handleStepping(e,t,r,i):""!==e&&this.handleNumber(e,t,r,i)}throwAtIllegalCharacters(t){for(let e=0;e<t.length;e++)if((3===e?/[^/*0-9,\-WwLl]+/:5===e?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(t[e]))throw TypeError("CronPattern: configuration entry "+e+" ("+t[e]+") contains illegal characters.")}handleNumber(t,e,r,i){let s=this.extractNth(t,e),a=t.toUpperCase().includes("W");if("day"!==e&&a)throw TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(e="nearestWeekdays");let n=parseInt(s[0],10)+r;if(isNaN(n))throw TypeError("CronPattern: "+e+" is not a number: '"+t+"'");this.setPart(e,n,s[1]||i)}setPart(t,e,r){if(!Object.prototype.hasOwnProperty.call(this,t))throw TypeError("CronPattern: Invalid part specified: "+t);if("dayOfWeek"===t){if(7===e&&(e=0),e<0||e>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+e);this.setNthWeekdayOfMonth(e,r);return}if("second"===t||"minute"===t){if(e<0||e>=60)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("hour"===t){if(e<0||e>=24)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("day"===t||"nearestWeekdays"===t){if(e<0||e>=31)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("month"===t){if(e<0||e>=12)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("year"===t&&(e<1||e>=1e4))throw RangeError("CronPattern: Invalid value for "+t+": "+e+" (supported range: 1-9999)");this[t][e]=r}validateNotNaN(t,e){if(isNaN(t))throw TypeError(e)}validateRange(t,e,r,i,s){if(t>e)throw TypeError("CronPattern: From value is larger than to value: '"+s+"'");if(void 0!==r){if(0===r)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(r>this[i].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[i].length+")")}}handleRangeWithStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(t,e),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(null===a)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+t+"'");let[,n,o,h]=a,l=parseInt(n,10)+r,u=parseInt(o,10)+r,d=parseInt(h,10);this.validateNotNaN(l,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(u,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateNotNaN(d,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(l,u,d,e,t);for(let t=l;t<=u;t+=d)this.setPart(e,t,s[1]||i)}extractNth(t,e){let r=t,i;if(r.includes("#")){if("dayOfWeek"!==e)throw Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if("dayOfWeek"!==e)throw Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(t,e),a=s[0].split("-");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal range: '"+t+"'");let n=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;this.validateNotNaN(n,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(o,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateRange(n,o,void 0,e,t);for(let t=n;t<=o;t++)this.setPart(e,t,s[1]||i)}handleStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(t,e),a=s[0].split("/");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+t+"'");if(this.sloppyRanges)""===a[0]&&(a[0]="*");else{if(""===a[0])throw TypeError("CronPattern: Syntax error, stepping with missing prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");if("*"!==a[0])throw TypeError("CronPattern: Syntax error, stepping with numeric prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.")}let n=0;"*"!==a[0]&&(n=parseInt(a[0],10)+r);let o=parseInt(a[1],10);this.validateNotNaN(o,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(0,this[e].length-1,o,e,t);for(let t=n;t<this[e].length;t+=o)this.setPart(e,t,s[1]||i)}replaceAlphaDays(t){return t.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaDaysQuartz(t){return t.replace(/sun/gi,"1").replace(/mon/gi,"2").replace(/tue/gi,"3").replace(/wed/gi,"4").replace(/thu/gi,"5").replace(/fri/gi,"6").replace(/sat/gi,"7")}replaceAlphaMonths(t){return t.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(t){let e=t.trim().toLowerCase();if("@yearly"===e||"@annually"===e)return"0 0 1 1 *";if("@monthly"===e)return"0 0 1 * *";if("@weekly"===e)return"0 0 * * 0";if("@daily"===e||"@midnight"===e)return"0 0 * * *";if("@hourly"===e)return"0 * * * *";if("@reboot"===e)throw TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return t}setNthWeekdayOfMonth(t,e){if("number"!=typeof e&&"L"===e.toUpperCase())this.dayOfWeek[t]=32|this.dayOfWeek[t];else if(63===e)this.dayOfWeek[t]=63;else if(e<6&&e>0)this.dayOfWeek[t]=this.dayOfWeek[t]|u[e-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${e}, Type: ${typeof e}`)}},c=[31,28,31,30,31,30,31,31,30,31,30,31],f=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],p=class t{tz;ms;second;minute;hour;day;month;year;constructor(e,r){if(this.tz=r,e&&e instanceof Date)if(isNaN(e))throw TypeError("CronDate: Invalid date passed to CronDate constructor");else this.fromDate(e);else if(null==e)this.fromDate(new Date);else if(e&&"string"==typeof e)this.fromString(e);else if(e instanceof t)this.fromCronDate(e);else throw TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getLastDayOfMonth(t,e){return 1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate()}getLastWeekday(t,e){let r=this.getLastDayOfMonth(t,e),i=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===i?r-2:6===i?r-1:r}getNearestWeekday(t,e,r){let i=this.getLastDayOfMonth(t,e);if(r>i)return -1;let s=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===s?r===i?r-2:r+1:6===s?1===r?r+2:r-1:r}isNthWeekdayOfMonth(t,e,r,i){let s=new Date(Date.UTC(t,e,r)).getUTCDay(),a=0;for(let i=1;i<=r;i++)new Date(Date.UTC(t,e,i)).getUTCDay()===s&&a++;if(63&i&&u[a-1]&i)return!0;if(32&i){let i=this.getLastDayOfMonth(t,e);for(let a=r+1;a<=i;a++)if(new Date(Date.UTC(t,e,a)).getUTCDay()===s)return!1;return!0}return!1}fromDate(t){if(void 0!==this.tz)if("number"==typeof this.tz)this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes()+this.tz,this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply();else try{let e=h(t,this.tz);this.ms=t.getMilliseconds(),this.second=e.s,this.minute=e.i,this.hour=e.h,this.day=e.d,this.month=e.m-1,this.year=e.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}else this.ms=t.getMilliseconds(),this.second=t.getSeconds(),this.minute=t.getMinutes(),this.hour=t.getHours(),this.day=t.getDate(),this.month=t.getMonth(),this.year=t.getFullYear()}fromCronDate(t){this.tz=t.tz,this.year=t.year,this.month=t.month,this.day=t.day,this.hour=t.hour,this.minute=t.minute,this.second=t.second,this.ms=t.ms}apply(){if(!(this.month>11)&&!(this.month<0)&&!(this.day>c[this.month])&&!(this.day<1)&&!(this.hour>59)&&!(this.minute>59)&&!(this.second>59)&&!(this.hour<0)&&!(this.minute<0)&&!(this.second<0))return!1;{let t=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),!0}}fromString(t){if("number"!=typeof this.tz)return this.fromDate(n(t,this.tz));{let e=n(t);this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply()}}findNext(t,e,r,i){return this._findMatch(t,e,r,i,1)}_findMatch(t,e,r,i,s){let a=this[e],n;r.lastDayOfMonth&&(n=this.getLastDayOfMonth(this.year,this.month));let o=r.starDOW||"day"!=e?void 0:new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),h=this[e]+i,l=1===s?t=>t<r[e].length:t=>t>=0;for(let u=h;l(u);u+=s){let s=r[e][u];if("day"===e&&!s){for(let t=0;t<r.nearestWeekdays.length;t++)if(r.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(-1===e)continue;if(e===u-i){s=1;break}}}if("day"===e&&r.lastWeekday&&u-i===this.getLastWeekday(this.year,this.month)&&(s=1),"day"===e&&r.lastDayOfMonth&&u-i==n&&(s=1),"day"===e&&!r.starDOW){let e=r.dayOfWeek[(o+(u-i-1))%7];if(e&&63&e)e=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-i,e);else if(e)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${e}`);s=r.useAndLogic||t.domAndDow||r.starDOM?s&&e:s||e}if(s)return this[e]=u-i,a!==this[e]?2:1}return 3}recurse(t,e,r){if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year+1;r<t.year.length&&r<1e4;r++)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(e,f[r][0],t,f[r][2]);if(i>1){let s=r+1;for(;s<f.length;)this[f[s][0]]=-f[s][2],s++;if(3===i){if(this[f[r][1]]++,this[f[r][0]]=-f[r][2],this.apply(),0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year]&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=t.year.length)return null}return this.recurse(t,e,0)}if(this.apply())return this.recurse(t,e,r-1)}return(r+=1)>=f.length?this:(t.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(t,e,r)}increment(t,e,r){return this.second+=void 0!==e.interval&&e.interval>1&&r?e.interval:1,this.ms=0,this.apply(),this.recurse(t,e,0)}decrement(t,e){return this.second-=void 0!==e.interval&&e.interval>1?e.interval:1,this.ms=0,this.apply(),this.recurseBackward(t,e,0,0)}recurseBackward(t,e,r,i=0){if(i>1e4)return null;if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year-1;r>=0;r--)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let s=this.findPrevious(e,f[r][0],t,f[r][2]);if(s>1){let a=r+1;for(;a<f.length;){let e=f[a][0],r=f[a][2],i=this.getMaxPatternValue(e,t,r);this[e]=i,a++}if(3===s){if(this[f[r][1]]--,0===r){let t=this.getLastDayOfMonth(this.year,this.month);this.day>t&&(this.day=t)}if(1===r)if(this.day<=0)this.day=1;else{let t=this.year,e=this.month;for(;e<0;)e+=12,t--;for(;e>11;)e-=12,t++;let r=1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate();this.day>r&&(this.day=r)}this.apply();let s=f[r][0],a=f[r][2],n=this.getMaxPatternValue(s,t,a);if("day"===s){let t=this.getLastDayOfMonth(this.year,this.month);this[s]=Math.min(n,t)}else this[s]=n;if(this.apply(),0===r){let e=f[1][2],r=Math.min(this.getMaxPatternValue("day",t,e),this.getLastDayOfMonth(this.year,this.month));r!==this.day&&(this.day=r,this.hour=this.getMaxPatternValue("hour",t,f[2][2]),this.minute=this.getMaxPatternValue("minute",t,f[3][2]),this.second=this.getMaxPatternValue("second",t,f[4][2]))}if(0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year];)this.year--;if(this.year<0)return null}return this.recurseBackward(t,e,0,i+1)}if(this.apply())return this.recurseBackward(t,e,r-1,i+1)}return(r+=1)>=f.length?this:this.year<0?null:this.recurseBackward(t,e,r,i+1)}getMaxPatternValue(t,e,r){if("day"===t&&e.lastDayOfMonth||"day"===t&&!e.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let i=e[t].length-1;i>=0;i--)if(e[t][i])return i-r;return e[t].length-1-r}findPrevious(t,e,r,i){return this._findMatch(t,e,r,i,-1)}getDate(t){return t||void 0===this.tz?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):"number"==typeof this.tz?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):o(l(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(t,e){if(!t.starYear&&(this.year<0||this.year>=t.year.length||0===t.year[this.year]))return!1;for(let r=0;r<f.length;r++){let i=f[r][0],s=f[r][2],a=this[i];if(a+s<0||a+s>=t[i].length)return!1;let n=t[i][a+s];if("day"===i){if(!n){for(let e=0;e<t.nearestWeekdays.length;e++)if(t.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-s);if(-1!==t&&t===a){n=1;break}}}if(t.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(n=1),t.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(n=1),!t.starDOW){let r=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),i=t.dayOfWeek[(r+(a-1))%7];i&&63&i&&(i=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,i)),n=t.useAndLogic||e.domAndDow||t.starDOM?n&&i:n||i}}if(!n)return!1}return!0}};function y(t){return"[object Function]"===Object.prototype.toString.call(t)||"function"==typeof t||t instanceof Function}var g=[],m=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(t){if(void 0!==this.options.dayOffset&&0!==this.options.dayOffset){let e=24*this.options.dayOffset*36e5;return new Date(t.getTime()+e)}return t}constructor(t,e,r){let i,s;if(y(e))s=e;else if("object"==typeof e)i=e;else if(void 0!==e)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))s=r;else if("object"==typeof r)i=r;else if(void 0!==r)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=function(t){if(void 0===t&&(t={}),delete t.name,void 0!==t.legacyMode&&void 0===t.domAndDow?t.domAndDow=!t.legacyMode:void 0===t.domAndDow&&(t.domAndDow=!1),t.legacyMode=!t.domAndDow,t.paused=void 0!==t.paused&&t.paused,t.maxRuns=void 0===t.maxRuns?1/0:t.maxRuns,t.catch=void 0!==t.catch&&t.catch,t.interval=void 0===t.interval?0:parseInt(t.interval.toString(),10),t.utcOffset=void 0===t.utcOffset?void 0:parseInt(t.utcOffset.toString(),10),t.dayOffset=void 0===t.dayOffset?0:parseInt(t.dayOffset.toString(),10),t.unref=void 0!==t.unref&&t.unref,t.mode=void 0===t.mode?"auto":t.mode,t.alternativeWeekdays=void 0!==t.alternativeWeekdays&&t.alternativeWeekdays,t.sloppyRanges=void 0!==t.sloppyRanges&&t.sloppyRanges,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(t.mode))throw Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(t.startAt&&(t.startAt=new p(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new p(t.stopAt,t.timezone)),null!==t.interval){if(isNaN(t.interval))throw Error("CronOptions: Supplied value for interval is not a number");if(t.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if(void 0!==t.utcOffset){if(isNaN(t.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(t.utcOffset<-870||t.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if(void 0!==t.utcOffset&&t.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(!0!==t.unref&&!1!==t.unref)throw Error("CronOptions: Unref should be either true, false or undefined(false).");if(void 0!==t.dayOffset&&0!==t.dayOffset&&isNaN(t.dayOffset))throw Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return t}(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:!!i&&i.paused,pattern:new d("* * * * *",void 0,{mode:"auto"})},t&&(t instanceof Date||"string"==typeof t&&t.indexOf(":")>0)?this._states.once=new p(t,this.getTz()):this._states.pattern=new d(t,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(g.find(t=>t.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");g.push(this)}return void 0!==s&&function(t){return y(t)}(s)&&(this.fn=s,this.schedule()),this}nextRun(t){let e=this._next(t);return e?this.applyDayOffset(e.getDate(!1)):null}nextRuns(t,e){void 0!==this._states.maxRuns&&t>this._states.maxRuns&&(t=this._states.maxRuns);let r=e||this._states.currentRun||void 0;return this._enumerateRuns(t,r,"next")}previousRuns(t,e){return this._enumerateRuns(t,e||void 0,"previous")}_enumerateRuns(t,e,r){let i=[],s=e?new p(e,this.getTz()):null,a="next"===r?this._next:this._previous;for(;t--;){let t=a.call(this,s);if(!t)break;let e=t.getDate(!1);i.push(this.applyDayOffset(e)),s=t}return i}match(t){if(this._states.once){let e=new p(t,this.getTz());e.ms=0;let r=new p(this._states.once,this.getTz());return r.ms=0,e.getTime()===r.getTime()}let e=new p(t,this.getTz());return e.ms=0,e.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let t=this.nextRun(this._states.currentRun),e=!this._states.paused,r=void 0!==this.fn,i=!this._states.kill;return e&&r&&i&&null!==t}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(t){let e=this._next(t);return e?t instanceof p||t instanceof Date?e.getTime()-t.getTime():e.getTime()-new p(t).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let t=g.indexOf(this);t>=0&&g.splice(t,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(t){var e;if(t&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");t&&(this.fn=t);let r=this.msToNext(),i=this.nextRun(this._states.currentRun);return null==r||isNaN(r)||null===i||(r>3e4&&(r=3e4),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(i),r),this._states.currentTimeout&&this.options.unref&&(e=this._states.currentTimeout,"u">typeof Deno&&"u">typeof Deno.unrefTimer?Deno.unrefTimer(e):e&&"u">typeof e.unref&&e.unref())),this}async _trigger(t){this._states.blocking=!0,this._states.currentRun=new p(void 0,this.getTz());try{if(this.options.catch)try{void 0!==this.fn&&await this.fn(this,this.options.context)}catch(t){if(y(this.options.catch))try{this.options.catch(t,this)}catch{}}else void 0!==this.fn&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new p(t,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(t){let e=new Date,r=!this._states.paused&&e.getTime()>=t.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(void 0!==this._states.maxRuns&&this._states.maxRuns--,this._trigger()):r&&i&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(t){let e=!!(t||this._states.currentRun),r=!1;!t&&this.options.startAt&&this.options.interval&&([t,e]=this._calculatePreviousRun(t,e),r=!t),t=new p(t,this.getTz()),this.options.startAt&&t&&t.getTime()<this.options.startAt.getTime()&&(t=this.options.startAt);let i=this._states.once||new p(t,this.getTz());return r||i===this._states.once||(i=i.increment(this._states.pattern,this.options,e)),this._states.once&&this._states.once.getTime()<=t.getTime()||null===i||void 0!==this._states.maxRuns&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_previous(t){let e=new p(t,this.getTz());this.options.stopAt&&e.getTime()>this.options.stopAt.getTime()&&(e=this.options.stopAt);let r=new p(e,this.getTz());return this._states.once?this._states.once.getTime()<e.getTime()?this._states.once:null:null===(r=r.decrement(this._states.pattern,this.options))||this.options.startAt&&r.getTime()<this.options.startAt.getTime()?null:r}_calculatePreviousRun(t,e){let r=new p(void 0,this.getTz()),i=t;if(this.options.startAt.getTime()<=r.getTime()){let t=(i=this.options.startAt).getTime()+1e3*this.options.interval;for(;t<=r.getTime();)t=(i=new p(i,this.getTz()).increment(this._states.pattern,this.options,!0)).getTime()+1e3*this.options.interval;e=!0}return null===i&&(i=void 0),[i,e]}};function w(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let t=process.cwd();return(console.warn("[paths] SLYCODE_HOME not set in production — falling back to cwd:",t),t.endsWith("/web")||t.endsWith("\\web"))?r.default.dirname(t):t}t.i(33405),t.i(54799);let T=w();r.default.basename(T),r.default.join(w(),"store",".ignored-updates.json");let v=function(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let t=process.cwd();return t.endsWith("/web")||t.endsWith("\\web")?r.default.dirname(t):t}(),C=r.default.join(v,"projects","registry.json");async function D(){try{let t=await e.promises.readFile(C,"utf-8");return JSON.parse(t)}catch(t){throw console.error("Failed to load registry:",t),Error(`Failed to load registry from ${C}`)}}let O=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];!function(){try{let t=r.default.join(w(),".env");for(let r of(0,e.readFileSync)(t,"utf-8").split("\n")){let t=r.trim();if(!t||t.startsWith("#"))continue;let e=t.indexOf("=");if(e<0)continue;let i=t.slice(0,e).trim(),s=t.slice(e+1).trim();process.env[i]||(process.env[i]=s)}}catch{}}();let k=process.env.BRIDGE_URL?process.env.BRIDGE_URL:"http://127.0.0.1:3004",S=process.env.TZ||"UTC",N=r.default.join(i.default.homedir(),".slycode","logs","automation.log");async function $(t,e){let r=new AbortController,i=setTimeout(()=>r.abort(),1e4);try{return await fetch(t,{...e,signal:r.signal})}finally{clearTimeout(i)}}async function x(t){try{let i=r.default.dirname(N);await e.promises.mkdir(i,{recursive:!0});let s=JSON.stringify(t)+"\n";await e.promises.appendFile(N,s);try{if((await e.promises.stat(N)).size>1e6){let t=(await e.promises.readFile(N,"utf-8")).trim().split("\n"),r=t.slice(Math.floor(t.length/2));await e.promises.writeFile(N,r.join("\n")+"\n")}}catch{}}catch(t){console.error("[scheduler] Failed to write automation log:",t)}}async function _(t){await new Promise(t=>setTimeout(t,2e4));try{let e=await $(`${k}/sessions/${encodeURIComponent(t)}`);if(!e.ok)return{status:"unknown"};let r=await e.json();if("stopped"===r.status)return{status:"stopped",exitCode:r.exitCode,exitedAt:r.exitedAt};if("running"===r.status||"detached"===r.status)return{status:"running"};return{status:"unknown"}}catch{return{status:"unknown"}}}function A(){try{let t=new Intl.DateTimeFormat("en-US",{timeZone:S,timeZoneName:"short"}).formatToParts(new Date),e=t.find(t=>"timeZoneName"===t.type)?.value||S;return{timezone:S,abbreviation:e}}catch{return{timezone:"UTC",abbreviation:"UTC"}}}let b="__scheduler_state__",R="__scheduler_timer__",U=globalThis;U[b]||(U[b]={running:!1,lastCheck:null,activeKickoffs:new Set}),void 0===U[R]&&(U[R]=null);let W=U[b];function M(){return U[R]??null}function E(t,e){if("one-shot"===e){let e=new Date(t);return isNaN(e.getTime())?null:e}try{return new m(t,{timezone:S}).nextRun()}catch{return null}}async function P(t){await new Promise(t=>setTimeout(t,1e4));let e=0;try{let r=await $(`${k}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;e=i.lastOutputAt?new Date(i.lastOutputAt).getTime():0}catch{return!1}await new Promise(t=>setTimeout(t,5e3));try{let r=await $(`${k}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;return(i.lastOutputAt?new Date(i.lastOutputAt).getTime():0)>e}catch{return!1}}function I(t){let e=t.toLocaleDateString("en-US",{weekday:"long",timeZone:S}),r=new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:S}).format(t),i=t.toLocaleDateString("en-US",{month:"short",timeZone:S}),s=new Intl.DateTimeFormat("en-US",{year:"numeric",timeZone:S}).format(t),a=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:S}),{abbreviation:n}=A();return`${e}, ${r} ${i} ${s}, ${a} ${n}`}async function z(t,e,r,i={trigger:"scheduled"}){let s=t.automation;if(!s)return{cardId:t.id,projectId:e,success:!1,error:"No automation config"};let a=s.provider||"claude",n=`${e}:${a}:card:${t.id}`,o=s.workingDirectory||r,h=[function(t,e,r){let i=new Date,s=["=== AUTOMATION RUN ==="];if(s.push(`Time: ${I(i)}`),s.push(`Card: ${t.title} (${t.id})`),"manual"===r)s.push("Trigger: manual");else{let t=function(t,e,r="Not set",i){if("one-shot"===e)try{let e=new Date(t);if(isNaN(e.getTime()))return t||r;return`Once on ${e.toLocaleDateString()} at ${e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}catch{return t||r}if(!t)return r;let s=t.split(" ");if(5!==s.length)return t;let[a,n,o,,h]=s,l=n.match(/^(\d+)-(\d+)\/(\d+)$/);if(l&&"*"===o&&"*"===h){let[,t,e,r]=l;return`Every ${r}h from ${t.padStart(2,"0")}:${a.padStart(2,"0")} to ${e.padStart(2,"0")}:${a.padStart(2,"0")}`}if(n.includes(",")&&"*"===o&&"*"===h){let t=n.split(",").map(Number);if(t.length>=2){let e=(t[1]-t[0]+24)%24;if(e>0){let r=String(t[0]).padStart(2,"0"),i=String(t[t.length-1]).padStart(2,"0");return`Every ${e}h from ${r}:${a.padStart(2,"0")} to ${i}:${a.padStart(2,"0")}`}}}if("*"===n&&"*"===o&&"*"===h)return`Every hour at :${a.padStart(2,"0")}`;if("*"===o&&"*"===h)return`Daily at ${n}:${a.padStart(2,"0")}`;if("*"===o&&"*"!==h){let t=h.split(",").map(t=>O[parseInt(t)]||t).join(", ");return`Weekly on ${t} at ${n}:${a.padStart(2,"0")}`}return"*"!==o&&"*"===h?`Monthly on day ${o} at ${n}:${a.padStart(2,"0")}`:t}(e.schedule,e.scheduleType);s.push(`Trigger: scheduled (${t.toLowerCase()})`)}if(e.lastRun){let t=new Date(e.lastRun);s.push(`Last run: ${I(t)} (${function(t,e){let r=e.getTime()-t.getTime();if(r<0)return"in the future";let i=Math.floor(r/6e4),s=Math.floor(i/60),a=Math.floor(s/24);return a>0?`${a}d ${s%24}h ago`:s>0?`${s}h ${i%60}m ago`:i>0?`${i}m ago`:"just now"}(t,i)})`)}else s.push("Last run: never");return s.push("======================"),s.join("\n")}(t,s,i.trigger),""];if(t.areas.length>0&&h.push(`Areas: ${t.areas.join(", ")}`),t.tags.length>0&&h.push(`Tags: ${t.tags.join(", ")}`),t.checklist.length>0){let e=t.checklist.filter(t=>!t.done);e.length>0&&h.push(`Pending checklist: ${e.map(t=>t.text).join("; ")}`)}h.push("","---","",t.description);let l=h.join("\n");s.reportViaMessaging&&(l+='\n\nAfter completing the task, send a summary of the results using the messaging skill: sly-messaging send "<your summary>"');let u=s.freshSession||!1,d=Date.now(),c=null,f=null,p=async r=>(await x({timestamp:new Date().toISOString(),cardId:t.id,cardTitle:t.title,projectId:e,trigger:i.trigger,provider:a,sessionName:n,fresh:u,bridgeRequest:c,livenessCheck:f,outcome:r.success?"success":"error",error:r.error||null,elapsedMs:Date.now()-d}),r);try{console.log(`[scheduler] Creating session: ${n} (fresh: ${u}, provider: ${a})`);let r=await $(`${k}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,provider:a,skipPermissions:!0,cwd:o,prompt:l,fresh:u})});if(r.ok||409!==r.status||u)if(r.ok){let t=await r.json();c={status:r.status,resumed:t.resumed,pid:t.pid},console.log(`[scheduler] Session created: ${n} (status: ${t.status}, resumed: ${t.resumed}, pid: ${t.pid})`)}else{let i;try{let t=await r.json();i=t.error||JSON.stringify(t)}catch{i=await r.text()}return c={status:r.status,error:i},p({cardId:t.id,projectId:e,success:!1,error:`Session create failed (${r.status}): ${i}`})}else{c={status:409},console.log(`[scheduler] Session ${n} returned 409, sending prompt via input endpoint`);let r=await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l})});if(r.ok&&(await new Promise(t=>setTimeout(t,600)),await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})})),!r.ok){let i=await r.text();return p({cardId:t.id,projectId:e,success:!1,error:`Input failed (${r.status}): ${i}`})}}if(u){let r=await _(n);if(f={type:"checkSessionAlive",result:r.status,delayMs:2e4,exitCode:r.exitCode,exitedAt:r.exitedAt},"stopped"===r.status){if(0===r.exitCode)return p({cardId:t.id,projectId:e,success:!0,sessionName:n});let i=void 0!==r.exitCode?` (exit code ${r.exitCode})`:"",s=r.exitedAt?`, alive ${((new Date(r.exitedAt).getTime()-d)/1e3).toFixed(1)}s`:"";return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:`Session stopped during startup${i}${s}`})}return p({cardId:t.id,projectId:e,success:!0,sessionName:n})}if(await P(n))return f={type:"waitForActivity",result:"active"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});console.log(`[scheduler] No activity for ${t.id} (resume path), retrying via input...`),await new Promise(t=>setTimeout(t,3e3));let i=`\x1b[200~${l}\x1b[201~`;if((await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:i})})).ok&&(await new Promise(t=>setTimeout(t,600)),await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})}),await P(n)))return f={type:"waitForActivity",result:"active (retry)"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});return f={type:"waitForActivity",result:"inactive after retry"},p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:"No activity detected after retry"})}catch(r){return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:r.message})}}async function L(t,i,s){let a=r.default.join(t,"documentation","kanban.json");try{let t=await e.promises.readFile(a,"utf-8"),r=JSON.parse(t);for(let t of Object.values(r.stages))for(let e of t)if(e.id===i&&e.automation){Object.assign(e.automation,s);break}await e.promises.writeFile(a,JSON.stringify(r,null,2)+"\n")}catch(t){console.error(`[scheduler] Failed to update card ${i}:`,t)}}async function j(e,r,i){try{let{execSync:s}=await t.A(44264),a=[`Automation failed: ${e}`];i&&a.push(`Session: ${i}`),a.push(`Error: ${r}`),a.push("Log: ~/.slycode/logs/automation.log");let n=a.join("\n").replace(/"/g,'\\"');s(`sly-messaging send "${n}"`,{timeout:1e4,stdio:"pipe"})}catch{console.error(`[scheduler] Failed to send error notification for "${e}"`)}}async function F(){W.lastCheck=new Date().toISOString();try{for(let t of(await D()).projects){let i,s=r.default.join(t.path,"documentation","kanban.json");try{let t=await e.promises.readFile(s,"utf-8");i=JSON.parse(t)}catch{continue}for(let[,e]of Object.entries(i.stages))for(let r of e)r.automation&&r.automation.enabled&&!r.archived&&!W.activeKickoffs.has(r.id)&&function(t){if(!t.enabled||!t.schedule)return!1;if("one-shot"===t.scheduleType){let e=new Date(t.schedule);return!isNaN(e.getTime())&&e.getTime()<=Date.now()}try{let e=new m(t.schedule,{timezone:S}),r=Date.now(),i=new Date(t.lastRun?Math.max(new Date(t.lastRun).getTime(),r-6e4):r),s=e.nextRun(i);if(!s)return!1;return s.getTime()<=r}catch{return!1}}(r.automation)&&(W.activeKickoffs.add(r.id),await L(t.path,r.id,{lastRun:new Date().toISOString()}),(async()=>{try{console.log(`[scheduler] Firing automation: ${r.title} (${r.id})`);let e=await z(r,t.id,t.path),i={lastResult:e.success?"success":"error"};if("one-shot"===r.automation.scheduleType)i.enabled=!1;else{let t=E(r.automation.schedule,"recurring");t&&(i.nextRun=t.toISOString())}await L(t.path,r.id,i),e.success||(console.error(`[scheduler] Kickoff failed for ${r.id}: ${e.error}`),e.error&&(e.error.includes("Session create failed")||e.error.includes("Session stopped")||e.error.includes("Input failed")||e.error.includes("No automation config"))?await j(r.title,e.error||"Unknown error",e.sessionName):console.log(`[scheduler] Soft failure for ${r.id}, skipping notification: ${e.error}`))}catch(t){console.error(`[scheduler] Error processing ${r.id}:`,t)}finally{W.activeKickoffs.delete(r.id)}})())}}catch(t){console.error("[scheduler] Check loop error:",t)}}function Y(){var t;let e=M();e&&(clearInterval(e),U[R]=null),W.running||(W.running=!0,console.log("[scheduler] Started. Checking every 30s."),F(),t=setInterval(F,3e4),U[R]=t)}function Z(){if(!W.running)return;W.running=!1;let t=M();t&&(clearInterval(t),U[R]=null);console.log("[scheduler] Stopped.")}function J(){return W.running||(console.log("[scheduler] Auto-starting on status check"),Y()),{running:W.running,lastCheck:W.lastCheck,activeKickoffs:Array.from(W.activeKickoffs)}}t.s(["getConfiguredTimezone",()=>A,"getNextRun",()=>E,"getSchedulerStatus",()=>J,"startScheduler",()=>Y,"stopScheduler",()=>Z,"triggerAutomation",()=>z,"updateCardAutomation",()=>L],92739)}];
1
+ module.exports=[92739,t=>{"use strict";var e=t.i(22734),r=t.i(14747),i=t.i(46786);function s(t){return Date.UTC(t.y,t.m-1,t.d,t.h,t.i,t.s)}function a(t,e){return t.y===e.y&&t.m===e.m&&t.d===e.d&&t.h===e.h&&t.i===e.i&&t.s===e.s}function n(t,e,r){return o(function(t,e){let r=new Date(Date.parse(t));if(isNaN(r))throw Error("Invalid ISO8601 passed to timezone parser.");let i=t.substring(9);return i.includes("Z")||i.includes("+")||i.includes("-")?l(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),"Etc/UTC"):l(r.getFullYear(),r.getMonth()+1,r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),e)}(t,e),r)}function o(t,e){let r=new Date(s(t)),i=h(r,t.tz),n=s(t),o=s(i),l=new Date(r.getTime()+(n-o)),u=h(l,t.tz);if(a(u,t)){let e=new Date(l.getTime()-36e5);return a(h(e,t.tz),t)?e:l}let d=new Date(l.getTime()+s(t)-s(u));if(a(h(d,t.tz),t))return d;if(e)throw Error("Invalid date passed to fromTZ()");return l.getTime()>d.getTime()?l:d}function h(t,e){let r;try{r=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(t)}catch(r){let t=r instanceof Error?r.message:String(r);throw RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${t}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let t of r)("year"===t.type||"month"===t.type||"day"===t.type||"hour"===t.type||"minute"===t.type||"second"===t.type)&&(i[t.type]=parseInt(t.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return 24===i.hour&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function l(t,e,r,i,s,a,n){return{y:t,m:e,d:r,h:i,i:s,s:a,tz:n}}var u=[1,2,4,8,16],d=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(t,e,r){this.pattern=t,this.timezone=e,this.mode=r?.mode??"auto",this.alternativeWeekdays=r?.alternativeWeekdays??!1,this.sloppyRanges=r?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!("string"==typeof this.pattern||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let t=this.pattern.match(/\S+/g)||[""],e=t.length;if(t.length<5||t.length>7)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if("auto"!==this.mode){let t;switch(this.mode){case"5-part":t=5;break;case"6-part":t=6;break;case"7-part":t=7;break;case"5-or-6-parts":t=[5,6];break;case"6-or-7-parts":t=[6,7];break;default:t=0}if(!(Array.isArray(t)?t.includes(e):e===t)){let r=Array.isArray(t)?t.join(" or "):t.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${r} parts, but pattern '${this.pattern}' has ${e} parts.`)}}if(5===t.length&&t.unshift("0"),6===t.length&&t.push("*"),"LW"===t[3].toUpperCase()?(this.lastWeekday=!0,t[3]=""):t[3].toUpperCase().indexOf("L")>=0&&(t[3]=t[3].replace(/L/gi,""),this.lastDayOfMonth=!0),"*"==t[3]&&(this.starDOM=!0),"*"==t[6]&&(this.starYear=!0),t[4].length>=3&&(t[4]=this.replaceAlphaMonths(t[4])),t[5].length>=3&&(t[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(t[5]):this.replaceAlphaDays(t[5])),t[5].startsWith("+")&&(this.useAndLogic=!0,t[5]=t[5].substring(1),""===t[5]))throw TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch("*"==t[5]&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(t[0]=t[0].replace(/\?/g,"*"),t[1]=t[1].replace(/\?/g,"*"),t[2]=t[2].replace(/\?/g,"*"),t[3]=t[3].replace(/\?/g,"*"),t[4]=t[4].replace(/\?/g,"*"),t[5]=t[5].replace(/\?/g,"*"),t[6]&&(t[6]=t[6].replace(/\?/g,"*"))),this.mode){case"5-part":t[0]="0",t[6]="*";break;case"6-part":case"5-or-6-parts":t[6]="*"}this.throwAtIllegalCharacters(t),this.partToArray("second",t[0],0,1),this.partToArray("minute",t[1],0,1),this.partToArray("hour",t[2],0,1),this.partToArray("day",t[3],-1,1),this.partToArray("month",t[4],-1,1);let r=this.alternativeWeekdays?-1:0;this.partToArray("dayOfWeek",t[5],r,63),this.partToArray("year",t[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(t,e,r,i){let s=this[t],a="day"===t&&this.lastDayOfMonth,n="day"===t&&this.lastWeekday;if(""===e&&!a&&!n)throw TypeError("CronPattern: configuration entry "+t+" ("+e+") is empty, check for trailing spaces.");if("*"===e)return s.fill(i);let o=e.split(",");if(o.length>1)for(let e=0;e<o.length;e++)this.partToArray(t,o[e],r,i);else -1!==e.indexOf("-")&&-1!==e.indexOf("/")?this.handleRangeWithStepping(e,t,r,i):-1!==e.indexOf("-")?this.handleRange(e,t,r,i):-1!==e.indexOf("/")?this.handleStepping(e,t,r,i):""!==e&&this.handleNumber(e,t,r,i)}throwAtIllegalCharacters(t){for(let e=0;e<t.length;e++)if((3===e?/[^/*0-9,\-WwLl]+/:5===e?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(t[e]))throw TypeError("CronPattern: configuration entry "+e+" ("+t[e]+") contains illegal characters.")}handleNumber(t,e,r,i){let s=this.extractNth(t,e),a=t.toUpperCase().includes("W");if("day"!==e&&a)throw TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(e="nearestWeekdays");let n=parseInt(s[0],10)+r;if(isNaN(n))throw TypeError("CronPattern: "+e+" is not a number: '"+t+"'");this.setPart(e,n,s[1]||i)}setPart(t,e,r){if(!Object.prototype.hasOwnProperty.call(this,t))throw TypeError("CronPattern: Invalid part specified: "+t);if("dayOfWeek"===t){if(7===e&&(e=0),e<0||e>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+e);this.setNthWeekdayOfMonth(e,r);return}if("second"===t||"minute"===t){if(e<0||e>=60)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("hour"===t){if(e<0||e>=24)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("day"===t||"nearestWeekdays"===t){if(e<0||e>=31)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("month"===t){if(e<0||e>=12)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("year"===t&&(e<1||e>=1e4))throw RangeError("CronPattern: Invalid value for "+t+": "+e+" (supported range: 1-9999)");this[t][e]=r}validateNotNaN(t,e){if(isNaN(t))throw TypeError(e)}validateRange(t,e,r,i,s){if(t>e)throw TypeError("CronPattern: From value is larger than to value: '"+s+"'");if(void 0!==r){if(0===r)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(r>this[i].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[i].length+")")}}handleRangeWithStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(t,e),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(null===a)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+t+"'");let[,n,o,h]=a,l=parseInt(n,10)+r,u=parseInt(o,10)+r,d=parseInt(h,10);this.validateNotNaN(l,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(u,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateNotNaN(d,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(l,u,d,e,t);for(let t=l;t<=u;t+=d)this.setPart(e,t,s[1]||i)}extractNth(t,e){let r=t,i;if(r.includes("#")){if("dayOfWeek"!==e)throw Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if("dayOfWeek"!==e)throw Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(t,e),a=s[0].split("-");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal range: '"+t+"'");let n=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;this.validateNotNaN(n,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(o,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateRange(n,o,void 0,e,t);for(let t=n;t<=o;t++)this.setPart(e,t,s[1]||i)}handleStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(t,e),a=s[0].split("/");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+t+"'");if(this.sloppyRanges)""===a[0]&&(a[0]="*");else{if(""===a[0])throw TypeError("CronPattern: Syntax error, stepping with missing prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");if("*"!==a[0])throw TypeError("CronPattern: Syntax error, stepping with numeric prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.")}let n=0;"*"!==a[0]&&(n=parseInt(a[0],10)+r);let o=parseInt(a[1],10);this.validateNotNaN(o,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(0,this[e].length-1,o,e,t);for(let t=n;t<this[e].length;t+=o)this.setPart(e,t,s[1]||i)}replaceAlphaDays(t){return t.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaDaysQuartz(t){return t.replace(/sun/gi,"1").replace(/mon/gi,"2").replace(/tue/gi,"3").replace(/wed/gi,"4").replace(/thu/gi,"5").replace(/fri/gi,"6").replace(/sat/gi,"7")}replaceAlphaMonths(t){return t.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(t){let e=t.trim().toLowerCase();if("@yearly"===e||"@annually"===e)return"0 0 1 1 *";if("@monthly"===e)return"0 0 1 * *";if("@weekly"===e)return"0 0 * * 0";if("@daily"===e||"@midnight"===e)return"0 0 * * *";if("@hourly"===e)return"0 * * * *";if("@reboot"===e)throw TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return t}setNthWeekdayOfMonth(t,e){if("number"!=typeof e&&"L"===e.toUpperCase())this.dayOfWeek[t]=32|this.dayOfWeek[t];else if(63===e)this.dayOfWeek[t]=63;else if(e<6&&e>0)this.dayOfWeek[t]=this.dayOfWeek[t]|u[e-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${e}, Type: ${typeof e}`)}},c=[31,28,31,30,31,30,31,31,30,31,30,31],f=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],p=class t{tz;ms;second;minute;hour;day;month;year;constructor(e,r){if(this.tz=r,e&&e instanceof Date)if(isNaN(e))throw TypeError("CronDate: Invalid date passed to CronDate constructor");else this.fromDate(e);else if(null==e)this.fromDate(new Date);else if(e&&"string"==typeof e)this.fromString(e);else if(e instanceof t)this.fromCronDate(e);else throw TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getLastDayOfMonth(t,e){return 1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate()}getLastWeekday(t,e){let r=this.getLastDayOfMonth(t,e),i=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===i?r-2:6===i?r-1:r}getNearestWeekday(t,e,r){let i=this.getLastDayOfMonth(t,e);if(r>i)return -1;let s=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===s?r===i?r-2:r+1:6===s?1===r?r+2:r-1:r}isNthWeekdayOfMonth(t,e,r,i){let s=new Date(Date.UTC(t,e,r)).getUTCDay(),a=0;for(let i=1;i<=r;i++)new Date(Date.UTC(t,e,i)).getUTCDay()===s&&a++;if(63&i&&u[a-1]&i)return!0;if(32&i){let i=this.getLastDayOfMonth(t,e);for(let a=r+1;a<=i;a++)if(new Date(Date.UTC(t,e,a)).getUTCDay()===s)return!1;return!0}return!1}fromDate(t){if(void 0!==this.tz)if("number"==typeof this.tz)this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes()+this.tz,this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply();else try{let e=h(t,this.tz);this.ms=t.getMilliseconds(),this.second=e.s,this.minute=e.i,this.hour=e.h,this.day=e.d,this.month=e.m-1,this.year=e.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}else this.ms=t.getMilliseconds(),this.second=t.getSeconds(),this.minute=t.getMinutes(),this.hour=t.getHours(),this.day=t.getDate(),this.month=t.getMonth(),this.year=t.getFullYear()}fromCronDate(t){this.tz=t.tz,this.year=t.year,this.month=t.month,this.day=t.day,this.hour=t.hour,this.minute=t.minute,this.second=t.second,this.ms=t.ms}apply(){if(!(this.month>11)&&!(this.month<0)&&!(this.day>c[this.month])&&!(this.day<1)&&!(this.hour>59)&&!(this.minute>59)&&!(this.second>59)&&!(this.hour<0)&&!(this.minute<0)&&!(this.second<0))return!1;{let t=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),!0}}fromString(t){if("number"!=typeof this.tz)return this.fromDate(n(t,this.tz));{let e=n(t);this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply()}}findNext(t,e,r,i){return this._findMatch(t,e,r,i,1)}_findMatch(t,e,r,i,s){let a=this[e],n;r.lastDayOfMonth&&(n=this.getLastDayOfMonth(this.year,this.month));let o=r.starDOW||"day"!=e?void 0:new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),h=this[e]+i,l=1===s?t=>t<r[e].length:t=>t>=0;for(let u=h;l(u);u+=s){let s=r[e][u];if("day"===e&&!s){for(let t=0;t<r.nearestWeekdays.length;t++)if(r.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(-1===e)continue;if(e===u-i){s=1;break}}}if("day"===e&&r.lastWeekday&&u-i===this.getLastWeekday(this.year,this.month)&&(s=1),"day"===e&&r.lastDayOfMonth&&u-i==n&&(s=1),"day"===e&&!r.starDOW){let e=r.dayOfWeek[(o+(u-i-1))%7];if(e&&63&e)e=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-i,e);else if(e)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${e}`);s=r.useAndLogic||t.domAndDow||r.starDOM?s&&e:s||e}if(s)return this[e]=u-i,a!==this[e]?2:1}return 3}recurse(t,e,r){if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year+1;r<t.year.length&&r<1e4;r++)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(e,f[r][0],t,f[r][2]);if(i>1){let s=r+1;for(;s<f.length;)this[f[s][0]]=-f[s][2],s++;if(3===i){if(this[f[r][1]]++,this[f[r][0]]=-f[r][2],this.apply(),0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year]&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=t.year.length)return null}return this.recurse(t,e,0)}if(this.apply())return this.recurse(t,e,r-1)}return(r+=1)>=f.length?this:(t.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(t,e,r)}increment(t,e,r){return this.second+=void 0!==e.interval&&e.interval>1&&r?e.interval:1,this.ms=0,this.apply(),this.recurse(t,e,0)}decrement(t,e){return this.second-=void 0!==e.interval&&e.interval>1?e.interval:1,this.ms=0,this.apply(),this.recurseBackward(t,e,0,0)}recurseBackward(t,e,r,i=0){if(i>1e4)return null;if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year-1;r>=0;r--)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let s=this.findPrevious(e,f[r][0],t,f[r][2]);if(s>1){let a=r+1;for(;a<f.length;){let e=f[a][0],r=f[a][2],i=this.getMaxPatternValue(e,t,r);this[e]=i,a++}if(3===s){if(this[f[r][1]]--,0===r){let t=this.getLastDayOfMonth(this.year,this.month);this.day>t&&(this.day=t)}if(1===r)if(this.day<=0)this.day=1;else{let t=this.year,e=this.month;for(;e<0;)e+=12,t--;for(;e>11;)e-=12,t++;let r=1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate();this.day>r&&(this.day=r)}this.apply();let s=f[r][0],a=f[r][2],n=this.getMaxPatternValue(s,t,a);if("day"===s){let t=this.getLastDayOfMonth(this.year,this.month);this[s]=Math.min(n,t)}else this[s]=n;if(this.apply(),0===r){let e=f[1][2],r=Math.min(this.getMaxPatternValue("day",t,e),this.getLastDayOfMonth(this.year,this.month));r!==this.day&&(this.day=r,this.hour=this.getMaxPatternValue("hour",t,f[2][2]),this.minute=this.getMaxPatternValue("minute",t,f[3][2]),this.second=this.getMaxPatternValue("second",t,f[4][2]))}if(0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year];)this.year--;if(this.year<0)return null}return this.recurseBackward(t,e,0,i+1)}if(this.apply())return this.recurseBackward(t,e,r-1,i+1)}return(r+=1)>=f.length?this:this.year<0?null:this.recurseBackward(t,e,r,i+1)}getMaxPatternValue(t,e,r){if("day"===t&&e.lastDayOfMonth||"day"===t&&!e.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let i=e[t].length-1;i>=0;i--)if(e[t][i])return i-r;return e[t].length-1-r}findPrevious(t,e,r,i){return this._findMatch(t,e,r,i,-1)}getDate(t){return t||void 0===this.tz?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):"number"==typeof this.tz?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):o(l(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(t,e){if(!t.starYear&&(this.year<0||this.year>=t.year.length||0===t.year[this.year]))return!1;for(let r=0;r<f.length;r++){let i=f[r][0],s=f[r][2],a=this[i];if(a+s<0||a+s>=t[i].length)return!1;let n=t[i][a+s];if("day"===i){if(!n){for(let e=0;e<t.nearestWeekdays.length;e++)if(t.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-s);if(-1!==t&&t===a){n=1;break}}}if(t.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(n=1),t.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(n=1),!t.starDOW){let r=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),i=t.dayOfWeek[(r+(a-1))%7];i&&63&i&&(i=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,i)),n=t.useAndLogic||e.domAndDow||t.starDOM?n&&i:n||i}}if(!n)return!1}return!0}};function y(t){return"[object Function]"===Object.prototype.toString.call(t)||"function"==typeof t||t instanceof Function}var g=[],m=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(t){if(void 0!==this.options.dayOffset&&0!==this.options.dayOffset){let e=24*this.options.dayOffset*36e5;return new Date(t.getTime()+e)}return t}constructor(t,e,r){let i,s;if(y(e))s=e;else if("object"==typeof e)i=e;else if(void 0!==e)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))s=r;else if("object"==typeof r)i=r;else if(void 0!==r)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=function(t){if(void 0===t&&(t={}),delete t.name,void 0!==t.legacyMode&&void 0===t.domAndDow?t.domAndDow=!t.legacyMode:void 0===t.domAndDow&&(t.domAndDow=!1),t.legacyMode=!t.domAndDow,t.paused=void 0!==t.paused&&t.paused,t.maxRuns=void 0===t.maxRuns?1/0:t.maxRuns,t.catch=void 0!==t.catch&&t.catch,t.interval=void 0===t.interval?0:parseInt(t.interval.toString(),10),t.utcOffset=void 0===t.utcOffset?void 0:parseInt(t.utcOffset.toString(),10),t.dayOffset=void 0===t.dayOffset?0:parseInt(t.dayOffset.toString(),10),t.unref=void 0!==t.unref&&t.unref,t.mode=void 0===t.mode?"auto":t.mode,t.alternativeWeekdays=void 0!==t.alternativeWeekdays&&t.alternativeWeekdays,t.sloppyRanges=void 0!==t.sloppyRanges&&t.sloppyRanges,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(t.mode))throw Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(t.startAt&&(t.startAt=new p(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new p(t.stopAt,t.timezone)),null!==t.interval){if(isNaN(t.interval))throw Error("CronOptions: Supplied value for interval is not a number");if(t.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if(void 0!==t.utcOffset){if(isNaN(t.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(t.utcOffset<-870||t.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if(void 0!==t.utcOffset&&t.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(!0!==t.unref&&!1!==t.unref)throw Error("CronOptions: Unref should be either true, false or undefined(false).");if(void 0!==t.dayOffset&&0!==t.dayOffset&&isNaN(t.dayOffset))throw Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return t}(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:!!i&&i.paused,pattern:new d("* * * * *",void 0,{mode:"auto"})},t&&(t instanceof Date||"string"==typeof t&&t.indexOf(":")>0)?this._states.once=new p(t,this.getTz()):this._states.pattern=new d(t,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(g.find(t=>t.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");g.push(this)}return void 0!==s&&function(t){return y(t)}(s)&&(this.fn=s,this.schedule()),this}nextRun(t){let e=this._next(t);return e?this.applyDayOffset(e.getDate(!1)):null}nextRuns(t,e){void 0!==this._states.maxRuns&&t>this._states.maxRuns&&(t=this._states.maxRuns);let r=e||this._states.currentRun||void 0;return this._enumerateRuns(t,r,"next")}previousRuns(t,e){return this._enumerateRuns(t,e||void 0,"previous")}_enumerateRuns(t,e,r){let i=[],s=e?new p(e,this.getTz()):null,a="next"===r?this._next:this._previous;for(;t--;){let t=a.call(this,s);if(!t)break;let e=t.getDate(!1);i.push(this.applyDayOffset(e)),s=t}return i}match(t){if(this._states.once){let e=new p(t,this.getTz());e.ms=0;let r=new p(this._states.once,this.getTz());return r.ms=0,e.getTime()===r.getTime()}let e=new p(t,this.getTz());return e.ms=0,e.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let t=this.nextRun(this._states.currentRun),e=!this._states.paused,r=void 0!==this.fn,i=!this._states.kill;return e&&r&&i&&null!==t}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(t){let e=this._next(t);return e?t instanceof p||t instanceof Date?e.getTime()-t.getTime():e.getTime()-new p(t).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let t=g.indexOf(this);t>=0&&g.splice(t,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(t){var e;if(t&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");t&&(this.fn=t);let r=this.msToNext(),i=this.nextRun(this._states.currentRun);return null==r||isNaN(r)||null===i||(r>3e4&&(r=3e4),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(i),r),this._states.currentTimeout&&this.options.unref&&(e=this._states.currentTimeout,"u">typeof Deno&&"u">typeof Deno.unrefTimer?Deno.unrefTimer(e):e&&"u">typeof e.unref&&e.unref())),this}async _trigger(t){this._states.blocking=!0,this._states.currentRun=new p(void 0,this.getTz());try{if(this.options.catch)try{void 0!==this.fn&&await this.fn(this,this.options.context)}catch(t){if(y(this.options.catch))try{this.options.catch(t,this)}catch{}}else void 0!==this.fn&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new p(t,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(t){let e=new Date,r=!this._states.paused&&e.getTime()>=t.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(void 0!==this._states.maxRuns&&this._states.maxRuns--,this._trigger()):r&&i&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(t){let e=!!(t||this._states.currentRun),r=!1;!t&&this.options.startAt&&this.options.interval&&([t,e]=this._calculatePreviousRun(t,e),r=!t),t=new p(t,this.getTz()),this.options.startAt&&t&&t.getTime()<this.options.startAt.getTime()&&(t=this.options.startAt);let i=this._states.once||new p(t,this.getTz());return r||i===this._states.once||(i=i.increment(this._states.pattern,this.options,e)),this._states.once&&this._states.once.getTime()<=t.getTime()||null===i||void 0!==this._states.maxRuns&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_previous(t){let e=new p(t,this.getTz());this.options.stopAt&&e.getTime()>this.options.stopAt.getTime()&&(e=this.options.stopAt);let r=new p(e,this.getTz());return this._states.once?this._states.once.getTime()<e.getTime()?this._states.once:null:null===(r=r.decrement(this._states.pattern,this.options))||this.options.startAt&&r.getTime()<this.options.startAt.getTime()?null:r}_calculatePreviousRun(t,e){let r=new p(void 0,this.getTz()),i=t;if(this.options.startAt.getTime()<=r.getTime()){let t=(i=this.options.startAt).getTime()+1e3*this.options.interval;for(;t<=r.getTime();)t=(i=new p(i,this.getTz()).increment(this._states.pattern,this.options,!0)).getTime()+1e3*this.options.interval;e=!0}return null===i&&(i=void 0),[i,e]}};function w(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let t=process.cwd();return(console.warn("[paths] SLYCODE_HOME not set in production — falling back to cwd:",t),t.endsWith("/web")||t.endsWith("\\web"))?r.default.dirname(t):t}t.i(33405),t.i(54799);let T=w();r.default.basename(T),r.default.join(w(),"store",".ignored-updates.json");let v=function(){if(process.env.SLYCODE_HOME)return process.env.SLYCODE_HOME;let t=process.cwd();return t.endsWith("/web")||t.endsWith("\\web")?r.default.dirname(t):t}(),C=r.default.join(v,"projects","registry.json");async function D(){try{let t=await e.promises.readFile(C,"utf-8");return JSON.parse(t)}catch(t){throw console.error("Failed to load registry:",t),Error(`Failed to load registry from ${C}`)}}let O=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];!function(){try{let t=r.default.join(w(),".env");for(let r of(0,e.readFileSync)(t,"utf-8").split("\n")){let t=r.trim();if(!t||t.startsWith("#"))continue;let e=t.indexOf("=");if(e<0)continue;let i=t.slice(0,e).trim(),s=t.slice(e+1).trim();process.env[i]||(process.env[i]=s)}}catch{}}();let k=process.env.BRIDGE_URL?process.env.BRIDGE_URL:"http://127.0.0.1:3004",S=process.env.TZ||"UTC",N=r.default.join(i.default.homedir(),".slycode","logs","automation.log");async function $(t,e){let r=new AbortController,i=setTimeout(()=>r.abort(),1e4);try{return await fetch(t,{...e,signal:r.signal})}finally{clearTimeout(i)}}async function x(t){try{let i=r.default.dirname(N);await e.promises.mkdir(i,{recursive:!0});let s=JSON.stringify(t)+"\n";await e.promises.appendFile(N,s);try{if((await e.promises.stat(N)).size>1e6){let t=(await e.promises.readFile(N,"utf-8")).trim().split("\n"),r=t.slice(Math.floor(t.length/2));await e.promises.writeFile(N,r.join("\n")+"\n")}}catch{}}catch(t){console.error("[scheduler] Failed to write automation log:",t)}}async function _(t){await new Promise(t=>setTimeout(t,2e4));try{let e=await $(`${k}/sessions/${encodeURIComponent(t)}`);if(!e.ok)return{status:"unknown"};let r=await e.json();if("stopped"===r.status)return{status:"stopped",exitCode:r.exitCode,exitedAt:r.exitedAt};if("running"===r.status||"detached"===r.status)return{status:"running"};return{status:"unknown"}}catch{return{status:"unknown"}}}function A(){try{let t=new Intl.DateTimeFormat("en-US",{timeZone:S,timeZoneName:"short"}).formatToParts(new Date),e=t.find(t=>"timeZoneName"===t.type)?.value||S;return{timezone:S,abbreviation:e}}catch{return{timezone:"UTC",abbreviation:"UTC"}}}let b="__scheduler_state__",R="__scheduler_timer__",U=globalThis;U[b]||(U[b]={running:!1,lastCheck:null,activeKickoffs:new Set}),void 0===U[R]&&(U[R]=null);let W=U[b];function M(){return U[R]??null}function E(t,e){if("one-shot"===e){let e=new Date(t);return isNaN(e.getTime())?null:e}try{return new m(t,{timezone:S}).nextRun()}catch{return null}}async function P(t){await new Promise(t=>setTimeout(t,1e4));let e=0;try{let r=await $(`${k}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;e=i.lastOutputAt?new Date(i.lastOutputAt).getTime():0}catch{return!1}await new Promise(t=>setTimeout(t,5e3));try{let r=await $(`${k}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;return(i.lastOutputAt?new Date(i.lastOutputAt).getTime():0)>e}catch{return!1}}function I(t){let e=t.toLocaleDateString("en-US",{weekday:"long",timeZone:S}),r=new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:S}).format(t),i=t.toLocaleDateString("en-US",{month:"short",timeZone:S}),s=new Intl.DateTimeFormat("en-US",{year:"numeric",timeZone:S}).format(t),a=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:S}),{abbreviation:n}=A();return`${e}, ${r} ${i} ${s}, ${a} ${n}`}async function z(t,e,r,i={trigger:"scheduled"}){let s=t.automation;if(!s)return{cardId:t.id,projectId:e,success:!1,error:"No automation config"};let a=s.provider||"claude",n=`${e}:${a}:card:${t.id}`,o=s.workingDirectory||r,h=[function(t,e,r){let i=new Date,s=["=== AUTOMATION RUN ==="];if(s.push(`Time: ${I(i)}`),s.push(`Card: ${t.title} (${t.id})`),"manual"===r)s.push("Trigger: manual");else{let t=function(t,e,r="Not set",i){if("one-shot"===e)try{let e=new Date(t);if(isNaN(e.getTime()))return t||r;return`Once on ${e.toLocaleDateString()} at ${e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}catch{return t||r}if(!t)return r;let s=t.split(" ");if(5!==s.length)return t;let[a,n,o,,h]=s,l=n.match(/^(\d+)-(\d+)\/(\d+)$/);if(l&&"*"===o&&"*"===h){let[,t,e,r]=l;return`Every ${r}h from ${t.padStart(2,"0")}:${a.padStart(2,"0")} to ${e.padStart(2,"0")}:${a.padStart(2,"0")}`}if(n.includes(",")&&"*"===o&&"*"===h){let t=n.split(",").map(Number);if(t.length>=2){let e=(t[1]-t[0]+24)%24;if(e>0){let r=String(t[0]).padStart(2,"0"),i=String(t[t.length-1]).padStart(2,"0");return`Every ${e}h from ${r}:${a.padStart(2,"0")} to ${i}:${a.padStart(2,"0")}`}}}if("*"===n&&"*"===o&&"*"===h)return`Every hour at :${a.padStart(2,"0")}`;if("*"===o&&"*"===h)return`Daily at ${n}:${a.padStart(2,"0")}`;if("*"===o&&"*"!==h){let t=h.split(",").map(t=>O[parseInt(t)]||t).join(", ");return`Weekly on ${t} at ${n}:${a.padStart(2,"0")}`}return"*"!==o&&"*"===h?`Monthly on day ${o} at ${n}:${a.padStart(2,"0")}`:t}(e.schedule,e.scheduleType);s.push(`Trigger: scheduled (${t.toLowerCase()})`)}if(e.lastRun){let t=new Date(e.lastRun);s.push(`Last run: ${I(t)} (${function(t,e){let r=e.getTime()-t.getTime();if(r<0)return"in the future";let i=Math.floor(r/6e4),s=Math.floor(i/60),a=Math.floor(s/24);return a>0?`${a}d ${s%24}h ago`:s>0?`${s}h ${i%60}m ago`:i>0?`${i}m ago`:"just now"}(t,i)})`)}else s.push("Last run: never");return s.push("======================"),s.join("\n")}(t,s,i.trigger),""];if(t.areas.length>0&&h.push(`Areas: ${t.areas.join(", ")}`),t.tags.length>0&&h.push(`Tags: ${t.tags.join(", ")}`),t.checklist.length>0){let e=t.checklist.filter(t=>!t.done);e.length>0&&h.push(`Pending checklist: ${e.map(t=>t.text).join("; ")}`)}h.push("","---","",t.description);let l=h.join("\n");s.reportViaMessaging&&(l+='\n\nAfter completing the task, send a summary of the results using the messaging skill: sly-messaging send "<your summary>"');let u=s.freshSession||!1,d=Date.now(),c=null,f=null,p=async r=>(await x({timestamp:new Date().toISOString(),cardId:t.id,cardTitle:t.title,projectId:e,trigger:i.trigger,provider:a,sessionName:n,fresh:u,bridgeRequest:c,livenessCheck:f,outcome:r.success?"success":"error",error:r.error||null,elapsedMs:Date.now()-d}),r);try{console.log(`[scheduler] Creating session: ${n} (fresh: ${u}, provider: ${a})`);let r=await $(`${k}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,provider:a,skipPermissions:!0,cwd:o,prompt:l,fresh:u})});if(r.ok||409!==r.status||u)if(r.ok){let t=await r.json();c={status:r.status,resumed:t.resumed,pid:t.pid},console.log(`[scheduler] Session created: ${n} (status: ${t.status}, resumed: ${t.resumed}, pid: ${t.pid})`)}else{let i;try{let t=await r.json();i=t.error||JSON.stringify(t)}catch{i=await r.text()}return c={status:r.status,error:i},p({cardId:t.id,projectId:e,success:!1,error:`Session create failed (${r.status}): ${i}`})}else{c={status:409},console.log(`[scheduler] Session ${n} returned 409, sending prompt via input endpoint`);let r=await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l})});if(r.ok&&(await new Promise(t=>setTimeout(t,600)),await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})})),!r.ok){let i=await r.text();return p({cardId:t.id,projectId:e,success:!1,error:`Input failed (${r.status}): ${i}`})}}if(u){let r=await _(n);if(f={type:"checkSessionAlive",result:r.status,delayMs:2e4,exitCode:r.exitCode,exitedAt:r.exitedAt},"stopped"===r.status){if(0===r.exitCode)return p({cardId:t.id,projectId:e,success:!0,sessionName:n});let i=void 0!==r.exitCode?` (exit code ${r.exitCode})`:"",s=r.exitedAt?`, alive ${((new Date(r.exitedAt).getTime()-d)/1e3).toFixed(1)}s`:"";return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:`Session stopped during startup${i}${s}`})}return p({cardId:t.id,projectId:e,success:!0,sessionName:n})}if(await P(n))return f={type:"waitForActivity",result:"active"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});console.log(`[scheduler] No activity for ${t.id} (resume path), retrying via input...`),await new Promise(t=>setTimeout(t,3e3));let i=`\x1b[200~${l}\x1b[201~`;if((await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:i})})).ok&&(await new Promise(t=>setTimeout(t,600)),await $(`${k}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})}),await P(n)))return f={type:"waitForActivity",result:"active (retry)"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});return f={type:"waitForActivity",result:"inactive after retry"},p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:"No activity detected after retry"})}catch(r){return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:r.message})}}async function L(t,i,s){let a=r.default.join(t,"documentation","kanban.json");try{let t=await e.promises.readFile(a,"utf-8"),r=JSON.parse(t);for(let t of Object.values(r.stages))for(let e of t)if(e.id===i&&e.automation){Object.assign(e.automation,s);break}await e.promises.writeFile(a,JSON.stringify(r,null,2)+"\n")}catch(t){console.error(`[scheduler] Failed to update card ${i}:`,t)}}async function j(e,r,i){try{let{execSync:s}=await t.A(44264),a=[`Automation failed: ${e}`];i&&a.push(`Session: ${i}`),a.push(`Error: ${r}`),a.push("Log: ~/.slycode/logs/automation.log");let n=a.join("\n").replace(/"/g,'\\"');s(`sly-messaging send "${n}"`,{timeout:1e4,stdio:"pipe"})}catch{console.error(`[scheduler] Failed to send error notification for "${e}"`)}}async function F(){W.lastCheck=new Date().toISOString();try{for(let t of(await D()).projects){let i,s=r.default.join(t.path,"documentation","kanban.json");try{let t=await e.promises.readFile(s,"utf-8");i=JSON.parse(t)}catch{continue}for(let[,e]of Object.entries(i.stages))for(let r of e)r.automation&&r.automation.enabled&&!r.archived&&!W.activeKickoffs.has(r.id)&&function(t){if(!t.enabled||!t.schedule)return!1;if("one-shot"===t.scheduleType){let e=new Date(t.schedule);return!isNaN(e.getTime())&&e.getTime()<=Date.now()}try{let e=new m(t.schedule,{timezone:S}),r=Date.now(),i=new Date(t.lastRun?Math.max(new Date(t.lastRun).getTime(),r-6e4):r),s=e.nextRun(i);if(!s)return!1;return s.getTime()<=r}catch{return!1}}(r.automation)&&(W.activeKickoffs.add(r.id),await L(t.path,r.id,{lastRun:new Date().toISOString()}),(async()=>{try{console.log(`[scheduler] Firing automation: ${r.title} (${r.id})`);let e=await z(r,t.id,t.path),i={lastResult:e.success?"success":"error"};if("one-shot"===r.automation.scheduleType)i.enabled=!1;else{let t=E(r.automation.schedule,"recurring");t&&(i.nextRun=t.toISOString())}await L(t.path,r.id,i),e.success||(console.error(`[scheduler] Kickoff failed for ${r.id}: ${e.error}`),e.error&&(e.error.includes("Session create failed")||e.error.includes("Session stopped")||e.error.includes("Input failed")||e.error.includes("No automation config")||e.error.includes("No activity detected"))?await j(r.title,e.error||"Unknown error",e.sessionName):console.log(`[scheduler] Soft failure for ${r.id}, skipping notification: ${e.error}`))}catch(t){console.error(`[scheduler] Error processing ${r.id}:`,t)}finally{W.activeKickoffs.delete(r.id)}})())}}catch(t){console.error("[scheduler] Check loop error:",t)}}function Y(){var t;let e=M();e&&(clearInterval(e),U[R]=null),W.running||(W.running=!0,console.log("[scheduler] Started. Checking every 30s."),F(),t=setInterval(F,3e4),U[R]=t)}function Z(){if(!W.running)return;W.running=!1;let t=M();t&&(clearInterval(t),U[R]=null);console.log("[scheduler] Stopped.")}function J(){return W.running||(console.log("[scheduler] Auto-starting on status check"),Y()),{running:W.running,lastCheck:W.lastCheck,activeKickoffs:Array.from(W.activeKickoffs)}}t.s(["getConfiguredTimezone",()=>A,"getNextRun",()=>E,"getSchedulerStatus",()=>J,"startScheduler",()=>Y,"stopScheduler",()=>Z,"triggerAutomation",()=>z,"updateCardAutomation",()=>L],92739)}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_scheduler_ts_03988e3e._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[32695,t=>{"use strict";var e=t.i(22734),r=t.i(14747),i=t.i(46786);function s(t){return Date.UTC(t.y,t.m-1,t.d,t.h,t.i,t.s)}function a(t,e){return t.y===e.y&&t.m===e.m&&t.d===e.d&&t.h===e.h&&t.i===e.i&&t.s===e.s}function n(t,e,r){return o(function(t,e){let r=new Date(Date.parse(t));if(isNaN(r))throw Error("Invalid ISO8601 passed to timezone parser.");let i=t.substring(9);return i.includes("Z")||i.includes("+")||i.includes("-")?l(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),"Etc/UTC"):l(r.getFullYear(),r.getMonth()+1,r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),e)}(t,e),r)}function o(t,e){let r=new Date(s(t)),i=h(r,t.tz),n=s(t),o=s(i),l=new Date(r.getTime()+(n-o)),u=h(l,t.tz);if(a(u,t)){let e=new Date(l.getTime()-36e5);return a(h(e,t.tz),t)?e:l}let d=new Date(l.getTime()+s(t)-s(u));if(a(h(d,t.tz),t))return d;if(e)throw Error("Invalid date passed to fromTZ()");return l.getTime()>d.getTime()?l:d}function h(t,e){let r;try{r=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(t)}catch(r){let t=r instanceof Error?r.message:String(r);throw RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${t}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let t of r)("year"===t.type||"month"===t.type||"day"===t.type||"hour"===t.type||"minute"===t.type||"second"===t.type)&&(i[t.type]=parseInt(t.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return 24===i.hour&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function l(t,e,r,i,s,a,n){return{y:t,m:e,d:r,h:i,i:s,s:a,tz:n}}var u=[1,2,4,8,16],d=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(t,e,r){this.pattern=t,this.timezone=e,this.mode=r?.mode??"auto",this.alternativeWeekdays=r?.alternativeWeekdays??!1,this.sloppyRanges=r?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!("string"==typeof this.pattern||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let t=this.pattern.match(/\S+/g)||[""],e=t.length;if(t.length<5||t.length>7)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if("auto"!==this.mode){let t;switch(this.mode){case"5-part":t=5;break;case"6-part":t=6;break;case"7-part":t=7;break;case"5-or-6-parts":t=[5,6];break;case"6-or-7-parts":t=[6,7];break;default:t=0}if(!(Array.isArray(t)?t.includes(e):e===t)){let r=Array.isArray(t)?t.join(" or "):t.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${r} parts, but pattern '${this.pattern}' has ${e} parts.`)}}if(5===t.length&&t.unshift("0"),6===t.length&&t.push("*"),"LW"===t[3].toUpperCase()?(this.lastWeekday=!0,t[3]=""):t[3].toUpperCase().indexOf("L")>=0&&(t[3]=t[3].replace(/L/gi,""),this.lastDayOfMonth=!0),"*"==t[3]&&(this.starDOM=!0),"*"==t[6]&&(this.starYear=!0),t[4].length>=3&&(t[4]=this.replaceAlphaMonths(t[4])),t[5].length>=3&&(t[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(t[5]):this.replaceAlphaDays(t[5])),t[5].startsWith("+")&&(this.useAndLogic=!0,t[5]=t[5].substring(1),""===t[5]))throw TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch("*"==t[5]&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(t[0]=t[0].replace(/\?/g,"*"),t[1]=t[1].replace(/\?/g,"*"),t[2]=t[2].replace(/\?/g,"*"),t[3]=t[3].replace(/\?/g,"*"),t[4]=t[4].replace(/\?/g,"*"),t[5]=t[5].replace(/\?/g,"*"),t[6]&&(t[6]=t[6].replace(/\?/g,"*"))),this.mode){case"5-part":t[0]="0",t[6]="*";break;case"6-part":case"5-or-6-parts":t[6]="*"}this.throwAtIllegalCharacters(t),this.partToArray("second",t[0],0,1),this.partToArray("minute",t[1],0,1),this.partToArray("hour",t[2],0,1),this.partToArray("day",t[3],-1,1),this.partToArray("month",t[4],-1,1);let r=this.alternativeWeekdays?-1:0;this.partToArray("dayOfWeek",t[5],r,63),this.partToArray("year",t[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(t,e,r,i){let s=this[t],a="day"===t&&this.lastDayOfMonth,n="day"===t&&this.lastWeekday;if(""===e&&!a&&!n)throw TypeError("CronPattern: configuration entry "+t+" ("+e+") is empty, check for trailing spaces.");if("*"===e)return s.fill(i);let o=e.split(",");if(o.length>1)for(let e=0;e<o.length;e++)this.partToArray(t,o[e],r,i);else -1!==e.indexOf("-")&&-1!==e.indexOf("/")?this.handleRangeWithStepping(e,t,r,i):-1!==e.indexOf("-")?this.handleRange(e,t,r,i):-1!==e.indexOf("/")?this.handleStepping(e,t,r,i):""!==e&&this.handleNumber(e,t,r,i)}throwAtIllegalCharacters(t){for(let e=0;e<t.length;e++)if((3===e?/[^/*0-9,\-WwLl]+/:5===e?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(t[e]))throw TypeError("CronPattern: configuration entry "+e+" ("+t[e]+") contains illegal characters.")}handleNumber(t,e,r,i){let s=this.extractNth(t,e),a=t.toUpperCase().includes("W");if("day"!==e&&a)throw TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(e="nearestWeekdays");let n=parseInt(s[0],10)+r;if(isNaN(n))throw TypeError("CronPattern: "+e+" is not a number: '"+t+"'");this.setPart(e,n,s[1]||i)}setPart(t,e,r){if(!Object.prototype.hasOwnProperty.call(this,t))throw TypeError("CronPattern: Invalid part specified: "+t);if("dayOfWeek"===t){if(7===e&&(e=0),e<0||e>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+e);this.setNthWeekdayOfMonth(e,r);return}if("second"===t||"minute"===t){if(e<0||e>=60)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("hour"===t){if(e<0||e>=24)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("day"===t||"nearestWeekdays"===t){if(e<0||e>=31)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("month"===t){if(e<0||e>=12)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("year"===t&&(e<1||e>=1e4))throw RangeError("CronPattern: Invalid value for "+t+": "+e+" (supported range: 1-9999)");this[t][e]=r}validateNotNaN(t,e){if(isNaN(t))throw TypeError(e)}validateRange(t,e,r,i,s){if(t>e)throw TypeError("CronPattern: From value is larger than to value: '"+s+"'");if(void 0!==r){if(0===r)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(r>this[i].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[i].length+")")}}handleRangeWithStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(t,e),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(null===a)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+t+"'");let[,n,o,h]=a,l=parseInt(n,10)+r,u=parseInt(o,10)+r,d=parseInt(h,10);this.validateNotNaN(l,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(u,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateNotNaN(d,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(l,u,d,e,t);for(let t=l;t<=u;t+=d)this.setPart(e,t,s[1]||i)}extractNth(t,e){let r=t,i;if(r.includes("#")){if("dayOfWeek"!==e)throw Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if("dayOfWeek"!==e)throw Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(t,e),a=s[0].split("-");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal range: '"+t+"'");let n=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;this.validateNotNaN(n,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(o,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateRange(n,o,void 0,e,t);for(let t=n;t<=o;t++)this.setPart(e,t,s[1]||i)}handleStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(t,e),a=s[0].split("/");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+t+"'");if(this.sloppyRanges)""===a[0]&&(a[0]="*");else{if(""===a[0])throw TypeError("CronPattern: Syntax error, stepping with missing prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");if("*"!==a[0])throw TypeError("CronPattern: Syntax error, stepping with numeric prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.")}let n=0;"*"!==a[0]&&(n=parseInt(a[0],10)+r);let o=parseInt(a[1],10);this.validateNotNaN(o,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(0,this[e].length-1,o,e,t);for(let t=n;t<this[e].length;t+=o)this.setPart(e,t,s[1]||i)}replaceAlphaDays(t){return t.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaDaysQuartz(t){return t.replace(/sun/gi,"1").replace(/mon/gi,"2").replace(/tue/gi,"3").replace(/wed/gi,"4").replace(/thu/gi,"5").replace(/fri/gi,"6").replace(/sat/gi,"7")}replaceAlphaMonths(t){return t.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(t){let e=t.trim().toLowerCase();if("@yearly"===e||"@annually"===e)return"0 0 1 1 *";if("@monthly"===e)return"0 0 1 * *";if("@weekly"===e)return"0 0 * * 0";if("@daily"===e||"@midnight"===e)return"0 0 * * *";if("@hourly"===e)return"0 * * * *";if("@reboot"===e)throw TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return t}setNthWeekdayOfMonth(t,e){if("number"!=typeof e&&"L"===e.toUpperCase())this.dayOfWeek[t]=32|this.dayOfWeek[t];else if(63===e)this.dayOfWeek[t]=63;else if(e<6&&e>0)this.dayOfWeek[t]=this.dayOfWeek[t]|u[e-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${e}, Type: ${typeof e}`)}},c=[31,28,31,30,31,30,31,31,30,31,30,31],f=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],p=class t{tz;ms;second;minute;hour;day;month;year;constructor(e,r){if(this.tz=r,e&&e instanceof Date)if(isNaN(e))throw TypeError("CronDate: Invalid date passed to CronDate constructor");else this.fromDate(e);else if(null==e)this.fromDate(new Date);else if(e&&"string"==typeof e)this.fromString(e);else if(e instanceof t)this.fromCronDate(e);else throw TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getLastDayOfMonth(t,e){return 1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate()}getLastWeekday(t,e){let r=this.getLastDayOfMonth(t,e),i=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===i?r-2:6===i?r-1:r}getNearestWeekday(t,e,r){let i=this.getLastDayOfMonth(t,e);if(r>i)return -1;let s=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===s?r===i?r-2:r+1:6===s?1===r?r+2:r-1:r}isNthWeekdayOfMonth(t,e,r,i){let s=new Date(Date.UTC(t,e,r)).getUTCDay(),a=0;for(let i=1;i<=r;i++)new Date(Date.UTC(t,e,i)).getUTCDay()===s&&a++;if(63&i&&u[a-1]&i)return!0;if(32&i){let i=this.getLastDayOfMonth(t,e);for(let a=r+1;a<=i;a++)if(new Date(Date.UTC(t,e,a)).getUTCDay()===s)return!1;return!0}return!1}fromDate(t){if(void 0!==this.tz)if("number"==typeof this.tz)this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes()+this.tz,this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply();else try{let e=h(t,this.tz);this.ms=t.getMilliseconds(),this.second=e.s,this.minute=e.i,this.hour=e.h,this.day=e.d,this.month=e.m-1,this.year=e.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}else this.ms=t.getMilliseconds(),this.second=t.getSeconds(),this.minute=t.getMinutes(),this.hour=t.getHours(),this.day=t.getDate(),this.month=t.getMonth(),this.year=t.getFullYear()}fromCronDate(t){this.tz=t.tz,this.year=t.year,this.month=t.month,this.day=t.day,this.hour=t.hour,this.minute=t.minute,this.second=t.second,this.ms=t.ms}apply(){if(!(this.month>11)&&!(this.month<0)&&!(this.day>c[this.month])&&!(this.day<1)&&!(this.hour>59)&&!(this.minute>59)&&!(this.second>59)&&!(this.hour<0)&&!(this.minute<0)&&!(this.second<0))return!1;{let t=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),!0}}fromString(t){if("number"!=typeof this.tz)return this.fromDate(n(t,this.tz));{let e=n(t);this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply()}}findNext(t,e,r,i){return this._findMatch(t,e,r,i,1)}_findMatch(t,e,r,i,s){let a=this[e],n;r.lastDayOfMonth&&(n=this.getLastDayOfMonth(this.year,this.month));let o=r.starDOW||"day"!=e?void 0:new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),h=this[e]+i,l=1===s?t=>t<r[e].length:t=>t>=0;for(let u=h;l(u);u+=s){let s=r[e][u];if("day"===e&&!s){for(let t=0;t<r.nearestWeekdays.length;t++)if(r.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(-1===e)continue;if(e===u-i){s=1;break}}}if("day"===e&&r.lastWeekday&&u-i===this.getLastWeekday(this.year,this.month)&&(s=1),"day"===e&&r.lastDayOfMonth&&u-i==n&&(s=1),"day"===e&&!r.starDOW){let e=r.dayOfWeek[(o+(u-i-1))%7];if(e&&63&e)e=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-i,e);else if(e)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${e}`);s=r.useAndLogic||t.domAndDow||r.starDOM?s&&e:s||e}if(s)return this[e]=u-i,a!==this[e]?2:1}return 3}recurse(t,e,r){if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year+1;r<t.year.length&&r<1e4;r++)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(e,f[r][0],t,f[r][2]);if(i>1){let s=r+1;for(;s<f.length;)this[f[s][0]]=-f[s][2],s++;if(3===i){if(this[f[r][1]]++,this[f[r][0]]=-f[r][2],this.apply(),0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year]&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=t.year.length)return null}return this.recurse(t,e,0)}if(this.apply())return this.recurse(t,e,r-1)}return(r+=1)>=f.length?this:(t.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(t,e,r)}increment(t,e,r){return this.second+=void 0!==e.interval&&e.interval>1&&r?e.interval:1,this.ms=0,this.apply(),this.recurse(t,e,0)}decrement(t,e){return this.second-=void 0!==e.interval&&e.interval>1?e.interval:1,this.ms=0,this.apply(),this.recurseBackward(t,e,0,0)}recurseBackward(t,e,r,i=0){if(i>1e4)return null;if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year-1;r>=0;r--)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let s=this.findPrevious(e,f[r][0],t,f[r][2]);if(s>1){let a=r+1;for(;a<f.length;){let e=f[a][0],r=f[a][2],i=this.getMaxPatternValue(e,t,r);this[e]=i,a++}if(3===s){if(this[f[r][1]]--,0===r){let t=this.getLastDayOfMonth(this.year,this.month);this.day>t&&(this.day=t)}if(1===r)if(this.day<=0)this.day=1;else{let t=this.year,e=this.month;for(;e<0;)e+=12,t--;for(;e>11;)e-=12,t++;let r=1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate();this.day>r&&(this.day=r)}this.apply();let s=f[r][0],a=f[r][2],n=this.getMaxPatternValue(s,t,a);if("day"===s){let t=this.getLastDayOfMonth(this.year,this.month);this[s]=Math.min(n,t)}else this[s]=n;if(this.apply(),0===r){let e=f[1][2],r=Math.min(this.getMaxPatternValue("day",t,e),this.getLastDayOfMonth(this.year,this.month));r!==this.day&&(this.day=r,this.hour=this.getMaxPatternValue("hour",t,f[2][2]),this.minute=this.getMaxPatternValue("minute",t,f[3][2]),this.second=this.getMaxPatternValue("second",t,f[4][2]))}if(0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year];)this.year--;if(this.year<0)return null}return this.recurseBackward(t,e,0,i+1)}if(this.apply())return this.recurseBackward(t,e,r-1,i+1)}return(r+=1)>=f.length?this:this.year<0?null:this.recurseBackward(t,e,r,i+1)}getMaxPatternValue(t,e,r){if("day"===t&&e.lastDayOfMonth||"day"===t&&!e.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let i=e[t].length-1;i>=0;i--)if(e[t][i])return i-r;return e[t].length-1-r}findPrevious(t,e,r,i){return this._findMatch(t,e,r,i,-1)}getDate(t){return t||void 0===this.tz?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):"number"==typeof this.tz?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):o(l(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(t,e){if(!t.starYear&&(this.year<0||this.year>=t.year.length||0===t.year[this.year]))return!1;for(let r=0;r<f.length;r++){let i=f[r][0],s=f[r][2],a=this[i];if(a+s<0||a+s>=t[i].length)return!1;let n=t[i][a+s];if("day"===i){if(!n){for(let e=0;e<t.nearestWeekdays.length;e++)if(t.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-s);if(-1!==t&&t===a){n=1;break}}}if(t.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(n=1),t.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(n=1),!t.starDOW){let r=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),i=t.dayOfWeek[(r+(a-1))%7];i&&63&i&&(i=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,i)),n=t.useAndLogic||e.domAndDow||t.starDOM?n&&i:n||i}}if(!n)return!1}return!0}};function y(t){return"[object Function]"===Object.prototype.toString.call(t)||"function"==typeof t||t instanceof Function}var g=[],m=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(t){if(void 0!==this.options.dayOffset&&0!==this.options.dayOffset){let e=24*this.options.dayOffset*36e5;return new Date(t.getTime()+e)}return t}constructor(t,e,r){let i,s;if(y(e))s=e;else if("object"==typeof e)i=e;else if(void 0!==e)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))s=r;else if("object"==typeof r)i=r;else if(void 0!==r)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=function(t){if(void 0===t&&(t={}),delete t.name,void 0!==t.legacyMode&&void 0===t.domAndDow?t.domAndDow=!t.legacyMode:void 0===t.domAndDow&&(t.domAndDow=!1),t.legacyMode=!t.domAndDow,t.paused=void 0!==t.paused&&t.paused,t.maxRuns=void 0===t.maxRuns?1/0:t.maxRuns,t.catch=void 0!==t.catch&&t.catch,t.interval=void 0===t.interval?0:parseInt(t.interval.toString(),10),t.utcOffset=void 0===t.utcOffset?void 0:parseInt(t.utcOffset.toString(),10),t.dayOffset=void 0===t.dayOffset?0:parseInt(t.dayOffset.toString(),10),t.unref=void 0!==t.unref&&t.unref,t.mode=void 0===t.mode?"auto":t.mode,t.alternativeWeekdays=void 0!==t.alternativeWeekdays&&t.alternativeWeekdays,t.sloppyRanges=void 0!==t.sloppyRanges&&t.sloppyRanges,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(t.mode))throw Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(t.startAt&&(t.startAt=new p(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new p(t.stopAt,t.timezone)),null!==t.interval){if(isNaN(t.interval))throw Error("CronOptions: Supplied value for interval is not a number");if(t.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if(void 0!==t.utcOffset){if(isNaN(t.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(t.utcOffset<-870||t.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if(void 0!==t.utcOffset&&t.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(!0!==t.unref&&!1!==t.unref)throw Error("CronOptions: Unref should be either true, false or undefined(false).");if(void 0!==t.dayOffset&&0!==t.dayOffset&&isNaN(t.dayOffset))throw Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return t}(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:!!i&&i.paused,pattern:new d("* * * * *",void 0,{mode:"auto"})},t&&(t instanceof Date||"string"==typeof t&&t.indexOf(":")>0)?this._states.once=new p(t,this.getTz()):this._states.pattern=new d(t,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(g.find(t=>t.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");g.push(this)}return void 0!==s&&function(t){return y(t)}(s)&&(this.fn=s,this.schedule()),this}nextRun(t){let e=this._next(t);return e?this.applyDayOffset(e.getDate(!1)):null}nextRuns(t,e){void 0!==this._states.maxRuns&&t>this._states.maxRuns&&(t=this._states.maxRuns);let r=e||this._states.currentRun||void 0;return this._enumerateRuns(t,r,"next")}previousRuns(t,e){return this._enumerateRuns(t,e||void 0,"previous")}_enumerateRuns(t,e,r){let i=[],s=e?new p(e,this.getTz()):null,a="next"===r?this._next:this._previous;for(;t--;){let t=a.call(this,s);if(!t)break;let e=t.getDate(!1);i.push(this.applyDayOffset(e)),s=t}return i}match(t){if(this._states.once){let e=new p(t,this.getTz());e.ms=0;let r=new p(this._states.once,this.getTz());return r.ms=0,e.getTime()===r.getTime()}let e=new p(t,this.getTz());return e.ms=0,e.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let t=this.nextRun(this._states.currentRun),e=!this._states.paused,r=void 0!==this.fn,i=!this._states.kill;return e&&r&&i&&null!==t}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(t){let e=this._next(t);return e?t instanceof p||t instanceof Date?e.getTime()-t.getTime():e.getTime()-new p(t).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let t=g.indexOf(this);t>=0&&g.splice(t,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(t){var e;if(t&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");t&&(this.fn=t);let r=this.msToNext(),i=this.nextRun(this._states.currentRun);return null==r||isNaN(r)||null===i||(r>3e4&&(r=3e4),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(i),r),this._states.currentTimeout&&this.options.unref&&(e=this._states.currentTimeout,"u">typeof Deno&&"u">typeof Deno.unrefTimer?Deno.unrefTimer(e):e&&"u">typeof e.unref&&e.unref())),this}async _trigger(t){this._states.blocking=!0,this._states.currentRun=new p(void 0,this.getTz());try{if(this.options.catch)try{void 0!==this.fn&&await this.fn(this,this.options.context)}catch(t){if(y(this.options.catch))try{this.options.catch(t,this)}catch{}}else void 0!==this.fn&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new p(t,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(t){let e=new Date,r=!this._states.paused&&e.getTime()>=t.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(void 0!==this._states.maxRuns&&this._states.maxRuns--,this._trigger()):r&&i&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(t){let e=!!(t||this._states.currentRun),r=!1;!t&&this.options.startAt&&this.options.interval&&([t,e]=this._calculatePreviousRun(t,e),r=!t),t=new p(t,this.getTz()),this.options.startAt&&t&&t.getTime()<this.options.startAt.getTime()&&(t=this.options.startAt);let i=this._states.once||new p(t,this.getTz());return r||i===this._states.once||(i=i.increment(this._states.pattern,this.options,e)),this._states.once&&this._states.once.getTime()<=t.getTime()||null===i||void 0!==this._states.maxRuns&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_previous(t){let e=new p(t,this.getTz());this.options.stopAt&&e.getTime()>this.options.stopAt.getTime()&&(e=this.options.stopAt);let r=new p(e,this.getTz());return this._states.once?this._states.once.getTime()<e.getTime()?this._states.once:null:null===(r=r.decrement(this._states.pattern,this.options))||this.options.startAt&&r.getTime()<this.options.startAt.getTime()?null:r}_calculatePreviousRun(t,e){let r=new p(void 0,this.getTz()),i=t;if(this.options.startAt.getTime()<=r.getTime()){let t=(i=this.options.startAt).getTime()+1e3*this.options.interval;for(;t<=r.getTime();)t=(i=new p(i,this.getTz()).increment(this._states.pattern,this.options,!0)).getTime()+1e3*this.options.interval;e=!0}return null===i&&(i=void 0),[i,e]}},w=t.i(48044);let T=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var v=t.i(7367);!function(){try{let t=r.default.join((0,v.getSlycodeRoot)(),".env");for(let r of(0,e.readFileSync)(t,"utf-8").split("\n")){let t=r.trim();if(!t||t.startsWith("#"))continue;let e=t.indexOf("=");if(e<0)continue;let i=t.slice(0,e).trim(),s=t.slice(e+1).trim();process.env[i]||(process.env[i]=s)}}catch{}}();let C=(0,v.getBridgeUrl)(),D=process.env.TZ||"UTC",k=r.default.join(i.default.homedir(),".slycode","logs","automation.log");async function O(t,e){let r=new AbortController,i=setTimeout(()=>r.abort(),1e4);try{return await fetch(t,{...e,signal:r.signal})}finally{clearTimeout(i)}}async function S(t){try{let i=r.default.dirname(k);await e.promises.mkdir(i,{recursive:!0});let s=JSON.stringify(t)+"\n";await e.promises.appendFile(k,s);try{if((await e.promises.stat(k)).size>1e6){let t=(await e.promises.readFile(k,"utf-8")).trim().split("\n"),r=t.slice(Math.floor(t.length/2));await e.promises.writeFile(k,r.join("\n")+"\n")}}catch{}}catch(t){console.error("[scheduler] Failed to write automation log:",t)}}async function N(t){await new Promise(t=>setTimeout(t,2e4));try{let e=await O(`${C}/sessions/${encodeURIComponent(t)}`);if(!e.ok)return{status:"unknown"};let r=await e.json();if("stopped"===r.status)return{status:"stopped",exitCode:r.exitCode,exitedAt:r.exitedAt};if("running"===r.status||"detached"===r.status)return{status:"running"};return{status:"unknown"}}catch{return{status:"unknown"}}}function $(){try{let t=new Intl.DateTimeFormat("en-US",{timeZone:D,timeZoneName:"short"}).formatToParts(new Date),e=t.find(t=>"timeZoneName"===t.type)?.value||D;return{timezone:D,abbreviation:e}}catch{return{timezone:"UTC",abbreviation:"UTC"}}}let x="__scheduler_state__",_="__scheduler_timer__",A=globalThis;A[x]||(A[x]={running:!1,lastCheck:null,activeKickoffs:new Set}),void 0===A[_]&&(A[_]=null);let R=A[x];function U(){return A[_]??null}function b(t,e){if("one-shot"===e){let e=new Date(t);return isNaN(e.getTime())?null:e}try{return new m(t,{timezone:D}).nextRun()}catch{return null}}async function W(t){await new Promise(t=>setTimeout(t,1e4));let e=0;try{let r=await O(`${C}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;e=i.lastOutputAt?new Date(i.lastOutputAt).getTime():0}catch{return!1}await new Promise(t=>setTimeout(t,5e3));try{let r=await O(`${C}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;return(i.lastOutputAt?new Date(i.lastOutputAt).getTime():0)>e}catch{return!1}}function M(t){let e=t.toLocaleDateString("en-US",{weekday:"long",timeZone:D}),r=new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:D}).format(t),i=t.toLocaleDateString("en-US",{month:"short",timeZone:D}),s=new Intl.DateTimeFormat("en-US",{year:"numeric",timeZone:D}).format(t),a=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:D}),{abbreviation:n}=$();return`${e}, ${r} ${i} ${s}, ${a} ${n}`}async function P(t,e,r,i={trigger:"scheduled"}){let s=t.automation;if(!s)return{cardId:t.id,projectId:e,success:!1,error:"No automation config"};let a=s.provider||"claude",n=`${e}:${a}:card:${t.id}`,o=s.workingDirectory||r,h=[function(t,e,r){let i=new Date,s=["=== AUTOMATION RUN ==="];if(s.push(`Time: ${M(i)}`),s.push(`Card: ${t.title} (${t.id})`),"manual"===r)s.push("Trigger: manual");else{let t=function(t,e,r="Not set",i){if("one-shot"===e)try{let e=new Date(t);if(isNaN(e.getTime()))return t||r;return`Once on ${e.toLocaleDateString()} at ${e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}catch{return t||r}if(!t)return r;let s=t.split(" ");if(5!==s.length)return t;let[a,n,o,,h]=s,l=n.match(/^(\d+)-(\d+)\/(\d+)$/);if(l&&"*"===o&&"*"===h){let[,t,e,r]=l;return`Every ${r}h from ${t.padStart(2,"0")}:${a.padStart(2,"0")} to ${e.padStart(2,"0")}:${a.padStart(2,"0")}`}if(n.includes(",")&&"*"===o&&"*"===h){let t=n.split(",").map(Number);if(t.length>=2){let e=(t[1]-t[0]+24)%24;if(e>0){let r=String(t[0]).padStart(2,"0"),i=String(t[t.length-1]).padStart(2,"0");return`Every ${e}h from ${r}:${a.padStart(2,"0")} to ${i}:${a.padStart(2,"0")}`}}}if("*"===n&&"*"===o&&"*"===h)return`Every hour at :${a.padStart(2,"0")}`;if("*"===o&&"*"===h)return`Daily at ${n}:${a.padStart(2,"0")}`;if("*"===o&&"*"!==h){let t=h.split(",").map(t=>T[parseInt(t)]||t).join(", ");return`Weekly on ${t} at ${n}:${a.padStart(2,"0")}`}return"*"!==o&&"*"===h?`Monthly on day ${o} at ${n}:${a.padStart(2,"0")}`:t}(e.schedule,e.scheduleType);s.push(`Trigger: scheduled (${t.toLowerCase()})`)}if(e.lastRun){let t=new Date(e.lastRun);s.push(`Last run: ${M(t)} (${function(t,e){let r=e.getTime()-t.getTime();if(r<0)return"in the future";let i=Math.floor(r/6e4),s=Math.floor(i/60),a=Math.floor(s/24);return a>0?`${a}d ${s%24}h ago`:s>0?`${s}h ${i%60}m ago`:i>0?`${i}m ago`:"just now"}(t,i)})`)}else s.push("Last run: never");return s.push("======================"),s.join("\n")}(t,s,i.trigger),""];if(t.areas.length>0&&h.push(`Areas: ${t.areas.join(", ")}`),t.tags.length>0&&h.push(`Tags: ${t.tags.join(", ")}`),t.checklist.length>0){let e=t.checklist.filter(t=>!t.done);e.length>0&&h.push(`Pending checklist: ${e.map(t=>t.text).join("; ")}`)}h.push("","---","",t.description);let l=h.join("\n");s.reportViaMessaging&&(l+='\n\nAfter completing the task, send a summary of the results using the messaging skill: sly-messaging send "<your summary>"');let u=s.freshSession||!1,d=Date.now(),c=null,f=null,p=async r=>(await S({timestamp:new Date().toISOString(),cardId:t.id,cardTitle:t.title,projectId:e,trigger:i.trigger,provider:a,sessionName:n,fresh:u,bridgeRequest:c,livenessCheck:f,outcome:r.success?"success":"error",error:r.error||null,elapsedMs:Date.now()-d}),r);try{console.log(`[scheduler] Creating session: ${n} (fresh: ${u}, provider: ${a})`);let r=await O(`${C}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,provider:a,skipPermissions:!0,cwd:o,prompt:l,fresh:u})});if(r.ok||409!==r.status||u)if(r.ok){let t=await r.json();c={status:r.status,resumed:t.resumed,pid:t.pid},console.log(`[scheduler] Session created: ${n} (status: ${t.status}, resumed: ${t.resumed}, pid: ${t.pid})`)}else{let i;try{let t=await r.json();i=t.error||JSON.stringify(t)}catch{i=await r.text()}return c={status:r.status,error:i},p({cardId:t.id,projectId:e,success:!1,error:`Session create failed (${r.status}): ${i}`})}else{c={status:409},console.log(`[scheduler] Session ${n} returned 409, sending prompt via input endpoint`);let r=await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l})});if(r.ok&&(await new Promise(t=>setTimeout(t,600)),await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})})),!r.ok){let i=await r.text();return p({cardId:t.id,projectId:e,success:!1,error:`Input failed (${r.status}): ${i}`})}}if(u){let r=await N(n);if(f={type:"checkSessionAlive",result:r.status,delayMs:2e4,exitCode:r.exitCode,exitedAt:r.exitedAt},"stopped"===r.status){if(0===r.exitCode)return p({cardId:t.id,projectId:e,success:!0,sessionName:n});let i=void 0!==r.exitCode?` (exit code ${r.exitCode})`:"",s=r.exitedAt?`, alive ${((new Date(r.exitedAt).getTime()-d)/1e3).toFixed(1)}s`:"";return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:`Session stopped during startup${i}${s}`})}return p({cardId:t.id,projectId:e,success:!0,sessionName:n})}if(await W(n))return f={type:"waitForActivity",result:"active"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});console.log(`[scheduler] No activity for ${t.id} (resume path), retrying via input...`),await new Promise(t=>setTimeout(t,3e3));let i=`\x1b[200~${l}\x1b[201~`;if((await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:i})})).ok&&(await new Promise(t=>setTimeout(t,600)),await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})}),await W(n)))return f={type:"waitForActivity",result:"active (retry)"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});return f={type:"waitForActivity",result:"inactive after retry"},p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:"No activity detected after retry"})}catch(r){return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:r.message})}}async function I(t,i,s){let a=r.default.join(t,"documentation","kanban.json");try{let t=await e.promises.readFile(a,"utf-8"),r=JSON.parse(t);for(let t of Object.values(r.stages))for(let e of t)if(e.id===i&&e.automation){Object.assign(e.automation,s);break}await e.promises.writeFile(a,JSON.stringify(r,null,2)+"\n")}catch(t){console.error(`[scheduler] Failed to update card ${i}:`,t)}}async function E(e,r,i){try{let{execSync:s}=await t.A(44264),a=[`Automation failed: ${e}`];i&&a.push(`Session: ${i}`),a.push(`Error: ${r}`),a.push("Log: ~/.slycode/logs/automation.log");let n=a.join("\n").replace(/"/g,'\\"');s(`sly-messaging send "${n}"`,{timeout:1e4,stdio:"pipe"})}catch{console.error(`[scheduler] Failed to send error notification for "${e}"`)}}async function z(){R.lastCheck=new Date().toISOString();try{for(let t of(await (0,w.loadRegistry)()).projects){let i,s=r.default.join(t.path,"documentation","kanban.json");try{let t=await e.promises.readFile(s,"utf-8");i=JSON.parse(t)}catch{continue}for(let[,e]of Object.entries(i.stages))for(let r of e)r.automation&&r.automation.enabled&&!r.archived&&!R.activeKickoffs.has(r.id)&&function(t){if(!t.enabled||!t.schedule)return!1;if("one-shot"===t.scheduleType){let e=new Date(t.schedule);return!isNaN(e.getTime())&&e.getTime()<=Date.now()}try{let e=new m(t.schedule,{timezone:D}),r=Date.now(),i=new Date(t.lastRun?Math.max(new Date(t.lastRun).getTime(),r-6e4):r),s=e.nextRun(i);if(!s)return!1;return s.getTime()<=r}catch{return!1}}(r.automation)&&(R.activeKickoffs.add(r.id),await I(t.path,r.id,{lastRun:new Date().toISOString()}),(async()=>{try{console.log(`[scheduler] Firing automation: ${r.title} (${r.id})`);let e=await P(r,t.id,t.path),i={lastResult:e.success?"success":"error"};if("one-shot"===r.automation.scheduleType)i.enabled=!1;else{let t=b(r.automation.schedule,"recurring");t&&(i.nextRun=t.toISOString())}await I(t.path,r.id,i),e.success||(console.error(`[scheduler] Kickoff failed for ${r.id}: ${e.error}`),e.error&&(e.error.includes("Session create failed")||e.error.includes("Session stopped")||e.error.includes("Input failed")||e.error.includes("No automation config"))?await E(r.title,e.error||"Unknown error",e.sessionName):console.log(`[scheduler] Soft failure for ${r.id}, skipping notification: ${e.error}`))}catch(t){console.error(`[scheduler] Error processing ${r.id}:`,t)}finally{R.activeKickoffs.delete(r.id)}})())}}catch(t){console.error("[scheduler] Check loop error:",t)}}function j(){var t;let e=U();e&&(clearInterval(e),A[_]=null),R.running||(R.running=!0,console.log("[scheduler] Started. Checking every 30s."),z(),t=setInterval(z,3e4),A[_]=t)}function L(){if(!R.running)return;R.running=!1;let t=U();t&&(clearInterval(t),A[_]=null);console.log("[scheduler] Stopped.")}function F(){return R.running||(console.log("[scheduler] Auto-starting on status check"),j()),{running:R.running,lastCheck:R.lastCheck,activeKickoffs:Array.from(R.activeKickoffs)}}t.s(["getConfiguredTimezone",()=>$,"getNextRun",()=>b,"getSchedulerStatus",()=>F,"startScheduler",()=>j,"stopScheduler",()=>L,"triggerAutomation",()=>P,"updateCardAutomation",()=>I],32695)}];
1
+ module.exports=[32695,t=>{"use strict";var e=t.i(22734),r=t.i(14747),i=t.i(46786);function s(t){return Date.UTC(t.y,t.m-1,t.d,t.h,t.i,t.s)}function a(t,e){return t.y===e.y&&t.m===e.m&&t.d===e.d&&t.h===e.h&&t.i===e.i&&t.s===e.s}function n(t,e,r){return o(function(t,e){let r=new Date(Date.parse(t));if(isNaN(r))throw Error("Invalid ISO8601 passed to timezone parser.");let i=t.substring(9);return i.includes("Z")||i.includes("+")||i.includes("-")?l(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),"Etc/UTC"):l(r.getFullYear(),r.getMonth()+1,r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),e)}(t,e),r)}function o(t,e){let r=new Date(s(t)),i=h(r,t.tz),n=s(t),o=s(i),l=new Date(r.getTime()+(n-o)),u=h(l,t.tz);if(a(u,t)){let e=new Date(l.getTime()-36e5);return a(h(e,t.tz),t)?e:l}let d=new Date(l.getTime()+s(t)-s(u));if(a(h(d,t.tz),t))return d;if(e)throw Error("Invalid date passed to fromTZ()");return l.getTime()>d.getTime()?l:d}function h(t,e){let r;try{r=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(t)}catch(r){let t=r instanceof Error?r.message:String(r);throw RangeError(`toTZ: Invalid timezone '${e}' or date. Please provide a valid IANA timezone (e.g., 'America/New_York', 'Europe/Stockholm'). Original error: ${t}`)}let i={year:0,month:0,day:0,hour:0,minute:0,second:0};for(let t of r)("year"===t.type||"month"===t.type||"day"===t.type||"hour"===t.type||"minute"===t.type||"second"===t.type)&&(i[t.type]=parseInt(t.value,10));if(isNaN(i.year)||isNaN(i.month)||isNaN(i.day)||isNaN(i.hour)||isNaN(i.minute)||isNaN(i.second))throw Error(`toTZ: Failed to parse all date components from timezone '${e}'. This may indicate an invalid date or timezone configuration. Parsed components: ${JSON.stringify(i)}`);return 24===i.hour&&(i.hour=0),{y:i.year,m:i.month,d:i.day,h:i.hour,i:i.minute,s:i.second,tz:e}}function l(t,e,r,i,s,a,n){return{y:t,m:e,d:r,h:i,i:s,s:a,tz:n}}var u=[1,2,4,8,16],d=class{pattern;timezone;mode;alternativeWeekdays;sloppyRanges;second;minute;hour;day;month;dayOfWeek;year;lastDayOfMonth;lastWeekday;nearestWeekdays;starDOM;starDOW;starYear;useAndLogic;constructor(t,e,r){this.pattern=t,this.timezone=e,this.mode=r?.mode??"auto",this.alternativeWeekdays=r?.alternativeWeekdays??!1,this.sloppyRanges=r?.sloppyRanges??!1,this.second=Array(60).fill(0),this.minute=Array(60).fill(0),this.hour=Array(24).fill(0),this.day=Array(31).fill(0),this.month=Array(12).fill(0),this.dayOfWeek=Array(7).fill(0),this.year=Array(1e4).fill(0),this.lastDayOfMonth=!1,this.lastWeekday=!1,this.nearestWeekdays=Array(31).fill(0),this.starDOM=!1,this.starDOW=!1,this.starYear=!1,this.useAndLogic=!1,this.parse()}parse(){if(!("string"==typeof this.pattern||this.pattern instanceof String))throw TypeError("CronPattern: Pattern has to be of type string.");this.pattern.indexOf("@")>=0&&(this.pattern=this.handleNicknames(this.pattern).trim());let t=this.pattern.match(/\S+/g)||[""],e=t.length;if(t.length<5||t.length>7)throw TypeError("CronPattern: invalid configuration format ('"+this.pattern+"'), exactly five, six, or seven space separated parts are required.");if("auto"!==this.mode){let t;switch(this.mode){case"5-part":t=5;break;case"6-part":t=6;break;case"7-part":t=7;break;case"5-or-6-parts":t=[5,6];break;case"6-or-7-parts":t=[6,7];break;default:t=0}if(!(Array.isArray(t)?t.includes(e):e===t)){let r=Array.isArray(t)?t.join(" or "):t.toString();throw TypeError(`CronPattern: mode '${this.mode}' requires exactly ${r} parts, but pattern '${this.pattern}' has ${e} parts.`)}}if(5===t.length&&t.unshift("0"),6===t.length&&t.push("*"),"LW"===t[3].toUpperCase()?(this.lastWeekday=!0,t[3]=""):t[3].toUpperCase().indexOf("L")>=0&&(t[3]=t[3].replace(/L/gi,""),this.lastDayOfMonth=!0),"*"==t[3]&&(this.starDOM=!0),"*"==t[6]&&(this.starYear=!0),t[4].length>=3&&(t[4]=this.replaceAlphaMonths(t[4])),t[5].length>=3&&(t[5]=this.alternativeWeekdays?this.replaceAlphaDaysQuartz(t[5]):this.replaceAlphaDays(t[5])),t[5].startsWith("+")&&(this.useAndLogic=!0,t[5]=t[5].substring(1),""===t[5]))throw TypeError("CronPattern: Day-of-week field cannot be empty after '+' modifier.");switch("*"==t[5]&&(this.starDOW=!0),this.pattern.indexOf("?")>=0&&(t[0]=t[0].replace(/\?/g,"*"),t[1]=t[1].replace(/\?/g,"*"),t[2]=t[2].replace(/\?/g,"*"),t[3]=t[3].replace(/\?/g,"*"),t[4]=t[4].replace(/\?/g,"*"),t[5]=t[5].replace(/\?/g,"*"),t[6]&&(t[6]=t[6].replace(/\?/g,"*"))),this.mode){case"5-part":t[0]="0",t[6]="*";break;case"6-part":case"5-or-6-parts":t[6]="*"}this.throwAtIllegalCharacters(t),this.partToArray("second",t[0],0,1),this.partToArray("minute",t[1],0,1),this.partToArray("hour",t[2],0,1),this.partToArray("day",t[3],-1,1),this.partToArray("month",t[4],-1,1);let r=this.alternativeWeekdays?-1:0;this.partToArray("dayOfWeek",t[5],r,63),this.partToArray("year",t[6],0,1),!this.alternativeWeekdays&&this.dayOfWeek[7]&&(this.dayOfWeek[0]=this.dayOfWeek[7])}partToArray(t,e,r,i){let s=this[t],a="day"===t&&this.lastDayOfMonth,n="day"===t&&this.lastWeekday;if(""===e&&!a&&!n)throw TypeError("CronPattern: configuration entry "+t+" ("+e+") is empty, check for trailing spaces.");if("*"===e)return s.fill(i);let o=e.split(",");if(o.length>1)for(let e=0;e<o.length;e++)this.partToArray(t,o[e],r,i);else -1!==e.indexOf("-")&&-1!==e.indexOf("/")?this.handleRangeWithStepping(e,t,r,i):-1!==e.indexOf("-")?this.handleRange(e,t,r,i):-1!==e.indexOf("/")?this.handleStepping(e,t,r,i):""!==e&&this.handleNumber(e,t,r,i)}throwAtIllegalCharacters(t){for(let e=0;e<t.length;e++)if((3===e?/[^/*0-9,\-WwLl]+/:5===e?/[^/*0-9,\-#Ll]+/:/[^/*0-9,\-]+/).test(t[e]))throw TypeError("CronPattern: configuration entry "+e+" ("+t[e]+") contains illegal characters.")}handleNumber(t,e,r,i){let s=this.extractNth(t,e),a=t.toUpperCase().includes("W");if("day"!==e&&a)throw TypeError("CronPattern: Nearest weekday modifier (W) only allowed in day-of-month.");a&&(e="nearestWeekdays");let n=parseInt(s[0],10)+r;if(isNaN(n))throw TypeError("CronPattern: "+e+" is not a number: '"+t+"'");this.setPart(e,n,s[1]||i)}setPart(t,e,r){if(!Object.prototype.hasOwnProperty.call(this,t))throw TypeError("CronPattern: Invalid part specified: "+t);if("dayOfWeek"===t){if(7===e&&(e=0),e<0||e>6)throw RangeError("CronPattern: Invalid value for dayOfWeek: "+e);this.setNthWeekdayOfMonth(e,r);return}if("second"===t||"minute"===t){if(e<0||e>=60)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("hour"===t){if(e<0||e>=24)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("day"===t||"nearestWeekdays"===t){if(e<0||e>=31)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("month"===t){if(e<0||e>=12)throw RangeError("CronPattern: Invalid value for "+t+": "+e)}else if("year"===t&&(e<1||e>=1e4))throw RangeError("CronPattern: Invalid value for "+t+": "+e+" (supported range: 1-9999)");this[t][e]=r}validateNotNaN(t,e){if(isNaN(t))throw TypeError(e)}validateRange(t,e,r,i,s){if(t>e)throw TypeError("CronPattern: From value is larger than to value: '"+s+"'");if(void 0!==r){if(0===r)throw TypeError("CronPattern: Syntax error, illegal stepping: 0");if(r>this[i].length)throw TypeError("CronPattern: Syntax error, steps cannot be greater than maximum value of part ("+this[i].length+")")}}handleRangeWithStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in ranges with stepping.");let s=this.extractNth(t,e),a=s[0].match(/^(\d+)-(\d+)\/(\d+)$/);if(null===a)throw TypeError("CronPattern: Syntax error, illegal range with stepping: '"+t+"'");let[,n,o,h]=a,l=parseInt(n,10)+r,u=parseInt(o,10)+r,d=parseInt(h,10);this.validateNotNaN(l,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(u,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateNotNaN(d,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(l,u,d,e,t);for(let t=l;t<=u;t+=d)this.setPart(e,t,s[1]||i)}extractNth(t,e){let r=t,i;if(r.includes("#")){if("dayOfWeek"!==e)throw Error("CronPattern: nth (#) only allowed in day-of-week field");i=r.split("#")[1],r=r.split("#")[0]}else if(r.toUpperCase().endsWith("L")){if("dayOfWeek"!==e)throw Error("CronPattern: L modifier only allowed in day-of-week field (use L alone for day-of-month)");i="L",r=r.slice(0,-1)}return[r,i]}handleRange(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in a range.");let s=this.extractNth(t,e),a=s[0].split("-");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal range: '"+t+"'");let n=parseInt(a[0],10)+r,o=parseInt(a[1],10)+r;this.validateNotNaN(n,"CronPattern: Syntax error, illegal lower range (NaN)"),this.validateNotNaN(o,"CronPattern: Syntax error, illegal upper range (NaN)"),this.validateRange(n,o,void 0,e,t);for(let t=n;t<=o;t++)this.setPart(e,t,s[1]||i)}handleStepping(t,e,r,i){if(t.toUpperCase().includes("W"))throw TypeError("CronPattern: Syntax error, W is not allowed in parts with stepping.");let s=this.extractNth(t,e),a=s[0].split("/");if(2!==a.length)throw TypeError("CronPattern: Syntax error, illegal stepping: '"+t+"'");if(this.sloppyRanges)""===a[0]&&(a[0]="*");else{if(""===a[0])throw TypeError("CronPattern: Syntax error, stepping with missing prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.");if("*"!==a[0])throw TypeError("CronPattern: Syntax error, stepping with numeric prefix ('"+t+"') is not allowed. Use wildcard (*/step) or range (min-max/step) instead.")}let n=0;"*"!==a[0]&&(n=parseInt(a[0],10)+r);let o=parseInt(a[1],10);this.validateNotNaN(o,"CronPattern: Syntax error, illegal stepping: (NaN)"),this.validateRange(0,this[e].length-1,o,e,t);for(let t=n;t<this[e].length;t+=o)this.setPart(e,t,s[1]||i)}replaceAlphaDays(t){return t.replace(/-sun/gi,"-7").replace(/sun/gi,"0").replace(/mon/gi,"1").replace(/tue/gi,"2").replace(/wed/gi,"3").replace(/thu/gi,"4").replace(/fri/gi,"5").replace(/sat/gi,"6")}replaceAlphaDaysQuartz(t){return t.replace(/sun/gi,"1").replace(/mon/gi,"2").replace(/tue/gi,"3").replace(/wed/gi,"4").replace(/thu/gi,"5").replace(/fri/gi,"6").replace(/sat/gi,"7")}replaceAlphaMonths(t){return t.replace(/jan/gi,"1").replace(/feb/gi,"2").replace(/mar/gi,"3").replace(/apr/gi,"4").replace(/may/gi,"5").replace(/jun/gi,"6").replace(/jul/gi,"7").replace(/aug/gi,"8").replace(/sep/gi,"9").replace(/oct/gi,"10").replace(/nov/gi,"11").replace(/dec/gi,"12")}handleNicknames(t){let e=t.trim().toLowerCase();if("@yearly"===e||"@annually"===e)return"0 0 1 1 *";if("@monthly"===e)return"0 0 1 * *";if("@weekly"===e)return"0 0 * * 0";if("@daily"===e||"@midnight"===e)return"0 0 * * *";if("@hourly"===e)return"0 * * * *";if("@reboot"===e)throw TypeError("CronPattern: @reboot is not supported in this environment. This is an event-based trigger that requires system startup detection.");return t}setNthWeekdayOfMonth(t,e){if("number"!=typeof e&&"L"===e.toUpperCase())this.dayOfWeek[t]=32|this.dayOfWeek[t];else if(63===e)this.dayOfWeek[t]=63;else if(e<6&&e>0)this.dayOfWeek[t]=this.dayOfWeek[t]|u[e-1];else throw TypeError(`CronPattern: nth weekday out of range, should be 1-5 or L. Value: ${e}, Type: ${typeof e}`)}},c=[31,28,31,30,31,30,31,31,30,31,30,31],f=[["month","year",0],["day","month",-1],["hour","day",0],["minute","hour",0],["second","minute",0]],p=class t{tz;ms;second;minute;hour;day;month;year;constructor(e,r){if(this.tz=r,e&&e instanceof Date)if(isNaN(e))throw TypeError("CronDate: Invalid date passed to CronDate constructor");else this.fromDate(e);else if(null==e)this.fromDate(new Date);else if(e&&"string"==typeof e)this.fromString(e);else if(e instanceof t)this.fromCronDate(e);else throw TypeError("CronDate: Invalid type ("+typeof e+") passed to CronDate constructor")}getLastDayOfMonth(t,e){return 1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate()}getLastWeekday(t,e){let r=this.getLastDayOfMonth(t,e),i=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===i?r-2:6===i?r-1:r}getNearestWeekday(t,e,r){let i=this.getLastDayOfMonth(t,e);if(r>i)return -1;let s=new Date(Date.UTC(t,e,r)).getUTCDay();return 0===s?r===i?r-2:r+1:6===s?1===r?r+2:r-1:r}isNthWeekdayOfMonth(t,e,r,i){let s=new Date(Date.UTC(t,e,r)).getUTCDay(),a=0;for(let i=1;i<=r;i++)new Date(Date.UTC(t,e,i)).getUTCDay()===s&&a++;if(63&i&&u[a-1]&i)return!0;if(32&i){let i=this.getLastDayOfMonth(t,e);for(let a=r+1;a<=i;a++)if(new Date(Date.UTC(t,e,a)).getUTCDay()===s)return!1;return!0}return!1}fromDate(t){if(void 0!==this.tz)if("number"==typeof this.tz)this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes()+this.tz,this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),this.apply();else try{let e=h(t,this.tz);this.ms=t.getMilliseconds(),this.second=e.s,this.minute=e.i,this.hour=e.h,this.day=e.d,this.month=e.m-1,this.year=e.y}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`CronDate: Failed to convert date to timezone '${this.tz}'. This may happen with invalid timezone names or dates. Original error: ${t}`)}else this.ms=t.getMilliseconds(),this.second=t.getSeconds(),this.minute=t.getMinutes(),this.hour=t.getHours(),this.day=t.getDate(),this.month=t.getMonth(),this.year=t.getFullYear()}fromCronDate(t){this.tz=t.tz,this.year=t.year,this.month=t.month,this.day=t.day,this.hour=t.hour,this.minute=t.minute,this.second=t.second,this.ms=t.ms}apply(){if(!(this.month>11)&&!(this.month<0)&&!(this.day>c[this.month])&&!(this.day<1)&&!(this.hour>59)&&!(this.minute>59)&&!(this.second>59)&&!(this.hour<0)&&!(this.minute<0)&&!(this.second<0))return!1;{let t=new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms));return this.ms=t.getUTCMilliseconds(),this.second=t.getUTCSeconds(),this.minute=t.getUTCMinutes(),this.hour=t.getUTCHours(),this.day=t.getUTCDate(),this.month=t.getUTCMonth(),this.year=t.getUTCFullYear(),!0}}fromString(t){if("number"!=typeof this.tz)return this.fromDate(n(t,this.tz));{let e=n(t);this.ms=e.getUTCMilliseconds(),this.second=e.getUTCSeconds(),this.minute=e.getUTCMinutes(),this.hour=e.getUTCHours(),this.day=e.getUTCDate(),this.month=e.getUTCMonth(),this.year=e.getUTCFullYear(),this.apply()}}findNext(t,e,r,i){return this._findMatch(t,e,r,i,1)}_findMatch(t,e,r,i,s){let a=this[e],n;r.lastDayOfMonth&&(n=this.getLastDayOfMonth(this.year,this.month));let o=r.starDOW||"day"!=e?void 0:new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),h=this[e]+i,l=1===s?t=>t<r[e].length:t=>t>=0;for(let u=h;l(u);u+=s){let s=r[e][u];if("day"===e&&!s){for(let t=0;t<r.nearestWeekdays.length;t++)if(r.nearestWeekdays[t]){let e=this.getNearestWeekday(this.year,this.month,t-i);if(-1===e)continue;if(e===u-i){s=1;break}}}if("day"===e&&r.lastWeekday&&u-i===this.getLastWeekday(this.year,this.month)&&(s=1),"day"===e&&r.lastDayOfMonth&&u-i==n&&(s=1),"day"===e&&!r.starDOW){let e=r.dayOfWeek[(o+(u-i-1))%7];if(e&&63&e)e=+!!this.isNthWeekdayOfMonth(this.year,this.month,u-i,e);else if(e)throw Error(`CronDate: Invalid value for dayOfWeek encountered. ${e}`);s=r.useAndLogic||t.domAndDow||r.starDOM?s&&e:s||e}if(s)return this[e]=u-i,a!==this[e]?2:1}return 3}recurse(t,e,r){if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year+1;r<t.year.length&&r<1e4;r++)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=0,this.day=1,this.hour=0,this.minute=0,this.second=0,this.ms=0}if(this.year>=1e4)return null}let i=this.findNext(e,f[r][0],t,f[r][2]);if(i>1){let s=r+1;for(;s<f.length;)this[f[s][0]]=-f[s][2],s++;if(3===i){if(this[f[r][1]]++,this[f[r][0]]=-f[r][2],this.apply(),0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year]&&this.year<1e4;)this.year++;if(this.year>=1e4||this.year>=t.year.length)return null}return this.recurse(t,e,0)}if(this.apply())return this.recurse(t,e,r-1)}return(r+=1)>=f.length?this:(t.starYear?this.year>=3e3:this.year>=1e4)?null:this.recurse(t,e,r)}increment(t,e,r){return this.second+=void 0!==e.interval&&e.interval>1&&r?e.interval:1,this.ms=0,this.apply(),this.recurse(t,e,0)}decrement(t,e){return this.second-=void 0!==e.interval&&e.interval>1?e.interval:1,this.ms=0,this.apply(),this.recurseBackward(t,e,0,0)}recurseBackward(t,e,r,i=0){if(i>1e4)return null;if(0===r&&!t.starYear){if(this.year>=0&&this.year<t.year.length&&0===t.year[this.year]){let e=-1;for(let r=this.year-1;r>=0;r--)if(1===t.year[r]){e=r;break}if(-1===e)return null;this.year=e,this.month=11,this.day=31,this.hour=23,this.minute=59,this.second=59,this.ms=0}if(this.year<0)return null}let s=this.findPrevious(e,f[r][0],t,f[r][2]);if(s>1){let a=r+1;for(;a<f.length;){let e=f[a][0],r=f[a][2],i=this.getMaxPatternValue(e,t,r);this[e]=i,a++}if(3===s){if(this[f[r][1]]--,0===r){let t=this.getLastDayOfMonth(this.year,this.month);this.day>t&&(this.day=t)}if(1===r)if(this.day<=0)this.day=1;else{let t=this.year,e=this.month;for(;e<0;)e+=12,t--;for(;e>11;)e-=12,t++;let r=1!==e?c[e]:new Date(Date.UTC(t,e+1,0)).getUTCDate();this.day>r&&(this.day=r)}this.apply();let s=f[r][0],a=f[r][2],n=this.getMaxPatternValue(s,t,a);if("day"===s){let t=this.getLastDayOfMonth(this.year,this.month);this[s]=Math.min(n,t)}else this[s]=n;if(this.apply(),0===r){let e=f[1][2],r=Math.min(this.getMaxPatternValue("day",t,e),this.getLastDayOfMonth(this.year,this.month));r!==this.day&&(this.day=r,this.hour=this.getMaxPatternValue("hour",t,f[2][2]),this.minute=this.getMaxPatternValue("minute",t,f[3][2]),this.second=this.getMaxPatternValue("second",t,f[4][2]))}if(0===r&&!t.starYear){for(;this.year>=0&&this.year<t.year.length&&0===t.year[this.year];)this.year--;if(this.year<0)return null}return this.recurseBackward(t,e,0,i+1)}if(this.apply())return this.recurseBackward(t,e,r-1,i+1)}return(r+=1)>=f.length?this:this.year<0?null:this.recurseBackward(t,e,r,i+1)}getMaxPatternValue(t,e,r){if("day"===t&&e.lastDayOfMonth||"day"===t&&!e.starDOW)return this.getLastDayOfMonth(this.year,this.month);for(let i=e[t].length-1;i>=0;i--)if(e[t][i])return i-r;return e[t].length-1-r}findPrevious(t,e,r,i){return this._findMatch(t,e,r,i,-1)}getDate(t){return t||void 0===this.tz?new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.ms):"number"==typeof this.tz?new Date(Date.UTC(this.year,this.month,this.day,this.hour,this.minute-this.tz,this.second,this.ms)):o(l(this.year,this.month+1,this.day,this.hour,this.minute,this.second,this.tz),!1)}getTime(){return this.getDate(!1).getTime()}match(t,e){if(!t.starYear&&(this.year<0||this.year>=t.year.length||0===t.year[this.year]))return!1;for(let r=0;r<f.length;r++){let i=f[r][0],s=f[r][2],a=this[i];if(a+s<0||a+s>=t[i].length)return!1;let n=t[i][a+s];if("day"===i){if(!n){for(let e=0;e<t.nearestWeekdays.length;e++)if(t.nearestWeekdays[e]){let t=this.getNearestWeekday(this.year,this.month,e-s);if(-1!==t&&t===a){n=1;break}}}if(t.lastWeekday&&a===this.getLastWeekday(this.year,this.month)&&(n=1),t.lastDayOfMonth&&a===this.getLastDayOfMonth(this.year,this.month)&&(n=1),!t.starDOW){let r=new Date(Date.UTC(this.year,this.month,1,0,0,0,0)).getUTCDay(),i=t.dayOfWeek[(r+(a-1))%7];i&&63&i&&(i=+!!this.isNthWeekdayOfMonth(this.year,this.month,a,i)),n=t.useAndLogic||e.domAndDow||t.starDOM?n&&i:n||i}}if(!n)return!1}return!0}};function y(t){return"[object Function]"===Object.prototype.toString.call(t)||"function"==typeof t||t instanceof Function}var g=[],m=class{name;options;_states;fn;getTz(){return this.options.timezone||this.options.utcOffset}applyDayOffset(t){if(void 0!==this.options.dayOffset&&0!==this.options.dayOffset){let e=24*this.options.dayOffset*36e5;return new Date(t.getTime()+e)}return t}constructor(t,e,r){let i,s;if(y(e))s=e;else if("object"==typeof e)i=e;else if(void 0!==e)throw Error("Cron: Invalid argument passed for optionsIn. Should be one of function, or object (options).");if(y(r))s=r;else if("object"==typeof r)i=r;else if(void 0!==r)throw Error("Cron: Invalid argument passed for funcIn. Should be one of function, or object (options).");if(this.name=i?.name,this.options=function(t){if(void 0===t&&(t={}),delete t.name,void 0!==t.legacyMode&&void 0===t.domAndDow?t.domAndDow=!t.legacyMode:void 0===t.domAndDow&&(t.domAndDow=!1),t.legacyMode=!t.domAndDow,t.paused=void 0!==t.paused&&t.paused,t.maxRuns=void 0===t.maxRuns?1/0:t.maxRuns,t.catch=void 0!==t.catch&&t.catch,t.interval=void 0===t.interval?0:parseInt(t.interval.toString(),10),t.utcOffset=void 0===t.utcOffset?void 0:parseInt(t.utcOffset.toString(),10),t.dayOffset=void 0===t.dayOffset?0:parseInt(t.dayOffset.toString(),10),t.unref=void 0!==t.unref&&t.unref,t.mode=void 0===t.mode?"auto":t.mode,t.alternativeWeekdays=void 0!==t.alternativeWeekdays&&t.alternativeWeekdays,t.sloppyRanges=void 0!==t.sloppyRanges&&t.sloppyRanges,!["auto","5-part","6-part","7-part","5-or-6-parts","6-or-7-parts"].includes(t.mode))throw Error("CronOptions: mode must be one of 'auto', '5-part', '6-part', '7-part', '5-or-6-parts', or '6-or-7-parts'.");if(t.startAt&&(t.startAt=new p(t.startAt,t.timezone)),t.stopAt&&(t.stopAt=new p(t.stopAt,t.timezone)),null!==t.interval){if(isNaN(t.interval))throw Error("CronOptions: Supplied value for interval is not a number");if(t.interval<0)throw Error("CronOptions: Supplied value for interval can not be negative")}if(void 0!==t.utcOffset){if(isNaN(t.utcOffset))throw Error("CronOptions: Invalid value passed for utcOffset, should be number representing minutes offset from UTC.");if(t.utcOffset<-870||t.utcOffset>870)throw Error("CronOptions: utcOffset out of bounds.");if(void 0!==t.utcOffset&&t.timezone)throw Error("CronOptions: Combining 'utcOffset' with 'timezone' is not allowed.")}if(!0!==t.unref&&!1!==t.unref)throw Error("CronOptions: Unref should be either true, false or undefined(false).");if(void 0!==t.dayOffset&&0!==t.dayOffset&&isNaN(t.dayOffset))throw Error("CronOptions: Invalid value passed for dayOffset, should be a number representing days to offset.");return t}(i),this._states={kill:!1,blocking:!1,previousRun:void 0,currentRun:void 0,once:void 0,currentTimeout:void 0,maxRuns:i?i.maxRuns:void 0,paused:!!i&&i.paused,pattern:new d("* * * * *",void 0,{mode:"auto"})},t&&(t instanceof Date||"string"==typeof t&&t.indexOf(":")>0)?this._states.once=new p(t,this.getTz()):this._states.pattern=new d(t,this.options.timezone,{mode:this.options.mode,alternativeWeekdays:this.options.alternativeWeekdays,sloppyRanges:this.options.sloppyRanges}),this.name){if(g.find(t=>t.name===this.name))throw Error("Cron: Tried to initialize new named job '"+this.name+"', but name already taken.");g.push(this)}return void 0!==s&&function(t){return y(t)}(s)&&(this.fn=s,this.schedule()),this}nextRun(t){let e=this._next(t);return e?this.applyDayOffset(e.getDate(!1)):null}nextRuns(t,e){void 0!==this._states.maxRuns&&t>this._states.maxRuns&&(t=this._states.maxRuns);let r=e||this._states.currentRun||void 0;return this._enumerateRuns(t,r,"next")}previousRuns(t,e){return this._enumerateRuns(t,e||void 0,"previous")}_enumerateRuns(t,e,r){let i=[],s=e?new p(e,this.getTz()):null,a="next"===r?this._next:this._previous;for(;t--;){let t=a.call(this,s);if(!t)break;let e=t.getDate(!1);i.push(this.applyDayOffset(e)),s=t}return i}match(t){if(this._states.once){let e=new p(t,this.getTz());e.ms=0;let r=new p(this._states.once,this.getTz());return r.ms=0,e.getTime()===r.getTime()}let e=new p(t,this.getTz());return e.ms=0,e.match(this._states.pattern,this.options)}getPattern(){if(!this._states.once)return this._states.pattern?this._states.pattern.pattern:void 0}getOnce(){return this._states.once?this._states.once.getDate():null}isRunning(){let t=this.nextRun(this._states.currentRun),e=!this._states.paused,r=void 0!==this.fn,i=!this._states.kill;return e&&r&&i&&null!==t}isStopped(){return this._states.kill}isBusy(){return this._states.blocking}currentRun(){return this._states.currentRun?this._states.currentRun.getDate():null}previousRun(){return this._states.previousRun?this._states.previousRun.getDate():null}msToNext(t){let e=this._next(t);return e?t instanceof p||t instanceof Date?e.getTime()-t.getTime():e.getTime()-new p(t).getTime():null}stop(){this._states.kill=!0,this._states.currentTimeout&&clearTimeout(this._states.currentTimeout);let t=g.indexOf(this);t>=0&&g.splice(t,1)}pause(){return this._states.paused=!0,!this._states.kill}resume(){return this._states.paused=!1,!this._states.kill}schedule(t){var e;if(t&&this.fn)throw Error("Cron: It is not allowed to schedule two functions using the same Croner instance.");t&&(this.fn=t);let r=this.msToNext(),i=this.nextRun(this._states.currentRun);return null==r||isNaN(r)||null===i||(r>3e4&&(r=3e4),this._states.currentTimeout=setTimeout(()=>this._checkTrigger(i),r),this._states.currentTimeout&&this.options.unref&&(e=this._states.currentTimeout,"u">typeof Deno&&"u">typeof Deno.unrefTimer?Deno.unrefTimer(e):e&&"u">typeof e.unref&&e.unref())),this}async _trigger(t){this._states.blocking=!0,this._states.currentRun=new p(void 0,this.getTz());try{if(this.options.catch)try{void 0!==this.fn&&await this.fn(this,this.options.context)}catch(t){if(y(this.options.catch))try{this.options.catch(t,this)}catch{}}else void 0!==this.fn&&await this.fn(this,this.options.context)}finally{this._states.previousRun=new p(t,this.getTz()),this._states.blocking=!1}}async trigger(){await this._trigger()}runsLeft(){return this._states.maxRuns}_checkTrigger(t){let e=new Date,r=!this._states.paused&&e.getTime()>=t.getTime(),i=this._states.blocking&&this.options.protect;r&&!i?(void 0!==this._states.maxRuns&&this._states.maxRuns--,this._trigger()):r&&i&&y(this.options.protect)&&setTimeout(()=>this.options.protect(this),0),this.schedule()}_next(t){let e=!!(t||this._states.currentRun),r=!1;!t&&this.options.startAt&&this.options.interval&&([t,e]=this._calculatePreviousRun(t,e),r=!t),t=new p(t,this.getTz()),this.options.startAt&&t&&t.getTime()<this.options.startAt.getTime()&&(t=this.options.startAt);let i=this._states.once||new p(t,this.getTz());return r||i===this._states.once||(i=i.increment(this._states.pattern,this.options,e)),this._states.once&&this._states.once.getTime()<=t.getTime()||null===i||void 0!==this._states.maxRuns&&this._states.maxRuns<=0||this._states.kill||this.options.stopAt&&i.getTime()>=this.options.stopAt.getTime()?null:i}_previous(t){let e=new p(t,this.getTz());this.options.stopAt&&e.getTime()>this.options.stopAt.getTime()&&(e=this.options.stopAt);let r=new p(e,this.getTz());return this._states.once?this._states.once.getTime()<e.getTime()?this._states.once:null:null===(r=r.decrement(this._states.pattern,this.options))||this.options.startAt&&r.getTime()<this.options.startAt.getTime()?null:r}_calculatePreviousRun(t,e){let r=new p(void 0,this.getTz()),i=t;if(this.options.startAt.getTime()<=r.getTime()){let t=(i=this.options.startAt).getTime()+1e3*this.options.interval;for(;t<=r.getTime();)t=(i=new p(i,this.getTz()).increment(this._states.pattern,this.options,!0)).getTime()+1e3*this.options.interval;e=!0}return null===i&&(i=void 0),[i,e]}},w=t.i(48044);let T=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var v=t.i(7367);!function(){try{let t=r.default.join((0,v.getSlycodeRoot)(),".env");for(let r of(0,e.readFileSync)(t,"utf-8").split("\n")){let t=r.trim();if(!t||t.startsWith("#"))continue;let e=t.indexOf("=");if(e<0)continue;let i=t.slice(0,e).trim(),s=t.slice(e+1).trim();process.env[i]||(process.env[i]=s)}}catch{}}();let C=(0,v.getBridgeUrl)(),D=process.env.TZ||"UTC",k=r.default.join(i.default.homedir(),".slycode","logs","automation.log");async function O(t,e){let r=new AbortController,i=setTimeout(()=>r.abort(),1e4);try{return await fetch(t,{...e,signal:r.signal})}finally{clearTimeout(i)}}async function N(t){try{let i=r.default.dirname(k);await e.promises.mkdir(i,{recursive:!0});let s=JSON.stringify(t)+"\n";await e.promises.appendFile(k,s);try{if((await e.promises.stat(k)).size>1e6){let t=(await e.promises.readFile(k,"utf-8")).trim().split("\n"),r=t.slice(Math.floor(t.length/2));await e.promises.writeFile(k,r.join("\n")+"\n")}}catch{}}catch(t){console.error("[scheduler] Failed to write automation log:",t)}}async function S(t){await new Promise(t=>setTimeout(t,2e4));try{let e=await O(`${C}/sessions/${encodeURIComponent(t)}`);if(!e.ok)return{status:"unknown"};let r=await e.json();if("stopped"===r.status)return{status:"stopped",exitCode:r.exitCode,exitedAt:r.exitedAt};if("running"===r.status||"detached"===r.status)return{status:"running"};return{status:"unknown"}}catch{return{status:"unknown"}}}function $(){try{let t=new Intl.DateTimeFormat("en-US",{timeZone:D,timeZoneName:"short"}).formatToParts(new Date),e=t.find(t=>"timeZoneName"===t.type)?.value||D;return{timezone:D,abbreviation:e}}catch{return{timezone:"UTC",abbreviation:"UTC"}}}let x="__scheduler_state__",_="__scheduler_timer__",A=globalThis;A[x]||(A[x]={running:!1,lastCheck:null,activeKickoffs:new Set}),void 0===A[_]&&(A[_]=null);let R=A[x];function U(){return A[_]??null}function b(t,e){if("one-shot"===e){let e=new Date(t);return isNaN(e.getTime())?null:e}try{return new m(t,{timezone:D}).nextRun()}catch{return null}}async function W(t){await new Promise(t=>setTimeout(t,1e4));let e=0;try{let r=await O(`${C}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;e=i.lastOutputAt?new Date(i.lastOutputAt).getTime():0}catch{return!1}await new Promise(t=>setTimeout(t,5e3));try{let r=await O(`${C}/sessions/${encodeURIComponent(t)}`);if(!r.ok)return!1;let i=await r.json();if("stopped"===i.status)return!1;return(i.lastOutputAt?new Date(i.lastOutputAt).getTime():0)>e}catch{return!1}}function M(t){let e=t.toLocaleDateString("en-US",{weekday:"long",timeZone:D}),r=new Intl.DateTimeFormat("en-US",{day:"numeric",timeZone:D}).format(t),i=t.toLocaleDateString("en-US",{month:"short",timeZone:D}),s=new Intl.DateTimeFormat("en-US",{year:"numeric",timeZone:D}).format(t),a=t.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1,timeZone:D}),{abbreviation:n}=$();return`${e}, ${r} ${i} ${s}, ${a} ${n}`}async function P(t,e,r,i={trigger:"scheduled"}){let s=t.automation;if(!s)return{cardId:t.id,projectId:e,success:!1,error:"No automation config"};let a=s.provider||"claude",n=`${e}:${a}:card:${t.id}`,o=s.workingDirectory||r,h=[function(t,e,r){let i=new Date,s=["=== AUTOMATION RUN ==="];if(s.push(`Time: ${M(i)}`),s.push(`Card: ${t.title} (${t.id})`),"manual"===r)s.push("Trigger: manual");else{let t=function(t,e,r="Not set",i){if("one-shot"===e)try{let e=new Date(t);if(isNaN(e.getTime()))return t||r;return`Once on ${e.toLocaleDateString()} at ${e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`}catch{return t||r}if(!t)return r;let s=t.split(" ");if(5!==s.length)return t;let[a,n,o,,h]=s,l=n.match(/^(\d+)-(\d+)\/(\d+)$/);if(l&&"*"===o&&"*"===h){let[,t,e,r]=l;return`Every ${r}h from ${t.padStart(2,"0")}:${a.padStart(2,"0")} to ${e.padStart(2,"0")}:${a.padStart(2,"0")}`}if(n.includes(",")&&"*"===o&&"*"===h){let t=n.split(",").map(Number);if(t.length>=2){let e=(t[1]-t[0]+24)%24;if(e>0){let r=String(t[0]).padStart(2,"0"),i=String(t[t.length-1]).padStart(2,"0");return`Every ${e}h from ${r}:${a.padStart(2,"0")} to ${i}:${a.padStart(2,"0")}`}}}if("*"===n&&"*"===o&&"*"===h)return`Every hour at :${a.padStart(2,"0")}`;if("*"===o&&"*"===h)return`Daily at ${n}:${a.padStart(2,"0")}`;if("*"===o&&"*"!==h){let t=h.split(",").map(t=>T[parseInt(t)]||t).join(", ");return`Weekly on ${t} at ${n}:${a.padStart(2,"0")}`}return"*"!==o&&"*"===h?`Monthly on day ${o} at ${n}:${a.padStart(2,"0")}`:t}(e.schedule,e.scheduleType);s.push(`Trigger: scheduled (${t.toLowerCase()})`)}if(e.lastRun){let t=new Date(e.lastRun);s.push(`Last run: ${M(t)} (${function(t,e){let r=e.getTime()-t.getTime();if(r<0)return"in the future";let i=Math.floor(r/6e4),s=Math.floor(i/60),a=Math.floor(s/24);return a>0?`${a}d ${s%24}h ago`:s>0?`${s}h ${i%60}m ago`:i>0?`${i}m ago`:"just now"}(t,i)})`)}else s.push("Last run: never");return s.push("======================"),s.join("\n")}(t,s,i.trigger),""];if(t.areas.length>0&&h.push(`Areas: ${t.areas.join(", ")}`),t.tags.length>0&&h.push(`Tags: ${t.tags.join(", ")}`),t.checklist.length>0){let e=t.checklist.filter(t=>!t.done);e.length>0&&h.push(`Pending checklist: ${e.map(t=>t.text).join("; ")}`)}h.push("","---","",t.description);let l=h.join("\n");s.reportViaMessaging&&(l+='\n\nAfter completing the task, send a summary of the results using the messaging skill: sly-messaging send "<your summary>"');let u=s.freshSession||!1,d=Date.now(),c=null,f=null,p=async r=>(await N({timestamp:new Date().toISOString(),cardId:t.id,cardTitle:t.title,projectId:e,trigger:i.trigger,provider:a,sessionName:n,fresh:u,bridgeRequest:c,livenessCheck:f,outcome:r.success?"success":"error",error:r.error||null,elapsedMs:Date.now()-d}),r);try{console.log(`[scheduler] Creating session: ${n} (fresh: ${u}, provider: ${a})`);let r=await O(`${C}/sessions`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,provider:a,skipPermissions:!0,cwd:o,prompt:l,fresh:u})});if(r.ok||409!==r.status||u)if(r.ok){let t=await r.json();c={status:r.status,resumed:t.resumed,pid:t.pid},console.log(`[scheduler] Session created: ${n} (status: ${t.status}, resumed: ${t.resumed}, pid: ${t.pid})`)}else{let i;try{let t=await r.json();i=t.error||JSON.stringify(t)}catch{i=await r.text()}return c={status:r.status,error:i},p({cardId:t.id,projectId:e,success:!1,error:`Session create failed (${r.status}): ${i}`})}else{c={status:409},console.log(`[scheduler] Session ${n} returned 409, sending prompt via input endpoint`);let r=await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:l})});if(r.ok&&(await new Promise(t=>setTimeout(t,600)),await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})})),!r.ok){let i=await r.text();return p({cardId:t.id,projectId:e,success:!1,error:`Input failed (${r.status}): ${i}`})}}if(u){let r=await S(n);if(f={type:"checkSessionAlive",result:r.status,delayMs:2e4,exitCode:r.exitCode,exitedAt:r.exitedAt},"stopped"===r.status){if(0===r.exitCode)return p({cardId:t.id,projectId:e,success:!0,sessionName:n});let i=void 0!==r.exitCode?` (exit code ${r.exitCode})`:"",s=r.exitedAt?`, alive ${((new Date(r.exitedAt).getTime()-d)/1e3).toFixed(1)}s`:"";return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:`Session stopped during startup${i}${s}`})}return p({cardId:t.id,projectId:e,success:!0,sessionName:n})}if(await W(n))return f={type:"waitForActivity",result:"active"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});console.log(`[scheduler] No activity for ${t.id} (resume path), retrying via input...`),await new Promise(t=>setTimeout(t,3e3));let i=`\x1b[200~${l}\x1b[201~`;if((await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:i})})).ok&&(await new Promise(t=>setTimeout(t,600)),await O(`${C}/sessions/${encodeURIComponent(n)}/input`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:"\r"})}),await W(n)))return f={type:"waitForActivity",result:"active (retry)"},p({cardId:t.id,projectId:e,success:!0,sessionName:n});return f={type:"waitForActivity",result:"inactive after retry"},p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:"No activity detected after retry"})}catch(r){return p({cardId:t.id,projectId:e,success:!1,sessionName:n,error:r.message})}}async function I(t,i,s){let a=r.default.join(t,"documentation","kanban.json");try{let t=await e.promises.readFile(a,"utf-8"),r=JSON.parse(t);for(let t of Object.values(r.stages))for(let e of t)if(e.id===i&&e.automation){Object.assign(e.automation,s);break}await e.promises.writeFile(a,JSON.stringify(r,null,2)+"\n")}catch(t){console.error(`[scheduler] Failed to update card ${i}:`,t)}}async function E(e,r,i){try{let{execSync:s}=await t.A(44264),a=[`Automation failed: ${e}`];i&&a.push(`Session: ${i}`),a.push(`Error: ${r}`),a.push("Log: ~/.slycode/logs/automation.log");let n=a.join("\n").replace(/"/g,'\\"');s(`sly-messaging send "${n}"`,{timeout:1e4,stdio:"pipe"})}catch{console.error(`[scheduler] Failed to send error notification for "${e}"`)}}async function z(){R.lastCheck=new Date().toISOString();try{for(let t of(await (0,w.loadRegistry)()).projects){let i,s=r.default.join(t.path,"documentation","kanban.json");try{let t=await e.promises.readFile(s,"utf-8");i=JSON.parse(t)}catch{continue}for(let[,e]of Object.entries(i.stages))for(let r of e)r.automation&&r.automation.enabled&&!r.archived&&!R.activeKickoffs.has(r.id)&&function(t){if(!t.enabled||!t.schedule)return!1;if("one-shot"===t.scheduleType){let e=new Date(t.schedule);return!isNaN(e.getTime())&&e.getTime()<=Date.now()}try{let e=new m(t.schedule,{timezone:D}),r=Date.now(),i=new Date(t.lastRun?Math.max(new Date(t.lastRun).getTime(),r-6e4):r),s=e.nextRun(i);if(!s)return!1;return s.getTime()<=r}catch{return!1}}(r.automation)&&(R.activeKickoffs.add(r.id),await I(t.path,r.id,{lastRun:new Date().toISOString()}),(async()=>{try{console.log(`[scheduler] Firing automation: ${r.title} (${r.id})`);let e=await P(r,t.id,t.path),i={lastResult:e.success?"success":"error"};if("one-shot"===r.automation.scheduleType)i.enabled=!1;else{let t=b(r.automation.schedule,"recurring");t&&(i.nextRun=t.toISOString())}await I(t.path,r.id,i),e.success||(console.error(`[scheduler] Kickoff failed for ${r.id}: ${e.error}`),e.error&&(e.error.includes("Session create failed")||e.error.includes("Session stopped")||e.error.includes("Input failed")||e.error.includes("No automation config")||e.error.includes("No activity detected"))?await E(r.title,e.error||"Unknown error",e.sessionName):console.log(`[scheduler] Soft failure for ${r.id}, skipping notification: ${e.error}`))}catch(t){console.error(`[scheduler] Error processing ${r.id}:`,t)}finally{R.activeKickoffs.delete(r.id)}})())}}catch(t){console.error("[scheduler] Check loop error:",t)}}function j(){var t;let e=U();e&&(clearInterval(e),A[_]=null),R.running||(R.running=!0,console.log("[scheduler] Started. Checking every 30s."),z(),t=setInterval(z,3e4),A[_]=t)}function L(){if(!R.running)return;R.running=!1;let t=U();t&&(clearInterval(t),A[_]=null);console.log("[scheduler] Stopped.")}function F(){return R.running||(console.log("[scheduler] Auto-starting on status check"),j()),{running:R.running,lastCheck:R.lastCheck,activeKickoffs:Array.from(R.activeKickoffs)}}t.s(["getConfiguredTimezone",()=>$,"getNextRun",()=>b,"getSchedulerStatus",()=>F,"startScheduler",()=>j,"stopScheduler",()=>L,"triggerAutomation",()=>P,"updateCardAutomation",()=>I],32695)}];
2
2
 
3
3
  //# sourceMappingURL=src_lib_scheduler_ts_7120457c._.js.map