react-iiif-vault 0.9.13 → 0.9.16

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 (34) hide show
  1. package/.build/types/canvas-panel/Viewer.d.ts +1 -1
  2. package/.build/types/canvas-panel/index.d.ts +2 -0
  3. package/.build/types/canvas-panel/render/Canvas.d.ts +8 -3
  4. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +4 -0
  5. package/.build/types/canvas-panel/render/Image.d.ts +2 -2
  6. package/.build/types/context/ContextBridge.d.ts +1 -9
  7. package/.build/types/context/PortalContext.d.ts +3 -2
  8. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
  9. package/.build/types/features/rendering-strategy/rendering-utils.d.ts +5 -1
  10. package/.build/types/features/rendering-strategy/resource-types.d.ts +3 -0
  11. package/.build/types/features/rendering-strategy/strategies.d.ts +10 -1
  12. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +17 -0
  13. package/.build/types/future-helpers/ranges.d.ts +6 -0
  14. package/.build/types/future-helpers/sequences.d.ts +6 -0
  15. package/.build/types/hooks/useCanvasSubset.d.ts +2 -0
  16. package/.build/types/index.d.ts +5 -0
  17. package/.build/types/viewers/SimpleViewerContext.d.ts +4 -16
  18. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +14 -0
  19. package/.build/types/viewers/SimpleViewerContext.types.d.ts +42 -0
  20. package/dist/bundle/cjs/index.js +5 -11
  21. package/dist/bundle/cjs/index.js.map +1 -1
  22. package/dist/bundle/esm/index.mjs +1034 -260
  23. package/dist/bundle/esm/index.mjs.map +1 -1
  24. package/dist/canvas-panel/cjs/canvas-panel.js +5 -11
  25. package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
  26. package/dist/canvas-panel/esm/canvas-panel.mjs +744 -141
  27. package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
  28. package/dist/index.umd.js +30 -36
  29. package/dist/index.umd.js.map +1 -1
  30. package/dist/react17/cjs/index.js +30 -0
  31. package/dist/react17/cjs/index.js.map +1 -0
  32. package/dist/react17/esm/index.mjs +3186 -0
  33. package/dist/react17/esm/index.mjs.map +1 -0
  34. package/package.json +16 -11
@@ -30,18 +30,20 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
  import * as React from "react";
33
- import React__default, { useContext, useMemo, useState, useEffect, createContext, useCallback, useRef, useLayoutEffect, Fragment as Fragment$1, useReducer } from "react";
34
- import { AtlasAuto, mergeStyles, RegionHighlight, TileSet } from "@atlas-viewer/atlas";
33
+ import React__default, { useContext, useMemo, useState, useEffect, useCallback, createContext, useRef, useLayoutEffect, Fragment, useReducer } from "react";
34
+ import { AtlasAuto, mergeStyles, RegionHighlight, TileSet, HTMLPortal } from "@atlas-viewer/atlas";
35
+ import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
35
36
  import { globalVault, Vault } from "@iiif/vault";
36
37
  import { createAction } from "typesafe-actions";
37
- import require$$0 from "react-dom";
38
+ import { createRoot } from "react-dom/client";
39
+ import { expandTarget as expandTarget$1 } from "@iiif/vault-helpers";
38
40
  import { ImageServiceLoader, getImageServices, getFixedSizeFromImage } from "@atlas-viewer/iiif-image-api";
39
- function _setPrototypeOf(o, p2) {
40
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p3) {
41
- o2.__proto__ = p3;
41
+ function _setPrototypeOf(o, p) {
42
+ _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
43
+ o2.__proto__ = p2;
42
44
  return o2;
43
45
  };
44
- return _setPrototypeOf(o, p2);
46
+ return _setPrototypeOf(o, p);
45
47
  }
46
48
  function _inheritsLoose(subClass, superClass) {
47
49
  subClass.prototype = Object.create(superClass.prototype);
@@ -125,39 +127,6 @@ var ErrorBoundary = /* @__PURE__ */ function(_React$Component) {
125
127
  };
126
128
  return ErrorBoundary2;
127
129
  }(React.Component);
128
- var jsxRuntime = { exports: {} };
129
- var reactJsxRuntime_production_min = {};
130
- /**
131
- * @license React
132
- * react-jsx-runtime.production.min.js
133
- *
134
- * Copyright (c) Facebook, Inc. and its affiliates.
135
- *
136
- * This source code is licensed under the MIT license found in the
137
- * LICENSE file in the root directory of this source tree.
138
- */
139
- var f = React__default, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m$1 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
140
- function q(c, a, g) {
141
- var b, d = {}, e = null, h = null;
142
- g !== void 0 && (e = "" + g);
143
- a.key !== void 0 && (e = "" + a.key);
144
- a.ref !== void 0 && (h = a.ref);
145
- for (b in a)
146
- m$1.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
147
- if (c && c.defaultProps)
148
- for (b in a = c.defaultProps, a)
149
- d[b] === void 0 && (d[b] = a[b]);
150
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
151
- }
152
- reactJsxRuntime_production_min.Fragment = l;
153
- reactJsxRuntime_production_min.jsx = q;
154
- reactJsxRuntime_production_min.jsxs = q;
155
- {
156
- jsxRuntime.exports = reactJsxRuntime_production_min;
157
- }
158
- const jsx = jsxRuntime.exports.jsx;
159
- const jsxs = jsxRuntime.exports.jsxs;
160
- const Fragment = jsxRuntime.exports.Fragment;
161
130
  const defaultResourceContext = {
162
131
  collection: void 0,
163
132
  manifest: void 0,
@@ -299,6 +268,238 @@ function useVisibleCanvases() {
299
268
  return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
300
269
  }, [ids]);
301
270
  }
