@uvalib/web-components 1.5.0 → 1.6.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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.0",
2
+ "version": "1.6.0",
3
3
  "elements": {
4
4
  "site-page": "site-page.js",
5
5
  "site-header": "site-header.js",
@@ -224,7 +224,7 @@ import '@uvalib/web-components/tokens.css'; // optional: tokens for your own CSS
224
224
 
225
225
  Analytics: only when the site needs Matomo, set `<site-page matomo-id="N">`, or add `site-analytics.js` and a `<site-analytics matomoid="N">` (add `downloads="event"`, or `matomo-downloads="event"` on `<site-page>`, when file URLs carry ids: downloads are then counted as `['download', '<extension>']` events without URLs); see the analytics page in [reference/snippets.md](reference/snippets.md). `<uvalib-analytics>` (`uvalib-analytics.js`) is the same element under its original name, for existing markup. It listens on `document` for `uvalib-analytics-*` and `site-analytics-*` events (`event`, `search`, `pageview`, `content`) and queues them for Matomo, so events fired before Matomo loads are kept, and a page never counts twice. A single-page app whose router uses `pushState` or hashes can set `spa="auto"` to have each route change counted (after the new title is set, never twice for one URL); bare `spa` means the app sends its own `uvalib-analytics-pageview` events.
226
226
 
227
- The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
227
+ The library's components already report what visitors do with them; do not add tracking for any of it: header utility and site links, logo, skip link, Menu and colour scheme; main-nav menu opens and links; footer links; breadcrumb and contents levels, the contents disclosure, Copy citation; card clicks (the card's place in its grid, or single); pager next, previous, page numbers and Load more; tab changes (the tab's label); alerts (impressions, dismiss, links, errors); event clicks; See all hours, week changes; filter facets, scopes and See more/less; date-range changes; histogram selections (`<from>–<to>` when both ends are ISO dates, otherwise `other`); bento searches, result and See all clicks, retries; lightbox opens, next, previous and full size (the name is `image N`, never the URL or the caption) and version comparisons (`compare`, the mode and the version's place, never its label); load errors; and tag-list clicks and Show all (`list N`, or the label with `track-label`, and the tag's place; never the tag text); and combobox choices and clears (the field's label and the suggestion's place; never the typed text or the suggestion); and image-region outline clicks (the list's label and the region's number; never a region's label); and map marker choices and zoom-button presses (the map's label and the place's position or the zoom level; never the place's name, coordinates or URL). `<uvalib-photo-grid>` and `<uvalib-results-count>` report nothing. The README's "Analytics" section has the full table.
228
228
 
229
229
  For the host page's own content, tag the clickable element (or a wrapper) with `data-uvalib-track="category,action[,name[,value]]"` instead of writing a listener, for example `<a href="/spaces" data-uvalib-track="home-page,banner-click,Study spaces">`: the category is your page or widget, the action a fixed kebab-case verb, the name a short fixed label, the value a number. It works inside shadow DOM too. Never put titles, URLs, search text, ids, email addresses, phone numbers or other personal data in events.
230
230
 
@@ -722,6 +722,7 @@ Use these instead of a hand-built gallery or a carousel. There is no autoplay.
722
722
  - Details: a child with `slot="details"` (`data-for` selects one item by id or position from 1; without it the details show for every image), or `data-details-id` on a link naming an element elsewhere. It is put back when the viewer moves on or closes.
723
723
  - `<uvalib-image-regions>` from `uvalib-image-regions.js`: numbered outlines on an image (people, objects, inscriptions) with a list of the same regions beside it. Write the page's own `<img width height alt>` and `<ol>` inside, each `<li data-xywh="percent:x,y,w,h">` (or pixels of the natural size, `160,120,320,240`; `image-width`/`image-height` for a IIIF derivative) holding the region's link and your own action buttons, which stay yours; or set `items` (`{ label, x, y, w, h, unit?, href?, description? }[]`). The list is the accessible route: the outlines are `aria-hidden`, not tab stops, and never the only place a name or action is; hovering or focusing an entry highlights its outline (thicker double outline and label) and back, and clicking an outline focuses its entry. `label` names the list. Listen for `uvalib-image-regions-activate` (an outline clicked, before its entry takes focus; `detail: { index, item, entry }`, `entry` the page's own `<li>`; cancelable, so the page can focus its own control in the entry, such as a "Who is this?" field) and `highlight`; never read the shadow DOM's outlines for it. Do not hand-build absolutely positioned outlines. It reports outline clicks itself (the list's label and the number, never a region's label).
724
724
  - Regions in the viewer: `data-regions` on a lightbox link (a JSON array, or `percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the lightbox's `regions` callback (`({ element, id, href, index }) => regions`). The open image then shows the outlines, their list and a "Show regions" toggle; `regions-label` names the list. For your own buttons in each entry, `data-regions-list="<id>"` (or the `regionsList` callback) names a hidden `<ol>` of `<li data-xywh>` in the page: it is lent to the viewer (same nodes, your listeners and CSS keep working) and put back on close; give each action a unique name ("Confirm Tim Kaine").
725
+ - Versions in the viewer: `data-versions='[{"label":"Original"},{"label":"AI colorization","href":"color.jpg","note":"The colours are an AI model’s guess."}]'` on a lightbox link (first entry = the link's image; or the `versions` callback) compares them over the photo, the comparison loaded on first use: Switch (default), Reveal (`compare="wipe"`, a divider: click the photo or the slider) or Fade; label AI versions as such and give them a `note`; `version-param` (with `url-param`) keeps `?version=wipe:40`; `uvalib-lightbox-version` reports changes.
725
726
  - `<uvalib-photo-grid>` from `uvalib-photo-grid.js`: justified rows. Each direct `<a href>` or `<button>` is one photo and stays a real control. The row is about 220px, and 140px at 767px and below, unless `row-height` is set (a bare number is pixels). Give each image `width` and `height` so the row does not jump when it loads. An image with no visible text gets a caption from its alt, and a repeated alt is cleared (the original is kept for a lightbox). A different alt is kept. Do not set an `aria-label` that differs from the visible text; the grid will not add a caption beside one. Generated "Photo N" captions renumber when the photos change order. A `<span slot="badge">` inside the item, or `data-badge` on it (“seq”, “3 photos”), is drawn over the thumbnail and stays in the accessible name; an existing `aria-label` gains the badge text. A grid inside a lightbox opens the viewer. The grid reports no analytics.
726
727
 
727
728
  ```html snippet
@@ -1102,6 +1102,7 @@ An image with numbered region outlines (people, objects, inscriptions) and a lis
1102
1102
  |---|---|
1103
1103
  | (default) | The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`. |
1104
1104
  | `image` | The image. A first `<img>` or `<picture>` child is put here by itself. |
1105
+ | `controls` | Controls for the image (a lightbox's version comparison), under the image and before the list in reading order. Not covered by the outlines. |
1105
1106
 
1106
1107
  ### CSS parts
1107
1108
 
@@ -1134,7 +1135,7 @@ An image with numbered region outlines (people, objects, inscriptions) and a lis
1134
1135
 
1135
1136
  ## `<uvalib-lightbox>`
1136
1137
 
1137
- An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back when the viewer moves on or closes. Optional regions (people, objects, inscriptions): `data-regions` on a link, a JSON array of `{ label, x, y, w, h, unit? }` or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the `regions` callback. The open image then shows numbered outlines (`<uvalib-image-regions>`, loaded on first use) and a list of the regions beside it, with a "Show regions" toggle (`aria-pressed`) that hides the outlines. Pixel regions are measured in `data-image-width` × `data-image-height` when set (the viewer shows a resized IIIF image), else in the image's natural size. Or the page's own list, with its own buttons: `data-regions-list="<id>"` on a link (or the `regionsList` callback) names an `<ol>` or `<ul>` of `<li data-xywh>` anywhere in the page, usually `hidden`. While that image is open the list (the same nodes, so the page's listeners keep working) is the region list: in shadow mode it becomes a child of the lightbox slotted into the viewer, not moved into the shadow root, so the page's CSS still applies to it. When the image changes or the viewer closes it goes back where it was, `hidden` as before. It wins over `data-regions`.
1138
+ An accessible image viewer over a set of plain links. With JavaScript a primary click opens a modal dialog; without it (or with a modified click) the link opens the image as before. Wrap the links, or point at them with `selector` (for example `a.pb-image` on a reading page). There is no autoplay and no carousel. The dialog is labelled by the caption (`data-caption`, else the image alt, else the link text). Focus moves to Close on open and back to the trigger on close. Escape and a click on the backdrop close it. With more than one image, Previous and Next and the arrow keys move through the set (wrapping), and a polite “3 of 13” counter is shown. Full size opens the original image in a new tab. A IIIF Image API URL keeps its region; only the size becomes `!W,H` for the viewport. TIFF and JPEG2000 URLs are left as written. `url-param` (for example `photo`) keeps `?photo=<id>` in sync, including on a hash route (`#/text?photo=<id>`): opening pushes a history entry, stepping replaces it, and Back closes. Optional details: children with `slot="details"` (and `data-for` equal to the item's id or its position from 1; without `data-for` they show for every image), or `data-details-id` on a link pointing at an element elsewhere on the page. Either is shown inside the dialog and put back when the viewer moves on or closes. Optional regions (people, objects, inscriptions): `data-regions` on a link, a JSON array of `{ label, x, y, w, h, unit? }` or `xywh` values each followed by its label, separated by `;` (`percent:10,20,30,40 Person 1; percent:55,15,20,30 Sign`), or the `regions` callback. The open image then shows numbered outlines (`<uvalib-image-regions>`, loaded on first use) and a list of the regions beside it, with a "Show regions" toggle (`aria-pressed`) that hides the outlines. Pixel regions are measured in `data-image-width` × `data-image-height` when set (the viewer shows a resized IIIF image), else in the image's natural size. Or the page's own list, with its own buttons: `data-regions-list="<id>"` on a link (or the `regionsList` callback) names an `<ol>` or `<ul>` of `<li data-xywh>` anywhere in the page, usually `hidden`. While that image is open the list (the same nodes, so the page's listeners keep working) is the region list: in shadow mode it becomes a child of the lightbox slotted into the viewer, not moved into the shadow root, so the page's CSS still applies to it. When the image changes or the viewer closes it goes back where it was, `hidden` as before. It wins over `data-regions`. Optional versions of an image (an original scan and an AI colorization, a restoration, an infrared capture): `data-versions` on a link, a JSON array of `{ label, href?, note? }` whose first entry is the link's own image, or the `versions` callback. The viewer then compares them over the photo (loaded on first use): Switch (a segmented control), Reveal (a divider: click or tap the photo, or use the slider) or Fade (a slider), `compare` choosing the first. A version's `note` shows under the photo while it is visible, and the image's accessible name ends with the label of the version shown. `version-param` (with `url-param`) keeps the comparison in the address: `?version=2` (Switch, the version from 0), `?version=wipe:40` or `?version=fade:60` (the percentage of the other version shown; `wipe:40:2` compares the original with version 2).
1138
1139
 
1139
1140
  ### Attributes
1140
1141
 
@@ -1143,6 +1144,8 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
1143
1144
  | `selector` | `string` | `''` | CSS selector for image links elsewhere in this root (the page, or the shadow root the component sits in). Combined with any links inside the component. Example: `a.pb-image`. |
1144
1145
  | `url-param` | `string` | `''` | Query parameter kept in sync with the open image, for example `photo` → `?photo=<id>`. The id is the link's `data-id`, else its `id`, else the IIIF identifier, else its position from 1. On a hash route the parameter is written inside the hash. Empty: no deep link. |
1145
1146
  | `regions-label` | `string` | `'Regions'` | The heading of the regions list (for example `People`). |
1147
+ | `compare` | `'switch' \| 'wipe' \| 'fade'` | `'switch'` | How an image's versions are compared first: `switch` (default: one at a time, any number of versions), `wipe` (a divider over the photo) or `fade` (a cross-fade). The viewer offers the others. |
1148
+ | `version-param` | `string` | `''` | Query parameter for the comparison (with `url-param`), for example `version`: `?version=1`, `?version=wipe:40`, `?version=fade:60`. Written with replaceState once the visitor's change settles; read when the viewer opens from the address. |
1146
1149
  | `no-shadow-dom` | `boolean` | `false` | |
1147
1150
  | `no-style` | `boolean` | `false` | |
1148
1151
 
@@ -1164,12 +1167,14 @@ An accessible image viewer over a set of plain links. With JavaScript a primary
1164
1167
  | `controls` | Previous, Next, the counter and Full size. |
1165
1168
  | `details` | The details panel. |
1166
1169
  | `regions` | The `<uvalib-image-regions>` around an image with regions. |
1170
+ | `compare` | The version comparison controls and notes under the photo. |
1167
1171
 
1168
1172
  ### Events
1169
1173
 
1170
1174
  | Event | Description |
1171
1175
  |---|---|
1172
- | `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-lightbox', 'open'\|'next'\|'previous'\|'full-size', 'image N', N]` (N from 1, the image's place in the set). Never the URL or the caption. Not fired for a viewer restored from the URL or from Back and Forward. Bubbles and is composed. |
1176
+ | `uvalib-lightbox-version` | The visitor changed the comparison (mode, version or position; once a slider settles): `detail` is `{ id, mode, index, value }` (`mode` `switch`, `wipe` or `fade`; `index` the version shown or compared, from 0; `value` the percentage of it shown, null for Switch). Not fired on open or for a comparison restored from the URL. Bubbles and is composed. |
1177
+ | `uvalib-analytics-event` | For `<site-analytics>`: `['uvalib-lightbox', 'open'\|'next'\|'previous'\|'full-size', 'image N', N]` (N from 1, the image's place in the set), and `['uvalib-lightbox', 'compare', 'switch'\|'wipe'\|'fade', N]` when the visitor changes a comparison (N the version's place from 1; once a slider settles). Never the URL, the caption or a version's label. Not fired for a viewer restored from the URL or from Back and Forward. Bubbles and is composed. |
1173
1178
 
1174
1179
  ### CSS custom properties
1175
1180
 
@@ -13,9 +13,9 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
13
13
  gap: 1rem;
14
14
  align-items: flex-start;
15
15
  }
16
+ ${e} .column { flex: 0 1 auto; min-width: 0; max-width: 100%; }
16
17
  ${e} .media {
17
18
  position: relative;
18
- flex: 0 1 auto;
19
19
  width: fit-content;
20
20
  min-width: 0;
21
21
  max-width: 100%;
@@ -208,6 +208,9 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
208
208
  get listHost() {
209
209
  return this.lightDom ? this.querySelector(":scope > .layout .list-host") : null;
210
210
  }
211
+ get controlsHost() {
212
+ return this.lightDom ? this.querySelector(":scope > .layout .controls-host") : null;
213
+ }
211
214
  imageEl() {
212
215
  if (this.src) return this.renderRoot.querySelector(".media > img");
213
216
  let e = this.sourceImage();
@@ -289,6 +292,8 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
289
292
  e && t && e.parentElement !== t && t.append(e);
290
293
  let n = this.items ? null : this.sourceList(), r = this.listHost;
291
294
  n && r && n.parentElement !== r && r.append(n);
295
+ let i = this.querySelector(":scope > [slot=\"controls\"]");
296
+ i && this.controlsHost?.append(i);
292
297
  }
293
298
  watchImage(e) {
294
299
  e === this.watchedImg ? e && this.measure() : (this.watchedImg?.removeEventListener("load", this.onImageLoad), this.watchedImg = e, e?.addEventListener("load", this.onImageLoad), this.measure());
@@ -424,24 +429,27 @@ var v = "Regions", y = 0, b = "button, input, select, textarea, ol, ul, [hidden]
424
429
  @load=${this.onImageLoad}
425
430
  />` : e ? r`<div class="img-host"></div>` : r`<slot name="image" @slotchange=${() => this.requestUpdate()}></slot>`, i = this.items ? this.renderOwnList() : e ? r`<div class="list-host"></div>` : r`<slot @slotchange=${() => this.sync()}></slot>`, a = this.active >= 0 && !!this.entries[this.active]?.box;
426
431
  return r`<div class="layout" part="layout">
427
- <div class="media" part="media">
428
- ${n}
429
- <div
430
- class="overlay ${a ? "has-active" : ""}"
431
- part="overlay"
432
- aria-hidden="true"
433
- ?hidden=${this.hideOutlines}
434
- >
435
- ${this.entries.map((e, n) => e.box ? r`<div
436
- class="region ${n === this.active ? "active" : ""}"
437
- part="region"
438
- data-index=${n}
439
- >
440
- <span class="badge ${t ? "" : "no-number"}"
441
- >${t ? r`<span class="number">${e.number}</span>` : o}${e.item.label ? r`<span class="name">${e.item.label}</span>` : o}</span
432
+ <div class="column">
433
+ <div class="media" part="media">
434
+ ${n}
435
+ <div
436
+ class="overlay ${a ? "has-active" : ""}"
437
+ part="overlay"
438
+ aria-hidden="true"
439
+ ?hidden=${this.hideOutlines}
440
+ >
441
+ ${this.entries.map((e, n) => e.box ? r`<div
442
+ class="region ${n === this.active ? "active" : ""}"
443
+ part="region"
444
+ data-index=${n}
442
445
  >
443
- </div>` : o)}
446
+ <span class="badge ${t ? "" : "no-number"}"
447
+ >${t ? r`<span class="number">${e.number}</span>` : o}${e.item.label ? r`<span class="name">${e.item.label}</span>` : o}</span
448
+ >
449
+ </div>` : o)}
450
+ </div>
444
451
  </div>
452
+ ${e ? r`<div class="controls-host"></div>` : r`<slot name="controls"></slot>`}
445
453
  </div>
446
454
  <div class="list" part="list">
447
455
  <div class="heading" role="heading" aria-level=${this.level} id=${this.headingId}>
@@ -1 +1 @@
1
- {"version":3,"file":"uvalib-image-regions.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","precedingHeadingLevel","normalize","safeHref","accessible","toRegion","parseXywh","toPercent","DEFAULT_LABEL","nextId","NOT_LABEL","structuralRules","host","shadowStructure","entryRules","p","entryStyles","UvalibImageRegions","to","hit","root","node","above","options","changed","kids","el","k","img","next","key","sameEls","out","raw","items","item","list","outside","start","li","box","link","label","id","href","parts","walk","imgHost","listHost","w","h","tall","entry","media","e","at","en","detail","name","base","A","light","numbers","image","hasActive"],"sources":["../src/components/uvalib-image-regions/UvalibImageRegions.ts","../src/components/uvalib-image-regions/uvalib-image-regions.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, safeHref } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { parseXywh, toPercent, toRegion, type ImageRegion, type RegionBox } from './regions.js';\n\nexport type { ImageRegion } from './regions.js';\n\n/** One region as drawn: what events carry, its box, its number and its list entry. */\ninterface Entry {\n item: ImageRegion;\n box: RegionBox | null;\n number: number;\n /** The author's list item (children mode); own items are found by index. */\n el: HTMLElement | null;\n}\n\nconst DEFAULT_LABEL = 'Regions';\nlet nextId = 0;\n\n/** Controls inside a list item, which are actions and not part of the region's name. */\nconst NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]';\n\n/**\n * Kept with `no-style`: the layout (the image at its own width, at most the element's, and\n * the list beside it when at least 14rem is left, else under it: the same wrapping flex row\n * base.css gives the children before the element upgrades, so nothing moves), the overlay\n * over the image, and the double outlines and number badges (without them the regions are\n * not visible). `host` is `:host` (shadow) or the tag (light DOM).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} .layout {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n ${host} .media {\n position: relative;\n flex: 0 1 auto;\n width: fit-content;\n min-width: 0;\n max-width: 100%;\n margin: 0;\n }\n ${host} .list { flex: 1 1 14rem; min-width: 0; }\n ${host} .media img, ${host} .img-host > picture${\n host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''\n } { display: block; max-width: 100%; height: auto; }\n ${host} .overlay {\n position: absolute;\n inset: 0;\n overflow: clip;\n overflow-clip-margin: 0.5rem;\n pointer-events: none;\n forced-color-adjust: none;\n }\n ${host} .region {\n position: absolute;\n box-sizing: border-box;\n border: 2px solid #fff;\n outline: 2px solid #000;\n pointer-events: auto;\n cursor: pointer;\n }\n ${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }\n ${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }\n ${host} .badge {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n display: flex;\n gap: 0.375em;\n max-width: 16rem;\n padding: 0.0625rem 0.375rem;\n background: #000;\n color: #fff;\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.25;\n white-space: nowrap;\n outline: 1px solid #fff;\n }\n ${host} .region:not([data-inside]) .badge {\n inset-block-start: auto;\n inset-block-end: calc(100% + 4px);\n inset-inline-start: -4px;\n }\n ${host} .region.active:not([data-inside]) .badge {\n inset-block-end: calc(100% + 8px);\n inset-inline-start: -8px;\n }\n ${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }\n ${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }\n ${host} .region:not(.active) .badge.no-number { display: none; }\n ${host} .heading { margin: 0 0 0.5rem; }\n ${host} .items { margin: 0; }\n @media (forced-colors: active) {\n ${host} .region { border-color: Canvas; outline-color: CanvasText; }\n ${host} .region.active { outline-color: Highlight; }\n ${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }\n ${host} .region.active .badge { background: Highlight; color: HighlightText; }\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A region's list entry: room for the highlight bar, and the bar (with a tint) while its\n * region is highlighted, so it is shown by more than colour. Shadow mode also installs\n * these in the page, scoped to the tag, for the author's own list items.\n */\nconst entryRules = (p: string) => `\n ${p}[data-uvalib-region] {\n box-sizing: border-box;\n padding-block: 0.5rem;\n padding-inline: calc(0.5rem + 0.375rem) 0.5rem;\n overflow-wrap: anywhere;\n }\n ${p}[data-uvalib-region][data-uvalib-active] {\n padding-inline-start: 0.5rem;\n border-inline-start: 0.375rem solid currentColor;\n background: var(--uva-color-surface-hover, #f1f1f1);\n }\n ${p}[data-uvalib-region]:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }\n @media (forced-colors: active) {\n ${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }\n }\n`;\nconst entryStyles = unsafeCSS(entryRules(''));\n\n/**\n * An image with numbered region outlines (people, objects, inscriptions) and a list of the\n * same regions beside it (under it on a narrow screen). The list is the way in: the\n * outlines are a visual aid, hidden from assistive technology and not in the tab order, so\n * no region is a second tab stop. Hovering or focusing a list entry (or anything in it)\n * highlights its region with a thicker double outline and its label, and dims the others;\n * hovering a region highlights its entry. Clicking a region moves focus to its entry.\n *\n * The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.\n * Give it `width` and `height` so its space is reserved before it loads.\n *\n * The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:\n * `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list\n * is shown as written, so it works before the component loads or without JavaScript, and\n * any links and buttons in it stay the page's own (their events are the page's). Or set\n * the `items` property, and the component draws the list. Region numbers are the list's\n * numbers, from 1 (or the `<ol>`'s `start`).\n *\n * @tagname uvalib-image-regions\n * @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.\n * @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.\n * @csspart layout - The grid holding the image and the list.\n * @csspart media - The image and its overlay.\n * @csspart overlay - The outlines over the image (`aria-hidden`).\n * @csspart region - One outline.\n * @csspart list - The heading and the list.\n * @fires highlight - The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed.\n * @fires uvalib-image-regions-activate - A region's outline was clicked, before its list entry takes focus: `detail` is `{ index, item, entry }` (`index` from 0; `item` the region's record; `entry` the page's own `<li>`, from its child list or a lightbox's lent list, or null when this element drew the list from `items`). Cancelable: `preventDefault()` keeps the entry from taking focus, so the page can focus its own control in it instead (a \"Who is this?\" field). Bubbles and is composed.\n * @fires select - A region's outline was clicked, after its entry took focus (or the page took the activate over): `detail` is `{ item, index, entry }`. Bubbles and is composed. Prefer `uvalib-image-regions-activate`: `select` is also the name of the native text-selection event.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).\n * @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).\n */\nexport class UvalibImageRegions extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n entryStyles,\n css`\n .list {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .heading {\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .items {\n padding-inline-start: 1.75rem;\n }\n .items a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .description {\n display: block;\n color: var(--uva-color-text-muted, #4b5563);\n font-size: 0.9375rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .region {\n transition: opacity 0.15s ease;\n }\n }\n `,\n ];\n\n /** The regions, when the component draws the list. Overrides the child list. */\n @property({ attribute: false }) items: ImageRegion[] | null = null;\n\n /** Image URL, when there is no `<img>` child. */\n @property({ type: String }) src = '';\n /** The image's alternative text (with `src`). */\n @property({ type: String }) alt = '';\n /** The image's width (with `src`), reserving its space. */\n @property({ type: Number }) width?: number;\n /** The image's height (with `src`). */\n @property({ type: Number }) height?: number;\n\n /**\n * The size pixel regions are measured in, when it is not the image's natural size (for\n * example a IIIF derivative of a larger original: the original's width and height).\n */\n @property({ type: Number, attribute: 'image-width' }) imageWidth?: number;\n /** The height pixel regions are measured in (with `image-width`). */\n @property({ type: Number, attribute: 'image-height' }) imageHeight?: number;\n\n /** The list's heading, and the analytics name. */\n @property({ type: String }) label = 'Regions';\n\n /** The heading's level (2 to 6). Default: one below the heading before the element. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** `numbers` (default) shows each region's number on its outline; `none` hides them. */\n @property({ type: String }) numbering: 'numbers' | 'none' = 'numbers';\n\n /** Hide the outlines (the list stays). */\n @property({ type: Boolean, reflect: true, attribute: 'hide-outlines' }) hideOutlines = false;\n\n @state() private entries: Entry[] = [];\n @state() private natural: { w: number; h: number } | null = null;\n @state() private active = -1;\n @state() private inferredLevel = 2;\n\n private hover = -1;\n private focused = -1;\n private readonly headingId = `uvalib-image-regions-heading-${++nextId}`;\n private observer?: MutationObserver;\n private watchedImg: HTMLImageElement | null = null;\n /** A list slotted through a `<slot>` child (from a host element's light DOM), also observed. */\n private slottedList: Element | null = null;\n private key = '';\n /** The image's rendered size decides where badges fit. */\n private resizer?: ResizeObserver;\n private resized = 0;\n\n constructor() {\n super();\n this.addEventListener('pointerover', this.onPointerOver);\n this.addEventListener('pointerleave', this.onPointerLeave);\n this.addEventListener('focusin', this.onFocusIn);\n this.addEventListener('focusout', this.onFocusOut);\n this.addEventListener('click', this.onClick);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)\n root.adoptedStyleSheets = [shadowStructure.styleSheet];\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;\n if (this.lightDom && this.noStyle) {\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n } else if (!this.lightDom && !this.noStyle) {\n // The author's list items are page content: their highlight is styled in the page.\n installLightDomStyles(\n `${this.localName}::entries`,\n unsafeCSS(entryRules(`${this.localName} `)),\n { root, scope: false },\n );\n }\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);\n this.slottedList = null;\n this.sync();\n this.observe();\n }\n\n /** Watch the children, and a list slotted from outside them (it is not in this subtree). */\n private observe(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n const options: MutationObserverInit = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],\n characterData: true,\n };\n this.observer.observe(this, options);\n if (this.slottedList) this.observer.observe(this.slottedList, options);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.resizer?.disconnect();\n this.resizer = undefined;\n this.watchImage(null);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') || changed.has('src')) this.sync();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.arrange();\n this.observeSize();\n this.place();\n this.mark();\n // Reading the image's size may set state: not from inside this update.\n queueMicrotask(() => {\n if (this.isConnected) this.watchImage(this.imageEl());\n });\n }\n\n // ---------------------------------------------------------------- sources\n\n /** The author's image element (`<img>` or `<picture>`), wherever it is now. */\n private sourceImage(): HTMLElement | null {\n if (this.src) return null;\n const kids = this.lightDom\n ? [...this.children, ...(this.imgHost?.children ?? [])]\n : [...this.children];\n const named = kids.find((k) => k.getAttribute('slot') === 'image');\n const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');\n return el instanceof HTMLElement ? el : null;\n }\n\n /**\n * The author's list (`<ol>` or `<ul>`), wherever it is now. A `<slot>` child (this element\n * inside another component's shadow root) passes on that host's list, which stays in the\n * page's light DOM (so the page's styles and listeners still apply to it).\n */\n private sourceList(): HTMLOListElement | HTMLUListElement | null {\n const kids = (\n this.lightDom ? [...this.children, ...(this.listHost?.children ?? [])] : [...this.children]\n ).flatMap((k) => (k instanceof HTMLSlotElement ? k.assignedElements({ flatten: true }) : [k]));\n const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');\n return (el as HTMLOListElement | HTMLUListElement | undefined) ?? null;\n }\n\n private get imgHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;\n }\n\n private get listHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;\n }\n\n /** The `<img>` whose natural size measures pixel regions. */\n private imageEl(): HTMLImageElement | null {\n if (this.src) return this.renderRoot.querySelector<HTMLImageElement>('.media > img');\n const el = this.sourceImage();\n if (!el) return null;\n return el instanceof HTMLImageElement ? el : el.querySelector('img');\n }\n\n /** Re-read the regions (and in shadow mode put the image in its slot). */\n private sync(): void {\n const img = this.sourceImage();\n if (img && !this.lightDom && !img.hasAttribute('slot')) img.setAttribute('slot', 'image');\n const next = this.items ? this.fromItems(this.items) : this.fromList();\n const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));\n const sameEls =\n next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);\n if (key === this.key && sameEls) return;\n this.key = key;\n this.entries = next;\n if (this.active >= next.length) this.active = -1;\n }\n\n private fromItems(items: unknown[]): Entry[] {\n const out: Entry[] = [];\n for (const raw of Array.isArray(items) ? items : []) {\n const item = toRegion(raw);\n if (!item) continue;\n const { x, y, w, h, unit = 'px' } = item;\n out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });\n }\n return out;\n }\n\n private fromList(): Entry[] {\n const list = this.sourceList();\n const outside = list && !this.contains(list) ? list : null;\n if (outside !== this.slottedList) {\n this.slottedList = outside;\n if (this.isConnected) this.observe();\n if (outside && !this.noStyle) {\n // Its entries are styled where the list is (the page), not under this tag.\n const root = outside.getRootNode();\n if (root instanceof Document || root instanceof ShadowRoot)\n installLightDomStyles(`${this.localName}::slotted-entries`, entryStyles, {\n root,\n scope: false,\n });\n }\n }\n if (!list) return [];\n const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;\n const out: Entry[] = [];\n [...list.children].forEach((li, i) => {\n if (li.localName !== 'li' || !(li instanceof HTMLElement)) return;\n const box = parseXywh(li.dataset.xywh);\n const link = li.querySelector('a[href]');\n const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);\n const item: ImageRegion = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };\n const id = normalize(li.dataset.id) || li.id;\n if (id) item.id = id;\n const href = link?.getAttribute('href');\n if (href) item.href = href;\n out.push({ item, box, number: start + i, el: li });\n });\n return out;\n }\n\n /** A list item's own text, without its actions (buttons, fields) or a nested list. */\n private text(li: Element): string {\n const parts: string[] = [];\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) parts.push(n.textContent ?? '');\n else if (n instanceof Element && !n.matches(NOT_LABEL)) n.childNodes.forEach(walk);\n };\n li.childNodes.forEach(walk);\n return normalize(parts.join(' '));\n }\n\n // ---------------------------------------------------------------- layout\n\n /** Light DOM: move the author's image and list into the layout (the same nodes). */\n private arrange(): void {\n if (!this.lightDom) return;\n const img = this.sourceImage();\n const imgHost = this.imgHost;\n if (img && imgHost && img.parentElement !== imgHost) imgHost.append(img);\n const list = this.items ? null : this.sourceList();\n const listHost = this.listHost;\n if (list && listHost && list.parentElement !== listHost) listHost.append(list);\n }\n\n private watchImage(img: HTMLImageElement | null): void {\n if (img === this.watchedImg) {\n if (img) this.measure();\n return;\n }\n this.watchedImg?.removeEventListener('load', this.onImageLoad);\n this.watchedImg = img;\n img?.addEventListener('load', this.onImageLoad);\n this.measure();\n }\n\n private readonly onImageLoad = (): void => this.measure();\n\n private measure(): void {\n const img = this.watchedImg;\n const w = img?.complete ? img.naturalWidth : 0;\n const h = img?.complete ? img.naturalHeight : 0;\n const next = w > 0 && h > 0 ? { w, h } : null;\n if (next?.w !== this.natural?.w || next?.h !== this.natural?.h) this.natural = next;\n }\n\n /** The size pixel regions are measured in. */\n private get space(): { w: number; h: number } {\n const w = Number(this.imageWidth);\n const h = Number(this.imageHeight);\n if (w > 0 && h > 0) return { w, h };\n return this.natural ?? { w: 0, h: 0 };\n }\n\n /**\n * Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).\n * A number badge sits above its outline, or inside it when there is no room above.\n */\n private place(): void {\n const { w, h } = this.space;\n const overlay = this.renderRoot.querySelector<HTMLElement>('.overlay');\n const tall = overlay?.clientHeight ?? 0;\n for (const el of this.renderRoot.querySelectorAll<HTMLElement>('.overlay > .region')) {\n const entry = this.entries[Number(el.dataset.index)];\n const box = entry?.box ? toPercent(entry.box, w, h) : null;\n el.hidden = !box;\n if (!box) continue;\n el.style.left = `${box.x}%`;\n el.style.top = `${box.y}%`;\n el.style.width = `${box.w}%`;\n el.style.height = `${box.h}%`;\n el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);\n }\n }\n\n private observeSize(): void {\n const media = this.renderRoot.querySelector<HTMLElement>('.media');\n if (!media || typeof ResizeObserver === 'undefined') return;\n if (!this.resizer) {\n this.resizer = new ResizeObserver(() => {\n // The outlines scale by themselves (percent); only the badges' side may change.\n const h = media.clientHeight;\n if (h === this.resized) return;\n this.resized = h;\n this.place();\n });\n this.resizer.observe(media);\n }\n }\n\n /** The list entry of region `i`. */\n private entryEl(i: number): HTMLElement | null {\n const entry = this.entries[i];\n if (!entry) return null;\n if (entry.el) return entry.el;\n return this.renderRoot.querySelector<HTMLElement>(`.items > li[data-index=\"${i}\"]`);\n }\n\n /** Mark the entries (their padding) and the highlighted one. */\n private mark(): void {\n const list = this.items ? null : this.sourceList();\n this.entries.forEach((e, i) => {\n const el = this.entryEl(i);\n // An author's item that has left the list (given back to the page) is not marked again.\n if (!el || (e.el && e.el.parentElement !== list)) return;\n if (el.getAttribute('data-uvalib-region') !== String(e.number))\n el.setAttribute('data-uvalib-region', String(e.number));\n el.toggleAttribute('data-uvalib-active', i === this.active);\n });\n }\n\n // ---------------------------------------------------------------- interaction\n\n /** The region an event is about: its outline or its list entry (or anything inside it). */\n private indexFrom(e: Event): { i: number; outline: boolean } | null {\n for (const n of e.composedPath()) {\n if (n === this) break;\n if (!(n instanceof HTMLElement)) continue;\n if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))\n return { i: Number(n.dataset.index), outline: true };\n const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);\n if (at >= 0) return { i: at, outline: false };\n }\n return null;\n }\n\n private setActive(): void {\n const next = this.hover >= 0 ? this.hover : this.focused;\n if (next === this.active) return;\n this.active = next;\n const item = this.entries[next]?.item ?? null;\n this.dispatchEvent(\n new CustomEvent('highlight', {\n detail: { item, index: item ? next : -1 },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private readonly onPointerOver = (e: PointerEvent): void => {\n this.hover = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onPointerLeave = (): void => {\n this.hover = -1;\n this.setActive();\n };\n\n private readonly onFocusIn = (e: FocusEvent): void => {\n this.focused = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onFocusOut = (e: FocusEvent): void => {\n const to = e.relatedTarget;\n if (\n to instanceof Node &&\n (this.contains(to) || this.renderRoot.contains(to) || this.slottedList?.contains(to))\n )\n return;\n this.focused = -1;\n this.setActive();\n };\n\n private readonly onClick = (e: MouseEvent): void => {\n const hit = this.indexFrom(e);\n if (!hit?.outline) return;\n this.choose(hit.i);\n };\n\n /**\n * An outline was clicked: say so first (`uvalib-image-regions-activate`, cancelable), then,\n * unless the page took it over, focus the entry; then `select`. `entry` is the page's own\n * `<li>` (its child list or a lightbox's lent list), never one this element drew from `items`.\n */\n private choose(i: number): void {\n const entry = this.entries[i];\n const el = this.entryEl(i);\n if (!entry || !el) return;\n const detail = { index: i, item: entry.item, entry: entry.el ?? null };\n const go = this.dispatchEvent(\n new CustomEvent('uvalib-image-regions-activate', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n }),\n );\n if (go) {\n if (!el.hasAttribute('tabindex')) el.tabIndex = -1;\n el.focus();\n el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { item: entry.item, index: i, entry: detail.entry },\n bubbles: true,\n composed: true,\n }),\n );\n const name = normalize(this.label) || DEFAULT_LABEL;\n trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);\n }\n\n // ---------------------------------------------------------------- render\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : this.inferredLevel;\n }\n\n private renderOwnList() {\n const base = this.ownerDocument.baseURI;\n return html`<ol class=\"items\" aria-labelledby=${this.headingId}>\n ${this.entries.map(({ item }, i) => {\n const href = item.href && safeHref(item.href, base) ? item.href : '';\n return html`<li data-index=${i}>\n ${href ? html`<a href=${href}>${item.label}</a>` : html`<span>${item.label}</span>`}\n ${item.description ? html`<span class=\"description\">${item.description}</span>` : nothing}\n </li>`;\n })}\n </ol>`;\n }\n\n protected override render() {\n const light = this.lightDom;\n const numbers = this.numbering !== 'none';\n const image = this.src\n ? html`<img\n part=\"image\"\n src=${this.src}\n alt=${this.alt}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n @load=${this.onImageLoad}\n />`\n : light\n ? html`<div class=\"img-host\"></div>`\n : html`<slot name=\"image\" @slotchange=${() => this.requestUpdate()}></slot>`;\n const list = this.items\n ? this.renderOwnList()\n : light\n ? html`<div class=\"list-host\"></div>`\n : html`<slot @slotchange=${() => this.sync()}></slot>`;\n const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;\n return html`<div class=\"layout\" part=\"layout\">\n <div class=\"media\" part=\"media\">\n ${image}\n <div\n class=\"overlay ${hasActive ? 'has-active' : ''}\"\n part=\"overlay\"\n aria-hidden=\"true\"\n ?hidden=${this.hideOutlines}\n >\n ${this.entries.map((e, i) =>\n e.box\n ? html`<div\n class=\"region ${i === this.active ? 'active' : ''}\"\n part=\"region\"\n data-index=${i}\n >\n <span class=\"badge ${numbers ? '' : 'no-number'}\"\n >${numbers ? html`<span class=\"number\">${e.number}</span>` : nothing}${\n e.item.label ? html`<span class=\"name\">${e.item.label}</span>` : nothing\n }</span\n >\n </div>`\n : nothing,\n )}\n </div>\n </div>\n <div class=\"list\" part=\"list\">\n <div class=\"heading\" role=\"heading\" aria-level=${this.level} id=${this.headingId}>\n ${normalize(this.label) || DEFAULT_LABEL}\n </div>\n ${list}\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibImageRegions } from './UvalibImageRegions.js';\n\ndefine('uvalib-image-regions', UvalibImageRegions);\n"],"mappings":";;;;;;;AAqBA,IAAMsB,IAAgB,WAClBC,IAAS,GAGPC,IAAY,6EASZC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;IAMLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK,eAAeA,EAAK,sBACzBA,MAAS,UAAU,yCAAyC,GAC7D;IACCA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;;;;;;;;;;;;;;;;IAgBLA,EAAK;;;;;IAKLA,EAAK;;;;IAILA,EAAK;IACLA,EAAK,sCAAsCA,EAAK;IAChDA,EAAK;IACLA,EAAK;IACLA,EAAK;;MAEHA,EAAK;MACLA,EAAK;MACLA,EAAK;MACLA,EAAK;;IAEPA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB3B,EAAUyB,EAAgB,OAAO,CAAC,GAOpDG,KAAc,MAAc;IAC9BC,EAAE;;;;;;IAMFA,EAAE;;;;;IAKFA,EAAE;;;;IAIFA,EAAE;;MAEAA,EAAE;;GAGFC,IAAc9B,EAAU4B,EAAW,EAAE,CAAC,GAsC/BG,IAAb,cAAwClB,EAAc;;EACpC,KAAA,SAAA;GACdK;GACAS;GACAG;GACA,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BL;;CAmDA,cAAc;EAMZ,AALA,MAAM,GAjDsD,KAAA,QAAA,MAG5B,KAAA,MAAA,IAEA,KAAA,MAAA,IAeE,KAAA,QAAA,WAMwB,KAAA,YAAA,WAG2B,KAAA,eAAA,IAEnD,KAAA,UAAA,CAAC,GACuB,KAAA,UAAA,MAClC,KAAA,SAAA,IACO,KAAA,gBAAA,GAEjB,KAAA,QAAA,IACE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AAA,GAGzB7B,EAAA,CAAAC,EAAS;CAAE,MAAM;CAAS,SAAS;CAAM,WAAW;AAAgB,CAAC,CAAA,GAAA4B,EAAA,WAAA,gBAAA,KAAA,CAAA,GAErE7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,WAAA,KAAA,CAAA,GACN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,WAAA,KAAA,CAAA,GACN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,UAAA,KAAA,CAAA,GACN7B,EAAA,CAAAE,EAAM,CAAA,GAAA2B,EAAA,WAAA,iBAAA,KAAA,CAAA,GCjPTtB,EAAO,wBAAwBsB,CAAkB"}
1
+ {"version":3,"file":"uvalib-image-regions.js","names":["unsafeCSS","nothing","_decorate","property","state","n","i","r$1","b","define","__decorate","r","installLightDomStyles","UvalibElement","trackEvent","precedingHeadingLevel","normalize","safeHref","accessible","toRegion","parseXywh","toPercent","DEFAULT_LABEL","nextId","NOT_LABEL","structuralRules","host","shadowStructure","entryRules","p","entryStyles","UvalibImageRegions","to","hit","root","node","above","options","changed","kids","el","k","img","next","key","sameEls","out","raw","items","item","list","outside","start","li","box","link","label","id","href","parts","walk","imgHost","listHost","controls","w","h","tall","entry","media","e","at","en","detail","name","base","A","light","numbers","image","hasActive"],"sources":["../src/components/uvalib-image-regions/UvalibImageRegions.ts","../src/components/uvalib-image-regions/uvalib-image-regions.ts"],"sourcesContent":["import { css, html, nothing, unsafeCSS, type PropertyValues } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { trackEvent } from '../../base/analytics.js';\nimport { precedingHeadingLevel } from '../../base/heading-level.js';\nimport { installLightDomStyles } from '../../base/light-dom-styles.js';\nimport { normalize, safeHref } from '../../base/source-children.js';\nimport { UvalibElement } from '../../base/UvalibElement.js';\nimport { accessible } from '../../styles/accessible.js';\nimport { parseXywh, toPercent, toRegion, type ImageRegion, type RegionBox } from './regions.js';\n\nexport type { ImageRegion } from './regions.js';\n\n/** One region as drawn: what events carry, its box, its number and its list entry. */\ninterface Entry {\n item: ImageRegion;\n box: RegionBox | null;\n number: number;\n /** The author's list item (children mode); own items are found by index. */\n el: HTMLElement | null;\n}\n\nconst DEFAULT_LABEL = 'Regions';\nlet nextId = 0;\n\n/** Controls inside a list item, which are actions and not part of the region's name. */\nconst NOT_LABEL = 'button, input, select, textarea, ol, ul, [hidden], [aria-hidden=\"true\"]';\n\n/**\n * Kept with `no-style`: the layout (the image at its own width, at most the element's, and\n * the list beside it when at least 14rem is left, else under it: the same wrapping flex row\n * base.css gives the children before the element upgrades, so nothing moves), the overlay\n * over the image, and the double outlines and number badges (without them the regions are\n * not visible). `host` is `:host` (shadow) or the tag (light DOM).\n */\nconst structuralRules = (host: string) => `\n ${host} { display: block; }\n ${host} .layout {\n display: flex;\n flex-wrap: wrap;\n gap: 1rem;\n align-items: flex-start;\n }\n ${host} .column { flex: 0 1 auto; min-width: 0; max-width: 100%; }\n ${host} .media {\n position: relative;\n width: fit-content;\n min-width: 0;\n max-width: 100%;\n margin: 0;\n }\n ${host} .list { flex: 1 1 14rem; min-width: 0; }\n ${host} .media img, ${host} .img-host > picture${\n host === ':host' ? ', ::slotted(img), ::slotted(picture)' : ''\n } { display: block; max-width: 100%; height: auto; }\n ${host} .overlay {\n position: absolute;\n inset: 0;\n overflow: clip;\n overflow-clip-margin: 0.5rem;\n pointer-events: none;\n forced-color-adjust: none;\n }\n ${host} .region {\n position: absolute;\n box-sizing: border-box;\n border: 2px solid #fff;\n outline: 2px solid #000;\n pointer-events: auto;\n cursor: pointer;\n }\n ${host} .region.active { z-index: 1; border-width: 4px; outline-width: 4px; }\n ${host} .overlay.has-active .region:not(.active) { opacity: 0.6; }\n ${host} .badge {\n position: absolute;\n inset-block-start: 0;\n inset-inline-start: 0;\n display: flex;\n gap: 0.375em;\n max-width: 16rem;\n padding: 0.0625rem 0.375rem;\n background: #000;\n color: #fff;\n font-size: 0.875rem;\n font-weight: 700;\n line-height: 1.25;\n white-space: nowrap;\n outline: 1px solid #fff;\n }\n ${host} .region:not([data-inside]) .badge {\n inset-block-start: auto;\n inset-block-end: calc(100% + 4px);\n inset-inline-start: -4px;\n }\n ${host} .region.active:not([data-inside]) .badge {\n inset-block-end: calc(100% + 8px);\n inset-inline-start: -8px;\n }\n ${host} .badge .name { overflow: hidden; text-overflow: ellipsis; }\n ${host} .region:not(.active) .badge .name, ${host} .badge:empty { display: none; }\n ${host} .region:not(.active) .badge.no-number { display: none; }\n ${host} .heading { margin: 0 0 0.5rem; }\n ${host} .items { margin: 0; }\n @media (forced-colors: active) {\n ${host} .region { border-color: Canvas; outline-color: CanvasText; }\n ${host} .region.active { outline-color: Highlight; }\n ${host} .badge { background: CanvasText; color: Canvas; outline-color: Canvas; }\n ${host} .region.active .badge { background: Highlight; color: HighlightText; }\n }\n ${host}[hidden], ${host} [hidden] { display: none !important; }\n`;\nconst shadowStructure = unsafeCSS(structuralRules(':host'));\n\n/**\n * A region's list entry: room for the highlight bar, and the bar (with a tint) while its\n * region is highlighted, so it is shown by more than colour. Shadow mode also installs\n * these in the page, scoped to the tag, for the author's own list items.\n */\nconst entryRules = (p: string) => `\n ${p}[data-uvalib-region] {\n box-sizing: border-box;\n padding-block: 0.5rem;\n padding-inline: calc(0.5rem + 0.375rem) 0.5rem;\n overflow-wrap: anywhere;\n }\n ${p}[data-uvalib-region][data-uvalib-active] {\n padding-inline-start: 0.5rem;\n border-inline-start: 0.375rem solid currentColor;\n background: var(--uva-color-surface-hover, #f1f1f1);\n }\n ${p}[data-uvalib-region]:focus-visible {\n outline: 3px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));\n outline-offset: 2px;\n }\n ${p}[data-uvalib-region][tabindex='-1']:focus:not(:focus-visible) { outline: none; }\n @media (forced-colors: active) {\n ${p}[data-uvalib-region][data-uvalib-active] { border-inline-start-color: Highlight; }\n }\n`;\nconst entryStyles = unsafeCSS(entryRules(''));\n\n/**\n * An image with numbered region outlines (people, objects, inscriptions) and a list of the\n * same regions beside it (under it on a narrow screen). The list is the way in: the\n * outlines are a visual aid, hidden from assistive technology and not in the tab order, so\n * no region is a second tab stop. Hovering or focusing a list entry (or anything in it)\n * highlights its region with a thicker double outline and its label, and dims the others;\n * hovering a region highlights its entry. Clicking a region moves focus to its entry.\n *\n * The image: an `<img>` (or `<picture>`) child, which keeps its `alt`, or `src` and `alt`.\n * Give it `width` and `height` so its space is reserved before it loads.\n *\n * The regions: an `<ol>` child whose `<li>` items carry `data-xywh` (IIIF / Media Fragments:\n * `percent:10,20,30,40`, or pixels `160,120,320,240` of the image's natural size). The list\n * is shown as written, so it works before the component loads or without JavaScript, and\n * any links and buttons in it stay the page's own (their events are the page's). Or set\n * the `items` property, and the component draws the list. Region numbers are the list's\n * numbers, from 1 (or the `<ol>`'s `start`).\n *\n * @tagname uvalib-image-regions\n * @slot - The region list (`<ol>` with `<li data-xywh>`), shown as written. Not used with `items`.\n * @slot image - The image. A first `<img>` or `<picture>` child is put here by itself.\n * @slot controls - Controls for the image (a lightbox's version comparison), under the image and before the list in reading order. Not covered by the outlines.\n * @csspart layout - The grid holding the image and the list.\n * @csspart media - The image and its overlay.\n * @csspart overlay - The outlines over the image (`aria-hidden`).\n * @csspart region - One outline.\n * @csspart list - The heading and the list.\n * @fires highlight - The highlighted region changed by hover or focus: `detail` is `{ item, index }` (`item` null and `index` -1 when none is). Bubbles and is composed.\n * @fires uvalib-image-regions-activate - A region's outline was clicked, before its list entry takes focus: `detail` is `{ index, item, entry }` (`index` from 0; `item` the region's record; `entry` the page's own `<li>`, from its child list or a lightbox's lent list, or null when this element drew the list from `items`). Cancelable: `preventDefault()` keeps the entry from taking focus, so the page can focus its own control in it instead (a \"Who is this?\" field). Bubbles and is composed.\n * @fires select - A region's outline was clicked, after its entry took focus (or the page took the activate over): `detail` is `{ item, index, entry }`. Bubbles and is composed. Prefer `uvalib-image-regions-activate`: `select` is also the name of the native text-selection event.\n * @fires uvalib-analytics-event - For `<site-analytics>`: `['uvalib-image-regions', 'select', '<label>', <number>]` when an outline is clicked (the list's `label`, and the region's number from 1). Never a region's label (it may be a person's name). Nothing on hover or focus. Bubbles and is composed.\n * @cssprop --uva-color-text - Dark-mode role token: text (else `--uva-grey-darkest`).\n * @cssprop --uva-color-surface-hover - Dark-mode role token: the highlighted entry's tint (else #f1f1f1).\n * @cssprop --uva-color-link - Dark-mode role token: entry links (else `--uva-brand-blue`).\n * @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).\n * @cssprop --uva-color-text-muted - Dark-mode role token: descriptions (else #4b5563).\n */\nexport class UvalibImageRegions extends UvalibElement {\n static styles = [\n accessible,\n shadowStructure,\n entryStyles,\n css`\n .list {\n color: var(--uva-color-text, var(--uva-grey-darkest, #2b2b2b));\n }\n .heading {\n font-size: 1.125rem;\n font-weight: 700;\n line-height: 1.3;\n }\n .items {\n padding-inline-start: 1.75rem;\n }\n .items a {\n color: var(--uva-color-link, var(--uva-brand-blue, #232d4b));\n }\n .description {\n display: block;\n color: var(--uva-color-text-muted, #4b5563);\n font-size: 0.9375rem;\n }\n @media (prefers-reduced-motion: no-preference) {\n .region {\n transition: opacity 0.15s ease;\n }\n }\n `,\n ];\n\n /** The regions, when the component draws the list. Overrides the child list. */\n @property({ attribute: false }) items: ImageRegion[] | null = null;\n\n /** Image URL, when there is no `<img>` child. */\n @property({ type: String }) src = '';\n /** The image's alternative text (with `src`). */\n @property({ type: String }) alt = '';\n /** The image's width (with `src`), reserving its space. */\n @property({ type: Number }) width?: number;\n /** The image's height (with `src`). */\n @property({ type: Number }) height?: number;\n\n /**\n * The size pixel regions are measured in, when it is not the image's natural size (for\n * example a IIIF derivative of a larger original: the original's width and height).\n */\n @property({ type: Number, attribute: 'image-width' }) imageWidth?: number;\n /** The height pixel regions are measured in (with `image-width`). */\n @property({ type: Number, attribute: 'image-height' }) imageHeight?: number;\n\n /** The list's heading, and the analytics name. */\n @property({ type: String }) label = 'Regions';\n\n /** The heading's level (2 to 6). Default: one below the heading before the element. */\n @property({ type: Number, attribute: 'heading-level' }) headingLevel?: number;\n\n /** `numbers` (default) shows each region's number on its outline; `none` hides them. */\n @property({ type: String }) numbering: 'numbers' | 'none' = 'numbers';\n\n /** Hide the outlines (the list stays). */\n @property({ type: Boolean, reflect: true, attribute: 'hide-outlines' }) hideOutlines = false;\n\n @state() private entries: Entry[] = [];\n @state() private natural: { w: number; h: number } | null = null;\n @state() private active = -1;\n @state() private inferredLevel = 2;\n\n private hover = -1;\n private focused = -1;\n private readonly headingId = `uvalib-image-regions-heading-${++nextId}`;\n private observer?: MutationObserver;\n private watchedImg: HTMLImageElement | null = null;\n /** A list slotted through a `<slot>` child (from a host element's light DOM), also observed. */\n private slottedList: Element | null = null;\n private key = '';\n /** The image's rendered size decides where badges fit. */\n private resizer?: ResizeObserver;\n private resized = 0;\n\n constructor() {\n super();\n this.addEventListener('pointerover', this.onPointerOver);\n this.addEventListener('pointerleave', this.onPointerLeave);\n this.addEventListener('focusin', this.onFocusIn);\n this.addEventListener('focusout', this.onFocusOut);\n this.addEventListener('click', this.onClick);\n }\n\n protected override createRenderRoot(): HTMLElement | DocumentFragment {\n const root = super.createRenderRoot();\n if (this.noStyle && root instanceof ShadowRoot && shadowStructure.styleSheet)\n root.adoptedStyleSheets = [shadowStructure.styleSheet];\n return root;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n const node = this.getRootNode();\n const root = node instanceof Document || node instanceof ShadowRoot ? node : undefined;\n if (this.lightDom && this.noStyle) {\n installLightDomStyles(\n `${this.localName}::structure`,\n unsafeCSS(structuralRules(this.localName)),\n { root, scope: false },\n );\n } else if (!this.lightDom && !this.noStyle) {\n // The author's list items are page content: their highlight is styled in the page.\n installLightDomStyles(\n `${this.localName}::entries`,\n unsafeCSS(entryRules(`${this.localName} `)),\n { root, scope: false },\n );\n }\n const above = precedingHeadingLevel(this);\n this.inferredLevel = above === null ? 2 : Math.min(Math.max(above + 1, 2), 6);\n this.slottedList = null;\n this.sync();\n this.observe();\n }\n\n /** Watch the children, and a list slotted from outside them (it is not in this subtree). */\n private observe(): void {\n this.observer ??= new MutationObserver(() => this.sync());\n this.observer.disconnect();\n const options: MutationObserverInit = {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['data-xywh', 'data-label', 'data-id', 'href', 'start', 'src', 'srcset'],\n characterData: true,\n };\n this.observer.observe(this, options);\n if (this.slottedList) this.observer.observe(this.slottedList, options);\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.observer?.disconnect();\n this.resizer?.disconnect();\n this.resizer = undefined;\n this.watchImage(null);\n }\n\n protected override willUpdate(changed: PropertyValues): void {\n if (changed.has('items') || changed.has('src')) this.sync();\n }\n\n protected override updated(changed: PropertyValues): void {\n super.updated(changed);\n this.arrange();\n this.observeSize();\n this.place();\n this.mark();\n // Reading the image's size may set state: not from inside this update.\n queueMicrotask(() => {\n if (this.isConnected) this.watchImage(this.imageEl());\n });\n }\n\n // ---------------------------------------------------------------- sources\n\n /** The author's image element (`<img>` or `<picture>`), wherever it is now. */\n private sourceImage(): HTMLElement | null {\n if (this.src) return null;\n const kids = this.lightDom\n ? [...this.children, ...(this.imgHost?.children ?? [])]\n : [...this.children];\n const named = kids.find((k) => k.getAttribute('slot') === 'image');\n const el = named ?? kids.find((k) => k.localName === 'img' || k.localName === 'picture');\n return el instanceof HTMLElement ? el : null;\n }\n\n /**\n * The author's list (`<ol>` or `<ul>`), wherever it is now. A `<slot>` child (this element\n * inside another component's shadow root) passes on that host's list, which stays in the\n * page's light DOM (so the page's styles and listeners still apply to it).\n */\n private sourceList(): HTMLOListElement | HTMLUListElement | null {\n const kids = (\n this.lightDom ? [...this.children, ...(this.listHost?.children ?? [])] : [...this.children]\n ).flatMap((k) => (k instanceof HTMLSlotElement ? k.assignedElements({ flatten: true }) : [k]));\n const el = kids.find((k) => k.localName === 'ol' || k.localName === 'ul');\n return (el as HTMLOListElement | HTMLUListElement | undefined) ?? null;\n }\n\n private get imgHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .img-host') : null;\n }\n\n private get listHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .list-host') : null;\n }\n\n private get controlsHost(): HTMLElement | null {\n return this.lightDom ? this.querySelector(':scope > .layout .controls-host') : null;\n }\n\n /** The `<img>` whose natural size measures pixel regions. */\n private imageEl(): HTMLImageElement | null {\n if (this.src) return this.renderRoot.querySelector<HTMLImageElement>('.media > img');\n const el = this.sourceImage();\n if (!el) return null;\n return el instanceof HTMLImageElement ? el : el.querySelector('img');\n }\n\n /** Re-read the regions (and in shadow mode put the image in its slot). */\n private sync(): void {\n const img = this.sourceImage();\n if (img && !this.lightDom && !img.hasAttribute('slot')) img.setAttribute('slot', 'image');\n const next = this.items ? this.fromItems(this.items) : this.fromList();\n const key = JSON.stringify(next.map((e) => [e.item, e.box, e.number]));\n const sameEls =\n next.length === this.entries.length && next.every((e, i) => e.el === this.entries[i]?.el);\n if (key === this.key && sameEls) return;\n this.key = key;\n this.entries = next;\n if (this.active >= next.length) this.active = -1;\n }\n\n private fromItems(items: unknown[]): Entry[] {\n const out: Entry[] = [];\n for (const raw of Array.isArray(items) ? items : []) {\n const item = toRegion(raw);\n if (!item) continue;\n const { x, y, w, h, unit = 'px' } = item;\n out.push({ item, box: { x, y, w, h, unit }, number: out.length + 1, el: null });\n }\n return out;\n }\n\n private fromList(): Entry[] {\n const list = this.sourceList();\n const outside = list && !this.contains(list) ? list : null;\n if (outside !== this.slottedList) {\n this.slottedList = outside;\n if (this.isConnected) this.observe();\n if (outside && !this.noStyle) {\n // Its entries are styled where the list is (the page), not under this tag.\n const root = outside.getRootNode();\n if (root instanceof Document || root instanceof ShadowRoot)\n installLightDomStyles(`${this.localName}::slotted-entries`, entryStyles, {\n root,\n scope: false,\n });\n }\n }\n if (!list) return [];\n const start = list.localName === 'ol' ? Number(list.getAttribute('start') ?? 1) || 1 : 1;\n const out: Entry[] = [];\n [...list.children].forEach((li, i) => {\n if (li.localName !== 'li' || !(li instanceof HTMLElement)) return;\n const box = parseXywh(li.dataset.xywh);\n const link = li.querySelector('a[href]');\n const label = normalize(li.dataset.label) || normalize(link?.textContent) || this.text(li);\n const item: ImageRegion = box ? { label, ...box } : { label, x: 0, y: 0, w: 0, h: 0 };\n const id = normalize(li.dataset.id) || li.id;\n if (id) item.id = id;\n const href = link?.getAttribute('href');\n if (href) item.href = href;\n out.push({ item, box, number: start + i, el: li });\n });\n return out;\n }\n\n /** A list item's own text, without its actions (buttons, fields) or a nested list. */\n private text(li: Element): string {\n const parts: string[] = [];\n const walk = (n: Node) => {\n if (n.nodeType === Node.TEXT_NODE) parts.push(n.textContent ?? '');\n else if (n instanceof Element && !n.matches(NOT_LABEL)) n.childNodes.forEach(walk);\n };\n li.childNodes.forEach(walk);\n return normalize(parts.join(' '));\n }\n\n // ---------------------------------------------------------------- layout\n\n /** Light DOM: move the author's image and list into the layout (the same nodes). */\n private arrange(): void {\n if (!this.lightDom) return;\n const img = this.sourceImage();\n const imgHost = this.imgHost;\n if (img && imgHost && img.parentElement !== imgHost) imgHost.append(img);\n const list = this.items ? null : this.sourceList();\n const listHost = this.listHost;\n if (list && listHost && list.parentElement !== listHost) listHost.append(list);\n const controls = this.querySelector(':scope > [slot=\"controls\"]');\n if (controls) this.controlsHost?.append(controls);\n }\n\n private watchImage(img: HTMLImageElement | null): void {\n if (img === this.watchedImg) {\n if (img) this.measure();\n return;\n }\n this.watchedImg?.removeEventListener('load', this.onImageLoad);\n this.watchedImg = img;\n img?.addEventListener('load', this.onImageLoad);\n this.measure();\n }\n\n private readonly onImageLoad = (): void => this.measure();\n\n private measure(): void {\n const img = this.watchedImg;\n const w = img?.complete ? img.naturalWidth : 0;\n const h = img?.complete ? img.naturalHeight : 0;\n const next = w > 0 && h > 0 ? { w, h } : null;\n if (next?.w !== this.natural?.w || next?.h !== this.natural?.h) this.natural = next;\n }\n\n /** The size pixel regions are measured in. */\n private get space(): { w: number; h: number } {\n const w = Number(this.imageWidth);\n const h = Number(this.imageHeight);\n if (w > 0 && h > 0) return { w, h };\n return this.natural ?? { w: 0, h: 0 };\n }\n\n /**\n * Position the outlines in percent of the image, so they scale with it (CSSOM, not markup).\n * A number badge sits above its outline, or inside it when there is no room above.\n */\n private place(): void {\n const { w, h } = this.space;\n const overlay = this.renderRoot.querySelector<HTMLElement>('.overlay');\n const tall = overlay?.clientHeight ?? 0;\n for (const el of this.renderRoot.querySelectorAll<HTMLElement>('.overlay > .region')) {\n const entry = this.entries[Number(el.dataset.index)];\n const box = entry?.box ? toPercent(entry.box, w, h) : null;\n el.hidden = !box;\n if (!box) continue;\n el.style.left = `${box.x}%`;\n el.style.top = `${box.y}%`;\n el.style.width = `${box.w}%`;\n el.style.height = `${box.h}%`;\n el.toggleAttribute('data-inside', (box.y / 100) * tall < 28);\n }\n }\n\n private observeSize(): void {\n const media = this.renderRoot.querySelector<HTMLElement>('.media');\n if (!media || typeof ResizeObserver === 'undefined') return;\n if (!this.resizer) {\n this.resizer = new ResizeObserver(() => {\n // The outlines scale by themselves (percent); only the badges' side may change.\n const h = media.clientHeight;\n if (h === this.resized) return;\n this.resized = h;\n this.place();\n });\n this.resizer.observe(media);\n }\n }\n\n /** The list entry of region `i`. */\n private entryEl(i: number): HTMLElement | null {\n const entry = this.entries[i];\n if (!entry) return null;\n if (entry.el) return entry.el;\n return this.renderRoot.querySelector<HTMLElement>(`.items > li[data-index=\"${i}\"]`);\n }\n\n /** Mark the entries (their padding) and the highlighted one. */\n private mark(): void {\n const list = this.items ? null : this.sourceList();\n this.entries.forEach((e, i) => {\n const el = this.entryEl(i);\n // An author's item that has left the list (given back to the page) is not marked again.\n if (!el || (e.el && e.el.parentElement !== list)) return;\n if (el.getAttribute('data-uvalib-region') !== String(e.number))\n el.setAttribute('data-uvalib-region', String(e.number));\n el.toggleAttribute('data-uvalib-active', i === this.active);\n });\n }\n\n // ---------------------------------------------------------------- interaction\n\n /** The region an event is about: its outline or its list entry (or anything inside it). */\n private indexFrom(e: Event): { i: number; outline: boolean } | null {\n for (const n of e.composedPath()) {\n if (n === this) break;\n if (!(n instanceof HTMLElement)) continue;\n if (n.classList.contains('region') && n.parentElement?.classList.contains('overlay'))\n return { i: Number(n.dataset.index), outline: true };\n const at = this.entries.findIndex((en, i) => (en.el ?? this.entryEl(i)) === n);\n if (at >= 0) return { i: at, outline: false };\n }\n return null;\n }\n\n private setActive(): void {\n const next = this.hover >= 0 ? this.hover : this.focused;\n if (next === this.active) return;\n this.active = next;\n const item = this.entries[next]?.item ?? null;\n this.dispatchEvent(\n new CustomEvent('highlight', {\n detail: { item, index: item ? next : -1 },\n bubbles: true,\n composed: true,\n }),\n );\n }\n\n private readonly onPointerOver = (e: PointerEvent): void => {\n this.hover = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onPointerLeave = (): void => {\n this.hover = -1;\n this.setActive();\n };\n\n private readonly onFocusIn = (e: FocusEvent): void => {\n this.focused = this.indexFrom(e)?.i ?? -1;\n this.setActive();\n };\n\n private readonly onFocusOut = (e: FocusEvent): void => {\n const to = e.relatedTarget;\n if (\n to instanceof Node &&\n (this.contains(to) || this.renderRoot.contains(to) || this.slottedList?.contains(to))\n )\n return;\n this.focused = -1;\n this.setActive();\n };\n\n private readonly onClick = (e: MouseEvent): void => {\n const hit = this.indexFrom(e);\n if (!hit?.outline) return;\n this.choose(hit.i);\n };\n\n /**\n * An outline was clicked: say so first (`uvalib-image-regions-activate`, cancelable), then,\n * unless the page took it over, focus the entry; then `select`. `entry` is the page's own\n * `<li>` (its child list or a lightbox's lent list), never one this element drew from `items`.\n */\n private choose(i: number): void {\n const entry = this.entries[i];\n const el = this.entryEl(i);\n if (!entry || !el) return;\n const detail = { index: i, item: entry.item, entry: entry.el ?? null };\n const go = this.dispatchEvent(\n new CustomEvent('uvalib-image-regions-activate', {\n detail,\n bubbles: true,\n composed: true,\n cancelable: true,\n }),\n );\n if (go) {\n if (!el.hasAttribute('tabindex')) el.tabIndex = -1;\n el.focus();\n el.scrollIntoView({ block: 'nearest', inline: 'nearest' });\n }\n this.dispatchEvent(\n new CustomEvent('select', {\n detail: { item: entry.item, index: i, entry: detail.entry },\n bubbles: true,\n composed: true,\n }),\n );\n const name = normalize(this.label) || DEFAULT_LABEL;\n trackEvent(this, ['uvalib-image-regions', 'select', name, entry.number]);\n }\n\n // ---------------------------------------------------------------- render\n\n private get level(): number {\n const n = Math.trunc(Number(this.headingLevel));\n return n >= 2 && n <= 6 ? n : this.inferredLevel;\n }\n\n private renderOwnList() {\n const base = this.ownerDocument.baseURI;\n return html`<ol class=\"items\" aria-labelledby=${this.headingId}>\n ${this.entries.map(({ item }, i) => {\n const href = item.href && safeHref(item.href, base) ? item.href : '';\n return html`<li data-index=${i}>\n ${href ? html`<a href=${href}>${item.label}</a>` : html`<span>${item.label}</span>`}\n ${item.description ? html`<span class=\"description\">${item.description}</span>` : nothing}\n </li>`;\n })}\n </ol>`;\n }\n\n protected override render() {\n const light = this.lightDom;\n const numbers = this.numbering !== 'none';\n const image = this.src\n ? html`<img\n part=\"image\"\n src=${this.src}\n alt=${this.alt}\n width=${this.width ?? nothing}\n height=${this.height ?? nothing}\n @load=${this.onImageLoad}\n />`\n : light\n ? html`<div class=\"img-host\"></div>`\n : html`<slot name=\"image\" @slotchange=${() => this.requestUpdate()}></slot>`;\n const list = this.items\n ? this.renderOwnList()\n : light\n ? html`<div class=\"list-host\"></div>`\n : html`<slot @slotchange=${() => this.sync()}></slot>`;\n const hasActive = this.active >= 0 && !!this.entries[this.active]?.box;\n return html`<div class=\"layout\" part=\"layout\">\n <div class=\"column\">\n <div class=\"media\" part=\"media\">\n ${image}\n <div\n class=\"overlay ${hasActive ? 'has-active' : ''}\"\n part=\"overlay\"\n aria-hidden=\"true\"\n ?hidden=${this.hideOutlines}\n >\n ${this.entries.map((e, i) =>\n e.box\n ? html`<div\n class=\"region ${i === this.active ? 'active' : ''}\"\n part=\"region\"\n data-index=${i}\n >\n <span class=\"badge ${numbers ? '' : 'no-number'}\"\n >${numbers ? html`<span class=\"number\">${e.number}</span>` : nothing}${\n e.item.label ? html`<span class=\"name\">${e.item.label}</span>` : nothing\n }</span\n >\n </div>`\n : nothing,\n )}\n </div>\n </div>\n ${light ? html`<div class=\"controls-host\"></div>` : html`<slot name=\"controls\"></slot>`}\n </div>\n <div class=\"list\" part=\"list\">\n <div class=\"heading\" role=\"heading\" aria-level=${this.level} id=${this.headingId}>\n ${normalize(this.label) || DEFAULT_LABEL}\n </div>\n ${list}\n </div>\n </div>`;\n }\n}\n","import { define } from '../../base/define.js';\nimport { UvalibImageRegions } from './UvalibImageRegions.js';\n\ndefine('uvalib-image-regions', UvalibImageRegions);\n"],"mappings":";;;;;;;AAqBA,IAAMsB,IAAgB,WAClBC,IAAS,GAGPC,IAAY,6EASZC,KAAmB,MAAiB;IACtCC,EAAK;IACLA,EAAK;;;;;;IAMLA,EAAK;IACLA,EAAK;;;;;;;IAOLA,EAAK;IACLA,EAAK,eAAeA,EAAK,sBACzBA,MAAS,UAAU,yCAAyC,GAC7D;IACCA,EAAK;;;;;;;;IAQLA,EAAK;;;;;;;;IAQLA,EAAK;IACLA,EAAK;IACLA,EAAK;;;;;;;;;;;;;;;;IAgBLA,EAAK;;;;;IAKLA,EAAK;;;;IAILA,EAAK;IACLA,EAAK,sCAAsCA,EAAK;IAChDA,EAAK;IACLA,EAAK;IACLA,EAAK;;MAEHA,EAAK;MACLA,EAAK;MACLA,EAAK;MACLA,EAAK;;IAEPA,EAAK,YAAYA,EAAK;GAEpBC,IAAkB3B,EAAUyB,EAAgB,OAAO,CAAC,GAOpDG,KAAc,MAAc;IAC9BC,EAAE;;;;;;IAMFA,EAAE;;;;;IAKFA,EAAE;;;;IAIFA,EAAE;;MAEAA,EAAE;;GAGFC,IAAc9B,EAAU4B,EAAW,EAAE,CAAC,GAuC/BG,IAAb,cAAwClB,EAAc;;EACpC,KAAA,SAAA;GACdK;GACAS;GACAG;GACA,CAAG;;;;;;;;;;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