emailengine-app 2.77.0 → 2.79.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (189) hide show
  1. package/.github/workflows/test.yml +80 -0
  2. package/.ncurc.js +23 -13
  3. package/.release-please-manifest.json +1 -1
  4. package/CHANGELOG.md +60 -0
  5. package/bin/emailengine.js +1 -1
  6. package/config/e2e.toml +2 -1
  7. package/config/test.toml +2 -1
  8. package/data/google-crawlers.json +1 -1
  9. package/encrypt.js +1 -1
  10. package/lib/account/expected-identity.js +88 -0
  11. package/lib/account.js +145 -61
  12. package/lib/api-reference/format.js +105 -4
  13. package/lib/api-reference/index.js +24 -7
  14. package/lib/api-reference/model.js +148 -21
  15. package/lib/api-reference/schema-tree.js +282 -28
  16. package/lib/api-routes/account-routes.js +99 -36
  17. package/lib/api-routes/behavior-notes.js +3 -0
  18. package/lib/api-routes/blocklist-routes.js +21 -47
  19. package/lib/api-routes/chat-routes.js +10 -12
  20. package/lib/api-routes/delivery-test-routes.js +6 -26
  21. package/lib/api-routes/export-routes.js +2 -0
  22. package/lib/api-routes/gateway-routes.js +52 -11
  23. package/lib/api-routes/license-routes.js +2 -0
  24. package/lib/api-routes/mailbox-routes.js +29 -26
  25. package/lib/api-routes/message-routes.js +27 -21
  26. package/lib/api-routes/oauth2-app-routes.js +11 -29
  27. package/lib/api-routes/operation-impact.js +80 -0
  28. package/lib/api-routes/outbox-routes.js +15 -5
  29. package/lib/api-routes/permission-map.js +397 -0
  30. package/lib/api-routes/route-helpers.js +223 -9
  31. package/lib/api-routes/route-metadata.js +28 -0
  32. package/lib/api-routes/settings-routes.js +30 -25
  33. package/lib/api-routes/stats-routes.js +2 -2
  34. package/lib/api-routes/submit-routes.js +53 -31
  35. package/lib/api-routes/template-routes.js +3 -0
  36. package/lib/api-routes/token-routes.js +319 -33
  37. package/lib/api-routes/webhook-route-routes.js +14 -4
  38. package/lib/append-list.js +3 -14
  39. package/lib/arf-detect.js +23 -1
  40. package/lib/auth-token.js +80 -8
  41. package/lib/autodetect-imap-settings.js +40 -16
  42. package/lib/base32.js +30 -0
  43. package/lib/bounce-detect.js +182 -62
  44. package/lib/consts.js +10 -0
  45. package/lib/db.js +20 -2
  46. package/lib/delivery-error.js +30 -1
  47. package/lib/egress-filter.js +89 -8
  48. package/lib/email-client/base-client.js +35 -113
  49. package/lib/email-client/gmail-client.js +22 -13
  50. package/lib/email-client/imap/listing-diff.js +3 -3
  51. package/lib/email-client/imap/mailbox.js +28 -93
  52. package/lib/email-client/imap/subconnection.js +10 -7
  53. package/lib/email-client/imap/sync-operations.js +46 -46
  54. package/lib/email-client/imap-client.js +39 -28
  55. package/lib/email-client/message-builder.js +15 -15
  56. package/lib/email-client/notification-handler.js +1 -1
  57. package/lib/email-client/outlook/graph-api.js +10 -4
  58. package/lib/email-client/outlook-client.js +54 -55
  59. package/lib/email-client/smtp-pool-manager.js +1 -1
  60. package/lib/enum-descriptions.js +92 -2
  61. package/lib/export.js +2 -2
  62. package/lib/field-usage.js +133 -0
  63. package/lib/gateway.js +2 -2
  64. package/lib/get-raw-email.js +1 -1
  65. package/lib/imapproxy/imap-core/lib/commands/authenticate-plain.js +3 -3
  66. package/lib/imapproxy/imap-core/lib/commands/id.js +2 -13
  67. package/lib/imapproxy/imap-core/lib/commands/starttls.js +1 -1
  68. package/lib/imapproxy/imap-core/lib/imap-command.js +21 -5
  69. package/lib/imapproxy/imap-core/lib/imap-connection.js +17 -7
  70. package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
  71. package/lib/imapproxy/imap-server.js +40 -10
  72. package/lib/license-beacon.js +5 -10
  73. package/lib/lists.js +49 -1
  74. package/lib/llm-pre-process.js +6 -6
  75. package/lib/logger.js +5 -1
  76. package/lib/metrics-collector.js +2 -2
  77. package/lib/msgpack.js +62 -0
  78. package/lib/oauth/decode-jwt-payload.js +39 -0
  79. package/lib/oauth/gmail.js +9 -12
  80. package/lib/oauth/mail-ru.js +5 -7
  81. package/lib/oauth/outlook-identity.js +61 -0
  82. package/lib/oauth/outlook.js +9 -9
  83. package/lib/oauth/pubsub/google.js +25 -10
  84. package/lib/oauth/retry-setup.js +38 -0
  85. package/lib/oauth/scope-checker.js +1 -1
  86. package/lib/oauth2-apps.js +224 -295
  87. package/lib/openapi/build-document.js +15 -7
  88. package/lib/openapi/joi-schema.js +20 -0
  89. package/lib/outbox.js +145 -14
  90. package/lib/pre-process.js +9 -9
  91. package/lib/queue-stats.js +49 -0
  92. package/lib/read-env-value.js +37 -0
  93. package/lib/reconnection-manager.js +2 -2
  94. package/lib/rewrite-text-nodes.js +4 -3
  95. package/lib/routes-ui.js +4 -0
  96. package/lib/schemas.js +223 -155
  97. package/lib/settings.js +84 -5
  98. package/lib/sub-script.js +2 -1
  99. package/lib/swagger-options.js +2 -1
  100. package/lib/templates.js +5 -5
  101. package/lib/threads.js +2 -2
  102. package/lib/token-audit-log.js +208 -0
  103. package/lib/token-permission-view.js +219 -0
  104. package/lib/token-permissions.js +172 -0
  105. package/lib/tokens.js +100 -16
  106. package/lib/tools.js +259 -85
  107. package/lib/totp.js +67 -0
  108. package/lib/ui-routes/account-routes.js +122 -26
  109. package/lib/ui-routes/admin-config-routes.js +20 -17
  110. package/lib/ui-routes/admin-entities-routes.js +66 -22
  111. package/lib/ui-routes/auth-routes.js +36 -48
  112. package/lib/ui-routes/export-routes.js +10 -4
  113. package/lib/ui-routes/oauth-config-routes.js +5 -5
  114. package/lib/ui-routes/reference-routes.js +11 -8
  115. package/lib/ui-routes/route-helpers.js +79 -2
  116. package/lib/ui-routes/settings-page.js +1 -1
  117. package/lib/ui-routes/smtp-test-routes.js +1 -1
  118. package/lib/ui-routes/suppression-list-routes.js +294 -0
  119. package/lib/ui-routes/unsubscribe-routes.js +19 -29
  120. package/lib/utils/is-email.js +34 -0
  121. package/lib/utils/network.js +2 -2
  122. package/lib/utils/to-camel-case.js +17 -0
  123. package/lib/web-safe-html.js +1 -1
  124. package/lib/webhook-egress.js +37 -0
  125. package/lib/webhook-routing.js +80 -0
  126. package/lib/webhooks.js +21 -15
  127. package/package.json +26 -27
  128. package/sbom.json +1 -0
  129. package/server.js +81 -42
  130. package/static/css/flyonui.css +1 -1
  131. package/static/css/public.css +3 -0
  132. package/static/css/src/app.tailwind.css +159 -9
  133. package/static/js/app.js +69 -0
  134. package/static/js/reference.js +741 -10
  135. package/static/js/ui.js +43 -0
  136. package/static/licenses.html +698 -1590
  137. package/translations/README.md +64 -0
  138. package/translations/de.mo +0 -0
  139. package/translations/de.po +164 -120
  140. package/translations/en.po +200 -161
  141. package/translations/et.mo +0 -0
  142. package/translations/et.po +163 -120
  143. package/translations/fr.mo +0 -0
  144. package/translations/fr.po +163 -120
  145. package/translations/ja.mo +0 -0
  146. package/translations/ja.po +163 -120
  147. package/translations/messages.pot +94 -64
  148. package/translations/nl.mo +0 -0
  149. package/translations/nl.po +164 -120
  150. package/translations/pl.mo +0 -0
  151. package/translations/pl.po +163 -120
  152. package/views/account-identity-error.hbs +34 -0
  153. package/views/accounts/account.hbs +69 -7
  154. package/views/accounts/browse.hbs +18 -35
  155. package/views/accounts/edit.hbs +1 -0
  156. package/views/accounts/register/imap.hbs +12 -2
  157. package/views/config/logging.hbs +6 -0
  158. package/views/config/oauth/app.hbs +0 -2
  159. package/views/config/security.hbs +13 -0
  160. package/views/layout/app.hbs +29 -5
  161. package/views/oauth-scope-error.hbs +1 -1
  162. package/views/partials/oauth_form.hbs +0 -15
  163. package/views/partials/reference/disclosure.hbs +8 -2
  164. package/views/partials/reference/nav.hbs +36 -9
  165. package/views/partials/reference/operation.hbs +48 -14
  166. package/views/partials/reference/params.hbs +17 -1
  167. package/views/partials/reference/schema-node.hbs +112 -54
  168. package/views/partials/reference/schema-tools.hbs +25 -0
  169. package/views/partials/reference/token-alert.hbs +35 -10
  170. package/views/partials/reference/try-it.hbs +84 -11
  171. package/views/partials/side_menu.hbs +1 -0
  172. package/views/partials/ui/checkbox.hbs +2 -2
  173. package/views/partials/ui/tabs.hbs +7 -1
  174. package/views/reference/index.hbs +1 -1
  175. package/views/reference/token.hbs +4 -0
  176. package/views/suppression-lists/index.hbs +85 -0
  177. package/views/suppression-lists/list.hbs +87 -0
  178. package/views/templates/index.hbs +8 -2
  179. package/views/tokens/index.hbs +31 -4
  180. package/views/tokens/new.hbs +324 -2
  181. package/workers/api.js +299 -140
  182. package/workers/documents.js +46 -26
  183. package/workers/export.js +20 -8
  184. package/workers/imap-proxy.js +2 -2
  185. package/workers/imap.js +13 -7
  186. package/workers/smtp.js +13 -7
  187. package/workers/submit.js +41 -31
  188. package/workers/webhooks.js +60 -37
  189. package/lib/feature-flags.js +0 -48
