@naosystem/cf-workers-status-page 0.0.0-stage → 0.1.2

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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +38 -2
  3. package/dist/admin.html +17 -0
  4. package/dist/auth-cloudflare-access.js +304 -0
  5. package/dist/auth-cloudflare-access.js.map +1 -0
  6. package/dist/chunks/monitor-B2u42off.js +79 -0
  7. package/dist/chunks/monitor-B2u42off.js.map +1 -0
  8. package/dist/chunks/notifier-DODVuFhr.js +158 -0
  9. package/dist/chunks/notifier-DODVuFhr.js.map +1 -0
  10. package/dist/chunks/page-templates-DPZcMlic.js +71 -0
  11. package/dist/chunks/page-templates-DPZcMlic.js.map +1 -0
  12. package/dist/chunks/run-check-bbo3LqI7.js +235 -0
  13. package/dist/chunks/run-check-bbo3LqI7.js.map +1 -0
  14. package/dist/chunks/timeline-YJXjehRf.js +1081 -0
  15. package/dist/chunks/timeline-YJXjehRf.js.map +1 -0
  16. package/dist/client/_headers +10 -0
  17. package/dist/client/assets/admin-BBJxKTF6.js +1 -0
  18. package/dist/client/assets/admin-Be4X0WFj.css +1 -0
  19. package/dist/client/assets/index-BgOspfsy.js +2 -0
  20. package/dist/client/assets/index-xpKyzvog.css +1 -0
  21. package/dist/client/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  22. package/dist/client/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  23. package/dist/client/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  24. package/dist/client/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  25. package/dist/client/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  26. package/dist/client/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  27. package/dist/client/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  28. package/dist/client/assets/ja-BT5brvxP.js +1 -0
  29. package/dist/client/assets/ja-DSSblLff.js +1 -0
  30. package/dist/client/assets/noto-sans-jp-0-wght-normal-vN5ykBQF.woff2 +0 -0
  31. package/dist/client/assets/noto-sans-jp-1-wght-normal-N_EDDt8j.woff2 +0 -0
  32. package/dist/client/assets/noto-sans-jp-10-wght-normal-ChuiXes4.woff2 +0 -0
  33. package/dist/client/assets/noto-sans-jp-100-wght-normal-CrE4HD6k.woff2 +0 -0
  34. package/dist/client/assets/noto-sans-jp-101-wght-normal-DOqEZFXR.woff2 +0 -0
  35. package/dist/client/assets/noto-sans-jp-102-wght-normal-2gFz4V6e.woff2 +0 -0
  36. package/dist/client/assets/noto-sans-jp-103-wght-normal-D9RhXU-z.woff2 +0 -0
  37. package/dist/client/assets/noto-sans-jp-104-wght-normal-OIyZ9iQD.woff2 +0 -0
  38. package/dist/client/assets/noto-sans-jp-105-wght-normal-CqRQAfnb.woff2 +0 -0
  39. package/dist/client/assets/noto-sans-jp-106-wght-normal-D-PO3jqS.woff2 +0 -0
  40. package/dist/client/assets/noto-sans-jp-107-wght-normal-DrykTIAp.woff2 +0 -0
  41. package/dist/client/assets/noto-sans-jp-108-wght-normal-DijBe27A.woff2 +0 -0
  42. package/dist/client/assets/noto-sans-jp-109-wght-normal-DaJwqT__.woff2 +0 -0
  43. package/dist/client/assets/noto-sans-jp-11-wght-normal-DdkFqF_o.woff2 +0 -0
  44. package/dist/client/assets/noto-sans-jp-110-wght-normal-bhh2FQQH.woff2 +0 -0
  45. package/dist/client/assets/noto-sans-jp-111-wght-normal-CuGzYIdC.woff2 +0 -0
  46. package/dist/client/assets/noto-sans-jp-112-wght-normal-DdhK_1vk.woff2 +0 -0
  47. package/dist/client/assets/noto-sans-jp-113-wght-normal-hxVHS2d4.woff2 +0 -0
  48. package/dist/client/assets/noto-sans-jp-114-wght-normal-DUzjAsrP.woff2 +0 -0
  49. package/dist/client/assets/noto-sans-jp-115-wght-normal-BiZ4-5rz.woff2 +0 -0
  50. package/dist/client/assets/noto-sans-jp-116-wght-normal-DkZAcxAY.woff2 +0 -0
  51. package/dist/client/assets/noto-sans-jp-117-wght-normal-CLJPD2y0.woff2 +0 -0
  52. package/dist/client/assets/noto-sans-jp-118-wght-normal-D8DI_HXJ.woff2 +0 -0
  53. package/dist/client/assets/noto-sans-jp-119-wght-normal-BAB3pFaH.woff2 +0 -0
  54. package/dist/client/assets/noto-sans-jp-12-wght-normal-K36fA5_o.woff2 +0 -0
  55. package/dist/client/assets/noto-sans-jp-13-wght-normal-BnYizWno.woff2 +0 -0
  56. package/dist/client/assets/noto-sans-jp-14-wght-normal-BP4IgVC-.woff2 +0 -0
  57. package/dist/client/assets/noto-sans-jp-15-wght-normal-DyhWcoYF.woff2 +0 -0
  58. package/dist/client/assets/noto-sans-jp-16-wght-normal-CXsQLI2j.woff2 +0 -0
  59. package/dist/client/assets/noto-sans-jp-17-wght-normal-C8FU1ZJ4.woff2 +0 -0
  60. package/dist/client/assets/noto-sans-jp-18-wght-normal-Cl0IKBVh.woff2 +0 -0
  61. package/dist/client/assets/noto-sans-jp-19-wght-normal-D3D3JUJm.woff2 +0 -0
  62. package/dist/client/assets/noto-sans-jp-2-wght-normal-CGu8NhtQ.woff2 +0 -0
  63. package/dist/client/assets/noto-sans-jp-20-wght-normal-DxsoeWSt.woff2 +0 -0
  64. package/dist/client/assets/noto-sans-jp-21-wght-normal-CuNsexW5.woff2 +0 -0
  65. package/dist/client/assets/noto-sans-jp-22-wght-normal-DVX3OFQM.woff2 +0 -0
  66. package/dist/client/assets/noto-sans-jp-23-wght-normal-BPFuo_yH.woff2 +0 -0
  67. package/dist/client/assets/noto-sans-jp-24-wght-normal-D85Fj66x.woff2 +0 -0
  68. package/dist/client/assets/noto-sans-jp-25-wght-normal-DdOOVuSz.woff2 +0 -0
  69. package/dist/client/assets/noto-sans-jp-26-wght-normal-BRB1GnUq.woff2 +0 -0
  70. package/dist/client/assets/noto-sans-jp-27-wght-normal-BxZFF8JU.woff2 +0 -0
  71. package/dist/client/assets/noto-sans-jp-28-wght-normal-VUlviaYI.woff2 +0 -0
  72. package/dist/client/assets/noto-sans-jp-29-wght-normal-CalQqRwB.woff2 +0 -0
  73. package/dist/client/assets/noto-sans-jp-3-wght-normal-cncaCaM8.woff2 +0 -0
  74. package/dist/client/assets/noto-sans-jp-30-wght-normal-CHLg85G9.woff2 +0 -0
  75. package/dist/client/assets/noto-sans-jp-31-wght-normal-BUoF9dl9.woff2 +0 -0
  76. package/dist/client/assets/noto-sans-jp-32-wght-normal-C5ZTiBNw.woff2 +0 -0
  77. package/dist/client/assets/noto-sans-jp-33-wght-normal-C6XNJsfA.woff2 +0 -0
  78. package/dist/client/assets/noto-sans-jp-34-wght-normal-DHkM837w.woff2 +0 -0
  79. package/dist/client/assets/noto-sans-jp-35-wght-normal-QMtEjDIl.woff2 +0 -0
  80. package/dist/client/assets/noto-sans-jp-36-wght-normal-CUyF0GqZ.woff2 +0 -0
  81. package/dist/client/assets/noto-sans-jp-37-wght-normal-EORmNjxA.woff2 +0 -0
  82. package/dist/client/assets/noto-sans-jp-38-wght-normal-C8ERbMNG.woff2 +0 -0
  83. package/dist/client/assets/noto-sans-jp-39-wght-normal-ChUfpJbl.woff2 +0 -0
  84. package/dist/client/assets/noto-sans-jp-4-wght-normal-DtWqs3EP.woff2 +0 -0
  85. package/dist/client/assets/noto-sans-jp-40-wght-normal-MgP8JEEE.woff2 +0 -0
  86. package/dist/client/assets/noto-sans-jp-41-wght-normal-3ctF9abM.woff2 +0 -0
  87. package/dist/client/assets/noto-sans-jp-42-wght-normal-CQtg6UZe.woff2 +0 -0
  88. package/dist/client/assets/noto-sans-jp-43-wght-normal-D1Pmm9aG.woff2 +0 -0
  89. package/dist/client/assets/noto-sans-jp-44-wght-normal-Cp9dHeXI.woff2 +0 -0
  90. package/dist/client/assets/noto-sans-jp-45-wght-normal-D2b1osBj.woff2 +0 -0
  91. package/dist/client/assets/noto-sans-jp-46-wght-normal-CGIA-Vlo.woff2 +0 -0
  92. package/dist/client/assets/noto-sans-jp-47-wght-normal-C4EEGqDS.woff2 +0 -0
  93. package/dist/client/assets/noto-sans-jp-48-wght-normal-D2iBztXa.woff2 +0 -0
  94. package/dist/client/assets/noto-sans-jp-49-wght-normal-DxqRVik_.woff2 +0 -0
  95. package/dist/client/assets/noto-sans-jp-5-wght-normal-CFiyVtll.woff2 +0 -0
  96. package/dist/client/assets/noto-sans-jp-50-wght-normal-CMseszwo.woff2 +0 -0
  97. package/dist/client/assets/noto-sans-jp-51-wght-normal-Cqc-9wfi.woff2 +0 -0
  98. package/dist/client/assets/noto-sans-jp-52-wght-normal-BVLZTbqC.woff2 +0 -0
  99. package/dist/client/assets/noto-sans-jp-53-wght-normal-DTyNOJaY.woff2 +0 -0
  100. package/dist/client/assets/noto-sans-jp-54-wght-normal-_mxGq_et.woff2 +0 -0
  101. package/dist/client/assets/noto-sans-jp-55-wght-normal-Bvndync8.woff2 +0 -0
  102. package/dist/client/assets/noto-sans-jp-56-wght-normal-0MmMqroR.woff2 +0 -0
  103. package/dist/client/assets/noto-sans-jp-57-wght-normal-BdRnjDYs.woff2 +0 -0
  104. package/dist/client/assets/noto-sans-jp-58-wght-normal-BYGgVeN_.woff2 +0 -0
  105. package/dist/client/assets/noto-sans-jp-59-wght-normal-Bdv8mdje.woff2 +0 -0
  106. package/dist/client/assets/noto-sans-jp-6-wght-normal-M-pWkj3J.woff2 +0 -0
  107. package/dist/client/assets/noto-sans-jp-60-wght-normal-DC6FEqsM.woff2 +0 -0
  108. package/dist/client/assets/noto-sans-jp-61-wght-normal-CYIuK5Lr.woff2 +0 -0
  109. package/dist/client/assets/noto-sans-jp-62-wght-normal-DeHy8p7w.woff2 +0 -0
  110. package/dist/client/assets/noto-sans-jp-63-wght-normal-B4M6eMmD.woff2 +0 -0
  111. package/dist/client/assets/noto-sans-jp-64-wght-normal-DLyOXBrC.woff2 +0 -0
  112. package/dist/client/assets/noto-sans-jp-65-wght-normal-X7SsA1bs.woff2 +0 -0
  113. package/dist/client/assets/noto-sans-jp-66-wght-normal-VScDM-_N.woff2 +0 -0
  114. package/dist/client/assets/noto-sans-jp-67-wght-normal-Dg2D3DZB.woff2 +0 -0
  115. package/dist/client/assets/noto-sans-jp-68-wght-normal-BB0AR8UN.woff2 +0 -0
  116. package/dist/client/assets/noto-sans-jp-69-wght-normal-CucwpUnQ.woff2 +0 -0
  117. package/dist/client/assets/noto-sans-jp-7-wght-normal-DzOz8Ryd.woff2 +0 -0
  118. package/dist/client/assets/noto-sans-jp-70-wght-normal-BZId6-Tb.woff2 +0 -0
  119. package/dist/client/assets/noto-sans-jp-71-wght-normal-CzPU0NF7.woff2 +0 -0
  120. package/dist/client/assets/noto-sans-jp-72-wght-normal-DrNRYXnT.woff2 +0 -0
  121. package/dist/client/assets/noto-sans-jp-73-wght-normal-DF2BdR6a.woff2 +0 -0
  122. package/dist/client/assets/noto-sans-jp-74-wght-normal-BMlOw_5y.woff2 +0 -0
  123. package/dist/client/assets/noto-sans-jp-75-wght-normal-DKq84hLG.woff2 +0 -0
  124. package/dist/client/assets/noto-sans-jp-76-wght-normal-CTb-2MFr.woff2 +0 -0
  125. package/dist/client/assets/noto-sans-jp-77-wght-normal-DfIVi-wf.woff2 +0 -0
  126. package/dist/client/assets/noto-sans-jp-78-wght-normal-_-z1Vrir.woff2 +0 -0
  127. package/dist/client/assets/noto-sans-jp-79-wght-normal-D8kGlXda.woff2 +0 -0
  128. package/dist/client/assets/noto-sans-jp-8-wght-normal-BfWoBb3q.woff2 +0 -0
  129. package/dist/client/assets/noto-sans-jp-80-wght-normal-BOEztZwY.woff2 +0 -0
  130. package/dist/client/assets/noto-sans-jp-81-wght-normal-h5VC8QpU.woff2 +0 -0
  131. package/dist/client/assets/noto-sans-jp-82-wght-normal-DJ4QkvX0.woff2 +0 -0
  132. package/dist/client/assets/noto-sans-jp-83-wght-normal-DANtuAZG.woff2 +0 -0
  133. package/dist/client/assets/noto-sans-jp-84-wght-normal-DjZ8Sp6m.woff2 +0 -0
  134. package/dist/client/assets/noto-sans-jp-85-wght-normal-kpU7kbMF.woff2 +0 -0
  135. package/dist/client/assets/noto-sans-jp-86-wght-normal-DRPTa-bf.woff2 +0 -0
  136. package/dist/client/assets/noto-sans-jp-87-wght-normal-CFM472wD.woff2 +0 -0
  137. package/dist/client/assets/noto-sans-jp-88-wght-normal-2rLLwelj.woff2 +0 -0
  138. package/dist/client/assets/noto-sans-jp-89-wght-normal-DUIF9ybW.woff2 +0 -0
  139. package/dist/client/assets/noto-sans-jp-9-wght-normal-WLs1HgG6.woff2 +0 -0
  140. package/dist/client/assets/noto-sans-jp-90-wght-normal-B0n_tL-y.woff2 +0 -0
  141. package/dist/client/assets/noto-sans-jp-91-wght-normal-BishDeFy.woff2 +0 -0
  142. package/dist/client/assets/noto-sans-jp-92-wght-normal-DoIdukLp.woff2 +0 -0
  143. package/dist/client/assets/noto-sans-jp-93-wght-normal-DMCycan_.woff2 +0 -0
  144. package/dist/client/assets/noto-sans-jp-94-wght-normal-DlyoTk-A.woff2 +0 -0
  145. package/dist/client/assets/noto-sans-jp-95-wght-normal-D0L1aiGf.woff2 +0 -0
  146. package/dist/client/assets/noto-sans-jp-96-wght-normal-CjJ0kYkQ.woff2 +0 -0
  147. package/dist/client/assets/noto-sans-jp-97-wght-normal-CJ8uP04H.woff2 +0 -0
  148. package/dist/client/assets/noto-sans-jp-98-wght-normal-CjEDrQIY.woff2 +0 -0
  149. package/dist/client/assets/noto-sans-jp-99-wght-normal-DaQ3GEVf.woff2 +0 -0
  150. package/dist/client/assets/noto-sans-jp-cyrillic-wght-normal-BbS1Q_ZO.woff2 +0 -0
  151. package/dist/client/assets/noto-sans-jp-latin-ext-wght-normal-IaSo_s9d.woff2 +0 -0
  152. package/dist/client/assets/noto-sans-jp-latin-wght-normal-Bnnzbixe.woff2 +0 -0
  153. package/dist/client/assets/noto-sans-jp-vietnamese-wght-normal-CjvP4Ahz.woff2 +0 -0
  154. package/dist/client/assets/src-BDi4qpij.js +9 -0
  155. package/dist/client/assets/src-C6ZFz-Gu.css +1 -0
  156. package/dist/client/assets/views-CSeX_2-u.css +1 -0
  157. package/dist/client/assets/views-DHTTEaNV.js +1 -0
  158. package/dist/client/index.html +15 -0
  159. package/dist/client/licenses/fonts.txt +104 -0
  160. package/dist/client/licenses/third-party.txt +349 -0
  161. package/dist/index.js +18 -0
  162. package/dist/index.js.map +1 -0
  163. package/dist/notifier-discord.js +153 -0
  164. package/dist/notifier-discord.js.map +1 -0
  165. package/dist/notifier-slack.js +98 -0
  166. package/dist/notifier-slack.js.map +1 -0
  167. package/dist/notifier-webhook.js +215 -0
  168. package/dist/notifier-webhook.js.map +1 -0
  169. package/dist/provider-http.js +177 -0
  170. package/dist/provider-http.js.map +1 -0
  171. package/dist/vite.js +224 -0
  172. package/dist/vite.js.map +1 -0
  173. package/dist/worker.js +8616 -0
  174. package/dist/worker.js.map +1 -0
  175. package/package.json +58 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeline-YJXjehRf.js","names":[],"sources":["../../../core/src/calendar.ts","../../../core/src/confirmation.ts","../../../core/src/duration.ts","../../../core/src/location.ts","../../../core/src/runner.ts","../../../core/src/config.ts","../../../core/src/display.ts","../../../core/src/timeline.ts"],"sourcesContent":["/**\n * Days in the configured time zone, with correct boundaries on days that\n * daylight saving time makes 23 or 25 hours long (or 23.5, or that start at 01:00 because\n * midnight is skipped). Uses `Intl.DateTimeFormat` with IANA zone names.\n */\nimport type { TimeRange } from \"./timeline\";\n\n/** A local calendar day: `[from, to)` runs from its first instant to the next day's. */\nexport interface CalendarDay extends TimeRange {\n\t/** `YYYY-MM-DD` in the time zone. */\n\treadonly date: string;\n}\n\nconst formatters = new Map<string, Intl.DateTimeFormat>();\n\nfunction formatter(timeZone: string): Intl.DateTimeFormat {\n\tlet found = formatters.get(timeZone);\n\tif (found === undefined) {\n\t\tfound = new Intl.DateTimeFormat(\"en-US\", {\n\t\t\ttimeZone,\n\t\t\thourCycle: \"h23\",\n\t\t\tyear: \"numeric\",\n\t\t\tmonth: \"2-digit\",\n\t\t\tday: \"2-digit\",\n\t\t\thour: \"2-digit\",\n\t\t\tminute: \"2-digit\",\n\t\t\tsecond: \"2-digit\",\n\t\t});\n\t\tformatters.set(timeZone, found);\n\t}\n\treturn found;\n}\n\ninterface WallClock {\n\treadonly year: number;\n\treadonly month: number;\n\treadonly day: number;\n\treadonly hour: number;\n\treadonly minute: number;\n\treadonly second: number;\n}\n\nfunction wallClock(at: number, timeZone: string): WallClock {\n\tconst parts: Record<string, number> = {};\n\tfor (const part of formatter(timeZone).formatToParts(at)) {\n\t\tif (part.type !== \"literal\") parts[part.type] = Number(part.value);\n\t}\n\treturn {\n\t\tyear: parts[\"year\"] ?? 0,\n\t\tmonth: parts[\"month\"] ?? 1,\n\t\tday: parts[\"day\"] ?? 1,\n\t\thour: parts[\"hour\"] ?? 0,\n\t\tminute: parts[\"minute\"] ?? 0,\n\t\tsecond: parts[\"second\"] ?? 0,\n\t};\n}\n\nfunction pad(value: number, length = 2): string {\n\treturn String(value).padStart(length, \"0\");\n}\n\nfunction formatDate(year: number, month: number, day: number): string {\n\treturn `${pad(year, 4)}-${pad(month)}-${pad(day)}`;\n}\n\nfunction parseDate(date: string): [number, number, number] {\n\tconst match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(date);\n\tif (match === null) throw new RangeError(`Not a YYYY-MM-DD date: ${date}`);\n\treturn [Number(match[1]), Number(match[2]), Number(match[3])];\n}\n\n/** The date `days` after `date` (negative: before), in the proleptic Gregorian calendar. */\nexport function addDays(date: string, days: number): string {\n\tconst [year, month, day] = parseDate(date);\n\tconst shifted = new Date(Date.UTC(year, month - 1, day + days));\n\treturn formatDate(shifted.getUTCFullYear(), shifted.getUTCMonth() + 1, shifted.getUTCDate());\n}\n\n/** The local date (`YYYY-MM-DD`) at instant `at` in `timeZone`. */\nexport function localDate(at: number, timeZone: string): string {\n\tconst clock = wallClock(at, timeZone);\n\treturn formatDate(clock.year, clock.month, clock.day);\n}\n\n/** Local wall-clock time minus UTC at `at`, in milliseconds (whole seconds). */\nfunction offsetAt(at: number, timeZone: string): number {\n\tconst seconds = Math.floor(at / 1000) * 1000;\n\tconst clock = wallClock(seconds, timeZone);\n\treturn Date.UTC(clock.year, clock.month - 1, clock.day, clock.hour, clock.minute, clock.second) - seconds;\n}\n\nconst starts = new Map<string, number>();\nconst MAX_MEMO = 4_096;\nconst HOUR_MS = 3_600_000;\n\n/**\n * The first instant of local date `date` in `timeZone`: local midnight, or the first\n * instant after a transition that skips midnight, or the earlier of two midnights when the\n * clock goes back across it.\n */\nexport function startOfLocalDay(date: string, timeZone: string): number {\n\tconst key = `${timeZone} ${date}`;\n\tconst memo = starts.get(key);\n\tif (memo !== undefined) return memo;\n\n\tconst [year, month, day] = parseDate(date);\n\tconst midnightUtc = Date.UTC(year, month - 1, day);\n\t// Two rounds find the offset in effect at local midnight in all but the cases checked below.\n\tlet start = midnightUtc - offsetAt(midnightUtc, timeZone);\n\tstart = midnightUtc - offsetAt(start, timeZone);\n\tif (localDate(start, timeZone) !== date || localDate(start - 1, timeZone) >= date) {\n\t\t// Midnight was skipped or repeated: search for the first instant of the date. Offsets\n\t\t// are between -12 and +14 hours, so it is within 15 hours of midnight UTC.\n\t\tlet low = midnightUtc - 15 * HOUR_MS;\n\t\tlet high = midnightUtc + 15 * HOUR_MS;\n\t\twhile (high - low > 1000) {\n\t\t\tconst middle = low + Math.floor((high - low) / 2000) * 1000;\n\t\t\tif (localDate(middle, timeZone) >= date) high = middle;\n\t\t\telse low = middle;\n\t\t}\n\t\tstart = high;\n\t}\n\tif (starts.size >= MAX_MEMO) starts.clear();\n\tstarts.set(key, start);\n\treturn start;\n}\n\n/** The local day of `date`. */\nexport function calendarDay(date: string, timeZone: string): CalendarDay {\n\treturn { date, from: startOfLocalDay(date, timeZone), to: startOfLocalDay(addDays(date, 1), timeZone) };\n}\n\n/** The last `count` local days up to and including the one containing `now`, oldest first. */\nexport function recentDays(now: number, timeZone: string, count: number): CalendarDay[] {\n\tconst today = localDate(now, timeZone);\n\tconst days: CalendarDay[] = [];\n\tfor (let offset = count - 1; offset >= 0; offset--) days.push(calendarDay(addDays(today, -offset), timeZone));\n\treturn days;\n}\n","import type { CheckState } from \"./provider\";\n\n/**\n * A state confirmed by the confirmation rule. Confirmed states, not individual\n * results, drive uptime, notifications and the stoppage history.\n */\nexport interface ConfirmedState {\n\treadonly state: CheckState;\n\t/**\n\t * When the run of results that confirmed this state began (ms since the epoch). Uptime\n\t * counts the state from here. Strictly greater than the previous confirmed state's `since`.\n\t */\n\treadonly since: number;\n\t/** When the result that completed the run was taken. Notifications report this time. */\n\treadonly confirmedAt: number;\n}\n\n/**\n * One check that produced a state. Checks that produced no result (a missing secret, a\n * provider exception, a runner that gave up) are not observations: leave them out, so they\n * neither confirm a state nor break a run.\n */\nexport interface Observation {\n\treadonly state: CheckState;\n\t/** When the check was taken (ms since the epoch). */\n\treadonly at: number;\n}\n\nexport interface ConfirmationThresholds {\n\t/** Consecutive non-`up` results needed to confirm a non-`up` state. At least 1. */\n\treadonly failureThreshold: number;\n\t/** Consecutive `up` results needed to confirm `up`. At least 1. */\n\treadonly successThreshold: number;\n}\n\nexport interface Confirmation {\n\t/** The confirmed state after the latest observation; `null` until a state has been confirmed. */\n\treadonly current: ConfirmedState | null;\n\t/** Whether the latest observation confirmed a new state, which `current` then is. */\n\treadonly changed: boolean;\n\t/**\n\t * The state the latest results point to while it is not confirmed yet, or `null` when\n\t * they agree with `current`. A non-`up` pending state is what calls for a re-check.\n\t */\n\treadonly pending: CheckState | null;\n}\n\n/** Lower is less severe. */\nconst SEVERITY: Readonly<Record<CheckState, number>> = { up: 0, degraded: 1, down: 2 };\n\n/**\n * How many of the latest observations {@link confirmState} needs to see: enough for the\n * longer threshold, plus one to see where the run started.\n */\nexport function observationsNeeded(thresholds: ConfirmationThresholds): number {\n\treturn Math.max(thresholds.failureThreshold, thresholds.successThreshold) + 1;\n}\n\n/** The trailing observations that satisfy `matches`, oldest first. */\nfunction trailingRun(recent: readonly Observation[], matches: (state: CheckState) => boolean): Observation[] {\n\tlet start = recent.length;\n\twhile (start > 0 && matches((recent[start - 1] as Observation).state)) start--;\n\treturn recent.slice(start);\n}\n\nfunction leastSevere(run: readonly Observation[]): CheckState {\n\treturn run.reduce<CheckState>(\n\t\t(least, { state }) => (SEVERITY[state] < SEVERITY[least] ? state : least),\n\t\t\"down\",\n\t);\n}\n\n/**\n * The confirmation rule, as a pure function of the confirmed state before the\n * latest observation and the latest observations.\n *\n * - `successThreshold` consecutive `up` results confirm `up`.\n * - From `up` (or before anything is confirmed), `failureThreshold` consecutive non-`up`\n * results confirm a non-`up` state: the least severe state in that run, so\n * `[down, degraded]` confirms `degraded`.\n * - While a non-`up` state is confirmed, moving between `degraded` and `down` needs\n * `failureThreshold` consecutive results of the new state.\n *\n * `since` is the start of the run that confirmed the state, as far back as `recent` reaches,\n * and is kept strictly after the previous state's `since`.\n *\n * @param previous The confirmed state before the latest observation, or `null`.\n * @param recent The latest observations, oldest first, ending with the newest one. Pass at\n * least {@link observationsNeeded} of them when that many exist.\n */\nexport function confirmState(\n\tprevious: ConfirmedState | null,\n\trecent: readonly Observation[],\n\tthresholds: ConfirmationThresholds,\n): Confirmation {\n\tconst latest = recent.at(-1);\n\tconst unchanged = (pending: CheckState | null): Confirmation => ({ current: previous, changed: false, pending });\n\tif (latest === undefined) return unchanged(null);\n\n\tlet target: CheckState;\n\tlet run: Observation[];\n\tlet threshold: number;\n\tif (latest.state === \"up\") {\n\t\tif (previous?.state === \"up\") return unchanged(null);\n\t\trun = trailingRun(recent, (state) => state === \"up\");\n\t\ttarget = \"up\";\n\t\tthreshold = thresholds.successThreshold;\n\t} else if (previous === null || previous.state === \"up\") {\n\t\trun = trailingRun(recent, (state) => state !== \"up\");\n\t\ttarget = leastSevere(run);\n\t\tthreshold = thresholds.failureThreshold;\n\t} else {\n\t\tif (latest.state === previous.state) return unchanged(null);\n\t\trun = trailingRun(recent, (state) => state === latest.state);\n\t\ttarget = latest.state;\n\t\tthreshold = thresholds.failureThreshold;\n\t}\n\n\tif (run.length < threshold) return unchanged(target);\n\tconst runStart = (run[0] as Observation).at;\n\tconst since = previous === null ? runStart : Math.max(runStart, previous.since + 1);\n\treturn {\n\t\tcurrent: { state: target, since, confirmedAt: latest.at },\n\t\tchanged: true,\n\t\t// [degraded, down] confirms degraded, and the latest down already points to down.\n\t\tpending: latest.state === target ? null : latest.state,\n\t};\n}\n","import * as z from \"zod\";\n\n/** Units accepted in a {@link Duration}. */\nexport type DurationUnit = \"ms\" | \"s\" | \"m\" | \"h\" | \"d\";\n\n/**\n * A length of time written as a non-negative integer followed by a unit,\n * for example `\"500ms\"`, `\"15s\"`, `\"1m\"`, `\"12h\"` or `\"180d\"`.\n * Compound forms such as `\"1h30m\"` and fractions such as `\"1.5h\"` are not accepted.\n */\nexport type Duration = `${number}${DurationUnit}`;\n\nconst UNIT_MS: Record<DurationUnit, number> = {\n\tms: 1,\n\ts: 1_000,\n\tm: 60_000,\n\th: 3_600_000,\n\td: 86_400_000,\n};\n\nconst DURATION_PATTERN = /^(\\d+)(ms|s|m|h|d)$/;\n\nconst FORMAT_HINT =\n\t'expected an integer followed by ms, s, m, h or d (for example \"15s\", \"1m\" or \"180d\")';\n\n/**\n * Converts a duration string to milliseconds.\n * @throws RangeError if the string is not a valid {@link Duration}.\n */\nexport function parseDuration(value: string): number {\n\tconst match = DURATION_PATTERN.exec(value);\n\tconst amount = match?.[1];\n\tconst unit = match?.[2] as DurationUnit | undefined;\n\tif (amount === undefined || unit === undefined) {\n\t\tthrow new RangeError(`Invalid duration \"${value}\": ${FORMAT_HINT}`);\n\t}\n\tconst ms = Number(amount) * UNIT_MS[unit];\n\tif (!Number.isSafeInteger(ms)) {\n\t\tthrow new RangeError(`Invalid duration \"${value}\": too large`);\n\t}\n\treturn ms;\n}\n\n/**\n * Zod schema that accepts a {@link Duration} string and outputs milliseconds.\n * Use `.prefault(\"10s\")` (not `.default()`) to give a default written as a duration string.\n */\nexport function durationSchema(): z.ZodType<number, Duration> {\n\treturn z.string().transform((value, ctx) => {\n\t\ttry {\n\t\t\treturn parseDuration(value);\n\t\t} catch (error) {\n\t\t\tctx.addIssue((error as Error).message);\n\t\t\treturn z.NEVER;\n\t\t}\n\t}) as z.ZodType<number, Duration>;\n}\n","/**\n * Where the hub places a monitor's Durable Object, and so where the built-in runner\n * checks from. Values are Durable Object location hints.\n *\n * The Worker verifies at type-check time that this list matches the runtime's\n * `DurableObjectLocationHint`, so core stays free of Cloudflare runtime types.\n */\nexport const LOCATION_HINTS = [\n\t\"wnam\",\n\t\"enam\",\n\t\"sam\",\n\t\"weur\",\n\t\"eeur\",\n\t\"apac\",\n\t\"apac-ne\",\n\t\"apac-se\",\n\t\"oc\",\n\t\"afr\",\n\t\"me\",\n] as const;\n\nexport type LocationHint = (typeof LOCATION_HINTS)[number];\n","import type { Capability } from \"./provider\";\n\n/**\n * Declares a runner (the environment that executes checks) and what it can do.\n * Results are stored per monitor × runner, so `id` must be stable.\n */\nexport interface RunnerDeclaration {\n\t/** Stable identifier, for example `\"cloudflare\"` for the built-in runner. */\n\treadonly id: string;\n\treadonly capabilities: readonly Capability[];\n\t/**\n\t * The longest monitor `timeout` this runner accepts, in milliseconds. A monitor with a\n\t * longer timeout is rejected when the configuration is loaded. Omit for no limit.\n\t */\n\treadonly maxTimeoutMs?: number;\n}\n\n/** Returns the capabilities in `required` that `runner` does not provide. */\nexport function missingCapabilities(\n\trequired: readonly Capability[],\n\trunner: RunnerDeclaration,\n): Capability[] {\n\treturn required.filter((capability) => !runner.capabilities.includes(capability));\n}\n","import * as z from \"zod\";\nimport type { AuthProvider } from \"./auth\";\nimport { type Duration, durationSchema } from \"./duration\";\nimport { LOCATION_HINTS, type LocationHint } from \"./location\";\nimport { type MonitorDefinition, RESERVED_MONITOR_KEYS } from \"./monitor\";\nimport type { NotifierKind } from \"./notifier\";\nimport { DEFAULT_PAGE_TEMPLATE, PAGE_TEMPLATES, type PageTemplate } from \"./page-templates\";\nimport type { CheckProvider } from \"./provider\";\nimport { missingCapabilities, type RunnerDeclaration } from \"./runner\";\nimport { secretNames } from \"./secret\";\n\n// ---------------------------------------------------------------------------\n// Input: what users write in status.config.ts\n// ---------------------------------------------------------------------------\n\nexport interface StatusConfig {\n\t/** IANA time zone that decides where each day starts for daily uptime. Default: `\"UTC\"`. */\n\ttimezone?: string;\n\t/** Default location for monitors; each monitor can override it. When omitted, Cloudflare chooses. */\n\tlocation?: LocationHint;\n\t/**\n\t * How long check results are kept: at least `\"1d\"`, and at least 10 times every monitor's\n\t * `interval`. Default: forever. Shortening it deletes older results, gradually, and they\n\t * cannot be recovered.\n\t */\n\tretention?: Duration;\n\t/**\n\t * Authentication for the admin UI and admin API.\n\t * When omitted, both reject every request.\n\t */\n\tauth?: AuthProvider;\n\t/** Notifier kinds offered in the admin UI. Targets and their secrets are not configured here. */\n\tnotifiers?: readonly NotifierKind[];\n\t/**\n\t * Language of notifications and of the text of automatic incidents, as a BCP 47 tag\n\t * such as `\"ja\"`. Default: `\"en\"`. A language without a translation falls back to English.\n\t */\n\tlocale?: string;\n\t/**\n\t * Where this deployment is reachable, such as `\"https://status.example.com\"`, for links in\n\t * notifications (the admin UI's \"create an incident\" form). Without it, notifications\n\t * have no links.\n\t */\n\tbaseUrl?: string;\n\t/** Notification settings that are not per target (targets are managed in the admin UI). */\n\tnotifications?: NotificationsConfig;\n\t/** Monitors, each created by a provider factory such as `http({ … })`. */\n\tmonitors?: readonly MonitorDefinition[];\n\t/** Public status pages. */\n\tpages?: readonly PageConfig[];\n\t/** The public API that status pages read. */\n\tpublicApi?: PublicApiConfig;\n\t/**\n\t * Host names (with the port, if not the default) on which the admin UI and admin API answer,\n\t * such as `[\"status.example.com\"]`, or `\"baseUrl\"` for the host of `baseUrl`. Requests for\n\t * them on any other host name (a `*.workers.dev` URL without Cloudflare Access, say) get the\n\t * same 403 as a failed sign-in. Default: any host name.\n\t */\n\tadminHosts?: \"baseUrl\" | readonly string[];\n}\n\nexport interface NotificationsConfig {\n\t/**\n\t * How often the every-minute Cron looks for monitors whose results stopped arriving\n\t * (`unknown`) to notify administrators. Whole minutes from `\"1m\"` (the default) to\n\t * `\"1h\"`. A longer interval delays those notifications but saves Durable Object requests,\n\t * which the Free plan limits per day.\n\t */\n\tunknownCheckInterval?: Duration;\n}\n\n/** Placeholders the texts of automatic incidents may use. */\nexport const INCIDENT_TEMPLATE_PLACEHOLDERS = [\"components\", \"monitor\", \"time\"] as const;\n\n/**\n * Texts of automatic incidents (`incidents.auto`), replacing the translated defaults.\n * They may use `{components}` (the affected components' names), `{monitor}` (the monitor's\n * name) and `{time}` (when it happened, in `timezone`).\n */\nexport interface IncidentTemplates {\n\t/** Title of a new incident. */\n\ttitle?: string;\n\t/** First update of a new incident (stage \"investigating\"). */\n\tinvestigating?: string;\n\t/** Update added to an unresolved incident of the same component. */\n\tupdate?: string;\n\t/** Update that resolves an automatic incident on recovery. */\n\tresolved?: string;\n\t/** Update that resolves an automatic incident when its monitor leaves the configuration while down. */\n\tstopped?: string;\n\t/** Update that reopens an automatic incident resolved less than `reopenWithin` ago. */\n\treopened?: string;\n\t/** Update when a monitor goes from `down` to `degraded`: the incident stays open. */\n\tpartial?: string;\n}\n\n/** Where public API responses are kept for 30 seconds. */\nexport type PublicApiCache = \"durable-object\" | \"workers-cache\";\n\nexport interface PublicApiConfig {\n\t/**\n\t * Where responses are kept for 30 seconds. Default: `\"durable-object\"`.\n\t *\n\t * - `\"durable-object\"`: in the memory of each page's Durable Object. One Worker request and\n\t * one Durable Object request per API call; an administrator's change shows at once\n\t * everywhere. A page's object takes about 1,000 requests per second at most.\n\t * - `\"workers-cache\"`: in Cloudflare's Workers Cache, in front of the Worker, near visitors.\n\t * Scales without limit, but every API call is billed as two Worker requests, and\n\t * purging after a change is rate-limited (a refused purge expires within 30 seconds).\n\t */\n\tcache?: PublicApiCache;\n\t/**\n\t * Web pages on other sites whose scripts may read the public API (CORS): `\"*\"` for any,\n\t * or exact origins such as `\"https://www.example.com\"`. Default: none. Never applies to the\n\t * admin API.\n\t */\n\tallowedOrigins?: \"*\" | readonly string[];\n}\n\nexport interface PageConfig {\n\t/** Unique identifier, with the same rules as monitor IDs. */\n\tid: string;\n\t/**\n\t * How the page looks: `\"default\"`, or `\"modern\"` (a dark header over one card, with\n\t * component groups, response times and a light/dark switch). Default: `\"default\"`. Both show\n\t * the same data from the same public API.\n\t */\n\ttemplate?: PageTemplate;\n\t/**\n\t * Where visitors report a problem, linked from the page's header (\"Report a problem\"): an\n\t * `https:` or `http:` URL, or `mailto:`. Shown by the `\"modern\"` template. Default: none.\n\t */\n\treportUrl?: string;\n\tincidents?: {\n\t\t/** Publish an \"investigating\" incident automatically when `down` is confirmed. Default: `false`. */\n\t\tauto?: boolean;\n\t\t/** Texts of automatic incidents, replacing the translated defaults. */\n\t\ttemplates?: IncidentTemplates;\n\t\t/**\n\t\t * A component confirmed `down` again within this long after automation resolved its\n\t\t * incident reopens that incident (with an update) instead of publishing a new one, so\n\t\t * that a flapping service does not fill the page with incidents. Never an incident an\n\t\t * administrator edited. `\"0m\"` turns it off. Default: `\"30m\"`; at most `\"1d\"`.\n\t\t */\n\t\treopenWithin?: Duration;\n\t};\n\t/**\n\t * What the page lists, in order: components, and groups of components. Monitors that are in\n\t * no component are not public.\n\t */\n\tcomponents?: readonly (ComponentConfig | ComponentGroupConfig)[];\n}\n\nexport interface ComponentConfig {\n\t/**\n\t * Identifier, unique within the page, with the same rules as monitor IDs. Incidents and\n\t * maintenance refer to components by ID, so keep it when renaming the component.\n\t */\n\tid: string;\n\t/** Display name. Optional only for a component with exactly one monitor, whose name is used. */\n\tname?: string;\n\t/** The component shows the worst state of these monitors. Without monitors, only incidents set its state. */\n\tmonitors?: readonly string[];\n\t/**\n\t * Publish the response times of its monitors: averages over the last 24 hours, 7 days and\n\t * 30 days, with the 95th percentile. Needs at least one monitor. Shown by the `\"modern\"`\n\t * template. Default: `false`.\n\t */\n\tlatency?: boolean;\n}\n\n/**\n * Components shown together under one name, folded by default (the `\"modern\"` template; the\n * `\"default\"` template lists the components one by one). Display only: incidents and\n * maintenance still affect components, and the group shows the worst of its components.\n */\nexport interface ComponentGroupConfig {\n\t/** Identifier, with the same rules as component IDs, unique among the page's components and groups. */\n\tid: string;\n\tname: string;\n\t/** At least one; groups do not nest. */\n\tcomponents: readonly ComponentConfig[];\n}\n\n/** Gives `status.config.ts` type checking and completion. Validation happens when the Worker loads it. */\nexport function defineConfig(config: StatusConfig): StatusConfig {\n\treturn config;\n}\n\n/**\n * Shorthand for a component made of a single monitor. Its ID is the monitor ID and its\n * name is the monitor's name unless `name` is given.\n */\nexport function component(monitorId: string, options: { name?: string; latency?: boolean } = {}): ComponentConfig {\n\treturn { id: monitorId, ...options, monitors: [monitorId] };\n}\n\n// ---------------------------------------------------------------------------\n// Output: the validated configuration with defaults applied\n// ---------------------------------------------------------------------------\n\nexport interface ResolvedConfirmation {\n\treadonly failureThreshold: number;\n\treadonly successThreshold: number;\n\treadonly recheckIntervalMs: number;\n}\n\nexport interface ResolvedMonitor {\n\treadonly id: string;\n\treadonly name: string;\n\treadonly provider: CheckProvider;\n\t/**\n\t * Provider options after validation and defaults. May contain `secret()` references;\n\t * run checks with `runCheck`, which resolves them.\n\t */\n\treadonly options: unknown;\n\t/** Names of the secrets the options reference. */\n\treadonly secrets: readonly string[];\n\treadonly intervalMs: number;\n\treadonly timeoutMs: number;\n\treadonly location: LocationHint | undefined;\n\treadonly confirmation: ResolvedConfirmation;\n\t/** IDs of the runners that check this monitor. Results are kept per monitor × runner. */\n\treadonly runners: readonly string[];\n}\n\nexport interface ResolvedComponent {\n\treadonly id: string;\n\treadonly name: string;\n\treadonly monitors: readonly string[];\n\t/** Whether its monitors' response times are public. */\n\treadonly latency: boolean;\n}\n\nexport interface ResolvedGroup {\n\treadonly id: string;\n\treadonly name: string;\n\t/** IDs of its components, in order; they are next to each other in the page's `components`. */\n\treadonly components: readonly string[];\n}\n\nexport interface ResolvedPage {\n\treadonly id: string;\n\treadonly template: PageTemplate;\n\t/** `null` when not configured. */\n\treadonly reportUrl: string | null;\n\treadonly incidents: {\n\t\treadonly auto: boolean;\n\t\treadonly templates: Readonly<IncidentTemplates>;\n\t\t/** 0: never reopen. */\n\t\treadonly reopenWithinMs: number;\n\t};\n\t/** Every component, those of groups included, in the order of the page. */\n\treadonly components: readonly ResolvedComponent[];\n\treadonly groups: readonly ResolvedGroup[];\n}\n\nexport interface ResolvedPublicApi {\n\treadonly cache: PublicApiCache;\n\t/** `\"*\"`, or the exact origins allowed (empty: CORS is off). */\n\treadonly allowedOrigins: \"*\" | readonly string[];\n}\n\nexport interface ResolvedConfig {\n\treadonly timezone: string;\n\t/** `null` keeps results forever. */\n\treadonly retentionMs: number | null;\n\t/** `undefined`: no auth provider, so the admin UI and admin API reject every request. */\n\treadonly auth: AuthProvider | undefined;\n\treadonly notifiers: readonly NotifierKind[];\n\t/** Canonical BCP 47 tag. */\n\treadonly locale: string;\n\t/** Without a trailing slash; `null` when not configured. */\n\treadonly baseUrl: string | null;\n\treadonly notifications: { readonly unknownCheckIntervalMs: number };\n\treadonly monitors: readonly ResolvedMonitor[];\n\treadonly pages: readonly ResolvedPage[];\n\treadonly publicApi: ResolvedPublicApi;\n\t/** Lowercase hosts (`host[:port]`) the admin UI and API answer on; `null` for any. */\n\treadonly adminHosts: readonly string[] | null;\n}\n\nexport interface ConfigIssue {\n\t/** Where the problem is, such as `monitors[0] (\"api\").url`. Empty for the configuration as a whole. */\n\treadonly path: string;\n\treadonly message: string;\n}\n\n/** Thrown by {@link resolveConfig} with every problem found, not just the first. */\nexport class ConfigError extends Error {\n\toverride readonly name = \"ConfigError\";\n\treadonly issues: readonly ConfigIssue[];\n\n\tconstructor(issues: readonly ConfigIssue[]) {\n\t\tconst lines = issues.map((issue) =>\n\t\t\tissue.path === \"\" ? ` - ${issue.message}` : ` - ${issue.path}: ${issue.message}`,\n\t\t);\n\t\tsuper([\"Invalid status.config.ts:\", ...lines].join(\"\\n\"));\n\t\tthis.issues = issues;\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Validation\n// ---------------------------------------------------------------------------\n\nconst ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/;\nconst DAY_MS = 86_400_000;\nconst DEFAULT_TIMEOUT: Duration = \"10s\";\n/** `retention` must cover at least this many intervals of every monitor. */\nconst MIN_INTERVALS_RETAINED = 10;\n\nconst idSchema = z\n\t.string()\n\t.regex(\n\t\tID_PATTERN,\n\t\t'must be 1-64 characters of lowercase letters, digits, \"-\" or \"_\", starting with a letter or digit',\n\t);\n\nfunction positiveDuration(): z.ZodType<number, Duration> {\n\treturn durationSchema().refine((ms) => ms > 0, \"must be longer than 0\");\n}\n\nconst UNITS: readonly [string, number][] = [\n\t[\"d\", DAY_MS],\n\t[\"h\", 3_600_000],\n\t[\"m\", 60_000],\n\t[\"s\", 1_000],\n];\n\n/** Milliseconds back to the largest exact unit, for messages: 90000 -> \"90s\". */\nfunction formatDuration(ms: number): string {\n\tconst unit = UNITS.find(([, size]) => ms % size === 0);\n\treturn unit ? `${ms / unit[1]}${unit[0]}` : `${ms}ms`;\n}\n\nconst timezoneSchema = z.string().transform((value, ctx) => {\n\ttry {\n\t\t// Also normalizes the spelling, e.g. \"asia/tokyo\" -> \"Asia/Tokyo\".\n\t\treturn new Intl.DateTimeFormat(\"en-US\", { timeZone: value }).resolvedOptions().timeZone;\n\t} catch {\n\t\tctx.addIssue(`unknown time zone \"${value}\"; use an IANA name such as \"Asia/Tokyo\"`);\n\t\treturn z.NEVER;\n\t}\n});\n\nconst confirmationSchema = z.strictObject({\n\tfailureThreshold: z.int().min(1).default(2),\n\tsuccessThreshold: z.int().min(1).default(1),\n\trecheckInterval: positiveDuration().prefault(\"15s\"),\n});\n\nconst monitorSettingsSchema = z.strictObject({\n\tid: idSchema,\n\tname: z.string().min(1).optional(),\n\tinterval: positiveDuration(),\n\ttimeout: positiveDuration().prefault(DEFAULT_TIMEOUT),\n\tlocation: z.enum(LOCATION_HINTS).optional(),\n\tconfirmation: confirmationSchema.prefault({}),\n});\n\nconst componentSchema = z.strictObject({\n\tid: idSchema,\n\tname: z.string().min(1).optional(),\n\tmonitors: z.array(z.string()).default([]),\n\tlatency: z.boolean().default(false),\n});\n\nconst groupSchema = z.strictObject({\n\tid: idSchema,\n\tname: z.string().trim().min(1),\n\t// Validated one by one, as the page's components.\n\tcomponents: z.array(z.unknown()).min(1, \"must list at least one component\"),\n});\n\n/** An entry of `components` that is a group (it has `components` of its own). */\nfunction isGroupEntry(value: unknown): boolean {\n\treturn isObject(value) && \"components\" in value;\n}\n\nconst reportUrlSchema = z\n\t.string()\n\t.max(2_000)\n\t.transform((value, ctx) => {\n\t\tlet url: URL;\n\t\ttry {\n\t\t\turl = new URL(value);\n\t\t} catch {\n\t\t\tctx.addIssue('must be a URL such as \"https://example.com/support\" or \"mailto:support@example.com\"');\n\t\t\treturn z.NEVER;\n\t\t}\n\t\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\" && url.protocol !== \"mailto:\") {\n\t\t\tctx.addIssue(\"must be an https, http or mailto URL\");\n\t\t\treturn z.NEVER;\n\t\t}\n\t\tif (url.username !== \"\" || url.password !== \"\") {\n\t\t\tctx.addIssue(\"must not contain credentials\");\n\t\t\treturn z.NEVER;\n\t\t}\n\t\treturn url.href;\n\t});\n\nconst PLACEHOLDER = /\\{([^{}]*)\\}/g;\nconst KNOWN_PLACEHOLDERS: ReadonlySet<string> = new Set(INCIDENT_TEMPLATE_PLACEHOLDERS);\n\nfunction templateSchema(maxLength: number) {\n\treturn z\n\t\t.string()\n\t\t.trim()\n\t\t.min(1)\n\t\t.max(maxLength)\n\t\t.superRefine((text, ctx) => {\n\t\t\tfor (const match of text.matchAll(PLACEHOLDER)) {\n\t\t\t\tif (!KNOWN_PLACEHOLDERS.has(match[1] as string)) {\n\t\t\t\t\tctx.addIssue(\n\t\t\t\t\t\t`unknown placeholder ${match[0]}; use ${INCIDENT_TEMPLATE_PLACEHOLDERS.map((name) => `{${name}}`).join(\", \")}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n}\n\nconst templatesSchema = z.strictObject({\n\ttitle: templateSchema(200).optional(),\n\tinvestigating: templateSchema(2_000).optional(),\n\tupdate: templateSchema(2_000).optional(),\n\tresolved: templateSchema(2_000).optional(),\n\tstopped: templateSchema(2_000).optional(),\n\treopened: templateSchema(2_000).optional(),\n\tpartial: templateSchema(2_000).optional(),\n});\n\nconst DEFAULT_REOPEN_WITHIN: Duration = \"30m\";\n\nconst pageSchema = z.strictObject({\n\tid: idSchema,\n\ttemplate: z.enum(PAGE_TEMPLATES).default(DEFAULT_PAGE_TEMPLATE),\n\treportUrl: reportUrlSchema.optional(),\n\tincidents: z\n\t\t.strictObject({\n\t\t\tauto: z.boolean().default(false),\n\t\t\ttemplates: templatesSchema.default({}),\n\t\t\treopenWithin: durationSchema()\n\t\t\t\t.refine((ms) => ms <= DAY_MS, \"must be at most 1d\")\n\t\t\t\t.prefault(DEFAULT_REOPEN_WITHIN),\n\t\t})\n\t\t.prefault({}),\n\t// Components are validated one by one, so that one bad entry does not hide the others.\n\tcomponents: z.array(z.unknown()).default([]),\n});\n\n/** An origin as browsers send it in `Origin`: scheme, host and port if not the default, lowercase. */\nconst originSchema = z.string().refine((value) => {\n\ttry {\n\t\tconst url = new URL(value);\n\t\treturn (url.protocol === \"https:\" || url.protocol === \"http:\") && url.origin === value;\n\t} catch {\n\t\treturn false;\n\t}\n}, 'must be an origin such as \"https://www.example.com\": lowercase, with no path, query or trailing slash, and no default port');\n\nconst publicApiSchema = z\n\t.strictObject({\n\t\tcache: z.enum([\"durable-object\", \"workers-cache\"]).default(\"durable-object\"),\n\t\tallowedOrigins: z\n\t\t\t.union([\n\t\t\t\tz.literal(\"*\"),\n\t\t\t\tz.array(originSchema).superRefine((origins, ctx) => {\n\t\t\t\t\torigins.forEach((origin, index) => {\n\t\t\t\t\t\tif (origins.indexOf(origin) !== index) {\n\t\t\t\t\t\t\tctx.addIssue({ code: \"custom\", message: `\"${origin}\" is listed twice`, path: [index] });\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t\t])\n\t\t\t.default([]),\n\t})\n\t.prefault({});\n\nconst localeSchema = z.string().transform((value, ctx) => {\n\ttry {\n\t\tconst [canonical] = Intl.getCanonicalLocales(value);\n\t\tif (canonical !== undefined) return canonical;\n\t} catch {\n\t\t// Reported below.\n\t}\n\tctx.addIssue(`\"${value}\" is not a language tag; use one such as \"en\" or \"ja\"`);\n\treturn z.NEVER;\n});\n\nconst baseUrlSchema = z.string().transform((value, ctx) => {\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(value);\n\t} catch {\n\t\tctx.addIssue('must be a URL such as \"https://status.example.com\"');\n\t\treturn z.NEVER;\n\t}\n\tif (url.protocol !== \"https:\" && url.protocol !== \"http:\") ctx.addIssue(\"must be an http or https URL\");\n\tif (url.username !== \"\" || url.password !== \"\") ctx.addIssue(\"must not contain credentials\");\n\tif (url.search !== \"\" || url.hash !== \"\") ctx.addIssue(\"must not have a query or fragment\");\n\treturn `${url.origin}${url.pathname}`.replace(/\\/+$/, \"\");\n});\n\nconst MINUTE_MS = 60_000;\n\n/** A host as `URL.host` gives it: lowercase name (or bracketed IPv6) and a port if not the default. */\nconst hostSchema = z.string().refine((value) => {\n\ttry {\n\t\tconst url = new URL(`https://${value}`);\n\t\treturn url.host === value && url.pathname === \"/\" && url.username === \"\" && url.password === \"\";\n\t} catch {\n\t\treturn false;\n\t}\n}, 'must be a host name such as \"status.example.com\" (lowercase, with a port only if it is not 443), without a scheme or path');\n\nconst adminHostsSchema = z.union([\n\tz.literal(\"baseUrl\"),\n\tz\n\t\t.array(hostSchema)\n\t\t.min(1, 'must list at least one host name, or be \"baseUrl\"')\n\t\t.superRefine((hosts, ctx) => {\n\t\t\thosts.forEach((host, index) => {\n\t\t\t\tif (hosts.indexOf(host) !== index) ctx.addIssue({ code: \"custom\", message: `\"${host}\" is listed twice`, path: [index] });\n\t\t\t});\n\t\t}),\n]);\n\nconst notificationsSchema = z\n\t.strictObject({\n\t\tunknownCheckInterval: durationSchema()\n\t\t\t.refine((ms) => ms % MINUTE_MS === 0 && ms >= MINUTE_MS && ms <= 60 * MINUTE_MS, {\n\t\t\t\tmessage: 'must be whole minutes from \"1m\" to \"1h\" (the Cron runs every minute)',\n\t\t\t})\n\t\t\t.prefault(\"1m\"),\n\t})\n\t.prefault({});\n\nconst authSchema = z.custom<AuthProvider>(\n\t(value) =>\n\t\tisObject(value) && typeof value[\"type\"] === \"string\" && typeof value[\"authenticate\"] === \"function\",\n\t\"must be an auth provider (an object with `type` and `authenticate()`)\",\n);\n\nconst TOP_LEVEL_KEYS: ReadonlySet<string> = new Set([\n\t\"timezone\",\n\t\"location\",\n\t\"retention\",\n\t\"auth\",\n\t\"notifiers\",\n\t\"locale\",\n\t\"baseUrl\",\n\t\"notifications\",\n\t\"monitors\",\n\t\"pages\",\n\t\"publicApi\",\n\t\"adminHosts\",\n] satisfies (keyof StatusConfig)[]);\n\nconst RESERVED_SETTING_KEYS: ReadonlySet<string> = new Set(RESERVED_MONITOR_KEYS);\n\n/** `value` without its `undefined` properties, so that resolved objects compare equal to what was written. */\nfunction stripUndefined<T extends object>(value: T): T {\n\treturn Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined)) as T;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction isSchema(value: unknown): boolean {\n\treturn isObject(value) && typeof value[\"safeParse\"] === \"function\";\n}\n\nfunction isNotifierKind(value: unknown): value is NotifierKind {\n\treturn (\n\t\tisObject(value) &&\n\t\ttypeof value[\"type\"] === \"string\" &&\n\t\tisSchema(value[\"options\"]) &&\n\t\tArray.isArray(value[\"secretOptions\"]) &&\n\t\ttypeof value[\"send\"] === \"function\"\n\t);\n}\n\nfunction isMonitorDefinition(value: unknown): value is MonitorDefinition {\n\tif (!isObject(value)) return false;\n\tconst provider = value[\"provider\"];\n\treturn (\n\t\tisObject(provider) &&\n\t\ttypeof provider[\"type\"] === \"string\" &&\n\t\ttypeof provider[\"check\"] === \"function\" &&\n\t\tArray.isArray(provider[\"requires\"]) &&\n\t\tisSchema(provider[\"options\"]) &&\n\t\tisObject(value[\"settings\"]) &&\n\t\tisObject(value[\"options\"])\n\t);\n}\n\ninterface IssueLike {\n\treadonly path: readonly PropertyKey[];\n\treadonly message: string;\n}\n\nfunction joinPath(base: string, segments: readonly PropertyKey[]): string {\n\tlet path = base;\n\tfor (const segment of segments) {\n\t\tif (typeof segment === \"number\") path += `[${segment}]`;\n\t\telse path += path === \"\" ? String(segment) : `.${String(segment)}`;\n\t}\n\treturn path;\n}\n\nexport interface ResolveOptions {\n\t/**\n\t * Runners available to the hub. Every monitor is assigned to the first one for now;\n\t * choosing runners per monitor arrives with external runners.\n\t */\n\treadonly runners: readonly RunnerDeclaration[];\n\t/**\n\t * Secrets of the hub itself, which a monitor must never reference with `secret()`: they\n\t * would be sent to the monitored endpoint (such as the key that encrypts notification\n\t * targets' secrets).\n\t */\n\treadonly reservedSecrets?: readonly string[];\n}\n\n/**\n * Validates a configuration and applies defaults. Call it when the Worker loads, so that a\n * broken configuration fails the deployment instead of failing at run time.\n * @throws ConfigError listing every problem found.\n */\nexport function resolveConfig(config: StatusConfig, { runners, reservedSecrets = [] }: ResolveOptions): ResolvedConfig {\n\tconst issues: ConfigIssue[] = [];\n\tconst report = (path: string, message: string) => issues.push({ path, message });\n\tconst collect = (base: string, found: readonly IssueLike[]) => {\n\t\tfor (const issue of found) report(joinPath(base, issue.path), issue.message);\n\t};\n\t// Each part is validated on its own, so one problem does not hide the others.\n\tconst parse = <T>(schema: z.ZodType<T, unknown>, value: unknown, path: string): T | undefined => {\n\t\tconst result = schema.safeParse(value);\n\t\tif (result.success) return result.data;\n\t\tcollect(path, result.error.issues);\n\t\treturn undefined;\n\t};\n\n\tif (!isObject(config)) {\n\t\tthrow new ConfigError([{ path: \"\", message: \"must be an object passed to defineConfig()\" }]);\n\t}\n\tconst input: Record<string, unknown> = config;\n\tfor (const key of Object.keys(input)) {\n\t\tif (!TOP_LEVEL_KEYS.has(key)) report(\"\", `Unrecognized key: \"${key}\"`);\n\t}\n\n\tconst timezone = parse(timezoneSchema.prefault(\"UTC\"), input[\"timezone\"], \"timezone\");\n\tconst location = parse(z.enum(LOCATION_HINTS).optional(), input[\"location\"], \"location\");\n\tconst retention = parse(\n\t\tdurationSchema()\n\t\t\t.refine((ms) => ms >= DAY_MS, \"must be at least 1d\")\n\t\t\t.optional(),\n\t\tinput[\"retention\"],\n\t\t\"retention\",\n\t);\n\tconst auth = parse(authSchema.optional(), input[\"auth\"], \"auth\");\n\tconst notifierEntries = parse(z.array(z.unknown()).default([]), input[\"notifiers\"], \"notifiers\") ?? [];\n\tconst monitorEntries = parse(z.array(z.unknown()).default([]), input[\"monitors\"], \"monitors\") ?? [];\n\tconst pageEntries = parse(z.array(z.unknown()).default([]), input[\"pages\"], \"pages\") ?? [];\n\tconst publicApi = parse(publicApiSchema, input[\"publicApi\"], \"publicApi\");\n\tconst locale = parse(localeSchema.prefault(\"en\"), input[\"locale\"], \"locale\");\n\tconst baseUrl = parse(baseUrlSchema.optional(), input[\"baseUrl\"], \"baseUrl\");\n\tconst notifications = parse(notificationsSchema, input[\"notifications\"], \"notifications\");\n\tconst adminHostsInput = parse(adminHostsSchema.optional(), input[\"adminHosts\"], \"adminHosts\");\n\tlet adminHosts: readonly string[] | null = null;\n\tif (adminHostsInput === \"baseUrl\") {\n\t\tif (baseUrl === undefined) {\n\t\t\tif (input[\"baseUrl\"] === undefined) report(\"adminHosts\", '\"baseUrl\" needs `baseUrl` to be set');\n\t\t} else adminHosts = [new URL(baseUrl).host];\n\t} else if (adminHostsInput !== undefined) adminHosts = adminHostsInput;\n\n\tconst runnerIds = new Set<string>();\n\tfor (const runner of runners) {\n\t\tif (runnerIds.has(runner.id)) report(\"\", `duplicate runner ID \"${runner.id}\"`);\n\t\trunnerIds.add(runner.id);\n\t}\n\tconst defaultRunner = runners[0];\n\tif (defaultRunner === undefined && monitorEntries.length > 0) {\n\t\treport(\"\", \"no runner is available to run monitors\");\n\t}\n\n\t// ---- Notifiers\n\tconst notifiers: NotifierKind[] = [];\n\tconst firstIndexOfNotifier = new Map<string, number>();\n\tnotifierEntries.forEach((notifier, index) => {\n\t\tconst path = `notifiers[${index}]`;\n\t\tif (!isNotifierKind(notifier)) {\n\t\t\treport(path, \"must be a notifier kind (an object with `type`, an `options` schema, `secretOptions` and `send()`)\");\n\t\t\treturn;\n\t\t}\n\t\tconst first = firstIndexOfNotifier.get(notifier.type);\n\t\tif (first !== undefined) {\n\t\t\treport(path, `duplicate notifier type \"${notifier.type}\" (also used by notifiers[${first}])`);\n\t\t\treturn;\n\t\t}\n\t\tfirstIndexOfNotifier.set(notifier.type, index);\n\t\tnotifiers.push(notifier);\n\t});\n\n\t// ---- Monitors\n\tconst definitions = monitorEntries.filter(isMonitorDefinition);\n\t// IDs as written, so that a monitor with other errors does not also show up as unknown.\n\tconst declaredMonitorIds = new Set(\n\t\tdefinitions.flatMap((definition) =>\n\t\t\ttypeof definition.settings.id === \"string\" ? [definition.settings.id] : [],\n\t\t),\n\t);\n\tconst firstIndexOfMonitor = new Map<string, number>();\n\tconst monitors: ResolvedMonitor[] = [];\n\n\tmonitorEntries.forEach((entry, index) => {\n\t\tif (!isMonitorDefinition(entry)) {\n\t\t\treport(`monitors[${index}]`, \"must be created by a provider factory such as http({ … })\");\n\t\t\treturn;\n\t\t}\n\t\tconst rawSettings: Record<string, unknown> = { ...entry.settings };\n\t\tconst rawId = rawSettings[\"id\"];\n\t\tconst base =\n\t\t\ttypeof rawId === \"string\" ? `monitors[${index}] (\"${rawId}\")` : `monitors[${index}]`;\n\t\tconst { provider } = entry;\n\n\t\tfor (const key of Object.keys(rawSettings)) {\n\t\t\tif (RESERVED_SETTING_KEYS.has(key)) {\n\t\t\t\treport(`${base}.${key}`, `\"${key}\" is reserved for a future monitor setting`);\n\t\t\t}\n\t\t}\n\t\tconst settings = parse(\n\t\t\tmonitorSettingsSchema,\n\t\t\tObject.fromEntries(Object.entries(rawSettings).filter(([key]) => !RESERVED_SETTING_KEYS.has(key))),\n\t\t\tbase,\n\t\t);\n\t\tconst options = parse(provider.options, entry.options, base);\n\n\t\tconst assigned = defaultRunner === undefined ? [] : [defaultRunner];\n\t\tfor (const runner of assigned) {\n\t\t\tconst missing = missingCapabilities(provider.requires, runner);\n\t\t\tif (missing.length > 0) {\n\t\t\t\treport(\n\t\t\t\t\tbase,\n\t\t\t\t\t`provider \"${provider.type}\" requires ${missing.map((c) => `\"${c}\"`).join(\", \")}, ` +\n\t\t\t\t\t\t`which runner \"${runner.id}\" does not provide`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (settings === undefined) return;\n\t\tconst { id, interval, timeout, confirmation } = settings;\n\t\tconst first = firstIndexOfMonitor.get(id);\n\t\tif (first !== undefined) {\n\t\t\treport(`${base}.id`, `duplicate monitor ID (also used by monitors[${first}])`);\n\t\t\treturn;\n\t\t}\n\t\tfirstIndexOfMonitor.set(id, index);\n\n\t\tif (confirmation.recheckInterval > interval) {\n\t\t\treport(\n\t\t\t\t`${base}.confirmation.recheckInterval`,\n\t\t\t\t`must not be longer than interval (${formatDuration(interval)})`,\n\t\t\t);\n\t\t}\n\t\tif (timeout >= interval) {\n\t\t\treport(\n\t\t\t\t`${base}.timeout`,\n\t\t\t\trawSettings[\"timeout\"] === undefined\n\t\t\t\t\t? `the default timeout (${DEFAULT_TIMEOUT}) must be shorter than interval (${formatDuration(interval)}); set a shorter timeout`\n\t\t\t\t\t: `must be shorter than interval (${formatDuration(interval)})`,\n\t\t\t);\n\t\t}\n\t\t// Scheduling and the confirmation rule read the last few results: keep many intervals' worth.\n\t\tif (retention !== undefined && interval * MIN_INTERVALS_RETAINED > retention) {\n\t\t\treport(\n\t\t\t\t`${base}.interval`,\n\t\t\t\t`must be at most 1/${MIN_INTERVALS_RETAINED} of retention (${formatDuration(retention)}), so that retention keeps enough results`,\n\t\t\t);\n\t\t}\n\t\tfor (const runner of assigned) {\n\t\t\tif (runner.maxTimeoutMs !== undefined && timeout > runner.maxTimeoutMs) {\n\t\t\t\treport(\n\t\t\t\t\t`${base}.timeout`,\n\t\t\t\t\t`must not be longer than ${formatDuration(runner.maxTimeoutMs)}, the limit of runner \"${runner.id}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (options === undefined) return;\n\t\tfor (const name of secretNames(options)) {\n\t\t\tif (reservedSecrets.includes(name)) {\n\t\t\t\treport(base, `must not use secret(\"${name}\"): it is the hub's own secret and must never be sent to a monitored endpoint`);\n\t\t\t}\n\t\t}\n\n\t\tmonitors.push({\n\t\t\tid,\n\t\t\tname: settings.name ?? id,\n\t\t\tprovider,\n\t\t\toptions,\n\t\t\tsecrets: secretNames(options),\n\t\t\tintervalMs: interval,\n\t\t\ttimeoutMs: timeout,\n\t\t\tlocation: settings.location ?? location,\n\t\t\tconfirmation: {\n\t\t\t\tfailureThreshold: confirmation.failureThreshold,\n\t\t\t\tsuccessThreshold: confirmation.successThreshold,\n\t\t\t\trecheckIntervalMs: confirmation.recheckInterval,\n\t\t\t},\n\t\t\trunners: assigned.map((runner) => runner.id),\n\t\t});\n\t});\n\n\t// ---- Pages\n\tconst monitorNames = new Map(monitors.map((monitor) => [monitor.id, monitor.name]));\n\tconst firstIndexOfPage = new Map<string, number>();\n\tconst pages: ResolvedPage[] = [];\n\n\tpageEntries.forEach((entry, pageIndex) => {\n\t\tconst pageBase = `pages[${pageIndex}]`;\n\t\tconst page = parse(pageSchema, entry, pageBase);\n\t\tif (page !== undefined) {\n\t\t\tconst firstPage = firstIndexOfPage.get(page.id);\n\t\t\tif (firstPage === undefined) firstIndexOfPage.set(page.id, pageIndex);\n\t\t\telse report(`${pageBase}.id`, `duplicate page ID \"${page.id}\" (also used by pages[${firstPage}])`);\n\t\t}\n\t\t// Check components even when the page itself is invalid.\n\t\tconst componentEntries =\n\t\t\tpage?.components ??\n\t\t\t(isObject(entry) && Array.isArray(entry[\"components\"]) ? (entry[\"components\"] as unknown[]) : []);\n\n\t\t// Components and groups share one namespace of IDs: where each ID was first used.\n\t\tconst firstUseOfId = new Map<string, { readonly where: string; readonly group: boolean }>();\n\t\tconst components: ResolvedComponent[] = [];\n\t\tconst groups: ResolvedGroup[] = [];\n\t\tconst claimId = (id: string, path: string, where: string, group: boolean): boolean => {\n\t\t\tconst first = firstUseOfId.get(id);\n\t\t\tif (first === undefined) {\n\t\t\t\tfirstUseOfId.set(id, { where, group });\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\treport(\n\t\t\t\t`${path}.id`,\n\t\t\t\t!group && !first.group\n\t\t\t\t\t? `duplicate component ID \"${id}\" (also used by ${first.where})`\n\t\t\t\t\t: `duplicate ID \"${id}\" (also used by ${first.where}): components and groups need different IDs`,\n\t\t\t);\n\t\t\treturn false;\n\t\t};\n\n\t\tconst resolveComponent = (componentEntry: unknown, where: string): ResolvedComponent | undefined => {\n\t\t\tconst base = `${pageBase}.${where}`;\n\t\t\tif (isGroupEntry(componentEntry)) {\n\t\t\t\treport(base, \"groups cannot contain groups\");\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tconst parsed = parse(componentSchema, componentEntry, base);\n\t\t\tif (parsed === undefined) return undefined;\n\t\t\tconst { id, monitors: monitorIds } = parsed;\n\n\t\t\tmonitorIds.forEach((monitorId, monitorIndex) => {\n\t\t\t\tif (!declaredMonitorIds.has(monitorId)) {\n\t\t\t\t\treport(`${base}.monitors[${monitorIndex}]`, `unknown monitor \"${monitorId}\"`);\n\t\t\t\t} else if (monitorIds.indexOf(monitorId) !== monitorIndex) {\n\t\t\t\t\treport(`${base}.monitors[${monitorIndex}]`, `monitor \"${monitorId}\" is listed twice`);\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (parsed.latency && monitorIds.length === 0) {\n\t\t\t\treport(`${base}.latency`, \"needs at least one monitor: response times come from the component's monitors\");\n\t\t\t}\n\n\t\t\tconst only = monitorIds.length === 1 ? monitorIds[0] : undefined;\n\t\t\tconst name = parsed.name ?? (only === undefined ? undefined : (monitorNames.get(only) ?? only));\n\t\t\tif (name === undefined) {\n\t\t\t\treport(`${base}.name`, \"is required unless the component has exactly one monitor\");\n\t\t\t}\n\n\t\t\tif (!claimId(id, base, where, false)) return undefined;\n\t\t\treturn { id, name: name ?? id, monitors: monitorIds, latency: parsed.latency };\n\t\t};\n\n\t\tcomponentEntries.forEach((componentEntry, componentIndex) => {\n\t\t\tconst where = `components[${componentIndex}]`;\n\t\t\tif (!isGroupEntry(componentEntry)) {\n\t\t\t\tconst resolved = resolveComponent(componentEntry, where);\n\t\t\t\tif (resolved !== undefined) components.push(resolved);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst base = `${pageBase}.${where}`;\n\t\t\tconst group = parse(groupSchema, componentEntry, base);\n\t\t\t// Check its components even when the group itself is invalid.\n\t\t\tconst memberEntries =\n\t\t\t\tgroup?.components ??\n\t\t\t\t(isObject(componentEntry) && Array.isArray(componentEntry[\"components\"]) ? (componentEntry[\"components\"] as unknown[]) : []);\n\t\t\tconst claimed = group !== undefined && claimId(group.id, base, where, true);\n\t\t\tconst members: string[] = [];\n\t\t\tmemberEntries.forEach((memberEntry, memberIndex) => {\n\t\t\t\tconst resolved = resolveComponent(memberEntry, `${where}.components[${memberIndex}]`);\n\t\t\t\tif (resolved === undefined) return;\n\t\t\t\tcomponents.push(resolved);\n\t\t\t\tmembers.push(resolved.id);\n\t\t\t});\n\t\t\tif (group !== undefined && claimed && members.length > 0) {\n\t\t\t\tgroups.push({ id: group.id, name: group.name, components: members });\n\t\t\t}\n\t\t});\n\n\t\tif (page !== undefined) {\n\t\t\tpages.push({\n\t\t\t\tid: page.id,\n\t\t\t\ttemplate: page.template,\n\t\t\t\treportUrl: page.reportUrl ?? null,\n\t\t\t\tincidents: {\n\t\t\t\t\tauto: page.incidents.auto,\n\t\t\t\t\ttemplates: stripUndefined(page.incidents.templates),\n\t\t\t\t\treopenWithinMs: page.incidents.reopenWithin,\n\t\t\t\t},\n\t\t\t\tcomponents,\n\t\t\t\tgroups,\n\t\t\t});\n\t\t}\n\t});\n\n\tif (\n\t\tissues.length > 0 ||\n\t\ttimezone === undefined ||\n\t\tpublicApi === undefined ||\n\t\tlocale === undefined ||\n\t\tnotifications === undefined\n\t) {\n\t\tthrow new ConfigError(issues);\n\t}\n\n\treturn {\n\t\ttimezone,\n\t\tretentionMs: retention ?? null,\n\t\tauth,\n\t\tnotifiers,\n\t\tlocale,\n\t\tbaseUrl: baseUrl ?? null,\n\t\tnotifications: { unknownCheckIntervalMs: notifications.unknownCheckInterval },\n\t\tmonitors,\n\t\tpages,\n\t\tpublicApi: { cache: publicApi.cache, allowedOrigins: publicApi.allowedOrigins },\n\t\tadminHosts,\n\t};\n}\n","/**\n * States as the status page shows them: `unknown` derived at display time,\n * the precedence between states, and a component's state from its monitors and incidents.\n */\nimport type { CheckState } from \"./provider\";\nimport type { RecordedState } from \"./timeline\";\n\n/** A state as displayed: a confirmed state, or `unknown` when results are missing or late. */\nexport type DisplayState = CheckState | \"unknown\";\n\n/**\n * Severity for \"the worst state\": `down` > `degraded` > `unknown` > `up`. `unknown`\n * means results are missing, which is not necessarily an outage, so a known problem\n * (`degraded`) outranks it.\n */\nconst RANK: Readonly<Record<DisplayState, number>> = { up: 0, unknown: 1, degraded: 2, down: 3 };\n\nexport function isCheckState(state: string): state is CheckState {\n\treturn state === \"up\" || state === \"degraded\" || state === \"down\";\n}\n\n/** The worse of two states. */\nexport function worseOf(a: DisplayState, b: DisplayState): DisplayState {\n\treturn RANK[b] > RANK[a] ? b : a;\n}\n\n/** The worst of `states`, or `empty` when there are none. */\nexport function worstState(states: Iterable<DisplayState>, empty: DisplayState): DisplayState {\n\tlet worst: DisplayState | undefined;\n\tfor (const state of states) worst = worst === undefined ? state : worseOf(worst, state);\n\treturn worst ?? empty;\n}\n\n/**\n * Slack on top of the schedule before a monitor counts as late: the runner's and the Monitor\n * DO's grace periods after a check's timeout (10 seconds), alarms that fire late, and clock\n * differences between Durable Objects.\n */\nexport const LATE_GRACE_MS = 60_000;\n\n/**\n * How long a monitor may go without a check that produced a state before it is `unknown`: two intervals, plus the check's timeout and {@link LATE_GRACE_MS}.\n *\n * A check's result is recorded when the check ends, up to its timeout (plus grace) after the\n * slot it ran for. Two intervals tolerate one missed result (a transient runner error, a\n * check that produced no result) without flapping to `unknown`; the second missed result in\n * a row makes the monitor `unknown`, before the third slot is due. With a 1-minute interval\n * and a 10-second timeout that is 3 minutes 10 seconds.\n *\n * The status page uses this for the live state and for every past moment of the history,\n * and the every-minute Cron uses it to notify `unknown`, so the three agree.\n */\nexport function staleAfterMs(intervalMs: number, timeoutMs: number): number {\n\treturn 2 * intervalMs + timeoutMs + LATE_GRACE_MS;\n}\n\n/** What {@link displayState} needs from a monitor. A Monitor DO's snapshot has this shape. */\nexport interface MonitorReading {\n\t/** The latest record of the state history; `null` before any. */\n\treadonly current: { readonly state: RecordedState } | null;\n\t/** The current schedule period; `null` before the monitor first started. */\n\treadonly period: { readonly from: number; readonly status: \"active\" | \"stopped\"; readonly intervalMs: number | null } | null;\n\t/** Start of the latest recent check that produced a state; `null` when none did. */\n\treadonly lastResultAt: number | null;\n}\n\nexport interface DisplayStateResult {\n\treadonly state: DisplayState;\n\t/**\n\t * Why the state is `unknown`, `null` otherwise:\n\t * - `stopped`: the monitor is not running (it left the configuration, or has not started);\n\t * - `late`: no result for longer than {@link staleAfterMs}, whether or not a state was\n\t * confirmed (a new monitor whose checks never produce a result is late too);\n\t * - `unconfirmed`: results arrive, but no state is confirmed yet (new, or resumed after a stop).\n\t *\n\t * The every-minute Cron notifies administrators of `late`.\n\t */\n\treadonly unknownReason: \"unconfirmed\" | \"stopped\" | \"late\" | null;\n}\n\n/**\n * A monitor's state at display time: its confirmed state, unless its latest result\n * is late for its schedule or it has no confirmed state (including `unconfirmed` after\n * resuming). Lateness counts from the later of the latest result and the start of the\n * current schedule period, so a new interval gets a fresh allowance, and it is checked\n * before the confirmed state, so that a monitor that never produces a result is `late`.\n */\nexport function displayState(reading: MonitorReading, timeoutMs: number, now: number): DisplayStateResult {\n\tconst { current, period } = reading;\n\tif (period === null || period.status !== \"active\" || period.intervalMs === null || current?.state === \"stopped\") {\n\t\treturn { state: \"unknown\", unknownReason: \"stopped\" };\n\t}\n\tconst anchor = Math.max(reading.lastResultAt ?? Number.NEGATIVE_INFINITY, period.from);\n\tif (now - anchor > staleAfterMs(period.intervalMs, timeoutMs)) return { state: \"unknown\", unknownReason: \"late\" };\n\tif (current === null || !isCheckState(current.state)) return { state: \"unknown\", unknownReason: \"unconfirmed\" };\n\treturn { state: current.state, unknownReason: null };\n}\n\n/** Impact of an open incident on a component. `none` lists it without changing its state. */\nexport type IncidentImpact = \"none\" | \"degraded\" | \"down\";\n\n/**\n * A component's current state: the worst of its monitors' display states and the\n * impacts of the unresolved incidents that affect it, so that a person's judgement can\n * override the automatic one. A component without monitors takes its state from incidents\n * alone, and is `up` without any. Maintenance is not a state: it is shown next to it.\n */\nexport function componentState(\n\tmonitorStates: Iterable<DisplayState>,\n\topenIncidentImpacts: Iterable<IncidentImpact>,\n): DisplayState {\n\tconst states: DisplayState[] = [...monitorStates];\n\tfor (const impact of openIncidentImpacts) {\n\t\tif (impact !== \"none\") states.push(impact);\n\t}\n\treturn worstState(states, \"up\");\n}\n","/**\n * Timelines of states for history and uptime: what a monitor's confirmed states,\n * schedule and results say about each moment, combined per component. Pure functions, so\n * that the Worker, the status pages and tests share one definition.\n */\nimport { type DisplayState, isCheckState, worseOf } from \"./display\";\nimport type { CheckState } from \"./provider\";\n\n/** A half-open time range `[from, to)` in milliseconds since the epoch. */\nexport interface TimeRange {\n\treadonly from: number;\n\treadonly to: number;\n}\n\n/**\n * A stretch of time with one schedule. A monitor's periods are contiguous: each one ends\n * where the next begins. A new period starts only when something changes (the monitor\n * starts, its interval changes, it leaves or returns to the configuration).\n */\nexport interface SchedulePeriod {\n\t/** Start, inclusive. */\n\treadonly from: number;\n\t/** End, exclusive; `null` for the current period. */\n\treadonly to: number | null;\n\t/**\n\t * `active`: scheduled checks every `intervalMs`, from `from` (the grid's anchor).\n\t * `stopped`: the monitor was not in the configuration. A stopped period is neither\n\t * uptime nor downtime, and its slots are not missed checks.\n\t */\n\treadonly status: \"active\" | \"stopped\";\n\t/** `null` when stopped. */\n\treadonly intervalMs: number | null;\n}\n\n/**\n * A state in a monitor's history: a confirmed state; `stopped` while the monitor was not in\n * the configuration; `unconfirmed` from when it resumed until a state is confirmed again. At\n * display time, `unconfirmed` (like no record at all) is `unknown`; neither `stopped` nor\n * `unconfirmed` counts as uptime or downtime.\n */\nexport type RecordedState = CheckState | \"stopped\" | \"unconfirmed\";\n\n/** One record of the state history. Each record lasts until the next one's `since`. */\nexport interface StateRecord {\n\treadonly state: RecordedState;\n\t/** When it began. For a confirmed state, when the run of results that confirmed it began. */\n\treadonly since: number;\n\t/** When it was recorded: for a confirmed state, the time of the result that confirmed it. */\n\treadonly confirmedAt: number;\n}\n\n/** A stretch of time in one display state. Lists of segments are sorted and never overlap. */\nexport interface Segment extends TimeRange {\n\treadonly state: DisplayState;\n}\n\n/** What a monitor's storage says about a time range. */\nexport interface TimelineSource {\n\t/** Schedule periods that overlap the range, oldest first. */\n\treadonly periods: readonly SchedulePeriod[];\n\t/** The state record in effect at the start of the range. */\n\treadonly atStart: StateRecord | null;\n\t/** State records that begin inside the range, oldest first. */\n\treadonly changes: readonly StateRecord[];\n\t/**\n\t * Start times of the checks that produced a state, ascending: at least those from\n\t * `staleAfter(interval)` before the range up to its end, so that lateness at the start of\n\t * the range is judged from the results before it.\n\t */\n\treadonly resultTimes: readonly number[];\n}\n\n/** Index of the first value `>= target` in a sorted array. */\nfunction lowerBound(values: readonly number[], target: number): number {\n\tlet low = 0;\n\tlet high = values.length;\n\twhile (low < high) {\n\t\tconst middle = (low + high) >>> 1;\n\t\tif ((values[middle] as number) < target) low = middle + 1;\n\t\telse high = middle;\n\t}\n\treturn low;\n}\n\n/** Appends a segment, merging it into the previous one when they touch and have the same state. */\nfunction append(segments: Segment[], from: number, to: number, state: DisplayState): void {\n\tif (to <= from) return;\n\tconst last = segments.at(-1);\n\tif (last !== undefined && last.to === from && last.state === state) {\n\t\tsegments[segments.length - 1] = { from: last.from, to, state };\n\t} else {\n\t\tsegments.push({ from, to, state });\n\t}\n}\n\n/** `a` followed by `b` (which starts where `a` ends, or later), merging at the seam. */\nexport function concatSegments(a: readonly Segment[], b: readonly Segment[]): Segment[] {\n\tconst result = [...a];\n\tfor (const segment of b) append(result, segment.from, segment.to, segment.state);\n\treturn result;\n}\n\n/**\n * Where a monitor is late inside one active schedule period and `range`: from\n * `staleAfterMs` after the latest anchor until the next one, where an anchor is the start of\n * the period or a check that produced a state. This is the display-time rule (see\n * `displayState`) applied to every past moment, so the history shows `unknown` exactly when\n * the live page did.\n *\n * Results from before the range are needed to judge its start: with none in the\n * `staleAfterMs` before it, the monitor is late from the range's start on.\n */\nexport function lateSpans(\n\tperiod: Pick<SchedulePeriod, \"from\" | \"to\">,\n\trange: TimeRange,\n\tresultTimes: readonly number[],\n\tstaleAfterMs: number,\n): TimeRange[] {\n\tconst low = Math.max(period.from, range.from);\n\tconst high = Math.min(period.to ?? Number.POSITIVE_INFINITY, range.to);\n\tif (low >= high) return [];\n\tconst spans: TimeRange[] = [];\n\tconst push = (from: number, to: number) => {\n\t\tconst clippedFrom = Math.max(from, low);\n\t\tconst clippedTo = Math.min(to, high);\n\t\tif (clippedFrom < clippedTo) spans.push({ from: clippedFrom, to: clippedTo });\n\t};\n\t// The latest anchor at or before `range.from - staleAfterMs` is at least that early, so\n\t// starting from there judges the range's start correctly whatever came before.\n\tlet anchor = Math.max(period.from, range.from - staleAfterMs);\n\tfor (let index = lowerBound(resultTimes, anchor); index < resultTimes.length; index++) {\n\t\tconst at = resultTimes[index] as number;\n\t\tif (at >= high) break;\n\t\tif (at - anchor > staleAfterMs) push(anchor + staleAfterMs, at);\n\t\tanchor = at;\n\t}\n\tif (high - anchor > staleAfterMs) push(anchor + staleAfterMs, high);\n\treturn spans;\n}\n\n/**\n * The display state of a monitor at every moment of `range`:\n *\n * - outside active schedule periods (before it started, or `stopped`): no segment, which is\n * neither uptime nor downtime;\n * - while late (see {@link lateSpans}): `unknown`;\n * - otherwise the confirmed state in effect, or `unknown` before any is confirmed and while\n * `unconfirmed` after resuming.\n *\n * `staleAfter` gives the lateness threshold for a period's interval (see `staleAfterMs`).\n */\nexport function monitorTimeline(\n\trange: TimeRange,\n\tsource: TimelineSource,\n\tstaleAfter: (intervalMs: number) => number,\n): Segment[] {\n\tconst active: TimeRange[] = [];\n\tconst late: TimeRange[] = [];\n\tfor (const period of source.periods) {\n\t\tif (period.status !== \"active\" || period.intervalMs === null) continue;\n\t\tconst from = Math.max(range.from, period.from);\n\t\tconst to = Math.min(range.to, period.to ?? Number.POSITIVE_INFINITY);\n\t\tif (from >= to) continue;\n\t\tactive.push({ from, to });\n\t\tlate.push(...lateSpans(period, range, source.resultTimes, staleAfter(period.intervalMs)));\n\t}\n\tif (active.length === 0) return [];\n\n\tconst records = [...(source.atStart === null ? [] : [source.atStart]), ...source.changes];\n\tconst points = new Set<number>();\n\tfor (const list of [active, late]) {\n\t\tfor (const part of list) {\n\t\t\tpoints.add(part.from);\n\t\t\tpoints.add(part.to);\n\t\t}\n\t}\n\tfor (const record of records) {\n\t\tif (record.since > range.from && record.since < range.to) points.add(record.since);\n\t}\n\tconst sorted = [...points].sort((a, b) => a - b);\n\n\tconst segments: Segment[] = [];\n\tlet activeIndex = 0;\n\tlet lateIndex = 0;\n\tlet recordIndex = -1;\n\tfor (let index = 0; index + 1 < sorted.length; index++) {\n\t\tconst from = sorted[index] as number;\n\t\tconst to = sorted[index + 1] as number;\n\t\twhile (activeIndex < active.length && (active[activeIndex] as TimeRange).to <= from) activeIndex++;\n\t\tconst part = active[activeIndex];\n\t\tif (part === undefined || part.from > from) continue;\n\t\twhile (lateIndex < late.length && (late[lateIndex] as TimeRange).to <= from) lateIndex++;\n\t\tconst span = late[lateIndex];\n\t\tif (span !== undefined && span.from <= from) {\n\t\t\tappend(segments, from, to, \"unknown\");\n\t\t\tcontinue;\n\t\t}\n\t\twhile (recordIndex + 1 < records.length && (records[recordIndex + 1] as StateRecord).since <= from) recordIndex++;\n\t\tconst state = records[recordIndex]?.state;\n\t\tappend(segments, from, to, state !== undefined && isCheckState(state) ? state : \"unknown\");\n\t}\n\treturn segments;\n}\n\n/**\n * A component's timeline from its monitors': at each moment, the worst state of\n * the monitors that have data then (`down` > `degraded` > `unknown` > `up`). Moments where\n * none of them has data have no segment.\n */\nexport function combineTimelines(timelines: readonly (readonly Segment[])[]): Segment[] {\n\tif (timelines.length === 1) return [...(timelines[0] as readonly Segment[])];\n\tconst points = new Set<number>();\n\tfor (const timeline of timelines) {\n\t\tfor (const segment of timeline) {\n\t\t\tpoints.add(segment.from);\n\t\t\tpoints.add(segment.to);\n\t\t}\n\t}\n\tconst sorted = [...points].sort((a, b) => a - b);\n\tconst cursors = timelines.map(() => 0);\n\tconst result: Segment[] = [];\n\tfor (let index = 0; index + 1 < sorted.length; index++) {\n\t\tconst from = sorted[index] as number;\n\t\tconst to = sorted[index + 1] as number;\n\t\tlet worst: DisplayState | undefined;\n\t\ttimelines.forEach((timeline, which) => {\n\t\t\tlet cursor = cursors[which] as number;\n\t\t\twhile (cursor < timeline.length && (timeline[cursor] as Segment).to <= from) cursor++;\n\t\t\tcursors[which] = cursor;\n\t\t\tconst segment = timeline[cursor];\n\t\t\tif (segment !== undefined && segment.from <= from) {\n\t\t\t\tworst = worst === undefined ? segment.state : worseOf(worst, segment.state);\n\t\t\t}\n\t\t});\n\t\tif (worst !== undefined) append(result, from, to, worst);\n\t}\n\treturn result;\n}\n\n/** Sorted, non-overlapping ranges covering the same time as `ranges`. */\nexport function mergeRanges(ranges: readonly TimeRange[]): TimeRange[] {\n\tconst sorted = ranges.filter((range) => range.from < range.to).sort((a, b) => a.from - b.from);\n\tconst merged: TimeRange[] = [];\n\tfor (const range of sorted) {\n\t\tconst last = merged.at(-1);\n\t\tif (last !== undefined && range.from <= last.to) {\n\t\t\tmerged[merged.length - 1] = { from: last.from, to: Math.max(last.to, range.to) };\n\t\t} else {\n\t\t\tmerged.push(range);\n\t\t}\n\t}\n\treturn merged;\n}\n\n/** `segments` without the time inside `windows` (maintenance: excluded from uptime). */\nexport function excludeWindows(segments: readonly Segment[], windows: readonly TimeRange[]): Segment[] {\n\tconst cuts = mergeRanges(windows);\n\tif (cuts.length === 0) return [...segments];\n\tconst result: Segment[] = [];\n\tfor (const segment of segments) {\n\t\tlet from = segment.from;\n\t\tfor (const cut of cuts) {\n\t\t\tif (cut.to <= from) continue;\n\t\t\tif (cut.from >= segment.to) break;\n\t\t\tif (cut.from > from) result.push({ from, to: cut.from, state: segment.state });\n\t\t\tfrom = Math.max(from, cut.to);\n\t\t\tif (from >= segment.to) break;\n\t\t}\n\t\tif (from < segment.to) result.push({ from, to: segment.to, state: segment.state });\n\t}\n\treturn result;\n}\n\nexport interface TimelineSummary {\n\t/** Time in `up` or `degraded`: `degraded` counts as uptime. */\n\treadonly upMs: number;\n\t/** Time in `down`, the only state that counts as an outage. */\n\treadonly downMs: number;\n\t/** Time in `degraded`, part of `upMs`. */\n\treadonly degradedMs: number;\n\t/** Time in `unknown`, excluded from uptime. */\n\treadonly unknownMs: number;\n\t/** The worst confirmed state (`down` > `degraded` > `up`), or `null` when there is none. */\n\treadonly worst: CheckState | null;\n}\n\nconst CONFIRMED_RANK: Readonly<Record<CheckState, number>> = { up: 0, degraded: 1, down: 2 };\n\nexport function summarize(segments: readonly Segment[]): TimelineSummary {\n\tlet upMs = 0;\n\tlet downMs = 0;\n\tlet degradedMs = 0;\n\tlet unknownMs = 0;\n\tlet worst: CheckState | null = null;\n\tfor (const segment of segments) {\n\t\tconst length = segment.to - segment.from;\n\t\tif (segment.state === \"unknown\") {\n\t\t\tunknownMs += length;\n\t\t\tcontinue;\n\t\t}\n\t\tif (segment.state === \"down\") downMs += length;\n\t\telse upMs += length;\n\t\tif (segment.state === \"degraded\") degradedMs += length;\n\t\tif (worst === null || CONFIRMED_RANK[segment.state] > CONFIRMED_RANK[worst]) worst = segment.state;\n\t}\n\treturn { upMs, downMs, degradedMs, unknownMs, worst };\n}\n\n/**\n * Uptime as a ratio: time `up` or `degraded` over time with a confirmed state. `null`\n * when no time had a confirmed state (everything unknown, stopped or under maintenance).\n */\nexport function uptimeRatio(upMs: number, downMs: number): number | null {\n\tconst known = upMs + downMs;\n\treturn known > 0 ? upMs / known : null;\n}\n\n/**\n * Coverage: scheduled checks that produced a state over the checks the schedule\n * expected. At most 1 (a check near a range boundary can land in the next range). `null`\n * when nothing was expected.\n */\nexport function coverageRatio(obtained: number, expected: number): number | null {\n\treturn expected > 0 ? Math.min(1, obtained / expected) : null;\n}\n\n/** A stretch of confirmed `down`. `to` is `null` while it lasts. */\nexport interface DownPeriod {\n\treadonly from: number;\n\treadonly to: number | null;\n}\n\n/**\n * The confirmed `down` periods in a state history (records oldest first): each lasts from its\n * record's `since` until the next record, whatever that is (recovery, `degraded`, a stop).\n */\nexport function downPeriods(records: readonly StateRecord[]): DownPeriod[] {\n\tconst periods: DownPeriod[] = [];\n\trecords.forEach((record, index) => {\n\t\tif (record.state !== \"down\") return;\n\t\tconst next = records[index + 1];\n\t\tconst last = periods.at(-1);\n\t\t// Two `down` records in a row (not written today, but harmless) make one period.\n\t\tif (last !== undefined && last.to === record.since) {\n\t\t\tperiods[periods.length - 1] = { from: last.from, to: next?.since ?? null };\n\t\t} else {\n\t\t\tperiods.push({ from: record.since, to: next?.since ?? null });\n\t\t}\n\t});\n\treturn periods;\n}\n\n/** The union of `periods` (from several monitors), oldest first; an open period absorbs what follows it. */\nexport function mergeDownPeriods(periods: readonly DownPeriod[]): DownPeriod[] {\n\tconst sorted = [...periods].sort((a, b) => a.from - b.from);\n\tconst merged: DownPeriod[] = [];\n\tfor (const period of sorted) {\n\t\tconst last = merged.at(-1);\n\t\tif (last !== undefined && (last.to === null || period.from <= last.to)) {\n\t\t\tconst to = last.to === null || period.to === null ? null : Math.max(last.to, period.to);\n\t\t\tmerged[merged.length - 1] = { from: last.from, to };\n\t\t} else {\n\t\t\tmerged.push(period);\n\t\t}\n\t}\n\treturn merged;\n}\n"],"mappings":";;;;;AAaA,IAAM,6BAAa,IAAI,IAAiC;AAExD,SAAS,UAAU,UAAuC;CACzD,IAAI,QAAQ,WAAW,IAAI,QAAQ;CACnC,IAAI,UAAU,KAAA,GAAW;EACxB,QAAQ,IAAI,KAAK,eAAe,SAAS;GACxC;GACA,WAAW;GACX,MAAM;GACN,OAAO;GACP,KAAK;GACL,MAAM;GACN,QAAQ;GACR,QAAQ;EACT,CAAC;EACD,WAAW,IAAI,UAAU,KAAK;CAC/B;CACA,OAAO;AACR;AAWA,SAAS,UAAU,IAAY,UAA6B;CAC3D,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,QAAQ,UAAU,QAAQ,CAAC,CAAC,cAAc,EAAE,GACtD,IAAI,KAAK,SAAS,WAAW,MAAM,KAAK,QAAQ,OAAO,KAAK,KAAK;CAElE,OAAO;EACN,MAAM,MAAM,WAAW;EACvB,OAAO,MAAM,YAAY;EACzB,KAAK,MAAM,UAAU;EACrB,MAAM,MAAM,WAAW;EACvB,QAAQ,MAAM,aAAa;EAC3B,QAAQ,MAAM,aAAa;CAC5B;AACD;AAEA,SAAS,IAAI,OAAe,SAAS,GAAW;CAC/C,OAAO,OAAO,KAAK,CAAC,CAAC,SAAS,QAAQ,GAAG;AAC1C;AAEA,SAAS,WAAW,MAAc,OAAe,KAAqB;CACrE,OAAO,GAAG,IAAI,MAAM,CAAC,EAAE,GAAG,IAAI,KAAK,EAAE,GAAG,IAAI,GAAG;AAChD;AAEA,SAAS,UAAU,MAAwC;CAC1D,MAAM,QAAQ,4BAA4B,KAAK,IAAI;CACnD,IAAI,UAAU,MAAM,MAA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1B,IAAI,SAAS,KAAA,KAAa,KAAK,OAAO,OAAO,OAC5C,QAAQ,QAAQ,SAAS,KAAK;GAAE,MAAM,KAAK;GAAM,IAAI,MAAM,SAAS;EAAK;OAEzE,QAAQ,KAAK;GAAE,MAAM,OAAO;GAAO,IAAI,MAAM,SAAS;EAAK,CAAC;CAE9D,CAAC;CACD,OAAO;AACR;;AAGA,SAAgB,iBAAiB,SAA8C;CAC9E,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,IAAI;CAC1D,MAAM,SAAuB,CAAC;CAC9B,KAAK,MAAM,UAAU,QAAQ;EAC5B,MAAM,OAAO,OAAO,GAAG,EAAE;EACzB,IAAI,SAAS,KAAA,MAAc,KAAK,OAAO,QAAQ,OAAO,QAAQ,KAAK,KAAK;GACvE,MAAM,KAAK,KAAK,OAAO,QAAQ,OAAO,OAAO,OAAO,OAAO,KAAK,IAAI,KAAK,IAAI,OAAO,EAAE;GACtF,OAAO,OAAO,SAAS,KAAK;IAAE,MAAM,KAAK;IAAM;GAAG;EACnD,OACC,OAAO,KAAK,MAAM;CAEpB;CACA,OAAO;AACR"}
