react-iiif-vault 1.0.11 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/bundle.d.ts +1058 -0
  2. package/dist/bundle.global.js +227 -0
  3. package/dist/canvas-panel.cjs +46 -0
  4. package/dist/canvas-panel.d.cts +11 -0
  5. package/dist/canvas-panel.d.ts +11 -0
  6. package/dist/canvas-panel.js +1 -0
  7. package/dist/chunk-HEVA2EDS.js +47 -0
  8. package/dist/chunk-YSH2CIKG.js +1 -0
  9. package/dist/index-BZirmhnp.d.cts +188 -0
  10. package/dist/index-Cxs6aAuK.d.ts +188 -0
  11. package/dist/index.cjs +47 -0
  12. package/dist/index.d.cts +721 -0
  13. package/dist/index.d.ts +721 -0
  14. package/dist/index.js +1 -0
  15. package/dist/useRenderingStrategy-Xj9yQm4y.d.cts +145 -0
  16. package/dist/useRenderingStrategy-Xj9yQm4y.d.ts +145 -0
  17. package/dist/utils.cjs +1 -0
  18. package/dist/utils.d.cts +32 -0
  19. package/dist/utils.d.ts +32 -0
  20. package/dist/utils.js +1 -0
  21. package/package.json +67 -70
  22. package/.build/types/canvas-panel/Viewer.d.ts +0 -14
  23. package/.build/types/canvas-panel/context/overlays.d.ts +0 -3
  24. package/.build/types/canvas-panel/context/world-size.d.ts +0 -2
  25. package/.build/types/canvas-panel/index.d.ts +0 -46
  26. package/.build/types/canvas-panel/render/Annotation.d.ts +0 -8
  27. package/.build/types/canvas-panel/render/AnnotationPage.d.ts +0 -7
  28. package/.build/types/canvas-panel/render/Audio.d.ts +0 -11
  29. package/.build/types/canvas-panel/render/Canvas.d.ts +0 -34
  30. package/.build/types/canvas-panel/render/CanvasBackground.d.ts +0 -4
  31. package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +0 -6
  32. package/.build/types/canvas-panel/render/Image.d.ts +0 -16
  33. package/.build/types/canvas-panel/render/Model.d.ts +0 -7
  34. package/.build/types/canvas-panel/render/Video.d.ts +0 -12
  35. package/.build/types/canvas-panel/render/VideoYouTube.d.ts +0 -12
  36. package/.build/types/components/CanvasAnnotations.d.ts +0 -10
  37. package/.build/types/components/CombinedMetadata.d.ts +0 -4
  38. package/.build/types/components/Image.d.ts +0 -15
  39. package/.build/types/components/ManifestMetadata.d.ts +0 -4
  40. package/.build/types/components/Metadata.d.ts +0 -39
  41. package/.build/types/components/SequenceThumbnails.d.ts +0 -29
  42. package/.build/types/components/SingleCanvasThumbnail.d.ts +0 -20
  43. package/.build/types/context/AnnotationContext.d.ts +0 -5
  44. package/.build/types/context/AnnotationPageContext.d.ts +0 -5
  45. package/.build/types/context/CanvasContext.d.ts +0 -5
  46. package/.build/types/context/CollectionContext.d.ts +0 -5
  47. package/.build/types/context/ContextBridge.d.ts +0 -14
  48. package/.build/types/context/ImageServiceLoaderContext.d.ts +0 -4
  49. package/.build/types/context/ManifestContext.d.ts +0 -5
  50. package/.build/types/context/MediaContext.d.ts +0 -17
  51. package/.build/types/context/RangeContext.d.ts +0 -5
  52. package/.build/types/context/ResourceContext.d.ts +0 -15
  53. package/.build/types/context/VaultContext.d.ts +0 -14
  54. package/.build/types/context/ViewerPresetContext.d.ts +0 -3
  55. package/.build/types/context/VisibleCanvasContext.d.ts +0 -4
  56. package/.build/types/demo/demo.d.ts +0 -1
  57. package/.build/types/demo/media-controls.d.ts +0 -1
  58. package/.build/types/demo/viewer-controls.d.ts +0 -1
  59. package/.build/types/features/rendering-strategy/3d-strategy.d.ts +0 -12
  60. package/.build/types/features/rendering-strategy/audio-strategy.d.ts +0 -3
  61. package/.build/types/features/rendering-strategy/get-rendering-strategy.d.ts +0 -11
  62. package/.build/types/features/rendering-strategy/image-strategy.d.ts +0 -12
  63. package/.build/types/features/rendering-strategy/rendering-utils.d.ts +0 -12
  64. package/.build/types/features/rendering-strategy/resource-types.d.ts +0 -55
  65. package/.build/types/features/rendering-strategy/strategies.d.ts +0 -31
  66. package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +0 -16
  67. package/.build/types/features/rendering-strategy/video-strategy.d.ts +0 -3
  68. package/.build/types/future-helpers/ranges.d.ts +0 -7
  69. package/.build/types/future-helpers/sequences.d.ts +0 -8
  70. package/.build/types/hooks/useAnnotation.d.ts +0 -8
  71. package/.build/types/hooks/useAnnotationPage.d.ts +0 -8
  72. package/.build/types/hooks/useAnnotationPageManager.d.ts +0 -10
  73. package/.build/types/hooks/useAnnotationsAtTime.d.ts +0 -4
  74. package/.build/types/hooks/useCanvas.d.ts +0 -8
  75. package/.build/types/hooks/useCanvasClock.d.ts +0 -1
  76. package/.build/types/hooks/useCanvasSelector.d.ts +0 -0
  77. package/.build/types/hooks/useCanvasSubset.d.ts +0 -2
  78. package/.build/types/hooks/useCanvasTimeline.d.ts +0 -0
  79. package/.build/types/hooks/useCollection.d.ts +0 -8
  80. package/.build/types/hooks/useDispatch.d.ts +0 -2
  81. package/.build/types/hooks/useEnabledAnnotationPageIds.d.ts +0 -1
  82. package/.build/types/hooks/useEventListener.d.ts +0 -4
  83. package/.build/types/hooks/useExistingVault.d.ts +0 -2
  84. package/.build/types/hooks/useExternalCollection.d.ts +0 -13
  85. package/.build/types/hooks/useExternalManifest.d.ts +0 -13
  86. package/.build/types/hooks/useExternalResource.d.ts +0 -16
  87. package/.build/types/hooks/useImage.d.ts +0 -10
  88. package/.build/types/hooks/useImageService.d.ts +0 -9
  89. package/.build/types/hooks/useImageTile.d.ts +0 -11
  90. package/.build/types/hooks/useLoadImageService.d.ts +0 -6
  91. package/.build/types/hooks/useManifest.d.ts +0 -8
  92. package/.build/types/hooks/usePaintables.d.ts +0 -9
  93. package/.build/types/hooks/usePaintingAnnotations.d.ts +0 -5
  94. package/.build/types/hooks/useRange.d.ts +0 -8
  95. package/.build/types/hooks/useRenderingStrategy.d.ts +0 -15
  96. package/.build/types/hooks/useResourceEvents.d.ts +0 -3
  97. package/.build/types/hooks/useResources.d.ts +0 -1
  98. package/.build/types/hooks/useSearchService.d.ts +0 -2
  99. package/.build/types/hooks/useSimpleMediaPlayer.d.ts +0 -32
  100. package/.build/types/hooks/useStyleHelper.d.ts +0 -1
  101. package/.build/types/hooks/useStyles.d.ts +0 -3
  102. package/.build/types/hooks/useThumbnail.d.ts +0 -5
  103. package/.build/types/hooks/useVault.d.ts +0 -2
  104. package/.build/types/hooks/useVaultEffect.d.ts +0 -2
  105. package/.build/types/hooks/useVaultSelector.d.ts +0 -2
  106. package/.build/types/hooks/useVirtualAnnotationPage.d.ts +0 -14
  107. package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +0 -671
  108. package/.build/types/hooks/useVirtualCanvas.d.ts +0 -0
  109. package/.build/types/index.d.ts +0 -72
  110. package/.build/types/utility/flatten-annotation-page-ids.d.ts +0 -7
  111. package/.build/types/utility/i18n-utils.d.ts +0 -30
  112. package/.build/types/utils.d.ts +0 -2
  113. package/.build/types/viewers/SimpleViewerContext.d.ts +0 -6
  114. package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +0 -19
  115. package/.build/types/viewers/SimpleViewerContext.types.d.ts +0 -46
  116. package/.build/types/viewers/SingleCanvasContext.d.ts +0 -1
  117. package/dist/bundle/cjs/index.js +0 -49
  118. package/dist/bundle/cjs/index.js.map +0 -1
  119. package/dist/bundle/esm/index.mjs +0 -3319
  120. package/dist/bundle/esm/index.mjs.map +0 -1
  121. package/dist/canvas-panel/cjs/canvas-panel.js +0 -47
  122. package/dist/canvas-panel/cjs/canvas-panel.js.map +0 -1
  123. package/dist/canvas-panel/esm/canvas-panel.mjs +0 -1858
  124. package/dist/canvas-panel/esm/canvas-panel.mjs.map +0 -1
  125. package/dist/index.umd.js +0 -393
  126. package/dist/index.umd.js.map +0 -1
  127. package/dist/react17/cjs/index.js +0 -49
  128. package/dist/react17/cjs/index.js.map +0 -1
  129. package/dist/react17/esm/index.mjs +0 -3319
  130. package/dist/react17/esm/index.mjs.map +0 -1
  131. package/dist/utils/cjs/utils.js +0 -2
  132. package/dist/utils/cjs/utils.js.map +0 -1
  133. package/dist/utils/esm/utils.mjs +0 -238
  134. package/dist/utils/esm/utils.mjs.map +0 -1
