@slycode/slycode 0.2.22 → 0.2.24

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 (176) 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/response-store.d.ts +46 -0
  10. package/dist/bridge/response-store.js +95 -0
  11. package/dist/bridge/response-store.js.map +1 -0
  12. package/dist/bridge/session-manager.d.ts +33 -1
  13. package/dist/bridge/session-manager.js +185 -2
  14. package/dist/bridge/session-manager.js.map +1 -1
  15. package/dist/bridge/types.d.ts +37 -0
  16. package/dist/data/scaffold-templates/tutorial-project/documentation/kanban.json +1 -1
  17. package/dist/messaging/bridge-client.d.ts +4 -0
  18. package/dist/messaging/bridge-client.js +20 -1
  19. package/dist/messaging/bridge-client.js.map +1 -1
  20. package/dist/messaging/index.js +38 -10
  21. package/dist/messaging/index.js.map +1 -1
  22. package/dist/scripts/kanban.js +448 -2
  23. package/dist/scripts/scaffold.js +40 -1
  24. package/dist/store/actions/approve.md +1 -1
  25. package/dist/store/actions/challenge-implementation.md +149 -0
  26. package/dist/store/actions/challenge.md +119 -0
  27. package/dist/store/actions/checkpoint.md +2 -2
  28. package/dist/store/actions/context.md +3 -3
  29. package/dist/store/actions/create-card.md +1 -1
  30. package/dist/store/actions/deep-design.md +13 -3
  31. package/dist/store/actions/design-requirements.md +11 -1
  32. package/dist/store/actions/explore.md +1 -1
  33. package/dist/store/actions/implement.md +1 -1
  34. package/dist/store/actions/onboard.md +2 -4
  35. package/dist/store/actions/show-card.md +2 -2
  36. package/dist/store/actions/summarize.md +3 -3
  37. package/dist/store/actions/test-review.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/changelog/route/app-paths-manifest.json +3 -0
  61. package/dist/web/.next/server/app/api/changelog/route/build-manifest.json +11 -0
  62. package/dist/web/.next/server/app/api/changelog/route/server-reference-manifest.json +4 -0
  63. package/dist/web/.next/server/app/api/changelog/route.js +7 -0
  64. package/dist/web/.next/server/app/api/changelog/route.js.map +5 -0
  65. package/dist/web/.next/server/app/api/changelog/route.js.nft.json +1 -0
  66. package/dist/web/.next/server/app/api/changelog/route_client-reference-manifest.js +2 -0
  67. package/dist/web/.next/server/app/api/cli-assets/assistant/route.js.nft.json +1 -1
  68. package/dist/web/.next/server/app/api/cli-assets/fix/route.js.nft.json +1 -1
  69. package/dist/web/.next/server/app/api/cli-assets/import/route.js.nft.json +1 -1
  70. package/dist/web/.next/server/app/api/cli-assets/route.js.nft.json +1 -1
  71. package/dist/web/.next/server/app/api/cli-assets/store/preview/route.js.nft.json +1 -1
  72. package/dist/web/.next/server/app/api/cli-assets/store/route.js.nft.json +1 -1
  73. package/dist/web/.next/server/app/api/cli-assets/sync/route.js.nft.json +1 -1
  74. package/dist/web/.next/server/app/api/cli-assets/updates/route.js.nft.json +1 -1
  75. package/dist/web/.next/server/app/api/dashboard/route.js.nft.json +1 -1
  76. package/dist/web/.next/server/app/api/file/route.js.nft.json +1 -1
  77. package/dist/web/.next/server/app/api/git-status/route.js.nft.json +1 -1
  78. package/dist/web/.next/server/app/api/kanban/route.js.nft.json +1 -1
  79. package/dist/web/.next/server/app/api/kanban/stream/route.js.nft.json +1 -1
  80. package/dist/web/.next/server/app/api/projects/[id]/route.js.nft.json +1 -1
  81. package/dist/web/.next/server/app/api/projects/reorder/route.js.nft.json +1 -1
  82. package/dist/web/.next/server/app/api/projects/route.js.nft.json +1 -1
  83. package/dist/web/.next/server/app/api/scheduler/route.js.nft.json +1 -1
  84. package/dist/web/.next/server/app/api/search/route.js.nft.json +1 -1
  85. package/dist/web/.next/server/app/api/sly-actions/invalidate/route.js.nft.json +1 -1
  86. package/dist/web/.next/server/app/api/sly-actions/route.js.nft.json +1 -1
  87. package/dist/web/.next/server/app/api/version-check/route.js.nft.json +1 -1
  88. package/dist/web/.next/server/app/page.js.nft.json +1 -1
  89. package/dist/web/.next/server/app/page_client-reference-manifest.js +1 -1
  90. package/dist/web/.next/server/app/project/[id]/page.js.nft.json +1 -1
  91. package/dist/web/.next/server/app/project/[id]/page_client-reference-manifest.js +1 -1
  92. package/dist/web/.next/server/app-paths-manifest.json +1 -0
  93. package/dist/web/.next/server/chunks/[root-of-the-server]__92f81907._.js +1 -1
  94. package/dist/web/.next/server/chunks/[root-of-the-server]__a259539f._.js +3 -0
  95. package/dist/web/.next/server/chunks/_next-internal_server_app_api_changelog_route_actions_d6e239bf.js +3 -0
  96. package/dist/web/.next/server/chunks/node_modules_next_dist_esm_build_templates_app-route_18324462.js +1 -1
  97. package/dist/web/.next/server/chunks/src_lib_scheduler_ts_03988e3e._.js +1 -1
  98. package/dist/web/.next/server/chunks/src_lib_scheduler_ts_7120457c._.js +1 -1
  99. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__1f5fc489._.js +4 -3
  100. package/dist/web/.next/server/chunks/ssr/{[root-of-the-server]__077f472c._.js → [root-of-the-server]__6183d28c._.js} +1 -1
  101. package/dist/web/.next/server/chunks/ssr/[root-of-the-server]__bcbe4bf2._.js +4 -3
  102. package/dist/web/.next/server/chunks/ssr/src_components_Dashboard_tsx_efc4dc27._.js +1 -1
  103. package/dist/web/.next/server/chunks/ssr/src_components_c4135402._.js +1 -1
  104. package/dist/web/.next/server/chunks/ssr/src_contexts_VoiceContext_tsx_cfba7292._.js +1 -1
  105. package/dist/web/.next/server/pages/404.html +1 -1
  106. package/dist/web/.next/server/pages/500.html +2 -2
  107. package/dist/web/.next/server/server-reference-manifest.js +1 -1
  108. package/dist/web/.next/server/server-reference-manifest.json +1 -1
  109. package/dist/web/.next/static/chunks/293449b828207656.css +1 -0
  110. package/dist/web/.next/static/chunks/{8415039c5941cf5c.js → 3a5721af09d1c753.js} +4 -3
  111. package/dist/web/.next/static/chunks/{8fb2a99c64580de7.js → 98311243e9a5a0ec.js} +1 -1
  112. package/dist/web/.next/static/chunks/{b8e0c1aeea4a14bc.js → a47f36b030917d1f.js} +1 -1
  113. package/dist/web/.next/static/chunks/d60c422421920130.js +5 -0
  114. package/dist/web/.next/static/chunks/{f55f3c8c1a52f80c.js → f566a4b05a9cd6ba.js} +1 -1
  115. package/dist/web/.next/static/chunks/{4049cceee6a49323.js → fa78afe3ceed998b.js} +1 -1
  116. package/dist/web/src/app/api/changelog/route.ts +45 -0
  117. package/dist/web/src/app/api/kanban/route.ts +52 -12
  118. package/dist/web/src/app/api/terminal-classes/route.ts +43 -4
  119. package/dist/web/src/components/ActivityFeed.tsx +3 -0
  120. package/dist/web/src/components/BranchTab.tsx +115 -0
  121. package/dist/web/src/components/ChangelogModal.tsx +233 -0
  122. package/dist/web/src/components/Dashboard.tsx +11 -0
  123. package/dist/web/src/components/GlobalClaudePanel.tsx +6 -0
  124. package/dist/web/src/components/ProjectKanban.tsx +38 -8
  125. package/dist/web/src/components/VersionUpdateToast.tsx +6 -4
  126. package/dist/web/src/components/VoiceControlBar.tsx +1 -1
  127. package/dist/web/src/lib/scheduler.ts +2 -1
  128. package/dist/web/src/lib/types.ts +24 -0
  129. package/dist/web/tsconfig.tsbuildinfo +1 -1
  130. package/lib/cli/sync.d.ts +7 -0
  131. package/lib/cli/sync.d.ts.map +1 -1
  132. package/lib/cli/sync.js +25 -0
  133. package/lib/cli/sync.js.map +1 -1
  134. package/lib/cli/update.d.ts.map +1 -1
  135. package/lib/cli/update.js +9 -0
  136. package/lib/cli/update.js.map +1 -1
  137. package/package.json +1 -1
  138. package/templates/changelog.json +268 -0
  139. package/templates/kanban-seed.json +1 -1
  140. package/templates/store/actions/approve.md +1 -1
  141. package/templates/store/actions/challenge-implementation.md +149 -0
  142. package/templates/store/actions/challenge.md +119 -0
  143. package/templates/store/actions/checkpoint.md +2 -2
  144. package/templates/store/actions/context.md +3 -3
  145. package/templates/store/actions/create-card.md +1 -1
  146. package/templates/store/actions/deep-design.md +13 -3
  147. package/templates/store/actions/design-requirements.md +11 -1
  148. package/templates/store/actions/explore.md +1 -1
  149. package/templates/store/actions/implement.md +1 -1
  150. package/templates/store/actions/onboard.md +2 -4
  151. package/templates/store/actions/show-card.md +2 -2
  152. package/templates/store/actions/summarize.md +3 -3
  153. package/templates/store/actions/test-review.md +1 -1
  154. package/templates/store/skills/kanban/SKILL.md +77 -3
  155. package/templates/terminal-classes.json +51 -0
  156. package/templates/tutorial-project/documentation/kanban.json +1 -1
  157. package/templates/updates/actions/approve.md +1 -1
  158. package/templates/updates/actions/challenge-implementation.md +149 -0
  159. package/templates/updates/actions/challenge.md +119 -0
  160. package/templates/updates/actions/checkpoint.md +2 -2
  161. package/templates/updates/actions/context.md +3 -3
  162. package/templates/updates/actions/create-card.md +1 -1
  163. package/templates/updates/actions/deep-design.md +13 -3
  164. package/templates/updates/actions/design-requirements.md +11 -1
  165. package/templates/updates/actions/explore.md +1 -1
  166. package/templates/updates/actions/implement.md +1 -1
  167. package/templates/updates/actions/onboard.md +2 -4
  168. package/templates/updates/actions/show-card.md +2 -2
  169. package/templates/updates/actions/summarize.md +3 -3
  170. package/templates/updates/actions/test-review.md +1 -1
  171. package/templates/updates/skills/kanban/SKILL.md +77 -3
  172. package/dist/web/.next/static/chunks/18cfbdd7e977bb01.css +0 -1
  173. package/dist/web/.next/static/chunks/a0f5f9cdee8a22c1.js +0 -4
  174. /package/dist/web/.next/static/{b2V8jC3HBMi4vgm7Kie3H → O1Ine2WtyXv6EQJcwHyOV}/_buildManifest.js +0 -0
  175. /package/dist/web/.next/static/{b2V8jC3HBMi4vgm7Kie3H → O1Ine2WtyXv6EQJcwHyOV}/_clientMiddlewareManifest.json +0 -0
  176. /package/dist/web/.next/static/{b2V8jC3HBMi4vgm7Kie3H → O1Ine2WtyXv6EQJcwHyOV}/_ssgManifest.js +0 -0
@@ -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