@headless-lms/server 0.2.0 → 0.4.0

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 (351) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +5 -0
  2. package/dist/app/community-mail.d.ts +24 -0
  3. package/dist/app/community-mail.js +92 -0
  4. package/dist/app/community-mail.js.map +1 -0
  5. package/dist/app/container.d.ts +40 -19
  6. package/dist/app/container.js +294 -45
  7. package/dist/app/container.js.map +1 -1
  8. package/dist/app/mcp-endpoints.d.ts +13 -0
  9. package/dist/app/mcp-endpoints.js +25 -0
  10. package/dist/app/mcp-endpoints.js.map +1 -0
  11. package/dist/app/notification-channels.d.ts +47 -0
  12. package/dist/app/notification-channels.js +174 -0
  13. package/dist/app/notification-channels.js.map +1 -0
  14. package/dist/app/notification-reads.d.ts +23 -0
  15. package/dist/app/notification-reads.js +95 -0
  16. package/dist/app/notification-reads.js.map +1 -0
  17. package/dist/http/config.d.ts +2 -1
  18. package/dist/http/errors.d.ts +15 -0
  19. package/dist/http/errors.js +162 -0
  20. package/dist/http/errors.js.map +1 -0
  21. package/dist/http/mcp/catalogue.d.ts +37 -0
  22. package/dist/http/mcp/catalogue.js +69 -0
  23. package/dist/http/mcp/catalogue.js.map +1 -0
  24. package/dist/http/mcp/challenge.d.ts +7 -0
  25. package/dist/http/mcp/challenge.js +35 -0
  26. package/dist/http/mcp/challenge.js.map +1 -0
  27. package/dist/http/mcp/input-schema.d.ts +7 -0
  28. package/dist/http/mcp/input-schema.js +28 -0
  29. package/dist/http/mcp/input-schema.js.map +1 -0
  30. package/dist/http/mcp/route.d.ts +8 -0
  31. package/dist/http/mcp/route.js +75 -0
  32. package/dist/http/mcp/route.js.map +1 -0
  33. package/dist/http/mcp/server.d.ts +8 -0
  34. package/dist/http/mcp/server.js +31 -0
  35. package/dist/http/mcp/server.js.map +1 -0
  36. package/dist/http/mcp/test-support.d.ts +55 -0
  37. package/dist/http/mcp/test-support.js +151 -0
  38. package/dist/http/mcp/test-support.js.map +1 -0
  39. package/dist/http/mcp/tool.d.ts +48 -0
  40. package/dist/http/mcp/tool.js +58 -0
  41. package/dist/http/mcp/tool.js.map +1 -0
  42. package/dist/http/mcp/tools/automations.d.ts +6 -0
  43. package/dist/http/mcp/tools/automations.js +120 -0
  44. package/dist/http/mcp/tools/automations.js.map +1 -0
  45. package/dist/http/mcp/tools/catalog.d.ts +6 -0
  46. package/dist/http/mcp/tools/catalog.js +200 -0
  47. package/dist/http/mcp/tools/catalog.js.map +1 -0
  48. package/dist/http/mcp/tools/comments.d.ts +6 -0
  49. package/dist/http/mcp/tools/comments.js +70 -0
  50. package/dist/http/mcp/tools/comments.js.map +1 -0
  51. package/dist/http/mcp/tools/communities.d.ts +6 -0
  52. package/dist/http/mcp/tools/communities.js +175 -0
  53. package/dist/http/mcp/tools/communities.js.map +1 -0
  54. package/dist/http/mcp/tools/community-members.d.ts +6 -0
  55. package/dist/http/mcp/tools/community-members.js +89 -0
  56. package/dist/http/mcp/tools/community-members.js.map +1 -0
  57. package/dist/http/mcp/tools/community-moderation.d.ts +6 -0
  58. package/dist/http/mcp/tools/community-moderation.js +144 -0
  59. package/dist/http/mcp/tools/community-moderation.js.map +1 -0
  60. package/dist/http/mcp/tools/courses.d.ts +6 -0
  61. package/dist/http/mcp/tools/courses.js +121 -0
  62. package/dist/http/mcp/tools/courses.js.map +1 -0
  63. package/dist/http/mcp/tools/index.d.ts +6 -0
  64. package/dist/http/mcp/tools/index.js +23 -0
  65. package/dist/http/mcp/tools/index.js.map +1 -0
  66. package/dist/http/mcp/tools/people.d.ts +6 -0
  67. package/dist/http/mcp/tools/people.js +145 -0
  68. package/dist/http/mcp/tools/people.js.map +1 -0
  69. package/dist/http/plugins/auth.js +13 -5
  70. package/dist/http/plugins/auth.js.map +1 -1
  71. package/dist/http/plugins/error-handler.d.ts +2 -1
  72. package/dist/http/plugins/error-handler.js +51 -65
  73. package/dist/http/plugins/error-handler.js.map +1 -1
  74. package/dist/http/plugins/openapi.js +49 -2
  75. package/dist/http/plugins/openapi.js.map +1 -1
  76. package/dist/http/routes/access.d.ts +7 -0
  77. package/dist/http/routes/access.js +140 -0
  78. package/dist/http/routes/access.js.map +1 -0
  79. package/dist/http/routes/activities.js +68 -23
  80. package/dist/http/routes/activities.js.map +1 -1
  81. package/dist/http/routes/assets.js +60 -55
  82. package/dist/http/routes/assets.js.map +1 -1
  83. package/dist/http/routes/automations.js +44 -24
  84. package/dist/http/routes/automations.js.map +1 -1
  85. package/dist/http/routes/bundles.js +29 -18
  86. package/dist/http/routes/bundles.js.map +1 -1
  87. package/dist/http/routes/communities.d.ts +7 -0
  88. package/dist/http/routes/communities.js +522 -0
  89. package/dist/http/routes/communities.js.map +1 -0
  90. package/dist/http/routes/community-moderation.d.ts +7 -0
  91. package/dist/http/routes/community-moderation.js +425 -0
  92. package/dist/http/routes/community-moderation.js.map +1 -0
  93. package/dist/http/routes/course-analytics.js +9 -7
  94. package/dist/http/routes/course-analytics.js.map +1 -1
  95. package/dist/http/routes/courses.js +30 -15
  96. package/dist/http/routes/courses.js.map +1 -1
  97. package/dist/http/routes/dashboard.js +15 -6
  98. package/dist/http/routes/dashboard.js.map +1 -1
  99. package/dist/http/routes/discussion.js +34 -26
  100. package/dist/http/routes/discussion.js.map +1 -1
  101. package/dist/http/routes/downloads.js +48 -30
  102. package/dist/http/routes/downloads.js.map +1 -1
  103. package/dist/http/routes/entitlements.js +16 -7
  104. package/dist/http/routes/entitlements.js.map +1 -1
  105. package/dist/http/routes/integrations.js +38 -41
  106. package/dist/http/routes/integrations.js.map +1 -1
  107. package/dist/http/routes/member/actor.d.ts +14 -0
  108. package/dist/http/routes/member/actor.js +11 -0
  109. package/dist/http/routes/member/actor.js.map +1 -0
  110. package/dist/http/routes/member/assets.d.ts +7 -0
  111. package/dist/http/routes/member/assets.js +79 -0
  112. package/dist/http/routes/member/assets.js.map +1 -0
  113. package/dist/http/routes/member/chats.d.ts +7 -0
  114. package/dist/http/routes/member/chats.js +435 -0
  115. package/dist/http/routes/member/chats.js.map +1 -0
  116. package/dist/http/routes/member/comments.d.ts +7 -0
  117. package/dist/http/routes/member/comments.js +187 -0
  118. package/dist/http/routes/member/comments.js.map +1 -0
  119. package/dist/http/routes/member/community.d.ts +7 -0
  120. package/dist/http/routes/member/community.js +312 -0
  121. package/dist/http/routes/member/community.js.map +1 -0
  122. package/dist/http/routes/member/courses.d.ts +7 -0
  123. package/dist/http/routes/member/courses.js +101 -0
  124. package/dist/http/routes/member/courses.js.map +1 -0
  125. package/dist/http/routes/member/devices.d.ts +7 -0
  126. package/dist/http/routes/member/devices.js +98 -0
  127. package/dist/http/routes/member/devices.js.map +1 -0
  128. package/dist/http/routes/member/downloads.d.ts +7 -0
  129. package/dist/http/routes/member/downloads.js +56 -0
  130. package/dist/http/routes/member/downloads.js.map +1 -0
  131. package/dist/http/routes/member/files.d.ts +7 -0
  132. package/dist/http/routes/member/files.js +184 -0
  133. package/dist/http/routes/member/files.js.map +1 -0
  134. package/dist/http/routes/member/index.d.ts +7 -0
  135. package/dist/http/routes/member/index.js +35 -0
  136. package/dist/http/routes/member/index.js.map +1 -0
  137. package/dist/http/routes/member/notification-settings.d.ts +7 -0
  138. package/dist/http/routes/member/notification-settings.js +108 -0
  139. package/dist/http/routes/member/notification-settings.js.map +1 -0
  140. package/dist/http/routes/member/notifications.d.ts +7 -0
  141. package/dist/http/routes/member/notifications.js +125 -0
  142. package/dist/http/routes/member/notifications.js.map +1 -0
  143. package/dist/http/routes/member/org.d.ts +7 -0
  144. package/dist/http/routes/member/org.js +56 -0
  145. package/dist/http/routes/member/org.js.map +1 -0
  146. package/dist/http/routes/member/posts.d.ts +7 -0
  147. package/dist/http/routes/member/posts.js +612 -0
  148. package/dist/http/routes/member/posts.js.map +1 -0
  149. package/dist/http/routes/member/profile.d.ts +7 -0
  150. package/dist/http/routes/member/profile.js +48 -0
  151. package/dist/http/routes/member/profile.js.map +1 -0
  152. package/dist/http/routes/member/progress.d.ts +7 -0
  153. package/dist/http/routes/member/progress.js +60 -0
  154. package/dist/http/routes/member/progress.js.map +1 -0
  155. package/dist/http/routes/organizations.js +171 -25
  156. package/dist/http/routes/organizations.js.map +1 -1
  157. package/dist/http/routes/students.js +32 -47
  158. package/dist/http/routes/students.js.map +1 -1
  159. package/dist/http/routes/webhooks.js +26 -18
  160. package/dist/http/routes/webhooks.js.map +1 -1
  161. package/dist/http/routes.js +8 -2
  162. package/dist/http/routes.js.map +1 -1
  163. package/dist/http/schemas/access.d.ts +146 -0
  164. package/dist/http/schemas/access.js +36 -0
  165. package/dist/http/schemas/access.js.map +1 -0
  166. package/dist/http/schemas/activities.d.ts +3 -1
  167. package/dist/http/schemas/activities.js +4 -4
  168. package/dist/http/schemas/activities.js.map +1 -1
  169. package/dist/http/schemas/assets.d.ts +79 -80
  170. package/dist/http/schemas/assets.js +23 -13
  171. package/dist/http/schemas/assets.js.map +1 -1
  172. package/dist/http/schemas/automations.d.ts +6 -0
  173. package/dist/http/schemas/bundles.js +6 -6
  174. package/dist/http/schemas/bundles.js.map +1 -1
  175. package/dist/http/schemas/chats.d.ts +409 -0
  176. package/dist/http/schemas/chats.js +56 -0
  177. package/dist/http/schemas/chats.js.map +1 -0
  178. package/dist/http/schemas/community.d.ts +597 -0
  179. package/dist/http/schemas/community.js +132 -0
  180. package/dist/http/schemas/community.js.map +1 -0
  181. package/dist/http/schemas/content.d.ts +4 -2
  182. package/dist/http/schemas/content.js +11 -8
  183. package/dist/http/schemas/content.js.map +1 -1
  184. package/dist/http/schemas/discussion.d.ts +98 -14
  185. package/dist/http/schemas/discussion.js +25 -12
  186. package/dist/http/schemas/discussion.js.map +1 -1
  187. package/dist/http/schemas/downloads.d.ts +11 -5
  188. package/dist/http/schemas/downloads.js +14 -11
  189. package/dist/http/schemas/downloads.js.map +1 -1
  190. package/dist/http/schemas/entitlements.d.ts +6 -6
  191. package/dist/http/schemas/entitlements.js +6 -6
  192. package/dist/http/schemas/entitlements.js.map +1 -1
  193. package/dist/http/schemas/files.d.ts +45 -0
  194. package/dist/http/schemas/files.js +25 -0
  195. package/dist/http/schemas/files.js.map +1 -0
  196. package/dist/http/schemas/index.d.ts +15 -8
  197. package/dist/http/schemas/index.js +15 -8
  198. package/dist/http/schemas/integrations.d.ts +4 -4
  199. package/dist/http/schemas/invites.d.ts +4 -0
  200. package/dist/http/schemas/invites.js +1 -0
  201. package/dist/http/schemas/invites.js.map +1 -1
  202. package/dist/http/schemas/{learn.d.ts → member.d.ts} +31 -18
  203. package/dist/http/schemas/{learn.js → member.js} +17 -13
  204. package/dist/http/schemas/member.js.map +1 -0
  205. package/dist/http/schemas/members.d.ts +35 -2
  206. package/dist/http/schemas/members.js +17 -3
  207. package/dist/http/schemas/members.js.map +1 -1
  208. package/dist/http/schemas/notifications.d.ts +550 -0
  209. package/dist/http/schemas/notifications.js +164 -0
  210. package/dist/http/schemas/notifications.js.map +1 -0
  211. package/dist/http/schemas/posts.d.ts +350 -0
  212. package/dist/http/schemas/posts.js +47 -0
  213. package/dist/http/schemas/posts.js.map +1 -0
  214. package/dist/http/schemas/profile.d.ts +23 -0
  215. package/dist/http/schemas/profile.js +15 -0
  216. package/dist/http/schemas/profile.js.map +1 -0
  217. package/dist/http/schemas/shared.d.ts +32 -1
  218. package/dist/http/schemas/shared.js +20 -2
  219. package/dist/http/schemas/shared.js.map +1 -1
  220. package/dist/http/schemas/students.d.ts +1 -7
  221. package/dist/http/schemas/students.js +1 -7
  222. package/dist/http/schemas/students.js.map +1 -1
  223. package/dist/http/scope.d.ts +3 -1
  224. package/dist/http/scope.js +26 -4
  225. package/dist/http/scope.js.map +1 -1
  226. package/dist/http/server.js +6 -1
  227. package/dist/http/server.js.map +1 -1
  228. package/dist/http/web-bridge.d.ts +1 -1
  229. package/dist/http/web-bridge.js +2 -2
  230. package/dist/http/web-bridge.js.map +1 -1
  231. package/dist/http/well-known.d.ts +7 -0
  232. package/dist/http/well-known.js +22 -0
  233. package/dist/http/well-known.js.map +1 -0
  234. package/dist/index.d.ts +3 -1
  235. package/dist/index.js +4 -2
  236. package/dist/index.js.map +1 -1
  237. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +78 -0
  238. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js.map +1 -0
  239. package/dist/node_modules/.pnpm/@vitest_expect@2.1.9/node_modules/@vitest/expect/dist/index.js +1267 -0
  240. package/dist/node_modules/.pnpm/@vitest_expect@2.1.9/node_modules/@vitest/expect/dist/index.js.map +1 -0
  241. package/dist/node_modules/.pnpm/@vitest_pretty-format@2.1.9/node_modules/@vitest/pretty-format/dist/index.js +814 -0
  242. package/dist/node_modules/.pnpm/@vitest_pretty-format@2.1.9/node_modules/@vitest/pretty-format/dist/index.js.map +1 -0
  243. package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/chunk-tasks.js +43 -0
  244. package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/chunk-tasks.js.map +1 -0
  245. package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/index.js +527 -0
  246. package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/index.js.map +1 -0
  247. package/dist/node_modules/.pnpm/@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/utils.js +2 -0
  248. package/dist/node_modules/.pnpm/@vitest_snapshot@2.1.9/node_modules/@vitest/snapshot/dist/index.js +1737 -0
  249. package/dist/node_modules/.pnpm/@vitest_snapshot@2.1.9/node_modules/@vitest/snapshot/dist/index.js.map +1 -0
  250. package/dist/node_modules/.pnpm/@vitest_spy@2.1.9/node_modules/@vitest/spy/dist/index.js +137 -0
  251. package/dist/node_modules/.pnpm/@vitest_spy@2.1.9/node_modules/@vitest/spy/dist/index.js.map +1 -0
  252. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +118 -0
  253. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js.map +1 -0
  254. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/diff.js +1222 -0
  255. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/diff.js.map +1 -0
  256. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/error.js +91 -0
  257. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/error.js.map +1 -0
  258. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/helpers.js +113 -0
  259. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/helpers.js.map +1 -0
  260. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/index.js +449 -0
  261. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/index.js.map +1 -0
  262. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/source-map.js +163 -0
  263. package/dist/node_modules/.pnpm/@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/source-map.js.map +1 -0
  264. package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js +3187 -0
  265. package/dist/node_modules/.pnpm/chai@5.3.3/node_modules/chai/index.js.map +1 -0
  266. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js +11 -0
  267. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/arguments.js.map +1 -0
  268. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js +16 -0
  269. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/array.js.map +1 -0
  270. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js +11 -0
  271. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/bigint.js.map +1 -0
  272. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js +15 -0
  273. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/class.js.map +1 -0
  274. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js +13 -0
  275. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/date.js.map +1 -0
  276. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js +34 -0
  277. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/error.js.map +1 -0
  278. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js +12 -0
  279. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/function.js.map +1 -0
  280. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js +122 -0
  281. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/helpers.js.map +1 -0
  282. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js +39 -0
  283. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/html.js.map +1 -0
  284. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js +99 -0
  285. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/index.js.map +1 -0
  286. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js +25 -0
  287. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/map.js.map +1 -0
  288. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js +14 -0
  289. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/number.js.map +1 -0
  290. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js +21 -0
  291. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/object.js.map +1 -0
  292. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js +6 -0
  293. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/promise.js.map +1 -0
  294. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js +12 -0
  295. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/regexp.js.map +1 -0
  296. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js +18 -0
  297. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/set.js.map +1 -0
  298. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js +24 -0
  299. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/string.js.map +1 -0
  300. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js +9 -0
  301. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/symbol.js.map +1 -0
  302. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js +30 -0
  303. package/dist/node_modules/.pnpm/loupe@3.2.1/node_modules/loupe/lib/typedarray.js.map +1 -0
  304. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js +939 -0
  305. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js.map +1 -0
  306. package/dist/node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.js +82 -0
  307. package/dist/node_modules/.pnpm/pathe@1.1.2/node_modules/pathe/dist/shared/pathe.ff20891b.js.map +1 -0
  308. package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +82 -0
  309. package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js.map +1 -0
  310. package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/node.js +8 -0
  311. package/dist/node_modules/.pnpm/tinyrainbow@1.2.0/node_modules/tinyrainbow/dist/node.js.map +1 -0
  312. package/dist/node_modules/.pnpm/tinyspy@3.0.2/node_modules/tinyspy/dist/index.js +83 -0
  313. package/dist/node_modules/.pnpm/tinyspy@3.0.2/node_modules/tinyspy/dist/index.js.map +1 -0
  314. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +9 -0
  315. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js.map +1 -0
  316. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.js +51 -0
  317. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/date.W2xKR2qe.js.map +1 -0
  318. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/utils.C8RiOc4B.js +48 -0
  319. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/utils.C8RiOc4B.js.map +1 -0
  320. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/vi.DgezovHB.js +2426 -0
  321. package/dist/node_modules/.pnpm/vitest@2.1.9_@types_node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/vi.DgezovHB.js.map +1 -0
  322. package/dist/packages/server/package.js +6 -0
  323. package/dist/packages/server/package.js.map +1 -0
  324. package/package.json +9 -7
  325. package/dist/app/notifications.d.ts +0 -7
  326. package/dist/app/notifications.js +0 -26
  327. package/dist/app/notifications.js.map +0 -1
  328. package/dist/http/routes/learn/assets.d.ts +0 -8
  329. package/dist/http/routes/learn/assets.js +0 -32
  330. package/dist/http/routes/learn/assets.js.map +0 -1
  331. package/dist/http/routes/learn/comments.d.ts +0 -7
  332. package/dist/http/routes/learn/comments.js +0 -175
  333. package/dist/http/routes/learn/comments.js.map +0 -1
  334. package/dist/http/routes/learn/courses.d.ts +0 -7
  335. package/dist/http/routes/learn/courses.js +0 -98
  336. package/dist/http/routes/learn/courses.js.map +0 -1
  337. package/dist/http/routes/learn/downloads.d.ts +0 -7
  338. package/dist/http/routes/learn/downloads.js +0 -76
  339. package/dist/http/routes/learn/downloads.js.map +0 -1
  340. package/dist/http/routes/learn/index.d.ts +0 -7
  341. package/dist/http/routes/learn/index.js +0 -19
  342. package/dist/http/routes/learn/index.js.map +0 -1
  343. package/dist/http/routes/learn/org.d.ts +0 -7
  344. package/dist/http/routes/learn/org.js +0 -50
  345. package/dist/http/routes/learn/org.js.map +0 -1
  346. package/dist/http/routes/learn/progress.d.ts +0 -7
  347. package/dist/http/routes/learn/progress.js +0 -63
  348. package/dist/http/routes/learn/progress.js.map +0 -1
  349. package/dist/http/schemas/learn.js.map +0 -1
  350. package/dist/package.js +0 -6
  351. package/dist/package.js.map +0 -1
