@uvalib/web-components 1.8.5 → 1.10.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 (98) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +719 -72
  3. package/bin/install-skill.mjs +174 -54
  4. package/dist/base/clipboard.d.ts +9 -0
  5. package/dist/base/clipboard.js +30 -0
  6. package/dist/base/clipboard.js.map +1 -0
  7. package/dist/base.css +301 -3
  8. package/dist/components/uvalib-citation/UvalibCitation.d.ts +124 -0
  9. package/dist/components/uvalib-citation/UvalibCitation.js +545 -0
  10. package/dist/components/uvalib-citation/UvalibCitation.js.map +1 -0
  11. package/dist/components/uvalib-citation/uvalib-citation.d.ts +1 -0
  12. package/dist/components/uvalib-citation/uvalib-citation.js +4 -0
  13. package/dist/components/uvalib-citation/uvalib-citation.js.map +1 -0
  14. package/dist/components/uvalib-dialog/UvalibDialog.d.ts +167 -0
  15. package/dist/components/uvalib-dialog/UvalibDialog.js +688 -0
  16. package/dist/components/uvalib-dialog/UvalibDialog.js.map +1 -0
  17. package/dist/components/uvalib-dialog/uvalib-dialog.d.ts +1 -0
  18. package/dist/components/uvalib-dialog/uvalib-dialog.js +4 -0
  19. package/dist/components/uvalib-dialog/uvalib-dialog.js.map +1 -0
  20. package/dist/components/uvalib-filter/UvalibFilter.d.ts +92 -9
  21. package/dist/components/uvalib-filter/UvalibFilter.js +748 -60
  22. package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
  23. package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
  24. package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
  25. package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
  26. package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
  27. package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
  28. package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
  29. package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -4
  30. package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
  31. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +28 -1
  32. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +139 -3
  33. package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
  34. package/dist/custom-elements.json +9503 -6086
  35. package/dist/edition.css +758 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +3 -0
  38. package/dist/index.js.map +1 -1
  39. package/dist/styles/base.js +112 -1
  40. package/dist/styles/base.js.map +1 -1
  41. package/dist/styles/color-scheme.js +4 -0
  42. package/dist/styles/color-scheme.js.map +1 -1
  43. package/dist/styles/controls.js +6 -0
  44. package/dist/styles/controls.js.map +1 -1
  45. package/dist/styles/edition.d.ts +1 -0
  46. package/dist/styles/edition.js +747 -0
  47. package/dist/styles/edition.js.map +1 -0
  48. package/dist/styles/field-text.d.ts +1 -0
  49. package/dist/styles/field-text.js +21 -0
  50. package/dist/styles/field-text.js.map +1 -0
  51. package/dist/styles/hidden.js +15 -1
  52. package/dist/styles/hidden.js.map +1 -1
  53. package/dist/styles/layout.d.ts +1 -0
  54. package/dist/styles/layout.js +92 -0
  55. package/dist/styles/layout.js.map +1 -0
  56. package/dist/styles/table.d.ts +1 -0
  57. package/dist/styles/table.js +164 -0
  58. package/dist/styles/table.js.map +1 -0
  59. package/dist/tokens.css +4 -0
  60. package/dist-cdn/base.css +301 -3
  61. package/dist-cdn/chunks/{base-B3tNX103.js → base-DXkGlSgH.js} +113 -2
  62. package/dist-cdn/chunks/base-DXkGlSgH.js.map +1 -0
  63. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js +18 -0
  64. package/dist-cdn/chunks/clipboard-CNG7Y_5X.js.map +1 -0
  65. package/dist-cdn/chunks/if-defined-COiQb-gl.js +6 -0
  66. package/dist-cdn/chunks/if-defined-COiQb-gl.js.map +1 -0
  67. package/dist-cdn/chunks/{site-header-CEmNtmk5.js → site-header-B78a_ldi.js} +27 -22
  68. package/dist-cdn/chunks/site-header-B78a_ldi.js.map +1 -0
  69. package/dist-cdn/chunks/{site-main-nav-CAwKq_x5.js → site-main-nav-CmMq2t8t.js} +52 -51
  70. package/dist-cdn/chunks/site-main-nav-CmMq2t8t.js.map +1 -0
  71. package/dist-cdn/custom-elements.json +9503 -6086
  72. package/dist-cdn/edition.css +758 -0
  73. package/dist-cdn/manifest.json +7 -3
  74. package/dist-cdn/site-header.js +1 -1
  75. package/dist-cdn/site-main-nav.js +1 -1
  76. package/dist-cdn/site-page.js +3 -3
  77. package/dist-cdn/site-style.js +1 -1
  78. package/dist-cdn/skills/uvalib-web-components/SKILL.md +34 -10
  79. package/dist-cdn/skills/uvalib-web-components/reference/components.md +188 -9
  80. package/dist-cdn/tokens.css +4 -0
  81. package/dist-cdn/uvalib-citation.js +382 -0
  82. package/dist-cdn/uvalib-citation.js.map +1 -0
  83. package/dist-cdn/uvalib-dialog.js +419 -0
  84. package/dist-cdn/uvalib-dialog.js.map +1 -0
  85. package/dist-cdn/uvalib-filter.js +603 -69
  86. package/dist-cdn/uvalib-filter.js.map +1 -1
  87. package/dist-cdn/uvalib-list-filter.js +451 -0
  88. package/dist-cdn/uvalib-list-filter.js.map +1 -0
  89. package/dist-cdn/uvalib-metadata.js +49 -49
  90. package/dist-cdn/uvalib-metadata.js.map +1 -1
  91. package/dist-cdn/uvalib-pagefind-search.js +118 -48
  92. package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
  93. package/package.json +14 -1
  94. package/skills/uvalib-web-components/SKILL.md +34 -10
  95. package/skills/uvalib-web-components/reference/components.md +188 -9
  96. package/dist-cdn/chunks/base-B3tNX103.js.map +0 -1
  97. package/dist-cdn/chunks/site-header-CEmNtmk5.js.map +0 -1
  98. package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +0 -1
@@ -1,10 +1,11 @@
1
- import { a as e, f as t, i as n, l as r, m as i, n as a, o, p as s, r as c, t as l } from "./UvalibElement-pGONDAwB.js";
1
+ import { a as e, f as t, i as n, l as r, m as i, n as a, p as o, r as s, t as c } from "./UvalibElement-pGONDAwB.js";
2
+ import { t as l } from "./if-defined-COiQb-gl.js";
2
3
  import { a as u } from "./analytics-DTTihuBD.js";
3
4
  import { t as d } from "./accessible-DJv7YOtS.js";
4
5
  import { t as f } from "./link-DbJSwj16.js";