@@ -1,1858 +0,0 @@
1
- import { jsx as u, jsxs as M, Fragment as $ } from "react/jsx-runtime";
2
- import B, { createContext as F, Component as rt, createElement as Pe, isValidElement as it, useContext as T, useMemo as w, useState as L, useEffect as N, useRef as _, useCallback as b, useLayoutEffect as Ie, Fragment as te, useReducer as ot, forwardRef as Me, useImperativeHandle as at } from "react";
3
- import { AtlasAuto as st, ModeContext as ut, mergeStyles as ct, RegionHighlight as lt, TileSet as dt, HTMLPortal as ft } from "@atlas-viewer/atlas";
4
- import { globalVault as Ae, Vault as be } from "@iiif/helpers/vault";
5
- import { createStylesHelper as Te } from "@iiif/helpers/styles";
6
- import { expandTarget as le } from "@iiif/helpers/annotation-targets";
7
- import { expandTarget as ht } from "@iiif/helpers";
8
- import { ImageServiceLoader as gt, getImageServices as mt } from "@atlas-viewer/iiif-image-api";
9
- import { createThumbnailHelper as vt } from "@iiif/helpers/thumbnail";
10
- const pt = F(null), se = {
11
- didCatch: !1,
12
- error: null
13
- };
14
- class yt extends rt {
15
- constructor(t) {
16
- super(t), this.resetErrorBoundary = this.resetErrorBoundary.bind(this), this.state = se;
17
- }
18
- static getDerivedStateFromError(t) {
19
- return {
20
- didCatch: !0,
21
- error: t
22
- };
23
- }
24
- resetErrorBoundary() {
25
- const {
26
- error: t
27
- } = this.state;
28
- if (t !== null) {
29
- for (var n, r, i = arguments.length, o = new Array(i), a = 0; a < i; a++)
30
- o[a] = arguments[a];
31
- (n = (r = this.props).onReset) === null || n === void 0 || n.call(r, {
32
- args: o,
33
- reason: "imperative-api"
34
- }), this.setState(se);
35
- }
36
- }
37
- componentDidCatch(t, n) {
38
- var r, i;
39
- (r = (i = this.props).onError) === null || r === void 0 || r.call(i, t, n);
40
- }
41
- componentDidUpdate(t, n) {
42
- const {
43
- didCatch: r
44
- } = this.state, {
45
- resetKeys: i
46
- } = this.props;
47
- if (r && n.error !== null && xt(t.resetKeys, i)) {
48
- var o, a;
49
- (o = (a = this.props).onReset) === null || o === void 0 || o.call(a, {
50
- next: i,
51
- prev: t.resetKeys,
52
- reason: "keys"
53
- }), this.setState(se);
54
- }
55
- }
56
- render() {
57
- const {
58
- children: t,
59
- fallbackRender: n,
60
- FallbackComponent: r,
61
- fallback: i
62
- } = this.props, {
63
- didCatch: o,
64
- error: a
65
- } = this.state;
66
- let s = t;
67
- if (o) {
68
- const c = {
69
- error: a,
70
- resetErrorBoundary: this.resetErrorBoundary
71
- };
72
- if (typeof n == "function")
73
- s = n(c);
74
- else if (r)
75
- s = Pe(r, c);
76
- else if (i === null || it(i))
77
- s = i;
78
- else
79
- throw a;
80
- }
81
- return Pe(pt.Provider, {
82
- value: {
83
- didCatch: o,
84
- error: a,
85
- resetErrorBoundary: this.resetErrorBoundary
86
- }
87
- }, s);
88
- }
89
- }
90
- function xt() {
91
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
92
- return e.length !== t.length || e.some((n, r) => !Object.is(n, t[r]));
93
- }
94
- const wt = {
95
- collection: void 0,
96
- manifest: void 0,
97
- range: void 0,
98
- canvas: void 0,
99
- annotation: void 0,
100
- annotationPage: void 0
101
- }, fe = B.createContext(wt), z = () => T(fe);
102
- function re({ value: e, children: t }) {
103
- const n = z(), r = w(() => ({
104
- ...n,
105
- ...e
106
- }), [e, n]);
107
- return /* @__PURE__ */ u(fe.Provider, { value: r, children: t });
108
- }
109
- const ie = B.createContext({
110
- vault: null,
111
- setVaultInstance: (e) => {
112
- }
113
- });
114
- function he({
115
- vault: e,
116
- vaultOptions: t,
117
- useGlobal: n,
118
- resources: r,
119
- children: i
120
- }) {
121
- const [o, a] = L(() => e || (n ? Ae(t) : t ? new be(t) : new be()));
122
- return /* @__PURE__ */ u(ie.Provider, { value: { vault: o, setVaultInstance: a }, children: /* @__PURE__ */ u(re, { value: r || {}, children: i }) });
123
- }
124
- function ge(e) {
125
- const t = T(ie);
126
- return e || (t && t.vault ? t.vault : Ae());
127
- }
128
- function St(e, { noCache: t = !1 } = {}) {
129
- const n = typeof e == "string" ? e : e.id, r = ge(), [i, o] = L(n), [a, s] = L(void 0), c = w(() => r.get(n, { skipSelfReturn: !0 }) || void 0, [n, r]), [d, l] = L(c);
130
- return N(() => {
131
- (async () => {
132
- try {
133
- const f = c && !t ? c : await r.load(n), m = f ? f.id || f["@id"] : null;
134
- f && i !== m && o(m), l(f);
135
- } catch (f) {
136
- s(f);
137
- }
138
- })();
139
- }, [n, t]), {
140
- isLoaded: !!d,
141
- id: i,
142
- requestId: n,
143
- error: a,
144
- resource: d,
145
- cached: !!(d && d === c)
146
- };
147
- }
148
- function Pt(e, t) {
149
- const { id: n, isLoaded: r, error: i, resource: o, requestId: a, cached: s } = St(
150
- e,
151
- t
152
- );
153
- return { id: n, isLoaded: r, error: i, manifest: o, requestId: a, cached: s };
154
- }
155
- function bt({ manifest: e, children: t }) {
156
- return /* @__PURE__ */ u(re, { value: { manifest: e }, children: t });
157
- }
158
- function me({ canvas: e, children: t }) {
159
- return /* @__PURE__ */ u(re, { value: { canvas: e }, children: t });
160
- }
161
- const O = () => {
162
- const { vault: e } = T(ie);
163
- if (e === null)
164
- throw new Error("Vault not found. Ensure you have your provider set up correctly.");
165
- return e;
166
- };
167
- function R(e, t = []) {
168
- const n = O(), [r, i] = L(() => e(n.getState(), n));
169
- return N(() => n.subscribe(
170
- (o) => e(o, n),
171
- (o) => {
172
- i(o);
173
- },
174
- !1
175
- ), t), r;
176
- }
177
- const oe = B.createContext([]);
178
- function Re() {
179
- const e = T(oe);
180
- return R(
181
- (t) => e.map((n) => t.iiif.entities.Canvas[n]).filter(Boolean),
182
- [e]
183
- );
184
- }
185
- function K(e = {}, t = []) {
186
- const { id: n, selector: r } = e, i = z();
187
- O();
188
- const o = n || i.manifest, a = R(
189
- (s) => o ? s.iiif.entities.Manifest[o] : void 0,
190
- [o]
191
- );
192
- return w(() => {
193
- if (a)
194
- return r ? r(a) : a;
195
- }, [a, r, ...t]);
196
- }
197
- function Ct({ range: e, children: t }) {
198
- return /* @__PURE__ */ u(re, { value: { range: e }, children: t });
199
- }
200
- function Ve(e, t) {
201
- var r;
202
- const n = [];
203
- for (const i of t.items)
204
- if (i.type === "SpecificResource" && ((r = i.source) == null ? void 0 : r.type) === "Canvas" && (i.source.id.indexOf("#") !== -1 ? n.push({ id: i.source.id.split("#")[0], type: "Canvas" }) : n.push(i.source)), i.type === "Range" && n.push(...Ve(e, e.get(i))), i.type === "SpecificResource") {
205
- const o = typeof i.source == "string" ? i.source : i.source.id;
206
- n.push({ id: o, type: "Canvas" });
207
- }
208
- return n;
209
- }
210
- function Et(e, t, { disablePaging: n, skipNonPaged: r } = {}) {
211
- const i = t.behavior, o = i.includes("paged"), a = o ? !1 : i.includes("continuous"), s = o || a ? !1 : i.includes("individuals"), c = t.type === "Manifest" ? t.items : Ve(e, t);
212
- if (a)
213
- return [c, [c.map((g, x) => x)]];
214
- if (s || !o || n)
215
- return [c, c.map((g, x) => [x])];
216
- const d = [];
217
- let l = [];
218
- const f = () => {
219
- l.length && (d.push([...l]), l = []);
220
- };
221
- let m = 0, p = !1;
222
- for (let g = 0; g < c.length; g++) {
223
- const x = e.get(c[g]);
224
- if (x.behavior.includes("non-paged")) {
225
- g === m && m++, r || (f(), d.push([g]), f());
226
- continue;
227
- }
228
- if (g === m || x.behavior.includes("facing-pages")) {
229
- l.length && (p = !0), f(), d.push([g]), f();
230
- continue;
231
- }
232
- if (l.push(g), p) {
233
- f(), p = !1;
234
- continue;
235
- }
236
- l.length > 1 && f();
237
- }
238
- return l.length && f(), [c, d];
239
- }
240
- function It(e = {}, t = []) {
241
- const { id: n, selector: r } = e, i = z(), o = n || i.range, a = R((s) => o ? s.iiif.entities.Range[o] : void 0, [o]);
242
- return w(() => {
243
- if (a)
244
- return r ? r(a) : a;
245
- }, [a, r, ...t]);
246
- }
247
- function Mt({ startCanvas: e, disablePaging: t }) {
248
- var x;
249
- const n = O(), r = K(), i = It(), [o, a] = L(void 0), s = i || r;
250
- if (!s)
251
- throw new Error("Nothing selected");
252
- const [c, d] = w(
253
- () => Et(n, s, { disablePaging: t }),
254
- [n, s, t]
255
- ), l = _(d);
256
- if (l.current !== d) {
257
- const y = l.current[o][0], C = d.findIndex((S) => S.includes(y));
258
- l.current = d, a(C);
259
- }
260
- const f = b(
261
- (v) => {
262
- const y = d.findIndex((C) => C.includes(v));
263
- a(y === -1 ? 0 : y);
264
- },
265
- [c, d]
266
- ), m = b(
267
- (v) => {
268
- const y = c.findIndex((C) => C.id === v);
269
- y !== -1 ? f(y) : a(0);
270
- },
271
- [c, d]
272
- ), p = b(() => {
273
- a((v) => v >= d.length - 1 ? v : v + 1);
274
- }, [d]), g = b(() => {
275
- a((v) => v <= 0 ? 0 : v - 1);
276
- }, [d]);
277
- return typeof o > "u" && (e ? m(e) : a(0)), {
278
- visibleItems: ((x = d[o]) == null ? void 0 : x.map((v) => c[v].id)) || [],
279
- cursor: o,
280
- items: c,
281
- sequence: d,
282
- hasPrevious: o > 0,
283
- hasNext: o < d.length - 1,
284
- setSequenceIndex: a,
285
- setCanvasIndex: f,
286
- setCanvasId: m,
287
- next: p,
288
- previous: g
289
- };
290
- }
291
- const J = () => {
292
- }, ae = F({
293
- setCurrentCanvasId: J,
294
- setCurrentCanvasIndex: J,
295
- nextCanvas: J,
296
- previousCanvas: J,
297
- items: [],
298
- sequence: [],
299
- setSequenceIndex: J,
300
- currentSequenceIndex: 0,
301
- hasNext: !1,
302
- hasPrevious: !1
303
- });
304
- function At(e) {
305
- const t = K(), {
306
- cursor: n,
307
- visibleItems: r,
308
- next: i,
309
- sequence: o,
310
- items: a,
311
- setCanvasIndex: s,
312
- setCanvasId: c,
313
- previous: d,
314
- setSequenceIndex: l,
315
- hasNext: f,
316
- hasPrevious: m
317
- } = Mt({
318
- startCanvas: e.startCanvas,
319
- disablePaging: e.pagingEnabled === !1
320
- }), p = w(
321
- () => ({
322
- sequence: o,
323
- items: a,
324
- // Extra functions.
325
- setCurrentCanvasId: c,
326
- nextCanvas: i,
327
- previousCanvas: d,
328
- totalCanvases: a.length,
329
- setCurrentCanvasIndex: s,
330
- setSequenceIndex: l,
331
- currentSequenceIndex: n,
332
- hasNext: f,
333
- hasPrevious: m
334
- }),
335
- [o, a, c, i, d, a, s, l, n]
336
- );
337
- return t ? r.length === 0 ? null : /* @__PURE__ */ u(ae.Provider, { value: p, children: /* @__PURE__ */ u(oe.Provider, { value: r, children: /* @__PURE__ */ u(me, { canvas: r[0], children: e.children }) }) }) : (console.warn("The manifest passed to the provider is not a valid IIIF manifest."), /* @__PURE__ */ u("div", { children: "Sorry, something went wrong." }));
338
- }
339
- function Tt(e) {
340
- const t = ge(e.vault), n = Pt(e.manifest);
341
- if (!n)
342
- return console.warn("The manifest passed to the provider is not a valid IIIF manifest."), /* @__PURE__ */ u("div", { children: "Sorry, something went wrong." });
343
- if (n.error)
344
- return /* @__PURE__ */ u("div", { children: n.error.toString() });
345
- if (!n.isLoaded)
346
- return /* @__PURE__ */ u("div", { children: "Loading..." });
347
- const r = /* @__PURE__ */ u(At, { ...e, children: e.children });
348
- return /* @__PURE__ */ u(he, { vault: t, children: /* @__PURE__ */ u(bt, { manifest: n.id, children: e.rangeId ? /* @__PURE__ */ u(Ct, { range: e.rangeId, children: r }) : r }) });
349
- }
350
- function Rt() {
351
- return T(ae);
352
- }
353
- function Vt() {
354
- return {
355
- VaultContext: T(ie),
356
- ResourceContext: T(fe),
357
- SimpleViewerReactContext: T(ae),
358
- VisibleCanvasReactContext: T(oe)
359
- };
360
- }
361
- function Ot(e) {
362
- return /* @__PURE__ */ u(he, { vault: e.bridge.VaultContext.vault || void 0, resources: e.bridge.ResourceContext, children: /* @__PURE__ */ u(oe.Provider, { value: e.bridge.VisibleCanvasReactContext, children: /* @__PURE__ */ u(ae.Provider, { value: e.bridge.SimpleViewerReactContext, children: e.children }) }) });
363
- }
364
- const U = function(e) {
365
- return function() {
366
- const t = { type: e, getType: () => e, toString: () => e };
367
- return (n, r) => ({
368
- ...t,
369
- ...n !== void 0 && { payload: n },
370
- ...r !== void 0 && { meta: r }
371
- });
372
- };
373
- }, Lt = "@iiif/IMPORT_ENTITIES", kt = "@iiif/MODIFY_ENTITY_FIELD", Nt = "@iiif/REORDER_ENTITY_FIELD", Ft = "@iiif/ADD_REFERENCE", Ut = "@iiif/UPDATE_REFERENCE", Dt = "@iiif/REMOVE_REFERENCE", _t = "@iiif/ADD_METADATA", qt = "@iiif/REMOVE_METADATA", Bt = "@iiif/UPDATE_METADATA", jt = "@iiif/REORDER_METADATA", Ht = U(Lt)(), $t = U(kt)(), Yt = U(Nt)(), zt = U(Ft)(), Kt = U(Dt)(), Wt = U(Ut)(), Gt = U(_t)(), Qt = U(Bt)(), Jt = U(qt)(), Zt = U(jt)(), ue = {
374
- importEntities: Ht,
375
- modifyEntityField: $t,
376
- reorderEntityField: Yt,
377
- addReference: zt,
378
- removeReference: Kt,
379
- updateReference: Wt,
380
- addMetadata: Gt,
381
- removeMetadata: Jt,
382
- updateMetadata: Qt,
383
- reorderMetadata: Zt
384
- };
385
- function Xt() {
386
- const t = O().getStore();
387
- return w(() => (n) => t.dispatch(n), [t]);
388
- }
389
- function Ce(e) {
390
- return typeof e != "string" && e && e.bindToVault;
391
- }
392
- function en() {
393
- const e = O(), t = _([]), n = Xt(), r = w(() => `vault://annotation-page/${(/* @__PURE__ */ new Date()).getTime()}/${Math.round(Math.random() * 1e9).toString(16)}`, []);
394
- Ie(() => {
395
- const s = {
396
- id: r,
397
- type: "AnnotationPage",
398
- behavior: [],
399
- label: null,
400
- thumbnail: [],
401
- summary: null,
402
- requiredStatement: null,
403
- metadata: [],
404
- rights: null,
405
- provider: [],
406
- items: [],
407
- seeAlso: [],
408
- homepage: [],
409
- rendering: [],
410
- service: []
411
- };
412
- n(
413
- ue.importEntities({
414
- entities: {
415
- AnnotationPage: {
416
- [s.id]: s
417
- }
418
- }
419
- })
420
- );
421
- }, [r]);
422
- const i = R(
423
- (s) => r ? s.iiif.entities.AnnotationPage[r] : null,
424
- [r]
425
- ), o = b(
426
- (s, c) => {
427
- if (r) {
428
- if (Ce(s)) {
429
- const f = s;
430
- f.__vault || f.bindToVault(e), s = typeof f.source == "string" ? f.source : f.source.id, t.current[s] = f;
431
- } else
432
- typeof s != "string" && (s = s.id);
433
- const d = e.get({ id: r, type: "AnnotationPage" }), l = e.get({ id: s, type: "Annotation" });
434
- d && l && (d.items.find((f) => f.id === l.id) || n(
435
- ue.addReference({
436
- id: r,
437
- type: "AnnotationPage",
438
- key: "items",
439
- reference: {
440
- id: s,
441
- type: "Annotation"
442
- },
443
- index: c
444
- })
445
- ));
446
- }
447
- },
448
- [r]
449
- ), a = b(
450
- (s) => {
451
- r && (Ce(s) ? s = typeof s.source == "string" ? s.source : s.source.id : typeof s != "string" && (s = s.id), t.current[s] && t.current[s].beforeRemove(), e.get({ id: r, type: "AnnotationPage" }) && n(
452
- ue.removeReference({
453
- id: r,
454
- type: "AnnotationPage",
455
- key: "items",
456
- reference: {
457
- id: s,
458
- type: "Annotation"
459
- }
460
- })
461
- ));
462
- },
463
- [r]
464
- );
465
- return [
466
- i,
467
- {
468
- addAnnotation: o,
469
- removeAnnotation: a
470
- }
471
- ];
472
- }
473
- const Oe = F(null);
474
- function tn() {
475
- const e = T(Oe);
476
- return [
477
- e.fullPage,
478
- {
479
- addAnnotation: e.addAnnotation,
480
- removeAnnotation: e.removeAnnotation
481
- }
482
- ];
483
- }
484
- function nn({ children: e }) {
485
- const [t, { addAnnotation: n, removeAnnotation: r }] = en();
486
- return /* @__PURE__ */ u(
487
- Oe.Provider,
488
- {
489
- value: w(() => ({ fullPage: t, addAnnotation: n, removeAnnotation: r }), [t]),
490
- children: e
491
- }
492
- );
493
- }
494
- function rn({
495
- width: e,
496
- style: t,
497
- height: n,
498
- error: r,
499
- resetErrorBoundary: i
500
- }) {
501
- return /* @__PURE__ */ M("div", { style: { width: e, height: n, minHeight: 500, ...t || {}, background: "#f9f9f9" }, children: [
502
- /* @__PURE__ */ u("h3", { children: "Error occurred" }),
503
- /* @__PURE__ */ u("p", { children: r.message }),
504
- /* @__PURE__ */ u("button", { onClick: i, children: "Reset" })
505
- ] });
506
- }
507
- const ve = F(null);
508
- function on() {
509
- return T(ve);
510
- }
511
- const Le = F(
512
- () => {
513
- }
514
- ), ke = F(
515
- () => {
516
- }
517
- );
518
- function Y(e, t, n, r, i = []) {
519
- const o = T(e === "portal" ? ke : Le);
520
- N(() => (e !== "none" && o(t, n, r), () => {
521
- o(t, null);
522
- }), [t, e, o, ...i]);
523
- }
524
- function j(e = {}, t = []) {
525
- const { id: n, selector: r } = e, i = z(), o = n || i.canvas, a = R((s) => o ? s.iiif.entities.Canvas[o] : void 0, [o]);
526
- return w(() => {
527
- if (a)
528
- return r ? r(a) : a;
529
- }, [a, r, ...t]);
530
- }
531
- const Ne = F(() => {
532
- });
533
- function an(e) {
534
- const t = j(), n = T(Ne);
535
- N(() => t && t.id ? (n(t.id, e), () => n(t.id, -1)) : () => {
536
- }, [t, e]);
537
- }
538
- function sn({
539
- children: e,
540
- errorFallback: t,
541
- outerContainerProps: n = {},
542
- worldScale: r,
543
- ...i
544
- }) {
545
- const [o, a] = L(), s = Vt(), c = t || rn, [d, l] = L({}), f = Object.entries(d), [m, p] = L({}), g = Object.entries(m), [x, v] = L({}), y = w(() => r || Math.max(...Object.values(x)), [x]), C = w(() => ({ maxOverZoom: y || 1, ...i.runtimeOptions || {} }), [y, i.runtimeOptions]), S = b((E, A) => {
546
- v((k) => {
547
- if (A === -1) {
548
- const { [E]: h, ...D } = k;
549
- return D;
550
- }
551
- return { ...k, [E]: A };
552
- });
553
- }, []), W = b((E, A, k) => {
554
- l(({ [E]: h, ...D }) => A ? {
555
- ...D,
556
- [E]: { element: A, props: k }
557
- } : D);
558
- }, []), Z = b((E, A, k) => {
559
- p(({ [E]: h, ...D }) => A ? {
560
- ...D,
561
- [E]: { element: A, props: k }
562
- } : D);
563
- }, []);
564
- return /* @__PURE__ */ M(yt, { resetKeys: [], fallbackRender: (E) => /* @__PURE__ */ u(c, { ...i, ...E }), children: [
565
- /* @__PURE__ */ u(
566
- st,
567
- {
568
- ...i,
569
- containerProps: { style: { position: "relative" }, ...i.containerProps || {} },
570
- htmlChildren: /* @__PURE__ */ u($, { children: f.map(([E, { element: A, props: k }]) => /* @__PURE__ */ u(B.Fragment, { children: /* @__PURE__ */ u(A, { ...k || {} }) }, E)) }),
571
- onCreated: (E) => {
572
- a(E), i.onCreated && i.onCreated(E);
573
- },
574
- runtimeOptions: C,
575
- children: /* @__PURE__ */ u(ve.Provider, { value: o, children: /* @__PURE__ */ u(Ne.Provider, { value: S, children: /* @__PURE__ */ u(Le.Provider, { value: W, children: /* @__PURE__ */ u(ke.Provider, { value: Z, children: /* @__PURE__ */ u(Ot, { bridge: s, children: /* @__PURE__ */ u(ut.Provider, { value: i.mode || "explore", children: /* @__PURE__ */ u(nn, { children: e }) }) }) }) }) }) })
576
- }
577
- ),
578
- /* @__PURE__ */ u("div", { children: g.map(([E, { element: A, props: k }]) => /* @__PURE__ */ u(B.Fragment, { children: /* @__PURE__ */ u(A, { ...k || {} }) }, E)) })
579
- ] });
580
- }
581
- const X = {}, Fe = {
582
- get(e) {
583
- return e;
584
- },
585
- setMetaValue([e, t, n], r) {
586
- const i = Fe.getResourceMeta(e, t), o = i ? i[n] : void 0, a = typeof r == "function" ? r(o) : r;
587
- X[e] = {
588
- ...X[e] || {},
589
- [t]: {
590
- ...(X[e] || {})[t] || {},
591
- [n]: a
592
- }
593
- };
594
- },
595
- getResourceMeta: (e, t) => {
596
- const n = X[e];
597
- if (n)
598
- return t ? n[t] : n;
599
- }
600
- };
601
- function un(e = Fe) {
602
- return {
603
- addEventListener(t, n, r, i) {
604
- if (t)
605
- return e.setMetaValue(
606
- [t.id, "eventManager", n],
607
- (o) => {
608
- const a = o || [];
609
- for (const s of a)
610
- if (s.callback === r)
611
- return a;
612
- return [...a, { callback: r, scope: i }];
613
- }
614
- ), r;
615
- },
616
- removeEventListener(t, n, r) {
617
- t && e.setMetaValue(
618
- [t.id, "eventManager", n],
619
- (i) => (i || []).filter((o) => o.callback !== r)
620
- );
621
- },
622
- getListenersAsProps(t, n) {
623
- const r = typeof t == "string" ? { id: t } : t;
624
- if (!r || !r.id)
625
- return {};
626
- const i = e.getResourceMeta(r.id, "eventManager"), o = {};
627
- if (i && r)
628
- for (const a of Object.keys(i))
629
- o[a] = (s) => {
630
- const c = e.get(r);
631
- for (const { callback: d, scope: l } of i[a] || [])
632
- (!l || n && l.indexOf(n) !== -1) && d(s, c);
633
- };
634
- return o;
635
- }
636
- };
637
- }
638
- function Ue(e, t) {
639
- const n = O(), r = w(() => un(n), [n]), i = R(() => e && e.id ? n.getResourceMeta(e.id, "eventManager") : null, [e]);
640
- return w(() => e ? r.getListenersAsProps(e, t) : {}, [i, e, n, t]);
641
- }
642
- function ne(e, t) {
643
- const n = O(), r = w(() => Te(n), [n]);
644
- return R(() => {
645
- if (!e)
646
- return null;
647
- const i = r.getAppliedStyles(e.id);
648
- return i ? t ? i[t] : i : void 0;
649
- }, [e, t]);
650
- }
651
- function De(e = {}, t = []) {
652
- const { id: n, selector: r } = e, i = z(), o = O(), a = n || i.annotation, s = R(
653
- (d) => a ? d.iiif.entities.Annotation[a] : void 0,
654
- [a]
655
- ), c = R(
656
- (d) => s && s.body ? s.body.map((l) => l ? l.type === "SpecificResource" ? {
657
- ...l,
658
- source: o.get(l)
659
- } : l ? d.iiif.entities[l.type][l.id] : null : null).filter(Boolean) : [],
660
- [s]
661
- );
662
- return w(() => {
663
- if (!s)
664
- return;
665
- const d = {
666
- ...s,
667
- body: c,
668
- target: le(s.target, { typeMap: o.getState().iiif.mapping })
669
- };
670
- return r ? r(d) : d;
671
- }, [s, r, c, ...t]);
672
- }
673
- const _e = ({
674
- id: e,
675
- style: t,
676
- className: n,
677
- interactive: r
678
- }) => {
679
- const i = De({ id: e }), o = ne(i, "atlas"), a = ne(i, "html"), s = Ue(i, ["atlas"]), c = j(), d = w(() => ct(t, o), [t, o]);
680
- return c && i && i.target && i.target.selector && i.target.selector.type === "BoxSelector" && i.target.source && (i.target.source.id === c.id || i.target.source === c.id) ? /* @__PURE__ */ u(
681
- lt,
682
- {
683
- id: i.id,
684
- isEditing: !0,
685
- region: i.target.selector.spatial,
686
- style: d,
687
- className: (a == null ? void 0 : a.className) || n,
688
- interactive: !!(a != null && a.href || r),
689
- href: (a == null ? void 0 : a.href) || null,
690
- title: (a == null ? void 0 : a.title) || null,
691
- hrefTarget: (a == null ? void 0 : a.target) || null,
692
- onClick: () => {
693
- },
694
- ...s
695
- }
696
- ) : null;
697
- };
698
- function cn(e = {}, t = []) {
699
- const { id: n, selector: r } = e, i = z(), o = n || i.annotationPage, a = R(
700
- (s) => o ? s.iiif.entities.AnnotationPage[o] : void 0,
701
- [o]
702
- );
703
- return w(() => {
704
- if (a)
705
- return r ? r(a) : a;
706
- }, [a, ...t]);
707
- }
708
- const de = ({
709
- className: e,
710
- page: t
711
- }) => {
712
- var o;
713
- const n = cn({ id: t.id }) || t, r = ne(n, "atlas"), i = ne(n, "html");
714
- return R((a) => n.id ? a.iiif.entities.AnnotationPage[n.id] : null, []), /* @__PURE__ */ u(te, { children: (o = n.items) == null ? void 0 : o.map((a) => /* @__PURE__ */ u(
715
- _e,
716
- {
717
- id: a.id,
718
- style: r,
719
- className: (i == null ? void 0 : i.className) || e
720
- },
721
- a.id
722
- )) });
723
- };
724
- function qe({
725
- id: e,
726
- image: t,
727
- thumbnail: n,
728
- isStatic: r,
729
- x: i = 0,
730
- y: o = 0,
731
- children: a,
732
- selector: s,
733
- onClick: c,
734
- enableSizes: d
735
- }) {
736
- var f, m;
737
- const l = w(() => {
738
- if (!(!s || s.spatial.x === 0 && s.spatial.y === 0))
739
- return s.spatial;
740
- }, [s]);
741
- return /* @__PURE__ */ u(
742
- "world-object",
743
- {
744
- x: i + t.target.spatial.x,
745
- y: o + t.target.spatial.y,
746
- width: t.target.spatial.width,
747
- height: t.target.spatial.height,
748
- onClick: c,
749
- children: t.service ? /* @__PURE__ */ M(te, { children: [
750
- /* @__PURE__ */ u(
751
- dt,
752
- {
753
- tiles: {
754
- id: t.service.id || t.service["@id"] || "unknown",
755
- height: t.height,
756
- width: t.width,
757
- imageService: t.service,
758
- thumbnail: n && n.type === "fixed" ? n : void 0
759
- },
760
- enableSizes: d,
761
- x: 0,
762
- y: 0,
763
- width: (f = t.target) == null ? void 0 : f.spatial.width,
764
- height: (m = t.target) == null ? void 0 : m.spatial.height,
765
- crop: l
766
- }
767
- ),
768
- a
769
- ] }, "service") : /* @__PURE__ */ M(te, { children: [
770
- /* @__PURE__ */ u(
771
- "world-image",
772
- {
773
- onClick: c,
774
- uri: t.id,
775
- target: { x: 0, y: 0, width: t.target.spatial.width, height: t.target.spatial.height },
776
- display: t.width && t.height ? {
777
- width: t.width,
778
- height: t.height
779
- } : void 0,
780
- crop: l
781
- }
782
- ),
783
- a
784
- ] }, "no-service")
785
- },
786
- e + (t.service ? "server" : "no-service")
787
- );
788
- }
789
- function Be(e, t) {
790
- const { selector: n, source: r } = ht(t);
791
- if (r.id !== e.id)
792
- return [null, r];
793
- const i = {
794
- type: "BoxSelector",
795
- spatial: {
796
- x: 0,
797
- y: 0,
798
- width: Number(e.width),
799
- height: Number(e.height)
800
- }
801
- };
802
- return [
803
- n ? n.type === "TemporalSelector" ? {
804
- type: "TemporalBoxSelector",
805
- temporal: n.temporal,
806
- spatial: i.spatial
807
- } : n : null,
808
- r
809
- ];
810
- }
811
- const ln = {
812
- makeChoice: () => {
813
- }
814
- }, ce = { type: "unknown" }, I = (e) => ({ type: "unknown", reason: e, annotations: { pages: [] } }), dn = (e, t) => ({ type: "empty", width: e, height: t, annotations: { pages: [] }, image: null, images: [] });
815
- function fn(e, t) {
816
- var r;
817
- const n = (r = e == null ? void 0 : e.iiif) == null ? void 0 : r.meta[t];
818
- return n ? n.annotationPageManager : null;
819
- }
820
- function hn(e, t) {
821
- return R(
822
- (n) => {
823
- const r = [];
824
- if (!e)
825
- return r;
826
- const i = Object.keys(n.iiif.entities.AnnotationPage);
827
- for (const o of i)
828
- if (!t || t.indexOf(o) !== -1) {
829
- const a = fn(n, o);
830
- a && a.views && a.views[e] && r.push(o);
831
- }
832
- return r;
833
- },
834
- [e, t]
835
- );
836
- }
837
- function gn({
838
- canvas: e,
839
- manifest: t,
840
- all: n,
841
- canvases: r
842
- }) {
843
- const i = [];
844
- if (t)
845
- for (const o of t.annotations)
846
- i.indexOf(o.id) === -1 && i.push(o.id);
847
- if (n) {
848
- if (r && r.length)
849
- for (const o of r)
850
- for (const a of o.annotations)
851
- i.indexOf(a.id) === -1 && i.push(a.id);
852
- } else if (e)
853
- for (const o of e.annotations)
854
- i.indexOf(o.id) === -1 && i.push(o.id);
855
- return i;
856
- }
857
- function mn(e, t) {
858
- var r;
859
- const n = (r = e == null ? void 0 : e.iiif) == null ? void 0 : r.meta[t];
860
- return n ? n.annotationPageManager : null;
861
- }
862
- function vn(e, t = {}) {
863
- const n = O(), r = K(), i = j(), o = Re(), a = w(() => gn({
864
- all: t.all,
865
- manifest: r,
866
- canvas: i,
867
- canvases: o
868
- }), [t.all, i, o, r]), s = hn(e, t.all ? void 0 : a), c = b(
869
- (l) => {
870
- e && n.setMetaValue(
871
- [l, "annotationPageManager", "views"],
872
- (f) => f && !f[e] ? f : {
873
- ...f || {},
874
- [e]: !1
875
- }
876
- );
877
- },
878
- [e, n]
879
- ), d = b(
880
- (l, f = {}) => {
881
- if (!e)
882
- return;
883
- const m = n.getState(), p = [];
884
- if (f != null && f.deselectOthers) {
885
- const g = Object.keys(m.iiif.entities.AnnotationPage);
886
- for (const x of g) {
887
- const v = mn(m, x);
888
- v && v.views && v.views[e] && p.push(x);
889
- }
890
- }
891
- for (const g of p)
892
- c(g);
893
- n.setMetaValue(
894
- [l, "annotationPageManager", "views"],
895
- (g) => g && g[e] ? g : {
896
- ...g || {},
897
- [e]: !0
898
- }
899
- );
900
- },
901
- [e, c, n]
902
- );
903
- return {
904
- availablePageIds: a,
905
- enabledPageIds: s,
906
- setPageEnabled: d,
907
- setPageDisabled: c
908
- };
909
- }
910
- function pn(e, t) {
911
- return R((n, r) => r.get(e.map((i) => ({ id: i, type: t }))), [e, t]);
912
- }
913
- const yn = B.createContext(new gt());
914
- function je() {
915
- return T(yn);
916
- }
917
- function xn() {
918
- const e = je(), [t, n] = L({}), r = _(!1);
919
- return N(() => () => {
920
- r.current = !0;
921
- }, []), [b(
922
- (o, { height: a, width: s }) => {
923
- if (o) {
924
- const c = o.id || o["@id"], d = e.loadServiceSync({
925
- id: c,
926
- width: o.width || s,
927
- height: o.height || a,
928
- source: o
929
- });
930
- d ? o = d : t[c] || (r.current || n((l) => ({
931
- ...l,
932
- [c]: "loading"
933
- })), e.loadService({
934
- id: c,
935
- width: o.width || s,
936
- height: o.height || a
937
- }).then(() => {
938
- r.current || n((l) => ({
939
- ...l,
940
- [c]: "done"
941
- }));
942
- }));
943
- }
944
- return o;
945
- },
946
- [e, t]
947
- ), t];
948
- }
949
- function wn(e = {}) {
950
- const t = De(), n = j(e.canvasId ? { id: e.canvasId } : void 0);
951
- return R(
952
- (r, i) => {
953
- if (!n)
954
- return [];
955
- if (t && e.enableSingleAnnotation)
956
- return [t];
957
- const o = i.get(n.items), a = [];
958
- for (const s of o)
959
- a.push(...i.get(s.items));
960
- return a;
961
- },
962
- [n]
963
- );
964
- }
965
- function Sn(e) {
966
- return e.type === "SpecificResource" ? [e.source, { selector: e.selector }] : [e, { selector: null }];
967
- }
968
- const ee = {}, He = {
969
- get(e) {
970
- return e;
971
- },
972
- setMetaValue([e, t, n], r) {
973
- const i = He.getResourceMeta(e, t), o = i ? i[n] : void 0, a = typeof r == "function" ? r(o) : r;
974
- ee[e] = {
975
- ...ee[e] || {},
976
- [t]: {
977
- ...(ee[e] || {})[t] || {},
978
- [n]: a
979
- }
980
- };
981
- },
982
- getResourceMeta: (e, t) => {
983
- const n = ee[e];
984
- if (n)
985
- return t ? n[t] : n;
986
- }
987
- };
988
- function Pn(e = He) {
989
- function t(i) {
990
- const o = i ? typeof i == "string" ? e.get(i) : i : null;
991
- if (!o)
992
- return [];
993
- const a = e.get(o.items, { parent: o }), s = [];
994
- for (const c of a)
995
- s.push(...e.get(c.items, { parent: c }));
996
- return s;
997
- }
998
- function n(i, o = []) {
999
- const a = Array.isArray(i) ? i : t(i), s = [];
1000
- let c = null;
1001
- const d = [];
1002
- for (const l of a) {
1003
- if (l.type !== "Annotation")
1004
- throw new Error("getPaintables() accept either a canvas or list of annotations");
1005
- const f = Array.from(Array.isArray(l.body) ? l.body : [l.body]);
1006
- for (const m of f) {
1007
- const [p, { selector: g }] = Sn(m), x = e.get(p), v = (x.type || "unknown").toLowerCase();
1008
- if (v === "choice") {
1009
- const y = e.get(x.items, { parent: x.id }), C = o.length ? o.map((S) => y.find((W) => W.id === S)).filter(Boolean) : [y[0]];
1010
- C.length === 0 && C.push(y[0]), c = {
1011
- type: "single-choice",
1012
- items: y.map((S) => ({
1013
- id: S.id,
1014
- label: S.label,
1015
- selected: C.indexOf(S) !== -1
1016
- })),
1017
- label: p.label
1018
- }, f.push(...C);
1019
- continue;
1020
- }
1021
- s.indexOf(v) === -1 && s.push(v), d.push({
1022
- type: v,
1023
- annotationId: l.id,
1024
- resource: x,
1025
- target: l.target,
1026
- selector: g
1027
- });
1028
- }
1029
- }
1030
- return {
1031
- types: s,
1032
- items: d,
1033
- choice: c
1034
- };
1035
- }
1036
- function r(i) {
1037
- const { choice: o } = n(i);
1038
- return o;
1039
- }
1040
- return {
1041
- getAllPaintingAnnotations: t,
1042
- getPaintables: n,
1043
- extractChoices: r
1044
- };
1045
- }
1046
- function bn(e, t = []) {
1047
- const n = O(), r = w(() => Pn(n), []), i = wn({ enableSingleAnnotation: e == null ? void 0 : e.enableSingleAnnotation }), [o, a] = L((e == null ? void 0 : e.defaultChoices) || []), s = w(
1048
- () => r.getPaintables(i, o),
1049
- [n, i, o, ...t]
1050
- ), d = { makeChoice: b(
1051
- (l, { deselectOthers: f = !0, deselect: m = !1 } = {}) => {
1052
- if (s.choice) {
1053
- if (s.choice.type !== "single-choice")
1054
- throw new Error("Complex choice not supported yet");
1055
- a((p) => {
1056
- if (m) {
1057
- const x = p.filter((v) => v !== l);
1058
- if (x.length === 0) {
1059
- const v = s.items[0].resource.id;
1060
- return v ? [v] : [];
1061
- }
1062
- return x;
1063
- }
1064
- if (f)
1065
- return [l];
1066
- const g = [...p];
1067
- if (g.length === 0 && s.items.length) {
1068
- const x = s.items[0].resource.id;
1069
- x && g.push(x);
1070
- }
1071
- return p.indexOf(l) !== -1 ? p : [...p, l];
1072
- });
1073
- }
1074
- },
1075
- [s.choice]
1076
- ) };
1077
- return [s, d];
1078
- }
1079
- const Cn = ["model/gltf-binary"];
1080
- function En(e, t) {
1081
- const r = t.items[0].resource;
1082
- return r.format ? Cn.indexOf(r.format) === -1 ? I(`3D format: ${r.format} is unsupported`) : {
1083
- type: "3d-model",
1084
- model: r
1085
- } : I("Unknown format");
1086
- }
1087
- function In(e, t) {
1088
- var r;
1089
- if (!e.duration)
1090
- return I("No duration on canvas");
1091
- if (t.items.length > 1)
1092
- return I("Only one audio source supported");
1093
- const n = (r = t.items[0]) == null ? void 0 : r.resource;
1094
- return n ? n.format ? {
1095
- type: "media",
1096
- media: {
1097
- annotationId: t.items[0].annotationId,
1098
- duration: e.duration,
1099
- url: n.id,
1100
- type: "Sound",
1101
- target: {
1102
- type: "TemporalSelector",
1103
- temporal: {
1104
- startTime: 0,
1105
- endTime: e.duration
1106
- }
1107
- },
1108
- format: n.format,
1109
- selector: {
1110
- type: "TemporalSelector",
1111
- temporal: {
1112
- startTime: 0,
1113
- endTime: e.duration
1114
- }
1115
- }
1116
- },
1117
- annotations: {
1118
- pages: []
1119
- }
1120
- } : I("Audio does not have format") : I("Unknown audio");
1121
- }
1122
- function Mn(e, t, n) {
1123
- const r = [];
1124
- for (const i of t.items) {
1125
- const o = i.resource && i.resource.type === "SpecificResource" ? i.resource.source : i.resource;
1126
- if (!o.id)
1127
- return I("No resource Identifier");
1128
- let a;
1129
- if (o.service) {
1130
- const p = mt(o);
1131
- p[0] && (a = n(p[0], e));
1132
- }
1133
- const s = {
1134
- type: "BoxSelector",
1135
- spatial: {
1136
- x: 0,
1137
- y: 0,
1138
- width: Number(e.width),
1139
- height: Number(e.height)
1140
- }
1141
- }, [c, d] = Be(e, i.target);
1142
- if (!(d.id === e.id || decodeURIComponent(d.id || "") === (e.id || "")))
1143
- continue;
1144
- i.resource.width && i.resource.height && (i.resource.width, i.resource.height);
1145
- let l = i.resource.type === "SpecificResource" ? le(i.resource) : null;
1146
- if (i.selector) {
1147
- const p = le({
1148
- type: "SpecificResource",
1149
- source: i.resource,
1150
- selector: i.selector
1151
- });
1152
- p && (l = p);
1153
- }
1154
- const f = l && l.selector && (l.selector.type === "BoxSelector" || l.selector.type === "TemporalBoxSelector") ? {
1155
- type: "BoxSelector",
1156
- spatial: {
1157
- x: l.selector.spatial.x,
1158
- y: l.selector.spatial.y,
1159
- width: l.selector.spatial.width,
1160
- height: l.selector.spatial.height
1161
- }
1162
- } : void 0;
1163
- a && !a.id && (a.id = a["@id"]);
1164
- const m = {
1165
- id: o.id,
1166
- type: "Image",
1167
- annotationId: i.annotationId,
1168
- width: Number(c || f ? o.width : e.width),
1169
- height: Number(c || f ? o.height : e.height),
1170
- service: a,
1171
- sizes: a && a.sizes ? a.sizes : o.width && o.height ? [{ width: o.width, height: o.height }] : [],
1172
- target: c && c.type !== "PointSelector" ? c : s,
1173
- selector: f
1174
- };
1175
- r.push(m);
1176
- }
1177
- return {
1178
- type: "images",
1179
- image: r[0],
1180
- images: r,
1181
- choice: t.choice
1182
- };
1183
- }
1184
- function $e(e, t = {}, n) {
1185
- const r = e.language || n || "none";
1186
- switch (e.type) {
1187
- case "TextualBody": {
1188
- typeof e.value < "u" && (t[r] = e.value);
1189
- break;
1190
- }
1191
- case "List":
1192
- case "Composite":
1193
- case "Choice":
1194
- e.items && e.items.forEach((i) => $e(i, t, r));
1195
- }
1196
- return t;
1197
- }
1198
- function An(e, t) {
1199
- const n = [];
1200
- return t.items.forEach((r) => {
1201
- if (r.resource) {
1202
- const [i] = Be(e, r.target);
1203
- n.push({ annotationId: r.annotationId, text: $e(r.resource), target: i });
1204
- }
1205
- }), {
1206
- type: "textual-content",
1207
- items: n
1208
- };
1209
- }
1210
- const Tn = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\/)|(?:(?:watch)?\?vi?=|&vi?=))([^#&?]*).*/;
1211
- function Rn(e, t) {
1212
- var s;
1213
- const n = t.items.filter((c) => c.type === "video");
1214
- let r = !1;
1215
- if (e.duration || (r = !0), n.length > 1)
1216
- return I("Only one video source supported");
1217
- const i = (s = n[0]) == null ? void 0 : s.resource, o = !!(i.service || []).find(
1218
- (c) => (c.profile || "").includes("youtube.com")
1219
- );
1220
- if (!o && r)
1221
- return I("Video does not have duration");
1222
- if (!i)
1223
- return I("Unknown video");
1224
- if ((!i.format || i.format === "text/html") && !o)
1225
- return I("Video does not have format");
1226
- const a = {
1227
- annotationId: t.items[0].annotationId,
1228
- duration: e.duration,
1229
- url: i.id,
1230
- type: "Video",
1231
- items: [],
1232
- target: {
1233
- type: "TemporalSelector",
1234
- temporal: {
1235
- startTime: 0,
1236
- endTime: e.duration
1237
- }
1238
- },
1239
- format: i.format,
1240
- selector: {
1241
- type: "TemporalSelector",
1242
- temporal: {
1243
- startTime: 0,
1244
- endTime: e.duration
1245
- }
1246
- }
1247
- };
1248
- if (o) {
1249
- a.type = "VideoYouTube";
1250
- const c = i.id.match(Tn);
1251
- if (!c[1])
1252
- return I("Video is not known youtube video");
1253
- a.youTubeId = c[1];
1254
- }
1255
- return {
1256
- type: "media",
1257
- media: a,
1258
- annotations: {
1259
- pages: []
1260
- }
1261
- };
1262
- }
1263
- function Vn({ canvas: e, paintables: t, supports: n, loadImageService: r }) {
1264
- if (!e)
1265
- return console.log("No canvas"), ce;
1266
- if (t.types.length === 0)
1267
- return n.indexOf("empty") !== -1 ? dn(e.width, e.height) : (console.log("No paintables"), ce);
1268
- if (t.types.length !== 1)
1269
- if (t.types.length === 2 && t.types.indexOf("text") !== -1)
1270
- t.types = t.types.filter((o) => o !== "text");
1271
- else
1272
- return n.indexOf("complex-timeline") === -1 ? I("Complex timeline not supported") : I("ComplexTimelineStrategy not yet supported");
1273
- const i = t.types[0];
1274
- return i === "image" ? n.indexOf("images") === -1 ? I("Image not supported") : Mn(e, t, r) : i === "Model" || i === "model" ? n.indexOf("3d-model") === -1 ? I("3D not supported") : En(e, t) : i === "textualbody" ? n.indexOf("textual-content") === -1 ? I("Textual content not supported") : An(e, t) : i === "sound" || i === "audio" ? n.indexOf("media") === -1 ? I("Media not supported") : In(e, t) : i === "video" ? n.indexOf("media") === -1 ? I("Media not supported") : Rn(e, t) : ce;
1275
- }
1276
- function On(e) {
1277
- const t = K(), n = j(), r = O(), [i, o] = xn(), { enabledPageIds: a } = vn((e == null ? void 0 : e.annotationPageManagerId) || (t == null ? void 0 : t.id) || (n == null ? void 0 : n.id), {
1278
- all: !1
1279
- }), s = pn(a, "AnnotationPage"), c = (e == null ? void 0 : e.strategies) || [
1280
- "empty",
1281
- "images",
1282
- "media",
1283
- "textual-content",
1284
- "complex-timeline"
1285
- ], [d, l] = bn(e, [o]), f = w(() => Vn({ canvas: n, paintables: d, supports: c, loadImageService: i }), [n, d, r, l.makeChoice]);
1286
- return w(() => f.type === "unknown" ? [f, ln] : [
1287
- {
1288
- ...f,
1289
- annotations: { pages: s }
1290
- },
1291
- l
1292
- ], [f, s]);
1293
- }
1294
- const Ln = (e, t = []) => {
1295
- const n = O();
1296
- N(() => {
1297
- e(n);
1298
- }, [n, ...t]);
1299
- };
1300
- function kn(e, t, { canvasId: n, manifestId: r } = {}) {
1301
- const i = O(), o = je(), a = w(() => vt(i, { imageServiceLoader: o }), [i, o]), [s, c] = L(), d = K(r ? { id: r } : void 0), l = j(n ? { id: n } : void 0), f = l || d, m = _(!1);
1302
- if (N(() => (m.current = !1, () => {
1303
- m.current = !0;
1304
- }), []), !f)
1305
- throw new Error("Must be called under a manifest or canvas context.");
1306
- return Ln(
1307
- (p) => {
1308
- a.getBestThumbnailAtSize(f, e, t).then((g) => {
1309
- g.best && !m.current && c(g.best);
1310
- });
1311
- },
1312
- [f]
1313
- ), s;
1314
- }
1315
- function Nn(e) {
1316
- return { isMuted: !1, playRequested: !1, isPlaying: !1, isFinished: !1, volume: 100, duration: e };
1317
- }
1318
- function Fn(e, t) {
1319
- switch (t.type) {
1320
- case "FINISHED":
1321
- return { ...e, isFinished: !0, isPlaying: !1, playRequested: !1 };
1322
- case "PLAY_PAUSE":
1323
- return { ...e, isFinished: !1, isPlaying: !e.isPlaying };
1324
- case "PLAY_REQUESTED":
1325
- return { ...e, isFinished: !1, playRequested: !0 };
1326
- case "PAUSE":
1327
- return { ...e, isPlaying: !1 };
1328
- case "PLAY":
1329
- return { ...e, isFinished: !1, playRequested: !1, isPlaying: !0 };
1330
- case "MUTE":
1331
- return { ...e, isMuted: !0 };
1332
- case "SET_VOLUME":
1333
- return { ...e, volume: t.volume, isMuted: t.volume === 0 };
1334
- case "TOGGLE_MUTE":
1335
- return { ...e, isMuted: !e.isMuted };
1336
- case "UNMUTE":
1337
- return { ...e, isMuted: !1 };
1338
- }
1339
- return e;
1340
- }
1341
- function Un(e) {
1342
- const t = Math.round(e);
1343
- return `${Math.floor(t / 60)}:${`${t % 60}`.padStart(2, "0")}`;
1344
- }
1345
- function pe(e) {
1346
- const [t, n] = ot(Fn, Nn(e.duration)), r = _(null), i = _(null), o = _(null), a = _(!1), s = b(() => {
1347
- i.current && r.current && (i.current.innerHTML = Un(r.current.currentTime), o.current && (o.current.style.width = `${r.current.currentTime / e.duration * 100}%`), a.current !== r.current.muted && (a.current = r.current.muted, n(r.current.muted ? { type: "MUTE" } : { type: "UNMUTE" })));
1348
- }, [e.duration]), c = b(() => {
1349
- r.current && (n({ type: "PLAY_REQUESTED" }), r.current.play().then(() => {
1350
- n({ type: "PLAY" });
1351
- }), s());
1352
- }, [s]), d = b(() => {
1353
- r.current && (r.current.duration > 0 && r.current.paused ? c() : l());
1354
- }, [s]), l = b(() => {
1355
- r.current && (r.current.pause(), n({ type: "PAUSE" }), s());
1356
- }, [s]), f = b(() => {
1357
- r.current && (r.current.muted = !r.current.muted, n(r.current.muted ? { type: "MUTE" } : { type: "UNMUTE" }));
1358
- }, []), m = b(() => {
1359
- r.current && (r.current.muted = !0, n({ type: "MUTE" }));
1360
- }, []), p = b(() => {
1361
- r.current && (r.current.muted = !1, n({ type: "UNMUTE" }));
1362
- }, []), g = b((y) => {
1363
- r.current && (r.current.muted = !1, r.current.volume = y / 100, n({ type: "SET_VOLUME", volume: y }));
1364
- }, []), x = b((y) => {
1365
- r.current && (r.current.currentTime = Math.max(0, Math.min(y * e.duration, e.duration)), s());
1366
- }, []), v = b((y) => {
1367
- r.current && (r.current.currentTime = Math.max(0, Math.min(y, e.duration)), s());
1368
- }, []);
1369
- return N(() => {
1370
- const y = setInterval(() => {
1371
- s();
1372
- }, 350);
1373
- return () => clearInterval(y);
1374
- }, [s, e.duration]), N(() => {
1375
- const y = () => {
1376
- n({ type: "FINISHED" });
1377
- }, C = r.current;
1378
- return C == null || C.addEventListener("ended", y), () => C == null ? void 0 : C.removeEventListener("ended", y);
1379
- }, []), [
1380
- { element: r, currentTime: i, progress: o },
1381
- t,
1382
- {
1383
- play: c,
1384
- pause: l,
1385
- playPause: d,
1386
- mute: m,
1387
- unmute: p,
1388
- toggleMute: f,
1389
- setVolume: g,
1390
- setDurationPercent: x,
1391
- setTime: v
1392
- }
1393
- ];
1394
- }
1395
- const Dn = F(null), _n = F(null), qn = F(null);
1396
- function Ye({
1397
- actions: e,
1398
- state: t,
1399
- children: n,
1400
- currentTime: r,
1401
- progress: i,
1402
- element: o
1403
- }) {
1404
- return /* @__PURE__ */ u(qn.Provider, { value: { currentTime: r, progress: i, element: o }, children: /* @__PURE__ */ u(_n.Provider, { value: e, children: /* @__PURE__ */ u(Dn.Provider, { value: t, children: n }) }) });
1405
- }
1406
- function ze({ media: e, children: t }) {
1407
- const [{ element: n, currentTime: r, progress: i }, o, a] = pe({ duration: e.duration });
1408
- return /* @__PURE__ */ M(
1409
- Ye,
1410
- {
1411
- state: o,
1412
- actions: a,
1413
- currentTime: r,
1414
- progress: i,
1415
- element: n,
1416
- children: [
1417
- /* @__PURE__ */ u("audio", { ref: n, src: e.url }),
1418
- t
1419
- ]
1420
- }
1421
- );
1422
- }
1423
- function Ke({
1424
- media: e,
1425
- mediaControlsDeps: t,
1426
- children: n
1427
- }) {
1428
- return Y("portal", "audio", ze, { media: e, children: n }, [e, ...t || []]), null;
1429
- }
1430
- function We({
1431
- element: e,
1432
- media: t,
1433
- playPause: n
1434
- }) {
1435
- return /* @__PURE__ */ M("div", { className: "video-container", part: "video-container", onClick: n, children: [
1436
- /* @__PURE__ */ u("style", { children: `
1437
- .video-container {
1438
- position: absolute;
1439
- top: 0;
1440
- bottom: 0;
1441
- left: 0;
1442
- right: 0;
1443
- background: #000;
1444
- z-index: 13;
1445
- display: flex;
1446
- justify-content: center;
1447
- pointer-events: visible;
1448
- }
1449
- ` }),
1450
- /* @__PURE__ */ u("video", { ref: e, src: t.url, style: { width: "100%", objectFit: "contain" } })
1451
- ] });
1452
- }
1453
- function Ge({
1454
- media: e,
1455
- mediaControlsDeps: t,
1456
- children: n
1457
- }) {
1458
- const [{ element: r, currentTime: i, progress: o }, a, s] = pe({ duration: e.duration });
1459
- return Y("overlay", "video-element", We, {
1460
- element: r,
1461
- media: e,
1462
- playPause: s.playPause
1463
- }), Y(
1464
- "portal",
1465
- "custom-controls",
1466
- Ye,
1467
- {
1468
- state: a,
1469
- actions: s,
1470
- currentTime: i,
1471
- progress: o,
1472
- element: r,
1473
- children: n
1474
- },
1475
- [i, a, e, ...t || []]
1476
- ), null;
1477
- }
1478
- function Qe({ model: e }) {
1479
- return /* @__PURE__ */ M($, { children: [
1480
- /* @__PURE__ */ u("style", { children: `
1481
- .model-container {
1482
- position: absolute;
1483
- top: 0;
1484
- bottom: 0;
1485
- left: 0;
1486
- right: 0;
1487
- background: #000;
1488
- z-index: 13;
1489
- display: flex;
1490
- justify-content: center;
1491
- pointer-events: visible;
1492
- }
1493
- ` }),
1494
- /* @__PURE__ */ u("div", { className: "model-container", children: /* @__PURE__ */ u(
1495
- "model-viewer",
1496
- {
1497
- "interaction-prompt": "none",
1498
- style: { width: "100%", height: "100%" },
1499
- "camera-controls": "",
1500
- "ar-status": "not-presenting",
1501
- src: e.id
1502
- }
1503
- ) })
1504
- ] });
1505
- }
1506
- function Je({ model: e, name: t }) {
1507
- return Y("overlay", `model-${t}`, Qe, { model: e }, [e]), null;
1508
- }
1509
- function Ze({ style: e }) {
1510
- const t = j();
1511
- return !t || !t.height || !t.width ? null : /* @__PURE__ */ u(
1512
- "box",
1513
- {
1514
- interactive: !1,
1515
- target: { x: 0, y: 0, width: Number(t.width), height: Number(t.height) },
1516
- style: e
1517
- }
1518
- );
1519
- }
1520
- const Bn = B.createContext("en");
1521
- function Xe() {
1522
- return B.useContext(Bn);
1523
- }
1524
- function Ee(e) {
1525
- return e.indexOf("-") !== -1 ? e.slice(0, e.indexOf("-")) : e;
1526
- }
1527
- function jn({ as: e, language: t, children: n, viewingDirection: r, ...i }) {
1528
- const o = Xe();
1529
- return w(() => Ee(o) === Ee(t), [o, t]) ? e ? /* @__PURE__ */ u(e, { ...i, children: n }) : /* @__PURE__ */ u("span", { ...i, children: n }) : e ? /* @__PURE__ */ u(e, { ...i, lang: t, dir: r, children: n }) : /* @__PURE__ */ u("span", { ...i, lang: t, dir: r, children: n });
1530
- }
1531
- function Hn(e, t, n) {
1532
- if (t.length === 0)
1533
- return;
1534
- if (t.length === 1)
1535
- return t[0];
1536
- if (t.indexOf(e) !== -1)
1537
- return e;
1538
- const r = e.indexOf("-") !== -1 ? e.slice(0, e.indexOf("-")) : null;
1539
- if (r && t.indexOf(r) !== -1)
1540
- return r;
1541
- for (const i of n)
1542
- if (t.indexOf(i) !== -1)
1543
- return i;
1544
- return t.indexOf("none") !== -1 ? "none" : t.indexOf("@none") !== -1 ? "@none" : t[0];
1545
- }
1546
- const $n = (e, t = []) => {
1547
- const n = Xe();
1548
- return w(() => {
1549
- const r = e();
1550
- return Hn(n, r, []);
1551
- }, [n, ...t]);
1552
- };
1553
- function Yn(e, t, n = `
1554
- `) {
1555
- const r = $n(() => Object.keys(e || {}), [e]);
1556
- return [
1557
- w(() => {
1558
- if (!e)
1559
- return t || "";
1560
- if (typeof e == "string")
1561
- return e;
1562
- const i = r ? e[r] : void 0;
1563
- return i ? typeof i == "string" ? i : i.join(n) : "";
1564
- }, [r, t, e]),
1565
- r
1566
- ];
1567
- }
1568
- function zn({
1569
- as: e,
1570
- defaultText: t,
1571
- enableDangerouslySetInnerHTML: n,
1572
- children: r,
1573
- separator: i,
1574
- ...o
1575
- }) {
1576
- const [a, s] = Yn(r, t, i);
1577
- return s ? /* @__PURE__ */ u(
1578
- jn,
1579
- {
1580
- ...o,
1581
- as: e,
1582
- language: s,
1583
- title: n ? void 0 : a,
1584
- dangerouslySetInnerHTML: n ? {
1585
- __html: a
1586
- } : void 0,
1587
- children: n ? void 0 : a
1588
- }
1589
- ) : e ? /* @__PURE__ */ u(e, { ...o, children: a }) : /* @__PURE__ */ u(
1590
- "span",
1591
- {
1592
- ...o,
1593
- title: n ? void 0 : a,
1594
- dangerouslySetInnerHTML: n ? {
1595
- __html: a
1596
- } : void 0,
1597
- children: n ? void 0 : a
1598
- }
1599
- );
1600
- }
1601
- function Kn({
1602
- element: e,
1603
- media: t,
1604
- playPause: n
1605
- }) {
1606
- const r = _(null);
1607
- return t.youTubeId ? /* @__PURE__ */ M("div", { className: "video-container", part: "video-container", onClick: n, children: [
1608
- /* @__PURE__ */ u("style", { children: `
1609
- .video-container {
1610
- position: absolute;
1611
- top: 0;
1612
- bottom: 0;
1613
- left: 0;
1614
- right: 0;
1615
- background: #000;
1616
- z-index: 13;
1617
- display: flex;
1618
- justify-content: center;
1619
- pointer-events: visible;
1620
- }
1621
- .video-yt {
1622
- border: none;
1623
- width: 100%;
1624
- object-fit: contain;
1625
- }
1626
- ` }),
1627
- /* @__PURE__ */ u(
1628
- "iframe",
1629
- {
1630
- className: "video-yt",
1631
- ref: r,
1632
- src: `https://www.youtube.com/embed/${t.youTubeId}?enablejsapi=1&origin=${window.location.host}`,
1633
- referrerPolicy: "no-referrer",
1634
- sandbox: "allow-scripts allow-same-origin allow-presentation"
1635
- }
1636
- )
1637
- ] }) : null;
1638
- }
1639
- function Wn({
1640
- media: e,
1641
- mediaControlsDeps: t,
1642
- children: n
1643
- }) {
1644
- const [{ element: r, currentTime: i, progress: o }, a, s] = pe({ duration: e.duration });
1645
- return Y("overlay", "video-element", Kn, {
1646
- element: r,
1647
- media: e,
1648
- playPause: s.playPause
1649
- }), null;
1650
- }
1651
- function et({
1652
- x: e,
1653
- y: t,
1654
- onChoiceChange: n,
1655
- registerActions: r,
1656
- defaultChoices: i,
1657
- isStatic: o,
1658
- renderViewerControls: a,
1659
- renderMediaControls: s,
1660
- viewControlsDeps: c,
1661
- mediaControlsDeps: d,
1662
- strategies: l,
1663
- throwOnUnknown: f,
1664
- backgroundStyle: m,
1665
- alwaysShowBackground: p,
1666
- keepCanvasScale: g = !1,
1667
- enableSizes: x = !1,
1668
- enableYouTube: v = !0,
1669
- onClickPaintingAnnotation: y,
1670
- children: C
1671
- }) {
1672
- const S = j(), W = Ue(S, ["deep-zoom"]), [Z] = tn(), E = on(), A = O(), k = w(() => Te(A), [A]), [h, D] = On({
1673
- strategies: l || ["images"],
1674
- defaultChoices: i == null ? void 0 : i.map(({ id: P }) => P)
1675
- }), ye = h.type === "images" ? h.choice : void 0, tt = w(() => g ? 1 : Math.max(
1676
- 1,
1677
- ...h.type === "images" ? h.images.map((P) => {
1678
- var H;
1679
- return (P.width || 0) / ((H = P.target) == null ? void 0 : H.spatial.width);
1680
- }) : []
1681
- ), [g, h]);
1682
- an(tt), N(() => {
1683
- r && r(D);
1684
- }, [h.annotations]), N(() => {
1685
- if (i)
1686
- for (const P of i)
1687
- typeof P.opacity < "u" && k.applyStyles({ id: P.id }, "atlas", {
1688
- opacity: P.opacity
1689
- });
1690
- }, [i]), Ie(() => {
1691
- n && n(ye);
1692
- }, [ye]), Y(
1693
- E && (h.type === "images" || h.type === "empty" || h.type === "textual-content" && a) ? "overlay" : "none",
1694
- `canvas-portal-controls-${S == null ? void 0 : S.id}`,
1695
- ve.Provider,
1696
- a ? {
1697
- value: E || null,
1698
- children: a(h)
1699
- } : {},
1700
- [S, E, h, ...c || []]
1701
- );
1702
- const q = kn({ maxWidth: 256, maxHeight: 256 });
1703
- if (!S)
1704
- return null;
1705
- const xe = S.accompanyingCanvas, G = q && q.type === "fixed" ? /* @__PURE__ */ u("world-object", { height: S.height, width: S.width, x: e, y: t, children: /* @__PURE__ */ u(
1706
- "world-image",
1707
- {
1708
- uri: q.id,
1709
- target: { x: 0, y: 0, width: S.width, height: S.height },
1710
- display: q.width && q.height ? {
1711
- width: q.width,
1712
- height: q.height
1713
- } : void 0,
1714
- crop: void 0
1715
- }
1716
- ) }) : null;
1717
- if (h.type === "unknown") {
1718
- if (G)
1719
- return G;
1720
- if (f)
1721
- throw new Error(h.reason || "Unknown image strategy");
1722
- return null;
1723
- }
1724
- const we = /* @__PURE__ */ M(te, { children: [
1725
- Z ? /* @__PURE__ */ u(de, { page: Z }) : null,
1726
- h.annotations && h.annotations.pages ? h.annotations.pages.map((P) => /* @__PURE__ */ u(de, { page: P }, P.id)) : null,
1727
- C
1728
- ] }), nt = h.type === "images" ? h.images.length : 0;
1729
- return /* @__PURE__ */ M($, { children: [
1730
- /* @__PURE__ */ M(
1731
- "world-object",
1732
- {
1733
- height: S.height,
1734
- width: S.width,
1735
- x: e,
1736
- y: t,
1737
- ...W,
1738
- children: [
1739
- h.type === "empty" || p ? /* @__PURE__ */ u(Ze, { style: m }) : null,
1740
- h.type === "textual-content" ? h.items.map((P, H) => {
1741
- var Q;
1742
- return /* @__PURE__ */ M($, { children: [
1743
- /* @__PURE__ */ u(
1744
- ft,
1745
- {
1746
- onClick: y ? (Se) => {
1747
- Se.stopPropagation(), y(P.annotationId, P, Se);
1748
- } : void 0,
1749
- target: ((Q = P.target) == null ? void 0 : Q.spatial) || void 0,
1750
- children: /* @__PURE__ */ u("div", { "data-textual-content": !0, children: /* @__PURE__ */ u(zn, { enableDangerouslySetInnerHTML: !0, children: P.text }) })
1751
- },
1752
- H
1753
- ),
1754
- we
1755
- ] });
1756
- }) : null,
1757
- h.type === "images" ? /* @__PURE__ */ M($, { children: [
1758
- h.images.map((P, H) => /* @__PURE__ */ u(
1759
- qe,
1760
- {
1761
- isStatic: o,
1762
- image: P,
1763
- id: P.id,
1764
- thumbnail: H === 0 ? q : void 0,
1765
- selector: P.selector,
1766
- enableSizes: x,
1767
- onClick: y ? (Q) => {
1768
- Q.stopPropagation(), y(P.annotationId, P, Q);
1769
- } : void 0
1770
- },
1771
- P.id + H
1772
- )),
1773
- we
1774
- ] }) : null,
1775
- h.type === "3d-model" ? /* @__PURE__ */ u(Je, { model: h.model }) : null,
1776
- h.type === "media" ? /* @__PURE__ */ u($, { children: h.media.type === "Sound" ? /* @__PURE__ */ M(Ke, { media: h.media, mediaControlsDeps: d, children: [
1777
- G,
1778
- s ? s(h) : null
1779
- ] }) : h.media.type === "Video" ? /* @__PURE__ */ M(Ge, { media: h.media, mediaControlsDeps: d, children: [
1780
- G,
1781
- s ? s(h) : null
1782
- ] }) : h.media.type === "VideoYouTube" && v ? /* @__PURE__ */ M(Wn, { media: h.media, mediaControlsDeps: d, children: [
1783
- G,
1784
- s ? s(h) : null
1785
- ] }) : null }) : null
1786
- ]
1787
- },
1788
- `${S.id}/${h.type}/${nt}`
1789
- ),
1790
- h.type === "media" && h.media.type === "Sound" && xe ? /* @__PURE__ */ u(me, { canvas: xe.id, children: /* @__PURE__ */ u(et, { renderViewerControls: a }) }) : null
1791
- ] });
1792
- }
1793
- const Gn = Me(function(t, n) {
1794
- const r = K(), i = Re(), o = Rt(), { ViewerControls: a, MediaControls: s } = t.components || {};
1795
- if (at(n, () => o, [o]), !r)
1796
- return /* @__PURE__ */ u("div", {});
1797
- let c = 0;
1798
- return /* @__PURE__ */ M($, { children: [
1799
- t.header,
1800
- /* @__PURE__ */ u(
1801
- V.Viewer,
1802
- {
1803
- height: t.height,
1804
- mode: t.mode,
1805
- children: i.map((d, l) => {
1806
- const f = c;
1807
- return c += d.width + (t.spacing || 0), /* @__PURE__ */ u(me, { canvas: d.id, children: /* @__PURE__ */ u(
1808
- V.RenderCanvas,
1809
- {
1810
- strategies: ["3d-model", "media", "images", "empty", "textual-content"],
1811
- renderViewerControls: l === 0 && a ? () => /* @__PURE__ */ u(a, {}) : void 0,
1812
- renderMediaControls: l === 0 && s ? () => /* @__PURE__ */ u(s, {}) : void 0,
1813
- x: f,
1814
- ...t.canvasProps || {},
1815
- children: t.annotations
1816
- },
1817
- d.id
1818
- ) }, d.id);
1819
- })
1820
- },
1821
- t.reuseAtlas ? "" : o.currentSequenceIndex
1822
- ),
1823
- t.children
1824
- ] });
1825
- }), V = Me(function({ children: t, height: n, annotations: r, canvasProps: i, spacing: o, header: a, components: s, mode: c, reuseAtlas: d, ...l }, f) {
1826
- const m = ge();
1827
- return /* @__PURE__ */ u(he, { vault: m, children: /* @__PURE__ */ u(Tt, { ...l, children: /* @__PURE__ */ u(
1828
- Gn,
1829
- {
1830
- ref: f,
1831
- height: n,
1832
- components: s,
1833
- spacing: o,
1834
- canvasProps: i,
1835
- annotations: r,
1836
- header: a,
1837
- mode: c,
1838
- reuseAtlas: d,
1839
- children: t
1840
- }
1841
- ) }) });
1842
- });
1843
- V.RenderImage = qe;
1844
- V.RenderCanvas = et;
1845
- V.RenderAnnotationPage = de;
1846
- V.RenderAnnotation = _e;
1847
- V.Viewer = sn;
1848
- V.CanvasBackground = Ze;
1849
- V.Audio = Ke;
1850
- V.Video = Ge;
1851
- V.Model = Je;
1852
- V.AudioHTML = ze;
1853
- V.VideoHTML = We;
1854
- V.ModelHTML = Qe;
1855
- export {
1856
- V as CanvasPanel
1857
- };
1858
- //# sourceMappingURL=canvas-panel.mjs.map