@@ -0,0 +1,2426 @@
1
+ import { assertTypes, createSimpleStackTrace } from "../../../../../@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/helpers.js";
2
+ import { getSafeTimers } from "../../../../../@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/index.js";
3
+ import { fn, isMockFunction, mocks, spyOn } from "../../../../../@vitest_spy@2.1.9/node_modules/@vitest/spy/dist/index.js";
4
+ import { Assertion, assert, expect, use, util as utils_exports } from "../../../../../chai@5.3.3/node_modules/chai/index.js";
5
+ import { ASYMMETRIC_MATCHERS_OBJECT, GLOBAL_EXPECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, addCustomEqualityTesters, equals, getState, iterableEquality, setState, subsetEquality } from "../../../../../@vitest_expect@2.1.9/node_modules/@vitest/expect/dist/index.js";
6
+ import { parseSingleStack } from "../../../../../@vitest_utils@2.1.9/node_modules/@vitest/utils/dist/source-map.js";
7
+ import { e as getNames, j as getTestName } from "../../../../../@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/chunk-tasks.js";
8
+ import { getCurrentTest } from "../../../../../@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/index.js";
9
+ import "../../../../../@vitest_runner@2.1.9/node_modules/@vitest/runner/dist/utils.js";
10
+ import { a as getCurrentEnvironment, g as getWorkerState, i as isChildProcess, r as resetModules, w as waitForImportsToResolve } from "./utils.C8RiOc4B.js";
11
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from "./_commonjsHelpers.BFTU3MAI.js";
12
+ import { SnapshotClient, addSerializer, stripSnapshotIndentation } from "../../../../../@vitest_snapshot@2.1.9/node_modules/@vitest/snapshot/dist/index.js";
13
+ import { R as RealDate, m as mockDate, r as resetDate } from "./date.W2xKR2qe.js";
14
+ //#region ../../node_modules/.pnpm/vitest@2.1.9_@types+node@22.20.0_jsdom@25.0.1_lightningcss@1.32.0/node_modules/vitest/dist/chunks/vi.DgezovHB.js
15
+ const unsupported = [
16
+ "matchSnapshot",
17
+ "toMatchSnapshot",
18
+ "toMatchInlineSnapshot",
19
+ "toThrowErrorMatchingSnapshot",
20
+ "toThrowErrorMatchingInlineSnapshot",
21
+ "throws",
22
+ "Throw",
23
+ "throw",
24
+ "toThrow",
25
+ "toThrowError"
26
+ ];
27
+ function createExpectPoll(expect) {
28
+ return function poll(fn, options = {}) {
29
+ const defaults = getWorkerState().config.expect?.poll ?? {};
30
+ const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
31
+ const assertion = expect(null, message).withContext({ poll: true });
32
+ fn = fn.bind(assertion);
33
+ const test = utils_exports.flag(assertion, "vitest-test");
34
+ if (!test) throw new Error("expect.poll() must be called inside a test");
35
+ const proxy = new Proxy(assertion, { get(target, key, receiver) {
36
+ const assertionFunction = Reflect.get(target, key, receiver);
37
+ if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
38
+ if (key === "assert") return assertionFunction;
39
+ if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
40
+ return function(...args) {
41
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
42
+ const promise = () => new Promise((resolve, reject) => {
43
+ let intervalId;
44
+ let lastError;
45
+ const { setTimeout, clearTimeout } = getSafeTimers();
46
+ const timeoutId = setTimeout(() => {
47
+ clearTimeout(intervalId);
48
+ reject(copyStackTrace$1(new Error(`Matcher did not succeed in ${timeout}ms`, { cause: lastError }), STACK_TRACE_ERROR));
49
+ }, timeout);
50
+ const check = async () => {
51
+ try {
52
+ utils_exports.flag(assertion, "_name", key);
53
+ const obj = await fn();
54
+ utils_exports.flag(assertion, "object", obj);
55
+ resolve(await assertionFunction.call(assertion, ...args));
56
+ clearTimeout(intervalId);
57
+ clearTimeout(timeoutId);
58
+ } catch (err) {
59
+ lastError = err;
60
+ intervalId = setTimeout(check, interval);
61
+ }
62
+ };
63
+ check();
64
+ });
65
+ let awaited = false;
66
+ test.onFinished ??= [];
67
+ test.onFinished.push(() => {
68
+ if (!awaited) {
69
+ const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
70
+ const assertionString = `expect.${utils_exports.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
71
+ throw copyStackTrace$1(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
72
+
73
+ await ${assertionString}
74
+ `), STACK_TRACE_ERROR);
75
+ }
76
+ });
77
+ let resultPromise;
78
+ return {
79
+ then(onFulfilled, onRejected) {
80
+ awaited = true;
81
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
82
+ },
83
+ catch(onRejected) {
84
+ return (resultPromise ||= promise()).catch(onRejected);
85
+ },
86
+ finally(onFinally) {
87
+ return (resultPromise ||= promise()).finally(onFinally);
88
+ },
89
+ [Symbol.toStringTag]: "Promise"
90
+ };
91
+ };
92
+ } });
93
+ return proxy;
94
+ };
95
+ }
96
+ function copyStackTrace$1(target, source) {
97
+ if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
98
+ return target;
99
+ }
100
+ function commonjsRequire(path) {
101
+ throw new Error("Could not dynamically require \"" + path + "\". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.");
102
+ }
103
+ var chaiSubset$1 = { exports: {} };
104
+ var chaiSubset = chaiSubset$1.exports;
105
+ var hasRequiredChaiSubset;
106
+ function requireChaiSubset() {
107
+ if (hasRequiredChaiSubset) return chaiSubset$1.exports;
108
+ hasRequiredChaiSubset = 1;
109
+ (function(module, exports) {
110
+ (function() {
111
+ (function(chaiSubset) {
112
+ if (typeof commonjsRequire === "function" && true) return module.exports = chaiSubset;
113
+ else return chai.use(chaiSubset);
114
+ })(function(chai, utils) {
115
+ var Assertion = chai.Assertion;
116
+ var assertionPrototype = Assertion.prototype;
117
+ Assertion.addMethod("containSubset", function(expected) {
118
+ var actual = utils.flag(this, "object");
119
+ var showDiff = chai.config.showDiff;
120
+ assertionPrototype.assert.call(this, compare(expected, actual), "expected #{act} to contain subset #{exp}", "expected #{act} to not contain subset #{exp}", expected, actual, showDiff);
121
+ });
122
+ chai.assert.containSubset = function(val, exp, msg) {
123
+ new chai.Assertion(val, msg).to.be.containSubset(exp);
124
+ };
125
+ function compare(expected, actual) {
126
+ if (expected === actual) return true;
127
+ if (typeof actual !== typeof expected) return false;
128
+ if (typeof expected !== "object" || expected === null) return expected === actual;
129
+ if (!!expected && !actual) return false;
130
+ if (Array.isArray(expected)) {
131
+ if (typeof actual.length !== "number") return false;
132
+ var aa = Array.prototype.slice.call(actual);
133
+ return expected.every(function(exp) {
134
+ return aa.some(function(act) {
135
+ return compare(exp, act);
136
+ });
137
+ });
138
+ }
139
+ if (expected instanceof Date) if (actual instanceof Date) return expected.getTime() === actual.getTime();
140
+ else return false;
141
+ return Object.keys(expected).every(function(key) {
142
+ var eo = expected[key];
143
+ var ao = actual[key];
144
+ if (typeof eo === "object" && eo !== null && ao !== null) return compare(eo, ao);
145
+ if (typeof eo === "function") return eo(ao);
146
+ return ao === eo;
147
+ });
148
+ }
149
+ });
150
+ }).call(chaiSubset);
151
+ })(chaiSubset$1);
152
+ return chaiSubset$1.exports;
153
+ }
154
+ var Subset = /*@__PURE__*/ getDefaultExportFromCjs(requireChaiSubset());
155
+ function createAssertionMessage(util, assertion, hasArgs) {
156
+ const not = util.flag(assertion, "negate") ? "not." : "";
157
+ const name = `${util.flag(assertion, "_name")}(expected)`;
158
+ const promiseName = util.flag(assertion, "promise");
159
+ return `expect(actual)${promiseName ? `.${promiseName}` : ""}.${not}${name}`;
160
+ }
161
+ function recordAsyncExpect(_test, promise, assertion, error) {
162
+ const test = _test;
163
+ if (test && promise instanceof Promise) {
164
+ promise = promise.finally(() => {
165
+ if (!test.promises) return;
166
+ const index = test.promises.indexOf(promise);
167
+ if (index !== -1) test.promises.splice(index, 1);
168
+ });
169
+ if (!test.promises) test.promises = [];
170
+ test.promises.push(promise);
171
+ let resolved = false;
172
+ test.onFinished ??= [];
173
+ test.onFinished.push(() => {
174
+ if (!resolved) {
175
+ const stack = (globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || ""))(error.stack);
176
+ console.warn([
177
+ `Promise returned by \`${assertion}\` was not awaited. `,
178
+ "Vitest currently auto-awaits hanging assertions at the end of the test, but this will cause the test to fail in Vitest 3. ",
179
+ "Please remember to await the assertion.\n",
180
+ stack
181
+ ].join(""));
182
+ }
183
+ });
184
+ return {
185
+ then(onFullfilled, onRejected) {
186
+ resolved = true;
187
+ return promise.then(onFullfilled, onRejected);
188
+ },
189
+ catch(onRejected) {
190
+ return promise.catch(onRejected);
191
+ },
192
+ finally(onFinally) {
193
+ return promise.finally(onFinally);
194
+ },
195
+ [Symbol.toStringTag]: "Promise"
196
+ };
197
+ }
198
+ return promise;
199
+ }
200
+ let _client;
201
+ function getSnapshotClient() {
202
+ if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
203
+ return equals(received, expected, [iterableEquality, subsetEquality]);
204
+ } });
205
+ return _client;
206
+ }
207
+ function getError(expected, promise) {
208
+ if (typeof expected !== "function") {
209
+ if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
210
+ return expected;
211
+ }
212
+ try {
213
+ expected();
214
+ } catch (e) {
215
+ return e;
216
+ }
217
+ throw new Error("snapshot function didn't throw");
218
+ }
219
+ function getTestNames(test) {
220
+ if (!test) return {};
221
+ return {
222
+ filepath: test.file.filepath,
223
+ name: getNames(test).slice(1).join(" > ")
224
+ };
225
+ }
226
+ const SnapshotPlugin = (chai, utils) => {
227
+ for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai.Assertion.prototype, key, function(properties, message) {
228
+ utils.flag(this, "_name", key);
229
+ if (utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
230
+ const expected = utils.flag(this, "object");
231
+ const test = utils.flag(this, "vitest-test");
232
+ if (typeof properties === "string" && typeof message === "undefined") {
233
+ message = properties;
234
+ properties = void 0;
235
+ }
236
+ const errorMessage = utils.flag(this, "message");
237
+ getSnapshotClient().assert({
238
+ received: expected,
239
+ message,
240
+ isInline: false,
241
+ properties,
242
+ errorMessage,
243
+ ...getTestNames(test)
244
+ });
245
+ });
246
+ utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
247
+ utils.flag(this, "_name", "toMatchFileSnapshot");
248
+ if (utils.flag(this, "negate")) throw new Error("toMatchFileSnapshot cannot be used with \"not\"");
249
+ const error = /* @__PURE__ */ new Error("resolves");
250
+ const expected = utils.flag(this, "object");
251
+ const test = utils.flag(this, "vitest-test");
252
+ const errorMessage = utils.flag(this, "message");
253
+ return recordAsyncExpect(test, getSnapshotClient().assertRaw({
254
+ received: expected,
255
+ message,
256
+ isInline: false,
257
+ rawSnapshot: { file },
258
+ errorMessage,
259
+ ...getTestNames(test)
260
+ }), createAssertionMessage(utils, this), error);
261
+ });
262
+ utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
263
+ utils.flag(this, "_name", "toMatchInlineSnapshot");
264
+ if (utils.flag(this, "negate")) throw new Error("toMatchInlineSnapshot cannot be used with \"not\"");
265
+ const test = utils.flag(this, "vitest-test");
266
+ if (test && (test.each || test.suite?.each)) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
267
+ const expected = utils.flag(this, "object");
268
+ const error = utils.flag(this, "error");
269
+ if (typeof properties === "string") {
270
+ message = inlineSnapshot;
271
+ inlineSnapshot = properties;
272
+ properties = void 0;
273
+ }
274
+ if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
275
+ const errorMessage = utils.flag(this, "message");
276
+ getSnapshotClient().assert({
277
+ received: expected,
278
+ message,
279
+ isInline: true,
280
+ properties,
281
+ inlineSnapshot,
282
+ error,
283
+ errorMessage,
284
+ ...getTestNames(test)
285
+ });
286
+ });
287
+ utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
288
+ utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
289
+ if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingSnapshot cannot be used with \"not\"");
290
+ const expected = utils.flag(this, "object");
291
+ const test = utils.flag(this, "vitest-test");
292
+ const promise = utils.flag(this, "promise");
293
+ const errorMessage = utils.flag(this, "message");
294
+ getSnapshotClient().assert({
295
+ received: getError(expected, promise),
296
+ message,
297
+ errorMessage,
298
+ ...getTestNames(test)
299
+ });
300
+ });
301
+ utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
302
+ if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingInlineSnapshot cannot be used with \"not\"");
303
+ const test = utils.flag(this, "vitest-test");
304
+ if (test && (test.each || test.suite?.each)) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
305
+ const expected = utils.flag(this, "object");
306
+ const error = utils.flag(this, "error");
307
+ const promise = utils.flag(this, "promise");
308
+ const errorMessage = utils.flag(this, "message");
309
+ if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
310
+ getSnapshotClient().assert({
311
+ received: getError(expected, promise),
312
+ message,
313
+ inlineSnapshot,
314
+ isInline: true,
315
+ error,
316
+ errorMessage,
317
+ ...getTestNames(test)
318
+ });
319
+ });
320
+ utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
321
+ };
322
+ use(JestExtend);
323
+ use(JestChaiExpect);
324
+ use(Subset);
325
+ use(SnapshotPlugin);
326
+ use(JestAsymmetricMatchers);
327
+ function createExpect(test) {
328
+ const expect$1 = (value, message) => {
329
+ const { assertionCalls } = getState(expect$1);
330
+ setState({ assertionCalls: assertionCalls + 1 }, expect$1);
331
+ const assert2 = expect(value, message);
332
+ const _test = test || getCurrentTest();
333
+ if (_test) return assert2.withTest(_test);
334
+ else return assert2;
335
+ };
336
+ Object.assign(expect$1, expect);
337
+ Object.assign(expect$1, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
338
+ expect$1.getState = () => getState(expect$1);
339
+ expect$1.setState = (state) => setState(state, expect$1);
340
+ const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
341
+ setState({
342
+ ...globalState,
343
+ assertionCalls: 0,
344
+ isExpectingAssertions: false,
345
+ isExpectingAssertionsError: null,
346
+ expectedAssertionsNumber: null,
347
+ expectedAssertionsNumberErrorGen: null,
348
+ environment: getCurrentEnvironment(),
349
+ get testPath() {
350
+ return getWorkerState().filepath;
351
+ },
352
+ currentTestName: test ? getTestName(test) : globalState.currentTestName
353
+ }, expect$1);
354
+ expect$1.extend = (matchers) => expect.extend(expect$1, matchers);
355
+ expect$1.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
356
+ expect$1.soft = (...args) => {
357
+ return expect$1(...args).withContext({ soft: true });
358
+ };
359
+ expect$1.poll = createExpectPoll(expect$1);
360
+ expect$1.unreachable = (message) => {
361
+ assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
362
+ };
363
+ function assertions(expected) {
364
+ const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect$1.getState().assertionCalls}`);
365
+ if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
366
+ expect$1.setState({
367
+ expectedAssertionsNumber: expected,
368
+ expectedAssertionsNumberErrorGen: errorGen
369
+ });
370
+ }
371
+ function hasAssertions() {
372
+ const error = /* @__PURE__ */ new Error("expected any number of assertion, but got none");
373
+ if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
374
+ expect$1.setState({
375
+ isExpectingAssertions: true,
376
+ isExpectingAssertionsError: error
377
+ });
378
+ }
379
+ utils_exports.addMethod(expect$1, "assertions", assertions);
380
+ utils_exports.addMethod(expect$1, "hasAssertions", hasAssertions);
381
+ return expect$1;
382
+ }
383
+ const globalExpect = createExpect();
384
+ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
385
+ value: globalExpect,
386
+ writable: true,
387
+ configurable: true
388
+ });
389
+ var fakeTimersSrc = {};
390
+ var global;
391
+ var hasRequiredGlobal;
392
+ function requireGlobal() {
393
+ if (hasRequiredGlobal) return global;
394
+ hasRequiredGlobal = 1;
395
+ /**
396
+ * A reference to the global object
397
+ *
398
+ * @type {object} globalObject
399
+ */
400
+ var globalObject;
401
+ /* istanbul ignore else */
402
+ if (typeof commonjsGlobal !== "undefined") globalObject = commonjsGlobal;
403
+ else if (typeof window !== "undefined") globalObject = window;
404
+ else globalObject = self;
405
+ global = globalObject;
406
+ return global;
407
+ }
408
+ var throwsOnProto_1;
409
+ var hasRequiredThrowsOnProto;
410
+ function requireThrowsOnProto() {
411
+ if (hasRequiredThrowsOnProto) return throwsOnProto_1;
412
+ hasRequiredThrowsOnProto = 1;
413
+ /**
414
+ * Is true when the environment causes an error to be thrown for accessing the
415
+ * __proto__ property.
416
+ *
417
+ * This is necessary in order to support `node --disable-proto=throw`.
418
+ *
419
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto
420
+ *
421
+ * @type {boolean}
422
+ */
423
+ let throwsOnProto;
424
+ try {
425
+ ({}).__proto__;
426
+ throwsOnProto = false;
427
+ } catch (_) {
428
+ /* istanbul ignore next */
429
+ throwsOnProto = true;
430
+ }
431
+ throwsOnProto_1 = throwsOnProto;
432
+ return throwsOnProto_1;
433
+ }
434
+ var copyPrototypeMethods;
435
+ var hasRequiredCopyPrototypeMethods;
436
+ function requireCopyPrototypeMethods() {
437
+ if (hasRequiredCopyPrototypeMethods) return copyPrototypeMethods;
438
+ hasRequiredCopyPrototypeMethods = 1;
439
+ var call = Function.call;
440
+ var throwsOnProto = requireThrowsOnProto();
441
+ var disallowedProperties = [
442
+ "size",
443
+ "caller",
444
+ "callee",
445
+ "arguments"
446
+ ];
447
+ /* istanbul ignore next */
448
+ if (throwsOnProto) disallowedProperties.push("__proto__");
449
+ copyPrototypeMethods = function copyPrototypeMethods(prototype) {
450
+ return Object.getOwnPropertyNames(prototype).reduce(function(result, name) {
451
+ if (disallowedProperties.includes(name)) return result;
452
+ if (typeof prototype[name] !== "function") return result;
453
+ result[name] = call.bind(prototype[name]);
454
+ return result;
455
+ }, Object.create(null));
456
+ };
457
+ return copyPrototypeMethods;
458
+ }
459
+ var array;
460
+ var hasRequiredArray;
461
+ function requireArray() {
462
+ if (hasRequiredArray) return array;
463
+ hasRequiredArray = 1;
464
+ array = requireCopyPrototypeMethods()(Array.prototype);
465
+ return array;
466
+ }
467
+ var calledInOrder_1;
468
+ var hasRequiredCalledInOrder;
469
+ function requireCalledInOrder() {
470
+ if (hasRequiredCalledInOrder) return calledInOrder_1;
471
+ hasRequiredCalledInOrder = 1;
472
+ var every = requireArray().every;
473
+ /**
474
+ * @private
475
+ */
476
+ function hasCallsLeft(callMap, spy) {
477
+ if (callMap[spy.id] === void 0) callMap[spy.id] = 0;
478
+ return callMap[spy.id] < spy.callCount;
479
+ }
480
+ /**
481
+ * @private
482
+ */
483
+ function checkAdjacentCalls(callMap, spy, index, spies) {
484
+ var calledBeforeNext = true;
485
+ if (index !== spies.length - 1) calledBeforeNext = spy.calledBefore(spies[index + 1]);
486
+ if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
487
+ callMap[spy.id] += 1;
488
+ return true;
489
+ }
490
+ return false;
491
+ }
492
+ /**
493
+ * A Sinon proxy object (fake, spy, stub)
494
+ *
495
+ * @typedef {object} SinonProxy
496
+ * @property {Function} calledBefore - A method that determines if this proxy was called before another one
497
+ * @property {string} id - Some id
498
+ * @property {number} callCount - Number of times this proxy has been called
499
+ */
500
+ /**
501
+ * Returns true when the spies have been called in the order they were supplied in
502
+ *
503
+ * @param {SinonProxy[] | SinonProxy} spies An array of proxies, or several proxies as arguments
504
+ * @returns {boolean} true when spies are called in order, false otherwise
505
+ */
506
+ function calledInOrder(spies) {
507
+ return every(arguments.length > 1 ? arguments : spies, checkAdjacentCalls.bind(null, {}));
508
+ }
509
+ calledInOrder_1 = calledInOrder;
510
+ return calledInOrder_1;
511
+ }
512
+ var functionName;
513
+ var hasRequiredFunctionName;
514
+ function requireFunctionName() {
515
+ if (hasRequiredFunctionName) return functionName;
516
+ hasRequiredFunctionName = 1;
517
+ /**
518
+ * Returns a display name for a function
519
+ *
520
+ * @param {Function} func
521
+ * @returns {string}
522
+ */
523
+ functionName = function functionName(func) {
524
+ if (!func) return "";
525
+ try {
526
+ return func.displayName || func.name || (String(func).match(/function ([^\s(]+)/) || [])[1];
527
+ } catch (e) {
528
+ return "";
529
+ }
530
+ };
531
+ return functionName;
532
+ }
533
+ var className_1;
534
+ var hasRequiredClassName;
535
+ function requireClassName() {
536
+ if (hasRequiredClassName) return className_1;
537
+ hasRequiredClassName = 1;
538
+ var functionName = requireFunctionName();
539
+ /**
540
+ * Returns a display name for a value from a constructor
541
+ *
542
+ * @param {object} value A value to examine
543
+ * @returns {(string|null)} A string or null
544
+ */
545
+ function className(value) {
546
+ return value.constructor && value.constructor.name || typeof value.constructor === "function" && functionName(value.constructor) || null;
547
+ }
548
+ className_1 = className;
549
+ return className_1;
550
+ }
551
+ var deprecated = {};
552
+ var hasRequiredDeprecated;
553
+ function requireDeprecated() {
554
+ if (hasRequiredDeprecated) return deprecated;
555
+ hasRequiredDeprecated = 1;
556
+ (function(exports) {
557
+ /**
558
+ * Returns a function that will invoke the supplied function and print a
559
+ * deprecation warning to the console each time it is called.
560
+ *
561
+ * @param {Function} func
562
+ * @param {string} msg
563
+ * @returns {Function}
564
+ */
565
+ exports.wrap = function(func, msg) {
566
+ var wrapped = function() {
567
+ exports.printWarning(msg);
568
+ return func.apply(this, arguments);
569
+ };
570
+ if (func.prototype) wrapped.prototype = func.prototype;
571
+ return wrapped;
572
+ };
573
+ /**
574
+ * Returns a string which can be supplied to `wrap()` to notify the user that a
575
+ * particular part of the sinon API has been deprecated.
576
+ *
577
+ * @param {string} packageName
578
+ * @param {string} funcName
579
+ * @returns {string}
580
+ */
581
+ exports.defaultMsg = function(packageName, funcName) {
582
+ return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
583
+ };
584
+ /**
585
+ * Prints a warning on the console, when it exists
586
+ *
587
+ * @param {string} msg
588
+ * @returns {undefined}
589
+ */
590
+ exports.printWarning = function(msg) {
591
+ /* istanbul ignore next */
592
+ if (typeof process === "object" && process.emitWarning) process.emitWarning(msg);
593
+ else if (console.info) console.info(msg);
594
+ else console.log(msg);
595
+ };
596
+ })(deprecated);
597
+ return deprecated;
598
+ }
599
+ var every;
600
+ var hasRequiredEvery;
601
+ function requireEvery() {
602
+ if (hasRequiredEvery) return every;
603
+ hasRequiredEvery = 1;
604
+ /**
605
+ * Returns true when fn returns true for all members of obj.
606
+ * This is an every implementation that works for all iterables
607
+ *
608
+ * @param {object} obj
609
+ * @param {Function} fn
610
+ * @returns {boolean}
611
+ */
612
+ every = function every(obj, fn) {
613
+ var pass = true;
614
+ try {
615
+ obj.forEach(function() {
616
+ if (!fn.apply(this, arguments)) throw new Error();
617
+ });
618
+ } catch (e) {
619
+ pass = false;
620
+ }
621
+ return pass;
622
+ };
623
+ return every;
624
+ }
625
+ var orderByFirstCall_1;
626
+ var hasRequiredOrderByFirstCall;
627
+ function requireOrderByFirstCall() {
628
+ if (hasRequiredOrderByFirstCall) return orderByFirstCall_1;
629
+ hasRequiredOrderByFirstCall = 1;
630
+ var sort = requireArray().sort;
631
+ var slice = requireArray().slice;
632
+ /**
633
+ * @private
634
+ */
635
+ function comparator(a, b) {
636
+ var aCall = a.getCall(0);
637
+ var bCall = b.getCall(0);
638
+ return (aCall && aCall.callId || -1) < (bCall && bCall.callId || -1) ? -1 : 1;
639
+ }
640
+ /**
641
+ * A Sinon proxy object (fake, spy, stub)
642
+ *
643
+ * @typedef {object} SinonProxy
644
+ * @property {Function} getCall - A method that can return the first call
645
+ */
646
+ /**
647
+ * Sorts an array of SinonProxy instances (fake, spy, stub) by their first call
648
+ *
649
+ * @param {SinonProxy[] | SinonProxy} spies
650
+ * @returns {SinonProxy[]}
651
+ */
652
+ function orderByFirstCall(spies) {
653
+ return sort(slice(spies), comparator);
654
+ }
655
+ orderByFirstCall_1 = orderByFirstCall;
656
+ return orderByFirstCall_1;
657
+ }
658
+ var _function;
659
+ var hasRequired_function;
660
+ function require_function() {
661
+ if (hasRequired_function) return _function;
662
+ hasRequired_function = 1;
663
+ _function = requireCopyPrototypeMethods()(Function.prototype);
664
+ return _function;
665
+ }
666
+ var map;
667
+ var hasRequiredMap;
668
+ function requireMap() {
669
+ if (hasRequiredMap) return map;
670
+ hasRequiredMap = 1;
671
+ map = requireCopyPrototypeMethods()(Map.prototype);
672
+ return map;
673
+ }
674
+ var object;
675
+ var hasRequiredObject;
676
+ function requireObject() {
677
+ if (hasRequiredObject) return object;
678
+ hasRequiredObject = 1;
679
+ object = requireCopyPrototypeMethods()(Object.prototype);
680
+ return object;
681
+ }
682
+ var set;
683
+ var hasRequiredSet;
684
+ function requireSet() {
685
+ if (hasRequiredSet) return set;
686
+ hasRequiredSet = 1;
687
+ set = requireCopyPrototypeMethods()(Set.prototype);
688
+ return set;
689
+ }
690
+ var string;
691
+ var hasRequiredString;
692
+ function requireString() {
693
+ if (hasRequiredString) return string;
694
+ hasRequiredString = 1;
695
+ string = requireCopyPrototypeMethods()(String.prototype);
696
+ return string;
697
+ }
698
+ var prototypes;
699
+ var hasRequiredPrototypes;
700
+ function requirePrototypes() {
701
+ if (hasRequiredPrototypes) return prototypes;
702
+ hasRequiredPrototypes = 1;
703
+ prototypes = {
704
+ array: requireArray(),
705
+ function: require_function(),
706
+ map: requireMap(),
707
+ object: requireObject(),
708
+ set: requireSet(),
709
+ string: requireString()
710
+ };
711
+ return prototypes;
712
+ }
713
+ var typeDetect$1 = { exports: {} };
714
+ var typeDetect = typeDetect$1.exports;
715
+ var hasRequiredTypeDetect;
716
+ function requireTypeDetect() {
717
+ if (hasRequiredTypeDetect) return typeDetect$1.exports;
718
+ hasRequiredTypeDetect = 1;
719
+ (function(module, exports) {
720
+ (function(global, factory) {
721
+ module.exports = factory();
722
+ })(typeDetect, (function() {
723
+ var promiseExists = typeof Promise === "function";
724
+ var globalObject = typeof self === "object" ? self : commonjsGlobal;
725
+ var symbolExists = typeof Symbol !== "undefined";
726
+ var mapExists = typeof Map !== "undefined";
727
+ var setExists = typeof Set !== "undefined";
728
+ var weakMapExists = typeof WeakMap !== "undefined";
729
+ var weakSetExists = typeof WeakSet !== "undefined";
730
+ var dataViewExists = typeof DataView !== "undefined";
731
+ var symbolIteratorExists = symbolExists && typeof Symbol.iterator !== "undefined";
732
+ var symbolToStringTagExists = symbolExists && typeof Symbol.toStringTag !== "undefined";
733
+ var setEntriesExists = setExists && typeof Set.prototype.entries === "function";
734
+ var mapEntriesExists = mapExists && typeof Map.prototype.entries === "function";
735
+ var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries());
736
+ var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries());
737
+ var arrayIteratorExists = symbolIteratorExists && typeof Array.prototype[Symbol.iterator] === "function";
738
+ var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
739
+ var stringIteratorExists = symbolIteratorExists && typeof String.prototype[Symbol.iterator] === "function";
740
+ var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(""[Symbol.iterator]());
741
+ var toStringLeftSliceLength = 8;
742
+ var toStringRightSliceLength = -1;
743
+ /**
744
+ * ### typeOf (obj)
745
+ *
746
+ * Uses `Object.prototype.toString` to determine the type of an object,
747
+ * normalising behaviour across engine versions & well optimised.
748
+ *
749
+ * @param {Mixed} object
750
+ * @return {String} object type
751
+ * @api public
752
+ */
753
+ function typeDetect(obj) {
754
+ var typeofObj = typeof obj;
755
+ if (typeofObj !== "object") return typeofObj;
756
+ if (obj === null) return "null";
757
+ if (obj === globalObject) return "global";
758
+ if (Array.isArray(obj) && (symbolToStringTagExists === false || !(Symbol.toStringTag in obj))) return "Array";
759
+ if (typeof window === "object" && window !== null) {
760
+ if (typeof window.location === "object" && obj === window.location) return "Location";
761
+ if (typeof window.document === "object" && obj === window.document) return "Document";
762
+ if (typeof window.navigator === "object") {
763
+ if (typeof window.navigator.mimeTypes === "object" && obj === window.navigator.mimeTypes) return "MimeTypeArray";
764
+ if (typeof window.navigator.plugins === "object" && obj === window.navigator.plugins) return "PluginArray";
765
+ }
766
+ if ((typeof window.HTMLElement === "function" || typeof window.HTMLElement === "object") && obj instanceof window.HTMLElement) {
767
+ if (obj.tagName === "BLOCKQUOTE") return "HTMLQuoteElement";
768
+ if (obj.tagName === "TD") return "HTMLTableDataCellElement";
769
+ if (obj.tagName === "TH") return "HTMLTableHeaderCellElement";
770
+ }
771
+ }
772
+ var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
773
+ if (typeof stringTag === "string") return stringTag;
774
+ var objPrototype = Object.getPrototypeOf(obj);
775
+ if (objPrototype === RegExp.prototype) return "RegExp";
776
+ if (objPrototype === Date.prototype) return "Date";
777
+ if (promiseExists && objPrototype === Promise.prototype) return "Promise";
778
+ if (setExists && objPrototype === Set.prototype) return "Set";
779
+ if (mapExists && objPrototype === Map.prototype) return "Map";
780
+ if (weakSetExists && objPrototype === WeakSet.prototype) return "WeakSet";
781
+ if (weakMapExists && objPrototype === WeakMap.prototype) return "WeakMap";
782
+ if (dataViewExists && objPrototype === DataView.prototype) return "DataView";
783
+ if (mapExists && objPrototype === mapIteratorPrototype) return "Map Iterator";
784
+ if (setExists && objPrototype === setIteratorPrototype) return "Set Iterator";
785
+ if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) return "Array Iterator";
786
+ if (stringIteratorExists && objPrototype === stringIteratorPrototype) return "String Iterator";
787
+ if (objPrototype === null) return "Object";
788
+ return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
789
+ }
790
+ return typeDetect;
791
+ }));
792
+ })(typeDetect$1);
793
+ return typeDetect$1.exports;
794
+ }
795
+ var typeOf;
796
+ var hasRequiredTypeOf;
797
+ function requireTypeOf() {
798
+ if (hasRequiredTypeOf) return typeOf;
799
+ hasRequiredTypeOf = 1;
800
+ var type = requireTypeDetect();
801
+ /**
802
+ * Returns the lower-case result of running type from type-detect on the value
803
+ *
804
+ * @param {*} value
805
+ * @returns {string}
806
+ */
807
+ typeOf = function typeOf(value) {
808
+ return type(value).toLowerCase();
809
+ };
810
+ return typeOf;
811
+ }
812
+ var valueToString_1;
813
+ var hasRequiredValueToString;
814
+ function requireValueToString() {
815
+ if (hasRequiredValueToString) return valueToString_1;
816
+ hasRequiredValueToString = 1;
817
+ /**
818
+ * Returns a string representation of the value
819
+ *
820
+ * @param {*} value
821
+ * @returns {string}
822
+ */
823
+ function valueToString(value) {
824
+ if (value && value.toString) return value.toString();
825
+ return String(value);
826
+ }
827
+ valueToString_1 = valueToString;
828
+ return valueToString_1;
829
+ }
830
+ var lib;
831
+ var hasRequiredLib;
832
+ function requireLib() {
833
+ if (hasRequiredLib) return lib;
834
+ hasRequiredLib = 1;
835
+ lib = {
836
+ global: requireGlobal(),
837
+ calledInOrder: requireCalledInOrder(),
838
+ className: requireClassName(),
839
+ deprecated: requireDeprecated(),
840
+ every: requireEvery(),
841
+ functionName: requireFunctionName(),
842
+ orderByFirstCall: requireOrderByFirstCall(),
843
+ prototypes: requirePrototypes(),
844
+ typeOf: requireTypeOf(),
845
+ valueToString: requireValueToString()
846
+ };
847
+ return lib;
848
+ }
849
+ var hasRequiredFakeTimersSrc;
850
+ function requireFakeTimersSrc() {
851
+ if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
852
+ hasRequiredFakeTimersSrc = 1;
853
+ const globalObject = requireLib().global;
854
+ let timersModule;
855
+ if (typeof __vitest_required__ !== "undefined") try {
856
+ timersModule = __vitest_required__.timers;
857
+ } catch (e) {}
858
+ /**
859
+ * @typedef {object} IdleDeadline
860
+ * @property {boolean} didTimeout - whether or not the callback was called before reaching the optional timeout
861
+ * @property {function():number} timeRemaining - a floating-point value providing an estimate of the number of milliseconds remaining in the current idle period
862
+ */
863
+ /**
864
+ * Queues a function to be called during a browser's idle periods
865
+ *
866
+ * @callback RequestIdleCallback
867
+ * @param {function(IdleDeadline)} callback
868
+ * @param {{timeout: number}} options - an options object
869
+ * @returns {number} the id
870
+ */
871
+ /**
872
+ * @callback NextTick
873
+ * @param {VoidVarArgsFunc} callback - the callback to run
874
+ * @param {...*} arguments - optional arguments to call the callback with
875
+ * @returns {void}
876
+ */
877
+ /**
878
+ * @callback SetImmediate
879
+ * @param {VoidVarArgsFunc} callback - the callback to run
880
+ * @param {...*} arguments - optional arguments to call the callback with
881
+ * @returns {NodeImmediate}
882
+ */
883
+ /**
884
+ * @callback VoidVarArgsFunc
885
+ * @param {...*} callback - the callback to run
886
+ * @returns {void}
887
+ */
888
+ /**
889
+ * @typedef RequestAnimationFrame
890
+ * @property {function(number):void} requestAnimationFrame
891
+ * @returns {number} - the id
892
+ */
893
+ /**
894
+ * @typedef Performance
895
+ * @property {function(): number} now
896
+ */
897
+ /**
898
+ * @typedef {object} Clock
899
+ * @property {number} now - the current time
900
+ * @property {Date} Date - the Date constructor
901
+ * @property {number} loopLimit - the maximum number of timers before assuming an infinite loop
902
+ * @property {RequestIdleCallback} requestIdleCallback
903
+ * @property {function(number):void} cancelIdleCallback
904
+ * @property {setTimeout} setTimeout
905
+ * @property {clearTimeout} clearTimeout
906
+ * @property {NextTick} nextTick
907
+ * @property {queueMicrotask} queueMicrotask
908
+ * @property {setInterval} setInterval
909
+ * @property {clearInterval} clearInterval
910
+ * @property {SetImmediate} setImmediate
911
+ * @property {function(NodeImmediate):void} clearImmediate
912
+ * @property {function():number} countTimers
913
+ * @property {RequestAnimationFrame} requestAnimationFrame
914
+ * @property {function(number):void} cancelAnimationFrame
915
+ * @property {function():void} runMicrotasks
916
+ * @property {function(string | number): number} tick
917
+ * @property {function(string | number): Promise<number>} tickAsync
918
+ * @property {function(): number} next
919
+ * @property {function(): Promise<number>} nextAsync
920
+ * @property {function(): number} runAll
921
+ * @property {function(): number} runToFrame
922
+ * @property {function(): Promise<number>} runAllAsync
923
+ * @property {function(): number} runToLast
924
+ * @property {function(): Promise<number>} runToLastAsync
925
+ * @property {function(): void} reset
926
+ * @property {function(number | Date): void} setSystemTime
927
+ * @property {function(number): void} jump
928
+ * @property {Performance} performance
929
+ * @property {function(number[]): number[]} hrtime - process.hrtime (legacy)
930
+ * @property {function(): void} uninstall Uninstall the clock.
931
+ * @property {Function[]} methods - the methods that are faked
932
+ * @property {boolean} [shouldClearNativeTimers] inherited from config
933
+ * @property {{methodName:string, original:any}[] | undefined} timersModuleMethods
934
+ */
935
+ /**
936
+ * Configuration object for the `install` method.
937
+ *
938
+ * @typedef {object} Config
939
+ * @property {number|Date} [now] a number (in milliseconds) or a Date object (default epoch)
940
+ * @property {string[]} [toFake] names of the methods that should be faked.
941
+ * @property {number} [loopLimit] the maximum number of timers that will be run when calling runAll()
942
+ * @property {boolean} [shouldAdvanceTime] tells FakeTimers to increment mocked time automatically (default false)
943
+ * @property {number} [advanceTimeDelta] increment mocked time every <<advanceTimeDelta>> ms (default: 20ms)
944
+ * @property {boolean} [shouldClearNativeTimers] forwards clear timer calls to native functions if they are not fakes (default: false)
945
+ */
946
+ /**
947
+ * The internal structure to describe a scheduled fake timer
948
+ *
949
+ * @typedef {object} Timer
950
+ * @property {Function} func
951
+ * @property {*[]} args
952
+ * @property {number} delay
953
+ * @property {number} callAt
954
+ * @property {number} createdAt
955
+ * @property {boolean} immediate
956
+ * @property {number} id
957
+ * @property {Error} [error]
958
+ */
959
+ /**
960
+ * A Node timer
961
+ *
962
+ * @typedef {object} NodeImmediate
963
+ * @property {function(): boolean} hasRef
964
+ * @property {function(): NodeImmediate} ref
965
+ * @property {function(): NodeImmediate} unref
966
+ */
967
+ /**
968
+ * Mocks available features in the specified global namespace.
969
+ *
970
+ * @param {*} _global Namespace to mock (e.g. `window`)
971
+ * @returns {FakeTimers}
972
+ */
973
+ function withGlobal(_global) {
974
+ const maxTimeout = Math.pow(2, 31) - 1;
975
+ const idCounterStart = 0xe8d4a51000;
976
+ const NOOP = function() {};
977
+ const NOOP_ARRAY = function() {
978
+ return [];
979
+ };
980
+ const timeoutResult = _global.setTimeout(NOOP, 0);
981
+ const addTimerReturnsObject = typeof timeoutResult === "object";
982
+ const hrtimePresent = _global.process && typeof _global.process.hrtime === "function";
983
+ const hrtimeBigintPresent = hrtimePresent && typeof _global.process.hrtime.bigint === "function";
984
+ const nextTickPresent = _global.process && typeof _global.process.nextTick === "function";
985
+ const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
986
+ const performancePresent = _global.performance && typeof _global.performance.now === "function";
987
+ const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
988
+ const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
989
+ const queueMicrotaskPresent = _global.hasOwnProperty("queueMicrotask");
990
+ const requestAnimationFramePresent = _global.requestAnimationFrame && typeof _global.requestAnimationFrame === "function";
991
+ const cancelAnimationFramePresent = _global.cancelAnimationFrame && typeof _global.cancelAnimationFrame === "function";
992
+ const requestIdleCallbackPresent = _global.requestIdleCallback && typeof _global.requestIdleCallback === "function";
993
+ const cancelIdleCallbackPresent = _global.cancelIdleCallback && typeof _global.cancelIdleCallback === "function";
994
+ const setImmediatePresent = _global.setImmediate && typeof _global.setImmediate === "function";
995
+ const intlPresent = _global.Intl && typeof _global.Intl === "object";
996
+ _global.clearTimeout(timeoutResult);
997
+ const NativeDate = _global.Date;
998
+ const NativeIntl = _global.Intl;
999
+ let uniqueTimerId = idCounterStart;
1000
+ /**
1001
+ * @param {number} num
1002
+ * @returns {boolean}
1003
+ */
1004
+ function isNumberFinite(num) {
1005
+ if (Number.isFinite) return Number.isFinite(num);
1006
+ return isFinite(num);
1007
+ }
1008
+ let isNearInfiniteLimit = false;
1009
+ /**
1010
+ * @param {Clock} clock
1011
+ * @param {number} i
1012
+ */
1013
+ function checkIsNearInfiniteLimit(clock, i) {
1014
+ if (clock.loopLimit && i === clock.loopLimit - 1) isNearInfiniteLimit = true;
1015
+ }
1016
+ /**
1017
+ *
1018
+ */
1019
+ function resetIsNearInfiniteLimit() {
1020
+ isNearInfiniteLimit = false;
1021
+ }
1022
+ /**
1023
+ * Parse strings like "01:10:00" (meaning 1 hour, 10 minutes, 0 seconds) into
1024
+ * number of milliseconds. This is used to support human-readable strings passed
1025
+ * to clock.tick()
1026
+ *
1027
+ * @param {string} str
1028
+ * @returns {number}
1029
+ */
1030
+ function parseTime(str) {
1031
+ if (!str) return 0;
1032
+ const strings = str.split(":");
1033
+ const l = strings.length;
1034
+ let i = l;
1035
+ let ms = 0;
1036
+ let parsed;
1037
+ if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) throw new Error("tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits");
1038
+ while (i--) {
1039
+ parsed = parseInt(strings[i], 10);
1040
+ if (parsed >= 60) throw new Error(`Invalid time ${str}`);
1041
+ ms += parsed * Math.pow(60, l - i - 1);
1042
+ }
1043
+ return ms * 1e3;
1044
+ }
1045
+ /**
1046
+ * Get the decimal part of the millisecond value as nanoseconds
1047
+ *
1048
+ * @param {number} msFloat the number of milliseconds
1049
+ * @returns {number} an integer number of nanoseconds in the range [0,1e6)
1050
+ *
1051
+ * Example: nanoRemainer(123.456789) -> 456789
1052
+ */
1053
+ function nanoRemainder(msFloat) {
1054
+ const modulo = 1e6;
1055
+ const remainder = msFloat * 1e6 % modulo;
1056
+ const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
1057
+ return Math.floor(positiveRemainder);
1058
+ }
1059
+ /**
1060
+ * Used to grok the `now` parameter to createClock.
1061
+ *
1062
+ * @param {Date|number} epoch the system time
1063
+ * @returns {number}
1064
+ */
1065
+ function getEpoch(epoch) {
1066
+ if (!epoch) return 0;
1067
+ if (typeof epoch.getTime === "function") return epoch.getTime();
1068
+ if (typeof epoch === "number") return epoch;
1069
+ throw new TypeError("now should be milliseconds since UNIX epoch");
1070
+ }
1071
+ /**
1072
+ * @param {number} from
1073
+ * @param {number} to
1074
+ * @param {Timer} timer
1075
+ * @returns {boolean}
1076
+ */
1077
+ function inRange(from, to, timer) {
1078
+ return timer && timer.callAt >= from && timer.callAt <= to;
1079
+ }
1080
+ /**
1081
+ * @param {Clock} clock
1082
+ * @param {Timer} job
1083
+ */
1084
+ function getInfiniteLoopError(clock, job) {
1085
+ const infiniteLoopError = /* @__PURE__ */ new Error(`Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`);
1086
+ if (!job.error) return infiniteLoopError;
1087
+ const computedTargetPattern = /target\.*[<|(|[].*?[>|\]|)]\s*/;
1088
+ let clockMethodPattern = new RegExp(String(Object.keys(clock).join("|")));
1089
+ if (addTimerReturnsObject) clockMethodPattern = new RegExp(`\\s+at (Object\\.)?(?:${Object.keys(clock).join("|")})\\s+`);
1090
+ let matchedLineIndex = -1;
1091
+ job.error.stack.split("\n").some(function(line, i) {
1092
+ /* istanbul ignore if */
1093
+ if (line.match(computedTargetPattern)) {
1094
+ matchedLineIndex = i;
1095
+ return true;
1096
+ }
1097
+ if (line.match(clockMethodPattern)) {
1098
+ matchedLineIndex = i;
1099
+ return false;
1100
+ }
1101
+ return matchedLineIndex >= 0;
1102
+ });
1103
+ const stack = `${infiniteLoopError}\n${job.type || "Microtask"} - ${job.func.name || "anonymous"}\n${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
1104
+ try {
1105
+ Object.defineProperty(infiniteLoopError, "stack", { value: stack });
1106
+ } catch (e) {}
1107
+ return infiniteLoopError;
1108
+ }
1109
+ /**
1110
+ * @param {Date} target
1111
+ * @param {Date} source
1112
+ * @returns {Date} the target after modifications
1113
+ */
1114
+ function mirrorDateProperties(target, source) {
1115
+ let prop;
1116
+ for (prop in source) if (source.hasOwnProperty(prop)) target[prop] = source[prop];
1117
+ if (source.now) target.now = function now() {
1118
+ return target.clock.now;
1119
+ };
1120
+ else delete target.now;
1121
+ if (source.toSource) target.toSource = function toSource() {
1122
+ return source.toSource();
1123
+ };
1124
+ else delete target.toSource;
1125
+ target.toString = function toString() {
1126
+ return source.toString();
1127
+ };
1128
+ target.prototype = source.prototype;
1129
+ target.parse = source.parse;
1130
+ target.UTC = source.UTC;
1131
+ target.prototype.toUTCString = source.prototype.toUTCString;
1132
+ target.isFake = true;
1133
+ return target;
1134
+ }
1135
+ function createDate() {
1136
+ /**
1137
+ * @param {number} year
1138
+ * @param {number} month
1139
+ * @param {number} date
1140
+ * @param {number} hour
1141
+ * @param {number} minute
1142
+ * @param {number} second
1143
+ * @param {number} ms
1144
+ * @returns {Date}
1145
+ */
1146
+ function ClockDate(year, month, date, hour, minute, second, ms) {
1147
+ if (!(this instanceof ClockDate)) return new NativeDate(ClockDate.clock.now).toString();
1148
+ switch (arguments.length) {
1149
+ case 0: return new NativeDate(ClockDate.clock.now);
1150
+ case 1: return new NativeDate(year);
1151
+ case 2: return new NativeDate(year, month);
1152
+ case 3: return new NativeDate(year, month, date);
1153
+ case 4: return new NativeDate(year, month, date, hour);
1154
+ case 5: return new NativeDate(year, month, date, hour, minute);
1155
+ case 6: return new NativeDate(year, month, date, hour, minute, second);
1156
+ default: return new NativeDate(year, month, date, hour, minute, second, ms);
1157
+ }
1158
+ }
1159
+ return mirrorDateProperties(ClockDate, NativeDate);
1160
+ }
1161
+ function createIntl() {
1162
+ const ClockIntl = { ...NativeIntl };
1163
+ ClockIntl.DateTimeFormat = function(...args) {
1164
+ const realFormatter = new NativeIntl.DateTimeFormat(...args);
1165
+ const formatter = {};
1166
+ [
1167
+ "formatRange",
1168
+ "formatRangeToParts",
1169
+ "resolvedOptions"
1170
+ ].forEach((method) => {
1171
+ formatter[method] = realFormatter[method].bind(realFormatter);
1172
+ });
1173
+ ["format", "formatToParts"].forEach((method) => {
1174
+ formatter[method] = function(date) {
1175
+ return realFormatter[method](date || ClockIntl.clock.now);
1176
+ };
1177
+ });
1178
+ return formatter;
1179
+ };
1180
+ ClockIntl.DateTimeFormat.prototype = Object.create(NativeIntl.DateTimeFormat.prototype);
1181
+ ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;
1182
+ return ClockIntl;
1183
+ }
1184
+ function enqueueJob(clock, job) {
1185
+ if (!clock.jobs) clock.jobs = [];
1186
+ clock.jobs.push(job);
1187
+ }
1188
+ function runJobs(clock) {
1189
+ if (!clock.jobs) return;
1190
+ for (let i = 0; i < clock.jobs.length; i++) {
1191
+ const job = clock.jobs[i];
1192
+ job.func.apply(null, job.args);
1193
+ checkIsNearInfiniteLimit(clock, i);
1194
+ if (clock.loopLimit && i > clock.loopLimit) throw getInfiniteLoopError(clock, job);
1195
+ }
1196
+ resetIsNearInfiniteLimit();
1197
+ clock.jobs = [];
1198
+ }
1199
+ /**
1200
+ * @param {Clock} clock
1201
+ * @param {Timer} timer
1202
+ * @returns {number} id of the created timer
1203
+ */
1204
+ function addTimer(clock, timer) {
1205
+ if (timer.func === void 0) throw new Error("Callback must be provided to timer calls");
1206
+ if (addTimerReturnsObject) {
1207
+ if (typeof timer.func !== "function") throw new TypeError(`[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`);
1208
+ }
1209
+ if (isNearInfiniteLimit) timer.error = /* @__PURE__ */ new Error();
1210
+ timer.type = timer.immediate ? "Immediate" : "Timeout";
1211
+ if (timer.hasOwnProperty("delay")) {
1212
+ if (typeof timer.delay !== "number") timer.delay = parseInt(timer.delay, 10);
1213
+ if (!isNumberFinite(timer.delay)) timer.delay = 0;
1214
+ timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
1215
+ timer.delay = Math.max(0, timer.delay);
1216
+ }
1217
+ if (timer.hasOwnProperty("interval")) {
1218
+ timer.type = "Interval";
1219
+ timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
1220
+ }
1221
+ if (timer.hasOwnProperty("animation")) {
1222
+ timer.type = "AnimationFrame";
1223
+ timer.animation = true;
1224
+ }
1225
+ if (timer.hasOwnProperty("idleCallback")) {
1226
+ timer.type = "IdleCallback";
1227
+ timer.idleCallback = true;
1228
+ }
1229
+ if (!clock.timers) clock.timers = {};
1230
+ timer.id = uniqueTimerId++;
1231
+ timer.createdAt = clock.now;
1232
+ timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
1233
+ clock.timers[timer.id] = timer;
1234
+ if (addTimerReturnsObject) {
1235
+ const res = {
1236
+ refed: true,
1237
+ ref: function() {
1238
+ this.refed = true;
1239
+ return res;
1240
+ },
1241
+ unref: function() {
1242
+ this.refed = false;
1243
+ return res;
1244
+ },
1245
+ hasRef: function() {
1246
+ return this.refed;
1247
+ },
1248
+ refresh: function() {
1249
+ timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
1250
+ clock.timers[timer.id] = timer;
1251
+ return res;
1252
+ },
1253
+ [Symbol.toPrimitive]: function() {
1254
+ return timer.id;
1255
+ }
1256
+ };
1257
+ return res;
1258
+ }
1259
+ return timer.id;
1260
+ }
1261
+ /**
1262
+ * Timer comparitor
1263
+ *
1264
+ * @param {Timer} a
1265
+ * @param {Timer} b
1266
+ * @returns {number}
1267
+ */
1268
+ function compareTimers(a, b) {
1269
+ if (a.callAt < b.callAt) return -1;
1270
+ if (a.callAt > b.callAt) return 1;
1271
+ if (a.immediate && !b.immediate) return -1;
1272
+ if (!a.immediate && b.immediate) return 1;
1273
+ if (a.createdAt < b.createdAt) return -1;
1274
+ if (a.createdAt > b.createdAt) return 1;
1275
+ if (a.id < b.id) return -1;
1276
+ if (a.id > b.id) return 1;
1277
+ }
1278
+ /**
1279
+ * @param {Clock} clock
1280
+ * @param {number} from
1281
+ * @param {number} to
1282
+ * @returns {Timer}
1283
+ */
1284
+ function firstTimerInRange(clock, from, to) {
1285
+ const timers = clock.timers;
1286
+ let timer = null;
1287
+ let id, isInRange;
1288
+ for (id in timers) if (timers.hasOwnProperty(id)) {
1289
+ isInRange = inRange(from, to, timers[id]);
1290
+ if (isInRange && (!timer || compareTimers(timer, timers[id]) === 1)) timer = timers[id];
1291
+ }
1292
+ return timer;
1293
+ }
1294
+ /**
1295
+ * @param {Clock} clock
1296
+ * @returns {Timer}
1297
+ */
1298
+ function firstTimer(clock) {
1299
+ const timers = clock.timers;
1300
+ let timer = null;
1301
+ let id;
1302
+ for (id in timers) if (timers.hasOwnProperty(id)) {
1303
+ if (!timer || compareTimers(timer, timers[id]) === 1) timer = timers[id];
1304
+ }
1305
+ return timer;
1306
+ }
1307
+ /**
1308
+ * @param {Clock} clock
1309
+ * @returns {Timer}
1310
+ */
1311
+ function lastTimer(clock) {
1312
+ const timers = clock.timers;
1313
+ let timer = null;
1314
+ let id;
1315
+ for (id in timers) if (timers.hasOwnProperty(id)) {
1316
+ if (!timer || compareTimers(timer, timers[id]) === -1) timer = timers[id];
1317
+ }
1318
+ return timer;
1319
+ }
1320
+ /**
1321
+ * @param {Clock} clock
1322
+ * @param {Timer} timer
1323
+ */
1324
+ function callTimer(clock, timer) {
1325
+ if (typeof timer.interval === "number") clock.timers[timer.id].callAt += timer.interval;
1326
+ else delete clock.timers[timer.id];
1327
+ if (typeof timer.func === "function") timer.func.apply(null, timer.args);
1328
+ else {
1329
+ const eval2 = eval;
1330
+ (function() {
1331
+ eval2(timer.func);
1332
+ })();
1333
+ }
1334
+ }
1335
+ /**
1336
+ * Gets clear handler name for a given timer type
1337
+ *
1338
+ * @param {string} ttype
1339
+ */
1340
+ function getClearHandler(ttype) {
1341
+ if (ttype === "IdleCallback" || ttype === "AnimationFrame") return `cancel${ttype}`;
1342
+ return `clear${ttype}`;
1343
+ }
1344
+ /**
1345
+ * Gets schedule handler name for a given timer type
1346
+ *
1347
+ * @param {string} ttype
1348
+ */
1349
+ function getScheduleHandler(ttype) {
1350
+ if (ttype === "IdleCallback" || ttype === "AnimationFrame") return `request${ttype}`;
1351
+ return `set${ttype}`;
1352
+ }
1353
+ /**
1354
+ * Creates an anonymous function to warn only once
1355
+ */
1356
+ function createWarnOnce() {
1357
+ let calls = 0;
1358
+ return function(msg) {
1359
+ !calls++ && console.warn(msg);
1360
+ };
1361
+ }
1362
+ const warnOnce = createWarnOnce();
1363
+ /**
1364
+ * @param {Clock} clock
1365
+ * @param {number} timerId
1366
+ * @param {string} ttype
1367
+ */
1368
+ function clearTimer(clock, timerId, ttype) {
1369
+ if (!timerId) return;
1370
+ if (!clock.timers) clock.timers = {};
1371
+ const id = Number(timerId);
1372
+ if (Number.isNaN(id) || id < idCounterStart) {
1373
+ const handlerName = getClearHandler(ttype);
1374
+ if (clock.shouldClearNativeTimers === true) {
1375
+ const nativeHandler = clock[`_${handlerName}`];
1376
+ return typeof nativeHandler === "function" ? nativeHandler(timerId) : void 0;
1377
+ }
1378
+ warnOnce(`FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.
1379
+ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.`);
1380
+ }
1381
+ if (clock.timers.hasOwnProperty(id)) {
1382
+ const timer = clock.timers[id];
1383
+ if (timer.type === ttype || timer.type === "Timeout" && ttype === "Interval" || timer.type === "Interval" && ttype === "Timeout") delete clock.timers[id];
1384
+ else {
1385
+ const clear = getClearHandler(ttype);
1386
+ const schedule = getScheduleHandler(timer.type);
1387
+ throw new Error(`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`);
1388
+ }
1389
+ }
1390
+ }
1391
+ /**
1392
+ * @param {Clock} clock
1393
+ * @param {Config} config
1394
+ * @returns {Timer[]}
1395
+ */
1396
+ function uninstall(clock, config) {
1397
+ let method, i, l;
1398
+ const installedHrTime = "_hrtime";
1399
+ const installedNextTick = "_nextTick";
1400
+ for (i = 0, l = clock.methods.length; i < l; i++) {
1401
+ method = clock.methods[i];
1402
+ if (method === "hrtime" && _global.process) _global.process.hrtime = clock[installedHrTime];
1403
+ else if (method === "nextTick" && _global.process) _global.process.nextTick = clock[installedNextTick];
1404
+ else if (method === "performance") {
1405
+ const originalPerfDescriptor = Object.getOwnPropertyDescriptor(clock, `_${method}`);
1406
+ if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) Object.defineProperty(_global, method, originalPerfDescriptor);
1407
+ else if (originalPerfDescriptor.configurable) _global[method] = clock[`_${method}`];
1408
+ } else if (_global[method] && _global[method].hadOwnProperty) _global[method] = clock[`_${method}`];
1409
+ else try {
1410
+ delete _global[method];
1411
+ } catch (ignore) {}
1412
+ if (clock.timersModuleMethods !== void 0) for (let j = 0; j < clock.timersModuleMethods.length; j++) {
1413
+ const entry = clock.timersModuleMethods[j];
1414
+ timersModule[entry.methodName] = entry.original;
1415
+ }
1416
+ }
1417
+ if (config.shouldAdvanceTime === true) _global.clearInterval(clock.attachedInterval);
1418
+ clock.methods = [];
1419
+ if (!clock.timers) return [];
1420
+ return Object.keys(clock.timers).map(function mapper(key) {
1421
+ return clock.timers[key];
1422
+ });
1423
+ }
1424
+ /**
1425
+ * @param {object} target the target containing the method to replace
1426
+ * @param {string} method the keyname of the method on the target
1427
+ * @param {Clock} clock
1428
+ */
1429
+ function hijackMethod(target, method, clock) {
1430
+ clock[method].hadOwnProperty = Object.prototype.hasOwnProperty.call(target, method);
1431
+ clock[`_${method}`] = target[method];
1432
+ if (method === "Date") target[method] = mirrorDateProperties(clock[method], target[method]);
1433
+ else if (method === "Intl") target[method] = clock[method];
1434
+ else if (method === "performance") {
1435
+ const originalPerfDescriptor = Object.getOwnPropertyDescriptor(target, method);
1436
+ if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
1437
+ Object.defineProperty(clock, `_${method}`, originalPerfDescriptor);
1438
+ const perfDescriptor = Object.getOwnPropertyDescriptor(clock, method);
1439
+ Object.defineProperty(target, method, perfDescriptor);
1440
+ } else target[method] = clock[method];
1441
+ } else {
1442
+ target[method] = function() {
1443
+ return clock[method].apply(clock, arguments);
1444
+ };
1445
+ Object.defineProperties(target[method], Object.getOwnPropertyDescriptors(clock[method]));
1446
+ }
1447
+ target[method].clock = clock;
1448
+ }
1449
+ /**
1450
+ * @param {Clock} clock
1451
+ * @param {number} advanceTimeDelta
1452
+ */
1453
+ function doIntervalTick(clock, advanceTimeDelta) {
1454
+ clock.tick(advanceTimeDelta);
1455
+ }
1456
+ /**
1457
+ * @typedef {object} Timers
1458
+ * @property {setTimeout} setTimeout
1459
+ * @property {clearTimeout} clearTimeout
1460
+ * @property {setInterval} setInterval
1461
+ * @property {clearInterval} clearInterval
1462
+ * @property {Date} Date
1463
+ * @property {Intl} Intl
1464
+ * @property {SetImmediate=} setImmediate
1465
+ * @property {function(NodeImmediate): void=} clearImmediate
1466
+ * @property {function(number[]):number[]=} hrtime
1467
+ * @property {NextTick=} nextTick
1468
+ * @property {Performance=} performance
1469
+ * @property {RequestAnimationFrame=} requestAnimationFrame
1470
+ * @property {boolean=} queueMicrotask
1471
+ * @property {function(number): void=} cancelAnimationFrame
1472
+ * @property {RequestIdleCallback=} requestIdleCallback
1473
+ * @property {function(number): void=} cancelIdleCallback
1474
+ */
1475
+ /** @type {Timers} */
1476
+ const timers = {
1477
+ setTimeout: _global.setTimeout,
1478
+ clearTimeout: _global.clearTimeout,
1479
+ setInterval: _global.setInterval,
1480
+ clearInterval: _global.clearInterval,
1481
+ Date: _global.Date
1482
+ };
1483
+ if (setImmediatePresent) {
1484
+ timers.setImmediate = _global.setImmediate;
1485
+ timers.clearImmediate = _global.clearImmediate;
1486
+ }
1487
+ if (hrtimePresent) timers.hrtime = _global.process.hrtime;
1488
+ if (nextTickPresent) timers.nextTick = _global.process.nextTick;
1489
+ if (performancePresent) timers.performance = _global.performance;
1490
+ if (requestAnimationFramePresent) timers.requestAnimationFrame = _global.requestAnimationFrame;
1491
+ if (queueMicrotaskPresent) timers.queueMicrotask = true;
1492
+ if (cancelAnimationFramePresent) timers.cancelAnimationFrame = _global.cancelAnimationFrame;
1493
+ if (requestIdleCallbackPresent) timers.requestIdleCallback = _global.requestIdleCallback;
1494
+ if (cancelIdleCallbackPresent) timers.cancelIdleCallback = _global.cancelIdleCallback;
1495
+ if (intlPresent) timers.Intl = _global.Intl;
1496
+ const originalSetTimeout = _global.setImmediate || _global.setTimeout;
1497
+ /**
1498
+ * @param {Date|number} [start] the system time - non-integer values are floored
1499
+ * @param {number} [loopLimit] maximum number of timers that will be run when calling runAll()
1500
+ * @returns {Clock}
1501
+ */
1502
+ function createClock(start, loopLimit) {
1503
+ start = Math.floor(getEpoch(start));
1504
+ loopLimit = loopLimit || 1e3;
1505
+ let nanos = 0;
1506
+ const adjustedSystemTime = [0, 0];
1507
+ if (NativeDate === void 0) throw new Error("The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)");
1508
+ const clock = {
1509
+ now: start,
1510
+ Date: createDate(),
1511
+ loopLimit
1512
+ };
1513
+ clock.Date.clock = clock;
1514
+ function getTimeToNextFrame() {
1515
+ return 16 - (clock.now - start) % 16;
1516
+ }
1517
+ function hrtime(prev) {
1518
+ const millisSinceStart = clock.now - adjustedSystemTime[0] - start;
1519
+ const secsSinceStart = Math.floor(millisSinceStart / 1e3);
1520
+ const remainderInNanos = (millisSinceStart - secsSinceStart * 1e3) * 1e6 + nanos - adjustedSystemTime[1];
1521
+ if (Array.isArray(prev)) {
1522
+ if (prev[1] > 1e9) throw new TypeError("Number of nanoseconds can't exceed a billion");
1523
+ const oldSecs = prev[0];
1524
+ let nanoDiff = remainderInNanos - prev[1];
1525
+ let secDiff = secsSinceStart - oldSecs;
1526
+ if (nanoDiff < 0) {
1527
+ nanoDiff += 1e9;
1528
+ secDiff -= 1;
1529
+ }
1530
+ return [secDiff, nanoDiff];
1531
+ }
1532
+ return [secsSinceStart, remainderInNanos];
1533
+ }
1534
+ function fakePerformanceNow() {
1535
+ const hrt = hrtime();
1536
+ return hrt[0] * 1e3 + hrt[1] / 1e6;
1537
+ }
1538
+ if (hrtimeBigintPresent) hrtime.bigint = function() {
1539
+ const parts = hrtime();
1540
+ return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
1541
+ };
1542
+ if (intlPresent) {
1543
+ clock.Intl = createIntl();
1544
+ clock.Intl.clock = clock;
1545
+ }
1546
+ clock.requestIdleCallback = function requestIdleCallback(func, timeout) {
1547
+ let timeToNextIdlePeriod = 0;
1548
+ if (clock.countTimers() > 0) timeToNextIdlePeriod = 50;
1549
+ const result = addTimer(clock, {
1550
+ func,
1551
+ args: Array.prototype.slice.call(arguments, 2),
1552
+ delay: typeof timeout === "undefined" ? timeToNextIdlePeriod : Math.min(timeout, timeToNextIdlePeriod),
1553
+ idleCallback: true
1554
+ });
1555
+ return Number(result);
1556
+ };
1557
+ clock.cancelIdleCallback = function cancelIdleCallback(timerId) {
1558
+ return clearTimer(clock, timerId, "IdleCallback");
1559
+ };
1560
+ clock.setTimeout = function setTimeout(func, timeout) {
1561
+ return addTimer(clock, {
1562
+ func,
1563
+ args: Array.prototype.slice.call(arguments, 2),
1564
+ delay: timeout
1565
+ });
1566
+ };
1567
+ if (typeof _global.Promise !== "undefined" && utilPromisify) clock.setTimeout[utilPromisify.custom] = function promisifiedSetTimeout(timeout, arg) {
1568
+ return new _global.Promise(function setTimeoutExecutor(resolve) {
1569
+ addTimer(clock, {
1570
+ func: resolve,
1571
+ args: [arg],
1572
+ delay: timeout
1573
+ });
1574
+ });
1575
+ };
1576
+ clock.clearTimeout = function clearTimeout(timerId) {
1577
+ return clearTimer(clock, timerId, "Timeout");
1578
+ };
1579
+ clock.nextTick = function nextTick(func) {
1580
+ return enqueueJob(clock, {
1581
+ func,
1582
+ args: Array.prototype.slice.call(arguments, 1),
1583
+ error: isNearInfiniteLimit ? /* @__PURE__ */ new Error() : null
1584
+ });
1585
+ };
1586
+ clock.queueMicrotask = function queueMicrotask(func) {
1587
+ return clock.nextTick(func);
1588
+ };
1589
+ clock.setInterval = function setInterval(func, timeout) {
1590
+ timeout = parseInt(timeout, 10);
1591
+ return addTimer(clock, {
1592
+ func,
1593
+ args: Array.prototype.slice.call(arguments, 2),
1594
+ delay: timeout,
1595
+ interval: timeout
1596
+ });
1597
+ };
1598
+ clock.clearInterval = function clearInterval(timerId) {
1599
+ return clearTimer(clock, timerId, "Interval");
1600
+ };
1601
+ if (setImmediatePresent) {
1602
+ clock.setImmediate = function setImmediate(func) {
1603
+ return addTimer(clock, {
1604
+ func,
1605
+ args: Array.prototype.slice.call(arguments, 1),
1606
+ immediate: true
1607
+ });
1608
+ };
1609
+ if (typeof _global.Promise !== "undefined" && utilPromisify) clock.setImmediate[utilPromisify.custom] = function promisifiedSetImmediate(arg) {
1610
+ return new _global.Promise(function setImmediateExecutor(resolve) {
1611
+ addTimer(clock, {
1612
+ func: resolve,
1613
+ args: [arg],
1614
+ immediate: true
1615
+ });
1616
+ });
1617
+ };
1618
+ clock.clearImmediate = function clearImmediate(timerId) {
1619
+ return clearTimer(clock, timerId, "Immediate");
1620
+ };
1621
+ }
1622
+ clock.countTimers = function countTimers() {
1623
+ return Object.keys(clock.timers || {}).length + (clock.jobs || []).length;
1624
+ };
1625
+ clock.requestAnimationFrame = function requestAnimationFrame(func) {
1626
+ const result = addTimer(clock, {
1627
+ func,
1628
+ delay: getTimeToNextFrame(),
1629
+ get args() {
1630
+ return [fakePerformanceNow()];
1631
+ },
1632
+ animation: true
1633
+ });
1634
+ return Number(result);
1635
+ };
1636
+ clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {
1637
+ return clearTimer(clock, timerId, "AnimationFrame");
1638
+ };
1639
+ clock.runMicrotasks = function runMicrotasks() {
1640
+ runJobs(clock);
1641
+ };
1642
+ /**
1643
+ * @param {number|string} tickValue milliseconds or a string parseable by parseTime
1644
+ * @param {boolean} isAsync
1645
+ * @param {Function} resolve
1646
+ * @param {Function} reject
1647
+ * @returns {number|undefined} will return the new `now` value or nothing for async
1648
+ */
1649
+ function doTick(tickValue, isAsync, resolve, reject) {
1650
+ const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
1651
+ const ms = Math.floor(msFloat);
1652
+ const remainder = nanoRemainder(msFloat);
1653
+ let nanosTotal = nanos + remainder;
1654
+ let tickTo = clock.now + ms;
1655
+ if (msFloat < 0) throw new TypeError("Negative ticks are not supported");
1656
+ if (nanosTotal >= 1e6) {
1657
+ tickTo += 1;
1658
+ nanosTotal -= 1e6;
1659
+ }
1660
+ nanos = nanosTotal;
1661
+ let tickFrom = clock.now;
1662
+ let previous = clock.now;
1663
+ let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;
1664
+ clock.duringTick = true;
1665
+ oldNow = clock.now;
1666
+ runJobs(clock);
1667
+ if (oldNow !== clock.now) {
1668
+ tickFrom += clock.now - oldNow;
1669
+ tickTo += clock.now - oldNow;
1670
+ }
1671
+ function doTickInner() {
1672
+ timer = firstTimerInRange(clock, tickFrom, tickTo);
1673
+ while (timer && tickFrom <= tickTo) {
1674
+ if (clock.timers[timer.id]) {
1675
+ tickFrom = timer.callAt;
1676
+ clock.now = timer.callAt;
1677
+ oldNow = clock.now;
1678
+ try {
1679
+ runJobs(clock);
1680
+ callTimer(clock, timer);
1681
+ } catch (e) {
1682
+ firstException = firstException || e;
1683
+ }
1684
+ if (isAsync) {
1685
+ originalSetTimeout(nextPromiseTick);
1686
+ return;
1687
+ }
1688
+ compensationCheck();
1689
+ }
1690
+ postTimerCall();
1691
+ }
1692
+ oldNow = clock.now;
1693
+ runJobs(clock);
1694
+ if (oldNow !== clock.now) {
1695
+ tickFrom += clock.now - oldNow;
1696
+ tickTo += clock.now - oldNow;
1697
+ }
1698
+ clock.duringTick = false;
1699
+ timer = firstTimerInRange(clock, tickFrom, tickTo);
1700
+ if (timer) try {
1701
+ clock.tick(tickTo - clock.now);
1702
+ } catch (e) {
1703
+ firstException = firstException || e;
1704
+ }
1705
+ else {
1706
+ clock.now = tickTo;
1707
+ nanos = nanosTotal;
1708
+ }
1709
+ if (firstException) throw firstException;
1710
+ if (isAsync) resolve(clock.now);
1711
+ else return clock.now;
1712
+ }
1713
+ nextPromiseTick = isAsync && function() {
1714
+ try {
1715
+ compensationCheck();
1716
+ postTimerCall();
1717
+ doTickInner();
1718
+ } catch (e) {
1719
+ reject(e);
1720
+ }
1721
+ };
1722
+ compensationCheck = function() {
1723
+ if (oldNow !== clock.now) {
1724
+ tickFrom += clock.now - oldNow;
1725
+ tickTo += clock.now - oldNow;
1726
+ previous += clock.now - oldNow;
1727
+ }
1728
+ };
1729
+ postTimerCall = function() {
1730
+ timer = firstTimerInRange(clock, previous, tickTo);
1731
+ previous = tickFrom;
1732
+ };
1733
+ return doTickInner();
1734
+ }
1735
+ /**
1736
+ * @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
1737
+ * @returns {number} will return the new `now` value
1738
+ */
1739
+ clock.tick = function tick(tickValue) {
1740
+ return doTick(tickValue, false);
1741
+ };
1742
+ if (typeof _global.Promise !== "undefined")
1743
+ /**
1744
+ * @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
1745
+ * @returns {Promise}
1746
+ */
1747
+ clock.tickAsync = function tickAsync(tickValue) {
1748
+ return new _global.Promise(function(resolve, reject) {
1749
+ originalSetTimeout(function() {
1750
+ try {
1751
+ doTick(tickValue, true, resolve, reject);
1752
+ } catch (e) {
1753
+ reject(e);
1754
+ }
1755
+ });
1756
+ });
1757
+ };
1758
+ clock.next = function next() {
1759
+ runJobs(clock);
1760
+ const timer = firstTimer(clock);
1761
+ if (!timer) return clock.now;
1762
+ clock.duringTick = true;
1763
+ try {
1764
+ clock.now = timer.callAt;
1765
+ callTimer(clock, timer);
1766
+ runJobs(clock);
1767
+ return clock.now;
1768
+ } finally {
1769
+ clock.duringTick = false;
1770
+ }
1771
+ };
1772
+ if (typeof _global.Promise !== "undefined") clock.nextAsync = function nextAsync() {
1773
+ return new _global.Promise(function(resolve, reject) {
1774
+ originalSetTimeout(function() {
1775
+ try {
1776
+ const timer = firstTimer(clock);
1777
+ if (!timer) {
1778
+ resolve(clock.now);
1779
+ return;
1780
+ }
1781
+ let err;
1782
+ clock.duringTick = true;
1783
+ clock.now = timer.callAt;
1784
+ try {
1785
+ callTimer(clock, timer);
1786
+ } catch (e) {
1787
+ err = e;
1788
+ }
1789
+ clock.duringTick = false;
1790
+ originalSetTimeout(function() {
1791
+ if (err) reject(err);
1792
+ else resolve(clock.now);
1793
+ });
1794
+ } catch (e) {
1795
+ reject(e);
1796
+ }
1797
+ });
1798
+ });
1799
+ };
1800
+ clock.runAll = function runAll() {
1801
+ let numTimers, i;
1802
+ runJobs(clock);
1803
+ for (i = 0; i < clock.loopLimit; i++) {
1804
+ if (!clock.timers) {
1805
+ resetIsNearInfiniteLimit();
1806
+ return clock.now;
1807
+ }
1808
+ numTimers = Object.keys(clock.timers).length;
1809
+ if (numTimers === 0) {
1810
+ resetIsNearInfiniteLimit();
1811
+ return clock.now;
1812
+ }
1813
+ clock.next();
1814
+ checkIsNearInfiniteLimit(clock, i);
1815
+ }
1816
+ const excessJob = firstTimer(clock);
1817
+ throw getInfiniteLoopError(clock, excessJob);
1818
+ };
1819
+ clock.runToFrame = function runToFrame() {
1820
+ return clock.tick(getTimeToNextFrame());
1821
+ };
1822
+ if (typeof _global.Promise !== "undefined") clock.runAllAsync = function runAllAsync() {
1823
+ return new _global.Promise(function(resolve, reject) {
1824
+ let i = 0;
1825
+ /**
1826
+ *
1827
+ */
1828
+ function doRun() {
1829
+ originalSetTimeout(function() {
1830
+ try {
1831
+ let numTimers;
1832
+ if (i < clock.loopLimit) {
1833
+ if (!clock.timers) {
1834
+ resetIsNearInfiniteLimit();
1835
+ resolve(clock.now);
1836
+ return;
1837
+ }
1838
+ numTimers = Object.keys(clock.timers).length;
1839
+ if (numTimers === 0) {
1840
+ resetIsNearInfiniteLimit();
1841
+ resolve(clock.now);
1842
+ return;
1843
+ }
1844
+ clock.next();
1845
+ i++;
1846
+ doRun();
1847
+ checkIsNearInfiniteLimit(clock, i);
1848
+ return;
1849
+ }
1850
+ const excessJob = firstTimer(clock);
1851
+ reject(getInfiniteLoopError(clock, excessJob));
1852
+ } catch (e) {
1853
+ reject(e);
1854
+ }
1855
+ });
1856
+ }
1857
+ doRun();
1858
+ });
1859
+ };
1860
+ clock.runToLast = function runToLast() {
1861
+ const timer = lastTimer(clock);
1862
+ if (!timer) {
1863
+ runJobs(clock);
1864
+ return clock.now;
1865
+ }
1866
+ return clock.tick(timer.callAt - clock.now);
1867
+ };
1868
+ if (typeof _global.Promise !== "undefined") clock.runToLastAsync = function runToLastAsync() {
1869
+ return new _global.Promise(function(resolve, reject) {
1870
+ originalSetTimeout(function() {
1871
+ try {
1872
+ const timer = lastTimer(clock);
1873
+ if (!timer) resolve(clock.now);
1874
+ resolve(clock.tickAsync(timer.callAt - clock.now));
1875
+ } catch (e) {
1876
+ reject(e);
1877
+ }
1878
+ });
1879
+ });
1880
+ };
1881
+ clock.reset = function reset() {
1882
+ nanos = 0;
1883
+ clock.timers = {};
1884
+ clock.jobs = [];
1885
+ clock.now = start;
1886
+ };
1887
+ clock.setSystemTime = function setSystemTime(systemTime) {
1888
+ const newNow = getEpoch(systemTime);
1889
+ const difference = newNow - clock.now;
1890
+ let id, timer;
1891
+ adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
1892
+ adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
1893
+ clock.now = newNow;
1894
+ nanos = 0;
1895
+ for (id in clock.timers) if (clock.timers.hasOwnProperty(id)) {
1896
+ timer = clock.timers[id];
1897
+ timer.createdAt += difference;
1898
+ timer.callAt += difference;
1899
+ }
1900
+ };
1901
+ /**
1902
+ * @param {string|number} tickValue number of milliseconds or a human-readable value like "01:11:15"
1903
+ * @returns {number} will return the new `now` value
1904
+ */
1905
+ clock.jump = function jump(tickValue) {
1906
+ const msFloat = typeof tickValue === "number" ? tickValue : parseTime(tickValue);
1907
+ const ms = Math.floor(msFloat);
1908
+ for (const timer of Object.values(clock.timers)) if (clock.now + ms > timer.callAt) timer.callAt = clock.now + ms;
1909
+ clock.tick(ms);
1910
+ };
1911
+ if (performancePresent) {
1912
+ clock.performance = Object.create(null);
1913
+ clock.performance.now = fakePerformanceNow;
1914
+ }
1915
+ if (hrtimePresent) clock.hrtime = hrtime;
1916
+ return clock;
1917
+ }
1918
+ /**
1919
+ * @param {Config=} [config] Optional config
1920
+ * @returns {Clock}
1921
+ */
1922
+ function install(config) {
1923
+ if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || typeof config === "number") throw new TypeError(`FakeTimers.install called with ${String(config)} install requires an object parameter`);
1924
+ if (_global.Date.isFake === true) throw new TypeError("Can't install fake timers twice on the same global object.");
1925
+ config = typeof config !== "undefined" ? config : {};
1926
+ config.shouldAdvanceTime = config.shouldAdvanceTime || false;
1927
+ config.advanceTimeDelta = config.advanceTimeDelta || 20;
1928
+ config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
1929
+ if (config.target) throw new TypeError("config.target is no longer supported. Use `withGlobal(target)` instead.");
1930
+ let i, l;
1931
+ const clock = createClock(config.now, config.loopLimit);
1932
+ clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
1933
+ clock.uninstall = function() {
1934
+ return uninstall(clock, config);
1935
+ };
1936
+ clock.methods = config.toFake || [];
1937
+ if (clock.methods.length === 0) clock.methods = Object.keys(timers).filter(function(key) {
1938
+ return key !== "nextTick" && key !== "queueMicrotask";
1939
+ });
1940
+ if (config.shouldAdvanceTime === true) {
1941
+ const intervalTick = doIntervalTick.bind(null, clock, config.advanceTimeDelta);
1942
+ clock.attachedInterval = _global.setInterval(intervalTick, config.advanceTimeDelta);
1943
+ }
1944
+ if (clock.methods.includes("performance")) {
1945
+ const proto = (() => {
1946
+ if (hasPerformanceConstructorPrototype) return _global.performance.constructor.prototype;
1947
+ if (hasPerformancePrototype) return _global.Performance.prototype;
1948
+ })();
1949
+ if (proto) Object.getOwnPropertyNames(proto).forEach(function(name) {
1950
+ if (name !== "now") clock.performance[name] = name.indexOf("getEntries") === 0 ? NOOP_ARRAY : NOOP;
1951
+ });
1952
+ else if ((config.toFake || []).includes("performance")) throw new ReferenceError("non-existent performance object cannot be faked");
1953
+ }
1954
+ if (_global === globalObject && timersModule) clock.timersModuleMethods = [];
1955
+ for (i = 0, l = clock.methods.length; i < l; i++) {
1956
+ const nameOfMethodToReplace = clock.methods[i];
1957
+ if (nameOfMethodToReplace === "hrtime") {
1958
+ if (_global.process && typeof _global.process.hrtime === "function") hijackMethod(_global.process, nameOfMethodToReplace, clock);
1959
+ } else if (nameOfMethodToReplace === "nextTick") {
1960
+ if (_global.process && typeof _global.process.nextTick === "function") hijackMethod(_global.process, nameOfMethodToReplace, clock);
1961
+ } else hijackMethod(_global, nameOfMethodToReplace, clock);
1962
+ if (clock.timersModuleMethods !== void 0 && timersModule[nameOfMethodToReplace]) {
1963
+ const original = timersModule[nameOfMethodToReplace];
1964
+ clock.timersModuleMethods.push({
1965
+ methodName: nameOfMethodToReplace,
1966
+ original
1967
+ });
1968
+ timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
1969
+ }
1970
+ }
1971
+ return clock;
1972
+ }
1973
+ return {
1974
+ timers,
1975
+ createClock,
1976
+ install,
1977
+ withGlobal
1978
+ };
1979
+ }
1980
+ /**
1981
+ * @typedef {object} FakeTimers
1982
+ * @property {Timers} timers
1983
+ * @property {createClock} createClock
1984
+ * @property {Function} install
1985
+ * @property {withGlobal} withGlobal
1986
+ */
1987
+ /** @type {FakeTimers} */
1988
+ const defaultImplementation = withGlobal(globalObject);
1989
+ fakeTimersSrc.timers = defaultImplementation.timers;
1990
+ fakeTimersSrc.createClock = defaultImplementation.createClock;
1991
+ fakeTimersSrc.install = defaultImplementation.install;
1992
+ fakeTimersSrc.withGlobal = withGlobal;
1993
+ return fakeTimersSrc;
1994
+ }
1995
+ var fakeTimersSrcExports = requireFakeTimersSrc();
1996
+ var FakeTimers = class {
1997
+ _global;
1998
+ _clock;
1999
+ _fakingTime;
2000
+ _fakingDate;
2001
+ _fakeTimers;
2002
+ _userConfig;
2003
+ _now = RealDate.now;
2004
+ constructor({ global, config }) {
2005
+ this._userConfig = config;
2006
+ this._fakingDate = false;
2007
+ this._fakingTime = false;
2008
+ this._fakeTimers = fakeTimersSrcExports.withGlobal(global);
2009
+ this._global = global;
2010
+ }
2011
+ clearAllTimers() {
2012
+ if (this._fakingTime) this._clock.reset();
2013
+ }
2014
+ dispose() {
2015
+ this.useRealTimers();
2016
+ }
2017
+ runAllTimers() {
2018
+ if (this._checkFakeTimers()) this._clock.runAll();
2019
+ }
2020
+ async runAllTimersAsync() {
2021
+ if (this._checkFakeTimers()) await this._clock.runAllAsync();
2022
+ }
2023
+ runOnlyPendingTimers() {
2024
+ if (this._checkFakeTimers()) this._clock.runToLast();
2025
+ }
2026
+ async runOnlyPendingTimersAsync() {
2027
+ if (this._checkFakeTimers()) await this._clock.runToLastAsync();
2028
+ }
2029
+ advanceTimersToNextTimer(steps = 1) {
2030
+ if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
2031
+ this._clock.next();
2032
+ this._clock.tick(0);
2033
+ if (this._clock.countTimers() === 0) break;
2034
+ }
2035
+ }
2036
+ async advanceTimersToNextTimerAsync(steps = 1) {
2037
+ if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
2038
+ await this._clock.nextAsync();
2039
+ this._clock.tick(0);
2040
+ if (this._clock.countTimers() === 0) break;
2041
+ }
2042
+ }
2043
+ advanceTimersByTime(msToRun) {
2044
+ if (this._checkFakeTimers()) this._clock.tick(msToRun);
2045
+ }
2046
+ async advanceTimersByTimeAsync(msToRun) {
2047
+ if (this._checkFakeTimers()) await this._clock.tickAsync(msToRun);
2048
+ }
2049
+ advanceTimersToNextFrame() {
2050
+ if (this._checkFakeTimers()) this._clock.runToFrame();
2051
+ }
2052
+ runAllTicks() {
2053
+ if (this._checkFakeTimers()) this._clock.runMicrotasks();
2054
+ }
2055
+ useRealTimers() {
2056
+ if (this._fakingDate) {
2057
+ resetDate();
2058
+ this._fakingDate = false;
2059
+ }
2060
+ if (this._fakingTime) {
2061
+ this._clock.uninstall();
2062
+ this._fakingTime = false;
2063
+ }
2064
+ }
2065
+ useFakeTimers() {
2066
+ if (this._fakingDate) throw new Error("\"setSystemTime\" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.");
2067
+ if (!this._fakingTime) {
2068
+ const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick");
2069
+ if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) throw new Error("process.nextTick cannot be mocked inside child_process");
2070
+ const existingFakedMethods = (this._userConfig?.toFake || toFake).filter((method) => {
2071
+ switch (method) {
2072
+ case "setImmediate":
2073
+ case "clearImmediate": return method in this._global && this._global[method];
2074
+ default: return true;
2075
+ }
2076
+ });
2077
+ this._clock = this._fakeTimers.install({
2078
+ now: Date.now(),
2079
+ ...this._userConfig,
2080
+ toFake: existingFakedMethods
2081
+ });
2082
+ this._fakingTime = true;
2083
+ }
2084
+ }
2085
+ reset() {
2086
+ if (this._checkFakeTimers()) {
2087
+ const { now } = this._clock;
2088
+ this._clock.reset();
2089
+ this._clock.setSystemTime(now);
2090
+ }
2091
+ }
2092
+ setSystemTime(now) {
2093
+ if (this._fakingTime) this._clock.setSystemTime(now);
2094
+ else {
2095
+ mockDate(now ?? this.getRealSystemTime());
2096
+ this._fakingDate = true;
2097
+ }
2098
+ }
2099
+ getRealSystemTime() {
2100
+ return this._now();
2101
+ }
2102
+ getTimerCount() {
2103
+ if (this._checkFakeTimers()) return this._clock.countTimers();
2104
+ return 0;
2105
+ }
2106
+ configure(config) {
2107
+ this._userConfig = config;
2108
+ }
2109
+ isFakeTimers() {
2110
+ return this._fakingTime;
2111
+ }
2112
+ _checkFakeTimers() {
2113
+ if (!this._fakingTime) throw new Error("Timers are not mocked. Try calling \"vi.useFakeTimers()\" first.");
2114
+ return this._fakingTime;
2115
+ }
2116
+ };
2117
+ function copyStackTrace(target, source) {
2118
+ if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
2119
+ return target;
2120
+ }
2121
+ function waitFor(callback, options = {}) {
2122
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
2123
+ const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2124
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2125
+ return new Promise((resolve, reject) => {
2126
+ let lastError;
2127
+ let promiseStatus = "idle";
2128
+ let timeoutId;
2129
+ let intervalId;
2130
+ const onResolve = (result) => {
2131
+ if (timeoutId) clearTimeout(timeoutId);
2132
+ if (intervalId) clearInterval(intervalId);
2133
+ resolve(result);
2134
+ };
2135
+ const handleTimeout = () => {
2136
+ if (intervalId) clearInterval(intervalId);
2137
+ let error = lastError;
2138
+ if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
2139
+ reject(error);
2140
+ };
2141
+ const checkCallback = () => {
2142
+ if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
2143
+ if (promiseStatus === "pending") return;
2144
+ try {
2145
+ const result = callback();
2146
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
2147
+ const thenable = result;
2148
+ promiseStatus = "pending";
2149
+ thenable.then((resolvedValue) => {
2150
+ promiseStatus = "resolved";
2151
+ onResolve(resolvedValue);
2152
+ }, (rejectedValue) => {
2153
+ promiseStatus = "rejected";
2154
+ lastError = rejectedValue;
2155
+ });
2156
+ } else {
2157
+ onResolve(result);
2158
+ return true;
2159
+ }
2160
+ } catch (error) {
2161
+ lastError = error;
2162
+ }
2163
+ };
2164
+ if (checkCallback() === true) return;
2165
+ timeoutId = setTimeout(handleTimeout, timeout);
2166
+ intervalId = setInterval(checkCallback, interval);
2167
+ });
2168
+ }
2169
+ function waitUntil(callback, options = {}) {
2170
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
2171
+ const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2172
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2173
+ return new Promise((resolve, reject) => {
2174
+ let promiseStatus = "idle";
2175
+ let timeoutId;
2176
+ let intervalId;
2177
+ const onReject = (error) => {
2178
+ if (intervalId) clearInterval(intervalId);
2179
+ if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
2180
+ reject(error);
2181
+ };
2182
+ const onResolve = (result) => {
2183
+ if (!result) return;
2184
+ if (timeoutId) clearTimeout(timeoutId);
2185
+ if (intervalId) clearInterval(intervalId);
2186
+ resolve(result);
2187
+ return true;
2188
+ };
2189
+ const checkCallback = () => {
2190
+ if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
2191
+ if (promiseStatus === "pending") return;
2192
+ try {
2193
+ const result = callback();
2194
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
2195
+ const thenable = result;
2196
+ promiseStatus = "pending";
2197
+ thenable.then((resolvedValue) => {
2198
+ promiseStatus = "resolved";
2199
+ onResolve(resolvedValue);
2200
+ }, (rejectedValue) => {
2201
+ promiseStatus = "rejected";
2202
+ onReject(rejectedValue);
2203
+ });
2204
+ } else return onResolve(result);
2205
+ } catch (error) {
2206
+ onReject(error);
2207
+ }
2208
+ };
2209
+ if (checkCallback() === true) return;
2210
+ timeoutId = setTimeout(onReject, timeout);
2211
+ intervalId = setInterval(checkCallback, interval);
2212
+ });
2213
+ }
2214
+ function createVitest() {
2215
+ let _mockedDate = null;
2216
+ let _config = null;
2217
+ const workerState = getWorkerState();
2218
+ let _timers;
2219
+ const timers = () => _timers ||= new FakeTimers({
2220
+ global: globalThis,
2221
+ config: workerState.config.fakeTimers
2222
+ });
2223
+ const _stubsGlobal = /* @__PURE__ */ new Map();
2224
+ const _stubsEnv = /* @__PURE__ */ new Map();
2225
+ const _envBooleans = [
2226
+ "PROD",
2227
+ "DEV",
2228
+ "SSR"
2229
+ ];
2230
+ const utils = {
2231
+ useFakeTimers(config) {
2232
+ if (isChildProcess()) {
2233
+ if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) throw new Error("vi.useFakeTimers({ toFake: [\"nextTick\"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.");
2234
+ }
2235
+ if (config) timers().configure({
2236
+ ...workerState.config.fakeTimers,
2237
+ ...config
2238
+ });
2239
+ else timers().configure(workerState.config.fakeTimers);
2240
+ timers().useFakeTimers();
2241
+ return utils;
2242
+ },
2243
+ isFakeTimers() {
2244
+ return timers().isFakeTimers();
2245
+ },
2246
+ useRealTimers() {
2247
+ timers().useRealTimers();
2248
+ _mockedDate = null;
2249
+ return utils;
2250
+ },
2251
+ runOnlyPendingTimers() {
2252
+ timers().runOnlyPendingTimers();
2253
+ return utils;
2254
+ },
2255
+ async runOnlyPendingTimersAsync() {
2256
+ await timers().runOnlyPendingTimersAsync();
2257
+ return utils;
2258
+ },
2259
+ runAllTimers() {
2260
+ timers().runAllTimers();
2261
+ return utils;
2262
+ },
2263
+ async runAllTimersAsync() {
2264
+ await timers().runAllTimersAsync();
2265
+ return utils;
2266
+ },
2267
+ runAllTicks() {
2268
+ timers().runAllTicks();
2269
+ return utils;
2270
+ },
2271
+ advanceTimersByTime(ms) {
2272
+ timers().advanceTimersByTime(ms);
2273
+ return utils;
2274
+ },
2275
+ async advanceTimersByTimeAsync(ms) {
2276
+ await timers().advanceTimersByTimeAsync(ms);
2277
+ return utils;
2278
+ },
2279
+ advanceTimersToNextTimer() {
2280
+ timers().advanceTimersToNextTimer();
2281
+ return utils;
2282
+ },
2283
+ async advanceTimersToNextTimerAsync() {
2284
+ await timers().advanceTimersToNextTimerAsync();
2285
+ return utils;
2286
+ },
2287
+ advanceTimersToNextFrame() {
2288
+ timers().advanceTimersToNextFrame();
2289
+ return utils;
2290
+ },
2291
+ getTimerCount() {
2292
+ return timers().getTimerCount();
2293
+ },
2294
+ setSystemTime(time) {
2295
+ const date = time instanceof Date ? time : new Date(time);
2296
+ _mockedDate = date;
2297
+ timers().setSystemTime(date);
2298
+ return utils;
2299
+ },
2300
+ getMockedSystemTime() {
2301
+ return _mockedDate;
2302
+ },
2303
+ getRealSystemTime() {
2304
+ return timers().getRealSystemTime();
2305
+ },
2306
+ clearAllTimers() {
2307
+ timers().clearAllTimers();
2308
+ return utils;
2309
+ },
2310
+ spyOn,
2311
+ fn,
2312
+ waitFor,
2313
+ waitUntil,
2314
+ hoisted(factory) {
2315
+ assertTypes(factory, "\"vi.hoisted\" factory", ["function"]);
2316
+ return factory();
2317
+ },
2318
+ mock(path, factory) {
2319
+ if (typeof path !== "string") throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
2320
+ const importer = getImporter("mock");
2321
+ _mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
2322
+ },
2323
+ unmock(path) {
2324
+ if (typeof path !== "string") throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
2325
+ _mocker().queueUnmock(path, getImporter("unmock"));
2326
+ },
2327
+ doMock(path, factory) {
2328
+ if (typeof path !== "string") throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
2329
+ const importer = getImporter("doMock");
2330
+ _mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
2331
+ },
2332
+ doUnmock(path) {
2333
+ if (typeof path !== "string") throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
2334
+ _mocker().queueUnmock(path, getImporter("doUnmock"));
2335
+ },
2336
+ async importActual(path) {
2337
+ return _mocker().importActual(path, getImporter("importActual"), _mocker().getMockContext().callstack);
2338
+ },
2339
+ async importMock(path) {
2340
+ return _mocker().importMock(path, getImporter("importMock"));
2341
+ },
2342
+ mocked(item, _options = {}) {
2343
+ return item;
2344
+ },
2345
+ isMockFunction(fn2) {
2346
+ return isMockFunction(fn2);
2347
+ },
2348
+ clearAllMocks() {
2349
+ mocks.forEach((spy) => spy.mockClear());
2350
+ return utils;
2351
+ },
2352
+ resetAllMocks() {
2353
+ mocks.forEach((spy) => spy.mockReset());
2354
+ return utils;
2355
+ },
2356
+ restoreAllMocks() {
2357
+ mocks.forEach((spy) => spy.mockRestore());
2358
+ return utils;
2359
+ },
2360
+ stubGlobal(name, value) {
2361
+ if (!_stubsGlobal.has(name)) _stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
2362
+ Object.defineProperty(globalThis, name, {
2363
+ value,
2364
+ writable: true,
2365
+ configurable: true,
2366
+ enumerable: true
2367
+ });
2368
+ return utils;
2369
+ },
2370
+ stubEnv(name, value) {
2371
+ if (!_stubsEnv.has(name)) _stubsEnv.set(name, process.env[name]);
2372
+ if (_envBooleans.includes(name)) process.env[name] = value ? "1" : "";
2373
+ else if (value === void 0) delete process.env[name];
2374
+ else process.env[name] = String(value);
2375
+ return utils;
2376
+ },
2377
+ unstubAllGlobals() {
2378
+ _stubsGlobal.forEach((original, name) => {
2379
+ if (!original) Reflect.deleteProperty(globalThis, name);
2380
+ else Object.defineProperty(globalThis, name, original);
2381
+ });
2382
+ _stubsGlobal.clear();
2383
+ return utils;
2384
+ },
2385
+ unstubAllEnvs() {
2386
+ _stubsEnv.forEach((original, name) => {
2387
+ if (original === void 0) delete process.env[name];
2388
+ else process.env[name] = original;
2389
+ });
2390
+ _stubsEnv.clear();
2391
+ return utils;
2392
+ },
2393
+ resetModules() {
2394
+ resetModules(workerState.moduleCache);
2395
+ return utils;
2396
+ },
2397
+ async dynamicImportSettled() {
2398
+ return waitForImportsToResolve();
2399
+ },
2400
+ setConfig(config) {
2401
+ if (!_config) _config = { ...workerState.config };
2402
+ Object.assign(workerState.config, config);
2403
+ },
2404
+ resetConfig() {
2405
+ if (_config) Object.assign(workerState.config, _config);
2406
+ }
2407
+ };
2408
+ return utils;
2409
+ }
2410
+ const vitest = createVitest();
2411
+ const vi = vitest;
2412
+ function _mocker() {
2413
+ return typeof __vitest_mocker__ !== "undefined" ? __vitest_mocker__ : new Proxy({}, { get(_, name) {
2414
+ throw new Error(`Vitest mocker was not initialized in this environment. vi.${String(name)}() is forbidden.`);
2415
+ } });
2416
+ }
2417
+ function getImporter(name) {
2418
+ const stackArray = createSimpleStackTrace({ stackTraceLimit: 5 }).split("\n");
2419
+ return parseSingleStack(stackArray[stackArray.findIndex((stack2) => {
2420
+ return stack2.includes(` at Object.${name}`) || stack2.includes(`${name}@`);
2421
+ }) + 1])?.file || "";
2422
+ }
2423
+ //#endregion
2424
+ export { globalExpect as a, vitest as b, createExpect as c, getSnapshotClient as g, vi as v };
2425
+
2426
+ //# sourceMappingURL=vi.DgezovHB.js.map