@@ -874,6 +874,9 @@ dialog.ee-modal.ee-modal-wide {
874
874
  .ee-dl dd {
875
875
  margin: 0 0 0.5rem;
876
876
  min-width: 0;
877
+ /* Values here can be email addresses, which offer no natural break opportunity and would otherwise
878
+ run past the single-column grid on a narrow screen. */
879
+ overflow-wrap: anywhere;
877
880
  }
878
881
 
879
882
  @media (min-width: 640px) {
@@ -96,6 +96,18 @@
96
96
  }
97
97
 
98
98
  @layer base {
99
+ /* The admin shell's topbar is sticky, and a page may stick a band of its own under it
100
+ * (the API reference's "no access token" banner, whose measured height static/js/
101
+ * reference.js publishes). Telling the scroller about that inset covers every way
102
+ * something is scrolled into view - fragment links, scrollIntoView, find-in-page, the
103
+ * focus moving through a Try it panel - instead of only the classes that carry a
104
+ * scroll-margin of their own. On the class rather than on html because the login and
105
+ * public layouts load this stylesheet too and have no topbar to clear; the class is on
106
+ * <html> in views/layout/app.hbs. */
107
+ .ee-app-chrome {
108
+ scroll-padding-top: calc(var(--spacing-topbar) + var(--ee-sticky-band-h, 0px));
109
+ }
110
+
99
111
  /* Tailwind preflight leaves hr at "1px solid currentColor" - a harsh
100
112
  * full-contrast line in both themes; default every hr to the standard
101
113
  * content-border token instead of classing each instance */
@@ -214,12 +226,19 @@
214
226
  * schema description, which the Tailwind scanner never sees - so this has
215
227
  * to be a class, not utilities. */
216
228
  .ee-code,
217
- .ee-chip {
229
+ .ee-chip,
230
+ .ee-ref-example-value {
218
231
  background-color: color-mix(in oklab, var(--color-base-content) 8%, transparent);
219
232
  border-radius: var(--radius-field, 0.375rem);
220
233
  padding: 0.0625rem 0.375rem;
221
234
  font-family: var(--font-mono, ui-monospace, monospace);
222
235
  font-size: 0.75rem;
236
+ }
237
+ /* A prose code span holds together on one line. A chip does not: a few spell out a list -
238
+ * the accepted proxy URI schemes run to 366px - and a chip that cannot break pushed the
239
+ * whole page sideways on a phone. Chips sit in wrapping flex rows, so one only breaks
240
+ * internally when it does not fit a line of its own; on the Account page that is 5 of 420. */
241
+ .ee-code {
223
242
  white-space: nowrap;
224
243
  }
225
244
  /* .ee-chip is the muted variant, for constraint and default markers */
@@ -231,16 +250,147 @@
231
250
  * The schema trees are deeply nested lists rendered by a recursive
232
251
  * partial, so their look comes from a class rather than utilities. These
233
252
  * class names double as the e2e selectors in test/e2e/reference.spec.js. */
253
+ /* Each list of rows is its own size container, which is what lets a row split on the
254
+ * width it actually has - see .ee-ref-prop-row. */
234
255
  .ee-ref-props {
235
256
  display: flex;
236
257
  flex-direction: column;
237
- gap: 0.625rem;
258
+ container-type: inline-size;
238
259
  }
239
260
  .ee-ref-nest {
240
261
  border-inline-start: 1px solid color-mix(in oklab, var(--color-base-content) 12%, transparent);
241
262
  padding-inline-start: 0.75rem;
242
263
  }
243
264
 
265
+ /* One property row: name, type and constraint chips in a rail, prose in a column
266
+ * beside it. Before this the name sat above its own description at the same left edge,
267
+ * and the description ran the full 800px content width - about 120 characters against
268
+ * a comfortable 45 to 75 - so the one token a reader scans for was the least
269
+ * distinguishable thing on the row and 128 of them read as a single grey field.
270
+ *
271
+ * The hairline replaces the old 0.625rem gap rather than adding to it, which keeps a
272
+ * long list the same height as before while making its rows countable.
273
+ *
274
+ * A container query, not a viewport one. A row never sees the viewport: the admin shell
275
+ * takes an 18rem sidebar and the reference a further 16rem nav column, BOTH of which
276
+ * appear at lg - so a viewport breakpoint fires just as the row gets narrower, not when
277
+ * it gets wider. Nesting then subtracts another 0.75rem per level through .ee-ref-nest,
278
+ * up to nine levels deep. Asking the row's own list how wide it is holds in every one of
279
+ * those cases with no breakpoint bookkeeping. */
280
+ .ee-ref-prop-row {
281
+ display: grid;
282
+ grid-template-columns: minmax(0, 1fr);
283
+ gap: 0.1rem 0.9rem;
284
+ padding-block: 0.3rem;
285
+ border-block-start: 1px solid color-mix(in oklab, var(--color-base-content) 8%, transparent);
286
+ }
287
+ .ee-ref-props > .ee-ref-prop:first-child > .ee-ref-prop-row {
288
+ border-block-start: 0;
289
+ padding-block-start: 0;
290
+ }
291
+ @container (width >= 30rem) {
292
+ .ee-ref-prop-row {
293
+ grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr);
294
+ }
295
+ }
296
+ .ee-ref-prop-rail {
297
+ display: flex;
298
+ flex-direction: column;
299
+ gap: 0.1rem;
300
+ min-width: 0;
301
+ }
302
+ /* The two wrapping lines inside the rail (name, then type and chips). A class rather
303
+ * than the utility string at both call sites: the recursive partial emits this twice
304
+ * per property, so on the Account tag page that is 836 copies of it. */
305
+ .ee-ref-prop-line {
306
+ display: flex;
307
+ flex-wrap: wrap;
308
+ align-items: baseline;
309
+ column-gap: 0.375rem;
310
+ row-gap: 0.25rem;
311
+ }
312
+ /* Capped measure for the prose. In rem rather than ch so the cap does not drift with
313
+ * whatever font-size the row inherits. */
314
+ .ee-ref-prop-body {
315
+ min-width: 0;
316
+ max-width: 34rem;
317
+ }
318
+
319
+ /* The example value on a property row. It takes the shared size and shape above so it
320
+ * belongs to the same family as the constraint markers, and overrides only the colour:
321
+ * primary text on a primary-tinted ground, because it is the one thing on the row that
322
+ * is a specimen rather than a statement about the field. Muting it into .ee-chip made it
323
+ * read as another constraint; leaving it as plain prose made it read as the end of the
324
+ * sentence it follows.
325
+ *
326
+ * It breaks internally rather than pushing the row sideways. A cut value is closed off
327
+ * by formatExample() in lib/api-reference/format.js, so what wraps is at most 43
328
+ * characters. */
329
+ .ee-ref-example-value {
330
+ background-color: color-mix(in oklab, var(--color-primary) 10%, transparent);
331
+ color: color-mix(in oklab, var(--color-primary) 85%, var(--color-base-content));
332
+ overflow-wrap: anywhere;
333
+ }
334
+
335
+ /* A usage note is prose about a decision, so it gets the same left rule the nested
336
+ * property lists use, in the primary colour to tie it to the disclosure that opened it. */
337
+ .ee-ref-usage {
338
+ border-inline-start: 2px solid color-mix(in oklab, var(--color-primary) 45%, transparent);
339
+ padding-inline-start: 0.625rem;
340
+ }
341
+
342
+ /* The Try it request body editor keeps .code-editor's border and radius but sizes itself
343
+ * from its content: static/js/reference.js gives it minLines/maxLines, which .code-editor's
344
+ * fixed 14rem would otherwise fight. */
345
+ .ee-ref-body-editor {
346
+ height: auto;
347
+ }
348
+
349
+ /* Example payloads open by default, so the shape of a response is the first thing a
350
+ * reader meets rather than 128 property rows. That only works if the cost is bounded:
351
+ * the AccountResponse example alone pretty-prints to about 130 lines, and thirteen of
352
+ * those on one tag page is worse than what it replaced. Past this height the block
353
+ * scrolls inside itself, which keeps every operation the same size on the page.
354
+ *
355
+ * Bounded is not the same as hidden, though, and it used to be: the submit request
356
+ * example is 392px of content in a 240px box, so 40% of it sat below an edge with
357
+ * nothing to say so. The four background layers are the standard pure-CSS scroll
358
+ * shadow: the two `local` layers scroll with the content and mask the two `scroll`
359
+ * layers, so a shadow appears at the top only when there is something above and at the
360
+ * bottom only when there is something below. No script, and no shadow at all on a block
361
+ * that fits. */
362
+ .ee-ref-example {
363
+ max-height: 15rem;
364
+ overflow-y: auto;
365
+ overscroll-behavior: contain;
366
+ background-image: linear-gradient(to bottom, var(--color-base-200), transparent), linear-gradient(to top, var(--color-base-200), transparent),
367
+ linear-gradient(to bottom, color-mix(in oklab, var(--color-base-content) 16%, transparent), transparent),
368
+ linear-gradient(to top, color-mix(in oklab, var(--color-base-content) 16%, transparent), transparent);
369
+ background-position:
370
+ top,
371
+ bottom,
372
+ top,
373
+ bottom;
374
+ background-size:
375
+ 100% 1.25rem,
376
+ 100% 1.25rem,
377
+ 100% 0.5rem,
378
+ 100% 0.5rem;
379
+ background-repeat: no-repeat;
380
+ background-attachment: local, local, scroll, scroll;
381
+ }
382
+
383
+ /* Room to breathe above a jump target - operations linked from the sidebar and from
384
+ * #operationId, property rows from #operation.body.field. The sticky chrome above them is
385
+ * NOT in here: that is scroll-padding on the scroller (.ee-app-chrome in @layer base), and
386
+ * counting it twice would park every deep link a band's height below where it belongs.
387
+ * Also keep any scroll-mt-* utility off these elements - utilities are emitted after this
388
+ * layer and would silently replace it. */
389
+ .ee-ref-op,
390
+ .ee-ref-prop {
391
+ scroll-margin-top: 2rem;
392
+ }
393
+
244
394
  /* Deep-link icons (reference/anchor-link), on operation headings and on every
245
395
  * property row. One definition instead of the utility string repeated at every
246
396
  * call site - a tag page renders up to 434 of these. */
@@ -252,28 +402,28 @@
252
402
  color: var(--color-primary);
253
403
  }
254
404
 
255
- /* Property links stay hidden until their row is hovered. The rule hangs off the
256
- * header row rather than the list item because the item CONTAINS the nested rows,
257
- * so hovering a leaf would reveal the link on every one of its ancestors too. The
258
- * header row has no rows inside it, which makes it exact at every depth (same
405
+ /* Property links stay hidden until their row is hovered. The rule hangs off the row
406
+ * rather than the list item because the item CONTAINS the nested rows, so hovering a
407
+ * leaf would reveal the link on every one of its ancestors too. The row holds only
408
+ * this property's own rail and prose, which makes it exact at every depth (same
259
409
  * reasoning as the disclosure chevron below). */
260
410
  .ee-ref-prop-anchor {
261
411
  opacity: 0;
262
412
  transition: opacity 0.15s;
263
413
  }
264
- .ee-ref-prop-head:hover .ee-ref-prop-anchor,
414
+ .ee-ref-prop-row:hover .ee-ref-prop-anchor,
265
415
  .ee-ref-prop-anchor:focus-visible {
266
416
  opacity: 1;
267
417
  }
268
418
 
269
419
  /* Arriving on a linked property. :target needs no script, so the row is marked
270
420
  * even if the deep link lands on an already-expanded group. */
271
- .ee-ref-prop:target > .ee-ref-prop-head {
421
+ .ee-ref-prop:target > .ee-ref-prop-row {
272
422
  background: color-mix(in oklab, var(--color-primary) 12%, transparent);
273
423
  border-radius: var(--radius-field);
274
424
  box-shadow: 0 0 0 0.25rem color-mix(in oklab, var(--color-primary) 12%, transparent);
275
425
  }
276
- .ee-ref-prop:target > .ee-ref-prop-head .ee-ref-prop-anchor {
426
+ .ee-ref-prop:target > .ee-ref-prop-row .ee-ref-prop-anchor {
277
427
  opacity: 1;
278
428
  }
279
429
 
package/static/js/app.js CHANGED
@@ -219,6 +219,75 @@ document.addEventListener('DOMContentLoaded', () => {
219
219
  });
220
220
  }
221
221
 
222
+ // Secondary navigation column (views/layout/app.hbs): a full column beside the content
223
+ // from lg up, a disclosure below that. aria-expanded on the button is the whole state -
224
+ // the panel derives its visibility from it in CSS (peer-aria-expanded:block), so there is
225
+ // no second flag to keep in step. Above lg the button is display:none and lg:block on the
226
+ // panel outranks the peer rule, so the writes below are inert rather than wrong there.
227
+ let secondaryNavToggle = document.getElementById('secondary-nav-toggle');
228
+ let secondaryNavPanel = document.getElementById('secondary-nav-panel');
229
+ if (secondaryNavToggle && secondaryNavPanel) {
230
+ let setSecondaryNav = expanded => secondaryNavToggle.setAttribute('aria-expanded', String(expanded));
231
+
232
+ secondaryNavToggle.addEventListener('click', () => setSecondaryNav(secondaryNavToggle.getAttribute('aria-expanded') !== 'true'));
233
+
234
+ // Closing takes focus with it when the caret is inside the panel: the subtree becomes
235
+ // display:none, and focus would fall back to <body> - the reader's next Tab would
236
+ // restart from the top of the page. Hand it back to the control they came from.
237
+ let closeSecondaryNav = () => {
238
+ let focused = document.activeElement;
239
+ setSecondaryNav(false);
240
+ if (focused && secondaryNavPanel.contains(focused)) {
241
+ secondaryNavToggle.focus();
242
+ }
243
+ };
244
+
245
+ // Page scripts have business with this too - the reference's filter shortcut has to
246
+ // open the panel before it can focus the field inside it, and its group rows behave
247
+ // differently depending on which mode the column is in. Publishing the facts they need
248
+ // keeps the toggle's id, and the fact that a click is what opens it, in this file.
249
+ // `collapsible` reads the button's own box: it is lg:hidden, so being laid out at all
250
+ // is the answer, and the breakpoint stays in the stylesheet.
251
+ window.uiSecondaryNav = {
252
+ // the elements too: the toggle so a page script can watch its box for the mode
253
+ // change, the panel because below lg it is the scroller the nav lives in
254
+ toggle: secondaryNavToggle,
255
+ panel: secondaryNavPanel,
256
+ collapsible: () => !!secondaryNavToggle.offsetParent,
257
+ open: () => setSecondaryNav(true),
258
+ close: closeSecondaryNav
259
+ };
260
+
261
+ secondaryNavPanel.addEventListener('click', event => {
262
+ // A link to another page reloads and closes this anyway, but an in-page anchor
263
+ // does not - it would leave the panel expanded over the section just jumped to.
264
+ // Closing before the browser acts on the fragment also keeps the landing position
265
+ // right: the page shrinks first and the scroll is measured after.
266
+ //
267
+ // Two links are left alone: one something else already handled (defaultPrevented -
268
+ // the reference's group rows open their own list in place), and one opened
269
+ // elsewhere by a modifier, which leaves this page exactly where it was.
270
+ if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
271
+ return;
272
+ }
273
+
274
+ if (event.target.closest('a')) {
275
+ closeSecondaryNav();
276
+ }
277
+ });
278
+
279
+ // Escape is the way out of any disclosure. Without it the only way to put the panel
280
+ // away is to find the row that opened it, which by then may be a screen above. Same
281
+ // rule as the click handler: a keystroke something else has already acted on is not
282
+ // ours - the reference's filter takes Escape to clear its query, and clearing a query
283
+ // should not also close the panel it was being typed into.
284
+ document.addEventListener('keydown', event => {
285
+ if (event.key === 'Escape' && !event.defaultPrevented && secondaryNavToggle.getAttribute('aria-expanded') === 'true') {
286
+ closeSecondaryNav();
287
+ }
288
+ });
289
+ }
290
+
222
291
  // show or hide the error tooltip attached to a state badge (the badge sits
223
292
  // inside a ui/state-badge tooltip wrapper). The empty state is gated with
224
293
  // ee-tooltip-empty on the wrapper, not with hidden on the content -