@@ -0,0 +1,10 @@
1
+ # Headers of the static assets (https://developers.cloudflare.com/workers/static-assets/headers/):
2
+ # the public status page, its scripts and styles, and the admin UI's scripts and styles.
3
+ # Applied at build, preview and deploy time, not under the Vite dev server (whose page has
4
+ # inline scripts). Responses of the Worker (the APIs, and the admin UI's HTML) set their own
5
+ # in worker/. The page loads its own scripts and styles only, calls its own API only, and may
6
+ # show a logo from another site over https (an administrator's `logoUrl`).
7
+ /*
8
+ Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' https: data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'
9
+ X-Content-Type-Options: nosniff
10
+ Referrer-Policy: strict-origin-when-cross-origin
@@ -0,0 +1 @@
1
+ import{A as e,C as t,D as n,E as r,F as i,I as a,L as o,M as s,N as c,O as l,P as u,T as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,j as x,k as S,l as ee,m as C,n as w,o as T,p as E,t as te,u as ne,v as re,w as ie,x as ae,y as oe}from"./src-BDi4qpij.js";function se(e){return e===`up`||e===`degraded`||e===`down`}var ce=6e4;function le(e,t){return 2*e+t+ce}function ue(e,t,n){let{current:r,period:i}=e;return i===null||i.status!==`active`||i.intervalMs===null||r?.state===`stopped`?{state:`unknown`,unknownReason:`stopped`}:n-Math.max(e.lastResultAt??-1/0,i.from)>le(i.intervalMs,t)?{state:`unknown`,unknownReason:`late`}:r===null||!se(r.state)?{state:`unknown`,unknownReason:`unconfirmed`}:{state:r.state,unknownReason:null}}var de=[`down`,`recovered`,`degraded`,`degraded_recovered`,`unknown`],D=o(),fe={"admin.title":`Status admin`,"admin.signedInAs":`Signed in as {name}`,"admin.viewStatusPage":`View status page`,"admin.nav.label":`Sections`,"admin.nav.incidents":`Incidents`,"admin.nav.maintenance":`Maintenance`,"admin.nav.monitors":`Monitors`,"admin.nav.appearance":`Appearance`,"admin.nav.notifications":`Notifications`,"admin.nav.deliveries":`Failed deliveries`,"admin.notFound.title":`Not found`,"admin.notFound.detail":`There is no such view in the admin UI.`,"admin.page.label":`Page`,"admin.page.removed":`{page} (no longer in status.config.ts)`,"admin.page.notConfigured":`Page “{page}” is not in status.config.ts.`,"admin.action.cancel":`Cancel`,"admin.action.delete":`Delete…`,"admin.action.deleteConfirm":`Delete`,"admin.action.refresh":`Refresh`,"admin.action.retry":`Try again`,"admin.action.reloadPage":`Reload the page`,"admin.list.more":`Load more`,"admin.common.automation":`automation`,"admin.common.byAt":`{who}, {time}`,"admin.common.lastChange":`Last changed by {who}, {time}.`,"admin.common.yes":`yes`,"admin.common.no":`no`,"admin.time.zone":`In your time zone: {timeZone} ({offset}).`,"admin.form.save":`Save`,"admin.form.saved":`Saved.`,"admin.form.unsaved":`Unsaved changes`,"admin.form.optional":`(optional)`,"admin.form.none":`(none)`,"admin.error.network":`The server could not be reached. Check your connection and try again.`,"admin.error.signedOut":`Your sign-in has expired. Reload the page to sign in again; unsaved changes on this page will be lost.`,"admin.error.forbidden":`You are not signed in as an administrator. Reload the page to sign in.`,"admin.error.notFound":`It no longer exists: someone may have deleted it.`,"admin.error.validation":`Some fields need correcting; see the messages next to them.`,"admin.error.encryptionKey":`Secret options cannot be saved: the encryption key is not set. {message}`,"admin.error.server":`The server refused the request ({status}): {message}`,"admin.error.unexpected":`Something went wrong: {message}`,"admin.conflict.title":`Someone else saved a change after you started editing. Nothing was saved.`,"admin.conflict.savedBy":`Saved by {who}, {time}.`,"admin.conflict.theyChanged":`They changed:`,"admin.conflict.noFieldChanges":`None of the fields shown here changed.`,"admin.conflict.alsoYours":`you changed it too`,"admin.conflict.takeCurrent":`Use their version`,"admin.conflict.reapply":`Keep my changes`,"admin.conflict.reapplyHint":`“Use their version” discards your changes. “Keep my changes” puts your changes on top of theirs; review the form, then save again.`,"admin.incidents.title":`Incidents`,"admin.incidents.new":`New incident`,"admin.incidents.filter":`Show`,"admin.incidents.status.all":`All`,"admin.incidents.status.open":`Unresolved`,"admin.incidents.status.resolved":`Resolved`,"admin.incidents.none":`No incidents.`,"admin.incidents.auto":`Automatic`,"admin.incidents.started":`Started`,"admin.incidents.updated":`Updated`,"admin.incidents.resolved":`Resolved`,"admin.incident.title":`Title`,"admin.incident.components":`Affected components`,"admin.incident.componentsHint":`While the incident is unresolved, the page shows each component as the worse of its monitors and this impact. “No impact” lists it without changing its state.`,"admin.incident.noComponents":`This page has no components.`,"admin.incident.noneAffected":`none`,"admin.incident.unknownComponents":`Also listed, but no longer in status.config.ts: {ids}. Saving the components removes them.`,"admin.incident.startedAt":`Started at (optional)`,"admin.incident.startedAtHint":`When the problem began, if earlier than now; leave empty for now. Not in the future. In your time zone: {timeZone} ({offset}).`,"admin.incident.stage":`Stage`,"admin.incident.stageHint":`Investigating → Identified → Monitoring → Resolved. “Resolved” closes the incident.`,"admin.incident.firstUpdate":`First update`,"admin.incident.message":`Message`,"admin.incident.bodyHint":`Shown on the public status page as written (plain text, in the page's language).`,"admin.incident.publish":`Publish incident`,"admin.incident.prefilled":`Pre-filled from a notification: check the components and their impact.`,"admin.incident.created":`The incident is published.`,"admin.incident.viewPublic":`View on the status page`,"admin.incident.createdBy":`Created`,"admin.incident.timeline":`Timeline`,"admin.incident.editTitle":`Title and components`,"admin.incident.postTitle":`Post an update`,"admin.incident.reopenHint":`This incident is resolved. Posting a stage other than “Resolved” reopens it.`,"admin.incident.alsoComponents":`Also change the affected components`,"admin.incident.post":`Post update`,"admin.incident.resolve":`Resolve incident`,"admin.incident.posted":`The update is published.`,"admin.incident.deleteTitle":`Delete this incident`,"admin.incident.deleteHint":`Deleting removes the incident and its timeline from the status page and its history. To close it, resolve it instead.`,"admin.incident.deleteQuestion":`Delete “{title}” and its whole timeline? This cannot be undone.`,"admin.impact.unaffected":`Not affected`,"admin.maintenance.title":`Maintenance`,"admin.maintenance.new":`Schedule maintenance`,"admin.maintenance.intro":`During maintenance, the page marks its components, uptime leaves the time out, and their monitors' notifications are held back.`,"admin.maintenance.none":`No maintenance scheduled.`,"admin.maintenance.phase.upcoming":`Scheduled`,"admin.maintenance.phase.active":`In progress`,"admin.maintenance.phase.ended":`Ended`,"admin.maintenance.fieldTitle":`Title`,"admin.maintenance.startsAt":`Starts`,"admin.maintenance.endsAt":`Ends`,"admin.maintenance.components":`Components under maintenance`,"admin.maintenance.componentsHint":`At least one.`,"admin.maintenance.body":`Details (optional)`,"admin.maintenance.bodyHint":`Shown on the public status page as written.`,"admin.maintenance.forPage":`Page: {page}.`,"admin.maintenance.create":`Schedule`,"admin.maintenance.deleteTitle":`Delete this maintenance`,"admin.maintenance.deleteQuestion":`Delete “{title}”? It disappears from the status page, and its time counts towards uptime again.`,"admin.monitors.title":`Monitors`,"admin.monitors.intro":`Monitors are defined in status.config.ts and change with a deploy. Here you see their current state.`,"admin.monitors.none":`No monitors are configured.`,"admin.monitors.noSnapshot":`Its state could not be read.`,"admin.monitors.snapshotError":`Could not read its state: {error}`,"admin.monitors.since":`since {time}`,"admin.monitors.unknown.unconfirmed":`No state confirmed yet`,"admin.monitors.unknown.stopped":`Not running`,"admin.monitors.unknown.late":`Results are late`,"admin.monitors.lastCheck":`Last check {time}: {result}`,"admin.monitors.noResult":`no result`,"admin.monitors.latency":`{ms} ms`,"admin.monitors.components":`Shown by {components}`,"admin.monitors.type":`Type`,"admin.monitors.interval":`Interval`,"admin.monitors.location":`Location`,"admin.monitors.locationAuto":`chosen by Cloudflare`,"admin.monitors.removedTitle":`Removed monitors`,"admin.monitors.removedIntro":`Monitors that left status.config.ts stop checking but keep their history, in case they come back. Delete their data once you are sure.`,"admin.monitors.removedNone":`None: every monitor with data is in status.config.ts.`,"admin.monitors.removedAt":`Removed`,"admin.monitors.purge":`Delete data…`,"admin.monitors.purgeQuestion":`Delete every result and the whole state history of “{id}”? This cannot be undone.`,"admin.monitors.purgeConfirm":`Delete the data`,"admin.monitors.purged":`The data of “{id}” is deleted.`,"admin.monitors.purgeRefused":`Not deleted: {reason}`,"admin.appearance.title":`Appearance`,"admin.appearance.intro":`What visitors see at the top of the status page, in the page's one language.`,"admin.appearance.fieldTitle":`Title`,"admin.appearance.titleHint":`Heading and browser tab title. Empty: the page ID ({page}).`,"admin.appearance.description":`Description`,"admin.appearance.descriptionHint":`A line under the heading. Empty: none.`,"admin.appearance.logoUrl":`Logo URL`,"admin.appearance.logoHint":`An https image, shown instead of the title text (which stays its alternative text). An uploaded logo image is shown instead. Empty: none.`,"admin.appearance.websiteUrl":`Website URL`,"admin.appearance.websiteHint":`Where the heading links to, such as your organisation's website. Empty: the status page itself.`,"admin.appearance.default":`(default)`,"admin.appearance.logoImage":`Logo image`,"admin.appearance.logoImageHint":`PNG, JPEG, GIF, WebP or ICO, up to {size} KB. Shown instead of the title text, and before the logo URL.`,"admin.appearance.favicon":`Favicon`,"admin.appearance.faviconHint":`The icon of browser tabs and bookmarks. A square PNG or ICO of 32×32 pixels or more works best. Up to {size} KB.`,"admin.appearance.currentImage":`Current {label}`,"admin.appearance.removeImage":`Remove image`,"admin.appearance.uploading":`Uploading…`,"admin.appearance.uploadsUnavailable":`Images cannot be uploaded: the Worker has no R2 bucket for them (the UPLOADS binding).`,"admin.appearance.imageType":`Choose a PNG, JPEG, GIF, WebP or ICO image.`,"admin.appearance.imageTooLarge":`Choose an image of {size} KB or less.`,"admin.appearance.imageInvalid":`The file could not be read as an image: it is damaged, or its format is not what its name says.`,"admin.appearance.colors":`Colours`,"admin.appearance.colorsHint":`Set for light and dark mode separately. Default: the template's colour.`,"admin.appearance.scheme.light":`Light`,"admin.appearance.scheme.dark":`Dark`,"admin.appearance.role.background":`Background`,"admin.appearance.role.header":`Header`,"admin.appearance.role.accent":`Accent`,"admin.appearance.roleHint.background":`Behind the page.`,"admin.appearance.roleHint.header":`The bar at the top. Its text turns white or black to stay readable.`,"admin.appearance.roleHint.accent":`Links and focus outlines.`,"admin.appearance.headerModernOnly":`This page uses the default template, which has no header bar: the header colour applies only if it switches to the modern template.`,"admin.appearance.colorDefault":`Default`,"admin.appearance.resetColor":`Reset`,"admin.appearance.resetColorOf":`Reset {color} to the default`,"admin.appearance.resetColors":`Reset all colours to the defaults`,"admin.appearance.preview":`Preview ({scheme})`,"admin.appearance.previewText":`All systems operational.`,"admin.appearance.previewLink":`Past incidents`,"admin.appearance.contrastBackground":`{scheme}: text on this background has a contrast of {ratio}:1. At least 4.5:1 reads well.`,"admin.appearance.contrastAccent":`{scheme}: links have a contrast of {ratio}:1 with what they sit on. At least 4.5:1 reads well.`,"admin.event.down":`Down`,"admin.event.recovered":`Recovered`,"admin.event.degraded":`Degraded`,"admin.event.degraded_recovered":`No longer degraded`,"admin.event.unknown":`Results stopped (unknown)`,"admin.targets.title":`Notification targets`,"admin.targets.new":`New target`,"admin.targets.intro":`Where notifications go: which service, for which monitors and events.`,"admin.targets.none":`No targets yet.`,"admin.targets.noKinds":"status.config.ts registers no notifier kinds (`notifiers`).","admin.targets.noKey":`The encryption key (NOTIFICATION_KEYS) is not set, so targets with secret options cannot be saved. {error}`,"admin.targets.noKeyForm":`The encryption key (NOTIFICATION_KEYS) is not set: saving secret options will fail until it is.`,"admin.targets.adminBadge":`Administrators`,"admin.targets.enabled":`Enabled`,"admin.targets.disabled":`Disabled`,"admin.targets.enable":`Enable`,"admin.targets.disable":`Disable`,"admin.targets.toggleConflict":`{who} changed this target meanwhile; it is shown as they saved it. Try again if needed.`,"admin.targets.events":`Events: {events}`,"admin.targets.allMonitors":`All monitors`,"admin.targets.someMonitors":`Chosen monitors: {monitors}; chosen components: {components}`,"admin.targets.chosenMonitors":`Chosen monitors and components`,"admin.targets.coverage":`Monitors`,"admin.targets.componentsHint":`The monitors these components show.`,"admin.targets.kind":`Kind`,"admin.targets.kindHint":`It cannot change later.`,"admin.targets.kindIs":`Kind: {kind}`,"admin.targets.kindGone":`Notifier kind “{kind}” is no longer in status.config.ts: its options cannot be edited.`,"admin.targets.name":`Name`,"admin.targets.options":`Options`,"admin.targets.optionsHint":`Defined by the notifier kind.`,"admin.targets.optionsChanged":`(options changed)`,"admin.targets.adminHint":`An administrators' target also receives “results stopped”, and links to the incident form.`,"admin.targets.unknownHint":`“Results stopped” goes to administrators' targets only.`,"admin.targets.field.name":`Name`,"admin.targets.field.admin":`Administrators' target`,"admin.targets.field.enabled":`Enabled`,"admin.targets.field.events":`Events`,"admin.targets.field.allMonitors":`All monitors`,"admin.targets.field.monitors":`Monitors`,"admin.targets.field.components":`Components`,"admin.targets.field.options":`Options`,"admin.targets.secret":`secret`,"admin.targets.secretHint":`Stored encrypted and never shown again.`,"admin.targets.secretSet":`Set`,"admin.targets.secretNotSet":`Not set`,"admin.targets.secretReplace":`Replace`,"admin.targets.secretEnter":`Enter a value`,"admin.targets.secretRemove":`Remove`,"admin.targets.secretKeep":`Keep the current value`,"admin.targets.secretUndo":`Undo`,"admin.targets.secretWillBeRemoved":`Will be removed when you save.`,"admin.targets.secretMissing":`Enter the new value, or keep the current one.`,"admin.targets.invalidNumber":`Enter a number.`,"admin.targets.invalidJson":`Enter valid JSON.`,"admin.targets.mapKey":`Name {index}`,"admin.targets.mapValue":`Value {index}`,"admin.targets.mapAdd":`Add`,"admin.targets.mapRemove":`Remove`,"admin.targets.create":`Create target`,"admin.targets.testTitle":`Test`,"admin.targets.testHint":`Sends a test notification now, with the saved settings: save your changes first.`,"admin.targets.test":`Send a test`,"admin.targets.testing":`Sending…`,"admin.targets.testOk":`The test notification was sent.`,"admin.targets.testFailed":`The test notification failed: {error}`,"admin.targets.deleteTitle":`Delete this target`,"admin.targets.deleteQuestion":`Delete “{name}”? It stops receiving notifications.`,"admin.deliveries.title":`Failed deliveries`,"admin.deliveries.intro":`Notifications that could not be delivered after their retries, and others by status. Records are kept 30 days.`,"admin.deliveries.status":`Status`,"admin.deliveries.statusName.failed":`Failed`,"admin.deliveries.statusName.retrying":`Waiting to retry`,"admin.deliveries.statusName.sending":`Sending`,"admin.deliveries.statusName.sent":`Sent`,"admin.deliveries.none":`Nothing here.`,"admin.deliveries.deletedTarget":`(deleted target)`,"admin.deliveries.occurred":`Event`,"admin.deliveries.updated":`Last attempt`,"admin.deliveries.attempts":`Attempts`,"admin.crash.title":`Something went wrong in the admin UI.`,"admin.crash.detail":`This view could not be shown. Reload the page; unsaved changes on it will be lost.`,"admin.conflict.titleRefresh":`A newer version was saved while you were editing, and it changes fields you changed too. Nothing was saved.`,"admin.form.leaveQuestion":`Leave this page? Your unsaved changes will be lost.`,"admin.incident.componentsChanged":`The affected components changed since you chose them: they now show the current ones. Check them and post again.`,"admin.issue.required":`Required.`,"admin.issue.tooShort":`Enter at least {minimum} characters.`,"admin.issue.tooLong":`Enter at most {maximum} characters.`,"admin.issue.tooFew":`Choose at least {minimum}.`,"admin.issue.tooMany":`Choose at most {maximum}.`,"admin.issue.tooSmall":`Must be at least {minimum}.`,"admin.issue.tooBig":`Must be at most {maximum}.`,"admin.issue.url":`Enter a valid URL.`,"admin.issue.email":`Enter a valid email address.`,"admin.issue.format":`This is not in the expected format.`,"admin.issue.oneOf":`Choose one of: {values}.`,"admin.issue.type":`This value is not valid (expected: {expected}).`,"admin.issue.unknownKeys":`Unknown fields: {keys}.`,"admin.issue.duplicate":`“{value}” is listed twice.`,"admin.issue.nothingToChange":`Nothing to change.`,"admin.issue.endsBeforeStart":`Must end after it starts.`,"admin.issue.startInFuture":`Must not be in the future.`,"admin.issue.unknownNeedsAdmin":`Only administrators' targets receive “results stopped”.`,"admin.issue.unknownPage":`status.config.ts has no page “{page}”.`,"admin.issue.pageRemoved":`Page “{page}” is no longer in status.config.ts.`,"admin.issue.unknownComponent":`Page “{page}” has no component “{component}”.`,"admin.issue.unknownMonitor":`status.config.ts has no monitor “{monitor}”.`,"admin.issue.unknownKind":`status.config.ts has no notifier kind “{kind}”.`,"admin.issue.kindRemoved":`Notifier kind “{kind}” is no longer in status.config.ts.`,"admin.issue.secretReentryRequired":`The destination changed: enter this secret again, or remove it. Secrets are never sent to a new destination.`,"admin.issue.destinationNotPublic":`Enter a public host: IP addresses and internal names such as localhost are not allowed.`,"admin.issue.hexColor":`Enter a colour as #rrggbb.`,"admin.issue.unknownImage":`This image is no longer stored. Upload it again.`,"admin.issue.uploadsUnavailable":`Images cannot be used: the Worker has no R2 bucket for them. Remove the image.`,"admin.issue.httpsRequired":`Enter an https URL.`,"admin.issue.localTimeGap":`This time does not exist in your time zone (a daylight saving time change). Choose another time.`,"admin.error.alreadyResolved":`The incident is already resolved; post an update to add to it.`,"admin.error.kindNotRegistered":`This target's notifier kind is no longer in status.config.ts.`,"admin.error.tooLarge":`The request is too large.`,"admin.error.internal":`The server failed; see the Worker's logs.`,"admin.monitors.purgeRefused.configured":`Not deleted: the monitor is in status.config.ts. Remove it and deploy first.`,"admin.monitors.purgeRefused.running":`Not deleted: the monitor is still running. Wait for the deploy to finish.`,"admin.monitors.purgeRefused.deploying":`Not deleted: a deploy is in progress. Try again once it has finished.`,"admin.form.leaveTitle":`Unsaved changes`,"admin.form.stay":`Stay on this page`,"admin.form.leave":`Leave without saving`},pe=d(Object.assign({"../../shared/i18n/admin/ja.ts":()=>r(()=>import(`./ja-DSSblLff.js`).then(e=>e.default),[])})),me={reference:{...t.reference,...fe},load:async e=>{let[n,r]=await Promise.all([t.load(e),ie(pe,e)]);return{...n,...r}}};function O(){return ae(me)}var k=class extends Error{status;code;issues;body;constructor(e,t,n,r=[],i=null){super(n),this.name=`AdminApiError`,this.status=e,this.code=t,this.issues=r,this.body=i}};function he(e){return e instanceof k&&e.status===409&&e.code===`edit_conflict`&&typeof e.body==`object`&&e.body!==null&&`current`in e.body}var ge={fetch:(e,t)=>globalThis.fetch(e,t)};async function _e(e,t,n,r){return ve(e,t,n===void 0?void 0:{content:JSON.stringify(n),contentType:`application/json`},r)}async function ve(e,t,n,r){let i={Accept:`application/json`};n!==void 0&&(i[`Content-Type`]=n.contentType);let a;try{a=await ge.fetch(`/api/admin${t}`,{method:e,headers:i,body:n?.content,credentials:`same-origin`,redirect:`manual`,cache:`no-store`,signal:r})}catch(e){throw r?.aborted?e:new k(0,`network`,e instanceof Error?e.message:String(e))}if(a.type===`opaqueredirect`||a.status>=300&&a.status<400)throw new k(0,`signed_out`,`The sign-in has expired`);if(a.status===204)return;let o=null;try{o=await a.json()}catch{if(a.ok)throw new k(a.status,`invalid_response`,`The response is not JSON`)}if(!a.ok){let e=o??{};throw new k(a.status,typeof e.error==`string`?e.error:`http_${a.status}`,typeof e.message==`string`?e.message:`HTTP ${a.status}`,Array.isArray(e.issues)?e.issues:[],o)}return o}var A={get:(e,t)=>_e(`GET`,e,void 0,t),post:(e,t)=>_e(`POST`,e,t),put:(e,t)=>_e(`PUT`,e,t),patch:(e,t)=>_e(`PATCH`,e,t),delete:e=>_e(`DELETE`,e),upload:(e,t,n)=>ve(`POST`,e,{content:t,contentType:n})};function ye(e,t){let n=new URLSearchParams;for(let[e,r]of Object.entries(t))r!=null&&r!==``&&n.set(e,String(r));let r=n.toString();return r===``?e:`${e}?${r}`}var j=encodeURIComponent,M=a(),be=(0,D.createContext)(null);function xe({value:e,children:t}){return(0,M.jsx)(be,{value:e,children:t})}function N(){let e=(0,D.useContext)(be);if(e===null)throw Error(`useAdmin() outside <AdminProvider>`);return e}function Se(){let{pages:e}=N(),t=u(),n=t.search.get(`page`)??e[0]?.id??``;return{pageId:n,page:e.find(e=>e.id===n),select:e=>{let n=Object.fromEntries(t.search);s(i(t.pathname,{...n,page:e}),{replace:!0,keepScroll:!0})}}}function Ce(e,t){return t.every((t,n)=>String(e[n])===String(t))}function P(e,t){return e.filter(e=>Ce(e.path,t)).map(e=>e.message)}function F(e,t){return e.filter(e=>!t.some(t=>Ce(e.path,t)))}var we={too_small:({origin:e,minimum:t})=>e===`string`?t===1?`admin.issue.required`:`admin.issue.tooShort`:e===`array`?`admin.issue.tooFew`:`admin.issue.tooSmall`,too_big:({origin:e})=>e===`string`?`admin.issue.tooLong`:e===`array`?`admin.issue.tooMany`:`admin.issue.tooBig`,invalid_format:({format:e})=>e===`url`?`admin.issue.url`:e===`email`?`admin.issue.email`:`admin.issue.format`,invalid_value:()=>`admin.issue.oneOf`,invalid_type:()=>`admin.issue.type`,unrecognized_keys:()=>`admin.issue.unknownKeys`,duplicate:()=>`admin.issue.duplicate`,nothing_to_change:()=>`admin.issue.nothingToChange`,ends_before_start:()=>`admin.issue.endsBeforeStart`,start_in_future:()=>`admin.issue.startInFuture`,unknown_needs_admin:()=>`admin.issue.unknownNeedsAdmin`,unknown_page:()=>`admin.issue.unknownPage`,page_removed:()=>`admin.issue.pageRemoved`,unknown_component:()=>`admin.issue.unknownComponent`,unknown_monitor:()=>`admin.issue.unknownMonitor`,unknown_kind:()=>`admin.issue.unknownKind`,kind_removed:()=>`admin.issue.kindRemoved`,secret_reentry_required:()=>`admin.issue.secretReentryRequired`,destination_not_public:()=>`admin.issue.destinationNotPublic`,https_required:()=>`admin.issue.httpsRequired`,hex_color:()=>`admin.issue.hexColor`,unknown_image:()=>`admin.issue.unknownImage`,uploads_unavailable:()=>`admin.issue.uploadsUnavailable`};function Te(e,t){let n=e.params??{},r=e.code===void 0?null:we[e.code]?.(n)??null;return r===null?e.message:t(r,n)}function I(e,t){return e instanceof k?e.issues.map(e=>({...e,message:Te(e,t)})):[]}function L(e,t){if(e instanceof k)switch(e.code){case`already_resolved`:return t(`admin.error.alreadyResolved`);case`kind_not_registered`:return t(`admin.error.kindNotRegistered`);case`payload_too_large`:return t(`admin.error.tooLarge`);case`internal_error`:return t(`admin.error.internal`);case`network`:return t(`admin.error.network`);case`signed_out`:return t(`admin.error.signedOut`);case`forbidden`:return t(`admin.error.forbidden`);case`not_found`:return t(`admin.error.notFound`);case`validation_failed`:return t(`admin.error.validation`);case`encryption_key_missing`:return t(`admin.error.encryptionKey`,{message:e.message});default:return t(`admin.error.server`,{message:e.message,status:e.status})}return t(`admin.error.unexpected`,{message:e instanceof Error?e.message:String(e)})}function R({error:e,onRetry:t}){let{t:n}=O();if(e==null)return null;let r=e instanceof k&&(e.code===`signed_out`||e.code===`forbidden`);return(0,M.jsxs)(`div`,{className:`alert alert--error`,role:`alert`,children:[(0,M.jsx)(l,{name:`warning`}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{children:L(e,n)}),r?(0,M.jsx)(`p`,{children:(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>window.location.reload(),children:n(`admin.action.reloadPage`)})}):t!==void 0&&(0,M.jsx)(`p`,{children:(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:t,children:n(`admin.action.retry`)})})]})]})}function z({issues:e}){return e.length===0?null:(0,M.jsx)(`ul`,{className:`issue-summary`,children:e.map(e=>(0,M.jsxs)(`li`,{children:[e.path.length>0&&(0,M.jsx)(`code`,{children:e.path.join(`.`)}),` `,e.message]},`${e.path.join(`.`)}:${e.message}`))})}function B({label:e,hint:t,errors:n=[],children:r}){let i=(0,D.useId)(),a=t===void 0?void 0:`${i}-hint`,o=n.length===0?void 0:`${i}-error`,s=[a,o].filter(e=>e!==void 0).join(` `)||void 0;return(0,M.jsxs)(`div`,{className:`field${n.length>0?` field--invalid`:``}`,children:[(0,M.jsx)(`label`,{className:`field__label`,htmlFor:i,children:e}),r({id:i,describedBy:s,invalid:n.length>0}),t!==void 0&&(0,M.jsx)(`p`,{id:a,className:`field__hint`,children:t}),(0,M.jsx)(Ee,{id:o,errors:n})]})}function Ee({id:e,errors:t}){return t.length===0?null:(0,M.jsx)(`ul`,{id:e,className:`field__errors`,children:t.map(e=>(0,M.jsx)(`li`,{children:e},e))})}function V({legend:e,hint:t,errors:n=[],children:r}){return(0,M.jsxs)(`fieldset`,{className:`fieldset${n.length>0?` field--invalid`:``}`,children:[(0,M.jsx)(`legend`,{className:`field__label`,children:e}),t!==void 0&&(0,M.jsx)(`p`,{className:`field__hint`,children:t}),r,(0,M.jsx)(Ee,{errors:n})]})}function H({children:e}){return(0,M.jsxs)(`p`,{className:`alert alert--success`,role:`status`,children:[(0,M.jsx)(l,{name:`up`}),(0,M.jsx)(`span`,{children:e})]})}function U(t){let{t:n}=O(),r=(0,D.useRef)({dirty:t,question:``});r.current={dirty:t,question:n(`admin.form.leaveQuestion`)},(0,D.useEffect)(()=>e(()=>r.current.dirty?r.current.question:null),[])}function W({title:e,actions:t,children:n}){let r=(0,D.useRef)(null),{pathname:i}=u();return(0,D.useEffect)(()=>{r.current?.focus({preventScroll:!0})},[i]),(0,M.jsxs)(`header`,{className:`view-header`,children:[(0,M.jsxs)(`div`,{className:`view-header__row`,children:[(0,M.jsx)(`h1`,{ref:r,tabIndex:-1,className:`view-header__title`,children:e}),t!==void 0&&(0,M.jsx)(`div`,{className:`actions`,children:t})]}),n]})}function De(){let{t:e}=O(),{pages:t}=N(),{pageId:n,page:r,select:i}=Se();return t.length<2&&r!==void 0?null:(0,M.jsxs)(`label`,{className:`inline-field`,children:[(0,M.jsx)(`span`,{children:e(`admin.page.label`)}),(0,M.jsxs)(`select`,{value:n,onChange:e=>i(e.target.value),children:[r===void 0&&(0,M.jsx)(`option`,{value:n,children:e(`admin.page.removed`,{page:n})}),t.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.id},e.id))]})]})}function G(e,t,n={}){return i(e,{page:t,...n})}function K(){let{t:e}=O();return(0,M.jsx)(`p`,{className:`muted`,"aria-busy":`true`,children:e(`ui.loading`)})}function q({href:e,children:t}){return(0,M.jsx)(`p`,{className:`back-link`,children:(0,M.jsxs)(S,{href:e,children:[`← `,t]})})}function Oe({error:e,retry:t}){let{t:n}=O();return(0,M.jsx)(`main`,{className:`admin-main`,children:(0,M.jsx)(`div`,{className:`alert alert--error`,role:`alert`,children:(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`conflict__title`,children:n(`admin.crash.title`)}),(0,M.jsx)(`p`,{children:n(`admin.crash.detail`)}),(0,M.jsx)(`p`,{className:`mono`,children:e instanceof Error?e.message:String(e)}),(0,M.jsxs)(`p`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`button`,className:`button button--primary`,onClick:()=>window.location.reload(),children:n(`admin.action.reloadPage`)}),(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:t,children:n(`admin.action.retry`)})]})]})})})}function ke(){let{t:e}=O(),t=c(),n=(0,D.useRef)(null),r=(0,D.useRef)(null);return(0,D.useEffect)(()=>{if(t!==null)return r.current=document.activeElement,n.current?.focus(),()=>{r.current instanceof HTMLElement&&r.current.focus()}},[t]),t===null?null:(0,M.jsx)(`div`,{className:`modal-backdrop`,children:(0,M.jsxs)(`div`,{className:`modal`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`leave-title`,"aria-describedby":`leave-question`,onKeyDown:e=>{if(e.key===`Escape`&&t.stay(),e.key===`Tab`){let t=[...e.currentTarget.querySelectorAll(`button`)],n=t[(t.indexOf(document.activeElement)+(e.shiftKey?t.length-1:1))%t.length];e.preventDefault(),n?.focus()}},children:[(0,M.jsx)(`h2`,{id:`leave-title`,className:`panel__title`,children:e(`admin.form.leaveTitle`)}),(0,M.jsx)(`p`,{id:`leave-question`,children:t.question}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{ref:n,type:`button`,className:`button button--primary`,onClick:t.stay,children:e(`admin.form.stay`)}),(0,M.jsx)(`button`,{type:`button`,className:`button button--danger`,onClick:t.leave,children:e(`admin.form.leave`)})]})]})})}function J(e,t){let[n,r]=(0,D.useState)({key:e,data:void 0,error:null,loading:e!==null}),[i,a]=(0,D.useState)(0),o=(0,D.useRef)(t);o.current=t,(0,D.useEffect)(()=>{if(e===null)return;let t=new AbortController;return r(t=>t.key===e?{...t,loading:!0,error:null}:{key:e,data:void 0,error:null,loading:!0}),o.current(t.signal).then(n=>{t.signal.aborted||r({key:e,data:n,error:null,loading:!1})}).catch(n=>{t.signal.aborted||r(t=>({key:e,data:t.key===e?t.data:void 0,error:n,loading:!1}))}),()=>t.abort()},[e,i]);let s=(0,D.useCallback)(()=>a(e=>e+1),[]),c=(0,D.useCallback)(t=>r({key:e,data:t,error:null,loading:!1}),[e]),l=n.key===e;return{data:l?n.data:void 0,error:l?n.error:null,loading:l?n.loading:e!==null,reload:s,setData:c}}function Ae(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Y(e,t){return Object.keys(t).filter(n=>!Ae(e[n],t[n]))}function je(e,t,n){let r={...n};for(let n of Y(e,t))r[n]=t[n];return r}function Me(e,t){let[n,r]=(0,D.useState)(()=>({base:e,draft:t(e),conflict:null})),i=t(n.base);return{base:n.base,draft:n.draft,setDraft:e=>r(t=>({...t,draft:e(t.draft)})),changed:Y(i,n.draft),conflict:n.conflict,saved:e=>r({base:e,draft:t(e),conflict:null}),refresh:e=>r(n=>{if(e.version<=n.base.version||n.conflict!==null)return n;let r=t(n.base),i=t(e),a=Y(r,i),o=new Set(Y(r,n.draft)),s=a.filter(e=>o.has(e));return s.length>0?{...n,conflict:{source:`refresh`,current:e,theirs:a,both:s}}:{base:e,draft:je(r,n.draft,i),conflict:null}}),handleError:e=>{if(!he(e))return!1;let n=e.body.current;return r(e=>{let r=t(e.base),i=Y(r,t(n)),a=new Set(Y(r,e.draft));return{...e,conflict:{source:`save`,current:n,theirs:i,both:i.filter(e=>a.has(e))}}}),!0},takeCurrent:()=>r(e=>e.conflict===null?e:{base:e.conflict.current,draft:t(e.conflict.current),conflict:null}),reapply:()=>r(e=>{if(e.conflict===null)return e;let n=e.conflict.current;return{base:n,draft:je(t(e.base),e.draft,t(n)),conflict:null}})}}function Ne({conflict:e,label:t,value:n,onTakeCurrent:r,onReapply:i}){let{t:a,f:o}=O(),{current:s}=e;return(0,M.jsxs)(`div`,{className:`alert alert--conflict`,role:`alert`,children:[(0,M.jsx)(l,{name:`warning`}),(0,M.jsxs)(`div`,{className:`conflict`,children:[(0,M.jsx)(`p`,{className:`conflict__title`,children:e.source===`save`?a(`admin.conflict.title`):a(`admin.conflict.titleRefresh`)}),(0,M.jsx)(`p`,{children:a(`admin.conflict.savedBy`,{who:s.updatedBy??a(`admin.common.automation`),time:s.updatedAt===null?`—`:o.dateTimeWithZone(s.updatedAt)})}),e.theirs.length===0?(0,M.jsx)(`p`,{children:a(`admin.conflict.noFieldChanges`)}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{children:a(`admin.conflict.theyChanged`)}),(0,M.jsx)(`dl`,{className:`conflict__fields`,children:e.theirs.map(r=>(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`dt`,{children:[t(r),e.both.includes(r)&&(0,M.jsx)(`span`,{className:`badge badge--degraded`,children:a(`admin.conflict.alsoYours`)})]}),(0,M.jsx)(`dd`,{children:n(r)})]},r))})]}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:r,children:a(`admin.conflict.takeCurrent`)}),(0,M.jsx)(`button`,{type:`button`,className:`button button--primary`,onClick:i,children:a(`admin.conflict.reapply`)})]}),(0,M.jsx)(`p`,{className:`field__hint`,children:a(`admin.conflict.reapplyHint`)})]})]})}var Pe=[`title`,`description`,`logoUrl`,`websiteUrl`,`logoImage`,`faviconImage`,`colors`];function Fe(e){return{title:e.title??``,description:e.description??``,logoUrl:e.logoUrl??``,websiteUrl:e.websiteUrl??``,logoImage:e.logoImage,faviconImage:e.faviconImage,colors:e.colors}}function Ie(e,t){let n=_.flatMap(n=>g.flatMap(r=>{let i=e[n][r];return i===null?[]:[`${t(`admin.appearance.scheme.${n}`)} ${t(`admin.appearance.role.${r}`)} ${i}`]}));return n.length===0?null:n.join(`, `)}function Le(){let{t:e}=O(),{uploads:t}=N(),{pageId:n,page:r}=Se(),i=J(n,e=>A.get(`/pages/${j(n)}/appearance`,e));return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(W,{title:e(`admin.appearance.title`),actions:(0,M.jsx)(`a`,{className:`button`,href:`/pages/${j(n)}`,target:`_blank`,rel:`noopener`,children:e(`admin.viewStatusPage`)}),children:[(0,M.jsx)(`div`,{className:`filters`,children:(0,M.jsx)(De,{})}),(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.appearance.intro`)})]}),r===void 0?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.page.notConfigured`,{page:n})}):i.data===void 0||i.data.pageId!==n?i.error===null?(0,M.jsx)(K,{}):(0,M.jsx)(R,{error:i.error,onRetry:i.reload}):(0,M.jsx)(Re,{appearance:i.data,onReload:i.reload,template:r.template,uploads:t},i.data.pageId)]})}function Re({appearance:e,onReload:t,template:n=`default`,uploads:r=!1}){let{t:i,f:a}=O(),o=Me(e,Fe);e.version>o.base.version&&o.conflict===null&&o.refresh(e);let[s,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(!1),[d,p]=(0,D.useState)(0),[m,h]=(0,D.useState)(!1),g=I(s,i);U(o.changed.length>0);let _={title:i(`admin.appearance.fieldTitle`),description:i(`admin.appearance.description`),logoUrl:i(`admin.appearance.logoUrl`),websiteUrl:i(`admin.appearance.websiteUrl`),logoImage:i(`admin.appearance.logoImage`),faviconImage:i(`admin.appearance.favicon`),colors:i(`admin.appearance.colors`)};async function v(t){t.preventDefault();let n=e=>e.trim()===``?null:e.trim(),r={version:o.base.version,title:n(o.draft.title),description:n(o.draft.description),logoUrl:n(o.draft.logoUrl),websiteUrl:n(o.draft.websiteUrl),logoImage:o.draft.logoImage,faviconImage:o.draft.faviconImage,colors:o.draft.colors};u(!0),c(null),h(!1);try{o.saved(await A.put(`/pages/${j(e.pageId)}/appearance`,r)),h(!0)}catch(e){o.handleError(e)||c(e)}finally{u(!1)}}let y=o.conflict,b=e=>o.setDraft(t=>({...t,colors:e})),x=(t,n)=>(0,M.jsx)(Ue,{label:_[t]??t,hint:n,pageId:e.pageId,imageId:o.draft[t],uploads:r,errors:P(g,[t]),onUploading:e=>p(t=>t+e),onChange:e=>o.setDraft(n=>({...n,[t]:e}))});return(0,M.jsxs)(M.Fragment,{children:[y!==null&&(0,M.jsx)(Ne,{conflict:y,label:e=>_[e]??e,value:e=>{let t=y.current[e];return e===`colors`?Ie(t,i)??i(`admin.appearance.default`):typeof t==`string`?t:i(`admin.appearance.default`)},onTakeCurrent:()=>{o.takeCurrent(),t()},onReapply:()=>{o.reapply(),t()}}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void v(e),children:[(0,M.jsx)(R,{error:s}),(0,M.jsx)(z,{issues:F(g,Pe.map(e=>[e]))}),m&&o.changed.length===0&&(0,M.jsx)(H,{children:i(`admin.form.saved`)}),o.base.updatedAt!==null&&(0,M.jsx)(`p`,{className:`field__hint`,children:i(`admin.common.lastChange`,{who:o.base.updatedBy??i(`admin.common.automation`),time:a.dateTimeWithZone(o.base.updatedAt)})}),(0,M.jsx)(B,{label:_.title,hint:i(`admin.appearance.titleHint`,{page:e.pageId}),errors:P(g,[`title`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`input`,{id:e,"aria-describedby":t,"aria-invalid":n||void 0,maxLength:f.appearanceTitle,value:o.draft.title,onChange:e=>{let t=e.target.value;o.setDraft(e=>({...e,title:t}))}})}),(0,M.jsx)(B,{label:_.description,hint:i(`admin.appearance.descriptionHint`),errors:P(g,[`description`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`textarea`,{id:e,"aria-describedby":t,"aria-invalid":n||void 0,rows:3,maxLength:f.appearanceDescription,value:o.draft.description,onChange:e=>{let t=e.target.value;o.setDraft(e=>({...e,description:t}))}})}),!r&&(0,M.jsx)(`p`,{className:`field__hint`,children:i(`admin.appearance.uploadsUnavailable`)}),x(`logoImage`,i(`admin.appearance.logoImageHint`,{size:f.imageBytes/1024})),(0,M.jsx)(B,{label:_.logoUrl,hint:i(`admin.appearance.logoHint`),errors:P(g,[`logoUrl`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`input`,{id:e,type:`url`,"aria-describedby":t,"aria-invalid":n||void 0,maxLength:f.url,placeholder:`https://`,value:o.draft.logoUrl,onChange:e=>{let t=e.target.value;o.setDraft(e=>({...e,logoUrl:t}))}})}),x(`faviconImage`,i(`admin.appearance.faviconHint`,{size:f.imageBytes/1024})),(0,M.jsx)(B,{label:_.websiteUrl,hint:i(`admin.appearance.websiteHint`),errors:P(g,[`websiteUrl`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`input`,{id:e,type:`url`,"aria-describedby":t,"aria-invalid":n||void 0,maxLength:f.url,placeholder:`https://`,value:o.draft.websiteUrl,onChange:e=>{let t=e.target.value;o.setDraft(e=>({...e,websiteUrl:t}))}})}),(0,M.jsx)(We,{template:n,colors:o.draft.colors,title:o.draft.title.trim()||e.pageId,issues:g,onChange:b}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:l||d>0||o.changed.length===0||y!==null,children:i(`admin.form.save`)}),o.changed.length>0&&(0,M.jsx)(`span`,{className:`muted`,children:i(`admin.form.unsaved`)})]})]})]})}var ze={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,ico:`image/x-icon`};function Be(e){let t=e.type.toLowerCase();return Object.hasOwn(C,t)?t:t===``?ze[e.name.slice(e.name.lastIndexOf(`.`)+1).toLowerCase()]??null:null}var Ve=[...Object.keys(C),`.ico`].join(`,`);function He(e,t){if(e instanceof k)switch(e.code){case`invalid_image`:return t(`admin.appearance.imageInvalid`);case`unsupported_media_type`:return t(`admin.appearance.imageType`);case`payload_too_large`:return t(`admin.appearance.imageTooLarge`,{size:f.imageBytes/1024});case`uploads_unavailable`:return t(`admin.appearance.uploadsUnavailable`)}return L(e,t)}function Ue({label:e,hint:t,pageId:n,imageId:r,uploads:i,errors:a,onUploading:o,onChange:s}){let{t:c}=O(),[l,u]=(0,D.useState)(null),[d,p]=(0,D.useState)(!1),m=(0,D.useRef)(null);async function h(e){u(null);let t=Be(e);if(t===null)return u(c(`admin.appearance.imageType`));if(e.size>f.imageBytes)return u(c(`admin.appearance.imageTooLarge`,{size:f.imageBytes/1024}));p(!0),o(1);try{s((await A.upload(`/pages/${j(n)}/images`,e,t)).id)}catch(e){u(He(e,c))}finally{p(!1),o(-1),m.current!==null&&(m.current.value=``)}}return(0,M.jsx)(B,{label:e,hint:t,errors:l===null?a:[...a,l],children:({id:t,describedBy:a,invalid:o})=>(0,M.jsxs)(`div`,{className:`image-field`,children:[r!==null&&i&&(0,M.jsx)(`img`,{className:`image-field__preview`,src:oe(n,r),alt:c(`admin.appearance.currentImage`,{label:e})}),(0,M.jsxs)(`div`,{className:`input-row`,children:[(0,M.jsx)(`input`,{ref:m,id:t,type:`file`,accept:Ve,"aria-describedby":a,"aria-invalid":o||void 0,disabled:!i||d,onChange:e=>{let t=e.target.files?.[0];t!==void 0&&h(t)}}),r!==null&&(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,disabled:d,onClick:()=>s(null),children:c(`admin.appearance.removeImage`)})]}),d&&(0,M.jsx)(`p`,{className:`muted`,role:`status`,children:c(`admin.appearance.uploading`)})]})})}function We({template:e,colors:t,title:n,issues:r,onChange:i}){let{t:a}=O(),o=(e,n,r)=>i({...t,[e]:{...t[e],[n]:r}}),s=_.flatMap(n=>h(e,n,t[n]).map(e=>a(e.role===`background`?`admin.appearance.contrastBackground`:`admin.appearance.contrastAccent`,{scheme:a(`admin.appearance.scheme.${n}`),ratio:e.ratio.toFixed(1)}))),c=Ie(t,a)!==null;return(0,M.jsxs)(V,{legend:a(`admin.appearance.colors`),hint:a(`admin.appearance.colorsHint`),errors:P(r,[`colors`]),children:[(0,M.jsxs)(`table`,{className:`color-table`,children:[(0,M.jsx)(`thead`,{children:(0,M.jsxs)(`tr`,{children:[(0,M.jsx)(`td`,{}),_.map(e=>(0,M.jsx)(`th`,{scope:`col`,children:a(`admin.appearance.scheme.${e}`)},e))]})}),(0,M.jsx)(`tbody`,{children:g.map(n=>(0,M.jsxs)(`tr`,{children:[(0,M.jsxs)(`th`,{scope:`row`,children:[a(`admin.appearance.role.${n}`),(0,M.jsx)(`span`,{className:`field__hint color-table__hint`,children:a(`admin.appearance.roleHint.${n}`)})]}),_.map(r=>(0,M.jsx)(`td`,{children:(0,M.jsx)(Ge,{scheme:a(`admin.appearance.scheme.${r}`),label:`${a(`admin.appearance.role.${n}`)} (${a(`admin.appearance.scheme.${r}`)})`,value:t[r][n],fallback:T[e][r][n]??T.modern[r][n]??`#000000`,onChange:e=>o(r,n,e)})},r))]},n))})]}),e!==`modern`&&(0,M.jsx)(`p`,{className:`field__hint`,children:a(`admin.appearance.headerModernOnly`)}),(0,M.jsx)(`div`,{className:`color-previews`,children:_.map(r=>(0,M.jsx)(Ke,{template:e,scheme:r,colors:t[r],title:n},r))}),s.length>0&&(0,M.jsx)(`ul`,{className:`field__warnings`,children:s.map(e=>(0,M.jsx)(`li`,{children:e},e))}),c&&(0,M.jsx)(`p`,{children:(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>i(re),children:a(`admin.appearance.resetColors`)})})]})}function Ge({scheme:e,label:t,value:n,fallback:r,onChange:i}){let{t:a}=O();return(0,M.jsxs)(`div`,{className:`color-input`,children:[(0,M.jsx)(`span`,{className:`color-input__scheme`,"aria-hidden":`true`,children:e}),(0,M.jsx)(`input`,{type:`color`,"aria-label":t,value:n??r,onChange:e=>i(e.target.value.toLowerCase())}),(0,M.jsx)(`code`,{className:n===null?`muted`:void 0,children:n??a(`admin.appearance.colorDefault`)}),n!==null&&(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,"aria-label":a(`admin.appearance.resetColorOf`,{color:t}),onClick:()=>i(null),children:a(`admin.appearance.resetColor`)})]})}function Ke({template:e,scheme:t,colors:n,title:r}){let{t:i}=O(),a=T[e][t],o=ee(e,t,n);return(0,M.jsxs)(`figure`,{className:`color-preview`,children:[(0,M.jsx)(`figcaption`,{className:`field__hint`,children:i(`admin.appearance.preview`,{scheme:i(`admin.appearance.scheme.${t}`)})}),(0,M.jsxs)(`div`,{className:`color-preview__page`,style:{background:o.background,color:a.textOnBackground},"aria-hidden":`true`,children:[o.header===null?(0,M.jsx)(`p`,{className:`color-preview__title`,style:{color:a.text},children:r}):(0,M.jsx)(`p`,{className:`color-preview__header`,style:{background:o.header,color:ne(o.header)},children:r}),(0,M.jsxs)(`div`,{className:`color-preview__surface`,style:{background:a.surface??o.background,color:a.text},children:[i(`admin.appearance.previewText`),` `,(0,M.jsx)(`span`,{className:`color-preview__link`,style:{color:o.accent},children:i(`admin.appearance.previewLink`)})]})]})]})}function qe(e,t){let[n,r]=(0,D.useState)({key:e,items:[],cursor:null,loading:!0,error:null}),[i,a]=(0,D.useState)(0),o=(0,D.useRef)(t);o.current=t;let s=(0,D.useRef)(n);s.current=n;let c=(0,D.useRef)(0);(0,D.useEffect)(()=>{let t=new AbortController,n=++c.current;return r({key:e,items:[],cursor:null,loading:!0,error:null}),o.current(null,t.signal).then(t=>{c.current===n&&r({key:e,items:t.items,cursor:t.nextCursor,loading:!1,error:null})}).catch(i=>{c.current===n&&!t.signal.aborted&&r({key:e,items:[],cursor:null,loading:!1,error:i})}),()=>t.abort()},[e,i]);function l(){let{cursor:e,loading:t}=s.current;if(e===null||t)return;let n=c.current;r(e=>({...e,loading:!0,error:null})),o.current(e).then(e=>{c.current===n&&r(t=>({...t,items:[...t.items,...e.items],cursor:e.nextCursor,loading:!1,error:null}))}).catch(e=>{c.current===n&&r(t=>({...t,loading:!1,error:e}))})}let u=n.key===e;return{items:u?n.items:[],loading:!u||n.loading,error:u?n.error:null,more:u&&n.cursor!==null,loadMore:l,reload:()=>a(e=>e+1),replace:(e,t)=>r(n=>({...n,items:n.items.map(n=>t(n,e)?e:n)}))}}var Je=[`failed`,`retrying`,`sending`,`sent`],Ye={failed:`badge--down`,retrying:`badge--degraded`,sending:`badge--unknown`,sent:`badge--up`};function Xe(){let{t:e,f:t}=O(),n=u(),r=Je.find(e=>e===n.search.get(`status`))??`failed`,a=qe(r,(e,t)=>A.get(ye(`/notifications/deliveries`,{status:r,cursor:e}),t));return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(W,{title:e(`admin.deliveries.title`),actions:(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:a.reload,disabled:a.loading,children:e(`admin.action.refresh`)}),children:[(0,M.jsx)(`div`,{className:`filters`,children:(0,M.jsxs)(`label`,{className:`inline-field`,children:[(0,M.jsx)(`span`,{children:e(`admin.deliveries.status`)}),(0,M.jsx)(`select`,{value:r,onChange:e=>s(i(n.pathname,{status:e.target.value}),{replace:!0,keepScroll:!0}),children:Je.map(t=>(0,M.jsx)(`option`,{value:t,children:e(`admin.deliveries.statusName.${t}`)},t))})]})}),(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.deliveries.intro`)})]}),(0,M.jsx)(R,{error:a.error,onRetry:a.reload}),a.items.length===0&&a.loading?(0,M.jsx)(K,{}):a.items.length===0&&a.error===null?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.deliveries.none`)}):(0,M.jsx)(`ul`,{className:`list`,children:a.items.map(n=>(0,M.jsxs)(`li`,{className:`list-item`,children:[(0,M.jsxs)(`div`,{className:`list-item__main`,children:[(0,M.jsx)(`p`,{className:`list-item__title`,children:n.targetName===null?(0,M.jsx)(`span`,{children:e(`admin.deliveries.deletedTarget`)}):(0,M.jsx)(S,{href:`/admin/notifications/${j(n.targetId)}`,children:n.targetName})}),(0,M.jsxs)(`p`,{className:`list-item__meta`,children:[(0,M.jsx)(`span`,{className:`badge ${Ye[n.status]}`,children:e(`admin.deliveries.statusName.${n.status}`)}),(0,M.jsx)(`span`,{className:`badge badge--stage`,children:e(`admin.event.${n.event}`)}),n.monitorId!==null&&(0,M.jsx)(`code`,{className:`muted`,children:n.monitorId})]}),n.lastError!==null&&(0,M.jsx)(`p`,{className:`mono error-text`,children:n.lastError})]}),(0,M.jsxs)(`dl`,{className:`list-item__facts`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e(`admin.deliveries.occurred`)}),(0,M.jsx)(`dd`,{children:t.dateTime(n.occurredAt)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e(`admin.deliveries.updated`)}),(0,M.jsx)(`dd`,{children:t.dateTime(n.updatedAt)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e(`admin.deliveries.attempts`)}),(0,M.jsx)(`dd`,{children:n.attempts})]})]})]},`${n.notificationId}:${n.targetId}`))}),a.more&&(0,M.jsx)(`p`,{children:(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:a.loadMore,disabled:a.loading,children:a.loading?e(`ui.loading`):e(`admin.list.more`)})})]})}var Ze=(e,t=2)=>String(e).padStart(t,`0`);function X(e){let t=new Date(e);return`${Ze(t.getFullYear(),4)}-${Ze(t.getMonth()+1)}-${Ze(t.getDate())}T${Ze(t.getHours())}:${Ze(t.getMinutes())}`}function Qe(e){if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,3})?)?$/.test(e))return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function Z(e){let t=Qe(e);return t===null||X(t)===e.slice(0,16)}var $e={none:0,degraded:1,down:2};function et(e){return e.reduce((e,{impact:t})=>$e[t]>$e[e]?t:e,`none`)}function tt(e,t){let n={};for(let t of e?.components??[])n[t.id]=``;for(let e of t)e.id in n&&(n[e.id]=e.impact);return n}function nt(e,t){return(e?.components??[]).flatMap(e=>{let n=t[e.id];return n===void 0||n===``?[]:[{id:e.id,impact:n}]})}function rt({page:e,value:t,onChange:n,issues:r,sent:i,unknown:a=[],legend:o}){let{t:s}=O(),c=r.filter(e=>e.path[0]===`components`&&typeof e.path[1]!=`number`).map(e=>e.message);return(0,M.jsxs)(V,{legend:o??s(`admin.incident.components`),hint:s(`admin.incident.componentsHint`),errors:c,children:[(e?.components.length??0)===0?(0,M.jsx)(`p`,{className:`muted`,children:s(`admin.incident.noComponents`)}):(0,M.jsx)(`div`,{className:`impact-grid`,children:e?.components.map(e=>{let a=i.findIndex(t=>t.id===e.id),o=a===-1?[]:P(r,[`components`,a]);return(0,M.jsx)(B,{label:e.name,errors:o,children:({id:r,describedBy:i,invalid:a})=>(0,M.jsxs)(`select`,{id:r,"aria-describedby":i,"aria-invalid":a||void 0,value:t[e.id]??``,onChange:r=>n({...t,[e.id]:r.target.value}),children:[(0,M.jsx)(`option`,{value:``,children:s(`admin.impact.unaffected`)}),y.map(e=>(0,M.jsx)(`option`,{value:e,children:s(`impact.${e}`)},e))]})},e.id)})}),a.length>0&&(0,M.jsx)(`p`,{className:`field__hint`,children:s(`admin.incident.unknownComponents`,{ids:a.join(`, `)})})]})}function it({value:e,onChange:t,errors:n,stages:r=v}){let{t:i}=O();return(0,M.jsx)(B,{label:i(`admin.incident.stage`),hint:i(`admin.incident.stageHint`),errors:n,children:({id:n,describedBy:a,invalid:o})=>(0,M.jsx)(`select`,{id:n,"aria-describedby":a,"aria-invalid":o||void 0,value:e,onChange:e=>t(e.target.value),children:r.map(e=>(0,M.jsx)(`option`,{value:e,children:i(`stage.${e}`)},e))})})}function at(){let{t:e,f:t}=O(),{pages:n}=N(),r=u(),[i]=(0,D.useState)(()=>{let e=r.search.get(`page`),t=n.find(t=>t.id===e)??n[0],i=new Set((r.search.get(`components`)??``).split(`,`).filter(e=>e!==``)),a=(t?.components??[]).filter(e=>i.has(e.id)).map(e=>({id:e.id,impact:`down`}));return{pageId:t?.id??``,impacts:tt(t,a),prefilled:a.length>0}}),[a,o]=(0,D.useState)(i.pageId),[c,l]=(0,D.useState)(``),[d,p]=(0,D.useState)(i.impacts),[m,h]=(0,D.useState)(``),[g,_]=(0,D.useState)(`investigating`),[v,y]=(0,D.useState)(``),[b,x]=(0,D.useState)([]),[S,ee]=(0,D.useState)(null),[C,w]=(0,D.useState)(!1),T=n.find(e=>e.id===a),E=I(S,e),te=Date.now(),ne=Qe(m);U(!C&&(c!==``||v!==``||m!==``||JSON.stringify(d)!==JSON.stringify(i.impacts)));async function re(e){if(e.preventDefault(),!Z(m))return;let t=nt(T,d),n={pageId:a,title:c,stage:g,body:v,components:t,...ne===null?{}:{startedAt:ne}};x(t),w(!0),ee(null);try{let e=await A.post(`/incidents`,n);s(`/admin/incidents/${encodeURIComponent(e.id)}?created=1`,{force:!0})}catch(e){ee(e)}finally{w(!1)}}return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:G(`/admin/incidents`,a),children:e(`admin.incidents.title`)}),(0,M.jsx)(W,{title:e(`admin.incidents.new`)}),i.prefilled&&(0,M.jsx)(`p`,{className:`alert alert--info`,children:e(`admin.incident.prefilled`)}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void re(e),children:[(0,M.jsx)(R,{error:S}),(0,M.jsx)(z,{issues:F(E,[[`pageId`],[`title`],[`startedAt`],[`stage`],[`body`],[`components`]])}),n.length>1&&(0,M.jsx)(B,{label:e(`admin.page.label`),errors:P(E,[`pageId`]),children:({id:e,describedBy:t})=>(0,M.jsx)(`select`,{id:e,"aria-describedby":t,value:a,onChange:e=>{let t=n.find(t=>t.id===e.target.value);o(e.target.value),p(tt(t,[]))},children:n.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.id},e.id))})}),(0,M.jsx)(B,{label:e(`admin.incident.title`),errors:P(E,[`title`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`input`,{id:e,"aria-describedby":t,"aria-invalid":n||void 0,required:!0,maxLength:f.title,value:c,onChange:e=>l(e.target.value)})}),(0,M.jsx)(rt,{page:T,value:d,onChange:p,issues:E,sent:b}),(0,M.jsx)(B,{label:e(`admin.incident.startedAt`),hint:e(`admin.incident.startedAtHint`,{timeZone:t.timeZone,offset:t.offset(ne??te)}),errors:[...Z(m)?[]:[e(`admin.issue.localTimeGap`)],...P(E,[`startedAt`])],children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`input`,{id:e,type:`datetime-local`,"aria-describedby":t,"aria-invalid":n||void 0,max:X(te),value:m,onChange:e=>h(e.target.value)})}),(0,M.jsx)(it,{value:g,onChange:_,errors:P(E,[`stage`])}),(0,M.jsx)(B,{label:e(`admin.incident.firstUpdate`),hint:e(`admin.incident.bodyHint`),errors:P(E,[`body`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`textarea`,{id:e,"aria-describedby":t,"aria-invalid":n||void 0,required:!0,rows:5,maxLength:f.body,value:v,onChange:e=>y(e.target.value)})}),(0,M.jsx)(`div`,{className:`actions`,children:(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:C,children:e(`admin.incident.publish`)})})]})]})}function ot({label:e,question:t,confirmLabel:n,onConfirm:r,danger:i=!0,disabled:a=!1}){let{t:o}=O(),[s,c]=(0,D.useState)(!1),[l,u]=(0,D.useState)(!1),d=(0,D.useRef)(null),f=(0,D.useRef)(null);if((0,D.useEffect)(()=>{s&&d.current?.focus()},[s]),!s)return(0,M.jsx)(`button`,{ref:f,type:`button`,className:i?`button button--danger`:`button`,disabled:a,onClick:()=>c(!0),children:e});let p=()=>{c(!1),requestAnimationFrame(()=>f.current?.focus())};return(0,M.jsxs)(`div`,{className:`confirm`,role:`group`,onKeyDown:e=>{e.key===`Escape`&&p()},children:[(0,M.jsx)(`p`,{className:`confirm__question`,children:t}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{ref:d,type:`button`,className:i?`button button--danger-solid`:`button button--primary`,disabled:l,onClick:async()=>{u(!0);try{await r()}finally{u(!1),c(!1)}},children:n}),(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:p,disabled:l,children:o(`admin.action.cancel`)})]})]})}function st({id:e}){let{t}=O(),n=u(),r=J(e,t=>A.get(`/incidents/${j(e)}`,t)),[i,a]=(0,D.useState)(null),{pages:o}=N();if(r.data===void 0)return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:`/admin/incidents`,children:t(`admin.incidents.title`)}),r.error===null?(0,M.jsx)(K,{}):(0,M.jsx)(R,{error:r.error,onRetry:r.reload})]});let c=r.data,l=o.find(e=>e.id===c.pageId);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:G(`/admin/incidents`,c.pageId),children:t(`admin.incidents.title`)}),(0,M.jsxs)(W,{title:c.title,actions:(0,M.jsx)(`a`,{className:`button`,href:`/pages/${j(c.pageId)}/incidents/${j(c.id)}`,target:`_blank`,rel:`noopener`,children:t(`admin.incident.viewPublic`)}),children:[(0,M.jsxs)(`p`,{className:`list-item__meta`,children:[(0,M.jsx)(b,{stage:c.stage}),(0,M.jsx)(w,{impact:et(c.components)}),c.autoCreated&&(0,M.jsx)(`span`,{className:`badge badge--unknown`,children:t(`admin.incidents.auto`)})]}),(0,M.jsx)(ct,{incident:c})]}),n.search.get(`created`)===`1`&&(0,M.jsx)(H,{children:t(`admin.incident.created`)}),(0,M.jsxs)(`div`,{className:`columns`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(dt,{incident:c,page:l,onPosted:e=>r.setData(e),onReload:r.reload}),(0,M.jsxs)(`section`,{className:`panel`,"aria-labelledby":`timeline-heading`,children:[(0,M.jsx)(`h2`,{id:`timeline-heading`,className:`panel__title`,children:t(`admin.incident.timeline`)}),(0,M.jsx)(lt,{incident:c})]})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(ut,{incident:c,page:l,onSaved:e=>r.setData({...e,updates:c.updates}),onReload:r.reload},c.id),(0,M.jsxs)(`section`,{className:`panel panel--danger`,"aria-labelledby":`delete-heading`,children:[(0,M.jsx)(`h2`,{id:`delete-heading`,className:`panel__title`,children:t(`admin.incident.deleteTitle`)}),(0,M.jsx)(`p`,{className:`field__hint`,children:t(`admin.incident.deleteHint`)}),(0,M.jsx)(R,{error:i}),(0,M.jsx)(ot,{label:t(`admin.action.delete`),question:t(`admin.incident.deleteQuestion`,{title:c.title}),confirmLabel:t(`admin.action.deleteConfirm`),onConfirm:async()=>{try{await A.delete(`/incidents/${j(c.id)}`),s(G(`/admin/incidents`,c.pageId),{force:!0})}catch(e){a(e)}}})]})]})]})]})}function ct({incident:e}){let{t,f:n}=O();return(0,M.jsxs)(`dl`,{className:`facts`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:t(`admin.page.label`)}),(0,M.jsx)(`dd`,{children:e.pageId})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:t(`admin.incidents.started`)}),(0,M.jsx)(`dd`,{children:n.dateTimeWithZone(e.startedAt)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:t(`admin.incident.createdBy`)}),(0,M.jsx)(`dd`,{children:t(`admin.common.byAt`,{who:e.createdBy??t(`admin.common.automation`),time:n.dateTimeWithZone(e.createdAt)})})]}),e.resolvedAt!==null&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:t(`admin.incidents.resolved`)}),(0,M.jsxs)(`dd`,{children:[n.dateTimeWithZone(e.resolvedAt),` (`,n.duration(e.resolvedAt-e.startedAt),`)`]})]})]})}function lt({incident:e}){let{t,f:n}=O();return(0,M.jsx)(`ol`,{className:`timeline`,children:[...e.updates].reverse().map(e=>(0,M.jsxs)(`li`,{className:`timeline__item`,children:[(0,M.jsxs)(`p`,{className:`timeline__meta`,children:[(0,M.jsx)(b,{stage:e.stage}),(0,M.jsx)(`span`,{children:t(`admin.common.byAt`,{who:e.author??t(`admin.common.automation`),time:n.dateTimeWithZone(e.createdAt)})})]}),(0,M.jsx)(`p`,{className:`timeline__body`,children:e.body})]},e.id))})}function ut({incident:e,page:t,onSaved:n,onReload:r}){let{t:i,f:a}=O(),o=Me(e,e=>({title:e.title,components:tt(t,e.components)})),[s,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(!1),[d,p]=(0,D.useState)(!1),[m,h]=(0,D.useState)([]);U(o.changed.length>0),e.version>o.base.version&&o.conflict===null&&o.refresh(e);let g=new Set(t?.components.map(e=>e.id)),_=e.components.filter(e=>!g.has(e.id)).map(e=>e.id),v=I(s,i);async function y(r){r.preventDefault();let i={version:o.base.version};o.changed.includes(`title`)&&(i.title=o.draft.title);let a=nt(t,o.draft.components);if(o.changed.includes(`components`)&&(i.components=a),i.title!==void 0||i.components!==void 0){h(a),p(!0),c(null),u(!1);try{let t=await A.patch(`/incidents/${j(e.id)}`,i);o.saved(t),n(t),u(!0)}catch(e){o.handleError(e)||c(e)}finally{p(!1)}}}let b=o.conflict;return(0,M.jsxs)(`section`,{className:`panel`,"aria-labelledby":`edit-heading`,children:[(0,M.jsx)(`h2`,{id:`edit-heading`,className:`panel__title`,children:i(`admin.incident.editTitle`)}),b!==null&&(0,M.jsx)(Ne,{conflict:b,label:e=>i(e===`title`?`admin.incident.title`:`admin.incident.components`),value:e=>{let n=b.current;return e===`title`?n.title:n.components.length===0?i(`admin.incident.noneAffected`):a.list(n.components.map(e=>`${t?.components.find(t=>t.id===e.id)?.name??e.id} (${i(`impact.${e.impact}`)})`))},onTakeCurrent:()=>{o.takeCurrent(),r()},onReapply:()=>{o.reapply(),r()}}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void y(e),children:[(0,M.jsx)(R,{error:s}),(0,M.jsx)(z,{issues:F(v,[[`title`],[`components`]])}),l&&o.changed.length===0&&(0,M.jsx)(H,{children:i(`admin.form.saved`)}),(0,M.jsx)(B,{label:i(`admin.incident.title`),errors:P(v,[`title`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`input`,{id:e,"aria-describedby":t,"aria-invalid":n||void 0,required:!0,maxLength:f.title,value:o.draft.title,onChange:e=>{let t=e.target.value;o.setDraft(e=>({...e,title:t}))}})}),(0,M.jsx)(rt,{page:t,value:o.draft.components,onChange:e=>o.setDraft(t=>({...t,components:e})),issues:v,sent:m,unknown:_}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:d||o.changed.length===0||b!==null,children:i(`admin.form.save`)}),o.changed.length>0&&(0,M.jsx)(`span`,{className:`muted`,children:i(`admin.form.unsaved`)})]})]})]})}function dt({incident:e,page:t,onPosted:n,onReload:r}){let{t:i}=O(),[a,o]=(0,D.useState)(e.stage===`resolved`?`monitoring`:e.stage),[s,c]=(0,D.useState)(``),[l,u]=(0,D.useState)(!1),[d,p]=(0,D.useState)(()=>({draft:tt(t,e.components),version:e.version})),[m,h]=(0,D.useState)([]),[g,_]=(0,D.useState)(null),[v,y]=(0,D.useState)(!1),[b,x]=(0,D.useState)(!1),[S,ee]=(0,D.useState)(!1),C=I(g,i),w=a===`resolved`&&e.resolvedAt===null;U(!b&&(s.trim()!==``||l));let T=e=>p({draft:tt(t,e.components),version:e.version});async function E(i){i.preventDefault(),x(!0),_(null),ee(!1),y(!1);try{let r;if(w&&!l)r=await A.post(`/incidents/${j(e.id)}/resolve`,{body:s});else{let n=nt(t,d.draft);h(n),r=await A.post(`/incidents/${j(e.id)}/updates`,{stage:a,body:s,...l?{components:n,version:d.version}:{}})}n(r),c(``),ee(!0),u(!1),T(r),r.stage===`resolved`&&o(`monitoring`)}catch(e){he(e)?(T(e.body.current),y(!0),r()):_(e)}finally{x(!1)}}return(0,M.jsxs)(`section`,{className:`panel`,"aria-labelledby":`update-heading`,children:[(0,M.jsx)(`h2`,{id:`update-heading`,className:`panel__title`,children:i(`admin.incident.postTitle`)}),e.resolvedAt!==null&&(0,M.jsx)(`p`,{className:`field__hint`,children:i(`admin.incident.reopenHint`)}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void E(e),children:[(0,M.jsx)(R,{error:g}),(0,M.jsx)(z,{issues:F(C,[[`stage`],[`body`],[`components`]])}),S&&(0,M.jsx)(H,{children:i(`admin.incident.posted`)}),(0,M.jsx)(it,{value:a,onChange:o,errors:P(C,[`stage`])}),(0,M.jsx)(B,{label:i(`admin.incident.message`),hint:i(`admin.incident.bodyHint`),errors:P(C,[`body`]),children:({id:e,describedBy:t,invalid:n})=>(0,M.jsx)(`textarea`,{id:e,"aria-describedby":t,"aria-invalid":n||void 0,required:!0,rows:4,maxLength:f.body,value:s,onChange:e=>c(e.target.value)})}),(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:l,onChange:t=>{t.target.checked&&T(e),u(t.target.checked)}}),i(`admin.incident.alsoComponents`)]}),v&&(0,M.jsx)(`p`,{className:`alert alert--warning`,role:`alert`,children:i(`admin.incident.componentsChanged`)}),l&&(0,M.jsx)(rt,{page:t,value:d.draft,onChange:e=>p(t=>({...t,draft:e})),issues:C,sent:m}),(0,M.jsx)(`div`,{className:`actions`,children:(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:b,children:i(w?`admin.incident.resolve`:`admin.incident.post`)})})]})]})}var ft=[``,`open`,`resolved`];function pt(){let{t:e,f:t}=O(),{pageId:n,page:r}=Se(),a=u(),o=ft.find(e=>e===a.search.get(`status`))??``,c=qe(`${n}\n${o}`,(e,t)=>A.get(ye(`/incidents`,{page:n,status:o,cursor:e}),t)),l=new Map(r?.components.map(e=>[e.id,e.name]));return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(W,{title:e(`admin.incidents.title`),actions:(0,M.jsx)(S,{className:`button button--primary`,href:G(`/admin/incidents/new`,n),children:e(`admin.incidents.new`)}),children:(0,M.jsxs)(`div`,{className:`filters`,children:[(0,M.jsx)(De,{}),(0,M.jsxs)(`label`,{className:`inline-field`,children:[(0,M.jsx)(`span`,{children:e(`admin.incidents.filter`)}),(0,M.jsx)(`select`,{value:o,onChange:e=>s(i(a.pathname,{page:a.search.get(`page`),status:e.target.value}),{replace:!0,keepScroll:!0}),children:ft.map(t=>(0,M.jsx)(`option`,{value:t,children:e(`admin.incidents.status.${t||`all`}`)},t))})]})]})}),(0,M.jsx)(R,{error:c.error,onRetry:c.reload}),c.items.length===0&&c.loading?(0,M.jsx)(K,{}):c.items.length===0&&c.error===null?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.incidents.none`)}):(0,M.jsx)(`ul`,{className:`list`,children:c.items.map(n=>(0,M.jsxs)(`li`,{className:`list-item`,children:[(0,M.jsxs)(`div`,{className:`list-item__main`,children:[(0,M.jsx)(`p`,{className:`list-item__title`,children:(0,M.jsx)(S,{href:`/admin/incidents/${encodeURIComponent(n.id)}`,children:n.title})}),(0,M.jsxs)(`p`,{className:`list-item__meta`,children:[(0,M.jsx)(b,{stage:n.stage}),(0,M.jsx)(w,{impact:et(n.components)}),n.autoCreated&&(0,M.jsx)(`span`,{className:`badge badge--unknown`,children:e(`admin.incidents.auto`)})]}),n.components.length>0&&(0,M.jsx)(`p`,{className:`muted`,children:t.list(n.components.map(t=>`${l.get(t.id)??t.id} (${e(`impact.${t.impact}`)})`))})]}),(0,M.jsxs)(`dl`,{className:`list-item__facts`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e(`admin.incidents.started`)}),(0,M.jsx)(`dd`,{children:t.dateTime(n.startedAt)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:n.resolvedAt===null?e(`admin.incidents.updated`):e(`admin.incidents.resolved`)}),(0,M.jsx)(`dd`,{children:t.dateTime(n.resolvedAt??n.updatedAt)})]})]})]},n.id))}),c.more&&(0,M.jsx)(`p`,{children:(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:c.loadMore,disabled:c.loading,children:c.loading?e(`ui.loading`):e(`admin.list.more`)})})]})}var mt=[[`title`],[`body`],[`startsAt`],[`endsAt`],[`components`],[`pageId`]];function ht(e){return{title:e.title,body:e.body,startsAt:X(e.startsAt),endsAt:X(e.endsAt),components:e.components}}function gt(e){return Qe(e)??-1}function _t({page:e,draft:t,onChange:n,issues:r}){let{t:i,f:a}=O(),o=e=>i(`admin.time.zone`,{timeZone:a.timeZone,offset:a.offset(Qe(e)??Date.now())}),s=e=>Z(e)?[]:[i(`admin.issue.localTimeGap`)],c=(e,t)=>n(n=>({...n,[e]:t}));return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(B,{label:i(`admin.maintenance.fieldTitle`),errors:P(r,[`title`]),children:({id:e,describedBy:n,invalid:r})=>(0,M.jsx)(`input`,{id:e,"aria-describedby":n,"aria-invalid":r||void 0,required:!0,maxLength:f.title,value:t.title,onChange:e=>c(`title`,e.target.value)})}),(0,M.jsxs)(`div`,{className:`field-row`,children:[(0,M.jsx)(B,{label:i(`admin.maintenance.startsAt`),hint:o(t.startsAt),errors:[...s(t.startsAt),...P(r,[`startsAt`])],children:({id:e,describedBy:n,invalid:r})=>(0,M.jsx)(`input`,{id:e,type:`datetime-local`,"aria-describedby":n,"aria-invalid":r||void 0,required:!0,value:t.startsAt,onChange:e=>c(`startsAt`,e.target.value)})}),(0,M.jsx)(B,{label:i(`admin.maintenance.endsAt`),hint:o(t.endsAt),errors:[...s(t.endsAt),...P(r,[`endsAt`])],children:({id:e,describedBy:n,invalid:r})=>(0,M.jsx)(`input`,{id:e,type:`datetime-local`,"aria-describedby":n,"aria-invalid":r||void 0,required:!0,min:t.startsAt||void 0,value:t.endsAt,onChange:e=>c(`endsAt`,e.target.value)})})]}),(0,M.jsx)(V,{legend:i(`admin.maintenance.components`),hint:i(`admin.maintenance.componentsHint`),errors:P(r,[`components`]),children:(0,M.jsx)(`div`,{className:`checks`,children:e?.components.map(n=>(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:t.components.includes(n.id),onChange:r=>c(`components`,r.target.checked?e.components.map(e=>e.id).filter(e=>e===n.id||t.components.includes(e)):t.components.filter(e=>e!==n.id))}),n.name]},n.id))})}),(0,M.jsx)(B,{label:i(`admin.maintenance.body`),hint:i(`admin.maintenance.bodyHint`),errors:P(r,[`body`]),children:({id:e,describedBy:n,invalid:r})=>(0,M.jsx)(`textarea`,{id:e,"aria-describedby":n,"aria-invalid":r||void 0,rows:4,maxLength:f.body,value:t.body,onChange:e=>c(`body`,e.target.value)})})]})}function vt(){let{t:e}=O(),{pageId:t,page:n}=Se(),[r]=(0,D.useState)(()=>{let e=Math.ceil(Date.now()/36e5)*36e5;return{title:``,body:``,startsAt:X(e),endsAt:X(e+36e5),components:[]}}),[i,a]=(0,D.useState)(r),[o,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(!1),d=I(o,e);U(!l&&!Ae(i,r));async function f(e){if(e.preventDefault(),!Z(i.startsAt)||!Z(i.endsAt))return;let n={pageId:t,title:i.title,body:i.body,startsAt:gt(i.startsAt),endsAt:gt(i.endsAt),components:[...i.components]};u(!0),c(null);try{let e=await A.post(`/maintenance`,n);s(`/admin/maintenance/${j(e.id)}?created=1`,{force:!0})}catch(e){c(e)}finally{u(!1)}}return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:G(`/admin/maintenance`,t),children:e(`admin.maintenance.title`)}),(0,M.jsx)(W,{title:e(`admin.maintenance.new`),children:(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.maintenance.forPage`,{page:t})})}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void f(e),children:[(0,M.jsx)(R,{error:o}),(0,M.jsx)(z,{issues:F(d,mt)}),(0,M.jsx)(_t,{page:n,draft:i,onChange:e=>a(e),issues:d}),(0,M.jsx)(`div`,{className:`actions`,children:(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:l,children:e(`admin.maintenance.create`)})})]})]})}function yt({id:e}){let{t}=O(),n=J(e,t=>A.get(`/maintenance/${j(e)}`,t));return n.data===void 0?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:`/admin/maintenance`,children:t(`admin.maintenance.title`)}),n.error===null?(0,M.jsx)(K,{}):(0,M.jsx)(R,{error:n.error,onRetry:n.reload})]}):(0,M.jsx)(bt,{maintenance:n.data,onReload:n.reload},n.data.id)}function bt({maintenance:e,onReload:t}){let{t:n,f:r}=O(),{pages:i}=N(),a=i.find(t=>t.id===e.pageId),o=Me(e,ht);e.version>o.base.version&&o.conflict===null&&o.refresh(e);let[s,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(!1),[d,f]=(0,D.useState)(()=>new URLSearchParams(window.location.search).get(`created`)===`1`),p=I(s,n);U(o.changed.length>0);async function m(t){if(t.preventDefault(),!Z(o.draft.startsAt)||!Z(o.draft.endsAt))return;let n={version:o.base.version};for(let e of o.changed)e===`startsAt`||e===`endsAt`?n[e]=gt(o.draft[e]):e===`components`?n.components=[...o.draft.components]:n[e]=o.draft[e];u(!0),c(null),f(!1);try{o.saved(await A.patch(`/maintenance/${j(e.id)}`,n)),f(!0)}catch(e){o.handleError(e)||c(e)}finally{u(!1)}}let h=o.conflict,g={title:n(`admin.maintenance.fieldTitle`),body:n(`admin.maintenance.body`),startsAt:n(`admin.maintenance.startsAt`),endsAt:n(`admin.maintenance.endsAt`),components:n(`admin.maintenance.components`)};return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:G(`/admin/maintenance`,e.pageId),children:n(`admin.maintenance.title`)}),(0,M.jsx)(W,{title:o.base.title,children:(0,M.jsxs)(`p`,{className:`field__hint`,children:[n(`admin.maintenance.forPage`,{page:e.pageId}),` `,n(`admin.common.lastChange`,{who:o.base.updatedBy??n(`admin.common.automation`),time:r.dateTimeWithZone(o.base.updatedAt)})]})}),h!==null&&(0,M.jsx)(Ne,{conflict:h,label:e=>g[e]??e,value:e=>{let t=h.current;switch(e){case`startsAt`:case`endsAt`:return r.dateTimeWithZone(t[e]);case`components`:return r.list(t.components.map(e=>a?.components.find(t=>t.id===e)?.name??e));case`title`:return t.title;default:return t.body}},onTakeCurrent:()=>{o.takeCurrent(),t()},onReapply:()=>{o.reapply(),t()}}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void m(e),children:[(0,M.jsx)(R,{error:s}),(0,M.jsx)(z,{issues:F(p,mt)}),d&&o.changed.length===0&&(0,M.jsx)(H,{children:n(`admin.form.saved`)}),(0,M.jsx)(_t,{page:a,draft:o.draft,onChange:o.setDraft,issues:p}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:l||o.changed.length===0||h!==null,children:n(`admin.form.save`)}),o.changed.length>0&&(0,M.jsx)(`span`,{className:`muted`,children:n(`admin.form.unsaved`)})]})]}),(0,M.jsxs)(`section`,{className:`panel panel--danger`,"aria-labelledby":`delete-heading`,children:[(0,M.jsx)(`h2`,{id:`delete-heading`,className:`panel__title`,children:n(`admin.maintenance.deleteTitle`)}),(0,M.jsx)(xt,{maintenance:e})]})]})}function xt({maintenance:e}){let{t}=O(),[n,r]=(0,D.useState)(null);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(R,{error:n}),(0,M.jsx)(ot,{label:t(`admin.action.delete`),question:t(`admin.maintenance.deleteQuestion`,{title:e.title}),confirmLabel:t(`admin.action.deleteConfirm`),onConfirm:async()=>{try{await A.delete(`/maintenance/${j(e.id)}`),s(G(`/admin/maintenance`,e.pageId),{force:!0})}catch(e){r(e)}}})]})}function St(e,t){return t<e.startsAt?`upcoming`:t<e.endsAt?`active`:`ended`}var Ct={upcoming:`badge--unknown`,active:`badge--maintenance`,ended:`badge--stage`};function wt(){let{t:e,f:t}=O(),{pageId:n,page:r}=Se(),i=qe(n,(e,t)=>A.get(ye(`/maintenance`,{page:n,cursor:e}),t)),a=new Map(r?.components.map(e=>[e.id,e.name])),o=Date.now();return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(W,{title:e(`admin.maintenance.title`),actions:(0,M.jsx)(S,{className:`button button--primary`,href:G(`/admin/maintenance/new`,n),children:e(`admin.maintenance.new`)}),children:[(0,M.jsx)(`div`,{className:`filters`,children:(0,M.jsx)(De,{})}),(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.maintenance.intro`)})]}),(0,M.jsx)(R,{error:i.error,onRetry:i.reload}),i.items.length===0&&i.loading?(0,M.jsx)(K,{}):i.items.length===0&&i.error===null?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.maintenance.none`)}):(0,M.jsx)(`ul`,{className:`list`,children:i.items.map(n=>{let r=St(n,o);return(0,M.jsxs)(`li`,{className:`list-item`,children:[(0,M.jsxs)(`div`,{className:`list-item__main`,children:[(0,M.jsx)(`p`,{className:`list-item__title`,children:(0,M.jsx)(S,{href:`/admin/maintenance/${encodeURIComponent(n.id)}`,children:n.title})}),(0,M.jsx)(`p`,{className:`list-item__meta`,children:(0,M.jsx)(`span`,{className:`badge ${Ct[r]}`,children:e(`admin.maintenance.phase.${r}`)})}),(0,M.jsx)(`p`,{className:`muted`,children:t.list(n.components.map(e=>a.get(e)??e))})]}),(0,M.jsxs)(`dl`,{className:`list-item__facts`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e(`admin.maintenance.startsAt`)}),(0,M.jsx)(`dd`,{children:t.dateTime(n.startsAt)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:e(`admin.maintenance.endsAt`)}),(0,M.jsx)(`dd`,{children:t.dateTime(n.endsAt)})]})]})]},n.id)})}),i.more&&(0,M.jsx)(`p`,{children:(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:i.loadMore,disabled:i.loading,children:i.loading?e(`ui.loading`):e(`admin.list.more`)})})]})}function Tt(){let{t:e}=O(),t=J(`monitors`,e=>A.get(`/monitors`,e)),[n,r]=(0,D.useState)(null),i=t.data?.monitors??[],a=i.filter(e=>e.configured),o=i.filter(e=>!e.configured);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(W,{title:e(`admin.monitors.title`),actions:(0,M.jsx)(`button`,{type:`button`,className:`button`,onClick:t.reload,disabled:t.loading,children:e(`admin.action.refresh`)}),children:(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.monitors.intro`)})}),(0,M.jsx)(R,{error:t.error,onRetry:t.reload}),n!==null&&(0,M.jsx)(H,{children:e(`admin.monitors.purged`,{id:n})}),t.data===void 0?t.error===null&&(0,M.jsx)(K,{}):(0,M.jsxs)(M.Fragment,{children:[a.length===0?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.monitors.none`)}):(0,M.jsx)(`ul`,{className:`list`,children:a.map(e=>(0,M.jsx)(Ot,{monitor:e},e.id))}),(0,M.jsxs)(`section`,{className:`section-block`,"aria-labelledby":`removed-heading`,children:[(0,M.jsx)(`h2`,{id:`removed-heading`,className:`panel__title`,children:e(`admin.monitors.removedTitle`)}),(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.monitors.removedIntro`)}),o.length===0?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.monitors.removedNone`)}):(0,M.jsx)(`ul`,{className:`list`,children:o.map(e=>(0,M.jsx)(Ot,{monitor:e,onPurged:()=>{r(e.id),t.reload()}},e.id))})]})]})]})}var Et={configured:`admin.monitors.purgeRefused.configured`,running:`admin.monitors.purgeRefused.running`,deploying:`admin.monitors.purgeRefused.deploying`};function Dt(e,t){if(!(e instanceof k)||e.code!==`purge_refused`)return L(e,t);let n=e.body?.reason,r=typeof n==`string`?Et[n]:void 0;return r===void 0?t(`admin.monitors.purgeRefused`,{reason:e.message}):t(r)}function Ot({monitor:e,onPurged:t}){let{t:n,f:r}=O(),[i,a]=(0,D.useState)(null),o=e.snapshot,s=Date.now(),c=o===null?null:ue(o,e.config?.timeoutMs??0,s),l=o?.lastCheck??null;return(0,M.jsxs)(`li`,{className:`list-item`,children:[(0,M.jsxs)(`div`,{className:`list-item__main`,children:[(0,M.jsxs)(`p`,{className:`list-item__title`,children:[e.config?.name??e.id,` `,(0,M.jsx)(`code`,{className:`muted`,children:e.id})]}),(0,M.jsx)(`p`,{className:`list-item__meta`,children:c===null?(0,M.jsx)(`span`,{className:`muted`,children:n(`admin.monitors.noSnapshot`)}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(p,{state:c.state}),c.unknownReason!==null&&(0,M.jsx)(`span`,{className:`muted`,children:n(`admin.monitors.unknown.${c.unknownReason}`)}),o?.current!==null&&o?.current!==void 0&&c.unknownReason===null&&(0,M.jsx)(`span`,{className:`muted`,children:n(`admin.monitors.since`,{time:r.dateTime(o.current.since)})})]})}),l!==null&&(0,M.jsxs)(`p`,{className:`muted`,children:[n(`admin.monitors.lastCheck`,{time:r.relative(l.at,s),result:l.state===null?n(`admin.monitors.noResult`):n(`public.state.${l.state}`)}),l.latencyMs!==null&&` · ${n(`admin.monitors.latency`,{ms:l.latencyMs})}`,l.message!==null&&l.message!==``&&(0,M.jsxs)(M.Fragment,{children:[` · `,(0,M.jsx)(`span`,{className:`mono`,children:l.message})]})]}),e.snapshotError!==null&&(0,M.jsx)(`p`,{className:`error-text`,children:n(`admin.monitors.snapshotError`,{error:e.snapshotError})}),e.components.length>0&&(0,M.jsx)(`p`,{className:`muted`,children:n(`admin.monitors.components`,{components:r.list(e.components.map(e=>`${e.pageId}/${e.componentId}`))})})]}),(0,M.jsxs)(`dl`,{className:`list-item__facts`,children:[e.config!==null&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:n(`admin.monitors.type`)}),(0,M.jsx)(`dd`,{children:e.config.type})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:n(`admin.monitors.interval`)}),(0,M.jsx)(`dd`,{children:r.duration(e.config.intervalMs)})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:n(`admin.monitors.location`)}),(0,M.jsx)(`dd`,{children:e.config.location??e.registry?.location??n(`admin.monitors.locationAuto`)})]})]}),e.registry?.status===`removed`&&(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`dt`,{children:n(`admin.monitors.removedAt`)}),(0,M.jsx)(`dd`,{children:r.dateTime(e.registry.statusChangedAt)})]})]}),t!==void 0&&(0,M.jsxs)(`div`,{className:`list-item__actions`,children:[i!==null&&(0,M.jsx)(`p`,{role:`alert`,className:`error-text`,children:Dt(i,n)}),(0,M.jsx)(ot,{label:n(`admin.monitors.purge`),question:n(`admin.monitors.purgeQuestion`,{id:e.id}),confirmLabel:n(`admin.monitors.purgeConfirm`),onConfirm:async()=>{a(null);try{await A.delete(`/monitors/${j(e.id)}`),t()}catch(e){a(e)}}})]})]})}function kt({fields:e,draft:t,onChange:n,saved:r,issues:i,clientErrors:a,texts:o=()=>void 0}){let s=(e,r)=>n({...t,values:{...t.values,[e]:r}}),c=(r,i)=>n({values:{...t.values,[r]:i===`replace`?t.values[r]??``:At(e,r)},secrets:{...t.secrets,[r]:i}});return(0,M.jsx)(M.Fragment,{children:e.map(e=>(0,M.jsx)(jt,{field:{...e,label:o(`${e.key}.title`)??e.label,description:o(`${e.key}.description`)??e.description},value:t.values[e.key],mode:e.secret?t.secrets[e.key]??`replace`:null,isSet:r?.secrets[e.key]??null,errors:[...P(i,[`options`,e.key]),...a[e.key]?[a[e.key]]:[]],onValue:t=>s(e.key,t),onMode:t=>c(e.key,t),creating:r===null},e.key))})}function At(e,t){let n=e.find(e=>e.key===t);return n?.kind===`map`?[]:n?.kind!==`boolean`&&``}function jt({field:e,value:t,mode:n,isSet:r,errors:i,creating:a,onValue:o,onMode:s}){let{t:c}=O(),l=(0,M.jsxs)(M.Fragment,{children:[e.label,e.required?null:(0,M.jsxs)(`span`,{className:`field__optional`,children:[` `,c(`admin.form.optional`)]}),e.secret&&(0,M.jsx)(`span`,{className:`badge badge--unknown`,children:c(`admin.targets.secret`)})]}),u=[e.description,e.secret?c(`admin.targets.secretHint`):null].filter(Boolean).join(` `)||void 0;if(e.secret&&!a&&n!==`replace`)return(0,M.jsxs)(`div`,{className:`field${i.length>0?` field--invalid`:``}`,children:[(0,M.jsx)(`p`,{className:`field__label`,children:l}),(0,M.jsxs)(`p`,{className:`secret-state`,children:[n===`remove`?(0,M.jsx)(`span`,{children:c(`admin.targets.secretWillBeRemoved`)}):r?(0,M.jsx)(`span`,{className:`badge badge--up`,children:c(`admin.targets.secretSet`)}):(0,M.jsx)(`span`,{className:`badge badge--unknown`,children:c(`admin.targets.secretNotSet`)}),n===`remove`?(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>s(`keep`),children:c(`admin.targets.secretUndo`)}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>s(`replace`),children:c(r?`admin.targets.secretReplace`:`admin.targets.secretEnter`)}),r&&!e.required&&(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>s(`remove`),children:c(`admin.targets.secretRemove`)})]})]}),u!==void 0&&(0,M.jsx)(`p`,{className:`field__hint`,children:u}),(0,M.jsx)(Ee,{errors:i})]});let d=e.secret&&!a?(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>s(`keep`),children:c(`admin.targets.secretKeep`)}):null;if(e.kind===`map`){let n=Array.isArray(t)?t:[];return(0,M.jsxs)(`fieldset`,{className:`fieldset${i.length>0?` field--invalid`:``}`,children:[(0,M.jsx)(`legend`,{className:`field__label`,children:l}),u!==void 0&&(0,M.jsx)(`p`,{className:`field__hint`,children:u}),n.map((t,r)=>(0,M.jsxs)(`div`,{className:`map-row`,children:[(0,M.jsx)(`input`,{"aria-label":c(`admin.targets.mapKey`,{index:r+1}),value:t.key,autoComplete:`off`,onChange:e=>o(n.map((t,n)=>n===r?{...t,key:e.target.value}:t))}),(0,M.jsx)(`input`,{"aria-label":c(`admin.targets.mapValue`,{index:r+1}),value:t.value,type:e.secret?`password`:`text`,autoComplete:`off`,maxLength:e.valueMaxLength??void 0,onChange:e=>o(n.map((t,n)=>n===r?{...t,value:e.target.value}:t))}),(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>o(n.filter((e,t)=>t!==r)),children:c(`admin.targets.mapRemove`)})]},r)),(0,M.jsxs)(`p`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>o([...n,{key:``,value:``}]),children:c(`admin.targets.mapAdd`)}),d]}),(0,M.jsx)(Ee,{errors:i})]})}if(e.kind===`boolean`)return(0,M.jsxs)(`div`,{className:`field field--check${i.length>0?` field--invalid`:``}`,children:[(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:t===!0,onChange:e=>o(e.target.checked)}),l]}),u!==void 0&&(0,M.jsx)(`p`,{className:`field__hint`,children:u}),(0,M.jsx)(Ee,{errors:i})]});let f=typeof t==`string`?t:``;return(0,M.jsx)(B,{label:l,hint:u,errors:i,children:({id:t,describedBy:n,invalid:r})=>{let i={id:t,"aria-describedby":n,"aria-invalid":r||void 0,required:e.required},a;return a=e.kind===`choice`?(0,M.jsxs)(`select`,{...i,value:f,onChange:e=>o(e.target.value),children:[!e.required&&(0,M.jsx)(`option`,{value:``,children:c(`admin.form.none`)}),e.options.map((e,t)=>(0,M.jsx)(`option`,{value:String(t),children:String(e)},String(e)))]}):e.kind===`json`?(0,M.jsx)(`textarea`,{...i,rows:4,className:`mono`,value:f,onChange:e=>o(e.target.value)}):e.kind===`number`?(0,M.jsx)(`input`,{...i,type:`number`,step:e.integer?1:`any`,min:e.minimum??void 0,max:e.maximum??void 0,value:f,onChange:e=>o(e.target.value)}):(0,M.jsx)(`input`,{...i,type:e.secret?`password`:e.inputType,autoComplete:e.secret?`new-password`:`off`,spellCheck:!1,minLength:e.minLength??void 0,maxLength:e.maxLength??void 0,value:f,onChange:e=>o(e.target.value)}),d===null?a:(0,M.jsxs)(`div`,{className:`input-row`,children:[a,d]})}})}function Q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var $=e=>typeof e==`number`&&Number.isFinite(e)?e:null,Mt=e=>typeof e==`string`?e:null,Nt=e=>[`string`,`number`,`boolean`].includes(typeof e);function Pt(e){let t=e.type;if(Array.isArray(t)&&t.includes(`null`)){let n=t.filter(e=>e!==`null`);return{schema:{...e,type:n.length===1?n[0]:n},nullable:!0}}for(let t of[`anyOf`,`oneOf`]){let n=e[t];if(!Array.isArray(n))continue;let r=n.filter(e=>!(Q(e)&&e.type===`null`));if(r.length===n.length-1&&r.length===1&&Q(r[0])){let{[t]:n,...i}=e;return{schema:{...i,...r[0]},nullable:!0}}}return{schema:e,nullable:!1}}function Ft(e){let t=e.enum;if(Array.isArray(t)&&t.length>0&&t.every(Nt))return[...t];if(Nt(e.const))return[e.const];for(let t of[`anyOf`,`oneOf`]){let n=e[t];if(!Array.isArray(n)||n.length===0)continue;let r=n.map(e=>Q(e)?Ft(e):null);if(r.every(e=>e!==null))return r.flat()}return null}function It(e,t,n,r){let{schema:i,nullable:a}=Pt(t),o={key:e,label:Mt(i.title)??Lt(e),description:Mt(i.description),required:n&&!a,secret:r||i.writeOnly===!0||t.writeOnly===!0},s=i.default,c=Ft(i);if(c!==null)return{...o,kind:`choice`,options:c,defaultValue:Nt(s)?s:null};switch(i.type){case`string`:{let e=Mt(i.format);return{...o,kind:`text`,inputType:e===`uri`||e===`url`?`url`:e===`email`?`email`:`text`,minLength:$(i.minLength),maxLength:$(i.maxLength),pattern:Mt(i.pattern),defaultValue:Mt(s)}}case`number`:case`integer`:return{...o,kind:`number`,integer:i.type===`integer`,minimum:$(i.minimum)??$(i.exclusiveMinimum),maximum:$(i.maximum)??$(i.exclusiveMaximum),defaultValue:$(s)};case`boolean`:return{...o,kind:`boolean`,defaultValue:typeof s==`boolean`?s:null};case`object`:{let e=i.additionalProperties;return!(Q(i.properties)&&Object.keys(i.properties).length>0)&&Q(e)&&e.type===`string`?{...o,kind:`map`,valueMaxLength:$(e.maxLength)}:{...o,kind:`json`}}default:return{...o,kind:`json`}}}function Lt(e){let t=e.replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/[_-]+/g,` `).trim().split(/\s+/).map(e=>/^(id|url|uri|api)$/i.test(e)?e.toUpperCase():e.toLowerCase()).join(` `);return t.charAt(0).toUpperCase()+t.slice(1)}function Rt(e,t,r){return e[n(t,Object.keys(e))]?.[r]??e.en?.[r]}function zt(e,t=[]){if(!Q(e)||!Q(e.properties))return[];let n=new Set(Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[]);return Object.entries(e.properties).map(([e,r])=>It(e,Q(r)?r:{},n.has(e),t.includes(e)))}function Bt(e){return e.kind===`boolean`?e.defaultValue??!1:e.kind===`map`?[]:``}function Vt(e,t){if(t==null)return Bt(e);switch(e.kind){case`boolean`:return t===!0;case`map`:return Q(t)?Object.entries(t).map(([e,t])=>({key:e,value:String(t)})):[];case`choice`:{let n=e.options.findIndex(e=>e===t);return n===-1?``:String(n)}case`json`:return JSON.stringify(t,null,2);default:return String(t)}}function Ht(e,t){let n={},r={};for(let i of e)i.secret?(n[i.key]=Bt(i),r[i.key]=t===null?`replace`:`keep`):t===null?n[i.key]=`defaultValue`in i?Vt(i,i.defaultValue):Bt(i):n[i.key]=Vt(i,t.options[i.key]);return{values:n,secrets:r}}function Ut(e,t){try{return new RegExp(e,`u`).test(t)}catch{return!0}}function Wt(e,t){if(t===void 0)return{ok:!0,value:void 0};switch(e.kind){case`boolean`:return{ok:!0,value:t===!0};case`map`:{let e=Array.isArray(t)?t.filter(e=>e.key.trim()!==``):[];return{ok:!0,value:e.length===0?void 0:Object.fromEntries(e.map(e=>[e.key.trim(),e.value]))}}default:{let n=typeof t==`string`?t:``;if(n.trim()===``)return{ok:!0,value:void 0};if(e.kind===`number`){let e=Number(n);return Number.isFinite(e)?{ok:!0,value:e}:{ok:!1,error:`number`}}if(e.kind===`choice`)return{ok:!0,value:e.options[Number(n)]};if(e.kind===`text`&&e.pattern!==null&&!Ut(e.pattern,n))return{ok:!1,error:`pattern`};if(e.kind===`json`)try{return{ok:!0,value:JSON.parse(n)}}catch{return{ok:!1,error:`json`}}return{ok:!0,value:n}}}}function Gt(e,t,n){let r={},i={};for(let a of e){let e=a.secret?t.secrets[a.key]??`replace`:null;if(e===`keep`)continue;if(e===`remove`){n?.secrets[a.key]===!0&&(r[a.key]=null);continue}let o=Wt(a,t.values[a.key]);if(!o.ok)i[a.key]=o.error;else if(n===null)o.value!==void 0&&(r[a.key]=o.value);else if(a.secret)o.value===void 0?i[a.key]=`secretMissing`:r[a.key]=o.value;else{let e=n.options[a.key],t=o.value;JSON.stringify(e??null)!==JSON.stringify(t??null)&&(r[a.key]=t??null)}}return Object.keys(i).length>0?{ok:!1,errors:i}:{ok:!0,options:r}}var Kt=[[`name`],[`kind`],[`admin`],[`enabled`],[`events`],[`allMonitors`],[`monitors`],[`components`],[`options`]],qt={number:`admin.targets.invalidNumber`,json:`admin.targets.invalidJson`,pattern:`admin.issue.format`,secretMissing:`admin.targets.secretMissing`};function Jt(e,t){return Rt(e.messages,t,`$kind`)??e.name}function Yt(){return J(`kinds`,e=>A.get(`/notifications/kinds`,e))}function Xt(){return J(`monitors`,e=>A.get(`/monitors`,e))}function Zt(){let{t:e,locale:t}=O(),n=Yt(),r=Xt(),[i,a]=(0,D.useState)(null),o=n.data?.kinds.find(e=>e.type===(i??n.data?.kinds[0]?.type));return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:`/admin/notifications`,children:e(`admin.targets.title`)}),(0,M.jsx)(W,{title:e(`admin.targets.new`)}),n.data===void 0?n.error===null?(0,M.jsx)(K,{}):(0,M.jsx)(R,{error:n.error,onRetry:n.reload}):n.data.kinds.length===0||o===void 0?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.targets.noKinds`)}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`form form--lead`,children:(0,M.jsx)(B,{label:e(`admin.targets.kind`),hint:e(`admin.targets.kindHint`),children:({id:e,describedBy:r})=>(0,M.jsx)(`select`,{id:e,"aria-describedby":r,value:o.type,onChange:e=>a(e.target.value),children:n.data?.kinds.map(e=>(0,M.jsx)(`option`,{value:e.type,children:Jt(e,t)},e.type))})})}),(0,M.jsx)(en,{kind:o,target:null,monitorIds:r.data?.monitors.filter(e=>e.configured).map(e=>e.id)??[],encryption:n.data.encryption.configured},o.type)]})]})}function Qt({id:e}){let{t,locale:n}=O(),r=Yt(),i=Xt(),a=J(e,t=>A.get(`/notifications/targets/${j(e)}`,t)),o=a.error??r.error;if(a.data===void 0||r.data===void 0)return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:`/admin/notifications`,children:t(`admin.targets.title`)}),o===null?(0,M.jsx)(K,{}):(0,M.jsx)(R,{error:o,onRetry:()=>{a.reload(),r.reload()}})]});let s=a.data,c=r.data.kinds.find(e=>e.type===s.kind);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(q,{href:`/admin/notifications`,children:t(`admin.targets.title`)}),(0,M.jsx)(W,{title:s.name,children:(0,M.jsx)(`p`,{className:`field__hint`,children:t(`admin.targets.kindIs`,{kind:c===void 0?s.kind:Jt(c,n)})})}),c===void 0?(0,M.jsx)(`p`,{className:`alert alert--warning`,children:t(`admin.targets.kindGone`,{kind:s.kind})}):(0,M.jsx)(en,{kind:c,target:s,monitorIds:i.data?.monitors.filter(e=>e.configured).map(e=>e.id)??[],encryption:r.data.encryption.configured,onReload:a.reload},s.id),(0,M.jsx)(an,{target:s}),(0,M.jsxs)(`section`,{className:`panel panel--danger`,"aria-labelledby":`delete-heading`,children:[(0,M.jsx)(`h2`,{id:`delete-heading`,className:`panel__title`,children:t(`admin.targets.deleteTitle`)}),(0,M.jsx)(on,{target:s})]})]})}function $t(e){return t=>({name:t.name,admin:t.admin,enabled:t.enabled,events:t.events,allMonitors:t.allMonitors,monitors:t.monitors,components:t.components,options:Ht(e,t)})}function en(e){let t=(0,D.useMemo)(()=>zt(e.kind.optionsSchema,e.kind.secretOptions),[e.kind]);return e.target===null?(0,M.jsx)(tn,{...e,fields:t}):(0,M.jsx)(nn,{...e,target:e.target,fields:t})}function tn({kind:e,fields:t,monitorIds:n,encryption:r}){let{t:i}=O(),[a]=(0,D.useState)(()=>({name:``,admin:!1,enabled:!0,events:E,allMonitors:!0,monitors:[],components:[],options:Ht(t,null)})),[o,c]=(0,D.useState)(a),[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)({}),[p,m]=(0,D.useState)(!1);U(!p&&!Ae(o,a));async function h(n){n.preventDefault();let r=Gt(t,o.options,null);if(!r.ok){f(Object.fromEntries(Object.entries(r.errors).map(([e,t])=>[e,i(qt[t])])));return}f({});let a={name:o.name,kind:e.type,options:r.options,admin:o.admin,enabled:o.enabled,events:[...o.events],allMonitors:o.allMonitors,monitors:o.allMonitors?[]:[...o.monitors],components:o.allMonitors?[]:[...o.components]};m(!0),u(null);try{let e=await A.post(`/notifications/targets`,a);s(`/admin/notifications/${j(e.id)}?created=1`,{force:!0})}catch(e){u(e)}finally{m(!1)}}return(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void h(e),children:[!r&&e.secretOptions.length>0&&(0,M.jsx)(`p`,{className:`alert alert--warning`,children:i(`admin.targets.noKeyForm`)}),(0,M.jsx)(R,{error:l}),(0,M.jsx)(z,{issues:F(I(l,i),Kt)}),(0,M.jsx)(rn,{kind:e,fields:t,draft:o,onChange:e=>c(e),issues:I(l,i),clientErrors:d,target:null,monitorIds:n}),(0,M.jsx)(`div`,{className:`actions`,children:(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:p,children:i(`admin.targets.create`)})})]})}function nn({kind:e,target:t,fields:n,monitorIds:r,encryption:i,onReload:a}){let{t:o,f:s}=O(),c=Me(t,(0,D.useMemo)(()=>$t(n),[n]));t.version>c.base.version&&c.conflict===null&&c.refresh(t);let[l,u]=(0,D.useState)(null),[d,f]=(0,D.useState)({}),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(()=>new URLSearchParams(window.location.search).get(`created`)===`1`);U(c.changed.length>0);async function _(e){e.preventDefault();let r=Gt(n,c.draft.options,c.base);if(!r.ok){f(Object.fromEntries(Object.entries(r.errors).map(([e,t])=>[e,o(qt[t])])));return}f({});let i={version:c.base.version},a=c.draft;for(let e of c.changed)e===`name`?i.name=a.name:e===`admin`?i.admin=a.admin:e===`enabled`?i.enabled=a.enabled:e===`events`?i.events=[...a.events]:e===`allMonitors`?i.allMonitors=a.allMonitors:e===`monitors`?i.monitors=[...a.monitors]:e===`components`&&(i.components=[...a.components]);if(Object.keys(r.options).length>0&&(i.options=r.options),Object.keys(i).length!==1){m(!0),u(null),g(!1);try{c.saved(await A.patch(`/notifications/targets/${j(t.id)}`,i)),g(!0)}catch(e){c.handleError(e)||u(e)}finally{m(!1)}}}let v=c.conflict,y=e=>o(e?`admin.common.yes`:`admin.common.no`);return(0,M.jsxs)(M.Fragment,{children:[v!==null&&(0,M.jsx)(Ne,{conflict:v,label:e=>o(`admin.targets.field.${e}`),value:e=>{let t=v.current;switch(e){case`name`:return t.name;case`admin`:return y(t.admin);case`enabled`:return y(t.enabled);case`events`:return s.list(t.events.map(e=>o(`admin.event.${e}`)));case`allMonitors`:return y(t.allMonitors);case`monitors`:return s.list(t.monitors);case`components`:return s.list(t.components.map(e=>`${e.pageId}/${e.componentId}`));default:return o(`admin.targets.optionsChanged`)}},onTakeCurrent:()=>{c.takeCurrent(),a?.()},onReapply:()=>{c.reapply(),a?.()}}),(0,M.jsxs)(`form`,{className:`form`,onSubmit:e=>void _(e),children:[!i&&e.secretOptions.length>0&&(0,M.jsx)(`p`,{className:`alert alert--warning`,children:o(`admin.targets.noKeyForm`)}),(0,M.jsx)(R,{error:l}),(0,M.jsx)(z,{issues:F(I(l,o),Kt)}),h&&c.changed.length===0&&(0,M.jsx)(H,{children:o(`admin.form.saved`)}),(0,M.jsx)(`p`,{className:`field__hint`,children:o(`admin.common.lastChange`,{who:c.base.updatedBy??o(`admin.common.automation`),time:s.dateTimeWithZone(c.base.updatedAt)})}),(0,M.jsx)(rn,{kind:e,fields:n,draft:c.draft,onChange:c.setDraft,issues:I(l,o),clientErrors:d,target:c.base,monitorIds:r}),(0,M.jsxs)(`div`,{className:`actions`,children:[(0,M.jsx)(`button`,{type:`submit`,className:`button button--primary`,disabled:p||c.changed.length===0||v!==null,children:o(`admin.form.save`)}),c.changed.length>0&&(0,M.jsx)(`span`,{className:`muted`,children:o(`admin.form.unsaved`)})]})]})]})}function rn({kind:e,fields:t,draft:n,onChange:r,issues:i,clientErrors:a,target:o,monitorIds:s}){let{t:c,locale:l}=O(),{pages:u}=N(),d=(e,t)=>r(n=>({...n,[e]:t})),p=(e,t,n,r=Object.is)=>n?[...e.filter(e=>!r(e,t)),t]:e.filter(e=>!r(e,t)),m=(e,t)=>e.pageId===t.pageId&&e.componentId===t.componentId,h=[...new Set([...s,...n.monitors])];return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(B,{label:c(`admin.targets.name`),errors:P(i,[`name`]),children:({id:e,describedBy:t,invalid:r})=>(0,M.jsx)(`input`,{id:e,"aria-describedby":t,"aria-invalid":r||void 0,required:!0,maxLength:f.targetName,value:n.name,onChange:e=>d(`name`,e.target.value)})}),(0,M.jsx)(V,{legend:c(`admin.targets.options`),hint:c(`admin.targets.optionsHint`),children:(0,M.jsx)(kt,{fields:t,draft:n.options,onChange:e=>d(`options`,e),saved:o,issues:i,clientErrors:a,texts:t=>Rt(e.messages,l,t)})}),(0,M.jsxs)(`div`,{className:`checks`,children:[(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:n.enabled,onChange:e=>d(`enabled`,e.target.checked)}),c(`admin.targets.field.enabled`)]}),(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:n.admin,onChange:e=>{let t=e.target.checked;r(e=>({...e,admin:t,events:t?e.events.includes(`unknown`)||o!==null?e.events:[...e.events,`unknown`]:e.events.filter(e=>e!==`unknown`)}))}}),c(`admin.targets.field.admin`)]}),(0,M.jsx)(`p`,{className:`field__hint`,children:c(`admin.targets.adminHint`)})]}),(0,M.jsxs)(V,{legend:c(`admin.targets.field.events`),errors:P(i,[`events`]),children:[(0,M.jsx)(`div`,{className:`checks`,children:de.map(e=>(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:n.events.includes(e),disabled:e===`unknown`&&!n.admin,onChange:t=>d(`events`,p(n.events,e,t.target.checked))}),c(`admin.event.${e}`)]},e))}),!n.admin&&(0,M.jsx)(`p`,{className:`field__hint`,children:c(`admin.targets.unknownHint`)})]}),(0,M.jsxs)(V,{legend:c(`admin.targets.coverage`),errors:[...P(i,[`allMonitors`]),...P(i,[`monitors`]),...P(i,[`components`])],children:[(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`radio`,name:`coverage`,checked:n.allMonitors,onChange:()=>d(`allMonitors`,!0)}),c(`admin.targets.allMonitors`)]}),(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`radio`,name:`coverage`,checked:!n.allMonitors,onChange:()=>d(`allMonitors`,!1)}),c(`admin.targets.chosenMonitors`)]}),!n.allMonitors&&(0,M.jsxs)(`div`,{className:`nested`,children:[(0,M.jsx)(`p`,{className:`field__label`,children:c(`admin.targets.field.monitors`)}),(0,M.jsxs)(`div`,{className:`checks`,children:[h.length===0&&(0,M.jsx)(`p`,{className:`muted`,children:c(`admin.monitors.none`)}),h.map(e=>(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:n.monitors.includes(e),onChange:t=>d(`monitors`,p(n.monitors,e,t.target.checked))}),(0,M.jsx)(`code`,{children:e})]},e))]}),(0,M.jsx)(`p`,{className:`field__label`,children:c(`admin.targets.field.components`)}),(0,M.jsx)(`p`,{className:`field__hint`,children:c(`admin.targets.componentsHint`)}),u.map(e=>(0,M.jsx)(`div`,{className:`checks`,children:e.components.map(t=>{let r={pageId:e.id,componentId:t.id};return(0,M.jsxs)(`label`,{className:`check`,children:[(0,M.jsx)(`input`,{type:`checkbox`,checked:n.components.some(e=>m(e,r)),onChange:e=>d(`components`,p(n.components,r,e.target.checked,m))}),u.length>1?`${e.id} / ${t.name}`:t.name]},t.id)})},e.id))]})]})]})}function an({target:e}){let{t}=O(),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null);return(0,M.jsxs)(`section`,{className:`panel`,"aria-labelledby":`test-heading`,children:[(0,M.jsx)(`h2`,{id:`test-heading`,className:`panel__title`,children:t(`admin.targets.testTitle`)}),(0,M.jsx)(`p`,{className:`field__hint`,children:t(`admin.targets.testHint`)}),(0,M.jsx)(`p`,{className:`actions`,children:(0,M.jsx)(`button`,{type:`button`,className:`button`,disabled:n,onClick:async()=>{r(!0),a(null);try{let n=await A.post(`/notifications/targets/${j(e.id)}/test`,{});a(n.ok?{ok:!0,text:t(`admin.targets.testOk`)}:{ok:!1,text:t(`admin.targets.testFailed`,{error:n.error??``})})}catch(e){a({ok:!1,text:L(e,t)})}finally{r(!1)}},children:t(n?`admin.targets.testing`:`admin.targets.test`)})}),i!==null&&(0,M.jsx)(`p`,{role:`status`,className:i.ok?`success-text`:`error-text`,children:i.text})]})}function on({target:e}){let{t}=O(),[n,r]=(0,D.useState)(null);return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(R,{error:n}),(0,M.jsx)(ot,{label:t(`admin.action.delete`),question:t(`admin.targets.deleteQuestion`,{name:e.name}),confirmLabel:t(`admin.action.deleteConfirm`),onConfirm:async()=>{try{await A.delete(`/notifications/targets/${j(e.id)}`),s(`/admin/notifications`,{force:!0})}catch(e){r(e)}}})]})}function sn(){let{t:e,locale:t}=O(),n=J(`targets`,e=>A.get(`/notifications/targets`,e)),r=J(`kinds`,e=>A.get(`/notifications/kinds`,e)),i=e=>{let n=r.data?.kinds.find(t=>t.type===e);return n===void 0?e:Jt(n,t)};return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(W,{title:e(`admin.targets.title`),actions:(0,M.jsx)(S,{className:`button button--primary`,href:`/admin/notifications/new`,children:e(`admin.targets.new`)}),children:(0,M.jsx)(`p`,{className:`field__hint`,children:e(`admin.targets.intro`)})}),r.data!==void 0&&!r.data.encryption.configured&&(0,M.jsx)(`div`,{className:`alert alert--warning`,role:`status`,children:(0,M.jsx)(`p`,{children:e(`admin.targets.noKey`,{error:r.data.encryption.error??``})})}),(0,M.jsx)(R,{error:n.error??r.error,onRetry:()=>{n.reload(),r.reload()}}),n.data===void 0?n.error===null&&(0,M.jsx)(K,{}):n.data.items.length===0?(0,M.jsx)(`p`,{className:`empty`,children:e(`admin.targets.none`)}):(0,M.jsx)(`ul`,{className:`list`,children:n.data.items.map(e=>(0,M.jsx)(cn,{target:e,kindName:i(e.kind),onChanged:e=>n.setData({items:(n.data?.items??[]).map(t=>t.id===e.id?e:t),nextCursor:null})},e.id))})]})}function cn({target:e,kindName:t,onChanged:n}){let{t:r,f:i}=O(),[a,o]=(0,D.useState)(!1),[s,c]=(0,D.useState)(null);async function l(){o(!0),c(null);try{n(await A.patch(`/notifications/targets/${j(e.id)}`,{version:e.version,enabled:!e.enabled}))}catch(e){he(e)?(n(e.body.current),c({ok:!1,text:r(`admin.targets.toggleConflict`,{who:e.body.current.updatedBy??`—`})})):c({ok:!1,text:L(e,r)})}finally{o(!1)}}async function u(){o(!0),c(null);try{let t=await A.post(`/notifications/targets/${j(e.id)}/test`,{});c(t.ok?{ok:!0,text:r(`admin.targets.testOk`)}:{ok:!1,text:r(`admin.targets.testFailed`,{error:t.error??``})})}catch(e){c({ok:!1,text:L(e,r)})}finally{o(!1)}}return(0,M.jsxs)(`li`,{className:`list-item`,children:[(0,M.jsxs)(`div`,{className:`list-item__main`,children:[(0,M.jsx)(`p`,{className:`list-item__title`,children:(0,M.jsx)(S,{href:`/admin/notifications/${j(e.id)}`,children:e.name})}),(0,M.jsxs)(`p`,{className:`list-item__meta`,children:[(0,M.jsx)(`span`,{className:`badge badge--stage`,children:t}),e.admin&&(0,M.jsx)(`span`,{className:`badge badge--maintenance`,children:r(`admin.targets.adminBadge`)}),(0,M.jsx)(`span`,{className:`badge ${e.enabled?`badge--up`:`badge--unknown`}`,children:e.enabled?r(`admin.targets.enabled`):r(`admin.targets.disabled`)})]}),(0,M.jsx)(`p`,{className:`muted`,children:r(`admin.targets.events`,{events:i.list(e.events.map(e=>r(`admin.event.${e}`)))})}),(0,M.jsx)(`p`,{className:`muted`,children:e.allMonitors?r(`admin.targets.allMonitors`):r(`admin.targets.someMonitors`,{monitors:e.monitors.length,components:e.components.length})}),s!==null&&(0,M.jsx)(`p`,{role:`status`,className:s.ok?`success-text`:`error-text`,children:s.text})]}),(0,M.jsxs)(`div`,{className:`list-item__actions`,children:[(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>void u(),disabled:a,children:r(`admin.targets.test`)}),(0,M.jsx)(`button`,{type:`button`,className:`button button--small`,onClick:()=>void l(),disabled:a,children:e.enabled?r(`admin.targets.disable`):r(`admin.targets.enable`)})]})]})}var ln=[{path:`/admin/incidents`,key:`admin.nav.incidents`,perPage:!0},{path:`/admin/maintenance`,key:`admin.nav.maintenance`,perPage:!0},{path:`/admin/monitors`,key:`admin.nav.monitors`,perPage:!1},{path:`/admin/appearance`,key:`admin.nav.appearance`,perPage:!0},{path:`/admin/notifications`,key:`admin.nav.notifications`,perPage:!1},{path:`/admin/deliveries`,key:`admin.nav.deliveries`,perPage:!1}];function un(){let{t:e}=O(),t=J(`me`,e=>A.get(`/me`,e)),n=J(`pages`,e=>A.get(`/pages`,e)),r=u();(0,D.useEffect)(()=>{(r.pathname===`/admin`||r.pathname===`/admin/`)&&s(`/admin/incidents`,{replace:!0})},[r.pathname]);let i=t.error??n.error,a=t.data!==void 0&&n.data!==void 0,o=r.search.get(`page`);return(0,M.jsxs)(`div`,{className:`admin`,children:[(0,M.jsx)(`a`,{className:`skip-link`,href:`#main`,children:e(`ui.skipToContent`)}),(0,M.jsxs)(`header`,{className:`admin-header`,children:[(0,M.jsx)(`p`,{className:`admin-header__brand`,children:(0,M.jsx)(S,{href:`/admin/incidents`,children:e(`admin.title`)})}),(0,M.jsx)(`nav`,{"aria-label":e(`admin.nav.label`),className:`admin-nav`,children:(0,M.jsx)(`ul`,{children:ln.map(t=>{let n=r.pathname===t.path||r.pathname.startsWith(`${t.path}/`);return(0,M.jsx)(`li`,{children:(0,M.jsx)(S,{href:t.perPage&&o!==null?`${t.path}?page=${encodeURIComponent(o)}`:t.path,"aria-current":n?`page`:void 0,children:e(t.key)})},t.path)})})}),(0,M.jsxs)(`div`,{className:`admin-header__meta`,children:[t.data!==void 0&&(0,M.jsx)(`span`,{className:`muted`,children:e(`admin.signedInAs`,{name:t.data.author??t.data.identity.id})}),(0,M.jsx)(`a`,{href:`/`,className:`muted`,children:e(`admin.viewStatusPage`)}),(0,M.jsx)(m,{className:`language`})]})]}),(0,M.jsx)(`main`,{id:`main`,className:`admin-main`,tabIndex:-1,children:i==null?a?(0,M.jsx)(xe,{value:{me:t.data,pages:n.data.pages,uploads:n.data.uploads},children:(0,M.jsx)(dn,{pathname:r.pathname})}):(0,M.jsx)(K,{}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(W,{title:e(`admin.title`)}),(0,M.jsx)(R,{error:i,onRetry:()=>{t.reload(),n.reload()}})]})}),(0,M.jsx)(ke,{})]})}function dn({pathname:e}){let{t}=O(),n=t=>x(t,e)?.id;switch(e){case`/admin`:case`/admin/`:case`/admin/incidents`:return(0,M.jsx)(pt,{});case`/admin/incidents/new`:return(0,M.jsx)(at,{});case`/admin/maintenance`:return(0,M.jsx)(wt,{});case`/admin/maintenance/new`:return(0,M.jsx)(vt,{});case`/admin/monitors`:return(0,M.jsx)(Tt,{});case`/admin/appearance`:return(0,M.jsx)(Le,{});case`/admin/notifications`:return(0,M.jsx)(sn,{});case`/admin/notifications/new`:return(0,M.jsx)(Zt,{});case`/admin/deliveries`:return(0,M.jsx)(Xe,{})}let r=n(`/admin/incidents/:id`);if(r!==void 0)return(0,M.jsx)(st,{id:r},r);let i=n(`/admin/maintenance/:id`);if(i!==void 0)return(0,M.jsx)(yt,{id:i},i);let a=n(`/admin/notifications/:id`);return a===void 0?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(W,{title:t(`admin.notFound.title`)}),(0,M.jsx)(`p`,{children:t(`admin.notFound.detail`)})]}):(0,M.jsx)(Qt,{id:a},a)}te(`admin-root`,(0,M.jsx)(un,{}),{catalog:me,fallback:(e,t,n)=>(0,M.jsx)(Oe,{error:e,retry:n})});
@@ -0,0 +1 @@
1
+ .admin{min-height:100vh}.admin-header{border-bottom:1px solid var(--border);background:var(--bg-subtle);flex-wrap:wrap;align-items:center;gap:4px 24px;padding:10px 24px 0;display:flex}.admin-header__brand{font-weight:700}.admin-header__brand a{color:var(--fg);text-decoration:none}.admin-nav{order:3;width:100%}.admin-nav ul{gap:2px;display:flex;overflow-x:auto}.admin-nav a{color:var(--fg);white-space:nowrap;border-bottom:2px solid #0000;padding:8px 12px;font-size:.9375rem;text-decoration:none;display:block}.admin-nav a:hover{border-bottom-color:var(--border-strong)}.admin-nav a[aria-current=page]{border-bottom-color:var(--link);font-weight:600}.admin-header__meta{flex-wrap:wrap;align-items:center;gap:6px 16px;margin-left:auto;font-size:.875rem;display:flex}.admin-main{max-width:1080px;margin:0 auto;padding:24px 24px 64px}@media (width<=720px){.admin-header{padding:8px 16px 0}.admin-nav ul{margin:0 -16px;padding:0 8px}.admin-header__meta{margin-left:0}.admin-main{padding:16px 16px 48px}}.view-header{gap:8px;margin-bottom:20px;display:grid}.view-header__row{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:8px 16px;display:flex}.view-header__title{font-size:1.5rem;line-height:1.3}.view-header__title:focus{outline:none}.back-link{margin-bottom:8px;font-size:.875rem}.filters{flex-wrap:wrap;gap:8px 16px;display:flex}.inline-field{align-items:center;gap:8px;font-size:.875rem;display:inline-flex}.actions{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.empty{border:1px dashed var(--border);border-radius:var(--radius);color:var(--muted);text-align:center;padding:24px}.columns{grid-template-columns:minmax(0,3fr) minmax(0,2fr);align-items:start;gap:24px;display:grid}.columns>div{gap:24px;display:grid}@media (width<=860px){.columns{grid-template-columns:minmax(0,1fr)}}.panel{border:1px solid var(--border);border-radius:var(--radius);padding:16px}.admin-main>.panel{max-width:720px;margin-top:24px}.admin-main>.alert{margin-bottom:16px}.panel--danger{border-color:color-mix(in srgb, var(--down) 40%, var(--border))}.panel__title{margin-bottom:12px;font-size:1.0625rem}.section-block{margin-top:32px}.facts{flex-wrap:wrap;gap:4px 24px;margin:0;font-size:.875rem;display:flex}.facts dt,.list-item__facts dt{color:var(--muted);font-size:.75rem}.facts dd,.list-item__facts dd{margin:0}.list{border:1px solid var(--border);border-radius:var(--radius)}.list-item{grid-template-columns:minmax(0,1fr) auto;gap:8px 24px;padding:14px 16px;display:grid}.list-item+.list-item{border-top:1px solid var(--border)}.list-item__main{gap:4px;min-width:0;display:grid}.list-item__title{font-weight:600}.list-item__meta{flex-wrap:wrap;align-items:center;gap:6px 8px;display:flex}.list-item__facts{text-align:right;grid-auto-flow:row;gap:4px;margin:0;font-size:.875rem;display:grid}.list-item__actions{flex-wrap:wrap;grid-column:1/-1;align-items:center;gap:8px;display:flex}@media (width<=600px){.list-item{grid-template-columns:minmax(0,1fr)}.list-item__facts{text-align:left;flex-wrap:wrap;gap:4px 16px;display:flex}}.mono,code{overflow-wrap:anywhere;font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,monospace;font-size:.8125rem}.success-text{color:var(--up)}.form{gap:16px;max-width:720px;display:grid}.form--lead{margin-bottom:16px}.field,.fieldset{gap:4px;min-width:0;display:grid}.fieldset{border:1px solid var(--border);border-radius:var(--radius);gap:10px;margin:0;padding:12px 14px}.fieldset>legend{padding:0 4px}.field__label{font-size:.9375rem;font-weight:600}.field__optional{color:var(--muted);font-weight:400}.field__label .badge{margin-left:6px}.field__hint{color:var(--muted);font-size:.8125rem}.field__errors{color:var(--down);font-size:.875rem;font-weight:500}.field__errors li:before{content:"⚠ "}.field-row{grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;display:grid}input:not([type=checkbox],[type=radio]),select,textarea{border:1px solid var(--border-strong);background:var(--bg);width:100%;min-height:36px;color:var(--fg);font:inherit;border-radius:6px;padding:6px 10px;font-size:.9375rem}.inline-field select,.language select{width:auto;min-height:32px;padding:4px 8px}textarea{resize:vertical;line-height:1.45}input[aria-invalid=true],select[aria-invalid=true],textarea[aria-invalid=true]{border-color:var(--down);box-shadow:0 0 0 1px var(--down)}input[type=checkbox],input[type=radio]{width:1rem;height:1rem;accent-color:var(--link);margin:0}.checks{flex-wrap:wrap;gap:6px 20px;display:flex}.check{cursor:pointer;align-items:center;gap:8px;min-height:28px;display:inline-flex}.nested{gap:8px;margin-top:4px;padding-left:24px;display:grid}.impact-grid{grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px 16px;display:grid}.impact-grid .field__label{font-weight:500}.input-row{align-items:center;gap:8px;display:flex}.input-row .button{white-space:nowrap}.map-row{grid-template-columns:minmax(0,1fr) minmax(0,2fr) auto;align-items:center;gap:8px;display:grid}.secret-state{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.issue-summary{color:var(--down);padding-left:20px;font-size:.875rem;list-style:outside}.image-field{gap:8px;display:grid}.image-field__preview{border:1px solid var(--border);background:repeating-conic-gradient(var(--bg-subtle) 0 25%, var(--bg) 0 50%) 0 0 / 12px 12px;object-fit:contain;border-radius:6px;max-width:min(240px,100%);max-height:64px;padding:6px;display:block}.image-field input[type=file]{min-height:0;padding:4px}.color-table{border-collapse:collapse;width:100%}.color-table th,.color-table td{text-align:left;vertical-align:middle;padding:6px 8px 6px 0}.color-table thead th{font-size:.875rem;font-weight:600}.color-table tbody th{font-size:.9375rem;font-weight:500}.color-table__hint{font-weight:400;display:block}.color-input{flex-wrap:wrap;align-items:center;gap:6px 8px;display:flex}.color-input__scheme{min-width:3.5em;color:var(--muted);font-size:.8125rem;display:none}.color-input input[type=color]{cursor:pointer;width:44px;height:32px;min-height:32px;padding:2px}.color-previews{grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:12px;display:grid}.color-preview{gap:4px;margin:0;display:grid}.color-preview__page{border:1px solid var(--border);border-radius:var(--radius);gap:10px;padding:0 0 12px;font-size:.875rem;display:grid;overflow:hidden}.color-preview__header{padding:12px 14px 20px;font-weight:700}.color-preview__title{padding:12px 14px 0;font-weight:700}.color-preview__surface{border-radius:6px;margin:0 12px;padding:10px 12px}.color-preview__link{text-decoration:underline}.field__warnings{color:var(--degraded);font-size:.875rem;font-weight:500}.field__warnings li:before{content:"⚠ "}@media (width<=600px){.color-table thead{display:none}.color-table,.color-table tbody,.color-table tr,.color-table th,.color-table td{display:block}.color-table tr{border-top:1px solid var(--border);padding:6px 0}.color-table td{padding:4px 0}.color-input__scheme{display:inline}}.alert{border:1px solid var(--border);border-radius:var(--radius);background:var(--bg-subtle);align-items:flex-start;gap:10px;padding:12px 14px;display:flex}.alert>.icon{margin-top:3px}.alert>div{gap:6px;min-width:0;display:grid}.alert--error{border-color:color-mix(in srgb, var(--down) 45%, transparent);background:var(--down-bg)}.alert--error>.icon{color:var(--down)}.alert--warning,.alert--conflict{border-color:color-mix(in srgb, var(--degraded) 45%, transparent);background:var(--degraded-bg)}.alert--conflict>.icon{color:var(--degraded)}.alert--success{border-color:color-mix(in srgb, var(--up) 40%, transparent);background:var(--up-bg)}.alert--success>.icon{color:var(--up)}.alert--info{border-color:color-mix(in srgb, var(--info) 40%, transparent);background:var(--info-bg)}.conflict__title{font-weight:600}.conflict__fields{gap:6px;margin:0;display:grid}.conflict__fields dt{font-size:.875rem;font-weight:600}.conflict__fields dt .badge{margin-left:6px}.conflict__fields dd{white-space:pre-wrap;margin:0}.confirm{border:1px solid var(--down);border-radius:var(--radius);background:var(--down-bg);gap:8px;padding:12px;display:grid}.confirm__question{font-weight:600}.timeline{border-left:2px solid var(--border);gap:14px;padding-left:14px;display:grid}.timeline__meta{color:var(--muted);flex-wrap:wrap;align-items:center;gap:4px 8px;font-size:.8125rem;display:flex}.timeline__body{white-space:pre-wrap;margin-top:4px}.modal-backdrop{z-index:20;background:#01040973;place-items:center;padding:16px;display:grid;position:fixed;inset:0}.modal{border-radius:var(--radius);background:var(--bg-raised);width:min(440px,100%);box-shadow:var(--shadow);gap:12px;padding:20px;display:grid}