@knaw-huc/osd-iiif-viewer 0.2.5 → 0.3.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.
- package/dist/Viewer.d.ts +1 -1
- package/dist/ViewerProvider.d.ts +1 -1
- package/dist/index.js +19 -1848
- package/package.json +16 -6
package/dist/index.js
CHANGED
|
@@ -2,1778 +2,11 @@ import { jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Viewer as Viewer$1 } from "openseadragon";
|
|
3
3
|
import { createContext, useContext, useMemo, useState, useRef, useEffect, useCallback } from "react";
|
|
4
4
|
import { createStore } from "zustand/vanilla";
|
|
5
|
+
import { Vault } from "@iiif/helpers/vault";
|
|
6
|
+
import { createPaintingAnnotationsHelper } from "@iiif/helpers/painting-annotations";
|
|
7
|
+
import { getImageServices, getId } from "@iiif/parser/image-3";
|
|
5
8
|
import { useStore } from "zustand";
|
|
6
9
|
import { createPortal } from "react-dom";
|
|
7
|
-
function e$7(t3) {
|
|
8
|
-
"@babel/helpers - typeof";
|
|
9
|
-
return e$7 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e2) {
|
|
10
|
-
return typeof e2;
|
|
11
|
-
} : function(e2) {
|
|
12
|
-
return e2 && typeof Symbol == "function" && e2.constructor === Symbol && e2 !== Symbol.prototype ? "symbol" : typeof e2;
|
|
13
|
-
}, e$7(t3);
|
|
14
|
-
}
|
|
15
|
-
function t$7(t3, n2) {
|
|
16
|
-
if (e$7(t3) != "object" || !t3) return t3;
|
|
17
|
-
var r2 = t3[Symbol.toPrimitive];
|
|
18
|
-
if (r2 !== void 0) {
|
|
19
|
-
var i3 = r2.call(t3, n2);
|
|
20
|
-
if (e$7(i3) != "object") return i3;
|
|
21
|
-
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
22
|
-
}
|
|
23
|
-
return (n2 === "string" ? String : Number)(t3);
|
|
24
|
-
}
|
|
25
|
-
function n$7(n2) {
|
|
26
|
-
var r2 = t$7(n2, "string");
|
|
27
|
-
return e$7(r2) == "symbol" ? r2 : r2 + "";
|
|
28
|
-
}
|
|
29
|
-
function r$6(e2, t3, r2) {
|
|
30
|
-
return (t3 = n$7(t3)) in e2 ? Object.defineProperty(e2, t3, { value: r2, enumerable: !0, configurable: !0, writable: !0 }) : e2[t3] = r2, e2;
|
|
31
|
-
}
|
|
32
|
-
const __vite_import_meta_env__$1 = {}, e$6 = (e2) => {
|
|
33
|
-
let t22, n2 = /* @__PURE__ */ new Set(), r2 = (e3, r22) => {
|
|
34
|
-
let i22 = typeof e3 == "function" ? e3(t22) : e3;
|
|
35
|
-
if (!Object.is(i22, t22)) {
|
|
36
|
-
let e4 = t22;
|
|
37
|
-
t22 = r22 ?? (typeof i22 != "object" || !i22) ? i22 : Object.assign({}, t22, i22), n2.forEach((n22) => n22(t22, e4));
|
|
38
|
-
}
|
|
39
|
-
}, i3 = () => t22, a2 = { setState: r2, getState: i3, getInitialState: () => o2, subscribe: (e3) => (n2.add(e3), () => n2.delete(e3)), destroy: () => {
|
|
40
|
-
(__vite_import_meta_env__$1 ? "production" : void 0) !== "production" && console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."), n2.clear();
|
|
41
|
-
} }, o2 = t22 = e2(r2, i3, a2);
|
|
42
|
-
return a2;
|
|
43
|
-
}, t$6 = (t22) => t22 ? e$6(t22) : e$6;
|
|
44
|
-
function e$5(e2) {
|
|
45
|
-
return { all: e2 = e2 || /* @__PURE__ */ new Map(), on: function(t3, n2) {
|
|
46
|
-
var r2 = e2.get(t3);
|
|
47
|
-
r2 ? r2.push(n2) : e2.set(t3, [n2]);
|
|
48
|
-
}, off: function(t3, n2) {
|
|
49
|
-
var r2 = e2.get(t3);
|
|
50
|
-
r2 && (n2 ? r2.splice(r2.indexOf(n2) >>> 0, 1) : e2.set(t3, []));
|
|
51
|
-
}, emit: function(t3, n2) {
|
|
52
|
-
var r2 = e2.get(t3);
|
|
53
|
-
r2 && r2.slice().map(function(e3) {
|
|
54
|
-
e3(n2);
|
|
55
|
-
}), (r2 = e2.get("*")) && r2.slice().map(function(e3) {
|
|
56
|
-
e3(t3, n2);
|
|
57
|
-
});
|
|
58
|
-
} };
|
|
59
|
-
}
|
|
60
|
-
function e$4(t3) {
|
|
61
|
-
"@babel/helpers - typeof";
|
|
62
|
-
return e$4 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e2) {
|
|
63
|
-
return typeof e2;
|
|
64
|
-
} : function(e2) {
|
|
65
|
-
return e2 && typeof Symbol == "function" && e2.constructor === Symbol && e2 !== Symbol.prototype ? "symbol" : typeof e2;
|
|
66
|
-
}, e$4(t3);
|
|
67
|
-
}
|
|
68
|
-
function t$5(t3, n2) {
|
|
69
|
-
if (e$4(t3) != "object" || !t3) return t3;
|
|
70
|
-
var r2 = t3[Symbol.toPrimitive];
|
|
71
|
-
if (r2 !== void 0) {
|
|
72
|
-
var i3 = r2.call(t3, n2);
|
|
73
|
-
if (e$4(i3) != "object") return i3;
|
|
74
|
-
throw TypeError("@@toPrimitive must return a primitive value.");
|
|
75
|
-
}
|
|
76
|
-
return (n2 === "string" ? String : Number)(t3);
|
|
77
|
-
}
|
|
78
|
-
function n$6(n2) {
|
|
79
|
-
var r2 = t$5(n2, "string");
|
|
80
|
-
return e$4(r2) == "symbol" ? r2 : r2 + "";
|
|
81
|
-
}
|
|
82
|
-
function r$5(e2, t3, r2) {
|
|
83
|
-
return (t3 = n$6(t3)) in e2 ? Object.defineProperty(e2, t3, { value: r2, enumerable: !0, configurable: !0, writable: !0 }) : e2[t3] = r2, e2;
|
|
84
|
-
}
|
|
85
|
-
function i$5(e2) {
|
|
86
|
-
return Array.isArray(e2) ? e2 : e2 ? [e2] : [];
|
|
87
|
-
}
|
|
88
|
-
function a$5(e2) {
|
|
89
|
-
for (let t3 in e2) (e2[t3] === void 0 || e2[t3] === null) && delete e2[t3];
|
|
90
|
-
return e2;
|
|
91
|
-
}
|
|
92
|
-
function n$5(e2) {
|
|
93
|
-
return typeof e2 == "string" ? !1 : e2 && !e2.type && "source" in e2 ? (e2.type = "SpecificResource", !0) : !!e2 && e2.type === "SpecificResource";
|
|
94
|
-
}
|
|
95
|
-
function r$4(...e2) {
|
|
96
|
-
return (t3) => e2.reduce((e3, t4) => t4(e3), t3);
|
|
97
|
-
}
|
|
98
|
-
const i$4 = ["Collection", "Manifest", "Canvas", "AnnotationPage", "AnnotationCollection", "Annotation", "ContentResource", "Range", "Service", "Selector", "Agent"];
|
|
99
|
-
function a$4(e2, t3) {
|
|
100
|
-
if (e2 == null) throw Error("Null or undefined is not a valid entity.");
|
|
101
|
-
if (Array.isArray(e2)) throw Error("Array is not a valid entity");
|
|
102
|
-
if (typeof e2 != "object") {
|
|
103
|
-
if (t3) return t3;
|
|
104
|
-
throw Error(`${typeof e2} is not a valid entity`);
|
|
105
|
-
}
|
|
106
|
-
if (typeof e2.type == "string") {
|
|
107
|
-
let t4 = i$4.indexOf(e2.type);
|
|
108
|
-
if (t4 !== -1) return i$4[t4];
|
|
109
|
-
}
|
|
110
|
-
if (e2.profile) return "Service";
|
|
111
|
-
throw Error("Resource type is not known");
|
|
112
|
-
}
|
|
113
|
-
var o$4 = class i {
|
|
114
|
-
constructor(t3, n2 = {}) {
|
|
115
|
-
r$5(this, "traversals", void 0), r$5(this, "options", void 0), r$5(this, "_traverseManifest", r$4(this.traverseManifestItems.bind(this), this.traverseNavPlace.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseManifestStructures.bind(this), this.traverseInlineAnnotationPages.bind(this))), r$5(this, "_traverseCanvas", r$4(this.traverseCanvasItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseInlineAnnotationPages.bind(this))), r$5(this, "_traverseAnnotationPage", r$4(this.traverseAnnotationPageItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this))), r$5(this, "_traverseRange", r$4(this.traverseRangeRanges.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this))), this.traversals = { collection: [], manifest: [], canvas: [], annotationCollection: [], annotationPage: [], annotation: [], contentResource: [], choice: [], range: [], service: [], agent: [], specificResource: [], geoJson: [], ...t3 }, this.options = { allowUndefinedReturn: !1, ...n2 };
|
|
116
|
-
}
|
|
117
|
-
static all(e2) {
|
|
118
|
-
return new i({ collection: [e2], manifest: [e2], canvas: [e2], annotationCollection: [e2], annotationPage: [e2], annotation: [e2], contentResource: [e2], choice: [e2], range: [e2], service: [e2], geoJson: [e2], specificResource: [e2], agent: [e2] });
|
|
119
|
-
}
|
|
120
|
-
traverseDescriptive(e2) {
|
|
121
|
-
return e2.thumbnail &&= i$5(e2.thumbnail).map((t3) => this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2.provider &&= e2.provider.map((t3) => this.traverseAgent(t3, e2)), e2;
|
|
122
|
-
}
|
|
123
|
-
traverseLinking(e2) {
|
|
124
|
-
return e2.seeAlso &&= i$5(e2.seeAlso).map((t3) => this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2.service &&= i$5(e2.service).map((e3) => this.traverseService(e3)), e2.services &&= i$5(e2.services).map((t3) => this.traverseService(t3, e2)), e2.logo &&= i$5(e2.logo).map((t3) => this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2.homepage &&= i$5(e2.homepage).map((t3) => this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2.partOf &&= e2.partOf.map((t3) => typeof t3 == "string" || !t3.type ? this.traverseType(t3, { parent: e2 }, this.traversals.contentResource) : t3.type === "Canvas" ? this.traverseType(t3, { parent: e2 }, this.traversals.canvas) : t3.type === "AnnotationCollection" ? this.traverseType(t3, { parent: e2 }, this.traversals.annotationCollection) : t3.type === "Collection" ? this.traverseType(t3, { parent: e2 }, this.traversals.collection) : this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2.start && (n$5(e2.start) ? e2.start = this.traverseSpecificResource(e2.start, "Canvas", e2) : e2.start = this.traverseType(e2.start, { parent: e2 }, this.traversals.canvas)), e2.rendering &&= e2.rendering.map((t3) => this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2.supplementary &&= e2.supplementary.map((t3) => this.traverseType(t3, { parent: e2 }, this.traversals.contentResource)), e2;
|
|
125
|
-
}
|
|
126
|
-
traverseCollectionItems(e2) {
|
|
127
|
-
return e2.items && e2.items.map((e3) => e3.type === "Collection" ? this.traverseCollection(e3) : this.traverseManifest(e3)), e2;
|
|
128
|
-
}
|
|
129
|
-
traverseCollection(e2, t3) {
|
|
130
|
-
return this.traverseType(this.traverseDescriptive(this.traverseNavPlace(this.traverseInlineAnnotationPages(this.traverseLinking(this.traverseLinkedCanvases(this.traverseCollectionItems(e2)))))), { parent: t3 }, this.traversals.collection);
|
|
131
|
-
}
|
|
132
|
-
traverseGeoJson(e2, t3) {
|
|
133
|
-
return this.traverseType(e2, { parent: t3 }, this.traversals.geoJson);
|
|
134
|
-
}
|
|
135
|
-
traverseNavPlace(e2) {
|
|
136
|
-
return e2.navPlace &&= this.traverseGeoJson(e2.navPlace, e2), e2;
|
|
137
|
-
}
|
|
138
|
-
traverseManifestItems(e2) {
|
|
139
|
-
return e2.items &&= e2.items.map((e3) => this.traverseCanvas(e3)), e2;
|
|
140
|
-
}
|
|
141
|
-
traverseManifestStructures(e2) {
|
|
142
|
-
return e2.structures &&= e2.structures.map((e3) => this.traverseRange(e3)), e2;
|
|
143
|
-
}
|
|
144
|
-
traverseManifest(e2, t3) {
|
|
145
|
-
return this.traverseType(this._traverseManifest(e2), { parent: t3 }, this.traversals.manifest);
|
|
146
|
-
}
|
|
147
|
-
traverseCanvasItems(e2) {
|
|
148
|
-
return e2.items = (e2.items || []).map((t3) => this.traverseAnnotationPage(t3, e2)), e2;
|
|
149
|
-
}
|
|
150
|
-
traverseInlineAnnotationPages(e2) {
|
|
151
|
-
return typeof e2 == "string" || !e2 || (e2.annotations &&= e2.annotations.map((t3) => this.traverseAnnotationPage(t3, e2))), e2;
|
|
152
|
-
}
|
|
153
|
-
traverseCanvas(e2, t3) {
|
|
154
|
-
return this.traverseType(this._traverseCanvas(e2), { parent: t3 }, this.traversals.canvas);
|
|
155
|
-
}
|
|
156
|
-
traverseAnnotationPageItems(e2) {
|
|
157
|
-
return e2.items &&= e2.items.map((t3) => this.traverseAnnotation(t3, e2)), e2;
|
|
158
|
-
}
|
|
159
|
-
traverseAnnotationPage(e2, t3) {
|
|
160
|
-
return this.traverseType(this._traverseAnnotationPage(e2), { parent: t3 }, this.traversals.annotationPage);
|
|
161
|
-
}
|
|
162
|
-
traverseAnnotationBody(e2) {
|
|
163
|
-
return Array.isArray(e2.body) ? e2.body = e2.body.map((t3) => this.traverseContentResource(t3, e2)) : e2.body &&= this.traverseContentResource(e2.body, e2), e2;
|
|
164
|
-
}
|
|
165
|
-
traverseLinkedCanvases(e2) {
|
|
166
|
-
return e2.placeholderCanvas &&= this.traverseCanvas(e2.placeholderCanvas), e2.accompanyingCanvas &&= this.traverseCanvas(e2.accompanyingCanvas), e2;
|
|
167
|
-
}
|
|
168
|
-
traverseAnnotation(e2, t3) {
|
|
169
|
-
return this.traverseType(this.traverseLinking(this.traverseAnnotationBody(this.traverseDescriptive(e2))), { parent: t3 }, this.traversals.annotation);
|
|
170
|
-
}
|
|
171
|
-
traverseContentResourceLinking(e2) {
|
|
172
|
-
return typeof e2 == "string" || !e2 || e2 && e2.service && (e2.service = i$5(e2.service || []).map((t3) => this.traverseService(t3, e2))), e2;
|
|
173
|
-
}
|
|
174
|
-
traverseContentResource(e2, t3) {
|
|
175
|
-
return e2.type === "Choice" && (e2.items = e2.items.map((t4) => this.traverseContentResource(t4, e2))), n$5(e2) ? this.traverseSpecificResource(e2, "ContentResource") : this.traverseType(this.traverseInlineAnnotationPages(this.traverseContentResourceLinking(e2)), { parent: t3 }, this.traversals.contentResource);
|
|
176
|
-
}
|
|
177
|
-
traverseSpecificResource(e2, t3, n2) {
|
|
178
|
-
let r2 = e2.source;
|
|
179
|
-
return typeof e2.source == "string" && (r2 = { id: e2.source, type: t3 || "unknown" }), this.traverseType({ ...e2, source: t3 === "Canvas" || r2.type === "Canvas" ? this.traverseType(r2, { parent: n2 }, this.traversals.canvas) : t3 === "ContentResource" ? this.traverseContentResource(r2, { parent: n2 }) : this.traverseUnknown(r2, { parent: n2, typeHint: t3 }) }, { parent: n2 }, this.traversals.specificResource);
|
|
180
|
-
}
|
|
181
|
-
traverseRangeRanges(e2) {
|
|
182
|
-
return e2.items &&= e2.items.map((t3) => typeof t3 == "string" ? this.traverseCanvas({ id: t3, type: "Canvas" }, e2) : n$5(t3) ? this.traverseSpecificResource(t3, "Canvas", e2) : t3.type === "Manifest" ? this.traverseManifest(t3, e2) : this.traverseRange(t3, e2)), e2;
|
|
183
|
-
}
|
|
184
|
-
traverseRange(e2, t3) {
|
|
185
|
-
return this.traverseType(this._traverseRange(e2), { parent: t3 }, this.traversals.range);
|
|
186
|
-
}
|
|
187
|
-
traverseAgent(e2, t3) {
|
|
188
|
-
return this.traverseType(this.traverseDescriptive(this.traverseLinking(e2)), { parent: t3 }, this.traversals.agent);
|
|
189
|
-
}
|
|
190
|
-
traverseType(e2, t3, n2) {
|
|
191
|
-
return n2.reduce((e3, n3) => {
|
|
192
|
-
let r2 = n3(e3, t3);
|
|
193
|
-
return r2 === void 0 && !this.options.allowUndefinedReturn ? e3 : r2;
|
|
194
|
-
}, e2);
|
|
195
|
-
}
|
|
196
|
-
traverseService(e2, n2) {
|
|
197
|
-
let r2 = Object.assign({}, e2);
|
|
198
|
-
return r2 && r2.service && (r2.service = i$5(r2.service).map((e3) => this.traverseService(e3))), this.traverseType(r2, { parent: n2 }, this.traversals.service);
|
|
199
|
-
}
|
|
200
|
-
traverseUnknown(e2, { parent: t3, typeHint: n2 } = {}) {
|
|
201
|
-
let r2 = a$4(e2, n2);
|
|
202
|
-
switch (r2) {
|
|
203
|
-
case "Collection":
|
|
204
|
-
return this.traverseCollection(e2, t3);
|
|
205
|
-
case "Manifest":
|
|
206
|
-
return this.traverseManifest(e2, t3);
|
|
207
|
-
case "Canvas":
|
|
208
|
-
return this.traverseCanvas(e2, t3);
|
|
209
|
-
case "AnnotationPage":
|
|
210
|
-
return this.traverseAnnotationPage(e2, t3);
|
|
211
|
-
case "Annotation":
|
|
212
|
-
return this.traverseAnnotation(e2, t3);
|
|
213
|
-
case "ContentResource":
|
|
214
|
-
return this.traverseContentResource(e2, t3);
|
|
215
|
-
case "Range":
|
|
216
|
-
return this.traverseRange(e2, t3);
|
|
217
|
-
case "Service":
|
|
218
|
-
return this.traverseService(e2, t3);
|
|
219
|
-
case "Agent":
|
|
220
|
-
return this.traverseAgent(e2, t3);
|
|
221
|
-
default:
|
|
222
|
-
throw Error(`Unknown or unsupported resource type of ${r2}`);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
};
|
|
226
|
-
const e$3 = "http://library.stanford.edu/iiif/image-api/compliance.html#level0", t$4 = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", n$4 = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", r$3 = "http://library.stanford.edu/iiif/image-api/conformance.html#level0", i$3 = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", a$3 = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", o$3 = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0", s$3 = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", c$3 = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", l$3 = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0", u$3 = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", d$3 = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", f$3 = "http://iiif.io/api/image/1/level0.json", p$3 = "http://iiif.io/api/image/1/profiles/level0.json", m$3 = "http://iiif.io/api/image/1/level1.json", h$4 = "http://iiif.io/api/image/1/profiles/level1.json", g$5 = "http://iiif.io/api/image/1/level2.json", _$5 = "http://iiif.io/api/image/1/profiles/level2.json", v$5 = "http://iiif.io/api/image/2/level0.json", y$5 = "http://iiif.io/api/image/2/profiles/level0.json", b$5 = "http://iiif.io/api/image/2/level1.json", x$5 = "http://iiif.io/api/image/2/profiles/level1.json", S$4 = "http://iiif.io/api/image/2/level2.json", C$4 = "http://iiif.io/api/image/2/profiles/level2.json", w$3 = "level0", T$4 = "level1", E$4 = "level2", D$3 = "http://iiif.io/api/image/2/level0", O$3 = "http://iiif.io/api/image/2/level1", k$3 = "http://iiif.io/api/image/2/level2", A$3 = [k$3, n$4, a$3, c$3, d$3, g$5, _$5, S$4, C$4, E$4], M$3 = [D$3, O$3, k$3, e$3, t$4, n$4, r$3, i$3, a$3, o$3, s$3, c$3, l$3, u$3, d$3, f$3, p$3, m$3, h$4, g$5, _$5, v$5, y$5, b$5, x$5, S$4, C$4, w$3, T$4, E$4], N$4 = M$3, a$2 = ["sc:Collection", "sc:Manifest", "sc:Canvas", "sc:AnnotationList", "oa:Annotation", "sc:Range", "sc:Layer", "sc:Sequence", "oa:Choice", "Service", "ContentResource"];
|
|
227
|
-
function o$2(e2) {
|
|
228
|
-
if (e2 == null) throw Error("Null or undefined is not a valid entity.");
|
|
229
|
-
if (Array.isArray(e2)) throw Error("Array is not a valid entity");
|
|
230
|
-
if (typeof e2 != "object") throw Error(`${typeof e2} is not a valid entity`);
|
|
231
|
-
if (typeof e2["@type"] == "string") {
|
|
232
|
-
let t3 = a$2.indexOf(e2["@type"]);
|
|
233
|
-
if (t3 !== -1) return a$2[t3];
|
|
234
|
-
}
|
|
235
|
-
if (e2.profile) return "Service";
|
|
236
|
-
if (e2.format || e2["@type"]) return "ContentResource";
|
|
237
|
-
throw Error("Resource type is not known");
|
|
238
|
-
}
|
|
239
|
-
var s$2 = class t {
|
|
240
|
-
constructor(t3, n2 = {}) {
|
|
241
|
-
r$5(this, "traversals", void 0), r$5(this, "options", void 0), this.traversals = { collection: [], manifest: [], canvas: [], annotationList: [], sequence: [], annotation: [], contentResource: [], choice: [], range: [], service: [], layer: [], ...t3 }, this.options = { convertPropsToArray: !0, mergeMemberProperties: !0, allowUndefinedReturn: !1, ...n2 };
|
|
242
|
-
}
|
|
243
|
-
static all(e2) {
|
|
244
|
-
return new t({ collection: [e2], manifest: [e2], canvas: [e2], annotationList: [e2], sequence: [e2], annotation: [e2], contentResource: [e2], choice: [e2], range: [e2], service: [e2], layer: [e2] });
|
|
245
|
-
}
|
|
246
|
-
traverseCollection(e2) {
|
|
247
|
-
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCollectionItems(e2))), this.traversals.collection);
|
|
248
|
-
}
|
|
249
|
-
traverseCollectionItems(e2) {
|
|
250
|
-
if (this.options.mergeMemberProperties) {
|
|
251
|
-
let t3 = [...(e2.manifests || []).map((e3) => typeof e3 == "string" ? { "@id": e3, "@type": "sc:Manifest" } : e3), ...(e2.collections || []).map((e3) => typeof e3 == "string" ? { "@id": e3, "@type": "sc:Collection" } : e3), ...e2.members || []], n2 = [], r2 = t3.filter((e3) => n2.includes(e3["@id"]) ? !1 : (n2.push(e3["@id"]), !0));
|
|
252
|
-
delete e2.collections, delete e2.manifests, e2.members = r2;
|
|
253
|
-
}
|
|
254
|
-
return e2.manifests &&= e2.manifests.map((e3) => this.traverseManifest(typeof e3 == "string" ? { "@id": e3, "@type": "sc:Manifest" } : e3)), e2.collections &&= e2.collections.map((e3) => this.traverseCollection(typeof e3 == "string" ? { "@id": e3, "@type": "sc:Collection" } : e3)), e2.members &&= e2.members.map((e3) => typeof e3 == "string" ? e3 : e3["@type"] === "sc:Collection" ? this.traverseCollection(e3) : e3["@type"] === "sc:Manifest" ? this.traverseManifest(e3) : this.traverseUnknown(e3)), e2;
|
|
255
|
-
}
|
|
256
|
-
traverseManifest(e2) {
|
|
257
|
-
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseManifestItems(e2))), this.traversals.manifest);
|
|
258
|
-
}
|
|
259
|
-
traverseManifestItems(e2) {
|
|
260
|
-
return e2.sequences &&= e2.sequences.map((e3) => this.traverseSequence(e3)), e2.structures &&= e2.structures.map((e3) => this.traverseRange(e3)), e2;
|
|
261
|
-
}
|
|
262
|
-
traverseSequence(e2) {
|
|
263
|
-
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseSequenceItems(e2))), this.traversals.sequence);
|
|
264
|
-
}
|
|
265
|
-
traverseSequenceItems(e2) {
|
|
266
|
-
return e2.canvases &&= e2.canvases.map((e3) => this.traverseCanvas(e3)), e2;
|
|
267
|
-
}
|
|
268
|
-
traverseCanvas(e2) {
|
|
269
|
-
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCanvasItems(e2))), this.traversals.canvas);
|
|
270
|
-
}
|
|
271
|
-
traverseCanvasItems(e2) {
|
|
272
|
-
return e2.images &&= e2.images.map((e3) => (e3.on && e3["@type"] !== "oa:Annotation" && e3["@type"] !== "Annotation" && (e3["@type"] = "oa:Annotation"), this.traverseAnnotation(e3))), e2.otherContent &&= e2.otherContent.map((e3) => this.traverseAnnotationList(e3)), e2;
|
|
273
|
-
}
|
|
274
|
-
traverseRange(e2) {
|
|
275
|
-
return e2["@type"] !== "sc:Range" && (e2["@type"] = "sc:Range"), this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseRangeItems(e2))), this.traversals.range);
|
|
276
|
-
}
|
|
277
|
-
traverseRangeItems(e2) {
|
|
278
|
-
if (this.options.mergeMemberProperties) {
|
|
279
|
-
let t3 = [...(e2.ranges || []).map((e3) => typeof e3 == "string" ? { "@id": e3, "@type": "sc:Range" } : e3), ...(e2.canvases || []).map((e3) => typeof e3 == "string" ? { "@id": e3, "@type": "sc:Canvas" } : e3), ...e2.members || []];
|
|
280
|
-
delete e2.ranges, delete e2.canvases, e2.members = t3.length ? t3.map((e3) => this.traverseUnknown(e3)) : void 0;
|
|
281
|
-
}
|
|
282
|
-
return e2;
|
|
283
|
-
}
|
|
284
|
-
traverseAnnotationList(e2) {
|
|
285
|
-
let t3 = typeof e2 == "string" ? { "@id": e2, "@type": "sc:AnnotationList" } : e2;
|
|
286
|
-
return this.traverseType(this.traverseDescriptive(this.traverseAnnotationListItems(t3)), this.traversals.annotationList);
|
|
287
|
-
}
|
|
288
|
-
traverseAnnotationListItems(e2) {
|
|
289
|
-
return e2.resources &&= e2.resources.map((e3) => this.traverseAnnotation(e3)), e2;
|
|
290
|
-
}
|
|
291
|
-
traverseAnnotation(e2) {
|
|
292
|
-
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseAnnotationItems(e2))), this.traversals.annotation);
|
|
293
|
-
}
|
|
294
|
-
traverseAnnotationItems(e2) {
|
|
295
|
-
return e2.resource && (Array.isArray(e2.resource) ? e2.resource = e2.resource.map((e3) => this.traverseContentResource(e3)) : e2.resource = this.traverseContentResource(e2.resource)), e2.on, e2;
|
|
296
|
-
}
|
|
297
|
-
traverseLayer(e2) {
|
|
298
|
-
return this.traverseType(this.traverseLinking(this.traverseLayerItems(e2)), this.traversals.layer);
|
|
299
|
-
}
|
|
300
|
-
traverseLayerItems(e2) {
|
|
301
|
-
return e2.otherContent &&= e2.otherContent.map((e3) => this.traverseAnnotationList(e3)), e2;
|
|
302
|
-
}
|
|
303
|
-
traverseChoice(e2) {
|
|
304
|
-
return this.traverseType(this.traverseChoiceItems(e2), this.traversals.choice);
|
|
305
|
-
}
|
|
306
|
-
traverseChoiceItems(e2) {
|
|
307
|
-
return e2.default && e2.default !== "rdf:nil" && (e2.default = this.traverseContentResource(e2.default)), e2.item && e2.item !== "rdf:nil" && (e2.item = e2.item.map((e3) => this.traverseContentResource(e3))), e2;
|
|
308
|
-
}
|
|
309
|
-
traverseService(e2) {
|
|
310
|
-
return this.traverseType(this.traverseLinking(e2), this.traversals.service);
|
|
311
|
-
}
|
|
312
|
-
traverseContentResource(e2) {
|
|
313
|
-
return e2["@type"] === "oa:Choice" ? this.traverseChoice(e2) : this.traverseType(this.traverseDescriptive(this.traverseLinking(e2)), this.traversals.contentResource);
|
|
314
|
-
}
|
|
315
|
-
traverseUnknown(e2) {
|
|
316
|
-
if (!e2["@type"] || typeof e2 == "string") return e2;
|
|
317
|
-
switch (o$2(e2)) {
|
|
318
|
-
case "sc:Collection":
|
|
319
|
-
return this.traverseCollection(e2);
|
|
320
|
-
case "sc:Manifest":
|
|
321
|
-
return this.traverseManifest(e2);
|
|
322
|
-
case "sc:Canvas":
|
|
323
|
-
return this.traverseCanvas(e2);
|
|
324
|
-
case "sc:Sequence":
|
|
325
|
-
return this.traverseSequence(e2);
|
|
326
|
-
case "sc:Range":
|
|
327
|
-
return this.traverseRange(e2);
|
|
328
|
-
case "oa:Annotation":
|
|
329
|
-
return this.traverseAnnotation(e2);
|
|
330
|
-
case "sc:AnnotationList":
|
|
331
|
-
return this.traverseAnnotationList(e2);
|
|
332
|
-
case "sc:Layer":
|
|
333
|
-
return this.traverseLayer(e2);
|
|
334
|
-
case "Service":
|
|
335
|
-
return this.traverseService(e2);
|
|
336
|
-
case "oa:Choice":
|
|
337
|
-
return this.traverseChoice(e2);
|
|
338
|
-
case "ContentResource":
|
|
339
|
-
return this.traverseContentResource(e2);
|
|
340
|
-
}
|
|
341
|
-
return e2.profile ? this.traverseService(e2) : e2;
|
|
342
|
-
}
|
|
343
|
-
traverseImageResource(e2) {
|
|
344
|
-
let t3 = Array.isArray(e2), n2 = Array.isArray(e2) ? e2 : [e2], r2 = [];
|
|
345
|
-
for (let e3 of n2) typeof e3 == "string" ? r2.push(this.traverseContentResource({ "@id": e3, "@type": "dctypes:Image" })) : r2.push(this.traverseContentResource(e3));
|
|
346
|
-
return !t3 && !this.options.convertPropsToArray ? r2[0] : r2;
|
|
347
|
-
}
|
|
348
|
-
traverseDescriptive(e2) {
|
|
349
|
-
return e2.thumbnail &&= this.traverseImageResource(e2.thumbnail), e2.logo &&= this.traverseImageResource(e2.logo), e2;
|
|
350
|
-
}
|
|
351
|
-
traverseOneOrMoreServices(e2) {
|
|
352
|
-
let t3 = Array.isArray(e2), n2 = Array.isArray(e2) ? e2 : [e2], r2 = [];
|
|
353
|
-
for (let e3 of n2) r2.push(this.traverseService(e3));
|
|
354
|
-
return !t3 && !this.options.convertPropsToArray ? r2[0] : r2;
|
|
355
|
-
}
|
|
356
|
-
traverseLinking(e2) {
|
|
357
|
-
return e2.related &&= this.traverseOneOrManyType(e2.related, this.traversals.contentResource), e2.rendering &&= this.traverseOneOrManyType(e2.rendering, this.traversals.contentResource), e2.service &&= this.traverseOneOrMoreServices(e2.service), e2.seeAlso &&= this.traverseOneOrManyType(e2.seeAlso, this.traversals.contentResource), e2.within && (typeof e2.within == "string" || (e2.within = this.traverseOneOrManyType(e2.within, this.traversals.contentResource))), e2.startCanvas && (typeof e2.startCanvas == "string" ? e2.startCanvas = this.traverseType({ "@id": e2.startCanvas, "@type": "sc:Canvas" }, this.traversals.canvas) : e2.startCanvas && this.traverseType(e2.startCanvas, this.traversals.canvas)), e2.contentLayer && (typeof e2.contentLayer == "string" ? e2.contentLayer = this.traverseLayer({ "@id": e2.contentLayer, "@type": "sc:Layer" }) : e2.contentLayer = this.traverseLayer(e2.contentLayer)), e2;
|
|
358
|
-
}
|
|
359
|
-
traverseOneOrManyType(e2, t3) {
|
|
360
|
-
if (!Array.isArray(e2)) if (this.options.convertPropsToArray) e2 = [e2];
|
|
361
|
-
else return this.traverseType(e2, t3);
|
|
362
|
-
return e2.map((e3) => this.traverseType(e3, t3));
|
|
363
|
-
}
|
|
364
|
-
traverseType(e2, t3) {
|
|
365
|
-
return t3.reduce((e3, t4) => {
|
|
366
|
-
let n2 = t4(e3);
|
|
367
|
-
return n2 === void 0 && !this.options.allowUndefinedReturn ? e3 : n2;
|
|
368
|
-
}, e2);
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
const c$2 = ["http://iiif.io/api/image/2/level1", "http://iiif.io/api/image/2/level2", "http://library.stanford.edu/iiif/image-api/compliance.html#level1", "http://library.stanford.edu/iiif/image-api/compliance.html#level2", "http://library.stanford.edu/iiif/image-api/conformance.html#level1", "http://library.stanford.edu/iiif/image-api/conformance.html#level2", "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", "http://iiif.io/api/image/1/level1.json", "http://iiif.io/api/image/1/profiles/level1.json", "http://iiif.io/api/image/1/level2.json", "http://iiif.io/api/image/1/profiles/level2.json", "http://iiif.io/api/image/2/level1.json", "http://iiif.io/api/image/2/profiles/level1.json", "http://iiif.io/api/image/2/level2.json", "http://iiif.io/api/image/2/profiles/level2.json", "level1", "level2"], l$2 = { attributionLabel: "Attribution", providerId: "http://example.org/provider", providerName: "" };
|
|
372
|
-
function u$2(e2) {
|
|
373
|
-
if (typeof e2 == "string") return [e2];
|
|
374
|
-
if (!e2) return [];
|
|
375
|
-
let t3 = Array.isArray(e2) ? e2 : [e2], n2 = [];
|
|
376
|
-
for (let e3 of t3) {
|
|
377
|
-
if (typeof e3 == "string") {
|
|
378
|
-
n2.push(e3);
|
|
379
|
-
continue;
|
|
380
|
-
}
|
|
381
|
-
n2.push({ "@language": e3["@language"] || e3.language, "@value": e3["@value"] || e3.value });
|
|
382
|
-
}
|
|
383
|
-
return n2;
|
|
384
|
-
}
|
|
385
|
-
function d$2(e2, t3 = "none") {
|
|
386
|
-
if (!e2) return { none: [""] };
|
|
387
|
-
let n2 = u$2(e2), r2 = {};
|
|
388
|
-
for (let e3 of n2) {
|
|
389
|
-
if (typeof e3 == "string") {
|
|
390
|
-
r2[t3] = r2[t3] ? r2[t3] : [], r2[t3].push(e3 || "");
|
|
391
|
-
continue;
|
|
392
|
-
}
|
|
393
|
-
if (!e3["@language"]) {
|
|
394
|
-
r2[t3] = r2[t3] ? r2[t3] : [], r2[t3].push(e3["@value"] || "");
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
let n3 = e3["@language"];
|
|
398
|
-
r2[n3] = r2[n3] ? r2[n3] : [], r2[n3].push(e3["@value"] || "");
|
|
399
|
-
}
|
|
400
|
-
return Object.keys(r2).length === 0 ? { none: [""] } : r2;
|
|
401
|
-
}
|
|
402
|
-
function f$2(e2) {
|
|
403
|
-
if (Array.isArray(e2)) return f$2(e2.find((e3) => typeof e3 == "string"));
|
|
404
|
-
if (A$3.indexOf(e2) !== -1) return "level2";
|
|
405
|
-
if (c$2.indexOf(e2) !== -1) return "level1";
|
|
406
|
-
if (N$4.indexOf(e2) !== -1) return "level0";
|
|
407
|
-
if (typeof e2 == "string") return e2;
|
|
408
|
-
}
|
|
409
|
-
function p$2(e2) {
|
|
410
|
-
let t3 = Array.isArray(e2) ? e2 : [e2];
|
|
411
|
-
for (let e3 of t3) switch (e3) {
|
|
412
|
-
case "http://iiif.io/api/image/2/context.json":
|
|
413
|
-
case "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2":
|
|
414
|
-
return "ImageService2";
|
|
415
|
-
case "http://iiif.io/api/image/1/context.json":
|
|
416
|
-
case "http://library.stanford.edu/iiif/image-api/1.1/context.json":
|
|
417
|
-
return "ImageService1";
|
|
418
|
-
case "http://iiif.io/api/annex/openannotation/context.json":
|
|
419
|
-
return "ImageApiSelector";
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
function m$2(e2) {
|
|
423
|
-
switch (e2) {
|
|
424
|
-
case "http://iiif.io/api/image/2/level0.json":
|
|
425
|
-
case "http://iiif.io/api/image/2/level1.json":
|
|
426
|
-
case "http://iiif.io/api/image/2/level2.json":
|
|
427
|
-
return "ImageService2";
|
|
428
|
-
case "http://iiif.io/api/auth/1/kiosk":
|
|
429
|
-
case "http://iiif.io/api/auth/1/login":
|
|
430
|
-
case "http://iiif.io/api/auth/1/clickthrough":
|
|
431
|
-
case "http://iiif.io/api/auth/1/external":
|
|
432
|
-
case "http://iiif.io/api/auth/0/kiosk":
|
|
433
|
-
case "http://iiif.io/api/auth/0/login":
|
|
434
|
-
case "http://iiif.io/api/auth/0/clickthrough":
|
|
435
|
-
case "http://iiif.io/api/auth/0/external":
|
|
436
|
-
return "AuthCookieService1";
|
|
437
|
-
case "http://iiif.io/api/auth/1/token":
|
|
438
|
-
case "http://iiif.io/api/auth/0/token":
|
|
439
|
-
return "AuthTokenService1";
|
|
440
|
-
case "http://iiif.io/api/auth/1/logout":
|
|
441
|
-
case "http://iiif.io/api/auth/0/logout":
|
|
442
|
-
return "AuthLogoutService1";
|
|
443
|
-
case "http://iiif.io/api/search/1/search":
|
|
444
|
-
case "http://iiif.io/api/search/0/search":
|
|
445
|
-
return "SearchService1";
|
|
446
|
-
case "http://iiif.io/api/search/1/autocomplete":
|
|
447
|
-
case "http://iiif.io/api/search/0/autocomplete":
|
|
448
|
-
return "AutoCompleteService1";
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
function h$3(e2) {
|
|
452
|
-
for (let t3 of ["sc", "oa", "dcterms", "dctypes", "iiif"]) if (e2.startsWith(`${t3}:`)) return e2.slice(t3.length + 1);
|
|
453
|
-
return e2;
|
|
454
|
-
}
|
|
455
|
-
const g$4 = ["Collection", "Manifest", "Annotation", "AnnotationPage", "Range", "Service"];
|
|
456
|
-
function _$4(e2) {
|
|
457
|
-
let t3 = e2["@id"] || e2.id, n2 = e2["@type"] || e2.type, r2 = e2.profile || void 0, i3 = e2["@context"] || void 0;
|
|
458
|
-
if (r2) {
|
|
459
|
-
let e3 = m$2(r2);
|
|
460
|
-
if (e3) return e3;
|
|
461
|
-
}
|
|
462
|
-
if (i3) {
|
|
463
|
-
let e3 = p$2(i3);
|
|
464
|
-
if (e3) return e3;
|
|
465
|
-
}
|
|
466
|
-
if (n2) {
|
|
467
|
-
if (Array.isArray(n2)) {
|
|
468
|
-
if (n2.indexOf("oa:CssStylesheet") !== -1) return "CssStylesheet";
|
|
469
|
-
if (n2.indexOf("cnt:ContentAsText") !== -1) return "TextualBody";
|
|
470
|
-
n2 = n2[0];
|
|
471
|
-
}
|
|
472
|
-
for (let e3 of ["sc", "oa", "dcterms", "dctypes", "iiif"]) if (n2.startsWith(`${e3}:`)) {
|
|
473
|
-
n2 = n2.slice(e3.length + 1);
|
|
474
|
-
break;
|
|
475
|
-
}
|
|
476
|
-
switch (n2) {
|
|
477
|
-
case "Layer":
|
|
478
|
-
return "AnnotationCollection";
|
|
479
|
-
case "AnnotationList":
|
|
480
|
-
return "AnnotationPage";
|
|
481
|
-
case "cnt:ContentAsText":
|
|
482
|
-
return "TextualBody";
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
if (n2 && g$4.indexOf(n2) !== -1) return n2;
|
|
486
|
-
if (e2.format) {
|
|
487
|
-
if (e2.format.startsWith("image/")) return "Image";
|
|
488
|
-
if (e2.format.startsWith("text/") || e2.format === "application/pdf") return "Text";
|
|
489
|
-
if (e2.format.startsWith("application/")) return "Dataset";
|
|
490
|
-
}
|
|
491
|
-
return t3 && (t3.endsWith(".jpg") || t3.endsWith(".png") || t3.endsWith(".jpeg")) ? "Image" : n2 || "unknown";
|
|
492
|
-
}
|
|
493
|
-
const v$4 = /^|["'\\>]http(s)?:\/\/(creativecommons.org|rightsstatements.org)\/[^"'\\<\n]+/gm;
|
|
494
|
-
function y$4(e2) {
|
|
495
|
-
let t3 = e2.match(v$4);
|
|
496
|
-
return t3 ? t3[0] : e2;
|
|
497
|
-
}
|
|
498
|
-
function b$4(e2, t3 = "Rights/License", n2 = "none") {
|
|
499
|
-
let r2 = null, i3 = [], a2 = Array.isArray(e2) ? e2 : [e2];
|
|
500
|
-
for (let e3 of a2) {
|
|
501
|
-
let a3 = e3 ? y$4(e3) : void 0;
|
|
502
|
-
if (a3 && (a3.indexOf("creativecommons.org") !== -1 || a3.indexOf("rightsstatements.org") !== -1)) {
|
|
503
|
-
r2 = a3.startsWith("https://") ? `http://${a3.slice(8)}` : a3;
|
|
504
|
-
continue;
|
|
505
|
-
}
|
|
506
|
-
a3 && i3.push({ label: { [n2]: [t3] }, value: { [n2]: [a3] } });
|
|
507
|
-
}
|
|
508
|
-
return [r2, i3];
|
|
509
|
-
}
|
|
510
|
-
const x$4 = ["http://iiif.io/api/presentation/2/context.json", "http://iiif.io/api/image/2/context.json", "http://iiif.io/api/image/1/context.json", "http://library.stanford.edu/iiif/image-api/1.1/context.json", "http://iiif.io/api/search/1/context.json", "http://iiif.io/api/search/0/context.json", "http://iiif.io/api/auth/1/context.json", "http://iiif.io/api/auth/0/context.json", "http://iiif.io/api/annex/openannotation/context.json"];
|
|
511
|
-
function S$3(e2) {
|
|
512
|
-
if (e2) {
|
|
513
|
-
let t3 = Array.isArray(e2) ? e2 : [e2], n2 = [];
|
|
514
|
-
for (let e3 of t3)
|
|
515
|
-
e3 === "http://iiif.io/api/presentation/2/context.json" && n2.push("http://iiif.io/api/presentation/3/context.json"), x$4.indexOf(e3) === -1 && n2.push(e3);
|
|
516
|
-
if (t3.length) return n2.length === 1 ? n2[0] : n2;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
function C$3(e2) {
|
|
520
|
-
return e2 ? e2.map((e3) => ({ label: d$2(e3.label), value: d$2(e3.value) })) : [];
|
|
521
|
-
}
|
|
522
|
-
let w$2 = 0;
|
|
523
|
-
function T$3(e2, t3) {
|
|
524
|
-
let n2 = encodeURI(e2.id || e2["@id"] || "").trim();
|
|
525
|
-
return n2 && t3 ? `${n2}/${t3}` : n2 || (w$2++, `http://example.org/${e2["@type"]}${t3 ? `/${t3}` : ""}/${w$2}`);
|
|
526
|
-
}
|
|
527
|
-
function E$3(e2) {
|
|
528
|
-
let t3 = [...e2.behavior || []];
|
|
529
|
-
e2.viewingHint && t3.push(e2.viewingHint);
|
|
530
|
-
let n2;
|
|
531
|
-
return Array.isArray(e2.motivation) ? n2 = e2.motivation.map(h$3) : e2.motivation && (n2 = h$3(e2.motivation)), { "@context": e2["@context"] ? S$3(e2["@context"]) : void 0, id: (e2["@id"] || T$3(e2)).trim(), type: _$4(e2), behavior: t3.length ? t3 : void 0, height: e2.height ? e2.height : void 0, width: e2.width ? e2.width : void 0, motivation: n2, viewingDirection: e2.viewingDirection, profile: e2.profile, format: e2.format ? e2.format : void 0, duration: void 0, timeMode: void 0 };
|
|
532
|
-
}
|
|
533
|
-
function D$2(e2) {
|
|
534
|
-
let [t3, n2] = b$4(e2.license), r2 = [...e2.metadata ? C$3(e2.metadata) : [], ...n2];
|
|
535
|
-
return { rights: t3, metadata: r2.length ? r2 : void 0, label: e2.label ? d$2(e2.label) : void 0, requiredStatement: e2.attribution ? { label: d$2(l$2.attributionLabel), value: d$2(e2.attribution) } : void 0, navDate: e2.navDate, summary: e2.description ? d$2(e2.description) : void 0, thumbnail: O$2(e2.thumbnail) };
|
|
536
|
-
}
|
|
537
|
-
function O$2(e2) {
|
|
538
|
-
return e2 && (Array.isArray(e2) ? e2 : [e2]).map((e3) => typeof e3 == "string" ? { id: e3, type: "Image" } : (e3.type === "unknown" && (e3.type = "Image"), e3));
|
|
539
|
-
}
|
|
540
|
-
function k$2(e2) {
|
|
541
|
-
if (!e2.within) return;
|
|
542
|
-
let t3 = Array.isArray(e2.within) ? e2.within : [e2.within], n2 = [];
|
|
543
|
-
for (let r2 of t3) if (typeof r2 == "string") {
|
|
544
|
-
if (r2) switch (e2["@type"]) {
|
|
545
|
-
case "sc:Manifest":
|
|
546
|
-
n2.push({ id: r2, type: "Collection" });
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
} else r2["@id"] && n2.push({ id: r2["@id"], type: _$4(r2) });
|
|
550
|
-
return n2.length ? n2 : void 0;
|
|
551
|
-
}
|
|
552
|
-
function A$2(e2) {
|
|
553
|
-
let n2 = e2.related ? Array.isArray(e2.related) ? e2.related : [e2.related] : [], r2 = e2.contentLayer;
|
|
554
|
-
return { provider: e2.logo || n2.length ? [{ id: l$2.providerId, type: "Agent", homepage: n2.length ? [n2[0]] : void 0, logo: e2.logo ? Array.isArray(e2.logo) ? e2.logo : [e2.logo] : void 0, label: d$2(l$2.providerName) }] : void 0, partOf: k$2(e2), rendering: e2.rendering, seeAlso: e2.seeAlso, start: e2.startCanvas, service: e2.service ? i$5(e2.service) : void 0, supplementary: r2 ? [r2] : void 0 };
|
|
555
|
-
}
|
|
556
|
-
function j$2(e2) {
|
|
557
|
-
return { chars: e2.chars, format: e2.format ? e2.format : void 0, language: e2.language };
|
|
558
|
-
}
|
|
559
|
-
function M$2(e2, t3) {
|
|
560
|
-
return e2 ? typeof e2 == "string" ? { id: e2, type: t3 } : typeof e2?.["@id"] == "string" ? { id: e2["@id"], type: t3 } : typeof e2.id == "string" ? { id: e2.id, type: t3 } : null : null;
|
|
561
|
-
}
|
|
562
|
-
function N$3(e2) {
|
|
563
|
-
let t3 = {};
|
|
564
|
-
if (e2.first) {
|
|
565
|
-
let n2 = M$2(e2.first, "Collection");
|
|
566
|
-
n2 && (t3.first = n2);
|
|
567
|
-
}
|
|
568
|
-
if ((e2.total || e2.total === 0) && (t3.total = e2.total), e2.prev) {
|
|
569
|
-
let n2 = M$2(e2.prev, "Collection");
|
|
570
|
-
n2 && (t3.prev = n2);
|
|
571
|
-
}
|
|
572
|
-
if (e2.next) {
|
|
573
|
-
let n2 = M$2(e2.next, "Collection");
|
|
574
|
-
n2 && (t3.next = n2);
|
|
575
|
-
}
|
|
576
|
-
return t3;
|
|
577
|
-
}
|
|
578
|
-
function P$3(e2) {
|
|
579
|
-
let t3 = [];
|
|
580
|
-
for (let n2 of e2) {
|
|
581
|
-
let e3 = { ...n2 };
|
|
582
|
-
e3.items && e3.items.length === 0 && delete e3.items, t3.push(e3);
|
|
583
|
-
}
|
|
584
|
-
return t3;
|
|
585
|
-
}
|
|
586
|
-
function F$3(e2) {
|
|
587
|
-
return a$5({ ...E$3(e2), ...D$2(e2), ...A$2(e2), ...N$3(e2), items: P$3(e2.members) });
|
|
588
|
-
}
|
|
589
|
-
function I$3(e2) {
|
|
590
|
-
let t3 = [], r2 = [], i3, a2;
|
|
591
|
-
for (let n2 of e2.sequences || []) n2.canvases.length && t3.push(...n2.canvases), n2.behavior && r2.push(...n2.behavior), n2.viewingDirection && (a2 = n2.viewingDirection), n2.startCanvas && (i3 = n2.startCanvas);
|
|
592
|
-
let o2 = E$3(e2);
|
|
593
|
-
return r2.length && (o2.behavior ? o2.behavior.push(...r2) : o2.behavior = r2), a$5({ ...o2, ...D$2(e2), ...A$2(e2), viewingDirection: a2, start: i3, items: t3, structures: L$3(e2.structures) });
|
|
594
|
-
}
|
|
595
|
-
function L$3(e2) {
|
|
596
|
-
if (!e2) return e2;
|
|
597
|
-
let t3 = /* @__PURE__ */ new Map();
|
|
598
|
-
for (let n3 of e2) t3.set(n3.id, n3);
|
|
599
|
-
let n2 = [];
|
|
600
|
-
for (let r2 of e2) if (r2.items) {
|
|
601
|
-
let e3 = r2.items.map((e4) => typeof e4 == "string" ? (n2.push(e4), t3.get(e4) || e4) : e4 && e4.id ? (n2.push(e4.id), t3.get(e4.id) || e4) : e4);
|
|
602
|
-
r2.items = e3;
|
|
603
|
-
}
|
|
604
|
-
return e2.filter((e3) => n2.indexOf(e3.id) === -1);
|
|
605
|
-
}
|
|
606
|
-
function R$3(e2) {
|
|
607
|
-
return a$5({ ...E$3(e2), ...D$2(e2), ...A$2(e2), annotations: e2.otherContent && e2.otherContent.length ? e2.otherContent : void 0, items: e2.images && e2.images.length ? [{ id: T$3(e2, "annotation-page"), type: "AnnotationPage", items: e2.images }] : void 0 });
|
|
608
|
-
}
|
|
609
|
-
function z$3(e2) {
|
|
610
|
-
return a$5({ ...E$3(e2), ...D$2(e2), ...A$2(e2), items: e2.resources && e2.resources.length ? e2.resources : void 0 });
|
|
611
|
-
}
|
|
612
|
-
function B$3(e2) {
|
|
613
|
-
return !e2.canvases || e2.canvases.length === 0 ? { canvases: [], behavior: [] } : { canvases: e2.canvases, behavior: e2.viewingHint ? [e2.viewingHint] : [], viewingDirection: e2.viewingDirection, startCanvas: e2.startCanvas };
|
|
614
|
-
}
|
|
615
|
-
function V$3(e2) {
|
|
616
|
-
function t3(e3) {
|
|
617
|
-
if (Array.isArray(e3)) {
|
|
618
|
-
if (e3.length > 1) return { type: "List", items: e3.map(t3) };
|
|
619
|
-
e3 = e3[0];
|
|
620
|
-
}
|
|
621
|
-
if (typeof e3 == "string") return encodeURI(e3).trim();
|
|
622
|
-
if ("@type" in e3) {
|
|
623
|
-
let t4;
|
|
624
|
-
if (typeof e3.full == "string") t4 = e3.full;
|
|
625
|
-
else if (e3.full["@type"] === "dctypes:Image") t4 = { id: e3.full["@id"], type: "Image" };
|
|
626
|
-
else if (e3.full["@type"] === "sc:Canvas") t4 = { id: e3.full["@id"], type: "Canvas" };
|
|
627
|
-
else throw Error(`Unsupported source type on annotation: ${e3.full["@type"]}`);
|
|
628
|
-
return { type: "SpecificResource", source: t4, selector: X$2(e3.selector) };
|
|
629
|
-
} else return encodeURI(e3["@id"]).trim();
|
|
630
|
-
}
|
|
631
|
-
return a$5({ ...E$3(e2), ...D$2(e2), ...A$2(e2), target: t3(e2.on), body: Array.isArray(e2.resource) ? e2.resource.map(H$4) : H$4(e2.resource) });
|
|
632
|
-
}
|
|
633
|
-
function H$4(e2) {
|
|
634
|
-
return e2.type === "Choice" ? e2 : U$4(e2);
|
|
635
|
-
}
|
|
636
|
-
function U$4(e2) {
|
|
637
|
-
let t3 = e2;
|
|
638
|
-
return a$5({ ...E$3(t3), ...D$2(t3), ...A$2(t3), ...j$2(t3) });
|
|
639
|
-
}
|
|
640
|
-
function W$3(e2) {
|
|
641
|
-
let t3 = [];
|
|
642
|
-
return e2.default && e2.default !== "rdf:nil" && t3.push(e2.default), e2.item && e2.item !== "rdf:nil" && t3.push(...e2.item), a$5({ ...E$3(e2), ...D$2(e2), items: t3 });
|
|
643
|
-
}
|
|
644
|
-
function G$2(e2) {
|
|
645
|
-
return a$5({ ...E$3(e2), ...D$2(e2), ...A$2(e2), items: e2.members });
|
|
646
|
-
}
|
|
647
|
-
function K$2(e2) {
|
|
648
|
-
let { "@id": t3, "@type": r2, "@context": i3, profile: a2, ...o2 } = e2, s2 = {};
|
|
649
|
-
return t3 && (s2["@id"] = t3), s2["@type"] = _$4(e2), s2["@type"] === "unknown" && (i3 && i3.length && (s2["@context"] = i3), s2["@type"] = "Service"), a2 && (s2.profile = f$2(a2)), a$5({ ...s2, ...o2 });
|
|
650
|
-
}
|
|
651
|
-
function q$3(e2) {
|
|
652
|
-
return a$5({ ...E$3(e2), ...D$2(e2), ...A$2(e2) });
|
|
653
|
-
}
|
|
654
|
-
const J$3 = new s$2({ collection: [F$3], manifest: [I$3], canvas: [R$3], annotationList: [z$3], sequence: [B$3], annotation: [V$3], contentResource: [U$4], choice: [W$3], range: [G$2], service: [K$2], layer: [q$3] });
|
|
655
|
-
function Y$3(e2) {
|
|
656
|
-
return e2 && e2["@context"] && (e2["@context"] === "http://iiif.io/api/presentation/2/context.json" || Array.isArray(e2["@context"]) && e2["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || e2["@context"] === "http://www.shared-canvas.org/ns/context.json") || e2["@context"] === "http://iiif.io/api/image/2/context.json" || e2["@id"] && e2["@type"] === "sc:Collection" || e2["@id"] && e2["@type"] === "sc:Manifest" ? (e2["@context"] ||= "http://iiif.io/api/presentation/2/context.json", J$3.traverseUnknown(e2)) : e2;
|
|
657
|
-
}
|
|
658
|
-
function X$2(e2) {
|
|
659
|
-
if ((Array.isArray(e2["@type"]) && e2["@type"].includes("oa:SvgSelector") || e2["@type"] == "oa:SvgSelector") && ("chars" in e2 || "value" in e2)) return { type: "SvgSelector", value: "chars" in e2 ? e2.chars : e2.value };
|
|
660
|
-
if (e2["@type"] === "oa:FragmentSelector") return { type: "FragmentSelector", value: e2.value };
|
|
661
|
-
if (e2["@type"] === "oa:Choice") return [X$2(e2.default), ...(Array.isArray(e2.item) ? e2.item : [e2.item]).map(X$2)];
|
|
662
|
-
if (e2["@type"] == "iiif:ImageApiSelector") return { type: "ImageApiSelector", region: "region" in e2 ? e2.region : void 0, rotation: "rotation" in e2 ? e2.rotation : void 0 };
|
|
663
|
-
throw Error(`Unsupported selector type: ${e2["@type"]}`);
|
|
664
|
-
}
|
|
665
|
-
function r$2(e2, n2) {
|
|
666
|
-
let i3 = "unknown";
|
|
667
|
-
if (!e2) return;
|
|
668
|
-
if (typeof e2 == "string") return { id: e2, type: i3 };
|
|
669
|
-
if (n$5(e2)) return r$2(e2.source);
|
|
670
|
-
let a2 = e2.type || e2["@type"], o2 = e2.id || e2["@id"];
|
|
671
|
-
if (a2 && a2.indexOf(":") !== -1 && (a2 = a2.split(":").pop()), o2 && a2) return { id: o2, type: a2 };
|
|
672
|
-
}
|
|
673
|
-
const i$2 = {}, a$1 = "iiif-parser:hasPart", o$1 = "iiif-parser:partOf", s$1 = "iiif-parser:isExternal", c$1 = "__$UNSET$__", l$1 = "__$UNWRAP$__", u$1 = [];
|
|
674
|
-
Object.freeze(u$1), Object.freeze(i$2);
|
|
675
|
-
function d$1(e2) {
|
|
676
|
-
if (e2 === i$2 || Object.keys(e2).length === 0) return !0;
|
|
677
|
-
for (let t3 in e2) return !1;
|
|
678
|
-
return !0;
|
|
679
|
-
}
|
|
680
|
-
function f$1(e2, t3) {
|
|
681
|
-
if (t3 && t3["@explicit"]) {
|
|
682
|
-
let n2 = {}, r2 = Object.keys(t3);
|
|
683
|
-
for (let i3 of r2)
|
|
684
|
-
i3 === o$1 || i3 === "@explicit" || (d$1(t3[i3]) ? n2[i3] = e2[i3] : n2[i3] = t3[i3]);
|
|
685
|
-
return n2;
|
|
686
|
-
}
|
|
687
|
-
return e2;
|
|
688
|
-
}
|
|
689
|
-
function p$1(e2, t3, n2) {
|
|
690
|
-
let i3 = r$2(t3);
|
|
691
|
-
if (!i3) return [void 0, void 0];
|
|
692
|
-
let s2 = e2.requests[i3.id], c2 = i3.type || e2.mapping[i3.id];
|
|
693
|
-
if (!c2 || s2 && s2.resourceUri && (!e2.entities[c2] || !e2.entities[c2][s2.resourceUri])) return [void 0, void 0];
|
|
694
|
-
let l2 = e2.entities[c2][s2 ? s2.resourceUri : i3.id];
|
|
695
|
-
if (i3.type && !l2) return p$1(e2, { id: i3.id }, n2);
|
|
696
|
-
if (l2 && l2[a$1]) {
|
|
697
|
-
let e3 = l2[a$1].find((e4) => n2 ? e4[o$1] === n2.id : e4[o$1] === l2.id);
|
|
698
|
-
return [f$1(l2, e3), l2];
|
|
699
|
-
}
|
|
700
|
-
return [l2, l2];
|
|
701
|
-
}
|
|
702
|
-
const m$1 = { id: "https://iiif-parser/annotation-page", type: "AnnotationPage", behavior: u$1, label: null, thumbnail: u$1, summary: null, requiredStatement: null, metadata: u$1, rights: null, provider: u$1, items: u$1, seeAlso: u$1, homepage: u$1, rendering: u$1, service: u$1 }, h$2 = { id: "https://iiif-parser/empty-canvas", type: "Canvas", label: null, behavior: u$1, thumbnail: u$1, accompanyingCanvas: null, placeholderCanvas: null, summary: null, requiredStatement: null, metadata: u$1, rights: null, navDate: null, provider: u$1, items: u$1, annotations: u$1, seeAlso: u$1, homepage: u$1, partOf: u$1, rendering: u$1, service: u$1, duration: 0, height: 0, width: 0 }, g$3 = { id: "https://iiif-parser/empty-collection", type: "Collection", label: null, viewingDirection: "left-to-right", behavior: u$1, thumbnail: u$1, accompanyingCanvas: null, placeholderCanvas: null, summary: null, requiredStatement: null, metadata: u$1, rights: null, navDate: null, provider: u$1, items: u$1, annotations: u$1, seeAlso: u$1, homepage: u$1, partOf: u$1, rendering: u$1, service: u$1, services: u$1 }, _$3 = { id: "https://iiif-parser/empty-manifest", type: "Manifest", annotations: u$1, behavior: u$1, homepage: u$1, items: u$1, label: null, metadata: u$1, navDate: null, provider: u$1, partOf: u$1, accompanyingCanvas: null, placeholderCanvas: null, rendering: u$1, requiredStatement: null, rights: null, seeAlso: u$1, service: u$1, services: u$1, start: null, structures: u$1, summary: null, thumbnail: u$1, viewingDirection: "left-to-right" }, v$3 = { id: "https://iiif-parser/empty-canvas", type: "Range", label: null, behavior: u$1, thumbnail: u$1, accompanyingCanvas: null, placeholderCanvas: null, summary: null, requiredStatement: null, metadata: u$1, rights: null, navDate: null, provider: u$1, items: u$1, annotations: u$1, seeAlso: u$1, homepage: u$1, partOf: u$1, rendering: u$1, service: u$1, start: null, supplementary: null, viewingDirection: "left-to-right" }, y$3 = { id: "https://iiif-parser/empty-agent", type: "Agent", label: {}, logo: u$1, seeAlso: u$1, homepage: u$1 }, b$3 = { id: "https://iiif-parser/empty-service", type: "UnknownService" };
|
|
703
|
-
function x$3(e2) {
|
|
704
|
-
let [t3, n2] = (e2 || "").split("#");
|
|
705
|
-
return !n2 || !S$2(n2) ? [e2 || "", ""] : [t3, n2];
|
|
706
|
-
}
|
|
707
|
-
function S$2(e2) {
|
|
708
|
-
return e2.includes("xywh=") || e2.includes("t=");
|
|
709
|
-
}
|
|
710
|
-
function C$2(e2, t3 = {}) {
|
|
711
|
-
if (Array.isArray(e2)) return C$2(e2[0]);
|
|
712
|
-
if (typeof e2 == "string") {
|
|
713
|
-
let [n2, r2] = x$3(e2);
|
|
714
|
-
return r2 ? { type: "SpecificResource", source: { id: n2, type: t3.typeHint || "Unknown" }, selector: { type: "FragmentSelector", value: r2 } } : { type: "SpecificResource", source: { id: n2, type: t3.typeMap && t3.typeMap[n2] || t3.typeHint || "Unknown" } };
|
|
715
|
-
}
|
|
716
|
-
if (e2.type === "Choice" || e2.type === "List" || e2.type === "Composite" || e2.type === "Independents") return C$2(e2.items[0]);
|
|
717
|
-
if (!e2.type && "source" in e2 && (e2.type = "SpecificResource"), e2.type === "SpecificResource") {
|
|
718
|
-
e2.source.type === "Canvas" && e2.source.partOf && typeof e2.source.partOf == "string" && (e2.source.partOf = [{ id: e2.source.partOf, type: "Manifest" }]);
|
|
719
|
-
let n2 = typeof e2.source == "string" ? e2.source : e2.source.id, [, r2] = x$3(n2);
|
|
720
|
-
if (r2) {
|
|
721
|
-
let r3 = C$2(n2, t3);
|
|
722
|
-
r3 && (e2.selector = r3.selector, e2.source = r3.source);
|
|
723
|
-
}
|
|
724
|
-
return e2.selector ? { ...e2, type: "SpecificResource", source: e2.source, selector: e2.selector } : { ...e2, type: "SpecificResource", source: e2.source };
|
|
725
|
-
}
|
|
726
|
-
if (e2.id) {
|
|
727
|
-
e2.type === "Canvas" && e2.partOf && typeof e2.partOf == "string" && (e2.partOf = [{ id: e2.partOf, type: "Manifest" }]);
|
|
728
|
-
let [t4, n2] = x$3(e2.id);
|
|
729
|
-
return n2 ? { type: "SpecificResource", source: { ...e2, id: t4 }, selector: { type: "FragmentSelector", value: n2 } } : { type: "SpecificResource", source: { ...e2, id: t4 } };
|
|
730
|
-
}
|
|
731
|
-
return { type: "SpecificResource", source: e2 };
|
|
732
|
-
}
|
|
733
|
-
function T$2() {
|
|
734
|
-
return { Collection: {}, Manifest: {}, Canvas: {}, AnnotationPage: {}, AnnotationCollection: {}, Annotation: {}, ContentResource: {}, Range: {}, Service: {}, Selector: {}, Agent: {} };
|
|
735
|
-
}
|
|
736
|
-
function E$2(e2, t3) {
|
|
737
|
-
if (typeof e2 == "string") return { id: e2, type: t3 };
|
|
738
|
-
if (!e2.id) throw Error(`Invalid resource does not have an ID (${JSON.stringify(e2)}, ${t3})`);
|
|
739
|
-
return e2;
|
|
740
|
-
}
|
|
741
|
-
function te(e2, t3) {
|
|
742
|
-
return (n2, r2) => {
|
|
743
|
-
let i3 = e2[n2] ? e2[n2] : {};
|
|
744
|
-
return (e3, a2) => {
|
|
745
|
-
let o2 = E$2(e3, r2 || n2);
|
|
746
|
-
return o2 && o2.id && n2 ? (i3[o2.id] = i3[o2.id] ? O$1(i3[o2.id], o2, { parent: a2.parent, isTopLevel: t3.id === o2.id }) : O$1({ id: o2.id, type: o2.type }, o2, { parent: a2.parent, isTopLevel: t3.id === o2.id }), { id: o2.id, type: n2 === "ContentResource" ? n2 : o2.type }) : o2;
|
|
747
|
-
};
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
function D$1(e2, t3, n2) {
|
|
751
|
-
if (!t3) return e2;
|
|
752
|
-
if (Array.isArray(e2)) {
|
|
753
|
-
if (!Array.isArray(t3)) throw Error("Cannot merge array with non-array");
|
|
754
|
-
let n3 = [...e2];
|
|
755
|
-
for (let r2 of t3)
|
|
756
|
-
if (r2["@id"] && !r2.id && (r2.id = r2["@id"]), r2["@type"] && !r2.type && (r2.type = r2["@type"]), r2 != null)
|
|
757
|
-
if (Array.isArray(r2)) n3.push(r2);
|
|
758
|
-
else if (typeof r2 == "object" && r2.id && r2.type) {
|
|
759
|
-
let e3 = n3.findIndex((e4) => e4.id === r2.id && e4.type === r2.type);
|
|
760
|
-
e3 >= 0 && (n3[e3] = D$1(n3[e3], r2));
|
|
761
|
-
} else e2.indexOf(r2) === -1 && n3.push(r2);
|
|
762
|
-
return n3;
|
|
763
|
-
} else if (typeof e2 == "object") {
|
|
764
|
-
if (Array.isArray(t3) || typeof t3 != "object") throw Error("Cannot merge object with non-object");
|
|
765
|
-
let r2 = { ...e2 }, s2 = [], c2 = [], l2 = Object.keys(e2).filter((e3) => e3 !== a$1 && e3 !== "id" && e3 !== "type"), d2 = {}, f2 = {};
|
|
766
|
-
for (let [e3, n3] of Object.entries(t3)) {
|
|
767
|
-
if (e3 === a$1 || e3 === "id" || e3 === "type") continue;
|
|
768
|
-
let t4 = r2[e3];
|
|
769
|
-
t4 === n3 ? c2.push(e3) : t4 === u$1 || !t4 ? (s2.push(e3), r2[e3] = n3) : (t4 && n3 && (d2[e3] = t4, f2[e3] = n3), r2[e3] = D$1(t4, n3), r2[e3] === d2[e3] && (c2.push(e3), delete d2[e3]));
|
|
770
|
-
}
|
|
771
|
-
if (n2 && (n2.parent && n2.parent.id || n2.isTopLevel)) {
|
|
772
|
-
let t4 = [], u2 = {};
|
|
773
|
-
if (n2.parent ? u2[o$1] = n2.parent.id : n2.isTopLevel && (u2[o$1] = e2.id), r2[a$1] && r2[a$1].length) {
|
|
774
|
-
let e3 = !(r2[a$1] || []).find((e4) => e4["@explicit"]), n3 = s2.length > 0 || c2.length !== l2.length;
|
|
775
|
-
if (e3 && n3) for (let e4 of r2[a$1]) {
|
|
776
|
-
let n4 = { ...e4 }, r3 = Object.keys(d2);
|
|
777
|
-
if (n4) {
|
|
778
|
-
n4["@explicit"] = !0;
|
|
779
|
-
for (let e5 of l2) e5 !== a$1 && (n4[e5] = i$2);
|
|
780
|
-
for (let e5 of r3) n4[e5] = d2[e5];
|
|
781
|
-
}
|
|
782
|
-
t4.push(n4);
|
|
783
|
-
}
|
|
784
|
-
else t4.push(...r2[a$1]);
|
|
785
|
-
if (n3) {
|
|
786
|
-
let e4 = Object.keys(f2);
|
|
787
|
-
u2["@explicit"] = !0;
|
|
788
|
-
for (let e5 of s2) u2[e5] = i$2;
|
|
789
|
-
for (let e5 of c2) u2[e5] = i$2;
|
|
790
|
-
for (let t5 of e4) u2[t5] = f2[t5];
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
u2.id = r2.id, u2.type = r2.type, t4.push(u2), r2[a$1] = t4;
|
|
794
|
-
}
|
|
795
|
-
return r2;
|
|
796
|
-
} else if (e2) return e2;
|
|
797
|
-
return t3;
|
|
798
|
-
}
|
|
799
|
-
function O$1(e2, t3, n2) {
|
|
800
|
-
if (typeof e2 == "string") return e2;
|
|
801
|
-
if (t3.id !== e2.id || t3.type !== e2.type) {
|
|
802
|
-
if (t3.type === "ImageService3") return t3;
|
|
803
|
-
if (e2.type === "ImageService3") return e2;
|
|
804
|
-
throw Error(`Can only merge entities with identical identifiers and type! ${t3.type}(${t3.id}) => ${e2.type}(${e2.id})`);
|
|
805
|
-
}
|
|
806
|
-
return D$1({ ...e2 }, t3, n2);
|
|
807
|
-
}
|
|
808
|
-
function ne(e2) {
|
|
809
|
-
return (t3, n2) => (r2) => {
|
|
810
|
-
let { id: i3, type: a2 } = E$2(r2, n2 || t3);
|
|
811
|
-
if (i3 === void 0) throw Error("Found invalid entity without an ID.");
|
|
812
|
-
return t3 === "ContentResource" || t3 === "Service" ? e2[i3] = t3 : e2[i3] = a2, r2;
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
function re(e2) {
|
|
816
|
-
let t3 = Object.assign({}, e2);
|
|
817
|
-
if (t3["@id"] && (t3.id = t3["@id"]), t3["@type"] && (t3.type = t3["@type"]), t3.service) {
|
|
818
|
-
let e3 = [];
|
|
819
|
-
t3.service = Array.isArray(t3.service) ? t3.service : [t3.service];
|
|
820
|
-
for (let n2 of t3.service) e3.push({ id: n2["@id"] || n2.id, type: n2["@type"] || n2.type });
|
|
821
|
-
t3.service = e3;
|
|
822
|
-
}
|
|
823
|
-
return Object.assign({}, b$3, t3);
|
|
824
|
-
}
|
|
825
|
-
function ie(e2) {
|
|
826
|
-
return (t3) => {
|
|
827
|
-
e2.Service = e2.Service ? e2.Service : {};
|
|
828
|
-
let n2 = t3.id || t3["@id"], r2 = re(t3);
|
|
829
|
-
return r2 && r2.id && (e2.Service[r2.id] ? e2.Service[n2] = O$1(e2.Service[n2], r2) : e2.Service[n2] = r2), t3;
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
function k$1(e2) {
|
|
833
|
-
let t3 = JSON.stringify(e2), n2 = 5381, r2 = t3.length;
|
|
834
|
-
for (; r2; ) n2 = n2 * 33 ^ t3.charCodeAt(--r2);
|
|
835
|
-
let i3 = n2 >>> 0, a2 = i3.toString(16);
|
|
836
|
-
return a2.length % 2 ? "0" + a2 : a2;
|
|
837
|
-
}
|
|
838
|
-
function A$1(e2) {
|
|
839
|
-
return (t3) => typeof t3 == "string" ? { id: t3, type: e2 } : t3.id ? t3.type ? t3 : { type: e2, ...t3 } : { id: `vault://${k$1(t3)}`, type: e2, ...t3 };
|
|
840
|
-
}
|
|
841
|
-
function j$1(e2) {
|
|
842
|
-
return (t3) => ({ ...e2, ...t3 });
|
|
843
|
-
}
|
|
844
|
-
function M$1(e2) {
|
|
845
|
-
return Array.isArray(e2) ? e2 : [e2];
|
|
846
|
-
}
|
|
847
|
-
function N$2(e2) {
|
|
848
|
-
return e2.body &&= M$1(e2.body), e2.seeAlso &&= M$1(e2.seeAlso), e2.audience &&= M$1(e2.audience), e2.accessibility &&= M$1(e2.accessibility), e2.motivation &&= M$1(e2.motivation), e2;
|
|
849
|
-
}
|
|
850
|
-
function P$2(e2, { typeHint: n2, partOfTypeHint: r2 } = {}) {
|
|
851
|
-
if (typeof e2 == "string" && (e2 = { id: e2, type: n2 || "unknown" }), n$5(e2)) return typeof e2.source == "string" && (e2.source = { id: e2.source, type: n2 || "unknown" }), e2.source.type === "Canvas" && e2.source.partOf && typeof e2.source.partOf == "string" && (e2.source.partOf = [{ id: e2.source.partOf, type: r2 || "Manifest" }]), e2;
|
|
852
|
-
let i3, [a2, o2] = x$3(e2.id);
|
|
853
|
-
return e2.id = a2, o2 && o2 && (i3 = { type: "FragmentSelector", value: o2 }), { type: "SpecificResource", source: e2, selector: i3 };
|
|
854
|
-
}
|
|
855
|
-
function ae(e2) {
|
|
856
|
-
let t3 = Object.assign({}, e2);
|
|
857
|
-
return e2 && e2.items && (t3.items = e2.items.map((e3) => typeof e3 == "string" || e3.type === "Canvas" ? P$2(e3) : e3)), t3;
|
|
858
|
-
}
|
|
859
|
-
function oe(e2) {
|
|
860
|
-
let t3 = Object.assign({}, e2);
|
|
861
|
-
return t3.start ? (t3.start = P$2(t3.start, { typeHint: "Canvas" }), t3) : e2;
|
|
862
|
-
}
|
|
863
|
-
function F$2(e2) {
|
|
864
|
-
let t3 = Object.assign({}, e2);
|
|
865
|
-
return t3.target ? (t3.target = C$2(t3.target, { typeHint: "Canvas" }), t3) : e2;
|
|
866
|
-
}
|
|
867
|
-
function I$2(e2) {
|
|
868
|
-
return e2;
|
|
869
|
-
}
|
|
870
|
-
function L$2(e2) {
|
|
871
|
-
return e2.items === void 0 && (e2[s$1] = !0), e2;
|
|
872
|
-
}
|
|
873
|
-
function se(t3) {
|
|
874
|
-
let r2 = Y$3(t3), i3 = T$2(), a2 = {}, o2 = te(i3, r2), s2 = ne(a2), c2 = new o$4({ collection: [L$2, j$1(g$3), s2("Collection"), o2("Collection")], manifest: [L$2, j$1(_$3), oe, s2("Manifest"), o2("Manifest")], canvas: [j$1(h$2), s2("Canvas"), o2("Canvas")], annotationPage: [L$2, A$1("AnnotationPage"), j$1(m$1), s2("AnnotationPage"), o2("AnnotationPage")], annotation: [A$1("Annotation"), N$2, F$2, s2("Annotation"), o2("Annotation")], contentResource: [A$1("ContentResource"), s2("ContentResource"), o2("ContentResource")], range: [j$1(v$3), ae, s2("Range", "Canvas"), o2("Range", "Canvas")], agent: [j$1(y$3), s2("Agent"), o2("Agent")], specificResource: [I$2], service: [ie(i3)] }), l2 = c2.traverseUnknown(r2);
|
|
875
|
-
return { entities: i3, resource: l2, mapping: a2 };
|
|
876
|
-
}
|
|
877
|
-
function R$2(e2) {
|
|
878
|
-
let t3 = {};
|
|
879
|
-
for (let [n2, r2] of e2) {
|
|
880
|
-
if (n2 === l$1 && r2 !== c$1) return r2;
|
|
881
|
-
r2 !== c$1 && r2 != null && (t3[n2] = r2);
|
|
882
|
-
}
|
|
883
|
-
return t3;
|
|
884
|
-
}
|
|
885
|
-
function ce(e2, t3, n2) {
|
|
886
|
-
if (!t3.type || !t3.id) throw Error("Unknown entity");
|
|
887
|
-
if (!n2[t3.type]) throw Error(`Serializer not found for ${t3.type}`);
|
|
888
|
-
function r2(i3, a2, o2 = 0) {
|
|
889
|
-
let s2 = n2[i3.type];
|
|
890
|
-
if (!s2) return c$1;
|
|
891
|
-
if (o2 > 20) throw Error("Circular reference: " + i3.id + " " + i3.type);
|
|
892
|
-
let [l2, u2] = p$1(e2, i3.type ? i3 : i3.id, a2) || (i3.id && i3.type ? i3 : null);
|
|
893
|
-
if (!l2) return c$1;
|
|
894
|
-
let d2 = s2(l2, e2, { parent: a2, isTopLevel: t3.id === i3.id, fullResource: u2 }), f2 = d2.next();
|
|
895
|
-
for (; !f2.done; ) {
|
|
896
|
-
let e3 = f2.value, t4 = c$1;
|
|
897
|
-
if (e3) if (Array.isArray(e3)) {
|
|
898
|
-
let n3 = [];
|
|
899
|
-
for (let t5 of e3) n3.push(r2(t5, i3, o2 + 1));
|
|
900
|
-
t4 = n3;
|
|
901
|
-
} else t4 = r2(e3, i3, o2 + 1);
|
|
902
|
-
f2 = d2.next(t4);
|
|
903
|
-
}
|
|
904
|
-
return f2.value === c$1 ? c$1 : R$2(f2.value);
|
|
905
|
-
}
|
|
906
|
-
return r2(t3);
|
|
907
|
-
}
|
|
908
|
-
function z$2(e2, { allowSourceString: t3 = !0, allowString: n2 = !1, allowedStringType: r2 } = {}) {
|
|
909
|
-
let i3 = (e3) => {
|
|
910
|
-
if (t3 && e3 && e3.source && typeof e3.source != "string") {
|
|
911
|
-
let t4 = Object.keys(e3.source);
|
|
912
|
-
if (e3.source.id && e3.source.type && t4.length === 2) return { ...e3, source: e3.source.id };
|
|
913
|
-
}
|
|
914
|
-
return e3;
|
|
915
|
-
};
|
|
916
|
-
if (e2) {
|
|
917
|
-
if (e2.source && e2.source.partOf) return i3(e2);
|
|
918
|
-
let t4 = Object.keys(e2);
|
|
919
|
-
if (t4.length === 2 && e2.type && e2.source || t4.length === 3 && e2.type && e2.source && t4.indexOf("selector") !== -1 && !e2.selector) return n2 && (!r2 || r2 === e2.source.type) ? e2.source.id : e2.source.type === "ContentResource" ? { type: "SpecificResource", source: e2.source.id } : e2.source;
|
|
920
|
-
if (e2.selector && !Array.isArray(e2.selector) && typeof e2.selector != "string" && e2.selector.type === "FragmentSelector") {
|
|
921
|
-
let t5 = `${e2.source.id}#${e2.selector.value}`;
|
|
922
|
-
return n2 ? t5 : { id: t5, type: e2.source.type };
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
return i3(e2);
|
|
926
|
-
}
|
|
927
|
-
function B$2(e2) {
|
|
928
|
-
if (!e2) return;
|
|
929
|
-
let t3 = Object.keys(e2);
|
|
930
|
-
if (t3.length !== 0) {
|
|
931
|
-
if (t3.length === 1) {
|
|
932
|
-
let n2 = t3[0];
|
|
933
|
-
if (!n2) return "";
|
|
934
|
-
let r2 = (e2[n2] || []).join("");
|
|
935
|
-
return n2 === "@none" || n2 === "none" || n2 === "en" ? r2 : { "@language": n2, "@value": r2 };
|
|
936
|
-
}
|
|
937
|
-
return t3.map((t4) => ({ "@language": t4, "@value": (e2[t4] || []).join("") }));
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
function V$2(e2) {
|
|
941
|
-
return Array.isArray(e2) ? e2.map((e3) => V$2(e3)) : typeof e2 == "string" ? e2 : e2.type && e2.type === "Canvas" ? e2.id : e2;
|
|
942
|
-
}
|
|
943
|
-
function H$3(e2, t3 = !1) {
|
|
944
|
-
if (e2) return e2.length > 1 && !t3 ? e2 : e2[0] || void 0;
|
|
945
|
-
}
|
|
946
|
-
function U$3(e2) {
|
|
947
|
-
if (e2) {
|
|
948
|
-
if (typeof e2 == "string") return { "@id": e2 };
|
|
949
|
-
if ("@id" in e2) {
|
|
950
|
-
let t3 = { ...e2 };
|
|
951
|
-
return delete t3["@type"], t3;
|
|
952
|
-
}
|
|
953
|
-
return { "@context": "http://iiif.io/api/image/2/context.json", "@id": e2.id, profile: `http://iiif.io/api/image/2/profiles/${e2.profile}.json` };
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
function W$2(e2, t3) {
|
|
957
|
-
return [["@id", e2.id], ["@type", t3], ["format", e2.format], ["height", e2.height], ["width", e2.width], ["viewingDirection", e2.viewingDirection === "left-to-right" ? void 0 : e2.viewingDirection], ["license", e2.license ? e2.license : void 0]];
|
|
958
|
-
}
|
|
959
|
-
function* G$1(e2) {
|
|
960
|
-
let t3 = e2.provider ? yield e2.provider[0] : void 0;
|
|
961
|
-
return [["label", B$2(e2.label)], ["metadata", e2.metadata && e2.metadata.length ? e2.metadata.map((e3) => ({ label: B$2(e3.label) || "", value: B$2(e3.value) || "" })) : void 0], ["description", B$2(e2.summary)], ["thumbnail", H$3(yield e2.thumbnail)], ["navDate", e2.navDate], ["logo", t3 ? H$3(t3.logo) : void 0], ["homepage", t3 ? t3.homepage : void 0], ["attribution", e2.requiredStatement ? B$2(e2.requiredStatement.value) : void 0]];
|
|
962
|
-
}
|
|
963
|
-
function* K$1(e2) {
|
|
964
|
-
let t3 = e2.start && e2.start.type && e2.start.type === "SpecificResource" ? z$2(e2.start) : e2.start;
|
|
965
|
-
return [["seeAlso", H$3(yield e2.seeAlso)], ["service", H$3((e2.service || []).map(U$3))], ["rendering", H$3(yield e2.rendering)], ["startCanvas", t3 ? t3.id : void 0]];
|
|
966
|
-
}
|
|
967
|
-
function le(e2) {
|
|
968
|
-
return e2.type === "SpecificResource";
|
|
969
|
-
}
|
|
970
|
-
function ue(e2) {
|
|
971
|
-
return e2 && e2.type === "FragmentSelector";
|
|
972
|
-
}
|
|
973
|
-
function de$1(e2) {
|
|
974
|
-
if (e2 && le(e2)) {
|
|
975
|
-
let t3 = e2.id, n2 = e2.selector ? Array.isArray(e2.selector) ? e2.selector[0] : e2.selector : void 0;
|
|
976
|
-
return ue(n2) && (t3 += "#" + n2.value), t3;
|
|
977
|
-
}
|
|
978
|
-
return e2?.id;
|
|
979
|
-
}
|
|
980
|
-
const fe = { Manifest: function* (e2, t3, { isTopLevel: n2 }) {
|
|
981
|
-
return [...n2 ? [["@context", "http://iiif.io/api/presentation/2/context.json"]] : [], ...W$2(e2, "sc:Manifest"), ...yield* G$1(e2), ...yield* K$1(e2), ["sequences", [{ "@id": `${e2.id}/sequence0`, "@type": "sc:Sequence", canvases: yield e2.items }]], ["structures", yield e2.structures]];
|
|
982
|
-
}, Canvas: function* (e2) {
|
|
983
|
-
let t3 = yield e2.items, n2 = t3[0];
|
|
984
|
-
return [...W$2(e2, "sc:Canvas"), ...yield* G$1(e2), ...yield* K$1(e2), ["images", n2 ? [n2.resources] : void 0], ["annotations", e2.annotations && e2.annotations.length ? H$3(yield e2.annotations) : void 0]];
|
|
985
|
-
}, AnnotationPage: function* (e2) {
|
|
986
|
-
return [...W$2(e2, "sc:AnnotationList"), ...yield* G$1(e2), ["resources", e2.items && e2.items.length ? H$3(yield e2.items) : void 0]];
|
|
987
|
-
}, Annotation: function* (e2) {
|
|
988
|
-
return [["@id", e2.id], ["@type", "oa:Annotation"], ["motivation", "sc:painting"], ["on", V$2(e2.target)], ["resource", H$3(yield e2.body, !0)]];
|
|
989
|
-
}, ContentResource: function* (e2) {
|
|
990
|
-
switch (e2.type) {
|
|
991
|
-
case "Image":
|
|
992
|
-
return [...W$2(e2, "dctypes:Image"), ...yield* G$1(e2), ...yield* K$1(e2)];
|
|
993
|
-
case "Text":
|
|
994
|
-
case "Dataset":
|
|
995
|
-
default:
|
|
996
|
-
return [...W$2(e2, void 0), ...yield* G$1(e2)];
|
|
997
|
-
}
|
|
998
|
-
}, AnnotationCollection: function* (e2) {
|
|
999
|
-
return [["@id", e2.id], ["@type", "sc:Layer"], ["label", B$2(e2.label)]];
|
|
1000
|
-
}, Collection: function* (e2) {
|
|
1001
|
-
return [...W$2(e2, "sc:Collection"), ...yield* G$1(e2), ...yield* K$1(e2), ["members", yield* e2.items]];
|
|
1002
|
-
}, Range: function* (e2) {
|
|
1003
|
-
let t3 = [], n2 = [];
|
|
1004
|
-
if (e2.items) for (let r2 of e2.items) {
|
|
1005
|
-
let i3 = r2.type === "SpecificResource" ? r2.source : r2;
|
|
1006
|
-
if (i3) {
|
|
1007
|
-
let a2 = yield i3;
|
|
1008
|
-
t3.push({ "@id": de$1(r2), "@type": i3.type, label: a2 ? a2.label : void 0, within: e2.id }), i3.type === "Canvas" && n2.push(i3.id);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return [...W$2(e2, "sc:Range"), ...yield* G$1(e2), ...yield* K$1(e2), ["canvases", n2.length === t3.length ? n2 : void 0], ["members", n2.length === t3.length ? void 0 : t3]];
|
|
1012
|
-
} };
|
|
1013
|
-
function q$2(e2) {
|
|
1014
|
-
return [["id", e2.id?.startsWith("vault://") ? void 0 : e2.id], ["type", e2.type], ["format", e2.format], ["profile", e2.profile], ["height", e2.height || void 0], ["width", e2.width || void 0], ["duration", e2.duration || void 0], ["viewingDirection", e2.viewingDirection === "left-to-right" ? void 0 : e2.viewingDirection], ["behavior", e2.behavior && e2.behavior.length ? e2.behavior : void 0], ["timeMode", e2.timeMode], ["motivation", Array.isArray(e2.motivation) ? e2.motivation[0] : e2.motivation], [a$1, c$1]];
|
|
1015
|
-
}
|
|
1016
|
-
function J$2(e2) {
|
|
1017
|
-
if (e2 === c$1 || !e2 || e2.length === 0) return;
|
|
1018
|
-
let t3 = e2.filter((e3) => e3 !== c$1);
|
|
1019
|
-
if (t3.length !== 0) return t3;
|
|
1020
|
-
}
|
|
1021
|
-
function Y$2(e2) {
|
|
1022
|
-
if (e2 && e2.type && e2.type === "ImageService2") {
|
|
1023
|
-
let { id: t3, type: n2, profile: r2, ...i3 } = e2, a2 = typeof r2 == "string" ? r2 : Array.isArray(r2) ? r2.find((e3) => typeof e3 == "string") : "";
|
|
1024
|
-
return { "@id": t3, "@type": n2, profile: a2 ? a2.startsWith("http") ? a2 : `http://iiif.io/api/image/2/${a2}.json` : "http://iiif.io/api/image/2/level0.json", ...i3 };
|
|
1025
|
-
}
|
|
1026
|
-
return e2;
|
|
1027
|
-
}
|
|
1028
|
-
function X$1(e2) {
|
|
1029
|
-
if (Array.isArray(e2) || (e2 = e2 ? [e2] : []), !(!e2 || e2.length === 0)) return e2.map(Y$2);
|
|
1030
|
-
}
|
|
1031
|
-
function* Z$1(e2) {
|
|
1032
|
-
return [["label", e2.label], ["metadata", J$2(e2.metadata)], ["summary", e2.summary], ["requiredStatement", e2.requiredStatement], ["rights", Array.isArray(e2.rights) ? e2.rights[0] || void 0 : e2.rights || void 0], ["navDate", e2.navDate], ["language", e2.language], ["thumbnail", J$2(yield e2.thumbnail)], ["placeholderCanvas", yield e2.placeholderCanvas], ["accompanyingCanvas", yield e2.accompanyingCanvas], ["provider", J$2(yield e2.provider)]];
|
|
1033
|
-
}
|
|
1034
|
-
function* Q$1(e2, t3) {
|
|
1035
|
-
let n2 = [];
|
|
1036
|
-
for (let r2 of e2.partOf || [])
|
|
1037
|
-
r2.type === "Manifest" && t3.type === "Manifest" || n2.push(yield r2);
|
|
1038
|
-
return [["seeAlso", J$2(yield e2.seeAlso)], ["service", J$2(X$1(e2.service))], ["services", J$2(X$1(e2.services))], ["rendering", J$2(yield e2.rendering)], ["supplementary", J$2(yield e2.supplementary)], ["homepage", J$2(yield e2.homepage)], ["logo", J$2(yield e2.logo)], ["partOf", J$2(n2)], ["start", e2.start ? z$2(e2.start) : e2.start]];
|
|
1039
|
-
}
|
|
1040
|
-
const pe = { Manifest: function* (e2, t3, { isTopLevel: n2 }) {
|
|
1041
|
-
if (!n2) return [...q$2(e2), ...yield* Z$1(e2), ["navPlace", e2.navPlace]];
|
|
1042
|
-
let r2 = "http://iiif.io/api/presentation/3/context.json";
|
|
1043
|
-
return (e2.navPlace || $$1(e2)) && (r2 = ["http://iiif.io/api/presentation/3/context.json", "http://iiif.io/api/extension/navplace/context.json"]), [["@context", e2["@context"] ? e2["@context"] : r2], ...q$2(e2), ...yield* Z$1(e2), ...yield* Q$1(e2), ["items", yield e2.items], ["structures", J$2(yield e2.structures)], ["annotations", J$2(yield e2.annotations)], ["navPlace", e2.navPlace]];
|
|
1044
|
-
}, Canvas: function* (e2, t3, { parent: n2 }) {
|
|
1045
|
-
return n2 && n2.type !== "Manifest" && n2.type !== "Canvas" ? [["id", e2.id]] : [...q$2(e2), ...yield* Z$1(e2), ...yield* Q$1(e2, n2), ["items", yield e2.items], ["annotations", J$2(yield e2.annotations)], ["navPlace", e2.navPlace]];
|
|
1046
|
-
}, Agent: function* (e2) {
|
|
1047
|
-
return [["id", e2.id], ["type", "Agent"], ["label", e2.label], ...yield* Q$1(e2)];
|
|
1048
|
-
}, AnnotationPage: function* (e2) {
|
|
1049
|
-
let t3 = Object.entries(e2).map(([e3, t4]) => [e3, Array.isArray(t4) ? J$2(t4) : t4]).filter(([e3, t4]) => e3 !== "items" && e3 !== "id" && e3 !== a$1 && e3 !== o$1 && e3 !== s$1), n2 = yield e2.items;
|
|
1050
|
-
return [["id", e2.id?.startsWith("vault://") ? void 0 : e2.id], ...t3, ...yield* Q$1(e2), ["items", n2.length || e2[s$1] === !1 ? n2 : c$1]];
|
|
1051
|
-
}, Service: function* (e2) {
|
|
1052
|
-
return [[l$1, Y$2(e2)]];
|
|
1053
|
-
}, Annotation: function* (e2) {
|
|
1054
|
-
let n2 = Object.entries(e2).map(([e3, t3]) => e3 === "motivation" ? [e3, Array.isArray(t3) ? t3[0] : t3] : e3 === "target" ? [e3, z$2(t3, { allowString: !0, allowSourceString: !0, allowedStringType: "Canvas" })] : [e3, Array.isArray(t3) ? J$2(t3) : t3]).filter(([e3]) => e3 !== "body" && e3 !== a$1 && e3 !== s$1), r2;
|
|
1055
|
-
if (Array.isArray(e2.body)) {
|
|
1056
|
-
let n3 = [];
|
|
1057
|
-
for (let r3 of e2.body) if (r3 && n$5(r3)) {
|
|
1058
|
-
let e3 = { ...r3 };
|
|
1059
|
-
r3.source.type === "Canvas" ? e3.source = r3.source : e3.source = yield r3.source, n3.push(z$2(e3, { allowSourceString: !0 }));
|
|
1060
|
-
} else n3.push(yield r3);
|
|
1061
|
-
r2 = n3;
|
|
1062
|
-
} else e2.body && n$5(e2.body) ? (r2 = { ...e2.body }, r2.source = yield e2.body.source) : r2 = yield e2.body;
|
|
1063
|
-
return [...n2, ...yield* Z$1(e2), ...yield* Q$1(e2), ["body", r2.length === 1 ? r2[0] : r2]];
|
|
1064
|
-
}, ContentResource: function* (e2) {
|
|
1065
|
-
return me([...q$2(e2), ...yield* Z$1(e2), ...yield* Q$1(e2), ["annotations", J$2(yield e2.annotations)], ["items", J$2(yield e2.items)]], e2);
|
|
1066
|
-
}, AnnotationCollection: function* (e2) {
|
|
1067
|
-
return [["id", e2.id], ["type", "AnnotationCollection"], ["label", e2.label]];
|
|
1068
|
-
}, Collection: function* (e2, t3, { isTopLevel: n2 }) {
|
|
1069
|
-
if (n2) {
|
|
1070
|
-
let t4 = "http://iiif.io/api/presentation/3/context.json";
|
|
1071
|
-
return (e2.navPlace || $$1(e2)) && (t4 = ["http://iiif.io/api/extension/navplace/context.json", "http://iiif.io/api/presentation/3/context.json"]), [["@context", t4], ...q$2(e2), ...yield* Z$1(e2), ...yield* Q$1(e2), ["items", J$2(yield e2.items)], ["navPlace", e2.navPlace]];
|
|
1072
|
-
}
|
|
1073
|
-
return [...q$2(e2), ...yield* Z$1(e2), ["navPlace", e2.navPlace]];
|
|
1074
|
-
}, Range: function* (e2) {
|
|
1075
|
-
let t3 = [];
|
|
1076
|
-
for (let n2 of e2.items) n2.type === "Range" ? t3.push(yield n2) : n2 && n2.type === "SpecificResource" ? t3.push(z$2(n2)) : t3.push(n2);
|
|
1077
|
-
return [...q$2(e2), ...yield* Z$1(e2), ...yield* Q$1(e2), ["items", t3], ["annotations", J$2(yield e2.annotations)], ["navPlace", e2.navPlace]];
|
|
1078
|
-
} };
|
|
1079
|
-
function me(e2, t3) {
|
|
1080
|
-
let n2 = Object.keys(t3), r2 = e2.map(([e3]) => e3);
|
|
1081
|
-
for (let i3 of n2)
|
|
1082
|
-
i3 === a$1 || i3 === s$1 || r2.indexOf(i3) === -1 && t3[i3] !== void 0 && e2.push([i3, t3[i3]]);
|
|
1083
|
-
return e2;
|
|
1084
|
-
}
|
|
1085
|
-
function $$1(e2) {
|
|
1086
|
-
if (!e2.items || !Array.isArray(e2.items)) return !1;
|
|
1087
|
-
for (let t3 of e2.items) if (t3.navPlace) return !0;
|
|
1088
|
-
return !1;
|
|
1089
|
-
}
|
|
1090
|
-
function n$3(t3, n2) {
|
|
1091
|
-
return n$5(t3) ? typeof t3.source == "string" ? { ...t3, source: n2 } : { ...t3, source: { ...t3.source || {}, id: n2 } } : { ...t3, id: n2 };
|
|
1092
|
-
}
|
|
1093
|
-
const e$2 = function(e2) {
|
|
1094
|
-
return function() {
|
|
1095
|
-
let t3 = { type: e2, getType: () => e2, toString: () => e2 };
|
|
1096
|
-
return (e3, n2) => ({ ...t3, ...e3 !== void 0 && { payload: e3 }, ...n2 !== void 0 && { meta: n2 } });
|
|
1097
|
-
};
|
|
1098
|
-
}, t$3 = "@iiif/IMPORT_ENTITIES", n$2 = "@iiif/MODIFY_ENTITY_FIELD", r$1 = "@iiif/REORDER_ENTITY_FIELD", i$1 = "@iiif/MOVE_ENTITY", a = "@iiif/MOVE_ENTITIES", o = "@iiif/ADD_REFERENCE", s = "@iiif/UPDATE_REFERENCE", c = "@iiif/CHANGE_REFERENCE_IDENTIFIER", l = "@iiif/REMOVE_REFERENCE", u = "@iiif/ADD_METADATA", d = "@iiif/REMOVE_METADATA", f = "@iiif/UPDATE_METADATA", p = "@iiif/REORDER_METADATA", m = e$2(t$3)(), h$1 = e$2(n$2)(), g$2 = e$2(r$1)(), _$2 = e$2(i$1)(), v$2 = e$2(a)(), y$2 = e$2(o)(), b$2 = e$2(l)(), x$2 = e$2(s)(), S$1 = e$2(c)(), C$1 = e$2(u)(), w$1 = e$2(f)(), T$1 = e$2(d)(), E$1 = e$2(p)(), D = { importEntities: m, modifyEntityField: h$1, reorderEntityField: g$2, addReference: y$2, removeReference: b$2, updateReference: x$2, changeReferenceIdentifier: S$1, addMetadata: C$1, removeMetadata: T$1, updateMetadata: w$1, reorderMetadata: E$1, moveEntity: _$2, moveEntities: v$2 }, O = "@iiif/ADD_MAPPING", k = "@iiif/ADD_MAPPINGS", A = e$2(O)(), j = e$2(k)(), N$1 = "RESOURCE_ERROR", P$1 = "RESOURCE_LOADING", F$1 = "RESOURCE_READY", I$1 = "@iiif/REQUEST_RESOURCE", L$1 = "@iiif/REQUEST_ERROR", R$1 = "@iiif/REQUEST_MISMATCH", z$1 = "@iiif/REQUEST_COMPLETE", B$1 = "@iiif/REQUEST_OFFLINE_RESOURCE", V$1 = e$2(I$1)(), H$2 = e$2(L$1)(), U$2 = e$2(R$1)(), W$1 = e$2(z$1)(), q$1 = "@iiif/BATCH", J$1 = "@iiif/BATCH_IMPORT", Y$1 = e$2(q$1)(), t$2 = "@iiif/SET_META_VALUE", n$1 = "@iiif/SET_META_VALUE_DYNAMIC", r = "@iiif/UNSET_META_VALUE", i2 = { setMetaValue: e$2(t$2)(), setMetaValueDynamic: e$2(n$1)(), unsetMetaValue: e$2(r)() }, h = (n2, r2) => {
|
|
1099
|
-
let { entities: s2, resource: c2, mapping: l2 } = se(r2);
|
|
1100
|
-
if (c2.id === void 0) return [H$2({ id: n2, message: "ID is not defined in resource." })];
|
|
1101
|
-
let d2 = [m({ entities: s2 }), j({ mapping: l2 })];
|
|
1102
|
-
return c2.id !== n2 && (d2.push(A({ id: n2, type: c2.type })), d2.push(U$2({ requestId: n2, actualId: c2.id }))), d2.push(W$1({ id: n2 })), d2;
|
|
1103
|
-
}, g$1 = Number.isNaN || function(e2) {
|
|
1104
|
-
return typeof e2 == "number" && e2 !== e2;
|
|
1105
|
-
};
|
|
1106
|
-
function _$1(e2, t3) {
|
|
1107
|
-
return !!(e2 === t3 || g$1(e2) && g$1(t3));
|
|
1108
|
-
}
|
|
1109
|
-
function v$1(e2, t3) {
|
|
1110
|
-
if (!Array.isArray(e2) || !Array.isArray(t3)) return e2 === t3;
|
|
1111
|
-
if (e2.length !== t3.length) return !1;
|
|
1112
|
-
for (let n2 = 0; n2 < e2.length; n2++) if (!_$1(e2[n2], t3[n2])) return !1;
|
|
1113
|
-
return !0;
|
|
1114
|
-
}
|
|
1115
|
-
function y$1(e2, t3, n2) {
|
|
1116
|
-
let r2 = e2.iiif.requests[t3], i3 = e2.iiif.mapping[t3];
|
|
1117
|
-
if (!i3 || !e2.iiif.entities[i3][r2.resourceUri]) return;
|
|
1118
|
-
let a2 = e2.iiif.entities[i3][r2.resourceUri];
|
|
1119
|
-
return a2 && a2[a$1] ? f$1(a2, a2[a$1].find((e3) => e3[o$1] === a2.id)) : a2;
|
|
1120
|
-
}
|
|
1121
|
-
function b$1(e2) {
|
|
1122
|
-
return e2 && typeof e2.then == "function";
|
|
1123
|
-
}
|
|
1124
|
-
function x$1(e2, t3, { waitTimeout: i3 = 30 } = {}) {
|
|
1125
|
-
return (o2, u2, d2) => {
|
|
1126
|
-
let f2 = e2.getStore(), p2 = f2.getState(), m2 = p2.iiif.requests[o2];
|
|
1127
|
-
if (m2) {
|
|
1128
|
-
if (m2.loadingState === F$1) {
|
|
1129
|
-
let e3 = y$1(p2, o2);
|
|
1130
|
-
if (e3) return e3;
|
|
1131
|
-
}
|
|
1132
|
-
switch (m2.loadingState) {
|
|
1133
|
-
case N$1:
|
|
1134
|
-
break;
|
|
1135
|
-
case P$1:
|
|
1136
|
-
return (async () => {
|
|
1137
|
-
let e3, t4 = !1;
|
|
1138
|
-
try {
|
|
1139
|
-
let n2 = await Promise.race([new Promise((n3, i4) => {
|
|
1140
|
-
t4 || (e3 = f2.subscribe(() => {
|
|
1141
|
-
let e4 = f2.getState();
|
|
1142
|
-
if (e4.iiif.requests[o2].loadingState === N$1) {
|
|
1143
|
-
i4();
|
|
1144
|
-
return;
|
|
1145
|
-
}
|
|
1146
|
-
if (e4.iiif.requests[o2].loadingState === F$1) {
|
|
1147
|
-
let t5 = y$1(e4, o2);
|
|
1148
|
-
t5 ? n3(t5) : i4();
|
|
1149
|
-
}
|
|
1150
|
-
}));
|
|
1151
|
-
}), new Promise((e4, n3) => setTimeout(() => {
|
|
1152
|
-
t4 = !0, n3();
|
|
1153
|
-
}, i3 * 60 * 1e3))]);
|
|
1154
|
-
if (e3 && e3(), n2) return n2;
|
|
1155
|
-
} catch {
|
|
1156
|
-
e3 && e3();
|
|
1157
|
-
}
|
|
1158
|
-
})();
|
|
1159
|
-
}
|
|
1160
|
-
}
|
|
1161
|
-
e2.dispatch(V$1({ id: o2 }));
|
|
1162
|
-
let g2 = (t4) => {
|
|
1163
|
-
if (!t4) return;
|
|
1164
|
-
!t4.id && !t4["@id"] && (t4["@type"] && (t4["@id"] = o2), t4.id = o2);
|
|
1165
|
-
let n2 = h(o2, t4);
|
|
1166
|
-
return e2.dispatch(Y$1({ actions: n2 })), y$1(f2.getState(), o2);
|
|
1167
|
-
};
|
|
1168
|
-
try {
|
|
1169
|
-
let n2 = t3(o2, u2);
|
|
1170
|
-
return b$1(n2) ? (async () => {
|
|
1171
|
-
try {
|
|
1172
|
-
let e3 = await n2;
|
|
1173
|
-
return d2 && (e3 = d2(e3)), g2(e3);
|
|
1174
|
-
} catch (t4) {
|
|
1175
|
-
throw e2.dispatch(H$2({ id: o2, message: t4.toString() })), t4;
|
|
1176
|
-
}
|
|
1177
|
-
})() : g2(d2 ? d2(n2) : n2);
|
|
1178
|
-
} catch (t4) {
|
|
1179
|
-
throw e2.dispatch(H$2({ id: o2, message: t4.toString() })), t4;
|
|
1180
|
-
}
|
|
1181
|
-
};
|
|
1182
|
-
}
|
|
1183
|
-
function e$1() {
|
|
1184
|
-
return { Collection: {}, Manifest: {}, Canvas: {}, AnnotationPage: {}, AnnotationCollection: {}, Annotation: {}, ContentResource: {}, Range: {}, Service: {}, Selector: {}, Agent: {} };
|
|
1185
|
-
}
|
|
1186
|
-
const __vite_import_meta_env__ = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 }, M = (e2, t22) => (n2, r2, i22) => (i22.dispatch = (t3) => (n2((n3) => e2(n3, t3), !1, t3), t3), i22.dispatchFromDevtools = !0, { dispatch: (...e3) => i22.dispatch(...e3), ...t22 }), N = /* @__PURE__ */ new Map(), P = (e2) => {
|
|
1187
|
-
let t22 = N.get(e2);
|
|
1188
|
-
return t22 ? Object.fromEntries(Object.entries(t22.stores).map(([e3, t3]) => [e3, t3.getState()])) : {};
|
|
1189
|
-
}, F = (e2, t22, n2) => {
|
|
1190
|
-
if (e2 === void 0) return { type: "untracked", connection: t22.connect(n2) };
|
|
1191
|
-
let r2 = N.get(n2.name);
|
|
1192
|
-
if (r2) return { type: "tracked", store: e2, ...r2 };
|
|
1193
|
-
let i22 = { connection: t22.connect(n2), stores: {} };
|
|
1194
|
-
return N.set(n2.name, i22), { type: "tracked", store: e2, ...i22 };
|
|
1195
|
-
}, I = (e2, t22 = {}) => (n2, r2, i22) => {
|
|
1196
|
-
let { enabled: a2, anonymousActionType: o2, store: s2, ...c2 } = t22, l2;
|
|
1197
|
-
try {
|
|
1198
|
-
l2 = (a2 ?? (__vite_import_meta_env__ ? "production" : void 0) !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
1199
|
-
} catch {
|
|
1200
|
-
}
|
|
1201
|
-
if (!l2) return (__vite_import_meta_env__ ? "production" : void 0) !== "production" && a2 && console.warn("[zustand devtools middleware] Please install/enable Redux devtools extension"), e2(n2, r2, i22);
|
|
1202
|
-
let { connection: u2, ...d2 } = F(s2, l2, c2), f2 = !0;
|
|
1203
|
-
i22.setState = (e3, t3, a3) => {
|
|
1204
|
-
let l3 = n2(e3, t3);
|
|
1205
|
-
if (!f2) return l3;
|
|
1206
|
-
let d3 = a3 === void 0 ? { type: o2 || "anonymous" } : typeof a3 == "string" ? { type: a3 } : a3;
|
|
1207
|
-
return s2 === void 0 ? (u2?.send(d3, r2()), l3) : (u2?.send({ ...d3, type: `${s2}/${d3.type}` }, { ...P(c2.name), [s2]: i22.getState() }), l3);
|
|
1208
|
-
};
|
|
1209
|
-
let p2 = (...e3) => {
|
|
1210
|
-
let t3 = f2;
|
|
1211
|
-
f2 = !1, n2(...e3), f2 = t3;
|
|
1212
|
-
}, m2 = e2(i22.setState, r2, i22);
|
|
1213
|
-
if (d2.type === "untracked" ? u2?.init(m2) : (d2.stores[d2.store] = i22, u2?.init(Object.fromEntries(Object.entries(d2.stores).map(([e3, t3]) => [e3, e3 === d2.store ? m2 : t3.getState()])))), i22.dispatchFromDevtools && typeof i22.dispatch == "function") {
|
|
1214
|
-
let e3 = !1, t3 = i22.dispatch;
|
|
1215
|
-
i22.dispatch = (...n3) => {
|
|
1216
|
-
(__vite_import_meta_env__ ? "production" : void 0) !== "production" && n3[0].type === "__setState" && !e3 && (console.warn('[zustand devtools middleware] "__setState" action type is reserved to set state from the devtools. Avoid using it.'), e3 = !0), t3(...n3);
|
|
1217
|
-
};
|
|
1218
|
-
}
|
|
1219
|
-
return u2.subscribe((e3) => {
|
|
1220
|
-
switch (e3.type) {
|
|
1221
|
-
case "ACTION":
|
|
1222
|
-
if (typeof e3.payload != "string") {
|
|
1223
|
-
console.error("[zustand devtools middleware] Unsupported action format");
|
|
1224
|
-
return;
|
|
1225
|
-
}
|
|
1226
|
-
return L(e3.payload, (e4) => {
|
|
1227
|
-
if (e4.type === "__setState") {
|
|
1228
|
-
if (s2 === void 0) {
|
|
1229
|
-
p2(e4.state);
|
|
1230
|
-
return;
|
|
1231
|
-
}
|
|
1232
|
-
Object.keys(e4.state).length !== 1 && console.error(`
|
|
1233
|
-
[zustand devtools middleware] Unsupported __setState action format.
|
|
1234
|
-
When using 'store' option in devtools(), the 'state' should have only one key, which is a value of 'store' that was passed in devtools(),
|
|
1235
|
-
and value of this only key should be a state object. Example: { "type": "__setState", "state": { "abc123Store": { "foo": "bar" } } }
|
|
1236
|
-
`);
|
|
1237
|
-
let t3 = e4.state[s2];
|
|
1238
|
-
if (t3 == null) return;
|
|
1239
|
-
JSON.stringify(i22.getState()) !== JSON.stringify(t3) && p2(t3);
|
|
1240
|
-
return;
|
|
1241
|
-
}
|
|
1242
|
-
i22.dispatchFromDevtools && typeof i22.dispatch == "function" && i22.dispatch(e4);
|
|
1243
|
-
});
|
|
1244
|
-
case "DISPATCH":
|
|
1245
|
-
switch (e3.payload.type) {
|
|
1246
|
-
case "RESET":
|
|
1247
|
-
return p2(m2), s2 === void 0 ? u2?.init(i22.getState()) : u2?.init(P(c2.name));
|
|
1248
|
-
case "COMMIT":
|
|
1249
|
-
if (s2 === void 0) {
|
|
1250
|
-
u2?.init(i22.getState());
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
return u2?.init(P(c2.name));
|
|
1254
|
-
case "ROLLBACK":
|
|
1255
|
-
return L(e3.state, (e4) => {
|
|
1256
|
-
if (s2 === void 0) {
|
|
1257
|
-
p2(e4), u2?.init(i22.getState());
|
|
1258
|
-
return;
|
|
1259
|
-
}
|
|
1260
|
-
p2(e4[s2]), u2?.init(P(c2.name));
|
|
1261
|
-
});
|
|
1262
|
-
case "JUMP_TO_STATE":
|
|
1263
|
-
case "JUMP_TO_ACTION":
|
|
1264
|
-
return L(e3.state, (e4) => {
|
|
1265
|
-
if (s2 === void 0) {
|
|
1266
|
-
p2(e4);
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
JSON.stringify(i22.getState()) !== JSON.stringify(e4[s2]) && p2(e4[s2]);
|
|
1270
|
-
});
|
|
1271
|
-
case "IMPORT_STATE": {
|
|
1272
|
-
let { nextLiftedState: t3 } = e3.payload, n3 = t3.computedStates.slice(-1)[0]?.state;
|
|
1273
|
-
if (!n3) return;
|
|
1274
|
-
p2(s2 === void 0 ? n3 : n3[s2]), u2?.send(null, t3);
|
|
1275
|
-
return;
|
|
1276
|
-
}
|
|
1277
|
-
case "PAUSE_RECORDING":
|
|
1278
|
-
return f2 = !f2;
|
|
1279
|
-
}
|
|
1280
|
-
return;
|
|
1281
|
-
}
|
|
1282
|
-
}), m2;
|
|
1283
|
-
}, L = (e2, t22) => {
|
|
1284
|
-
let n2;
|
|
1285
|
-
try {
|
|
1286
|
-
n2 = JSON.parse(e2);
|
|
1287
|
-
} catch (e3) {
|
|
1288
|
-
console.error("[zustand devtools middleware] Could not parse the received json", e3);
|
|
1289
|
-
}
|
|
1290
|
-
n2 !== void 0 && t22(n2);
|
|
1291
|
-
}, R = (e2) => (t22, n2, r2) => {
|
|
1292
|
-
let i22 = r2.subscribe;
|
|
1293
|
-
return r2.subscribe = (e3, t3, n3) => {
|
|
1294
|
-
let a2 = e3;
|
|
1295
|
-
if (t3) {
|
|
1296
|
-
let i3 = n3?.equalityFn || Object.is, o2 = e3(r2.getState());
|
|
1297
|
-
a2 = (n4) => {
|
|
1298
|
-
let r3 = e3(n4);
|
|
1299
|
-
if (!i3(o2, r3)) {
|
|
1300
|
-
let e4 = o2;
|
|
1301
|
-
t3(o2 = r3, e4);
|
|
1302
|
-
}
|
|
1303
|
-
}, n3?.fireImmediately && t3(o2, o2);
|
|
1304
|
-
}
|
|
1305
|
-
return i22(a2);
|
|
1306
|
-
}, e2(t22, n2, r2);
|
|
1307
|
-
}, z = (e2 = {}, t22) => {
|
|
1308
|
-
switch (t22.type) {
|
|
1309
|
-
case O:
|
|
1310
|
-
return { ...e2, [t22.payload.id]: t22.payload.type };
|
|
1311
|
-
case k:
|
|
1312
|
-
return { ...e2, ...t22.payload.mapping };
|
|
1313
|
-
default:
|
|
1314
|
-
return e2;
|
|
1315
|
-
}
|
|
1316
|
-
};
|
|
1317
|
-
function B(e2, t22, n2, r2) {
|
|
1318
|
-
return !(!e2[n2] || !e2[n2][t22] || !e2[n2][t22][r2] || !Array.isArray(e2[n2][t22][r2]));
|
|
1319
|
-
}
|
|
1320
|
-
function V(e2, t22) {
|
|
1321
|
-
let n2 = {}, r2 = [];
|
|
1322
|
-
for (let [i22, a2] of Object.entries(e2 || {})) {
|
|
1323
|
-
r2.push(i22);
|
|
1324
|
-
let e3 = (t22 || {})[i22];
|
|
1325
|
-
if (!e3 || e3.length === 0) {
|
|
1326
|
-
n2[i22] = a2;
|
|
1327
|
-
continue;
|
|
1328
|
-
}
|
|
1329
|
-
n2[i22] = e3;
|
|
1330
|
-
}
|
|
1331
|
-
for (let [e3, i22] of Object.entries(t22 || {})) r2.indexOf(e3) === -1 && (n2[e3] = i22);
|
|
1332
|
-
return n2;
|
|
1333
|
-
}
|
|
1334
|
-
function H$1(e2) {
|
|
1335
|
-
return e2.payload || {};
|
|
1336
|
-
}
|
|
1337
|
-
function U$1(e2, t22, n2) {
|
|
1338
|
-
if (!e2[t22] || !Array.isArray(e2[t22])) return null;
|
|
1339
|
-
let r2 = n2.index === void 0 ? e2[t22].findIndex((e3) => e3 ? r$2(e3)?.id === n2.id : !1) : n2.index;
|
|
1340
|
-
return r2 === -1 ? null : { entity: e2[t22][r2], index: r2 };
|
|
1341
|
-
}
|
|
1342
|
-
function W(e2, t22) {
|
|
1343
|
-
if (!(!t22?.id || !t22?.type)) return e2[t22.type]?.[t22.id];
|
|
1344
|
-
}
|
|
1345
|
-
function G(e2, t22) {
|
|
1346
|
-
return e2 === void 0 ? t22 : e2;
|
|
1347
|
-
}
|
|
1348
|
-
const K = (e2 = e$1(), f2) => {
|
|
1349
|
-
let p2 = (t22, n2) => ({ ...e2, [H$1(f2).type]: { ...e2[H$1(f2).type], [H$1(f2).id]: { ...t22, ...n2 } } });
|
|
1350
|
-
switch (f2.type) {
|
|
1351
|
-
case n$2: {
|
|
1352
|
-
if (!e2[H$1(f2).type] || !e2[H$1(f2).type][H$1(f2).id]) return e2;
|
|
1353
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id];
|
|
1354
|
-
return typeof t22 == "string" ? e2 : p2(t22, { [H$1(f2).key]: H$1(f2).value });
|
|
1355
|
-
}
|
|
1356
|
-
case r$1: {
|
|
1357
|
-
if (!B(e2, H$1(f2).id, H$1(f2).type, H$1(f2).key)) return e2;
|
|
1358
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id];
|
|
1359
|
-
if (typeof t22 == "string") return e2;
|
|
1360
|
-
let n2 = Array.from(t22[H$1(f2).key]), [r2] = n2.splice(H$1(f2).startIndex, 1);
|
|
1361
|
-
return n2.splice(H$1(f2).endIndex, 0, r2), p2(t22, { [H$1(f2).key]: n2 });
|
|
1362
|
-
}
|
|
1363
|
-
case a: {
|
|
1364
|
-
let t22 = H$1(f2).subjects, n2 = H$1(f2).from, r2 = H$1(f2).to || n2, i22 = W(e2, n2), a2 = r2?.key || n2.key;
|
|
1365
|
-
if (!B(e2, n2.id, n2.type, n2.key) || !B(e2, r2.id, r2.type, r2.key)) return e2;
|
|
1366
|
-
let o2 = [], s2 = [];
|
|
1367
|
-
if (t22.type === "slice") {
|
|
1368
|
-
let e3 = t22.startIndex, r3 = t22.length;
|
|
1369
|
-
o2 = Array.from(i22[n2.key]), s2 = o2.splice(e3, r3);
|
|
1370
|
-
} else {
|
|
1371
|
-
let e3 = Array.from(i22[n2.key]);
|
|
1372
|
-
for (let r3 of t22.items) {
|
|
1373
|
-
let t3 = U$1(i22, n2.key, r3);
|
|
1374
|
-
t3 && (s2.push(t3.entity), e3[t3.index] = null), o2 = e3.filter((e4) => e4 !== null);
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
let c2 = { ...i22, [n2.key]: o2 }, l2 = { ...e2, [n2.type]: { ...e2[n2.type], [n2.id]: c2 } }, u2 = W(l2, r2);
|
|
1378
|
-
if (!u2) return e2;
|
|
1379
|
-
let d2 = r2?.index === void 0 ? u2[a2].length : r2.index, p3 = Array.from(u2[r2.key]);
|
|
1380
|
-
p3.splice(d2, 0, ...s2);
|
|
1381
|
-
let m2 = { ...u2, [a2]: p3 };
|
|
1382
|
-
return { ...l2, [r2.type]: { ...l2[r2.type], [r2.id]: m2 } };
|
|
1383
|
-
}
|
|
1384
|
-
case i$1:
|
|
1385
|
-
return K(e2, { type: a, payload: { subjects: { type: "list", items: [H$1(f2).subject] }, from: H$1(f2).from, to: H$1(f2).to } });
|
|
1386
|
-
case c: {
|
|
1387
|
-
let { id: n2, index: r2, key: i22, newIdentifier: a2, reference: o2, type: s2 } = H$1(f2), c2 = e2[s2][n2], l2 = r$2(o2);
|
|
1388
|
-
if (!c2 || !c2[i22] || !l2 || r2 < 0) return e2;
|
|
1389
|
-
let u2 = c2[i22], d2 = u2[r2], m2 = e2[l2.type]?.[l2.id];
|
|
1390
|
-
if (!m2 || !d2) return e2;
|
|
1391
|
-
let h2 = n$3(d2, a2), g2 = Array.from(u2);
|
|
1392
|
-
g2.splice(G(r2, g2.length + 1), 1, h2);
|
|
1393
|
-
let _2 = p2(c2, { [i22]: g2 }), v2 = { ...m2, id: a2 };
|
|
1394
|
-
v2["iiif-parser:hasPart"] && (v2["iiif-parser:hasPart"] = v2["iiif-parser:hasPart"].filter((e3) => e3["iiif-parser:partOf"] === n2).map((e3) => ({ ...e3, id: a2 })));
|
|
1395
|
-
let y2 = { ..._2[l2.type], [a2]: v2 };
|
|
1396
|
-
return _2[l2.type] = y2, _2;
|
|
1397
|
-
}
|
|
1398
|
-
case t$3: {
|
|
1399
|
-
let t22 = Object.keys(H$1(f2).entities), n2 = { ...e2 };
|
|
1400
|
-
for (let r2 of t22) {
|
|
1401
|
-
let t3 = H$1(f2).entities[r2], i22 = { ...e2[r2] || {} }, a2 = !1, o2 = Object.keys(t3 || {}) || [];
|
|
1402
|
-
if (t3 && o2) {
|
|
1403
|
-
for (let n3 of o2) a2 = !0, i22[n3] = e2[r2][n3] ? V(e2[r2][n3], t3[n3]) : t3[n3];
|
|
1404
|
-
a2 && (n2[r2] = i22);
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
return n2;
|
|
1408
|
-
}
|
|
1409
|
-
case o: {
|
|
1410
|
-
if (!B(e2, H$1(f2).id, H$1(f2).type, H$1(f2).key)) return e2;
|
|
1411
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id], n2 = Array.from(t22[H$1(f2).key]);
|
|
1412
|
-
return n2.splice(G(H$1(f2).index, n2.length + 1), 0, H$1(f2).reference), p2(t22, { [H$1(f2).key]: n2 });
|
|
1413
|
-
}
|
|
1414
|
-
case s:
|
|
1415
|
-
case l: {
|
|
1416
|
-
if (!B(e2, H$1(f2).id, H$1(f2).type, H$1(f2).key)) return e2;
|
|
1417
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id], n2 = Array.from(t22[H$1(f2).key]), r2 = G(H$1(f2).index, n2.findIndex((e3) => e3 && e3.id === H$1(f2).reference.id));
|
|
1418
|
-
return r2 === -1 || n2[r2]?.id !== H$1(f2).reference.id ? e2 : (f2.type === s ? n2.splice(r2, 1, H$1(f2).reference) : n2.splice(r2, 1), p2(t22, { [H$1(f2).key]: n2 }));
|
|
1419
|
-
}
|
|
1420
|
-
case u: {
|
|
1421
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id];
|
|
1422
|
-
if (!t22) return e2;
|
|
1423
|
-
let n2 = Array.from(t22.metadata || []), r2 = H$1(f2);
|
|
1424
|
-
return n2.splice(G(f2.payload.beforeIndex, n2.length + 1), 0, { label: r2.label, value: r2.label }), p2(t22, { metadata: n2 });
|
|
1425
|
-
}
|
|
1426
|
-
case p: {
|
|
1427
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id];
|
|
1428
|
-
if (typeof t22 == "string" || !t22) return e2;
|
|
1429
|
-
let n2 = Array.from(t22.metadata || []), [r2] = n2.splice(H$1(f2).startIndex, 1);
|
|
1430
|
-
return n2.splice(H$1(f2).endIndex, 0, r2), p2(t22, { metadata: n2 });
|
|
1431
|
-
}
|
|
1432
|
-
case f:
|
|
1433
|
-
case d: {
|
|
1434
|
-
let t22 = e2[H$1(f2).type][H$1(f2).id], n2 = Array.from(t22.metadata || []), r2 = H$1(f2).atIndex;
|
|
1435
|
-
return r2 === void 0 || r2 === -1 || !n2[r2] ? e2 : (f2.type === f ? n2.splice(r2, 1, { label: H$1(f2).label, value: H$1(f2).value }) : n2.splice(r2, 1), p2(t22, { metadata: n2 }));
|
|
1436
|
-
}
|
|
1437
|
-
default:
|
|
1438
|
-
return e2;
|
|
1439
|
-
}
|
|
1440
|
-
}, q = (e2 = {}, t22) => {
|
|
1441
|
-
switch (t22.type) {
|
|
1442
|
-
case I$1:
|
|
1443
|
-
case B$1:
|
|
1444
|
-
return { ...e2, [t22.payload.id]: { requestUri: t22.payload.id, loadingState: P$1, uriMismatch: !1, resourceUri: t22.payload.id } };
|
|
1445
|
-
case R$1:
|
|
1446
|
-
return { ...e2, [t22.payload.requestId]: { ...e2[t22.payload.requestId] || {}, uriMismatch: !0, resourceUri: t22.payload.actualId }, [t22.payload.actualId]: { requestUri: t22.payload.requestId, loadingState: e2[t22.payload.requestId].loadingState, uriMismatch: !0, resourceUri: t22.payload.actualId } };
|
|
1447
|
-
case L$1:
|
|
1448
|
-
return { ...e2, [t22.payload.id]: { ...e2[t22.payload.id] || {}, loadingState: N$1, error: t22.payload.message } };
|
|
1449
|
-
case z$1:
|
|
1450
|
-
return { ...e2, [t22.payload.id]: { ...e2[t22.payload.id] || {}, loadingState: F$1, error: void 0 } };
|
|
1451
|
-
}
|
|
1452
|
-
return e2;
|
|
1453
|
-
}, J = (e2 = {}, t22) => {
|
|
1454
|
-
let { id: n2, updateValue: r2, value: i22, meta: a2, key: o2 } = t22 && t22.payload || {};
|
|
1455
|
-
switch (t22.type) {
|
|
1456
|
-
case t$2:
|
|
1457
|
-
return { ...e2, [n2]: { ...e2[n2] || {}, [a2]: { ...e2[n2] && e2[n2][a2] || {}, [o2]: i22 } } };
|
|
1458
|
-
case n$1:
|
|
1459
|
-
return { ...e2, [n2]: { ...e2[n2] || {}, [a2]: { ...e2[n2] && e2[n2][a2] || {}, [o2]: e2[n2] && e2[n2][a2] ? r2(e2[n2][a2][o2]) : r2(void 0) } } };
|
|
1460
|
-
case r:
|
|
1461
|
-
return e2[n2] && e2[n2][a2] && e2[n2][a2][o2] ? { ...e2, [n2]: { ...e2[n2] || {}, [a2]: { ...e2[n2] && e2[n2][a2] || {}, [o2]: void 0 } } } : e2;
|
|
1462
|
-
default:
|
|
1463
|
-
return e2;
|
|
1464
|
-
}
|
|
1465
|
-
};
|
|
1466
|
-
function Y(e2 = {}) {
|
|
1467
|
-
let t22 = Object.keys(e2);
|
|
1468
|
-
return function(n2 = {}, r2) {
|
|
1469
|
-
let i22 = !1, a2 = {};
|
|
1470
|
-
for (let o2 = 0; o2 < t22.length; o2++) {
|
|
1471
|
-
let s2 = t22[o2];
|
|
1472
|
-
a2[s2] = e2[s2](n2[s2], r2), i22 = i22 || a2[s2] !== n2[s2];
|
|
1473
|
-
}
|
|
1474
|
-
return i22 ? a2 : n2;
|
|
1475
|
-
};
|
|
1476
|
-
}
|
|
1477
|
-
function X(e2) {
|
|
1478
|
-
return (t22, n2) => n2 && n2.type === q$1 ? n2.payload.actions.reduce(e2, t22) : n2 && n2.type === J$1 ? { ...t22, iiif: { ...t22.iiif, ...n2.payload.state } } : e2(t22, n2);
|
|
1479
|
-
}
|
|
1480
|
-
const Z = Y({ mapping: z, entities: K, requests: q, meta: J });
|
|
1481
|
-
function Q() {
|
|
1482
|
-
return { iiif: { entities: e$1(), meta: {}, mapping: {}, requests: {} } };
|
|
1483
|
-
}
|
|
1484
|
-
function $(t22 = {}) {
|
|
1485
|
-
let { enableDevtools: n2 = !1, iiifStoreName: r2 = "iiif", defaultState: i22 = Q(), customReducers: a2 = {} } = t22, o2 = X(Y({ [r2]: Z, ...a2 }));
|
|
1486
|
-
return t$6(R((typeof window < "u" && window.__REDUX_DEVTOOLS_EXTENSION__ ? I : (e2, t3) => e2)(M(o2, i22), { enabled: n2 })));
|
|
1487
|
-
}
|
|
1488
|
-
function g(e2, t3, n2, r2 = !0) {
|
|
1489
|
-
t3[y] = t3[y] || [], t3[y].push(e2);
|
|
1490
|
-
let i3 = /* @__PURE__ */ new Map();
|
|
1491
|
-
Object.defineProperty(t3, e2, { enumerable: r2, get() {
|
|
1492
|
-
if (t3[_][e2] === void 0) return;
|
|
1493
|
-
let r3 = t3[_][e2];
|
|
1494
|
-
if (!r3) return r3;
|
|
1495
|
-
let a2 = n2.get(t3[_][e2], { parent: this.id ? { id: this.id, type: this.type } : void 0 });
|
|
1496
|
-
return i3.has(a2) || (i3.clear(), i3.set(a2, w(a2, n2))), i3.get(a2);
|
|
1497
|
-
}, set(r3) {
|
|
1498
|
-
t3[_][e2] !== r3 && (this[v] ? n2.modifyEntityField({ id: this.id, type: this.type }, e2, C(r3)) : this[_][e2] = r3);
|
|
1499
|
-
} });
|
|
1500
|
-
}
|
|
1501
|
-
const _ = Symbol.for("_refs_"), v = Symbol.for("_reactive_"), y = Symbol.for("_defined_"), b = Symbol.for("_parent_");
|
|
1502
|
-
function x(e2, t3 = !1, n2) {
|
|
1503
|
-
let r2 = { id: "", type: "unknown", [y]: [], [_]: {}, [b]: null, [v]: null, is(e3) {
|
|
1504
|
-
return typeof e3 == "string" ? this.id === e3 : e3.id ? e3.id === this.id : !1;
|
|
1505
|
-
}, reactive() {
|
|
1506
|
-
if (!this[v]) return this[v] = this.subscribe(() => this.refresh(), !0), () => {
|
|
1507
|
-
this.unreactive();
|
|
1508
|
-
};
|
|
1509
|
-
}, refresh() {
|
|
1510
|
-
if (this.id) {
|
|
1511
|
-
let e3 = this.unwrap();
|
|
1512
|
-
for (let t4 of Object.keys(e3 || {})) this[y].includes(t4) ? this[_][t4] = e3[t4] : this[t4] = e3[t4];
|
|
1513
|
-
}
|
|
1514
|
-
}, unreactive() {
|
|
1515
|
-
this[v] && (this[v](), this[v] = null);
|
|
1516
|
-
}, unwrap() {
|
|
1517
|
-
if (!this.id) throw Error("Invalid object");
|
|
1518
|
-
let t4 = this[b];
|
|
1519
|
-
return e2.get(this.id, { parent: t4 ? { id: t4, type: "unknown" } : void 0 });
|
|
1520
|
-
}, toPresentation3() {
|
|
1521
|
-
return e2.toPresentation3(this.unwrap());
|
|
1522
|
-
}, toPresentation2() {
|
|
1523
|
-
return e2.toPresentation2(this.unwrap());
|
|
1524
|
-
}, valueOf() {
|
|
1525
|
-
return this.unwrap();
|
|
1526
|
-
}, toJSON() {
|
|
1527
|
-
let e3 = this;
|
|
1528
|
-
return { ...e3, items: e3.items, annotations: e3.annotations, structures: e3.structures, seeAlso: e3.seeAlso, service: e3.service, services: e3.services, rendering: e3.rendering, partOf: e3.partOf, start: e3.start, supplementary: e3.supplementary, homepage: e3.homepage, thumbnail: e3.thumbnail, placeholderCanvas: e3.placeholderCanvas, accompanyingCanvas: e3.accompanyingCanvas, provider: e3.provider };
|
|
1529
|
-
}, subscribe(t4, n3 = !0) {
|
|
1530
|
-
return e2.subscribe(() => this.id ? e2.get(this.id) : null, t4, n3);
|
|
1531
|
-
} };
|
|
1532
|
-
return g("items", r2, e2), g("annotations", r2, e2), g("structures", r2, e2), g("seeAlso", r2, e2), g("rendering", r2, e2), g("partOf", r2, e2), g("start", r2, e2, !1), g("supplementary", r2, e2), g("homepage", r2, e2), g("thumbnail", r2, e2), g("placeholderCanvas", r2, e2, !1), g("accompanyingCanvas", r2, e2, !1), g("provider", r2, e2), g("body", r2, e2), g("logo", r2, e2), r2;
|
|
1533
|
-
}
|
|
1534
|
-
function S(e2) {
|
|
1535
|
-
return !!e2[y];
|
|
1536
|
-
}
|
|
1537
|
-
function C(e2) {
|
|
1538
|
-
return Array.isArray(e2) ? e2.map((e3) => C(e3)) : !e2 || !e2.type ? e2 : { id: e2.id, type: e2.type };
|
|
1539
|
-
}
|
|
1540
|
-
function w(e2, t3, n2 = !1, r2) {
|
|
1541
|
-
if (Array.isArray(e2)) return e2.map((e3) => w(e3, t3, n2));
|
|
1542
|
-
if (!e2 || !e2.type || !e2.id) return e2;
|
|
1543
|
-
let i3 = x(t3, n2), a2 = Object.create(i3), o2 = Object.assign(a2, e2);
|
|
1544
|
-
return n2 && o2.reactive(), o2;
|
|
1545
|
-
}
|
|
1546
|
-
function T(e2) {
|
|
1547
|
-
switch (e2) {
|
|
1548
|
-
case "Image":
|
|
1549
|
-
case "Video":
|
|
1550
|
-
case "Sound":
|
|
1551
|
-
case "Dataset":
|
|
1552
|
-
case "Text":
|
|
1553
|
-
case "Composite":
|
|
1554
|
-
case "List":
|
|
1555
|
-
case "Independents":
|
|
1556
|
-
case "Audience":
|
|
1557
|
-
return "ContentResource";
|
|
1558
|
-
case "ImageService1":
|
|
1559
|
-
case "ImageService2":
|
|
1560
|
-
case "ImageService3":
|
|
1561
|
-
return "Service";
|
|
1562
|
-
}
|
|
1563
|
-
return e2;
|
|
1564
|
-
}
|
|
1565
|
-
var E = class {
|
|
1566
|
-
constructor(n2, r2) {
|
|
1567
|
-
r$6(this, "options", void 0), r$6(this, "store", void 0), r$6(this, "emitter", void 0), r$6(this, "isBatching", !1), r$6(this, "batchQueue", []), r$6(this, "remoteFetcher", void 0), r$6(this, "staticFetcher", void 0), r$6(this, "defaultFetcher", (e2) => fetch(e2).then((e3) => {
|
|
1568
|
-
if (e3.status === 200) return e3.json();
|
|
1569
|
-
{
|
|
1570
|
-
let t3 = Error(`${e3.status} ${e3.statusText}`);
|
|
1571
|
-
throw t3.name = "HTTPError", t3;
|
|
1572
|
-
}
|
|
1573
|
-
})), this.options = Object.assign({ reducers: {}, customFetcher: this.defaultFetcher, enableDevtools: !0 }, n2 || {}), this.store = r2 || $({ customReducers: this.options.reducers, defaultState: this.options.defaultState, enableDevtools: this.options.enableDevtools }), this.emitter = e$5(), this.remoteFetcher = x$1(this, this.options.customFetcher), this.staticFetcher = x$1(this, (e2, t3) => t3);
|
|
1574
|
-
}
|
|
1575
|
-
batch(e2) {
|
|
1576
|
-
this.isBatching = !0;
|
|
1577
|
-
try {
|
|
1578
|
-
e2(this), this.isBatching = !1, this.dispatch(Y$1({ actions: this.batchQueue }));
|
|
1579
|
-
} catch (e3) {
|
|
1580
|
-
throw this.batchQueue = [], this.isBatching = !1, e3;
|
|
1581
|
-
}
|
|
1582
|
-
this.batchQueue = [];
|
|
1583
|
-
}
|
|
1584
|
-
async asyncBatch(e2) {
|
|
1585
|
-
this.isBatching = !0;
|
|
1586
|
-
try {
|
|
1587
|
-
await e2(this), this.isBatching = !1, this.dispatch(Y$1({ actions: this.batchQueue }));
|
|
1588
|
-
} catch (e3) {
|
|
1589
|
-
throw this.batchQueue = [], this.isBatching = !1, e3;
|
|
1590
|
-
}
|
|
1591
|
-
this.batchQueue = [];
|
|
1592
|
-
}
|
|
1593
|
-
modifyEntityField(e2, t3, r2) {
|
|
1594
|
-
this.dispatch(D.modifyEntityField({ id: e2.id, type: e2.type, key: t3, value: r2 }));
|
|
1595
|
-
}
|
|
1596
|
-
dispatch(e2) {
|
|
1597
|
-
if (this.isBatching) this.batchQueue.push(e2);
|
|
1598
|
-
else {
|
|
1599
|
-
if (e2.type === q$1) {
|
|
1600
|
-
for (let t5 of e2.payload.actions) this.emitter.emit(t5.type, { action: t5, state: this.store.getState() });
|
|
1601
|
-
this.store.dispatch(e2);
|
|
1602
|
-
let t4 = this.getState();
|
|
1603
|
-
for (let n2 of e2.payload.actions) this.emitter.emit(`after:${n2.type}`, { action: n2, state: t4 });
|
|
1604
|
-
return;
|
|
1605
|
-
}
|
|
1606
|
-
this.emitter.emit(e2.type, { action: e2, state: this.store.getState() }), this.store.dispatch(e2);
|
|
1607
|
-
let t3 = this.store.getState();
|
|
1608
|
-
this.emitter.emit(`after:${e2.type}`, { action: e2, state: t3 });
|
|
1609
|
-
return;
|
|
1610
|
-
}
|
|
1611
|
-
}
|
|
1612
|
-
on(e2, t3) {
|
|
1613
|
-
return this.emitter.on(e2, t3), () => {
|
|
1614
|
-
this.emitter.off(e2, t3);
|
|
1615
|
-
};
|
|
1616
|
-
}
|
|
1617
|
-
serialize(e2, t3) {
|
|
1618
|
-
return ce(this.getState().iiif, e2, t3);
|
|
1619
|
-
}
|
|
1620
|
-
toPresentation2(e2) {
|
|
1621
|
-
return this.serialize(e2, fe);
|
|
1622
|
-
}
|
|
1623
|
-
toPresentation3(e2) {
|
|
1624
|
-
return this.serialize(e2, pe);
|
|
1625
|
-
}
|
|
1626
|
-
hydrate(e2, t3, n2 = {}) {
|
|
1627
|
-
return this.get(e2, t3, { ...n2, skipSelfReturn: !1 });
|
|
1628
|
-
}
|
|
1629
|
-
get(e2, t3, n2 = {}) {
|
|
1630
|
-
typeof t3 != "string" && (n2 = t3 || {}, t3 = void 0);
|
|
1631
|
-
let { skipSelfReturn: r2 = !0 } = n2 || {}, i3 = n2.parent ? typeof n2.parent == "string" ? n2.parent : n2.parent.id : void 0;
|
|
1632
|
-
if (Array.isArray(e2)) return e2.map((e3) => this.get(e3, n2));
|
|
1633
|
-
let a2 = this.getState();
|
|
1634
|
-
if (n$5(e2) && !n2.preserveSpecificResources && (e2 = e2.source), typeof e2 == "string") {
|
|
1635
|
-
let n3 = T(t3 || a2.iiif.mapping[e2]);
|
|
1636
|
-
if (!n3) return r2 ? null : { id: e2, type: "unknown" };
|
|
1637
|
-
e2 = { id: e2, type: n3 };
|
|
1638
|
-
}
|
|
1639
|
-
if (e2 && e2.partOf && !i3 && !n2.skipPartOfCheck) {
|
|
1640
|
-
let t4 = Array.isArray(e2.partOf) ? e2.partOf[0] : e2.partOf;
|
|
1641
|
-
t4 && (typeof t4 == "string" && (i3 = t4), typeof t4.id == "string" && (i3 = t4.id));
|
|
1642
|
-
}
|
|
1643
|
-
let o2 = T(t3 || e2?.type), s2 = e2?.id, c2 = a2.iiif.entities[o2];
|
|
1644
|
-
if (!c2) {
|
|
1645
|
-
let t4 = a2.iiif.requests[s2];
|
|
1646
|
-
return t4 && t4.resourceUri !== s2 ? this.get(t4.resourceUri, n2) : r2 ? null : e2;
|
|
1647
|
-
}
|
|
1648
|
-
let p2 = c2[e2.id];
|
|
1649
|
-
return p2 && p2[a$1] ? f$1(p2, p2[a$1].find((e3) => i3 ? e3[o$1] === i3 : e3[o$1] === p2.id)) : c2[e2.id] || (r2 ? null : e2);
|
|
1650
|
-
}
|
|
1651
|
-
select(e2) {
|
|
1652
|
-
return e2(this.getState());
|
|
1653
|
-
}
|
|
1654
|
-
getStore() {
|
|
1655
|
-
return this.store;
|
|
1656
|
-
}
|
|
1657
|
-
getState() {
|
|
1658
|
-
return this.store.getState();
|
|
1659
|
-
}
|
|
1660
|
-
deep(e2, t3) {
|
|
1661
|
-
if (e2 === void 0) return this.get(t3, { skipSelfReturn: !1 });
|
|
1662
|
-
if (typeof e2 == "function") try {
|
|
1663
|
-
let n3 = e2(this.get(t3, { skipSelfReturn: !1 })), r2 = (e3) => this.deep(e3, n3);
|
|
1664
|
-
return r2.size = Array.isArray(n3) ? n3.length : 1, r2;
|
|
1665
|
-
} catch {
|
|
1666
|
-
let e3 = (e4) => this.deep(e4, void 0);
|
|
1667
|
-
return e3.size = 0, e3;
|
|
1668
|
-
}
|
|
1669
|
-
let n2 = (t4) => this.deep(t4, e2);
|
|
1670
|
-
return n2.size = Array.isArray(e2) ? e2.length : 1, n2;
|
|
1671
|
-
}
|
|
1672
|
-
loadManifest(e2, t3, n2) {
|
|
1673
|
-
let r2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1674
|
-
return this.load(r2, t3, n2);
|
|
1675
|
-
}
|
|
1676
|
-
loadCollection(e2, t3, n2) {
|
|
1677
|
-
let r2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1678
|
-
return this.load(r2, t3, n2);
|
|
1679
|
-
}
|
|
1680
|
-
load(e2, t3, n2) {
|
|
1681
|
-
let r2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1682
|
-
return t3 ? Promise.resolve(this.staticFetcher(r2, t3, n2)) : Promise.resolve(this.remoteFetcher(r2, {}, n2));
|
|
1683
|
-
}
|
|
1684
|
-
loadSync(e2, t3, n2) {
|
|
1685
|
-
let r2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1686
|
-
return this.staticFetcher(r2, t3, n2);
|
|
1687
|
-
}
|
|
1688
|
-
loadManifestSync(e2, t3, n2) {
|
|
1689
|
-
let r2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1690
|
-
return this.loadSync(r2, t3, n2);
|
|
1691
|
-
}
|
|
1692
|
-
loadCollectionSync(e2, t3, n2) {
|
|
1693
|
-
let r2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1694
|
-
return this.loadSync(r2, t3, n2);
|
|
1695
|
-
}
|
|
1696
|
-
areInputsEqual(e2, t3) {
|
|
1697
|
-
return v$1(e2, t3);
|
|
1698
|
-
}
|
|
1699
|
-
subscribe(e2, t3, n2) {
|
|
1700
|
-
return n2 === void 0 && (t3 === void 0 || t3 === !1 || t3 === !0) && (n2 = t3, t3 = e2, e2 = (e3) => e3), this.store.subscribe(e2, (e3) => t3(e3, this), { equalityFn: v$1, fireImmediately: !n2 });
|
|
1701
|
-
}
|
|
1702
|
-
async ensureLoaded(e2) {
|
|
1703
|
-
let t3 = typeof e2 == "string" ? e2 : e2.id;
|
|
1704
|
-
this.requestStatus(t3) || await this.load(t3);
|
|
1705
|
-
}
|
|
1706
|
-
requestStatus(e2) {
|
|
1707
|
-
return this.select((t3) => t3.iiif.requests[e2]);
|
|
1708
|
-
}
|
|
1709
|
-
getPaginationState(e2) {
|
|
1710
|
-
let t3 = typeof e2 == "string" ? e2 : e2.id;
|
|
1711
|
-
if (!t3) return null;
|
|
1712
|
-
let n2 = this.getResourceMeta(t3, "@vault/pagination");
|
|
1713
|
-
if (n2?.state) return n2.state;
|
|
1714
|
-
let r2 = this.get(e2);
|
|
1715
|
-
if (r2.first) {
|
|
1716
|
-
let e3 = { currentPage: null, currentPageIndex: null, isFetching: !1, isFullyLoaded: !1, next: r2.first, page: 1, pages: [], previous: null, totalItems: r2.total, currentLength: 0 };
|
|
1717
|
-
return this.setMetaValue([t3, "@vault/pagination", "state"], e3), e3;
|
|
1718
|
-
}
|
|
1719
|
-
return null;
|
|
1720
|
-
}
|
|
1721
|
-
async loadNextPage(e2, t3) {
|
|
1722
|
-
let n2 = typeof e2 == "string" ? e2 : e2.id;
|
|
1723
|
-
if (!n2) return [null, null];
|
|
1724
|
-
let r2 = this.getPaginationState(e2);
|
|
1725
|
-
if (!r2 || r2.isFullyLoaded || !r2.next) return [null, null];
|
|
1726
|
-
if (r2.isFetching) return [r2, null];
|
|
1727
|
-
let i3 = typeof r2.next == "string" ? r2.next : r2.next.id, a2 = r2.currentPage, o2 = { ...r2, isFetching: !0 };
|
|
1728
|
-
this.setMetaValue([n2, "@vault/pagination", "state"], o2);
|
|
1729
|
-
let s2;
|
|
1730
|
-
try {
|
|
1731
|
-
s2 = await this.loadCollection(i3, t3, (e3) => {
|
|
1732
|
-
let { id: t4, "@id": n3, ...r3 } = e3 || {};
|
|
1733
|
-
return n3 ? { "@id": i3, ...r3 } : { id: i3, ...r3 };
|
|
1734
|
-
});
|
|
1735
|
-
} catch (e3) {
|
|
1736
|
-
let t4 = { ...r2, isFetching: !1, error: e3 };
|
|
1737
|
-
return this.setMetaValue([n2, "@vault/pagination", "state"], t4), [t4, null];
|
|
1738
|
-
}
|
|
1739
|
-
if (!s2) {
|
|
1740
|
-
let e3 = { ...r2, isFetching: !1, error: Error("Collection not found") };
|
|
1741
|
-
return this.setMetaValue([n2, "@vault/pagination", "state"], e3), [e3, null];
|
|
1742
|
-
}
|
|
1743
|
-
let c2 = this.get(n2), l2 = [...c2.items || [], ...s2.items || []].map((e3) => ({ id: e3.id, type: e3.type }));
|
|
1744
|
-
this.modifyEntityField({ id: n2, type: "Collection" }, "items", l2);
|
|
1745
|
-
let u2 = this.getPaginationState(e2);
|
|
1746
|
-
if (!u2) throw Error("Pagination state not found");
|
|
1747
|
-
let d2 = { ...u2, isFetching: !1, error: null, currentPage: s2.id, next: s2.next?.id || null, currentPageIndex: u2.pages.length, currentLength: l2.length, pages: [...u2.pages, { id: s2.id, type: "Collection", startIndex: c2.items.length, pageLength: s2.items.length, order: typeof u2.currentPageIndex == "number" ? u2.currentPageIndex + 1 : 0 }], isFullyLoaded: !s2.next, previous: a2, page: u2.pages.length + 1 };
|
|
1748
|
-
return this.setMetaValue([n2, "@vault/pagination", "state"], d2), [d2, s2];
|
|
1749
|
-
}
|
|
1750
|
-
getResourceMeta(e2, t3) {
|
|
1751
|
-
let n2 = this.getState().iiif.meta[e2];
|
|
1752
|
-
if (n2) return t3 ? n2[t3] : n2;
|
|
1753
|
-
}
|
|
1754
|
-
getObject(e2, t3, n2 = {}) {
|
|
1755
|
-
let { reactive: r2, ...i3 } = n2;
|
|
1756
|
-
return w(this.get(e2, t3, i3), this, r2);
|
|
1757
|
-
}
|
|
1758
|
-
async loadObject(e2, t3) {
|
|
1759
|
-
return w(await this.load(e2, t3), this);
|
|
1760
|
-
}
|
|
1761
|
-
async loadManifestObject(e2, t3) {
|
|
1762
|
-
return w(await this.loadManifest(e2, t3), this);
|
|
1763
|
-
}
|
|
1764
|
-
async loadCollectionObject(e2, t3) {
|
|
1765
|
-
return w(await this.loadCollection(e2, t3), this);
|
|
1766
|
-
}
|
|
1767
|
-
wrapObject(e2) {
|
|
1768
|
-
return w(this.get(e2, { skipSelfReturn: !1 }), this);
|
|
1769
|
-
}
|
|
1770
|
-
isWrapped(e2) {
|
|
1771
|
-
return S(e2);
|
|
1772
|
-
}
|
|
1773
|
-
setMetaValue([e2, t3, n2], r2) {
|
|
1774
|
-
this.dispatch(typeof r2 == "function" ? i2.setMetaValueDynamic({ id: e2, meta: t3, key: n2, updateValue: r2 }) : i2.setMetaValue({ id: e2, meta: t3, key: n2, value: r2 }));
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
10
|
const defaultState$1 = {
|
|
1778
11
|
viewer: null,
|
|
1779
12
|
viewerReady: !1
|
|
@@ -1825,8 +58,8 @@ const defaultManifest = {
|
|
|
1825
58
|
index !== -1 && (updates.currentIndex = index);
|
|
1826
59
|
}
|
|
1827
60
|
set(updates);
|
|
1828
|
-
} catch (
|
|
1829
|
-
const error =
|
|
61
|
+
} catch (e) {
|
|
62
|
+
const error = e instanceof Error ? e.message : "Unknown error";
|
|
1830
63
|
set({ isLoading: !1, error });
|
|
1831
64
|
}
|
|
1832
65
|
},
|
|
@@ -1866,14 +99,14 @@ const defaultManifest = {
|
|
|
1866
99
|
},
|
|
1867
100
|
reset: () => set(defaultCanvas)
|
|
1868
101
|
}), createViewerStore = () => {
|
|
1869
|
-
const vault = new
|
|
1870
|
-
return createStore((...
|
|
1871
|
-
const instance = withReset(createInstanceSlice(...
|
|
102
|
+
const vault = new Vault(), resets = [], withReset = (slice) => (resets.push(slice.reset), slice);
|
|
103
|
+
return createStore((...a) => {
|
|
104
|
+
const instance = withReset(createInstanceSlice(...a)), control = withReset(createControlSlice(...a));
|
|
1872
105
|
return {
|
|
1873
106
|
...instance,
|
|
1874
107
|
...control,
|
|
1875
|
-
...withReset(createManifestSlice(vault)(...
|
|
1876
|
-
...withReset(createCanvasSlice(...
|
|
108
|
+
...withReset(createManifestSlice(vault)(...a)),
|
|
109
|
+
...withReset(createCanvasSlice(...a)),
|
|
1877
110
|
reset: () => resets.forEach((fn) => fn()),
|
|
1878
111
|
resetViewer: () => {
|
|
1879
112
|
instance.reset(), control.reset();
|
|
@@ -1884,77 +117,15 @@ const defaultManifest = {
|
|
|
1884
117
|
function useViewerStore() {
|
|
1885
118
|
return useContext(ViewerContext) ?? orThrow("viewer hook must be used within viewer provider");
|
|
1886
119
|
}
|
|
1887
|
-
const e = {}, t$1 = { get(e2) {
|
|
1888
|
-
return e2;
|
|
1889
|
-
}, setMetaValue([n2, r2, i3], a2) {
|
|
1890
|
-
let o2 = t$1.getResourceMeta(n2, r2), s2 = o2 ? o2[i3] : void 0, c2 = typeof a2 == "function" ? a2(s2) : a2;
|
|
1891
|
-
e[n2] = { ...e[n2] || {}, [r2]: { ...(e[n2] || {})[r2] || {}, [i3]: c2 } };
|
|
1892
|
-
}, getResourceMeta: ((t3, n2) => {
|
|
1893
|
-
let r2 = e[t3];
|
|
1894
|
-
if (r2) return n2 ? r2[n2] : r2;
|
|
1895
|
-
}), async load(e2) {
|
|
1896
|
-
let t3 = typeof e2 == "string" ? e2 : e2.id;
|
|
1897
|
-
return fetch(t3).then((e3) => e3.json());
|
|
1898
|
-
}, requestStatus(e2) {
|
|
1899
|
-
} };
|
|
1900
|
-
function t2(e2) {
|
|
1901
|
-
return e2.type === "SpecificResource" ? [e2.source, { selector: e2.selector }] : [e2, { selector: null }];
|
|
1902
|
-
}
|
|
1903
|
-
function n(n2 = t$1) {
|
|
1904
|
-
function r2(e2) {
|
|
1905
|
-
let t3 = e2 ? typeof e2 == "string" ? n2.get(e2) : e2 : null;
|
|
1906
|
-
if (!t3) return [];
|
|
1907
|
-
let r3 = n2.get(t3.items, { parent: t3 }), i4 = [];
|
|
1908
|
-
for (let e3 of r3) i4.push(...n2.get(e3.items, { parent: e3 }));
|
|
1909
|
-
return i4;
|
|
1910
|
-
}
|
|
1911
|
-
function i3(e2, i4 = []) {
|
|
1912
|
-
let a3 = Array.isArray(e2) ? e2 : r2(e2), o2 = [], s2 = { items: [], type: "complex-choice" }, c2 = [];
|
|
1913
|
-
for (let e3 of a3) {
|
|
1914
|
-
if (e3.type !== "Annotation") throw Error("getPaintables() accept either a canvas or list of annotations");
|
|
1915
|
-
let r3 = Array.from(Array.isArray(e3.body) ? e3.body : [e3.body]);
|
|
1916
|
-
for (let a4 of r3) {
|
|
1917
|
-
let [l2, { selector: u2 }] = t2(a4), d2 = n2.get(l2), f2 = (d2.type || "unknown").toLowerCase();
|
|
1918
|
-
if (f2 === "choice") {
|
|
1919
|
-
let e4 = n2.get(d2.items, { parent: d2.id }), t3 = i4.length ? i4.map((t4) => e4.find((e5) => e5.id === t4)).filter(Boolean) : [e4[0]];
|
|
1920
|
-
t3.length === 0 && t3.push(e4[0]), s2.items.push({ type: "single-choice", items: e4.map((e5) => ({ id: e5.id, label: e5.label, selected: t3.indexOf(e5) !== -1 })), label: l2.label }), r3.push(...t3);
|
|
1921
|
-
continue;
|
|
1922
|
-
}
|
|
1923
|
-
o2.indexOf(f2) === -1 && o2.push(f2), c2.push({ type: f2, annotationId: e3.id, annotation: e3, resource: d2, target: e3.target, selector: u2 });
|
|
1924
|
-
}
|
|
1925
|
-
}
|
|
1926
|
-
return { types: o2, items: c2, choice: s2.items.length < 2 ? s2.items[0] || null : s2, allChoices: s2.items.length ? s2 : null };
|
|
1927
|
-
}
|
|
1928
|
-
function a2(e2) {
|
|
1929
|
-
let { choice: t3 } = i3(e2);
|
|
1930
|
-
return t3;
|
|
1931
|
-
}
|
|
1932
|
-
return { getAllPaintingAnnotations: r2, getPaintables: i3, extractChoices: a2 };
|
|
1933
|
-
}
|
|
1934
|
-
function H(e2) {
|
|
1935
|
-
if (e2["@id"]) return e2["@id"];
|
|
1936
|
-
if (e2.id) return e2.id;
|
|
1937
|
-
}
|
|
1938
|
-
function U(e2) {
|
|
1939
|
-
if (!e2 || !e2.profile || !H(e2)) return !1;
|
|
1940
|
-
let t3 = Array.isArray(e2.profile) ? e2.profile : [e2.profile];
|
|
1941
|
-
for (let e3 of t3) if (typeof e3 == "string" && M$3.indexOf(e3) !== -1) return !0;
|
|
1942
|
-
return !1;
|
|
1943
|
-
}
|
|
1944
|
-
function de(e2) {
|
|
1945
|
-
let t3 = e2.service ? Array.isArray(e2.service) ? e2.service : [e2.service] : [], n2 = t3.length, r2 = [];
|
|
1946
|
-
for (let e3 = 0; e3 < n2; e3++) U(t3[e3]) && r2.push(t3[e3]);
|
|
1947
|
-
return r2;
|
|
1948
|
-
}
|
|
1949
120
|
function getImageServiceId(vault, canvas) {
|
|
1950
|
-
const paintables =
|
|
121
|
+
const paintables = createPaintingAnnotationsHelper(vault).getPaintables(canvas.id);
|
|
1951
122
|
if (!paintables.items.length)
|
|
1952
123
|
return null;
|
|
1953
124
|
const resource = paintables.items[0].resource;
|
|
1954
125
|
if (!isExternalWebResource(resource))
|
|
1955
126
|
return null;
|
|
1956
|
-
const services =
|
|
1957
|
-
return services.length ?
|
|
127
|
+
const services = getImageServices(resource);
|
|
128
|
+
return services.length ? getId(services[0]) ?? null : getImageServiceIdWithoutProfileCheck(resource);
|
|
1958
129
|
}
|
|
1959
130
|
function getImageServiceIdWithoutProfileCheck(resource) {
|
|
1960
131
|
const service = resource.service;
|
|
@@ -1975,7 +146,7 @@ function useViewerStoreSelector(selector) {
|
|
|
1975
146
|
return useStore(store, selector);
|
|
1976
147
|
}
|
|
1977
148
|
function useCanvas() {
|
|
1978
|
-
const vault = useViewerStoreSelector((
|
|
149
|
+
const vault = useViewerStoreSelector((s) => s.vault), id = useViewerStoreSelector((s) => s.id), isLoading = useViewerStoreSelector((s) => s.isLoading), currentIndex = useViewerStoreSelector((s) => s.currentIndex), goTo = useViewerStoreSelector((s) => s.goToCanvas), goToById = useViewerStoreSelector((s) => s.goToCanvasById), next = useViewerStoreSelector((s) => s.nextCanvas), prev = useViewerStoreSelector((s) => s.prevCanvas), { current, total } = useMemo(() => {
|
|
1979
150
|
if (!id || isLoading)
|
|
1980
151
|
return { current: null, total: 0 };
|
|
1981
152
|
const manifest = vault.get({ id, type: "Manifest" }), canvasRef = manifest.items[currentIndex] ?? orThrow("No canvas ref for " + currentIndex), current2 = vault.get(canvasRef), total2 = manifest.items.length;
|
|
@@ -1993,11 +164,11 @@ function useCanvas() {
|
|
|
1993
164
|
};
|
|
1994
165
|
}
|
|
1995
166
|
function useManifest() {
|
|
1996
|
-
const vault = useViewerStoreSelector((
|
|
167
|
+
const vault = useViewerStoreSelector((s) => s.vault), id = useViewerStoreSelector((s) => s.id), url = useViewerStoreSelector((s) => s.url), isLoading = useViewerStoreSelector((s) => s.isLoading), error = useViewerStoreSelector((s) => s.error), loadManifest = useViewerStoreSelector((s) => s.loadManifest);
|
|
1997
168
|
return { vault, id, url, isLoading, error, isReady: !!url && !isLoading && !error, loadManifest };
|
|
1998
169
|
}
|
|
1999
170
|
function useLoadManifest() {
|
|
2000
|
-
return useViewerStoreSelector((
|
|
171
|
+
return useViewerStoreSelector((s) => s.loadManifest);
|
|
2001
172
|
}
|
|
2002
173
|
function useStableProp(options) {
|
|
2003
174
|
const [stable, setStable] = useState(options), [key, setKey] = useState(() => JSON.stringify(options)), json = JSON.stringify(options);
|
|
@@ -2074,10 +245,10 @@ function useContainerSize(ref) {
|
|
|
2074
245
|
}, [ref]), size;
|
|
2075
246
|
}
|
|
2076
247
|
function useViewer() {
|
|
2077
|
-
return useViewerStoreSelector((
|
|
248
|
+
return useViewerStoreSelector((s) => s.viewer);
|
|
2078
249
|
}
|
|
2079
250
|
function useViewerReady() {
|
|
2080
|
-
return useViewerStoreSelector((
|
|
251
|
+
return useViewerStoreSelector((s) => s.viewerReady);
|
|
2081
252
|
}
|
|
2082
253
|
function useImageInfo() {
|
|
2083
254
|
const viewer = useViewer(), ready = useViewerReady();
|
|
@@ -2115,7 +286,7 @@ function ViewerProvider({ children }) {
|
|
|
2115
286
|
return /* @__PURE__ */ jsx(ViewerContext.Provider, { value: store, children });
|
|
2116
287
|
}
|
|
2117
288
|
function useViewerControls(fullscreenRef) {
|
|
2118
|
-
const viewer = useViewer(), store = useViewerStore(), zoomLevel = useViewerStoreSelector((
|
|
289
|
+
const viewer = useViewer(), store = useViewerStore(), zoomLevel = useViewerStoreSelector((s) => s.zoomLevel), zoomMin = useViewerStoreSelector((s) => s.zoomMin), zoomMax = useViewerStoreSelector((s) => s.zoomMax), isFullPage = useViewerStoreSelector((s) => s.isFullPage), rotation = useViewerStoreSelector((s) => s.rotation);
|
|
2119
290
|
useEffect(() => {
|
|
2120
291
|
const onFullscreenChange = () => {
|
|
2121
292
|
store.getState().setIsFullPage(!!document.fullscreenElement);
|