5
- // node_modules/.pnpm/lit-html@3.3.3/node_modules/lit-html/directives/if-defined.js
6
- var p = (e) => e ?? o, m = (e) => typeof e == "string" ? e.replace(/\s+/g, " ").trim() : "";
7
- function h(e) {
6
+ // src/components/site-main-nav/main-nav-items.ts
7
+ var p = (e) => typeof e == "string" ? e.replace(/\s+/g, " ").trim() : "";
8
+ function m(e) {
8
9
  let t = {
9
10
  items: [],
10
11
  invalid: !1,
@@ -13,7 +14,7 @@ function h(e) {
13
14
  if (!Array.isArray(e)) return t.invalid = e != null, t;
14
15
  let n = (e, r, i) => {
15
16
  for (let a of e) {
16
- let e = a ?? {}, o = m(e.label), s = m(e.href), c = Array.isArray(e.items) && e.items.length ? e.items : null;
17
+ let e = a ?? {}, o = p(e.label), s = p(e.href), c = Array.isArray(e.items) && e.items.length ? e.items : null;
17
18
  c ? (t.flattened = !0, o && s && r.push({
18
19
  label: o,
19
20
  href: s
@@ -24,7 +25,7 @@ function h(e) {
24
25
  }
25
26
  };
26
27
  for (let r of e) {
27
- let e = r ?? {}, i = m(e.label), a = m(e.href), o = Array.isArray(e.items) && e.items.length ? e.items : null;
28
+ let e = r ?? {}, i = p(e.label), a = p(e.href), o = Array.isArray(e.items) && e.items.length ? e.items : null;
28
29
  if (!i) t.invalid = !0;
29
30
  else if (o) {
30
31
  let e = [];
@@ -42,15 +43,15 @@ function h(e) {
42
43
  }
43
44
  return t;
44
45
  }
45
- var g = (e) => (e.textContent ?? "").replace(/\s+/g, " ").trim();
46
- function _(e) {
46
+ var h = (e) => (e.textContent ?? "").replace(/\s+/g, " ").trim();
47
+ function g(e) {
47
48
  let t = e.localName === "ul" ? e : e.querySelector(":scope > ul") ?? void 0;
48
49
  if (!t) return [{}];
49
50
  let n = (e) => {
50
51
  if (e.localName !== "li") return {};
51
52
  let t = [...e.children], r = t.find((e) => e.localName === "ul"), i = t.find((e) => e.localName !== "ul");
52
53
  if (!i) return {};
53
- let a = g(i), o = i.localName === "a" ? i.getAttribute("href") : null;
54
+ let a = h(i), o = i.localName === "a" ? i.getAttribute("href") : null;
54
55
  return r ? {
55
56
  label: a,
56
57
  href: o,
@@ -62,17 +63,17 @@ function _(e) {
62
63
  };
63
64
  return [...t.children].map(n);
64
65
  }
65
- var v = {
66
+ var _ = {
66
67
  attempts: 2,
67
68
  retryDelay: 1e3,
68
69
  timeout: 1e4
69
70
  };
70
- async function y(e) {
71
- let t, n = Math.max(1, v.attempts);
71
+ async function v(e) {
72
+ let t, n = Math.max(1, _.attempts);
72
73
  for (let r = 0; r < n; r++) {
73
- r > 0 && await new Promise((e) => setTimeout(e, v.retryDelay));
74
+ r > 0 && await new Promise((e) => setTimeout(e, _.retryDelay));
74
75
  try {
75
- let t = await fetch(e, { signal: AbortSignal.timeout(v.timeout) });
76
+ let t = await fetch(e, { signal: AbortSignal.timeout(_.timeout) });
76
77
  if (!t.ok) throw Error(`${t.status} ${t.statusText} for ${e}`);
77
78
  return await t.json();
78
79
  } catch (e) {
@@ -81,23 +82,23 @@ async function y(e) {
81
82
  }
82
83
  throw t instanceof Error ? t : Error(String(t));
83
84
  }
84
- var b = /* @__PURE__ */ new Map();
85
- function x(e) {
86
- let t = b.get(e);
85
+ var y = /* @__PURE__ */ new Map();
86
+ function b(e) {
87
+ let t = y.get(e);
87
88
  if (!t) {
88
- let n = y(e).then((t) => {
89
- let n = h(t);
89
+ let n = v(e).then((t) => {
90
+ let n = m(t);
90
91
  if (!n.items.length) throw Error(`no valid main navigation entries in ${e}`);
91
92
  return n;
92
93
  });
93
- b.set(e, t = n), n.catch(() => {
94
- b.get(e) === n && b.delete(e);
94
+ y.set(e, t = n), n.catch(() => {
95
+ y.get(e) === n && y.delete(e);
95
96
  });
96
97
  }
97
98
  return t;
98
99
  }
99
100
  // src/components/site-main-nav/main-nav-data.ts
100
- var S = [
101
+ var x = [
101
102
  {
102
103
  label: "About",
103
104
  items: [
@@ -182,8 +183,8 @@ var S = [
182
183
  }
183
184
  ]
184
185
  }
185
- ], C = 0, w = "main-nav", T = (e) => e instanceof Element && e.getAttribute("slot") === w, E = ["href", "slot"], D = "\n .toggle:focus-visible,\n .top-link:focus-visible,\n .panel a:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: -4px;\n }\n .toggle[aria-expanded='true']:focus-visible,\n .toggle:hover:focus-visible,\n .top-link:hover:focus-visible,\n .panel a:hover:focus-visible {\n outline-color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n", O = s(D), k = (e) => s(D.replace(/(^|,)\s*\./gm, `$1 ${e} .`));
186
- function A(e, t) {
186
+ ], S = 0, C = "main-nav", w = (e) => e instanceof Element && e.getAttribute("slot") === C, T = ["href", "slot"], E = "\n .toggle:focus-visible,\n .top-link:focus-visible,\n .panel a:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: -4px;\n }\n .toggle[aria-expanded='true']:focus-visible,\n .toggle:hover:focus-visible,\n .top-link:hover:focus-visible,\n .panel a:hover:focus-visible {\n outline-color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n", D = o(E), O = (e) => o(E.replace(/(^|,)\s*\./gm, `$1 ${e} .`));
187
+ function k(e, t) {
187
188
  try {
188
189
  let n = new URL(e, t);
189
190
  return `${n.host.replace(/^www\./, "")}${n.pathname.replace(/\/+$/, "")}`;
@@ -191,15 +192,15 @@ function A(e, t) {
191
192
  return null;
192
193
  }
193
194
  }
194
- var j = (e, t) => {
195
+ var A = (e, t) => {
195
196
  try {
196
197
  return new URL(e, t).hash;
197
198
  } catch {
198
199
  return "";
199
200
  }
200
- }, M = class extends l {
201
+ }, j = class extends c {
201
202
  constructor(...e) {
202
- super(...e), this.label = "Main", this.rootLinkDomain = "https://www.library.virginia.edu", this.layout = "bar", this.slotItems = null, this.fetched = null, this.open = null, this.propItems = null, this.warned = /* @__PURE__ */ new Set(), this.idBase = `main-nav-${++C}`, this.onLocationChange = () => {
203
+ super(...e), this.label = "Main", this.rootLinkDomain = "https://www.library.virginia.edu", this.layout = "bar", this.slotItems = null, this.fetched = null, this.open = null, this.propItems = null, this.warned = /* @__PURE__ */ new Set(), this.idBase = `main-nav-${++S}`, this.onLocationChange = () => {
203
204
  this.current || this.requestUpdate();
204
205
  }, this.listeningLocation = !1, this.onOutsidePointer = (e) => {
205
206
  let t = this.navEl;
@@ -282,7 +283,7 @@ var j = (e, t) => {
282
283
  background-color: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));
283
284
  text-decoration: none;
284
285
  }
285
- ${O}
286
+ ${D}
286
287
  /* Current page, and the group holding it: bold with a thick underline, not colour alone. */
287
288
  [aria-current]:not([aria-current='false']),
288
289
  .panel a[aria-current]:not([aria-current='false']):hover {
@@ -365,7 +366,7 @@ var j = (e, t) => {
365
366
  `];
366
367
  }
367
368
  installLightStyles(e) {
368
- super.installLightStyles(e), c(`${this.localName}-focus`, [k(this.localName)], {
369
+ super.installLightStyles(e), s(`${this.localName}-focus`, [O(this.localName)], {
369
370
  root: e,
370
371
  scope: !1,
371
372
  layer: !1
@@ -409,19 +410,19 @@ var j = (e, t) => {
409
410
  return e.invalid && this.warnOnce("invalid", t), e.flattened && this.warnOnce("flattened", t), e.items.length ? e.items : null;
410
411
  }
411
412
  adoptSource() {
412
- let e = [...this.children].filter(T);
413
+ let e = [...this.children].filter(w);
413
414
  return e.length && !this.holder && (this.holder = document.createElement("div"), this.holder.hidden = !0, this.holder.className = "main-nav-source"), this.holder && (this.holder.append(...e), this.holder.parentNode !== this && this.append(this.holder)), this.holder ? [...this.holder.children] : [];
414
415
  }
415
416
  syncSource() {
416
- let e = this.lightDom ? this.adoptSource() : [...this.children].filter(T), t = null;
417
+ let e = this.lightDom ? this.adoptSource() : [...this.children].filter(w), t = null;
417
418
  if (e.length) {
418
- let n = e.flatMap((e, t) => t === 0 ? _(e) : [{}]);
419
- t = this.use(h(n), "slot=\"main-nav\"");
419
+ let n = e.flatMap((e, t) => t === 0 ? g(e) : [{}]);
420
+ t = this.use(m(n), "slot=\"main-nav\"");
420
421
  }
421
422
  JSON.stringify(t) !== JSON.stringify(this.slotItems) && (this.slotItems = t), this.observer ??= new MutationObserver(() => this.syncSource()), this.observer.disconnect();
422
423
  let n = {
423
424
  attributes: !0,
424
- attributeFilter: E,
425
+ attributeFilter: T,
425
426
  characterData: !0,
426
427
  childList: !0,
427
428
  subtree: !0
@@ -429,9 +430,9 @@ var j = (e, t) => {
429
430
  this.lightDom ? (this.observer.observe(this, { childList: !0 }), this.holder && this.observer.observe(this.holder, n)) : this.observer.observe(this, n);
430
431
  }
431
432
  willUpdate(e) {
432
- e.has("items") && (this.propItems = this.items == null ? null : this.use(h(this.items), "items")), e.has("itemsSrc") && this.fetchedFor !== this.itemsSrc && (this.fetched = null, this.fetchedFor = void 0);
433
+ e.has("items") && (this.propItems = this.items == null ? null : this.use(m(this.items), "items")), e.has("itemsSrc") && this.fetchedFor !== this.itemsSrc && (this.fetched = null, this.fetchedFor = void 0);
433
434
  let t = this.itemsSrc;
434
- t && !this.slotItems && !this.propItems && this.fetchedFor !== t && (this.fetchedFor = t, x(t).then((e) => {
435
+ t && !this.slotItems && !this.propItems && this.fetchedFor !== t && (this.fetchedFor = t, b(t).then((e) => {
435
436
  this.itemsSrc === t && (this.fetched = this.use(e, "items-src"));
436
437
  }, (e) => {
437
438
  this.itemsSrc === t && this.dispatchEvent(new CustomEvent("site-main-nav-error", {
@@ -450,7 +451,7 @@ var j = (e, t) => {
450
451
  (e.has("open") || e.has("layout")) && this.listenOutside(this.isConnected && this.open !== null && this.layout === "bar");
451
452
  }
452
453
  get shown() {
453
- return this.slotItems ?? this.propItems ?? this.fetched ?? S;
454
+ return this.slotItems ?? this.propItems ?? this.fetched ?? x;
454
455
  }
455
456
  get navEl() {
456
457
  return this.renderRoot.querySelector("nav.main-nav");
@@ -534,10 +535,10 @@ var j = (e, t) => {
534
535
  return `${this.idBase}-${e}`;
535
536
  }
536
537
  currentHref(e) {
537
- let t = this.current || this.ownerDocument.defaultView?.location.href || "", n = this.ownerDocument.baseURI, r = A(t, n);
538
+ let t = this.current || this.ownerDocument.defaultView?.location.href || "", n = this.ownerDocument.baseURI, r = k(t, n);
538
539
  if (!r) return null;
539
- let i = e.filter((e) => A(e, n) === r), a = j(t, n);
540
- return i.find((e) => a && j(e, n) === a) ?? i.find((e) => !j(e, n)) ?? (a ? null : i[0]) ?? null;
540
+ let i = e.filter((e) => k(e, n) === r), a = A(t, n);
541
+ return i.find((e) => a && A(e, n) === a) ?? i.find((e) => !A(e, n)) ?? (a ? null : i[0]) ?? null;
541
542
  }
542
543
  resolve(e) {
543
544
  return e.startsWith("#") ? e : f(this.rootLinkDomain, e);
@@ -575,28 +576,28 @@ var j = (e, t) => {
575
576
  if (!e.items) {
576
577
  let t = !a && i(e.href);
577
578
  return t && (a = !0), r`<li>
578
- <a class="top-link" href=${e.href} aria-current=${p(t || void 0)}
579
+ <a class="top-link" href=${e.href} aria-current=${l(t || void 0)}
579
580
  >${e.label}</a
580
581
  >
581
582
  </li>`;
582
583
  }
583
- let o = this.panelId(t), s = this.open === t, c = !a && e.items.some((e) => e.href === n), l = !1;
584
+ let o = this.panelId(t), s = this.open === t, c = !a && e.items.some((e) => e.href === n), u = !1;
584
585
  return c && (a = !0), r`<li>
585
586
  <button
586
587
  type="button"
587
588
  class="toggle"
588
589
  aria-expanded=${s ? "true" : "false"}
589
590
  aria-controls=${o}
590
- aria-current=${p(c ? "true" : void 0)}
591
+ aria-current=${l(c ? "true" : void 0)}
591
592
  @click=${() => this.onToggle(t)}
592
593
  >
593
594
  ${e.label}
594
595
  </button>
595
596
  <ul class="panel" id=${o} ?hidden=${!s}>
596
597
  ${e.items.map((e) => {
597
- let t = c && !l && e.href === n;
598
- return t && (l = !0), r`<li>
599
- <a href=${e.href} aria-current=${p(t ? "page" : void 0)}
598
+ let t = c && !u && e.href === n;
599
+ return t && (u = !0), r`<li>
600
+ <a href=${e.href} aria-current=${l(t ? "page" : void 0)}
600
601
  >${e.label}</a
601
602
  >
602
603
  </li>`;
@@ -609,13 +610,13 @@ var j = (e, t) => {
609
610
  }
610
611
  };
611
612
  // src/components/site-main-nav/site-main-nav.ts
612
- a([e({ type: String })], M.prototype, "label", void 0), a([e({
613
+ a([e({ type: String })], j.prototype, "label", void 0), a([e({
613
614
  type: String,
614
615
  attribute: "root-link-domain"
615
- })], M.prototype, "rootLinkDomain", void 0), a([e({
616
+ })], j.prototype, "rootLinkDomain", void 0), a([e({
616
617
  type: String,
617
618
  attribute: "items-src"
618
- })], M.prototype, "itemsSrc", void 0), a([e({ type: String })], M.prototype, "layout", void 0), a([e({ type: String })], M.prototype, "current", void 0), a([e({ attribute: !1 })], M.prototype, "items", void 0), a([n()], M.prototype, "slotItems", void 0), a([n()], M.prototype, "fetched", void 0), a([n()], M.prototype, "open", void 0), i("site-main-nav", M);
619
- export { p as i, h as n, _ as r, M as t };
619
+ })], j.prototype, "itemsSrc", void 0), a([e({ type: String })], j.prototype, "layout", void 0), a([e({ type: String })], j.prototype, "current", void 0), a([e({ attribute: !1 })], j.prototype, "items", void 0), a([n()], j.prototype, "slotItems", void 0), a([n()], j.prototype, "fetched", void 0), a([n()], j.prototype, "open", void 0), i("site-main-nav", j);
620
+ export { m as n, g as r, j as t };
620
621
 
621
- //# sourceMappingURL=site-main-nav-CAwKq_x5.js.map
622
+ //# sourceMappingURL=site-main-nav-CmMq2t8t.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"site-main-nav-CmMq2t8t.js","names":["unsafeCSS","ifDefined","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","o","trackEvent","accessible","siteLink","str","v","normalizeItems","out","raw","collect","nodes","label","href","kids","into","depth","links","text","el","readItemsMarkup","list","source","readLi","li","sub","k","head","mainNavTiming","fetchJson","error","attempts","response","url","cache","loadMainNavItems","p","promise","result","json","MAIN_NAV_SNAPSHOT","\"label\"","\"items\"","\"href\"","navCounter","MAIN_NAV","isSourceChild","SOURCE_ATTRS","FOCUS_RULES","focusRules","lightFocusRules","tag","pageKey","u","base","hashOf","SiteMainNav","_args","nav","root","win","on","target","type","kind","what","moved","sources","next","s","content","changed","src","key","index","opening","doc","to","tops","top","open","openButton","panel","button","here","matches","hrefs","h","hash","a","group","items","item","l","all","current","mark","marked","cur","id","expanded","has","linkMarked"],"sources":["../../src/components/site-main-nav/main-nav-items.ts","../../src/components/site-main-nav/main-nav-data.ts","../../src/components/site-main-nav/SiteMainNav.ts","../../src/components/site-main-nav/site-main-nav.ts"],"sourcesContent":["// Data helpers for <site-main-nav>: the item types, normalising items from any source\n// (property, JSON, markup) to the two levels the nav shows, and the `items-src` loader.\n// Internal apart from the types. No side effects on import.\n\n/** A link inside a main-navigation group. */\nexport interface MainNavLink {\n label: string;\n href: string;\n}\n\n/**\n * One top-level main-navigation entry: a group (a button that discloses `items`) or, with\n * no `items`, a direct link to `href`. A group's own `href` is not shown.\n */\nexport interface MainNavItem {\n label: string;\n href?: string;\n items?: MainNavLink[];\n}\n\n/** What normalising found besides the items: skipped entries, flattened deeper levels. */\nexport interface NormalizeResult {\n items: MainNavItem[];\n invalid: boolean;\n flattened: boolean;\n}\n\nconst str = (v: unknown): string => (typeof v === 'string' ? v.replace(/\\s+/g, ' ').trim() : '');\n\n/**\n * Reduce untrusted items (a property, JSON or parsed markup) to the two levels the nav\n * shows. Entries without a label, links without an href, and groups with no valid links\n * are skipped (`invalid`); links nested deeper than a group are lifted into it\n * (`flattened`), and a deeper level's own label is dropped unless it has an href.\n */\nexport function normalizeItems(raw: unknown): NormalizeResult {\n const out: NormalizeResult = { items: [], invalid: false, flattened: false };\n if (!Array.isArray(raw)) {\n out.invalid = raw != null;\n return out;\n }\n const collect = (nodes: unknown[], into: MainNavLink[], depth: number): void => {\n for (const n of nodes) {\n const o = (n ?? {}) as Record<string, unknown>;\n const label = str(o.label);\n const href = str(o.href);\n const kids = Array.isArray(o.items) && o.items.length ? o.items : null;\n if (kids) {\n out.flattened = true;\n if (label && href) into.push({ label, href });\n collect(kids, into, depth + 1);\n } else if (label && href) {\n into.push({ label, href });\n } else {\n out.invalid = true;\n }\n }\n };\n for (const n of raw) {\n const o = (n ?? {}) as Record<string, unknown>;\n const label = str(o.label);\n const href = str(o.href);\n const kids = Array.isArray(o.items) && o.items.length ? o.items : null;\n if (!label) {\n out.invalid = true;\n } else if (kids) {\n const links: MainNavLink[] = [];\n collect(kids, links, 2);\n if (links.length) out.items.push({ label, items: links });\n else if (href) out.items.push({ label, href });\n else out.invalid = true;\n } else if (href) {\n out.items.push({ label, href });\n } else {\n out.invalid = true;\n }\n }\n return out;\n}\n\nconst text = (el: Element): string => (el.textContent ?? '').replace(/\\s+/g, ' ').trim();\n\n/**\n * Read `<nav><ul><li>…</li></ul></nav>` (or a bare `<ul>`) markup into raw items: an\n * `<li>` holding an `<a href>` (and no list) is a direct link; an `<li>` whose first child\n * element is a label (`<span>`, or any element but a list) followed by a `<ul>` is a group.\n * Anything else is reported as invalid by normalizeItems().\n */\nexport function readItemsMarkup(source: Element): unknown[] {\n const list =\n source.localName === 'ul' ? source : (source.querySelector(':scope > ul') ?? undefined);\n if (!list) return [{}];\n const readLi = (li: Element): unknown => {\n if (li.localName !== 'li') return {};\n const kids = [...li.children];\n const sub = kids.find((k) => k.localName === 'ul');\n const head = kids.find((k) => k.localName !== 'ul');\n if (!head) return {};\n const label = text(head);\n const href = head.localName === 'a' ? head.getAttribute('href') : null;\n if (!sub) return head.localName === 'a' ? { label, href } : { label };\n return { label, href, items: [...sub.children].map(readLi) };\n };\n return [...list.children].map(readLi);\n}\n\n/**\n * `items-src` fetch: how many attempts, the delay between them (ms) and each attempt's\n * timeout (ms). With the defaults a hung server is given up on after about 21 s.\n */\nexport const mainNavTiming = { attempts: 2, retryDelay: 1000, timeout: 10_000 };\n\nasync function fetchJson(url: string): Promise<unknown> {\n let error: unknown;\n const attempts = Math.max(1, mainNavTiming.attempts);\n for (let i = 0; i < attempts; i++) {\n if (i > 0) await new Promise((r) => setTimeout(r, mainNavTiming.retryDelay));\n try {\n // A hung attempt times out and counts as a failed attempt.\n const response = await fetch(url, { signal: AbortSignal.timeout(mainNavTiming.timeout) });\n if (!response.ok) throw new Error(`${response.status} ${response.statusText} for ${url}`);\n return await response.json();\n } catch (e) {\n error = e;\n }\n }\n throw error instanceof Error ? error : new Error(String(error));\n}\n\nconst cache = new Map<string, Promise<NormalizeResult>>();\n\n/**\n * The items at `url` (JSON in the `MainNavItem[]` shape), fetched once per URL and shared by\n * every nav on the page. A response with no valid entries is an error. Failures are not\n * cached, so a later load tries again.\n */\nexport function loadMainNavItems(url: string): Promise<NormalizeResult> {\n let p = cache.get(url);\n if (!p) {\n const promise = fetchJson(url).then((json) => {\n const result = normalizeItems(json);\n if (!result.items.length) throw new Error(`no valid main navigation entries in ${url}`);\n return result;\n });\n cache.set(url, (p = promise));\n promise.catch(() => {\n if (cache.get(url) === promise) cache.delete(url);\n });\n }\n return p;\n}\n","// GENERATED by scripts/sync-main-nav.mjs from a saved page on 2026-11-14 — do not edit.\n// The desktop \"Main navigation\" of library.virginia.edu. Regenerate with `pnpm sync:main-nav`.\nimport type { MainNavItem } from './main-nav-items.js';\n\n/** The day the snapshot was taken (YYYY-MM-DD). */\nexport const MAIN_NAV_SNAPSHOT_DATE = '2026-11-14';\n\n/** The library main navigation, as on library.virginia.edu when the snapshot was taken. */\nexport const MAIN_NAV_SNAPSHOT: readonly MainNavItem[] = [\n {\n \"label\": \"About\",\n \"items\": [\n {\n \"label\": \"About UVA Library\",\n \"href\": \"/about-uva-library\"\n },\n {\n \"label\": \"News & announcements\",\n \"href\": \"https://library.virginia.edu/news/all?mtm_campaign=main-nav\"\n },\n {\n \"label\": \"Plan a visit\",\n \"href\": \"/about-uva-library#visit\"\n },\n {\n \"label\": \"Library Assessment\",\n \"href\": \"/assessment\"\n },\n {\n \"label\": \"Staff directory\",\n \"href\": \"/staff\"\n }\n ]\n },\n {\n \"label\": \"Using the Library\",\n \"items\": [\n {\n \"label\": \"Search, borrow, request\",\n \"href\": \"/services\"\n },\n {\n \"label\": \"Library spaces\",\n \"href\": \"/spaces\"\n },\n {\n \"label\": \"Equipment & technology\",\n \"href\": \"/equipment-and-tech\"\n }\n ]\n },\n {\n \"label\": \"Research & teaching support\",\n \"items\": [\n {\n \"label\": \"Research & teaching support\",\n \"href\": \"/research-and-teaching\"\n },\n {\n \"label\": \"Research support\",\n \"href\": \"/research-and-teaching/research\"\n },\n {\n \"label\": \"Instruction assistance\",\n \"href\": \"/research-and-teaching/teach\"\n },\n {\n \"label\": \"Writing & publication\",\n \"href\": \"/research-and-teaching/write\"\n }\n ]\n },\n {\n \"label\": \"Get help\",\n \"items\": [\n {\n \"label\": \"Get help\",\n \"href\": \"/help\"\n },\n {\n \"label\": \"Ask a Librarian\",\n \"href\": \"/askalibrarian\"\n },\n {\n \"label\": \"Accessibility services\",\n \"href\": \"/accessibility\"\n },\n {\n \"label\": \"Subject specialists\",\n \"href\": \"https://guides.lib.virginia.edu/subjectlibrarians\"\n }\n ]\n }\n];\n","import { html, css, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { siteLink } from '../link.js';\nimport { MAIN_NAV_SNAPSHOT } from './main-nav-data.js';\nimport {\n loadMainNavItems,\n normalizeItems,\n readItemsMarkup,\n type MainNavItem,\n type NormalizeResult,\n} from './main-nav-items.js';\n\nexport type { MainNavItem, MainNavLink } from './main-nav-items.js';\n\n/** Light-DOM instances share the document id space, so every instance numbers its own ids. */\nlet navCounter = 0;\n\nconst MAIN_NAV = 'main-nav';\nconst isSourceChild = (n: Node): n is Element =>\n n instanceof Element && n.getAttribute('slot') === MAIN_NAV;\n/** Attributes of the source markup that change what the nav renders. */\nconst SOURCE_ATTRS = ['href', 'slot'];\n\n/**\n * Focus rings: inset (as on the live site) so an open panel or a neighbour never covers\n * them; orange on white, brand blue where the background is grey (hover, the open group),\n * so the ring keeps 3:1 contrast.\n */\nconst FOCUS_RULES = `\n .toggle:focus-visible,\n .top-link:focus-visible,\n .panel a:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: -4px;\n }\n .toggle[aria-expanded='true']:focus-visible,\n .toggle:hover:focus-visible,\n .top-link:hover:focus-visible,\n .panel a:hover:focus-visible {\n outline-color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n`;\nconst focusRules = unsafeCSS(FOCUS_RULES);\n/** The focus rules scoped to `tag`, for the unlayered light-mode sheet. */\nconst lightFocusRules = (tag: string) =>\n unsafeCSS(FOCUS_RULES.replace(/(^|,)\\s*\\./gm, `$1 ${tag} .`));\n\n/** A URL reduced to what \"the same page\" means here: host (without `www.`) and path. */\nfunction pageKey(href: string, base: string): string | null {\n try {\n const u = new URL(href, base);\n return `${u.host.replace(/^www\\./, '')}${u.pathname.replace(/\\/+$/, '')}`;\n } catch {\n return null;\n }\n}\nconst hashOf = (href: string, base: string): string => {\n try {\n return new URL(href, base).hash;\n } catch {\n return '';\n }\n};\n\n/**\n * The UVA Library main navigation (About, Using the Library, Research & teaching support,\n * Get help), as on library.virginia.edu, following the WAI-ARIA disclosure navigation\n * pattern: one `<nav>` landmark; each group is a `<button aria-expanded aria-controls>`\n * followed by its list of links, and an entry with no group is a plain link. Click, Enter or\n * Space toggles a group and only one is open at a time; Escape closes it and returns focus to\n * its button; arrow keys, Home and End move between the buttons and between a panel's links,\n * and ArrowDown on an open button moves into its panel. In the `bar` layout a panel also closes\n * when focus leaves the nav or on a pointer press outside it. There is no hover-to-open.\n *\n * The items come from, in order of precedence: a `<nav slot=\"main-nav\">` child holding\n * `<ul><li><a href>…</a></li></ul>` (a direct link) or `<li><span>Group</span><ul><li><a href>…`\n * (a group), kept hidden and watched for changes; the `items` property; JSON at `items-src`;\n * and the snapshot of the live menu bundled with the component (see `pnpm sync:main-nav`).\n * Invalid entries are skipped and levels deeper than two are flattened, each with one console\n * warning. Relative hrefs are joined to `root-link-domain`; absolute ones are kept, and\n * fragment-only ones (`#…`, a hash route) stay on this page. A plain click on a link closes\n * the open group.\n *\n * The link for the current page (`current`, default the page location, followed through\n * same-document navigations; host and path, ignoring the query, the hash, a trailing slash\n * and a leading `www.`) gets `aria-current=\"page\"`, and its group button\n * `aria-current=\"true\"`, shown bold with a thick underline. Of links that differ only by\n * hash, the one with the page's hash is marked, else the one without a hash; if every one\n * has a hash, the first is marked while the page has none, and none for a hash none has.\n *\n * `<site-header>` renders it: as a row under the logo on wide screens and as an accordion in\n * the Menu popover on narrow ones.\n *\n * @tagname site-main-nav\n * @slot main-nav - Optional `<nav>` (or `<ul>`) whose list replaces the menu: `<li><a href>` for a direct link, `<li><span>Group</span><ul><li><a href>…</a></li></ul></li>` for a group. It is never shown itself; in light mode it is moved into a hidden holder.\n * @fires site-main-nav-error - `items-src` could not be loaded: both attempts failed (network error, a 10 s timeout per attempt, or no valid entries), after about 21 s at worst; the nav shows the bundled snapshot. `detail` is `{ src, message }`. Bubbles and is composed.\n * @fires uvalib-analytics-event - For `<site-analytics>`: a group was opened, `['site-main-nav', 'menu-open', <the group's label>]` (not on close), and a link was clicked, `['site-main-nav', 'link-click', '<Group> > <Link>']` (a top-level link: its label alone; never the URL). Bubbles and is composed.\n * @cssprop [--uva-grey-darkest=#2b2b2b] - Top-level button colour.\n * @cssprop [--uva-brand-blue=#232d4b] - Bar bottom border, chevrons, panel links, and the hover and expanded button text.\n * @cssprop [--uva-grey-100=#dadada] - Hover and expanded button background, and panel link hover background.\n * @cssprop [--uva-brand-orange=#e57200] - Focus ring colour, and the underline of the current page's link and group (also bold, with a 3px underline).\n * @cssprop [--uva-font-family=franklin-gothic-urw, \"UVA Franklin Fallback\", Arial, Helvetica, sans-serif] - Font family.\n * @cssprop --uva-color-text - Dark-mode role token: top-level button text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-link - Dark-mode role token: chevrons, panel links, hover text and the focus ring over hover (else `--uva-brand-blue`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: hover and open-group background (else `--uva-grey-100`).\n * @cssprop --uva-color-surface-raised - Dark-mode role token: bar and panel background (else #ffffff).\n * @cssprop --uva-color-accent-bg - Dark-mode role token: bar bottom rule (else `--uva-brand-blue`).\n * @cssprop --uva-color-shadow - Dark-mode role token: panel shadow colour (else rgba(0, 0, 0, 0.2)).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-current - Dark-mode role token: current-page underline (else `--uva-brand-orange`).\n */\nexport class SiteMainNav extends UvalibElement {\n static styles = [\n accessible,\n css`\n :host {\n display: block;\n font-family: var(\n --uva-font-family,\n franklin-gothic-urw,\n 'UVA Franklin Fallback',\n Arial,\n Helvetica,\n sans-serif\n );\n font-size: 17px;\n line-height: 1.5;\n }\n :host([hidden]) {\n display: none;\n }\n ul {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n .panel[hidden] {\n display: none;\n }\n .toggle,\n .top-link {\n display: flex;\n align-items: center;\n box-sizing: border-box;\n margin: 0;\n border: 0;\n border-radius: 0;\n background: transparent;\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n font: inherit;\n font-weight: 500;\n line-height: 1.5;\n text-align: start;\n text-decoration: none;\n cursor: pointer;\n }\n /* Chevron: a rotated border box, turned over when expanded. */\n .toggle::after {\n content: '';\n flex: none;\n inline-size: 0.5em;\n block-size: 0.5em;\n margin-inline-start: 0.75em;\n border-style: solid;\n border-color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n border-width: 0 1px 1px 0;\n transform: translateY(-0.15em) rotate(45deg);\n }\n .toggle[aria-expanded='true']::after {\n transform: translateY(0.15em) rotate(-135deg);\n }\n /* Grey for hover and the open group only, never for focus: the orange focus ring\n would fall below 3:1 against it. */\n .toggle:hover,\n .toggle[aria-expanded='true'],\n .top-link:hover {\n background-color: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .panel a {\n display: block;\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n font-weight: 400;\n text-decoration: underline;\n }\n .panel a:hover {\n background-color: var(--uva-color-surface-hover, var(--uva-grey-100, #dadada));\n text-decoration: none;\n }\n ${focusRules}\n /* Current page, and the group holding it: bold with a thick underline, not colour alone. */\n [aria-current]:not([aria-current='false']),\n .panel a[aria-current]:not([aria-current='false']):hover {\n font-weight: 700;\n text-decoration-line: underline;\n text-decoration-thickness: 3px;\n text-decoration-color: var(--uva-color-current, var(--uva-brand-orange, #e57200));\n text-underline-offset: 0.3em;\n }\n\n /* Bar: a full-width row with the brand-blue rule, content capped at 1600px. */\n .bar {\n border-bottom: 5px solid var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b));\n background: var(--uva-color-surface-raised, #ffffff);\n }\n .bar > ul {\n display: flex;\n flex-wrap: wrap;\n box-sizing: border-box;\n max-inline-size: 1600px;\n margin-inline: auto;\n padding-inline: 16px;\n }\n .bar > ul > li {\n position: relative;\n display: flex;\n }\n .bar .toggle,\n .bar .top-link {\n padding: 11.5px 17px;\n }\n .bar .panel {\n position: absolute;\n top: 100%;\n inset-inline-start: 0;\n z-index: 1000;\n box-sizing: border-box;\n inline-size: max-content;\n min-inline-size: 100%;\n max-inline-size: 20rem;\n background: var(--uva-color-surface-raised, #ffffff);\n border-radius: 0 0 4px 4px;\n box-shadow: 0 8px 16px var(--uva-color-shadow, rgba(0, 0, 0, 0.2));\n /* Invisible normally; forced colors paint it, so the panel keeps an edge. */\n outline: 1px solid transparent;\n }\n .bar .panel a {\n padding: 8.5px 17px;\n }\n\n /* Accordion (the header's narrow-screen Menu popover): full-width rows, panels in flow. */\n .accordion .toggle,\n .accordion .top-link {\n inline-size: 100%;\n justify-content: space-between;\n padding: 0.375rem 0.5rem;\n }\n .accordion .toggle::after {\n margin-inline-end: 0.25em;\n }\n .accordion .panel {\n position: static;\n padding-inline-start: 1rem;\n }\n .accordion .panel a {\n padding: 0.375rem 0.5rem;\n }\n\n /* Forced colors drop backgrounds and shadows: outline the open group and hovered\n controls instead. */\n @media (forced-colors: active) {\n .toggle[aria-expanded='true']:not(:focus-visible),\n .toggle:hover:not(:focus-visible),\n .top-link:hover:not(:focus-visible),\n .panel a:hover:not(:focus-visible) {\n outline: 1px solid CanvasText;\n outline-offset: -1px;\n }\n }\n `,\n ];\n\n /**\n * Light mode: the focus rules again, unlayered. A page's own accessibility sheet (which\n * `<site-page>` installs unlayered) would otherwise beat the layered component rules.\n */\n protected override installLightStyles(root?: Document | ShadowRoot): void {\n super.installLightStyles(root);\n installLightDomStyles(`${this.localName}-focus`, [lightFocusRules(this.localName)], {\n root,\n scope: false,\n layer: false,\n });\n }\n\n /** Accessible name of the navigation landmark. */\n @property({ type: String }) label = 'Main';\n @property({ type: String, attribute: 'root-link-domain' }) rootLinkDomain =\n 'https://www.library.virginia.edu';\n /** URL of JSON in the `MainNavItem[]` shape (needs CORS); the snapshot is shown until it loads, and if it fails. */\n @property({ type: String, attribute: 'items-src' }) itemsSrc?: string;\n /** `bar` (a row of buttons with floating panels) or `accordion` (stacked, panels in flow). */\n @property({ type: String }) layout: 'bar' | 'accordion' = 'bar';\n /**\n * The URL whose link is marked current. Default: the page location, followed through\n * same-document navigations (`popstate`, `hashchange`, and the Navigation API's\n * `currententrychange` where supported).\n */\n @property({ type: String }) current?: string;\n /**\n * The menu, replacing the bundled snapshot (but not `slot=\"main-nav\"` markup):\n * `{ label, href }` for a direct link, `{ label, items: [{ label, href }] }` for a group.\n * Unset or empty uses `items-src` or the snapshot.\n */\n @property({ attribute: false }) items?: MainNavItem[];\n\n /** Items from slotted markup, or null when there is none. */\n @state() private slotItems: MainNavItem[] | null = null;\n /** Items loaded from `items-src`. */\n @state() private fetched: MainNavItem[] | null = null;\n /** Index of the open group. */\n @state() private open: number | null = null;\n\n private propItems: MainNavItem[] | null = null;\n private fetchedFor?: string;\n /** The shown items last rendered, to close the open group when they change. */\n private shownKey?: string;\n private warned = new Set<string>();\n private observer?: MutationObserver;\n private holder?: HTMLDivElement;\n private readonly idBase = `main-nav-${++navCounter}`;\n\n override connectedCallback(): void {\n super.connectedCallback();\n // Read the markup before the first render where it is already there (no second update);\n // the observer catches markup parsed or added later.\n this.syncSource();\n this.listenLocation(true);\n // Reconnected while a group was open: watch for outside presses again.\n this.listenOutside(this.open !== null && this.layout === 'bar');\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.listenOutside(false);\n this.listenLocation(false);\n }\n\n /** Same-document navigation: re-mark the current page when `current` is not set. */\n private onLocationChange = (): void => {\n if (!this.current) this.requestUpdate();\n };\n\n private locationTargets(): { target: EventTarget; type: string }[] {\n const win = this.ownerDocument.defaultView;\n if (!win) return [];\n const nav = (win as Window & { navigation?: EventTarget }).navigation;\n return [\n { target: win, type: 'popstate' },\n { target: win, type: 'hashchange' },\n ...(nav ? [{ target: nav, type: 'currententrychange' }] : []),\n ];\n }\n\n private listeningLocation = false;\n private listenLocation(on: boolean): void {\n if (on === this.listeningLocation) return;\n this.listeningLocation = on;\n for (const { target, type } of this.locationTargets()) {\n if (on) target.addEventListener(type, this.onLocationChange);\n else target.removeEventListener(type, this.onLocationChange);\n }\n }\n\n private warnOnce(kind: 'invalid' | 'flattened', what: string): void {\n if (this.warned.has(kind)) return;\n this.warned.add(kind);\n console.warn(\n kind === 'invalid'\n ? `${this.localName}: ignoring invalid ${what} entries (each needs a label, and an href or links).`\n : `${this.localName}: ${what} nests deeper than two levels; the deeper links are shown in their group.`,\n );\n }\n\n private use(result: NormalizeResult, what: string): MainNavItem[] | null {\n if (result.invalid) this.warnOnce('invalid', what);\n if (result.flattened) this.warnOnce('flattened', what);\n return result.items.length ? result.items : null;\n }\n\n /** Light mode: move `slot=\"main-nav\"` children into a hidden holder this element owns. */\n private adoptSource(): Element[] {\n const moved = [...this.children].filter(isSourceChild);\n if (moved.length && !this.holder) {\n this.holder = document.createElement('div');\n this.holder.hidden = true;\n this.holder.className = 'main-nav-source';\n }\n if (this.holder) {\n this.holder.append(...moved);\n if (this.holder.parentNode !== this) this.append(this.holder);\n }\n return this.holder ? [...this.holder.children] : [];\n }\n\n /** Read the `slot=\"main-nav\"` markup, render it, and watch it for changes. */\n private syncSource(): void {\n const sources = this.lightDom ? this.adoptSource() : [...this.children].filter(isSourceChild);\n let next: MainNavItem[] | null = null;\n if (sources.length) {\n const raw = sources.flatMap((s, i) => (i === 0 ? readItemsMarkup(s) : [{}]));\n next = this.use(normalizeItems(raw), 'slot=\"main-nav\"');\n }\n // Only a real change re-renders.\n if (JSON.stringify(next) !== JSON.stringify(this.slotItems)) this.slotItems = next;\n this.observer ??= new MutationObserver(() => this.syncSource());\n this.observer.disconnect();\n const content = {\n attributes: true,\n attributeFilter: SOURCE_ATTRS,\n characterData: true,\n childList: true,\n subtree: true,\n };\n if (this.lightDom) {\n this.observer.observe(this, { childList: true });\n if (this.holder) this.observer.observe(this.holder, content);\n } else {\n // Shadow mode: the host's children are only the source markup.\n this.observer.observe(this, content);\n }\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items')) {\n this.propItems = this.items == null ? null : this.use(normalizeItems(this.items), 'items');\n }\n if (changed.has('itemsSrc') && this.fetchedFor !== this.itemsSrc) {\n this.fetched = null;\n this.fetchedFor = undefined;\n }\n const src = this.itemsSrc;\n // Fetch only when items-src is what would be shown. The result arrives asynchronously.\n if (src && !this.slotItems && !this.propItems && this.fetchedFor !== src) {\n this.fetchedFor = src;\n loadMainNavItems(src).then(\n (result) => {\n if (this.itemsSrc !== src) return;\n this.fetched = this.use(result, 'items-src');\n },\n (error: unknown) => {\n if (this.itemsSrc !== src) return;\n this.dispatchEvent(\n new CustomEvent('site-main-nav-error', {\n detail: { src, message: error instanceof Error ? error.message : String(error) },\n bubbles: true,\n composed: true,\n }),\n );\n },\n );\n }\n // A different menu: the open index would point at another group, so close it.\n const key = JSON.stringify(this.shown);\n if (this.shownKey !== undefined && key !== this.shownKey) this.open = null;\n this.shownKey = key;\n }\n\n protected override updated(changed: PropertyValues): void {\n if (changed.has('open') || changed.has('layout')) {\n this.listenOutside(this.isConnected && this.open !== null && this.layout === 'bar');\n }\n }\n\n /** The items shown, by precedence. */\n private get shown(): readonly MainNavItem[] {\n return this.slotItems ?? this.propItems ?? this.fetched ?? MAIN_NAV_SNAPSHOT;\n }\n\n // --- behaviour ----------------------------------------------------------------------\n\n private get navEl(): HTMLElement | null {\n return this.renderRoot.querySelector<HTMLElement>('nav.main-nav');\n }\n\n /** The top-level buttons and direct links, in order. */\n private get tops(): HTMLElement[] {\n const nav = this.navEl;\n return nav\n ? [...nav.querySelectorAll<HTMLElement>(':scope > ul > li > :is(.toggle, .top-link)')]\n : [];\n }\n\n private setOpen(index: number | null): void {\n this.open = index;\n }\n\n private onToggle(index: number): void {\n const opening = this.open !== index;\n this.setOpen(opening ? index : null);\n const label = this.shown[index]?.label;\n if (opening && label) trackEvent(this, ['site-main-nav', 'menu-open', label]);\n }\n\n private onOutsidePointer = (e: Event): void => {\n const nav = this.navEl;\n if (nav && !e.composedPath().includes(nav)) this.setOpen(null);\n };\n\n private listening = false;\n private listenOutside(on: boolean): void {\n if (on === this.listening) return;\n this.listening = on;\n const doc = this.ownerDocument;\n if (on) doc.addEventListener('pointerdown', this.onOutsidePointer, true);\n else doc.removeEventListener('pointerdown', this.onOutsidePointer, true);\n }\n\n private onFocusOut(e: FocusEvent): void {\n if (this.layout !== 'bar' || this.open === null) return;\n const to = e.relatedTarget as Node | null;\n // A null relatedTarget (a click on nothing focusable) is left to the pointerdown check.\n if (to && !this.navEl?.contains(to)) this.setOpen(null);\n }\n\n /** Arrow keys, Home and End over `nodes`, from `index` (as the live site's script does). */\n private move(e: KeyboardEvent, nodes: HTMLElement[], index: number): void {\n let to: number;\n switch (e.key) {\n case 'ArrowUp':\n case 'ArrowLeft':\n to = Math.max(0, index - 1);\n break;\n case 'ArrowDown':\n case 'ArrowRight':\n to = Math.min(nodes.length - 1, index + 1);\n break;\n case 'Home':\n to = 0;\n break;\n case 'End':\n to = nodes.length - 1;\n break;\n default:\n return;\n }\n e.preventDefault();\n nodes[to]?.focus();\n }\n\n private onKeyDown(e: KeyboardEvent): void {\n if (e.altKey || e.ctrlKey || e.metaKey) return;\n const target = e.target as HTMLElement;\n const tops = this.tops;\n const top = tops.indexOf(target);\n const open = this.open;\n const openButton = open === null ? null : this.toggleAt(open);\n if (top >= 0) {\n if (e.key === 'Escape') {\n if (open === null) return; // nothing to close: let a surrounding popover handle it\n e.preventDefault();\n this.setOpen(null);\n } else if (e.key === 'ArrowDown' && openButton === target) {\n e.preventDefault();\n this.panelOf(openButton)?.querySelector<HTMLElement>('a')?.focus();\n } else {\n this.move(e, tops, top);\n }\n return;\n }\n const panel = target.closest('.panel');\n if (!panel || !openButton || this.panelOf(openButton) !== panel) return;\n if (e.key === 'Escape') {\n e.preventDefault();\n this.setOpen(null);\n openButton.focus();\n return;\n }\n const links = [...panel.querySelectorAll<HTMLElement>('a')];\n this.move(e, links, links.indexOf(target));\n }\n\n private toggleAt(index: number): HTMLElement | null {\n return (\n this.navEl?.querySelector<HTMLElement>(`[aria-controls=\"${this.panelId(index)}\"]`) ?? null\n );\n }\n\n /** A group button's panel: the list right after it, whose id it controls. */\n private panelOf(button: HTMLElement): HTMLElement | null {\n const next = button.nextElementSibling as HTMLElement | null;\n return next && next.id === button.getAttribute('aria-controls') ? next : null;\n }\n\n private panelId(index: number): string {\n return `${this.idBase}-${index}`;\n }\n\n // --- rendering ----------------------------------------------------------------------\n\n /** The one link to mark current: same host and path; then the same hash; then no hash. */\n private currentHref(hrefs: string[]): string | null {\n const here = this.current || this.ownerDocument.defaultView?.location.href || '';\n const base = this.ownerDocument.baseURI;\n const key = pageKey(here, base);\n if (!key) return null;\n const matches = hrefs.filter((h) => pageKey(h, base) === key);\n const hash = hashOf(here, base);\n return (\n matches.find((h) => hash && hashOf(h, base) === hash) ??\n matches.find((h) => !hashOf(h, base)) ??\n // Every match has a hash: with no hash of its own the page is theirs, so the first is\n // marked; a hash none of them has (a hash route the menu does not list) marks none.\n (hash ? null : matches[0]) ??\n null\n );\n }\n\n /** A link's href: fragment-only (`#…`) stays on this page; others go through siteLink. */\n private resolve(href: string): string {\n return href.startsWith('#') ? href : siteLink(this.rootLinkDomain, href);\n }\n\n /**\n * A plain click on a link closes the open group, so a single-page app that handles the\n * navigation in place does not leave the panel open. Modified clicks (a new tab or\n * window) keep it open.\n */\n private onClick(e: MouseEvent): void {\n const a = e.composedPath().find((n) => n instanceof HTMLAnchorElement);\n // Only the menu's own links (rendered here), never anything else on the click's path.\n if (a && this.renderRoot.contains(a)) {\n const text = (n: Node | null | undefined) =>\n (n?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n // `Group > Link` for a link in a group, the link alone for a top-level one.\n const group = text(a.closest('.panel')?.previousElementSibling);\n const label = text(a);\n if (label)\n trackEvent(this, ['site-main-nav', 'link-click', group ? `${group} > ${label}` : label]);\n }\n if (this.open === null || e.button !== 0) return;\n if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey) return;\n if (e.composedPath().some((n) => n instanceof Element && n.localName === 'a')) {\n this.setOpen(null);\n }\n }\n\n render() {\n const items = this.shown.map((item) => ({\n label: item.label,\n href: item.items ? undefined : this.resolve(item.href!),\n items: item.items?.map((l) => ({ label: l.label, href: this.resolve(l.href) })),\n }));\n const all = items.flatMap((i) => (i.items ? i.items.map((l) => l.href) : [i.href!]));\n const current = this.currentHref(all);\n const mark = (href: string) => (href === current ? 'page' : undefined);\n let marked = false;\n return html`<nav\n class=\"main-nav ${this.layout === 'accordion' ? 'accordion' : 'bar'}\"\n aria-label=${this.label}\n @keydown=${this.onKeyDown}\n @focusout=${this.onFocusOut}\n @click=${this.onClick}\n >\n <ul>\n ${items.map((item, i) => {\n if (!item.items) {\n const cur = !marked && mark(item.href!);\n if (cur) marked = true;\n return html`<li>\n <a class=\"top-link\" href=${item.href!} aria-current=${ifDefined(cur || undefined)}\n >${item.label}</a\n >\n </li>`;\n }\n const id = this.panelId(i);\n const expanded = this.open === i;\n const has = !marked && item.items.some((l) => l.href === current);\n let linkMarked = false;\n if (has) marked = true;\n return html`<li>\n <button\n type=\"button\"\n class=\"toggle\"\n aria-expanded=${expanded ? 'true' : 'false'}\n aria-controls=${id}\n aria-current=${ifDefined(has ? 'true' : undefined)}\n @click=${() => this.onToggle(i)}\n >\n ${item.label}\n </button>\n <ul class=\"panel\" id=${id} ?hidden=${!expanded}>\n ${item.items.map((l) => {\n const cur = has && !linkMarked && l.href === current;\n if (cur) linkMarked = true;\n return html`<li>\n <a href=${l.href} aria-current=${ifDefined(cur ? 'page' : undefined)}\n >${l.label}</a\n >\n </li>`;\n })}\n </ul>\n </li>`;\n })}\n </ul>\n </nav>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { SiteMainNav } from './SiteMainNav.js';\n\ndefine('site-main-nav', SiteMainNav);\n"],"mappings":";;;;;;AA2BA,IAAMkB,KAAO,MAAwB,OAAOC,KAAM,WAAWA,EAAE,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK,IAAI;AAQ7F,SAAgBC,EAAe,GAA+B;CAC5D,IAAMC,IAAuB;EAAE,OAAO,CAAC;EAAG,SAAS;EAAO,WAAW;CAAM;CAC3E,IAAI,CAAC,MAAM,QAAQC,CAAG,GAEpB,OADA,EAAI,UAAUA,KAAO,MACdD;CAET,IAAME,KAAW,GAAkB,GAAqB,MAAwB;EA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