271
+ function useManifest(options = {}, deps = []) {
272
+ const { id, selector } = options;
273
+ const ctx = useResourceContext();
274
+ useVault();
275
+ const manifestId = id ? id : ctx.manifest;
276
+ const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
277
+ return useMemo(() => {
278
+ if (!manifest) {
279
+ return void 0;
280
+ }
281
+ if (selector) {
282
+ return selector(manifest);
283
+ }
284
+ return manifest;
285
+ }, [manifest, selector, ...deps]);
286
+ }
287
+ function RangeContext({
288
+ range,
289
+ children
290
+ }) {
291
+ return /* @__PURE__ */ jsx(ResourceProvider, {
292
+ value: {
293
+ range
294
+ },
295
+ children
296
+ });
297
+ }
298
+ function findFirstCanvasFromRange(vault, range) {
299
+ for (const inner of range.items) {
300
+ if (inner.type === "Canvas") {
301
+ return inner;
302
+ }
303
+ if (inner.type === "Range") {
304
+ const found = findFirstCanvasFromRange(vault, vault.get(inner));
305
+ if (found) {
306
+ return found;
307
+ }
308
+ }
309
+ }
310
+ return null;
311
+ }
312
+ function findAllCanvasesInRange(vault, range) {
313
+ const found = [];
314
+ for (const inner of range.items) {
315
+ if (inner.type === "Canvas") {
316
+ if (inner.id.indexOf("#") !== -1) {
317
+ found.push({ id: inner.id.split("#")[0], type: "Canvas" });
318
+ } else {
319
+ found.push(inner);
320
+ }
321
+ }
322
+ if (inner.type === "Range") {
323
+ found.push(...findAllCanvasesInRange(vault, vault.get(inner)));
324
+ }
325
+ if (inner.type === "SpecificResource") {
326
+ const sourceId = typeof inner.source === "string" ? inner.source : inner.source.id;
327
+ found.push({ id: sourceId, type: "Canvas" });
328
+ }
329
+ }
330
+ return found;
331
+ }
332
+ function findManifestSelectedRange(vault, manifest, canvasId) {
333
+ for (const range of manifest.structures) {
334
+ const found = findSelectedRange(vault, vault.get(range), canvasId);
335
+ if (found) {
336
+ return found;
337
+ }
338
+ }
339
+ return null;
340
+ }
341
+ function findSelectedRange(vault, range, canvasId) {
342
+ var _a;
343
+ for (const inner of range.items) {
344
+ const parsedId = (_a = inner.id) == null ? void 0 : _a.split("#")[0];
345
+ if (inner.type === "SpecificResource" && inner.source === canvasId) {
346
+ return range;
347
+ }
348
+ if (inner.type === "Canvas" && canvasId === parsedId) {
349
+ return range;
350
+ }
351
+ if (inner.type === "Range") {
352
+ const found = findSelectedRange(vault, vault.get(inner), canvasId);
353
+ if (found) {
354
+ return found;
355
+ }
356
+ }
357
+ }
358
+ return null;
359
+ }
360
+ function getVisibleCanvasesFromCanvasId(vault, manifestOrRange, canvasId, preventPaged = false) {
361
+ const behavior = manifestOrRange.behavior;
362
+ const fullCanvas = canvasId ? vault.get(canvasId) : null;
363
+ if (!fullCanvas) {
364
+ return [];
365
+ }
366
+ const canvasBehavior = fullCanvas.behavior;
367
+ const isPaged = preventPaged ? false : behavior.includes("paged");
368
+ const isContinuous = isPaged ? false : behavior.includes("continuous");
369
+ const isIndividuals = isPaged || isContinuous ? false : behavior.includes("individuals");
370
+ const isCanvasFacingPages = canvasBehavior.includes("facing-pages");
371
+ const isCanvasNonPaged = canvasBehavior.includes("non-paged");
372
+ if (isCanvasFacingPages || isCanvasNonPaged || isIndividuals || preventPaged) {
373
+ return [{ id: fullCanvas.id, type: "Canvas" }];
374
+ }
375
+ const [manifestItems, ordering] = getManifestSequence(vault, manifestOrRange);
376
+ if (isContinuous) {
377
+ return manifestItems;
378
+ }
379
+ const canvasIndex = manifestItems.findIndex((r) => r.id === canvasId);
380
+ if (canvasIndex === -1) {
381
+ return [];
382
+ }
383
+ for (const indexes of ordering) {
384
+ if (indexes.includes(canvasIndex)) {
385
+ return indexes.map((index) => manifestItems[index]);
386
+ }
387
+ }
388
+ return [{ id: fullCanvas.id, type: "Canvas" }];
389
+ }
390
+ function getManifestSequence(vault, manifestOrRange, { disablePaging } = {}) {
391
+ const behavior = manifestOrRange.behavior;
392
+ const isPaged = behavior.includes("paged");
393
+ const isContinuous = isPaged ? false : behavior.includes("continuous");
394
+ const isIndividuals = isPaged || isContinuous ? false : behavior.includes("individuals");
395
+ const manifestItems = manifestOrRange.type === "Manifest" ? manifestOrRange.items : findAllCanvasesInRange(vault, manifestOrRange);
396
+ if (isContinuous) {
397
+ return [manifestItems, [manifestItems.map((_, index) => index)]];
398
+ }
399
+ if (isIndividuals || !isPaged || disablePaging) {
400
+ return [manifestItems, manifestItems.map((_, index) => [index])];
401
+ }
402
+ const ordering = [];
403
+ let currentOrdering = [];
404
+ const flush = () => {
405
+ if (currentOrdering.length) {
406
+ ordering.push([...currentOrdering]);
407
+ currentOrdering = [];
408
+ }
409
+ };
410
+ for (let i = 0; i < manifestItems.length; i++) {
411
+ const canvas = vault.get(manifestItems[i]);
412
+ if (i === 0 || canvas.behavior.includes("facing-pages")) {
413
+ flush();
414
+ ordering.push([i]);
415
+ continue;
416
+ }
417
+ if (canvas.behavior.includes("non-paged")) {
418
+ continue;
419
+ }
420
+ currentOrdering.push(i);
421
+ if (currentOrdering.length > 1) {
422
+ flush();
423
+ }
424
+ }
425
+ if (currentOrdering.length) {
426
+ flush();
427
+ }
428
+ return [manifestItems, ordering];
429
+ }
430
+ function useRange(options = {}, deps = []) {
431
+ const { id, selector } = options;
432
+ const ctx = useResourceContext();
433
+ const rangeId = id ? id : ctx.range;
434
+ const range = useVaultSelector((s) => rangeId ? s.iiif.entities.Range[rangeId] : void 0, [rangeId]);
435
+ return useMemo(() => {
436
+ if (!range) {
437
+ return void 0;
438
+ }
439
+ if (selector) {
440
+ return selector(range);
441
+ }
442
+ return range;
443
+ }, [range, selector, ...deps]);
444
+ }
445
+ function useCanvasSequence({ startCanvas, disablePaging }) {
446
+ var _a;
447
+ const vault = useVault();
448
+ const manifest = useManifest();
449
+ const range = useRange();
450
+ const [cursor, setCursor] = useState(void 0);
451
+ const rangeOrManifest = range ? range : manifest;
452
+ if (!rangeOrManifest) {
453
+ throw new Error("Nothing selected");
454
+ }
455
+ const [items, initialSequence] = useMemo(() => getManifestSequence(vault, rangeOrManifest, { disablePaging }), [vault, rangeOrManifest]);
456
+ const setCanvasIndex = useCallback((index) => {
457
+ const foundSequence = initialSequence.findIndex((i) => i.includes(index));
458
+ setCursor(foundSequence === -1 ? 0 : foundSequence);
459
+ }, [items, initialSequence]);
460
+ const setCanvasId = useCallback((id) => {
461
+ const foundIndex = items.findIndex((i) => i.id === id);
462
+ if (foundIndex !== -1) {
463
+ setCanvasIndex(foundIndex);
464
+ } else {
465
+ setCursor(0);
466
+ }
467
+ }, [items, initialSequence]);
468
+ const next = useCallback(() => {
469
+ setCursor((i) => {
470
+ if (i >= initialSequence.length) {
471
+ return i;
472
+ }
473
+ return i + 1;
474
+ });
475
+ }, [initialSequence]);
476
+ const previous = useCallback(() => {
477
+ setCursor((i) => {
478
+ if (i <= 0) {
479
+ return 0;
480
+ }
481
+ return i - 1;
482
+ });
483
+ }, [initialSequence]);
484
+ if (typeof cursor === "undefined") {
485
+ if (startCanvas) {
486
+ setCanvasId(startCanvas);
487
+ } else {
488
+ setCursor(0);
489
+ }
490
+ }
491
+ return {
492
+ visibleItems: ((_a = initialSequence[cursor]) == null ? void 0 : _a.map((idx) => items[idx].id)) || [],
493
+ cursor,
494
+ items,
495
+ sequence: initialSequence,
496
+ setSequenceIndex: setCursor,
497
+ setCanvasIndex,
498
+ setCanvasId,
499
+ next,
500
+ previous
501
+ };
502
+ }
302
503
  const noop = () => {
303
504
  };
