@azurioh/discord-kernel 0.1.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 (373) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/dist/authz/authorizer.d.ts +45 -0
  4. package/dist/authz/authorizer.d.ts.map +1 -0
  5. package/dist/authz/authorizer.js +31 -0
  6. package/dist/authz/authorizer.js.map +1 -0
  7. package/dist/authz/require-level-guard.d.ts +23 -0
  8. package/dist/authz/require-level-guard.d.ts.map +1 -0
  9. package/dist/authz/require-level-guard.js +37 -0
  10. package/dist/authz/require-level-guard.js.map +1 -0
  11. package/dist/clock.d.ts +13 -0
  12. package/dist/clock.d.ts.map +1 -0
  13. package/dist/clock.js +13 -0
  14. package/dist/clock.js.map +1 -0
  15. package/dist/concurrency/keyed-queue.d.ts +18 -0
  16. package/dist/concurrency/keyed-queue.d.ts.map +1 -0
  17. package/dist/concurrency/keyed-queue.js +37 -0
  18. package/dist/concurrency/keyed-queue.js.map +1 -0
  19. package/dist/concurrency/run-with-concurrency.d.ts +15 -0
  20. package/dist/concurrency/run-with-concurrency.d.ts.map +1 -0
  21. package/dist/concurrency/run-with-concurrency.js +40 -0
  22. package/dist/concurrency/run-with-concurrency.js.map +1 -0
  23. package/dist/config/env.d.ts +17 -0
  24. package/dist/config/env.d.ts.map +1 -0
  25. package/dist/config/env.js +49 -0
  26. package/dist/config/env.js.map +1 -0
  27. package/dist/config/errors.d.ts +14 -0
  28. package/dist/config/errors.d.ts.map +1 -0
  29. package/dist/config/errors.js +25 -0
  30. package/dist/config/errors.js.map +1 -0
  31. package/dist/datetime.d.ts +34 -0
  32. package/dist/datetime.d.ts.map +1 -0
  33. package/dist/datetime.js +188 -0
  34. package/dist/datetime.js.map +1 -0
  35. package/dist/discord/api-errors.d.ts +20 -0
  36. package/dist/discord/api-errors.d.ts.map +1 -0
  37. package/dist/discord/api-errors.js +90 -0
  38. package/dist/discord/api-errors.js.map +1 -0
  39. package/dist/discord/channel-exporter.d.ts +42 -0
  40. package/dist/discord/channel-exporter.d.ts.map +1 -0
  41. package/dist/discord/channel-exporter.js +3 -0
  42. package/dist/discord/channel-exporter.js.map +1 -0
  43. package/dist/discord/command/autocomplete-dispatcher.d.ts +26 -0
  44. package/dist/discord/command/autocomplete-dispatcher.d.ts.map +1 -0
  45. package/dist/discord/command/autocomplete-dispatcher.js +41 -0
  46. package/dist/discord/command/autocomplete-dispatcher.js.map +1 -0
  47. package/dist/discord/command/autocomplete.d.ts +18 -0
  48. package/dist/discord/command/autocomplete.d.ts.map +1 -0
  49. package/dist/discord/command/autocomplete.js +65 -0
  50. package/dist/discord/command/autocomplete.js.map +1 -0
  51. package/dist/discord/command/context.d.ts +33 -0
  52. package/dist/discord/command/context.d.ts.map +1 -0
  53. package/dist/discord/command/context.js +48 -0
  54. package/dist/discord/command/context.js.map +1 -0
  55. package/dist/discord/command/cooldown-guard.d.ts +25 -0
  56. package/dist/discord/command/cooldown-guard.d.ts.map +1 -0
  57. package/dist/discord/command/cooldown-guard.js +60 -0
  58. package/dist/discord/command/cooldown-guard.js.map +1 -0
  59. package/dist/discord/command/create-command.d.ts +100 -0
  60. package/dist/discord/command/create-command.d.ts.map +1 -0
  61. package/dist/discord/command/create-command.js +245 -0
  62. package/dist/discord/command/create-command.js.map +1 -0
  63. package/dist/discord/command/create-context-menu-command.d.ts +51 -0
  64. package/dist/discord/command/create-context-menu-command.d.ts.map +1 -0
  65. package/dist/discord/command/create-context-menu-command.js +128 -0
  66. package/dist/discord/command/create-context-menu-command.js.map +1 -0
  67. package/dist/discord/command/errors.d.ts +19 -0
  68. package/dist/discord/command/errors.d.ts.map +1 -0
  69. package/dist/discord/command/errors.js +27 -0
  70. package/dist/discord/command/errors.js.map +1 -0
  71. package/dist/discord/command/guard.d.ts +30 -0
  72. package/dist/discord/command/guard.d.ts.map +1 -0
  73. package/dist/discord/command/guard.js +34 -0
  74. package/dist/discord/command/guard.js.map +1 -0
  75. package/dist/discord/command/localization.d.ts +9 -0
  76. package/dist/discord/command/localization.d.ts.map +1 -0
  77. package/dist/discord/command/localization.js +13 -0
  78. package/dist/discord/command/localization.js.map +1 -0
  79. package/dist/discord/command/options.d.ts +113 -0
  80. package/dist/discord/command/options.d.ts.map +1 -0
  81. package/dist/discord/command/options.js +509 -0
  82. package/dist/discord/command/options.js.map +1 -0
  83. package/dist/discord/command/permission-guard.d.ts +21 -0
  84. package/dist/discord/command/permission-guard.d.ts.map +1 -0
  85. package/dist/discord/command/permission-guard.js +69 -0
  86. package/dist/discord/command/permission-guard.js.map +1 -0
  87. package/dist/discord/command/router.d.ts +48 -0
  88. package/dist/discord/command/router.d.ts.map +1 -0
  89. package/dist/discord/command/router.js +118 -0
  90. package/dist/discord/command/router.js.map +1 -0
  91. package/dist/discord/command/types.d.ts +51 -0
  92. package/dist/discord/command/types.d.ts.map +1 -0
  93. package/dist/discord/command/types.js +3 -0
  94. package/dist/discord/command/types.js.map +1 -0
  95. package/dist/discord/components/component-router.d.ts +116 -0
  96. package/dist/discord/components/component-router.d.ts.map +1 -0
  97. package/dist/discord/components/component-router.js +123 -0
  98. package/dist/discord/components/component-router.js.map +1 -0
  99. package/dist/discord/components/interactive-message/index.d.ts +3 -0
  100. package/dist/discord/components/interactive-message/index.d.ts.map +1 -0
  101. package/dist/discord/components/interactive-message/index.js +11 -0
  102. package/dist/discord/components/interactive-message/index.js.map +1 -0
  103. package/dist/discord/components/interactive-message/interactive-message-collector.d.ts +195 -0
  104. package/dist/discord/components/interactive-message/interactive-message-collector.d.ts.map +1 -0
  105. package/dist/discord/components/interactive-message/interactive-message-collector.js +151 -0
  106. package/dist/discord/components/interactive-message/interactive-message-collector.js.map +1 -0
  107. package/dist/discord/components/interactive-message/mount-interactive-message.d.ts +30 -0
  108. package/dist/discord/components/interactive-message/mount-interactive-message.d.ts.map +1 -0
  109. package/dist/discord/components/interactive-message/mount-interactive-message.js +44 -0
  110. package/dist/discord/components/interactive-message/mount-interactive-message.js.map +1 -0
  111. package/dist/discord/components/paginator/index.d.ts +5 -0
  112. package/dist/discord/components/paginator/index.d.ts.map +1 -0
  113. package/dist/discord/components/paginator/index.js +15 -0
  114. package/dist/discord/components/paginator/index.js.map +1 -0
  115. package/dist/discord/components/paginator/mount-paginator.d.ts +25 -0
  116. package/dist/discord/components/paginator/mount-paginator.d.ts.map +1 -0
  117. package/dist/discord/components/paginator/mount-paginator.js +41 -0
  118. package/dist/discord/components/paginator/mount-paginator.js.map +1 -0
  119. package/dist/discord/components/paginator/page-state.d.ts +21 -0
  120. package/dist/discord/components/paginator/page-state.d.ts.map +1 -0
  121. package/dist/discord/components/paginator/page-state.js +44 -0
  122. package/dist/discord/components/paginator/page-state.js.map +1 -0
  123. package/dist/discord/components/paginator/paginator-buttons.d.ts +17 -0
  124. package/dist/discord/components/paginator/paginator-buttons.d.ts.map +1 -0
  125. package/dist/discord/components/paginator/paginator-buttons.js +45 -0
  126. package/dist/discord/components/paginator/paginator-buttons.js.map +1 -0
  127. package/dist/discord/components/paginator/paginator-view.d.ts +26 -0
  128. package/dist/discord/components/paginator/paginator-view.d.ts.map +1 -0
  129. package/dist/discord/components/paginator/paginator-view.js +28 -0
  130. package/dist/discord/components/paginator/paginator-view.js.map +1 -0
  131. package/dist/discord/components/persistent-paginator.d.ts +47 -0
  132. package/dist/discord/components/persistent-paginator.d.ts.map +1 -0
  133. package/dist/discord/components/persistent-paginator.js +137 -0
  134. package/dist/discord/components/persistent-paginator.js.map +1 -0
  135. package/dist/discord/components/settings-editor/index.d.ts +7 -0
  136. package/dist/discord/components/settings-editor/index.d.ts.map +1 -0
  137. package/dist/discord/components/settings-editor/index.js +22 -0
  138. package/dist/discord/components/settings-editor/index.js.map +1 -0
  139. package/dist/discord/components/settings-editor/mount-settings-editor.d.ts +140 -0
  140. package/dist/discord/components/settings-editor/mount-settings-editor.d.ts.map +1 -0
  141. package/dist/discord/components/settings-editor/mount-settings-editor.js +344 -0
  142. package/dist/discord/components/settings-editor/mount-settings-editor.js.map +1 -0
  143. package/dist/discord/components/settings-editor/navigation.d.ts +49 -0
  144. package/dist/discord/components/settings-editor/navigation.d.ts.map +1 -0
  145. package/dist/discord/components/settings-editor/navigation.js +39 -0
  146. package/dist/discord/components/settings-editor/navigation.js.map +1 -0
  147. package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts +56 -0
  148. package/dist/discord/components/settings-editor/settings-editor-card.view.d.ts.map +1 -0
  149. package/dist/discord/components/settings-editor/settings-editor-card.view.js +284 -0
  150. package/dist/discord/components/settings-editor/settings-editor-card.view.js.map +1 -0
  151. package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts +69 -0
  152. package/dist/discord/components/settings-editor/settings-editor-field-modal.d.ts.map +1 -0
  153. package/dist/discord/components/settings-editor/settings-editor-field-modal.js +353 -0
  154. package/dist/discord/components/settings-editor/settings-editor-field-modal.js.map +1 -0
  155. package/dist/discord/components/settings-editor/settings-editor-fields.d.ts +216 -0
  156. package/dist/discord/components/settings-editor/settings-editor-fields.d.ts.map +1 -0
  157. package/dist/discord/components/settings-editor/settings-editor-fields.js +66 -0
  158. package/dist/discord/components/settings-editor/settings-editor-fields.js.map +1 -0
  159. package/dist/discord/components/settings-editor/settings-editor.view.d.ts +303 -0
  160. package/dist/discord/components/settings-editor/settings-editor.view.d.ts.map +1 -0
  161. package/dist/discord/components/settings-editor/settings-editor.view.js +316 -0
  162. package/dist/discord/components/settings-editor/settings-editor.view.js.map +1 -0
  163. package/dist/discord/events/create-event.d.ts +5 -0
  164. package/dist/discord/events/create-event.d.ts.map +1 -0
  165. package/dist/discord/events/create-event.js +8 -0
  166. package/dist/discord/events/create-event.js.map +1 -0
  167. package/dist/discord/events/event-router.d.ts +16 -0
  168. package/dist/discord/events/event-router.d.ts.map +1 -0
  169. package/dist/discord/events/event-router.js +51 -0
  170. package/dist/discord/events/event-router.js.map +1 -0
  171. package/dist/discord/events/types.d.ts +16 -0
  172. package/dist/discord/events/types.d.ts.map +1 -0
  173. package/dist/discord/events/types.js +3 -0
  174. package/dist/discord/events/types.js.map +1 -0
  175. package/dist/discord/i18n.d.ts +58 -0
  176. package/dist/discord/i18n.d.ts.map +1 -0
  177. package/dist/discord/i18n.js +173 -0
  178. package/dist/discord/i18n.js.map +1 -0
  179. package/dist/discord/interaction/button.d.ts +39 -0
  180. package/dist/discord/interaction/button.d.ts.map +1 -0
  181. package/dist/discord/interaction/button.js +36 -0
  182. package/dist/discord/interaction/button.js.map +1 -0
  183. package/dist/discord/interaction/interaction-router.d.ts +21 -0
  184. package/dist/discord/interaction/interaction-router.d.ts.map +1 -0
  185. package/dist/discord/interaction/interaction-router.js +24 -0
  186. package/dist/discord/interaction/interaction-router.js.map +1 -0
  187. package/dist/discord/interaction/modal.d.ts +171 -0
  188. package/dist/discord/interaction/modal.d.ts.map +1 -0
  189. package/dist/discord/interaction/modal.js +264 -0
  190. package/dist/discord/interaction/modal.js.map +1 -0
  191. package/dist/discord/interaction/select-menu.d.ts +104 -0
  192. package/dist/discord/interaction/select-menu.d.ts.map +1 -0
  193. package/dist/discord/interaction/select-menu.js +126 -0
  194. package/dist/discord/interaction/select-menu.js.map +1 -0
  195. package/dist/discord/permissions.d.ts +32 -0
  196. package/dist/discord/permissions.d.ts.map +1 -0
  197. package/dist/discord/permissions.js +40 -0
  198. package/dist/discord/permissions.js.map +1 -0
  199. package/dist/discord/placeholder-registry-errors.d.ts +10 -0
  200. package/dist/discord/placeholder-registry-errors.d.ts.map +1 -0
  201. package/dist/discord/placeholder-registry-errors.js +18 -0
  202. package/dist/discord/placeholder-registry-errors.js.map +1 -0
  203. package/dist/discord/placeholder-registry.d.ts +53 -0
  204. package/dist/discord/placeholder-registry.d.ts.map +1 -0
  205. package/dist/discord/placeholder-registry.js +52 -0
  206. package/dist/discord/placeholder-registry.js.map +1 -0
  207. package/dist/discord/presenter.d.ts +26 -0
  208. package/dist/discord/presenter.d.ts.map +1 -0
  209. package/dist/discord/presenter.js +3 -0
  210. package/dist/discord/presenter.js.map +1 -0
  211. package/dist/discord/ui/card.d.ts +114 -0
  212. package/dist/discord/ui/card.d.ts.map +1 -0
  213. package/dist/discord/ui/card.js +162 -0
  214. package/dist/discord/ui/card.js.map +1 -0
  215. package/dist/discord/ui/color-input-errors.d.ts +12 -0
  216. package/dist/discord/ui/color-input-errors.d.ts.map +1 -0
  217. package/dist/discord/ui/color-input-errors.js +21 -0
  218. package/dist/discord/ui/color-input-errors.js.map +1 -0
  219. package/dist/discord/ui/color-input.d.ts +37 -0
  220. package/dist/discord/ui/color-input.d.ts.map +1 -0
  221. package/dist/discord/ui/color-input.js +166 -0
  222. package/dist/discord/ui/color-input.js.map +1 -0
  223. package/dist/discord/ui/colors.d.ts +44 -0
  224. package/dist/discord/ui/colors.d.ts.map +1 -0
  225. package/dist/discord/ui/colors.js +45 -0
  226. package/dist/discord/ui/colors.js.map +1 -0
  227. package/dist/discord/ui/embed.d.ts +16 -0
  228. package/dist/discord/ui/embed.d.ts.map +1 -0
  229. package/dist/discord/ui/embed.js +53 -0
  230. package/dist/discord/ui/embed.js.map +1 -0
  231. package/dist/discord/ui/message-attachments.d.ts +40 -0
  232. package/dist/discord/ui/message-attachments.d.ts.map +1 -0
  233. package/dist/discord/ui/message-attachments.js +27 -0
  234. package/dist/discord/ui/message-attachments.js.map +1 -0
  235. package/dist/errors/business-error.d.ts +41 -0
  236. package/dist/errors/business-error.d.ts.map +1 -0
  237. package/dist/errors/business-error.js +39 -0
  238. package/dist/errors/business-error.js.map +1 -0
  239. package/dist/errors/describe-error.d.ts +29 -0
  240. package/dist/errors/describe-error.d.ts.map +1 -0
  241. package/dist/errors/describe-error.js +49 -0
  242. package/dist/errors/describe-error.js.map +1 -0
  243. package/dist/errors/incident-ref.d.ts +7 -0
  244. package/dist/errors/incident-ref.d.ts.map +1 -0
  245. package/dist/errors/incident-ref.js +13 -0
  246. package/dist/errors/incident-ref.js.map +1 -0
  247. package/dist/errors/index.d.ts +4 -0
  248. package/dist/errors/index.d.ts.map +1 -0
  249. package/dist/errors/index.js +15 -0
  250. package/dist/errors/index.js.map +1 -0
  251. package/dist/i18n/business-message.d.ts +14 -0
  252. package/dist/i18n/business-message.d.ts.map +1 -0
  253. package/dist/i18n/business-message.js +19 -0
  254. package/dist/i18n/business-message.js.map +1 -0
  255. package/dist/i18n/catalog.d.ts +27 -0
  256. package/dist/i18n/catalog.d.ts.map +1 -0
  257. package/dist/i18n/catalog.js +25 -0
  258. package/dist/i18n/catalog.js.map +1 -0
  259. package/dist/i18n/errors.d.ts +10 -0
  260. package/dist/i18n/errors.d.ts.map +1 -0
  261. package/dist/i18n/errors.js +18 -0
  262. package/dist/i18n/errors.js.map +1 -0
  263. package/dist/i18n/index.d.ts +6 -0
  264. package/dist/i18n/index.d.ts.map +1 -0
  265. package/dist/i18n/index.js +16 -0
  266. package/dist/i18n/index.js.map +1 -0
  267. package/dist/i18n/locale.d.ts +22 -0
  268. package/dist/i18n/locale.d.ts.map +1 -0
  269. package/dist/i18n/locale.js +40 -0
  270. package/dist/i18n/locale.js.map +1 -0
  271. package/dist/i18n/translator.d.ts +35 -0
  272. package/dist/i18n/translator.d.ts.map +1 -0
  273. package/dist/i18n/translator.js +40 -0
  274. package/dist/i18n/translator.js.map +1 -0
  275. package/dist/logger.d.ts +28 -0
  276. package/dist/logger.d.ts.map +1 -0
  277. package/dist/logger.js +3 -0
  278. package/dist/logger.js.map +1 -0
  279. package/dist/module/module.d.ts +42 -0
  280. package/dist/module/module.d.ts.map +1 -0
  281. package/dist/module/module.js +3 -0
  282. package/dist/module/module.js.map +1 -0
  283. package/dist/persistence/database.d.ts +24 -0
  284. package/dist/persistence/database.d.ts.map +1 -0
  285. package/dist/persistence/database.js +3 -0
  286. package/dist/persistence/database.js.map +1 -0
  287. package/dist/resilience/retry.d.ts +36 -0
  288. package/dist/resilience/retry.d.ts.map +1 -0
  289. package/dist/resilience/retry.js +78 -0
  290. package/dist/resilience/retry.js.map +1 -0
  291. package/dist/scheduler/errors.d.ts +25 -0
  292. package/dist/scheduler/errors.d.ts.map +1 -0
  293. package/dist/scheduler/errors.js +45 -0
  294. package/dist/scheduler/errors.js.map +1 -0
  295. package/dist/scheduler/scheduler.d.ts +68 -0
  296. package/dist/scheduler/scheduler.d.ts.map +1 -0
  297. package/dist/scheduler/scheduler.js +162 -0
  298. package/dist/scheduler/scheduler.js.map +1 -0
  299. package/package.json +89 -0
  300. package/src/authz/authorizer.ts +76 -0
  301. package/src/authz/require-level-guard.ts +42 -0
  302. package/src/clock.ts +18 -0
  303. package/src/concurrency/keyed-queue.ts +50 -0
  304. package/src/concurrency/run-with-concurrency.ts +44 -0
  305. package/src/config/env.ts +58 -0
  306. package/src/config/errors.ts +21 -0
  307. package/src/datetime.ts +221 -0
  308. package/src/discord/api-errors.ts +91 -0
  309. package/src/discord/channel-exporter.ts +48 -0
  310. package/src/discord/command/autocomplete-dispatcher.ts +54 -0
  311. package/src/discord/command/autocomplete.ts +76 -0
  312. package/src/discord/command/context.ts +85 -0
  313. package/src/discord/command/cooldown-guard.ts +81 -0
  314. package/src/discord/command/create-command.ts +431 -0
  315. package/src/discord/command/create-context-menu-command.ts +227 -0
  316. package/src/discord/command/errors.ts +22 -0
  317. package/src/discord/command/guard.ts +54 -0
  318. package/src/discord/command/localization.ts +11 -0
  319. package/src/discord/command/options.ts +847 -0
  320. package/src/discord/command/permission-guard.ts +74 -0
  321. package/src/discord/command/router.ts +142 -0
  322. package/src/discord/command/types.ts +52 -0
  323. package/src/discord/components/component-router.ts +213 -0
  324. package/src/discord/components/interactive-message/index.ts +18 -0
  325. package/src/discord/components/interactive-message/interactive-message-collector.ts +374 -0
  326. package/src/discord/components/interactive-message/mount-interactive-message.ts +71 -0
  327. package/src/discord/components/paginator/index.ts +17 -0
  328. package/src/discord/components/paginator/mount-paginator.ts +69 -0
  329. package/src/discord/components/paginator/page-state.ts +45 -0
  330. package/src/discord/components/paginator/paginator-buttons.ts +60 -0
  331. package/src/discord/components/paginator/paginator-view.ts +61 -0
  332. package/src/discord/components/persistent-paginator.ts +197 -0
  333. package/src/discord/components/settings-editor/index.ts +41 -0
  334. package/src/discord/components/settings-editor/mount-settings-editor.ts +646 -0
  335. package/src/discord/components/settings-editor/navigation.ts +67 -0
  336. package/src/discord/components/settings-editor/settings-editor-card.view.ts +344 -0
  337. package/src/discord/components/settings-editor/settings-editor-field-modal.ts +538 -0
  338. package/src/discord/components/settings-editor/settings-editor-fields.ts +290 -0
  339. package/src/discord/components/settings-editor/settings-editor.view.ts +654 -0
  340. package/src/discord/events/create-event.ts +7 -0
  341. package/src/discord/events/event-router.ts +53 -0
  342. package/src/discord/events/types.ts +17 -0
  343. package/src/discord/i18n.ts +173 -0
  344. package/src/discord/interaction/button.ts +75 -0
  345. package/src/discord/interaction/interaction-router.ts +28 -0
  346. package/src/discord/interaction/modal.ts +505 -0
  347. package/src/discord/interaction/select-menu.ts +246 -0
  348. package/src/discord/permissions.ts +57 -0
  349. package/src/discord/placeholder-registry-errors.ts +11 -0
  350. package/src/discord/placeholder-registry.ts +77 -0
  351. package/src/discord/presenter.ts +26 -0
  352. package/src/discord/ui/card.ts +303 -0
  353. package/src/discord/ui/color-input-errors.ts +17 -0
  354. package/src/discord/ui/color-input.ts +179 -0
  355. package/src/discord/ui/colors.ts +58 -0
  356. package/src/discord/ui/embed.ts +64 -0
  357. package/src/discord/ui/message-attachments.ts +57 -0
  358. package/src/errors/business-error.ts +49 -0
  359. package/src/errors/describe-error.ts +73 -0
  360. package/src/errors/incident-ref.ts +10 -0
  361. package/src/errors/index.ts +12 -0
  362. package/src/i18n/business-message.ts +23 -0
  363. package/src/i18n/catalog.ts +41 -0
  364. package/src/i18n/errors.ts +11 -0
  365. package/src/i18n/index.ts +11 -0
  366. package/src/i18n/locale.ts +41 -0
  367. package/src/i18n/translator.ts +78 -0
  368. package/src/logger.ts +28 -0
  369. package/src/module/module.ts +42 -0
  370. package/src/persistence/database.ts +23 -0
  371. package/src/resilience/retry.ts +102 -0
  372. package/src/scheduler/errors.ts +40 -0
  373. package/src/scheduler/scheduler.ts +248 -0
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_CARD_BUTTON_LEVEL_ENTRIES = exports.MAX_CARD_LEVEL_ENTRIES = void 0;
4
+ exports.fieldButtonId = fieldButtonId;
5
+ exports.createCardEditorView = createCardEditorView;
6
+ const navigation_1 = require("../../../discord/components/settings-editor/navigation");
7
+ const settings_editor_view_1 = require("../../../discord/components/settings-editor/settings-editor.view");
8
+ const i18n_1 = require("../../../discord/i18n");
9
+ const button_1 = require("../../../discord/interaction/button");
10
+ const card_1 = require("../../../discord/ui/card");
11
+ const colors_1 = require("../../../discord/ui/colors");
12
+ /**
13
+ * Discord refuses a card carrying more than {@link import("../../../discord/ui/card").MAX_CARD_COMPONENTS}
14
+ * components; every menu entry a level declares becomes a `Section` — its
15
+ * text plus a button accessory, three components — so this is what a level's
16
+ * own field list may not exceed *before* the chrome fixed around it
17
+ * (breadcrumb, preview, extra blocks, separators, the bottom controls, the
18
+ * signature) is even counted. Generous rather than exact: the fixed chrome
19
+ * costs roughly a dozen components on its own, and no level this repository
20
+ * declares comes within three of this cap.
21
+ */
22
+ exports.MAX_CARD_LEVEL_ENTRIES = 10;
23
+ /**
24
+ * Discord refuses an `ActionRow` carrying more than five buttons, so a level
25
+ * declaring `entryLayout: "buttons"` folds its entries into as many rows of
26
+ * this size as it needs, rather than the single row it used to require.
27
+ */
28
+ const BUTTONS_PER_ROW = 5;
29
+ /**
30
+ * How many entries a level declaring `entryLayout: "buttons"` may carry
31
+ * before the rows they compile to — one `ActionRow` per five, however many
32
+ * that takes — would overrun what a container can actually hold.
33
+ *
34
+ * Sits higher than {@link MAX_CARD_LEVEL_ENTRIES} on purpose: a `"buttons"`
35
+ * row costs its `ActionRow` plus the buttons in it, cheaper per entry than a
36
+ * `"sections"` level's `Section` (text, accessory, the `Section` itself —
37
+ * three components apiece). Generous rather than exact, for the same reason
38
+ * {@link MAX_CARD_LEVEL_ENTRIES} is: the fixed chrome (breadcrumb, preview,
39
+ * separators, the bottom controls, the signature) costs roughly a dozen
40
+ * components on its own, and no level this repository declares comes within
41
+ * half of this cap.
42
+ */
43
+ exports.MAX_CARD_BUTTON_LEVEL_ENTRIES = 20;
44
+ /**
45
+ * The most buttons {@link SettingsEditorCardChrome.entryActions} ever adds to
46
+ * one render of a level's own row: the confirm/cancel pair a screen's own
47
+ * removal swaps to once armed — the single ask button it swaps *from* costs
48
+ * less. Reserved against every `"buttons"` level's own cap whenever the
49
+ * chrome declares the hook at all: the guard below runs once at construction,
50
+ * before any state — and so before `entryActions` has anything to measure —
51
+ * exists.
52
+ */
53
+ const ENTRY_ACTIONS_RESERVE = 2;
54
+ /**
55
+ * The button a menu entry's own `Section` carries, derived from the field's
56
+ * key rather than declared alongside it — the same relationship `ids.field`
57
+ * already has to the select it used to name, one level of indirection lower.
58
+ */
59
+ function fieldButtonId(ids, key) {
60
+ return `${ids.field}:${key}`;
61
+ }
62
+ /**
63
+ * The card editor screen: one Components V2 card carrying the breadcrumb, the
64
+ * last notice, whatever the screen adds above the preview, the preview
65
+ * itself, a `Section` per entry of the current level — each with the button
66
+ * `fieldButtonId` names — and the bottom controls, closing with the bot's own
67
+ * signature.
68
+ *
69
+ * The counterpart of `createEditorView` for a screen declaring
70
+ * `chrome.layout === "card"`; the two never mix; {@link mountSettingsEditor}
71
+ * picks whichever this screen's chrome names.
72
+ *
73
+ * Takes no `SettingsEditorIds` of its own, unlike `createEditorView`: every
74
+ * button it renders — reset, back, and one per menu entry — already exists,
75
+ * built by `mountSettingsEditor` against those very ids, so nothing here has
76
+ * to name them again.
77
+ */
78
+ function createCardEditorView(fields, levels, buttons, fieldButtons, chrome, translator, locale, dressing) {
79
+ const screenTitle = translator.translate(locale, chrome.titleKey);
80
+ // Separates the levels in the breadcrumb trail.
81
+ const BREADCRUMB_SEPARATOR = " › ";
82
+ // The root is a level like any other, named after the screen itself, so
83
+ // rendering never special-cases "no depth declared" — the same bargain
84
+ // `createEditorView` strikes for the embeds layout. Its own `entryLayout`
85
+ // is the chrome's, mirroring `SettingsEditorLevel.entryLayout` for the one
86
+ // level that is never itself a `SettingsEditorLevel`.
87
+ const root = {
88
+ key: navigation_1.ROOT_LEVEL_KEY,
89
+ titleKey: chrome.titleKey,
90
+ fields,
91
+ entryLayout: chrome.entryLayout,
92
+ };
93
+ const allLevels = [root, ...(levels ?? [])];
94
+ // A level's fields are authored, not accumulated: passing more entries than a
95
+ // card can carry is a mistake in the declaration, and Discord would reject
96
+ // the whole message rather than show the first ones that fit. Failing here
97
+ // names the level; failing at render time would only say the message was
98
+ // invalid.
99
+ for (const level of allLevels) {
100
+ // A `"buttons"` level spends its budget on rows of `ActionRow`s rather
101
+ // than `Section`s, so it is checked against its own, higher cap instead
102
+ // of the `"sections"` one — failing here names the level rather than the
103
+ // invalid message Discord would otherwise reject. The chrome's own
104
+ // `entryActions`, when declared, reserves its worst case on top of the
105
+ // level's declared fields: those buttons exist only once a state renders
106
+ // them, which this construction-time guard has none of to count instead.
107
+ if (level.entryLayout === "buttons") {
108
+ const reserve = chrome.entryActions === undefined ? 0 : ENTRY_ACTIONS_RESERVE;
109
+ if (level.fields.length + reserve > exports.MAX_CARD_BUTTON_LEVEL_ENTRIES) {
110
+ throw new Error(`Settings editor level "${level.key}" declares ${level.fields.length} entries${reserve === 0 ? "" : ` (+${reserve} reserved for the chrome's own entryActions)`} with entryLayout "buttons"; a card holds ${exports.MAX_CARD_BUTTON_LEVEL_ENTRIES} before its own controls. Split it into a deeper level.`);
111
+ }
112
+ }
113
+ else if (level.fields.length > exports.MAX_CARD_LEVEL_ENTRIES) {
114
+ throw new Error(`Settings editor level "${level.key}" declares ${level.fields.length} entries; a card section holds ${exports.MAX_CARD_LEVEL_ENTRIES} before its own controls. Split it into a deeper level.`);
115
+ }
116
+ }
117
+ function levelAt(key) {
118
+ return allLevels.find((level) => level.key === key) ?? root;
119
+ }
120
+ /**
121
+ * Where the reader is, as a trail rather than only the current name: a level
122
+ * called "Roles" says nothing on its own about which type it belongs to.
123
+ */
124
+ function heading(state) {
125
+ return state.path
126
+ .map((key) => translator.translate(locale, levelAt(key).titleKey))
127
+ .join(BREADCRUMB_SEPARATOR);
128
+ }
129
+ /**
130
+ * The bot's own signature, once at the bottom of the card rather than on
131
+ * every embed the way two embeds each carried their own footer. Discord's
132
+ * own timestamp markdown, so it reads in the viewer's own locale exactly as
133
+ * an embed's timestamp already did.
134
+ */
135
+ function signature() {
136
+ const unixSeconds = Math.floor(dressing.clock.now().getTime() / 1000);
137
+ return `-# ${screenTitle} • <t:${unixSeconds}:t>`;
138
+ }
139
+ /**
140
+ * One menu entry, as the `Section` that replaces it: its label as the title,
141
+ * its hint as the line under it, and the button `mountSettingsEditor`
142
+ * registered for it as the accessory — the very button that opens its modal
143
+ * or descends into it, reached by a click instead of a pick.
144
+ */
145
+ function entrySection(field) {
146
+ const title = translator.translate(locale, field.labelKey);
147
+ const lines = [translator.translate(locale, field.hintKey)];
148
+ const action = fieldButtons.get(field.key);
149
+ return action === undefined
150
+ ? { kind: "entry", title, lines }
151
+ : { kind: "entry", title, lines, action };
152
+ }
153
+ /**
154
+ * A `"buttons"` level's entries, as the rows that replace their `Section`s:
155
+ * each field's own button — labelled with the entry's own name, not the
156
+ * generic "Open"/"Edit" a `"sections"` level wears, which is the whole
157
+ * point of folding them into rows of buttons instead of stacking them.
158
+ * `mountSettingsEditor` is what actually words the button that way — see
159
+ * its own `buildFieldButton` — this only collects the ones this level owns.
160
+ */
161
+ function entryButtons(level) {
162
+ return level.fields.map((field) => {
163
+ const button = fieldButtons.get(field.key);
164
+ if (button === undefined) {
165
+ // `fieldButtons` is built by `mountSettingsEditor` over every field of
166
+ // every level up front, this level's included — unreachable outside a
167
+ // wiring mistake in that map, not something an administrator can cause.
168
+ throw new Error(`Settings editor level "${level.key}" has no button registered for field "${field.key}".`);
169
+ }
170
+ return button;
171
+ });
172
+ }
173
+ /**
174
+ * A `"buttons"` level's entries row for one render: its own field buttons,
175
+ * plus whatever {@link SettingsEditorCardChrome.entryActions} adds — the
176
+ * create/edit/remove row a module's own removal control now lives in,
177
+ * rather than floating beside a picker or hiding at the bottom of the card.
178
+ *
179
+ * A screen's own action waiting on its second click takes the row over
180
+ * entirely: while `state.confirming` names anything, the level's own
181
+ * buttons step aside and the row is exactly what `entryActions` returns —
182
+ * the confirm/cancel pair, once it recognises its own key in `confirming`.
183
+ * The same "the pending question replaces what is here" rule the editor's
184
+ * own reset already follows for the row below the card, transposed to a
185
+ * level's own entries instead of the screen's outer one.
186
+ */
187
+ function levelButtons(level, state) {
188
+ const actions = chrome.entryActions?.(state) ?? [];
189
+ return state.confirming === null ? [...entryButtons(level), ...actions] : actions;
190
+ }
191
+ /**
192
+ * Split a `"buttons"` level's entries into as many rows of
193
+ * {@link BUTTONS_PER_ROW} as they need — Discord's own cap on one
194
+ * `ActionRow`, not a limit on how many entries the level may declare in
195
+ * total (that is {@link MAX_CARD_BUTTON_LEVEL_ENTRIES}, checked above).
196
+ */
197
+ function buttonRows(buttons) {
198
+ const rows = [];
199
+ for (let start = 0; start < buttons.length; start += BUTTONS_PER_ROW) {
200
+ rows.push({ kind: "controls", buttons: buttons.slice(start, start + BUTTONS_PER_ROW) });
201
+ }
202
+ return rows;
203
+ }
204
+ /**
205
+ * The screen's own controls for the current state, outside the card
206
+ * entirely — see the module-level note on {@link SettingsEditorRow}. Empty
207
+ * for a screen with nothing to offer here at all — a flat screen with
208
+ * nothing to reset, with dismissing the message the only way out.
209
+ */
210
+ function outerButtons(state) {
211
+ if (state.confirming === settings_editor_view_1.SETTINGS_EDITOR_RESET_CONFIRMING) {
212
+ return buttons.confirming;
213
+ }
214
+ // Reset, then the return control — the order the outer row reads left to
215
+ // right. Each is absent rather than disabled wherever there is nothing for
216
+ // it to do, same principle both already followed on their own.
217
+ return [
218
+ ...(0, settings_editor_view_1.resetButtons)(buttons, chrome, state),
219
+ ...((0, navigation_1.canReturn)(state.path) ? buttons.returning : []),
220
+ ];
221
+ }
222
+ /** {@link outerButtons}, compiled into the one row it renders as — or none at all. */
223
+ function outerRow(state, forceDisabled) {
224
+ const row = outerButtons(state);
225
+ return row.length === 0 ? [] : [(0, button_1.createActionRow)(row, state, { disableAll: forceDisabled })];
226
+ }
227
+ /**
228
+ * The card's blocks, top to bottom — but for the screen's own controls,
229
+ * which render beside the card rather than inside it — see {@link outerRow}.
230
+ * `disabled` here means only "the editor's own reset is waiting for its
231
+ * second click", not the outer neutralising pass: that one is `Card.apply`'s
232
+ * own `forceDisabled`, applied uniformly across every block a second time —
233
+ * see {@link import("../../../discord/ui/card").Card}.
234
+ */
235
+ function openBlocks(state) {
236
+ const confirmingReset = state.confirming === settings_editor_view_1.SETTINGS_EDITOR_RESET_CONFIRMING;
237
+ const level = levelAt((0, navigation_1.currentLevelKey)(state.path));
238
+ const notice = confirmingReset
239
+ ? {
240
+ kind: "entry",
241
+ title: translator.translate(locale, i18n_1.SETTINGS_EDITOR_MESSAGES.resetConfirmTitle),
242
+ lines: [translator.translate(locale, i18n_1.SETTINGS_EDITOR_MESSAGES.resetConfirmDescription)],
243
+ }
244
+ : state.notice === null
245
+ ? null
246
+ : { kind: "text", content: state.notice.text };
247
+ const entries = level.entryLayout === "buttons"
248
+ ? buttonRows(levelButtons(level, state))
249
+ : level.fields.map((field) => entrySection(field));
250
+ return [
251
+ { kind: "text", content: `-# ${heading(state)}` },
252
+ notice,
253
+ ...(chrome.extraBlocks?.(state, confirmingReset) ?? []),
254
+ { kind: "separator" },
255
+ ...chrome.preview(state),
256
+ { kind: "separator" },
257
+ ...entries,
258
+ { kind: "text", content: signature() },
259
+ ];
260
+ }
261
+ function cardDef(state) {
262
+ return { accent: colors_1.EMBED_COLORS.brand, blocks: openBlocks(state) };
263
+ }
264
+ const mentions = chrome.allowedMentions === undefined ? {} : { allowedMentions: chrome.allowedMentions };
265
+ return {
266
+ render: (state) => ({
267
+ layout: "card",
268
+ card: (0, card_1.createCard)(cardDef(state)),
269
+ // The screen's own controls, beside the card rather than inside it —
270
+ // empty for a screen with nothing to offer here, which is what
271
+ // `outerRow` already returns.
272
+ controls: outerRow(state, false),
273
+ // Always stated, empty included: this is the screen's whole set of
274
+ // attachments, and an update that said nothing would leave the image of
275
+ // an override that has just been cleared sitting on the message.
276
+ files: [...chrome.filesOf(state)],
277
+ ...mentions,
278
+ }),
279
+ disabledControls: (state) => ({
280
+ components: [(0, card_1.createCard)(cardDef(state)).apply(state, true), ...outerRow(state, true)],
281
+ }),
282
+ };
283
+ }
284
+ //# sourceMappingURL=settings-editor-card.view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-editor-card.view.js","sourceRoot":"","sources":["../../../../src/discord/components/settings-editor/settings-editor-card.view.ts"],"names":[],"mappings":";;;AA2EA,sCAEC;AAkBD,oDAwPC;AAtVD,gFAKyD;AACzD,oGASmE;AAEnE,yCAA0D;AAC1D,yDAA4E;AAC5E,4CAA6E;AAC7E,gDAAmD;AAGnD;;;;;;;;;GASG;AACU,QAAA,sBAAsB,GAAG,EAAE,CAAC;AAEzC;;;;GAIG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B;;;;;;;;;;;;;GAaG;AACU,QAAA,6BAA6B,GAAG,EAAE,CAAC;AAEhD;;;;;;;;GAQG;AACH,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC;;;;GAIG;AACH,SAAgB,aAAa,CAAC,GAAsB,EAAE,GAAW;IAChE,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,oBAAoB,CACnC,MAAyC,EACzC,MAAqD,EACrD,OAAoC,EACpC,YAAoE,EACpE,MAAsC,EACtC,UAAsB,EACtB,MAAc,EACd,QAAgC;IAEhC,MAAM,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAClE,g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8B;YAC9B,QAAQ,EAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;YAChC,mEAAmE;YACnE,wEAAwE;YACxE,iEAAiE;YACjE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACjC,GAAG,QAAQ;SACX,CAAC;QACF,gBAAgB,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YAC7B,UAAU,EAAE,CAAC,IAAA,iBAAU,EAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,GAAG,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SACrF,CAAC;KACF,CAAC;AACH,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { type Attachment, type MessageComponentInteraction, type ModalMessageModalSubmitInteraction } from "discord.js";
2
+ import { type SettingsEditorFieldValue, type SettingsEditorGroupField, type SettingsEditorPickerField, type SettingsEditorValueField } from "../../../discord/components/settings-editor/settings-editor-fields";
3
+ import type { Locale, Translator } from "../../../i18n";
4
+ export interface SettingsEditorSubmission {
5
+ /** The modal's own submit interaction — the only one still usable to answer. */
6
+ readonly interaction: ModalMessageModalSubmitInteraction;
7
+ /** `null` when the field came back empty, which is how an override is cleared. */
8
+ readonly value: string | null;
9
+ /**
10
+ * The uploaded image, on the fields that offer one. Always `null` elsewhere,
11
+ * and `null` on those when nothing was uploaded.
12
+ */
13
+ readonly upload: Attachment | null;
14
+ /**
15
+ * What a picker field reported. `null` when the selection was emptied — that
16
+ * is how such a setting is cleared. Always `null` on a value field.
17
+ */
18
+ readonly ids: readonly string[] | null;
19
+ }
20
+ /**
21
+ * Ask for one field's new value, prefilled with the current one, and wait for
22
+ * the answer. Returns `null` on timeout or on any failure to show/collect it
23
+ * (the administrator dismissed the modal, say) — the caller treats that as
24
+ * "nothing happened", never as an error, and the screen stays as it was.
25
+ *
26
+ * `showModal` finally acknowledges `interaction`: nothing can `.update()` on it
27
+ * again, which is why the submission carries its own interaction to answer
28
+ * through.
29
+ *
30
+ * `MessageComponentInteraction` rather than `AnySelectMenuInteraction`: a menu
31
+ * entry opens the very same modal whether it is reached by picking it from a
32
+ * select (the embeds layout) or by clicking the button its own `Section`
33
+ * carries (the card layout), and both interaction kinds carry `showModal` and
34
+ * `awaitModalSubmit` from that shared base.
35
+ */
36
+ export declare function promptEditorFieldValue<F extends string>(interaction: MessageComponentInteraction, field: SettingsEditorValueField<F> | SettingsEditorPickerField<F>, current: SettingsEditorFieldValue, translator: Translator, locale: Locale): Promise<SettingsEditorSubmission | null>;
37
+ /** What one member field of a group came back with — the group's own per-member slice. */
38
+ export interface SettingsEditorGroupMemberSubmission {
39
+ readonly value: string | null;
40
+ readonly upload: Attachment | null;
41
+ readonly ids: readonly string[] | null;
42
+ }
43
+ /**
44
+ * What a group's modal came back with, one entry per member field it declared.
45
+ * A member absent from a submission cannot happen — every member the group
46
+ * declares is a component of the very modal that produced this — but the type
47
+ * stays a partial record rather than asserting it, since nothing here proves it
48
+ * to the compiler.
49
+ */
50
+ export type SettingsEditorGroupSubmission<F extends string> = Readonly<Partial<Record<F, SettingsEditorGroupMemberSubmission>>>;
51
+ /** What opening a group's modal resolves to: the submitted values, and the one interaction left to answer through. */
52
+ export interface SettingsEditorGroupPrompt<F extends string> {
53
+ readonly interaction: ModalMessageModalSubmitInteraction;
54
+ readonly values: SettingsEditorGroupSubmission<F>;
55
+ }
56
+ /**
57
+ * Ask for every setting a group declares at once, in a single modal — the
58
+ * group's counterpart of {@link promptEditorFieldValue}. Each member is laid
59
+ * out in the geometry its own `kind` imposes, exactly as it would if it were
60
+ * prompted on its own, and prefilled the same way: from `currentValue`, asked
61
+ * once per member.
62
+ *
63
+ * `legend` is extra text shown above the fields — a token list a message field
64
+ * reads against, say — already counted against the modal's own five-component
65
+ * budget by the caller that built it; `null` when the group has nothing to say
66
+ * there.
67
+ */
68
+ export declare function promptEditorGroupValue<F extends string>(interaction: MessageComponentInteraction, group: SettingsEditorGroupField<F>, currentValue: (memberKey: F) => SettingsEditorFieldValue, legend: string | null, translator: Translator, locale: Locale): Promise<SettingsEditorGroupPrompt<F> | null>;
69
+ //# sourceMappingURL=settings-editor-field-modal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings-editor-field-modal.d.ts","sourceRoot":"","sources":["../../../../src/discord/components/settings-editor/settings-editor-field-modal.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,UAAU,EAEf,KAAK,2BAA2B,EAEhC,KAAK,kCAAkC,EACvC,MAAM,YAAY,CAAC;AACpB,OAAO,EAEN,KAAK,wBAAwB,EAC7B,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,wBAAwB,EAC7B,MAAM,6DAA6D,CAAC;AAWrE,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAyDjD,MAAM,WAAW,wBAAwB;IACxC,gFAAgF;IAChF,QAAQ,CAAC,WAAW,EAAE,kCAAkC,CAAC;IACzD,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,SAAS,MAAM,EAC5D,WAAW,EAAE,2BAA2B,EACxC,KAAK,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAAG,yBAAyB,CAAC,CAAC,CAAC,EACjE,OAAO,EAAE,wBAAwB,EACjC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CA2B1C;AAED,0FAA0F;AAC1F,MAAM,WAAW,mCAAmC;IAC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