304
505
  const SimpleViewerReactContext = createContext({
@@ -306,92 +507,58 @@ const SimpleViewerReactContext = createContext({
306
507
  setCurrentCanvasIndex: noop,
307
508
  nextCanvas: noop,
308
509
  previousCanvas: noop,
309
- currentCanvasIndex: -1,
310
- totalCanvases: 0,
311
- pagingView: true
510
+ items: [],
511
+ sequence: [],
512
+ setSequenceIndex: noop,
513
+ currentSequenceIndex: 0
312
514
  });
515
+ function InnerViewerProvider(props) {
516
+ const manifest = useManifest();
517
+ const {
518
+ cursor,
519
+ visibleItems,
520
+ next,
521
+ sequence,
522
+ items,
523
+ setCanvasIndex,
524
+ setCanvasId,
525
+ previous,
526
+ setSequenceIndex
527
+ } = useCanvasSequence({
528
+ startCanvas: props.startCanvas,
529
+ disablePaging: props.pagingEnabled === false
530
+ });
531
+ const ctx = useMemo(() => ({
532
+ sequence,
533
+ items,
534
+ setCurrentCanvasId: setCanvasId,
535
+ nextCanvas: next,
536
+ previousCanvas: previous,
537
+ totalCanvases: items.length,
538
+ setCurrentCanvasIndex: setCanvasIndex,
539
+ setSequenceIndex,
540
+ currentSequenceIndex: cursor
541
+ }), [sequence, items, setCanvasId, next, previous, items, setCanvasIndex, setSequenceIndex, cursor]);
542
+ if (!manifest) {
543
+ console.warn("The manifest passed to the provider is not a valid IIIF manifest.");
544
+ return /* @__PURE__ */ jsx("div", {
545
+ children: "Sorry, something went wrong."
546
+ });
547
+ }
548
+ return /* @__PURE__ */ jsx(SimpleViewerReactContext.Provider, {
549
+ value: ctx,
550
+ children: /* @__PURE__ */ jsx(VisibleCanvasReactContext.Provider, {
551
+ value: visibleItems,
552
+ children: /* @__PURE__ */ jsx(CanvasContext, {
553
+ canvas: visibleItems[0],
554
+ children: props.children
555
+ })
556
+ })
557
+ });
558
+ }
313
559
  function SimpleViewerProvider(props) {
314
560
  const manifest = useExternalManifest(props.manifest);
315
- const [currentCanvasId, setCurrentCanvasId] = useState("");
316
- const [visible, setVisible] = useState([]);
317
- const pagingView = (typeof props.pagingEnabled === "undefined" || props.pagingEnabled) && manifest.manifest && manifest.manifest.behavior && manifest.manifest.behavior.includes("paged");
318
- useEffect(() => {
319
- var _a, _b;
320
- if (manifest.manifest) {
321
- setCurrentCanvasId((_a = manifest.manifest.items[0]) == null ? void 0 : _a.id);
322
- setVisible([(_b = manifest.manifest.items[0]) == null ? void 0 : _b.id]);
323
- }
324
- }, [manifest.manifest, props.manifest]);
325
- const canvasList = useMemo(() => {
326
- var _a;
327
- return ((_a = manifest.manifest) == null ? void 0 : _a.items.map((c) => c.id)) || [];
328
- }, [manifest.manifest, props.manifest]);
329
- const currentCanvasIndex = useMemo(() => canvasList.indexOf(currentCanvasId), [canvasList, currentCanvasId]);
330
- const nextCanvas = useCallback(() => {
331
- if (canvasList.length && currentCanvasId) {
332
- if (currentCanvasIndex === -1) {
333
- return;
334
- }
335
- if (canvasList[currentCanvasIndex + 2] ? currentCanvasIndex + 2 === canvasList.length : currentCanvasIndex === canvasList.length) {
336
- return;
337
- }
338
- const newCanvas = pagingView && currentCanvasIndex !== 0 ? canvasList[currentCanvasIndex + 2] : canvasList[currentCanvasIndex + 1];
339
- const pageCanvas = pagingView ? currentCanvasIndex !== 0 ? canvasList[currentCanvasIndex + 3] : canvasList[currentCanvasIndex + 2] : null;
340
- if (newCanvas) {
341
- setCurrentCanvasId(newCanvas);
342
- setVisible(pageCanvas ? [newCanvas, pageCanvas] : [newCanvas]);
343
- }
344
- }
345
- }, [pagingView, canvasList, currentCanvasId, currentCanvasIndex]);
346
- const previousCanvas = useCallback(() => {
347
- if (canvasList.length && currentCanvasId) {
348
- if (currentCanvasIndex === 0 || currentCanvasIndex === -1) {
349
- return;
350
- }
351
- const newCanvas = pagingView && currentCanvasIndex !== 1 ? canvasList[currentCanvasIndex - 2] : canvasList[currentCanvasIndex - 1];
352
- const pageCanvas = pagingView && currentCanvasIndex !== 1 ? canvasList[currentCanvasIndex - 1] : null;
353
- if (newCanvas) {
354
- setCurrentCanvasId(newCanvas);
355
- setVisible(pageCanvas ? [newCanvas, pageCanvas] : [newCanvas]);
356
- }
357
- }
358
- }, [pagingView, canvasList, currentCanvasId, currentCanvasIndex]);
359
- const setCurrentCanvasIndex = useCallback((idx) => {
360
- const realIdx = pagingView && idx % 2 === 1 ? idx - 1 : idx;
361
- const newId = canvasList[realIdx];
362
- const newNextId = pagingView && realIdx !== 0 ? canvasList[realIdx + 1] : null;
363
- if (newId) {
364
- setCurrentCanvasId(newId);
365
- setVisible((prevValue) => {
366
- const newValue = newNextId ? [newId, newNextId] : [newId];
367
- if (prevValue.length === prevValue.length) {
368
- for (let i = 0; i < prevValue.length; i++) {
369
- if (prevValue[i] !== newValue[i]) {
370
- return newValue;
371
- }
372
- }
373
- return prevValue;
374
- }
375
- return newValue;
376
- });
377
- }
378
- }, [pagingView, canvasList]);
379
- const internalSetCurrentCanvasId = useCallback((nextId) => {
380
- const idx = canvasList.indexOf(nextId);
381
- if (idx !== -1) {
382
- setCurrentCanvasIndex(idx);
383
- }
384
- }, [canvasList, setCurrentCanvasIndex]);
385
- const ctx = useMemo(() => ({
386
- setCurrentCanvasId: internalSetCurrentCanvasId,
387
- nextCanvas,
388
- previousCanvas,
389
- currentCanvasIndex,
390
- totalCanvases: canvasList.length,
391
- setCurrentCanvasIndex,
392
- pagingView: true
393
- }), [nextCanvas, previousCanvas, currentCanvasIndex, canvasList, setCurrentCanvasIndex, internalSetCurrentCanvasId]);
394
- if (!manifest.manifest) {
561
+ if (!manifest) {
395
562
  console.warn("The manifest passed to the provider is not a valid IIIF manifest.");
396
563
  return /* @__PURE__ */ jsx("div", {
397
564
  children: "Sorry, something went wrong."
@@ -402,18 +569,15 @@ function SimpleViewerProvider(props) {
402
569
  children: "Loading..."
403
570
  });
404
571
  }
405
- return /* @__PURE__ */ jsx(SimpleViewerReactContext.Provider, {
406
- value: ctx,
407
- children: /* @__PURE__ */ jsx(VisibleCanvasReactContext.Provider, {
408
- value: visible,
409
- children: /* @__PURE__ */ jsx(ManifestContext, {
410
- manifest: manifest.manifest.id,
411
- children: /* @__PURE__ */ jsx(CanvasContext, {
412
- canvas: currentCanvasId,
413
- children: props.children
414
- })
415
- })
416
- })
572
+ const inner = /* @__PURE__ */ jsx(InnerViewerProvider, __spreadProps(__spreadValues({}, props), {
573
+ children: props.children
574
+ }));
575
+ return /* @__PURE__ */ jsx(ManifestContext, {
576
+ manifest: manifest.id,
577
+ children: props.rangeId ? /* @__PURE__ */ jsx(RangeContext, {
578
+ range: props.rangeId,
579
+ children: inner
580
+ }) : inner
417
581
  });
418
582
  }
419
583
  function useSimpleViewer() {
@@ -623,11 +787,6 @@ function DefaultCanvasFallback({
623
787
  children: "Unknown error"
624
788
  });
625
789
  }
626
- var createRoot;
627
- var m = require$$0;
628
- {
629
- createRoot = m.createRoot;
630
- }
631
790
  const ViewerPresetContext = createContext(null);
632
791
  function useViewerPreset() {
633
792
  return useContext(ViewerPresetContext);
@@ -639,26 +798,16 @@ function CanvasPortal({
639
798
  overlay
640
799
  }) {
641
800
  const htmlElement = useContext(overlay ? OverlayPortalContext : PortalContext);
642
- const rootRef = useRef(null);
643
801
  const preset = useViewerPreset();
644
802
  useLayoutEffect(() => {
645
- if (!rootRef.current) {
646
- rootRef.current = htmlElement ? createRoot(htmlElement) : null;
647
- }
648
- }, []);
649
- useLayoutEffect(() => {
650
- return () => {
651
- var _a;
652
- (_a = rootRef.current) == null ? void 0 : _a.unmount();
653
- rootRef.current = null;
654
- };
655
- }, []);
656
- useLayoutEffect(() => {
657
- if (rootRef.current) {
658
- rootRef.current.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
659
- value: preset,
660
- children
661
- }));
803
+ if (htmlElement) {
804
+ try {
805
+ htmlElement.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
806
+ value: preset,
807
+ children
808
+ }));
809
+ } catch (e) {
810
+ }
662
811
  }
663
812
  }, [children, preset]);
664
813
  return null;
@@ -681,8 +830,31 @@ function Viewer(_a) {
681
830
  const bridge = useContextBridge();
682
831
  const ErrorFallback = errorFallback || DefaultCanvasFallback;
683
832
  useLayoutEffect(() => {
684
- setPortalElement(portal.current);
685
- setOverlayPortalElement(overlayPortal.current);
833
+ const roots = {};
834
+ if (portal.current) {
835
+ const $el = document.createElement("div");
836
+ portal.current.appendChild($el);
837
+ roots.portal = createRoot($el);
838
+ setPortalElement(roots.portal);
839
+ }
840
+ if (overlayPortal.current) {
841
+ const $el = document.createElement("div");
842
+ overlayPortal.current.appendChild($el);
843
+ roots.overlayPortal = createRoot($el);
844
+ setOverlayPortalElement(roots.overlayPortal);
845
+ }
846
+ return () => {
847
+ setPortalElement(null);
848
+ setOverlayPortalElement(null);
849
+ setTimeout(() => {
850
+ if (roots.portal) {
851
+ roots.portal.unmount();
852
+ }
853
+ if (roots.overlayPortal) {
854
+ roots.overlayPortal.unmount();
855
+ }
856
+ }, 0);
857
+ };
686
858
  }, []);
687
859
  return /* @__PURE__ */ jsxs(ErrorBoundary, {
688
860
  fallbackRender: () => /* @__PURE__ */ jsx(ErrorFallback, __spreadValues({}, props)),
@@ -805,25 +977,25 @@ function useStyles(resource, scope) {
805
977
  return styles ? scope ? styles[scope] : styles : void 0;
806
978
  }, [resource, scope]);
807
979
  }
808
- var __defProp2 = Object.defineProperty;
809
- var __defProps2 = Object.defineProperties;
810
- var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
811
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
812
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
813
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
814
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
815
- var __spreadValues2 = (a, b) => {
980
+ var __defProp$1 = Object.defineProperty;
981
+ var __defProps$1 = Object.defineProperties;
982
+ var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
983
+ var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
984
+ var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
985
+ var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
986
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
987
+ var __spreadValues$1 = (a, b) => {
816
988
  for (var prop in b || (b = {}))
817
- if (__hasOwnProp2.call(b, prop))
818
- __defNormalProp2(a, prop, b[prop]);
819
- if (__getOwnPropSymbols2)
820
- for (var prop of __getOwnPropSymbols2(b)) {
821
- if (__propIsEnum2.call(b, prop))
822
- __defNormalProp2(a, prop, b[prop]);
989
+ if (__hasOwnProp$1.call(b, prop))
990
+ __defNormalProp$1(a, prop, b[prop]);
991
+ if (__getOwnPropSymbols$1)
992
+ for (var prop of __getOwnPropSymbols$1(b)) {
993
+ if (__propIsEnum$1.call(b, prop))
994
+ __defNormalProp$1(a, prop, b[prop]);
823
995
  }
824
996
  return a;
825
997
  };
826
- var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
998
+ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
827
999
  const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
828
1000
  const TEMPORAL_SELECTOR = /&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;
829
1001
  function parseSelector(source) {
@@ -968,7 +1140,7 @@ function expandTarget(target, options = {}) {
968
1140
  if (!fragment) {
969
1141
  return {
970
1142
  type: "SpecificResource",
971
- source: __spreadProps2(__spreadValues2({}, target), {
1143
+ source: __spreadProps$1(__spreadValues$1({}, target), {
972
1144
  id
973
1145
  }),
974
1146
  selector: null,
@@ -977,7 +1149,7 @@ function expandTarget(target, options = {}) {
977
1149
  }
978
1150
  return expandTarget({
979
1151
  type: "SpecificResource",
980
- source: __spreadProps2(__spreadValues2({}, target), {
1152
+ source: __spreadProps$1(__spreadValues$1({}, target), {
981
1153
  id
982
1154
  }),
983
1155
  selector: {
@@ -1069,7 +1241,7 @@ const RenderAnnotationPage = ({
1069
1241
  const style = useStyles(page, "atlas");
1070
1242
  const html = useStyles(page, "html");
1071
1243
  useVaultSelector((state) => page.id ? state.iiif.entities.AnnotationPage[page.id] : null, []);
1072
- return /* @__PURE__ */ jsx(Fragment$1, {
1244
+ return /* @__PURE__ */ jsx(Fragment, {
1073
1245
  children: (_a = page.items) == null ? void 0 : _a.map((annotation) => {
1074
1246
  return /* @__PURE__ */ jsx(RenderAnnotation, {
1075
1247
  id: annotation.id,
@@ -1086,21 +1258,22 @@ function RenderImage({
1086
1258
  isStatic,
1087
1259
  x = 0,
1088
1260
  y = 0,
1089
- annotations,
1090
- children
1261
+ children,
1262
+ onClick
1091
1263
  }) {
1092
1264
  var _a, _b, _c, _d;
1093
- return /* @__PURE__ */ jsx(Fragment$1, {
1094
- children: !image.service ? /* @__PURE__ */ jsxs(Fragment$1, {
1265
+ return /* @__PURE__ */ jsx(Fragment, {
1266
+ children: !image.service ? /* @__PURE__ */ jsxs(Fragment, {
1095
1267
  children: [/* @__PURE__ */ jsx("world-image", {
1268
+ onClick,
1096
1269
  uri: image.id,
1097
1270
  target: image.target.spatial,
1098
1271
  display: image.width && image.height ? {
1099
1272
  width: image.width,
1100
1273
  height: image.height
1101
1274
  } : void 0
1102
- }), annotations, children]
1103
- }, "no-service") : /* @__PURE__ */ jsxs(Fragment$1, {
1275
+ }), children]
1276
+ }, "no-service") : /* @__PURE__ */ jsxs(Fragment, {
1104
1277
  children: [/* @__PURE__ */ jsx(TileSet, {
1105
1278
  tiles: {
1106
1279
  id: image.service.id || image.service["@id"] || "unknown",
@@ -1112,8 +1285,9 @@ function RenderImage({
1112
1285
  x: ((_a = image.target) == null ? void 0 : _a.spatial.x) + x,
1113
1286
  y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
1114
1287
  width: (_c = image.target) == null ? void 0 : _c.spatial.width,
1115
- height: (_d = image.target) == null ? void 0 : _d.spatial.height
1116
- }), annotations, children]
1288
+ height: (_d = image.target) == null ? void 0 : _d.spatial.height,
1289
+ onClick
1290
+ }), children]
1117
1291
  }, "service")
1118
1292
  }, id);
1119
1293
  }
@@ -1154,6 +1328,7 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
1154
1328
  types.push(type);
1155
1329
  }
1156
1330
  items.push({
1331
+ annotationId: annotation.id,
1157
1332
  type,
1158
1333
  resource: body,
1159
1334
  target: annotation.target,
@@ -1167,6 +1342,29 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
1167
1342
  choice
1168
1343
  };
1169
1344
  }
1345
+ function getParsedTargetSelector(canvas, target) {
1346
+ const { selector: imageTarget, source } = expandTarget$1(target);
1347
+ if (source.id !== canvas.id) {
1348
+ return [null, source];
1349
+ }
1350
+ const defaultTarget = {
1351
+ type: "BoxSelector",
1352
+ spatial: {
1353
+ x: 0,
1354
+ y: 0,
1355
+ width: canvas.width,
1356
+ height: canvas.height
1357
+ }
1358
+ };
1359
+ return [
1360
+ imageTarget ? imageTarget.type === "TemporalSelector" ? {
1361
+ type: "TemporalBoxSelector",
1362
+ temporal: imageTarget.temporal,
1363
+ spatial: defaultTarget.spatial
1364
+ } : imageTarget : null,
1365
+ source
1366
+ ];
1367
+ }
1170
1368
  const emptyActions = {
1171
1369
  makeChoice: () => {
1172
1370
  }
@@ -1175,22 +1373,9 @@ const unknownResponse = { type: "unknown" };
1175
1373
  const unsupportedStrategy = (reason) => {
1176
1374
  return { type: "unknown", reason, annotations: { pages: [] } };
1177
1375
  };
1178
- function useManifest(options = {}, deps = []) {
1179
- const { id, selector } = options;
1180
- const ctx = useResourceContext();
1181
- useVault();
1182
- const manifestId = id ? id : ctx.manifest;
1183
- const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
1184
- return useMemo(() => {
1185
- if (!manifest) {
1186
- return void 0;
1187
- }
1188
- if (selector) {
1189
- return selector(manifest);
1190
- }
1191
- return manifest;
1192
- }, [manifest, selector, ...deps]);
1193
- }
1376
+ const emptyStrategy = (width, height) => {
1377
+ return { type: "empty", width, height, annotations: { pages: [] }, image: null, images: [] };
1378
+ };
1194
1379
  function getMeta$1(state, resourceId) {
1195
1380
  var _a;
1196
1381
  const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
@@ -1444,10 +1629,6 @@ function getImageStrategy(canvas, paintables, loadImageService) {
1444
1629
  imageService = loadImageService(imageServices[0], canvas);
1445
1630
  }
1446
1631
  }
1447
- const { selector: imageTarget, source } = expandTarget(singleImage.target);
1448
- if (source.id !== canvas.id) {
1449
- continue;
1450
- }
1451
1632
  const defaultTarget = {
1452
1633
  type: "BoxSelector",
1453
1634
  spatial: {
@@ -1457,11 +1638,10 @@ function getImageStrategy(canvas, paintables, loadImageService) {
1457
1638
  height: canvas.height
1458
1639
  }
1459
1640
  };
1460
- const target = imageTarget ? imageTarget.type === "TemporalSelector" ? {
1461
- type: "TemporalBoxSelector",
1462
- temporal: imageTarget.temporal,
1463
- spatial: defaultTarget.spatial
1464
- } : imageTarget : null;
1641
+ const [target, source] = getParsedTargetSelector(canvas, singleImage.target);
1642
+ if (source.id !== canvas.id) {
1643
+ continue;
1644
+ }
1465
1645
  const defaultImageSelector = {
1466
1646
  type: "BoxSelector",
1467
1647
  spatial: {
@@ -1487,6 +1667,7 @@ function getImageStrategy(canvas, paintables, loadImageService) {
1487
1667
  const imageType = {
1488
1668
  id: resource.id,
1489
1669
  type: "Image",
1670
+ annotationId: singleImage.annotationId,
1490
1671
  width: target ? resource.width : canvas.width,
1491
1672
  height: target ? resource.height : canvas.height,
1492
1673
  service: imageService,
@@ -1536,6 +1717,7 @@ function getAudioStrategy(canvas, paintables) {
1536
1717
  return {
1537
1718
  type: "media",
1538
1719
  media: {
1720
+ annotationId: paintables.items[0].annotationId,
1539
1721
  duration: canvas.duration,
1540
1722
  url: audioResource.id,
1541
1723
  type: "Sound",
@@ -1579,6 +1761,7 @@ function getVideoStrategy(canvas, paintables) {
1579
1761
  return {
1580
1762
  type: "media",
1581
1763
  media: {
1764
+ annotationId: paintables.items[0].annotationId,
1582
1765
  duration: canvas.duration,
1583
1766
  url: audioResource.id,
1584
1767
  type: "Video",
@@ -1604,6 +1787,38 @@ function getVideoStrategy(canvas, paintables) {
1604
1787
  }
1605
1788
  };
1606
1789
  }
1790
+ function parseType(item, languageMap = {}, lang) {
1791
+ const language = item.language || lang || "none";
1792
+ switch (item.type) {
1793
+ case "TextualBody": {
1794
+ if (typeof item.value !== "undefined") {
1795
+ languageMap[language] = item.value;
1796
+ }
1797
+ break;
1798
+ }
1799
+ case "List":
1800
+ case "Composite":
1801
+ case "Choice": {
1802
+ if (item.items) {
1803
+ item.items.forEach((inner) => parseType(inner, languageMap, language));
1804
+ }
1805
+ }
1806
+ }
1807
+ return languageMap;
1808
+ }
1809
+ function getTextualContentStrategy(canvas, paintables) {
1810
+ const items = [];
1811
+ paintables.items.forEach((item) => {
1812
+ if (item.resource) {
1813
+ const [target] = getParsedTargetSelector(canvas, item.target);
1814
+ items.push({ annotationId: item.annotationId, text: parseType(item.resource), target });
1815
+ }
1816
+ });
1817
+ return {
1818
+ type: "textual-content",
1819
+ items
1820
+ };
1821
+ }
1607
1822
  function useRenderingStrategy(options) {
1608
1823
  const manifest = useManifest();
1609
1824
  const canvas = useCanvas();
@@ -1613,10 +1828,22 @@ function useRenderingStrategy(options) {
1613
1828
  all: false
1614
1829
  });
1615
1830
  const enabledPages = useResources(enabledPageIds, "AnnotationPage");
1616
- const supports = (options == null ? void 0 : options.strategies) || ["images", "media", "complex-timeline"];
1831
+ const supports = (options == null ? void 0 : options.strategies) || [
1832
+ "empty",
1833
+ "images",
1834
+ "media",
1835
+ "textual-content",
1836
+ "complex-timeline"
1837
+ ];
1617
1838
  const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
1618
1839
  const strategy = useMemo(() => {
1619
- if (!canvas || paintables.types.length === 0) {
1840
+ if (!canvas) {
1841
+ return unknownResponse;
1842
+ }
1843
+ if (paintables.types.length === 0) {
1844
+ if (supports.indexOf("empty") !== -1) {
1845
+ return emptyStrategy(canvas.width, canvas.height);
1846
+ }
1620
1847
  return unknownResponse;
1621
1848
  }
1622
1849
  if (paintables.types.length !== 1) {
@@ -1642,6 +1869,12 @@ function useRenderingStrategy(options) {
1642
1869
  }
1643
1870
  return get3dStrategy(canvas, paintables);
1644
1871
  }
1872
+ if (mainType === "textualbody") {
1873
+ if (supports.indexOf("textual-content") === -1) {
1874
+ return unsupportedStrategy("Textual content not supported");
1875
+ }
1876
+ return getTextualContentStrategy(canvas, paintables);
1877
+ }
1645
1878
  if (mainType === "sound" || mainType === "audio") {
1646
1879
  if (supports.indexOf("media") === -1) {
1647
1880
  return unsupportedStrategy("Media not supported");
@@ -1761,6 +1994,7 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
1761
1994
  const subject = canvas ? canvas : manifest;
1762
1995
  const didUnmount = useRef(false);
1763
1996
  useEffect(() => {
1997
+ didUnmount.current = false;
1764
1998
  return () => {
1765
1999
  didUnmount.current = true;
1766
2000
  };
@@ -1975,7 +2209,7 @@ function Audio({
1975
2209
  }, state, actions] = useSimpleMediaPlayer({
1976
2210
  duration: media.duration
1977
2211
  });
1978
- return /* @__PURE__ */ jsx(Fragment, {
2212
+ return /* @__PURE__ */ jsx(Fragment$1, {
1979
2213
  children: /* @__PURE__ */ jsx(CanvasPortal, {
1980
2214
  children: /* @__PURE__ */ jsxs(MediaPlayerProvider, {
1981
2215
  state,
@@ -2003,7 +2237,7 @@ function Video({
2003
2237
  duration: media.duration
2004
2238
  });
2005
2239
  const Component = "div";
2006
- return /* @__PURE__ */ jsxs(Fragment, {
2240
+ return /* @__PURE__ */ jsxs(Fragment$1, {
2007
2241
  children: [/* @__PURE__ */ jsxs(CanvasPortal, {
2008
2242
  overlay: true,
2009
2243
  children: [/* @__PURE__ */ jsx("style", {
@@ -2081,6 +2315,533 @@ function Model({
2081
2315
  })]
2082
2316
  });
2083
2317
  }
2318
+ function CanvasBackground({
2319
+ style
2320
+ }) {
2321
+ const canvas = useCanvas();
2322
+ if (!canvas || !canvas.height || !canvas.width) {
2323
+ return null;
2324
+ }
2325
+ return /* @__PURE__ */ jsx("box", {
2326
+ interactive: false,
2327
+ target: {
2328
+ x: 0,
2329
+ y: 0,
2330
+ width: canvas.width,
2331
+ height: canvas.height
2332
+ },
2333
+ style
2334
+ });
2335
+ }
2336
+ var __defProp2 = Object.defineProperty;
2337
+ var __defProps2 = Object.defineProperties;
2338
+ var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
2339
+ var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
2340
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
2341
+ var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
2342
+ var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
2343
+ enumerable: true,
2344
+ configurable: true,
2345
+ writable: true,
2346
+ value
2347
+ }) : obj[key] = value;
2348
+ var __spreadValues2 = (a, b) => {
2349
+ for (var prop in b || (b = {}))
2350
+ if (__hasOwnProp2.call(b, prop))
2351
+ __defNormalProp2(a, prop, b[prop]);
2352
+ if (__getOwnPropSymbols2)
2353
+ for (var prop of __getOwnPropSymbols2(b)) {
2354
+ if (__propIsEnum2.call(b, prop))
2355
+ __defNormalProp2(a, prop, b[prop]);
2356
+ }
2357
+ return a;
2358
+ };
2359
+ var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
2360
+ var __objRest2 = (source, exclude) => {
2361
+ var target = {};
2362
+ for (var prop in source)
2363
+ if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
2364
+ target[prop] = source[prop];
2365
+ if (source != null && __getOwnPropSymbols2)
2366
+ for (var prop of __getOwnPropSymbols2(source)) {
2367
+ if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
2368
+ target[prop] = source[prop];
2369
+ }
2370
+ return target;
2371
+ };
2372
+ function _defineProperty(obj, key, value) {
2373
+ if (key in obj) {
2374
+ Object.defineProperty(obj, key, {
2375
+ value,
2376
+ enumerable: true,
2377
+ configurable: true,
2378
+ writable: true
2379
+ });
2380
+ } else {
2381
+ obj[key] = value;
2382
+ }
2383
+ return obj;
2384
+ }
2385
+ function _classCallCheck(instance, Constructor) {
2386
+ if (!(instance instanceof Constructor)) {
2387
+ throw new TypeError("Cannot call a class as a function");
2388
+ }
2389
+ }
2390
+ function _defineProperties(target, props) {
2391
+ for (var i = 0; i < props.length; i++) {
2392
+ var descriptor = props[i];
2393
+ descriptor.enumerable = descriptor.enumerable || false;
2394
+ descriptor.configurable = true;
2395
+ if ("value" in descriptor)
2396
+ descriptor.writable = true;
2397
+ Object.defineProperty(target, descriptor.key, descriptor);
2398
+ }
2399
+ }
2400
+ function _createClass(Constructor, protoProps, staticProps) {
2401
+ if (protoProps)
2402
+ _defineProperties(Constructor.prototype, protoProps);
2403
+ if (staticProps)
2404
+ _defineProperties(Constructor, staticProps);
2405
+ Object.defineProperty(Constructor, "prototype", {
2406
+ writable: false
2407
+ });
2408
+ return Constructor;
2409
+ }
2410
+ var defaultOptions = {
2411
+ bindI18n: "languageChanged",
2412
+ bindI18nStore: "",
2413
+ transEmptyNodeValue: "",
2414
+ transSupportBasicHtmlNodes: true,
2415
+ transWrapTextNodes: "",
2416
+ transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"],
2417
+ useSuspense: true
2418
+ };
2419
+ var i18nInstance;
2420
+ var I18nContext = React__default.createContext();
2421
+ function getDefaults() {
2422
+ return defaultOptions;
2423
+ }
2424
+ var ReportNamespaces = function() {
2425
+ function ReportNamespaces2() {
2426
+ _classCallCheck(this, ReportNamespaces2);
2427
+ this.usedNamespaces = {};
2428
+ }
2429
+ _createClass(ReportNamespaces2, [{
2430
+ key: "addUsedNamespaces",
2431
+ value: function addUsedNamespaces(namespaces) {
2432
+ var _this = this;
2433
+ namespaces.forEach(function(ns) {
2434
+ if (!_this.usedNamespaces[ns])
2435
+ _this.usedNamespaces[ns] = true;
2436
+ });
2437
+ }
2438
+ }, {
2439
+ key: "getUsedNamespaces",
2440
+ value: function getUsedNamespaces() {
2441
+ return Object.keys(this.usedNamespaces);
2442
+ }
2443
+ }]);
2444
+ return ReportNamespaces2;
2445
+ }();
2446
+ function getI18n() {
2447
+ return i18nInstance;
2448
+ }
2449
+ function warn() {
2450
+ if (console && console.warn) {
2451
+ var _console;
2452
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2453
+ args[_key] = arguments[_key];
2454
+ }
2455
+ if (typeof args[0] === "string")
2456
+ args[0] = "react-i18next:: ".concat(args[0]);
2457
+ (_console = console).warn.apply(_console, args);
2458
+ }
2459
+ }
2460
+ var alreadyWarned = {};
2461
+ function warnOnce() {
2462
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2463
+ args[_key2] = arguments[_key2];
2464
+ }
2465
+ if (typeof args[0] === "string" && alreadyWarned[args[0]])
2466
+ return;
2467
+ if (typeof args[0] === "string")
2468
+ alreadyWarned[args[0]] = new Date();
2469
+ warn.apply(void 0, args);
2470
+ }
2471
+ function loadNamespaces(i18n, ns, cb) {
2472
+ i18n.loadNamespaces(ns, function() {
2473
+ if (i18n.isInitialized) {
2474
+ cb();
2475
+ } else {
2476
+ var initialized = function initialized2() {
2477
+ setTimeout(function() {
2478
+ i18n.off("initialized", initialized2);
2479
+ }, 0);
2480
+ cb();
2481
+ };
2482
+ i18n.on("initialized", initialized);
2483
+ }
2484
+ });
2485
+ }
2486
+ function hasLoadedNamespace(ns, i18n) {
2487
+ var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
2488
+ if (!i18n.languages || !i18n.languages.length) {
2489
+ warnOnce("i18n.languages were undefined or empty", i18n.languages);
2490
+ return true;
2491
+ }
2492
+ var lng = i18n.languages[0];
2493
+ var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
2494
+ var lastLng = i18n.languages[i18n.languages.length - 1];
2495
+ if (lng.toLowerCase() === "cimode")
2496
+ return true;
2497
+ var loadNotPending = function loadNotPending2(l, n) {
2498
+ var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
2499
+ return loadState === -1 || loadState === 2;
2500
+ };
2501
+ if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns))
2502
+ return false;
2503
+ if (i18n.hasResourceBundle(lng, ns))
2504
+ return true;
2505
+ if (!i18n.services.backendConnector.backend)
2506
+ return true;
2507
+ if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns)))
2508
+ return true;
2509
+ return false;
2510
+ }
2511
+ function _arrayWithHoles(arr) {
2512
+ if (Array.isArray(arr))
2513
+ return arr;
2514
+ }
2515
+ function _iterableToArrayLimit(arr, i) {
2516
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
2517
+ if (_i == null)
2518
+ return;
2519
+ var _arr = [];
2520
+ var _n = true;
2521
+ var _d = false;
2522
+ var _s, _e;
2523
+ try {
2524
+ for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
2525
+ _arr.push(_s.value);
2526
+ if (i && _arr.length === i)
2527
+ break;
2528
+ }
2529
+ } catch (err) {
2530
+ _d = true;
2531
+ _e = err;
2532
+ } finally {
2533
+ try {
2534
+ if (!_n && _i["return"] != null)
2535
+ _i["return"]();
2536
+ } finally {
2537
+ if (_d)
2538
+ throw _e;
2539
+ }
2540
+ }
2541
+ return _arr;
2542
+ }
2543
+ function _arrayLikeToArray(arr, len) {
2544
+ if (len == null || len > arr.length)
2545
+ len = arr.length;
2546
+ for (var i = 0, arr2 = new Array(len); i < len; i++) {
2547
+ arr2[i] = arr[i];
2548
+ }
2549
+ return arr2;
2550
+ }
2551
+ function _unsupportedIterableToArray(o, minLen) {
2552
+ if (!o)
2553
+ return;
2554
+ if (typeof o === "string")
2555
+ return _arrayLikeToArray(o, minLen);
2556
+ var n = Object.prototype.toString.call(o).slice(8, -1);
2557
+ if (n === "Object" && o.constructor)
2558
+ n = o.constructor.name;
2559
+ if (n === "Map" || n === "Set")
2560
+ return Array.from(o);
2561
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
2562
+ return _arrayLikeToArray(o, minLen);
2563
+ }
2564
+ function _nonIterableRest() {
2565
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
2566
+ }
2567
+ function _slicedToArray(arr, i) {
2568
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
2569
+ }
2570
+ function ownKeys(object, enumerableOnly) {
2571
+ var keys = Object.keys(object);
2572
+ if (Object.getOwnPropertySymbols) {
2573
+ var symbols = Object.getOwnPropertySymbols(object);
2574
+ if (enumerableOnly) {
2575
+ symbols = symbols.filter(function(sym) {
2576
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2577
+ });
2578
+ }
2579
+ keys.push.apply(keys, symbols);
2580
+ }
2581
+ return keys;
2582
+ }
2583
+ function _objectSpread(target) {
2584
+ for (var i = 1; i < arguments.length; i++) {
2585
+ var source = arguments[i] != null ? arguments[i] : {};
2586
+ if (i % 2) {
2587
+ ownKeys(Object(source), true).forEach(function(key) {
2588
+ _defineProperty(target, key, source[key]);
2589
+ });
2590
+ } else if (Object.getOwnPropertyDescriptors) {
2591
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
2592
+ } else {
2593
+ ownKeys(Object(source)).forEach(function(key) {
2594
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2595
+ });
2596
+ }
2597
+ }
2598
+ return target;
2599
+ }
2600
+ function useTranslation(ns) {
2601
+ var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
2602
+ var i18nFromProps = props.i18n;
2603
+ var _ref = useContext(I18nContext) || {}, i18nFromContext = _ref.i18n, defaultNSFromContext = _ref.defaultNS;
2604
+ var i18n = i18nFromProps || i18nFromContext || getI18n();
2605
+ if (i18n && !i18n.reportNamespaces)
2606
+ i18n.reportNamespaces = new ReportNamespaces();
2607
+ if (!i18n) {
2608
+ warnOnce("You will need to pass in an i18next instance by using initReactI18next");
2609
+ var notReadyT = function notReadyT2(k) {
2610
+ return Array.isArray(k) ? k[k.length - 1] : k;
2611
+ };
2612
+ var retNotReady = [notReadyT, {}, false];
2613
+ retNotReady.t = notReadyT;
2614
+ retNotReady.i18n = {};
2615
+ retNotReady.ready = false;
2616
+ return retNotReady;
2617
+ }
2618
+ if (i18n.options.react && i18n.options.react.wait !== void 0)
2619
+ warnOnce("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
2620
+ var i18nOptions = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), i18n.options.react), props);
2621
+ var useSuspense = i18nOptions.useSuspense, keyPrefix = i18nOptions.keyPrefix;
2622
+ var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
2623
+ namespaces = typeof namespaces === "string" ? [namespaces] : namespaces || ["translation"];
2624
+ if (i18n.reportNamespaces.addUsedNamespaces)
2625
+ i18n.reportNamespaces.addUsedNamespaces(namespaces);
2626
+ var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function(n) {
2627
+ return hasLoadedNamespace(n, i18n, i18nOptions);
2628
+ });
2629
+ function getT() {
2630
+ return i18n.getFixedT(null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
2631
+ }
2632
+ var _useState = useState(getT), _useState2 = _slicedToArray(_useState, 2), t = _useState2[0], setT = _useState2[1];
2633
+ var isMounted = useRef(true);
2634
+ useEffect(function() {
2635
+ var bindI18n = i18nOptions.bindI18n, bindI18nStore = i18nOptions.bindI18nStore;
2636
+ isMounted.current = true;
2637
+ if (!ready && !useSuspense) {
2638
+ loadNamespaces(i18n, namespaces, function() {
2639
+ if (isMounted.current)
2640
+ setT(getT);
2641
+ });
2642
+ }
2643
+ function boundReset() {
2644
+ if (isMounted.current)
2645
+ setT(getT);
2646
+ }
2647
+ if (bindI18n && i18n)
2648
+ i18n.on(bindI18n, boundReset);
2649
+ if (bindI18nStore && i18n)
2650
+ i18n.store.on(bindI18nStore, boundReset);
2651
+ return function() {
2652
+ isMounted.current = false;
2653
+ if (bindI18n && i18n)
2654
+ bindI18n.split(" ").forEach(function(e) {
2655
+ return i18n.off(e, boundReset);
2656
+ });
2657
+ if (bindI18nStore && i18n)
2658
+ bindI18nStore.split(" ").forEach(function(e) {
2659
+ return i18n.store.off(e, boundReset);
2660
+ });
2661
+ };
2662
+ }, [i18n, namespaces.join()]);
2663
+ var isInitial = useRef(true);
2664
+ useEffect(function() {
2665
+ if (isMounted.current && !isInitial.current) {
2666
+ setT(getT);
2667
+ }
2668
+ isInitial.current = false;
2669
+ }, [i18n]);
2670
+ var ret = [t, i18n, ready];
2671
+ ret.t = t;
2672
+ ret.i18n = i18n;
2673
+ ret.ready = ready;
2674
+ if (ready)
2675
+ return ret;
2676
+ if (!ready && !useSuspense)
2677
+ return ret;
2678
+ throw new Promise(function(resolve) {
2679
+ loadNamespaces(i18n, namespaces, function() {
2680
+ resolve();
2681
+ });
2682
+ });
2683
+ }
2684
+ function LanguageString(_a) {
2685
+ var _b = _a, {
2686
+ as: Component,
2687
+ language,
2688
+ children
2689
+ } = _b, props = __objRest2(_b, ["as", "language", "children"]);
2690
+ const {
2691
+ i18n
2692
+ } = useTranslation();
2693
+ const viewingDirection = useMemo(() => i18n.dir ? i18n.dir(language) : "ltr", [language]);
2694
+ const isSame = useMemo(() => {
2695
+ if (!i18n.services) {
2696
+ return false;
2697
+ }
2698
+ return i18n.services.languageUtils.getLanguagePartFromCode(i18n.language) === i18n.services.languageUtils.getLanguagePartFromCode(language);
2699
+ }, [i18n.language, language]);
2700
+ if (isSame) {
2701
+ if (Component) {
2702
+ return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, __spreadValues2({}, props)), {
2703
+ children
2704
+ }));
2705
+ }
2706
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, __spreadValues2({}, props)), {
2707
+ children
2708
+ }));
2709
+ }
2710
+ if (Component) {
2711
+ return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
2712
+ lang: language,
2713
+ dir: viewingDirection
2714
+ })), {
2715
+ children
2716
+ }));
2717
+ }
2718
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
2719
+ lang: language,
2720
+ dir: viewingDirection
2721
+ })), {
2722
+ children
2723
+ }));
2724
+ }
2725
+ function getClosestLanguage(i18nLanguage, languages, i18nLanguages = [], strictFallback = false) {
2726
+ if (!i18nLanguage || !languages || languages.length === 0) {
2727
+ return void 0;
2728
+ }
2729
+ if (languages.length === 1) {
2730
+ return languages[0];
2731
+ }
2732
+ if (languages.indexOf(i18nLanguage) !== -1) {
2733
+ return i18nLanguage;
2734
+ }
2735
+ const root = i18nLanguage.indexOf("-") !== -1 ? i18nLanguage.slice(0, i18nLanguage.indexOf("-")) : null;
2736
+ if (root && languages.indexOf(root) !== -1) {
2737
+ return root;
2738
+ }
2739
+ for (const lang of i18nLanguages) {
2740
+ if (languages.indexOf(lang) !== -1) {
2741
+ return lang;
2742
+ }
2743
+ }
2744
+ if (!strictFallback) {
2745
+ const inverseRoot = languages.map((l) => l.indexOf("-") !== -1 ? l.slice(0, l.indexOf("-")) : null);
2746
+ const inverseIdx = inverseRoot.indexOf(i18nLanguage);
2747
+ if (inverseIdx !== -1) {
2748
+ return languages[inverseIdx];
2749
+ }
2750
+ for (const lang of i18nLanguages) {
2751
+ const root2 = lang.indexOf("-") !== -1 ? lang.slice(0, lang.indexOf("-")) : null;
2752
+ const inverseIdx2 = root2 ? languages.indexOf(root2) : -1;
2753
+ if (inverseIdx2 !== -1) {
2754
+ return languages[inverseIdx2];
2755
+ }
2756
+ }
2757
+ }
2758
+ if (languages.indexOf("none") !== -1) {
2759
+ return "none";
2760
+ }
2761
+ if (languages.indexOf("@none") !== -1) {
2762
+ return "@none";
2763
+ }
2764
+ return languages[0];
2765
+ }
2766
+ function buildLocaleString(inputText, i18nLanguage, options = {}) {
2767
+ const {
2768
+ strictFallback = false,
2769
+ defaultText = "",
2770
+ separator = "\n",
2771
+ fallbackLanguages = [],
2772
+ closest
2773
+ } = options;
2774
+ const languages = Object.keys(inputText || {});
2775
+ const language = closest ? i18nLanguage : getClosestLanguage(i18nLanguage, languages, fallbackLanguages, strictFallback);
2776
+ if (!inputText) {
2777
+ return defaultText;
2778
+ }
2779
+ if (typeof inputText === "string") {
2780
+ return inputText;
2781
+ }
2782
+ const candidateText = language ? inputText[language] : void 0;
2783
+ if (candidateText) {
2784
+ if (typeof candidateText === "string") {
2785
+ return candidateText;
2786
+ }
2787
+ return candidateText.join(separator);
2788
+ }
2789
+ return "";
2790
+ }
2791
+ function useClosestLanguage(getLanguages, deps = []) {
2792
+ const {
2793
+ i18n
2794
+ } = useTranslation();
2795
+ const i18nLanguages = i18n && i18n.languages ? i18n.languages : [];
2796
+ const i18nLanguage = i18n && i18n.language ? i18n.language : "en";
2797
+ return useMemo(() => {
2798
+ const languages = getLanguages();
2799
+ return getClosestLanguage(i18nLanguage, languages, i18nLanguages);
2800
+ }, [i18nLanguages, i18nLanguage, ...deps]);
2801
+ }
2802
+ function useLocaleString(inputText, defaultText) {
2803
+ const language = useClosestLanguage(() => Object.keys(inputText || {}), [inputText]);
2804
+ return [useMemo(() => {
2805
+ return buildLocaleString(inputText, language, {
2806
+ defaultText,
2807
+ closest: true
2808
+ });
2809
+ }, [language, defaultText, inputText]), language];
2810
+ }
2811
+ const LocaleString = (_c) => {
2812
+ var _d = _c, {
2813
+ as: Component,
2814
+ defaultText,
2815
+ enableDangerouslySetInnerHTML,
2816
+ children
2817
+ } = _d, props = __objRest2(_d, ["as", "defaultText", "enableDangerouslySetInnerHTML", "children"]);
2818
+ const [text, language] = useLocaleString(children, defaultText);
2819
+ if (language) {
2820
+ return /* @__PURE__ */ jsx(LanguageString, __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
2821
+ as: Component,
2822
+ language,
2823
+ title: enableDangerouslySetInnerHTML ? void 0 : text,
2824
+ dangerouslySetInnerHTML: enableDangerouslySetInnerHTML ? {
2825
+ __html: text
2826
+ } : void 0
2827
+ })), {
2828
+ children: enableDangerouslySetInnerHTML ? void 0 : text
2829
+ }));
2830
+ }
2831
+ if (Component) {
2832
+ return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, __spreadValues2({}, props)), {
2833
+ children: text
2834
+ }));
2835
+ }
2836
+ return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
2837
+ title: enableDangerouslySetInnerHTML ? void 0 : text,
2838
+ dangerouslySetInnerHTML: enableDangerouslySetInnerHTML ? {
2839
+ __html: text
2840
+ } : void 0
2841
+ })), {
2842
+ children: enableDangerouslySetInnerHTML ? void 0 : text
2843
+ }));
2844
+ };
2084
2845
  function RenderCanvas({
2085
2846
  x,
2086
2847
  y,
@@ -2091,6 +2852,9 @@ function RenderCanvas({
2091
2852
  renderViewerControls,
2092
2853
  renderMediaControls,
2093
2854
  strategies,
2855
+ backgroundStyle,
2856
+ alwaysShowBackground,
2857
+ onClickPaintingAnnotation,
2094
2858
  children
2095
2859
  }) {
2096
2860
  const canvas = useCanvas();
@@ -2161,7 +2925,7 @@ function RenderCanvas({
2161
2925
  }
2162
2926
  throw new Error(strategy.reason || "Unknown image strategy");
2163
2927
  }
2164
- const annotations = /* @__PURE__ */ jsxs(Fragment$1, {
2928
+ const annotations = /* @__PURE__ */ jsxs(Fragment, {
2165
2929
  children: [virtualPage ? /* @__PURE__ */ jsx(RenderAnnotationPage, {
2166
2930
  page: virtualPage
2167
2931
  }) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
@@ -2170,29 +2934,45 @@ function RenderCanvas({
2170
2934
  }, page.id);
2171
2935
  }) : null, children]
2172
2936
  });
2173
- return /* @__PURE__ */ jsxs(Fragment, {
2937
+ return /* @__PURE__ */ jsxs(Fragment$1, {
2174
2938
  children: [/* @__PURE__ */ jsxs("world-object", __spreadProps(__spreadValues({
2175
2939
  height: canvas.height,
2176
2940
  width: canvas.width,
2177
2941
  x,
2178
2942
  y
2179
2943
  }, elementProps), {
2180
- children: [strategy.type === "images" ? /* @__PURE__ */ jsxs(Fragment, {
2181
- children: [strategy.images.map((image, idx) => {
2182
- return /* @__PURE__ */ jsx(RenderImage, {
2183
- isStatic,
2184
- image,
2185
- id: image.id,
2186
- thumbnail: idx === 0 ? thumbnail : void 0,
2187
- annotations
2188
- }, image.id);
2189
- }), renderViewerControls ? /* @__PURE__ */ jsx(CanvasPortal, {
2190
- overlay: true,
2191
- children: renderViewerControls(strategy)
2192
- }) : null]
2944
+ children: [strategy.type === "empty" || alwaysShowBackground ? /* @__PURE__ */ jsx(CanvasBackground, {
2945
+ style: backgroundStyle
2946
+ }) : null, strategy.type === "textual-content" ? strategy.items.map((item, n) => {
2947
+ return /* @__PURE__ */ jsxs(Fragment$1, {
2948
+ children: [/* @__PURE__ */ jsx(HTMLPortal, {
2949
+ onClick: onClickPaintingAnnotation ? (e) => {
2950
+ e.stopPropagation();
2951
+ onClickPaintingAnnotation(item.annotationId, item, e);
2952
+ } : void 0,
2953
+ target: item.target.spatial || void 0,
2954
+ children: /* @__PURE__ */ jsx(LocaleString, {
2955
+ children: item.text
2956
+ })
2957
+ }, n), annotations]
2958
+ });
2959
+ }) : null, strategy.type === "images" ? /* @__PURE__ */ jsxs(Fragment$1, {
2960
+ children: [strategy.images.map((image, idx) => /* @__PURE__ */ jsx(RenderImage, {
2961
+ isStatic,
2962
+ image,
2963
+ id: image.id,
2964
+ thumbnail: idx === 0 ? thumbnail : void 0,
2965
+ onClick: onClickPaintingAnnotation ? (e) => {
2966
+ e.stopPropagation();
2967
+ onClickPaintingAnnotation(image.annotationId, image, e);
2968
+ } : void 0
2969
+ }, image.id)), annotations]
2970
+ }) : null, (strategy.type === "images" || strategy.type === "empty" || strategy.type === "textual-content") && renderViewerControls ? /* @__PURE__ */ jsx(CanvasPortal, {
2971
+ overlay: true,
2972
+ children: renderViewerControls(strategy)
2193
2973
  }) : null, strategy.type === "3d-model" ? /* @__PURE__ */ jsx(Model, {
2194
2974
  model: strategy.model
2195
- }) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment, {
2975
+ }) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment$1, {
2196
2976
  children: strategy.media.type === "Sound" ? /* @__PURE__ */ jsxs(Audio, {
2197
2977
  media: strategy.media,
2198
2978
  children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
@@ -2201,7 +2981,7 @@ function RenderCanvas({
2201
2981
  children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
2202
2982
  }) : null
2203
2983
  }) : null]
2204
- }), strategy.type), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ jsx(CanvasContext, {
2984
+ }), `${canvas.id}/${strategy.type}`), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ jsx(CanvasContext, {
2205
2985
  canvas: accompanyingCanvas.id,
2206
2986
  children: /* @__PURE__ */ jsx(RenderCanvas, {
2207
2987
  renderViewerControls
@@ -2214,7 +2994,8 @@ const CanvasPanel = {
2214
2994
  RenderCanvas,
2215
2995
  RenderAnnotationPage,
2216
2996
  RenderAnnotation,
2217
- Viewer
2997
+ Viewer,
2998
+ CanvasBackground
2218
2999
  };
2219
3000
  function AnnotationContext({
2220
3001
  annotation,
@@ -2238,23 +3019,31 @@ function CollectionContext({
2238
3019
  children
2239
3020
  });
2240
3021
  }
2241
- function RangeContext({
2242
- range,
2243
- children
2244
- }) {
2245
- return /* @__PURE__ */ jsx(ResourceProvider, {
2246
- value: {
2247
- range
2248
- },
2249
- children
2250
- });
2251
- }
2252
3022
  function useAnnotationsAtTime(time, options = {}) {
2253
3023
  const allAnnotations = usePaintingAnnotations(options);
2254
3024
  return allAnnotations;
2255
3025
  }
2256
3026
  function useCanvasClock(canvasId, autoplay = false) {
2257
3027
  }
3028
+ function useCanvasSubset(idsOrRefs) {
3029
+ const ctx = useResourceContext();
3030
+ const manifestId = ctx.manifest;
3031
+ const refs = idsOrRefs ? idsOrRefs.map((item) => typeof item === "string" ? item : item == null ? void 0 : item.id) : [];
3032
+ return useVaultSelector((s) => {
3033
+ const manifest = manifestId ? s.iiif.entities.Manifest[manifestId] : void 0;
3034
+ const items = (manifest == null ? void 0 : manifest.items) || [];
3035
+ if (typeof idsOrRefs === "undefined") {
3036
+ return items;
3037
+ }
3038
+ const newItems = [];
3039
+ for (const item of (manifest == null ? void 0 : manifest.items) || []) {
3040
+ if (refs.indexOf(item.id) !== -1) {
3041
+ newItems.push(item);
3042
+ }
3043
+ }
3044
+ return newItems;
3045
+ }, [refs.join("/")]);
3046
+ }
2258
3047
  function useCollection(options, deps = []) {
2259
3048
  const { id, selector } = options;
2260
3049
  const ctx = useResourceContext();
@@ -2380,21 +3169,6 @@ function useImageTile() {
2380
3169
  } : null
2381
3170
  };
2382
3171
  }
2383
- function useRange(options = {}, deps = []) {
2384
- const { id, selector } = options;
2385
- const ctx = useResourceContext();
2386
- const rangeId = id ? id : ctx.range;
2387
- const range = useVaultSelector((s) => rangeId ? s.iiif.entities.Range[rangeId] : void 0, [rangeId]);
2388
- return useMemo(() => {
2389
- if (!range) {
2390
- return void 0;
2391
- }
2392
- if (selector) {
2393
- return selector(range);
2394
- }
2395
- return range;
2396
- }, [range, selector, ...deps]);
2397
- }
2398
3172
  function useSearchService() {
2399
3173
  const manifest = useManifest();
2400
3174
  return manifest ? manifest.service.find((service) => service.profile === "SearchService1" || service.profile === "http://iiif.io/api/search/1/search") : void 0;
@@ -2403,5 +3177,5 @@ function useStyleHelper() {
2403
3177
  const vault = useVault();
2404
3178
  return useMemo(() => createStylesHelper(vault), [vault]);
2405
3179
  }
2406
- export { AnnotationContext, CanvasContext, CanvasPanel, CanvasPortal, CollectionContext, ContextBridge, ImageServiceLoaderContext, ManifestContext, MediaPlayerProvider, OverlayPortalContext, PortalContext, RangeContext, ReactVaultContext, ResourceProvider, ResourceReactContext, SimpleViewerProvider, SimpleViewerReactContext, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, emptyActions, expandTarget, flattenAnnotationPageIds, formatTime, getImageStrategy, getPaintables, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
3180
+ export { AnnotationContext, CanvasContext, CanvasPanel, CanvasPortal, CollectionContext, ContextBridge, ImageServiceLoaderContext, InnerViewerProvider, ManifestContext, MediaPlayerProvider, OverlayPortalContext, PortalContext, RangeContext, ReactVaultContext, ResourceProvider, ResourceReactContext, SimpleViewerProvider, SimpleViewerReactContext, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, emptyActions, emptyStrategy, expandTarget, findAllCanvasesInRange, findFirstCanvasFromRange, findManifestSelectedRange, findSelectedRange, flattenAnnotationPageIds, formatTime, getImageStrategy, getManifestSequence, getPaintables, getParsedTargetSelector, getVisibleCanvasesFromCanvasId, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCanvasSequence, useCanvasSubset, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
2407
3181
  //# sourceMappingURL=index.mjs.map