cozy-iiif 0.1.6 → 0.2.1
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/README.md +197 -11
- package/dist/Cozy.d.ts +0 -2
- package/dist/core/manifest.d.ts +2 -2
- package/dist/helpers/index.js +93 -0
- package/dist/index.js +276 -360
- package/dist/types.d.ts +11 -4
- package/package.json +2 -1
- package/src/Cozy.ts +1 -2
- package/src/core/manifest.ts +45 -8
- package/src/types.ts +29 -6
- package/vite.config.ts +1 -0
package/dist/index.js
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
import { g as
|
2
|
-
import { c as
|
3
|
-
var
|
4
|
-
function
|
1
|
+
import { g as h, a as $, b as w } from "./resource-DS2brz47.js";
|
2
|
+
import { c as Ft } from "./resource-DS2brz47.js";
|
3
|
+
var ce = "http://library.stanford.edu/iiif/image-api/compliance.html#level0", le = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", V = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", pe = "http://library.stanford.edu/iiif/image-api/conformance.html#level0", ve = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", F = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", he = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0", ue = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", W = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", fe = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level0", me = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", B = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", ge = "http://iiif.io/api/image/1/level0.json", de = "http://iiif.io/api/image/1/profiles/level0.json", ye = "http://iiif.io/api/image/1/level1.json", Ae = "http://iiif.io/api/image/1/profiles/level1.json", H = "http://iiif.io/api/image/1/level2.json", J = "http://iiif.io/api/image/1/profiles/level2.json", Ce = "http://iiif.io/api/image/2/level0.json", be = "http://iiif.io/api/image/2/profiles/level0.json", Re = "http://iiif.io/api/image/2/level1.json", Le = "http://iiif.io/api/image/2/profiles/level1.json", G = "http://iiif.io/api/image/2/level2.json", z = "http://iiif.io/api/image/2/profiles/level2.json", we = "level0", Ie = "level1", K = "level2", Se = "http://iiif.io/api/image/2/level0", Te = "http://iiif.io/api/image/2/level1", Q = "http://iiif.io/api/image/2/level2", xe = [Q, V, F, W, B, H, J, G, z, K], $e = [Se, Te, Q, ce, le, V, pe, ve, F, he, ue, W, fe, me, B, ge, de, ye, Ae, H, J, Ce, be, Re, Le, G, z, we, Ie, K], Me = $e;
|
4
|
+
function u(t) {
|
5
5
|
for (let e in t) (typeof t[e] > "u" || t[e] === null) && delete t[e];
|
6
6
|
return t;
|
7
7
|
}
|
8
|
-
function
|
8
|
+
function b(t) {
|
9
9
|
return Array.isArray(t) ? t : t ? [t] : [];
|
10
10
|
}
|
11
|
-
var
|
12
|
-
function
|
11
|
+
var je = Object.defineProperty, ke = (t, e, r) => e in t ? je(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, A = (t, e, r) => (ke(t, typeof e != "symbol" ? e + "" : e, r), r), U = ["sc:Collection", "sc:Manifest", "sc:Canvas", "sc:AnnotationList", "oa:Annotation", "sc:Range", "sc:Layer", "sc:Sequence", "oa:Choice", "Service", "ContentResource"];
|
12
|
+
function Pe(t) {
|
13
13
|
if (typeof t > "u" || t === null) throw new Error("Null or undefined is not a valid entity.");
|
14
14
|
if (Array.isArray(t)) throw new Error("Array is not a valid entity");
|
15
15
|
if (typeof t != "object") throw new Error(`${typeof t} is not a valid entity`);
|
16
16
|
if (typeof t["@type"] == "string") {
|
17
|
-
let e =
|
18
|
-
if (e !== -1) return
|
17
|
+
let e = U.indexOf(t["@type"]);
|
18
|
+
if (e !== -1) return U[e];
|
19
19
|
}
|
20
20
|
if (t.profile) return "Service";
|
21
21
|
if (t.format || t["@type"]) return "ContentResource";
|
22
22
|
throw new Error("Resource type is not known");
|
23
23
|
}
|
24
|
-
var
|
24
|
+
var Oe = class X {
|
25
25
|
constructor(e, r = {}) {
|
26
26
|
A(this, "traversals"), A(this, "options"), this.traversals = { collection: [], manifest: [], canvas: [], annotationList: [], sequence: [], annotation: [], contentResource: [], choice: [], range: [], service: [], layer: [], ...e }, this.options = { convertPropsToArray: !0, mergeMemberProperties: !0, allowUndefinedReturn: !1, ...r };
|
27
27
|
}
|
28
28
|
static all(e) {
|
29
|
-
return new
|
29
|
+
return new X({ collection: [e], manifest: [e], canvas: [e], annotationList: [e], sequence: [e], annotation: [e], contentResource: [e], choice: [e], range: [e], service: [e], layer: [e] });
|
30
30
|
}
|
31
31
|
traverseCollection(e) {
|
32
32
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(this.traverseCollectionItems(e))), this.traversals.collection);
|
@@ -99,7 +99,7 @@ var Ne = class te {
|
|
99
99
|
}
|
100
100
|
traverseUnknown(e) {
|
101
101
|
if (!e["@type"] || typeof e == "string") return e;
|
102
|
-
switch (
|
102
|
+
switch (Pe(e)) {
|
103
103
|
case "sc:Collection":
|
104
104
|
return this.traverseCollection(e);
|
105
105
|
case "sc:Manifest":
|
@@ -126,17 +126,17 @@ var Ne = class te {
|
|
126
126
|
return e.profile ? this.traverseService(e) : e;
|
127
127
|
}
|
128
128
|
traverseImageResource(e) {
|
129
|
-
let r = Array.isArray(e), i = Array.isArray(e) ? e : [e],
|
130
|
-
for (let
|
131
|
-
return !r && !this.options.convertPropsToArray ?
|
129
|
+
let r = Array.isArray(e), i = Array.isArray(e) ? e : [e], s = [];
|
130
|
+
for (let n of i) typeof n == "string" ? s.push(this.traverseContentResource({ "@id": n, "@type": "dctypes:Image" })) : s.push(this.traverseContentResource(n));
|
131
|
+
return !r && !this.options.convertPropsToArray ? s[0] : s;
|
132
132
|
}
|
133
133
|
traverseDescriptive(e) {
|
134
134
|
return e.thumbnail && (e.thumbnail = this.traverseImageResource(e.thumbnail)), e.logo && (e.logo = this.traverseImageResource(e.logo)), e;
|
135
135
|
}
|
136
136
|
traverseOneOrMoreServices(e) {
|
137
|
-
let r = Array.isArray(e), i = Array.isArray(e) ? e : [e],
|
138
|
-
for (let
|
139
|
-
return !r && !this.options.convertPropsToArray ?
|
137
|
+
let r = Array.isArray(e), i = Array.isArray(e) ? e : [e], s = [];
|
138
|
+
for (let n of i) s.push(this.traverseService(n));
|
139
|
+
return !r && !this.options.convertPropsToArray ? s[0] : s;
|
140
140
|
}
|
141
141
|
traverseLinking(e) {
|
142
142
|
return e.related && (e.related = this.traverseOneOrManyType(e.related, this.traversals.contentResource)), e.rendering && (e.rendering = this.traverseOneOrManyType(e.rendering, this.traversals.contentResource)), e.service && (e.service = this.traverseOneOrMoreServices(e.service)), e.seeAlso && (e.seeAlso = this.traverseOneOrManyType(e.seeAlso, this.traversals.contentResource)), e.within && (typeof e.within == "string" || (e.within = this.traverseOneOrManyType(e.within, this.traversals.contentResource))), e.startCanvas && (typeof e.startCanvas == "string" ? e.startCanvas = this.traverseType({ "@id": e.startCanvas, "@type": "sc:Canvas" }, this.traversals.canvas) : e.startCanvas && this.traverseType(e.startCanvas, this.traversals.canvas)), e.contentLayer && (typeof e.contentLayer == "string" ? e.contentLayer = this.traverseLayer({ "@id": e.contentLayer, "@type": "sc:Layer" }) : e.contentLayer = this.traverseLayer(e.contentLayer)), e;
|
@@ -147,13 +147,13 @@ var Ne = class te {
|
|
147
147
|
return e.map((i) => this.traverseType(i, r));
|
148
148
|
}
|
149
149
|
traverseType(e, r) {
|
150
|
-
return r.reduce((i,
|
151
|
-
let
|
152
|
-
return typeof
|
150
|
+
return r.reduce((i, s) => {
|
151
|
+
let n = s(i);
|
152
|
+
return typeof n > "u" && !this.options.allowUndefinedReturn ? i : n;
|
153
153
|
}, e);
|
154
154
|
}
|
155
|
-
},
|
156
|
-
function
|
155
|
+
}, Ue = "http://library.stanford.edu/iiif/image-api/compliance.html#level1", De = "http://library.stanford.edu/iiif/image-api/compliance.html#level2", Ee = "http://library.stanford.edu/iiif/image-api/conformance.html#level1", Ne = "http://library.stanford.edu/iiif/image-api/conformance.html#level2", qe = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level1", _e = "http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level2", Ve = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level1", Fe = "http://library.stanford.edu/iiif/image-api/1.1/conformance.html#level2", We = "http://iiif.io/api/image/1/level1.json", Be = "http://iiif.io/api/image/1/profiles/level1.json", He = "http://iiif.io/api/image/1/level2.json", Je = "http://iiif.io/api/image/1/profiles/level2.json", Ge = "http://iiif.io/api/image/2/level1.json", ze = "http://iiif.io/api/image/2/profiles/level1.json", Ke = "http://iiif.io/api/image/2/level2.json", Qe = "http://iiif.io/api/image/2/profiles/level2.json", Xe = "level1", Ye = "level2", Ze = "http://iiif.io/api/image/2/level1", et = "http://iiif.io/api/image/2/level2", tt = [Ze, et, Ue, De, Ee, Ne, qe, _e, Ve, Fe, We, Be, He, Je, Ge, ze, Ke, Qe, Xe, Ye], M = { attributionLabel: "Attribution", providerId: "http://example.org/provider", providerName: "Unknown" };
|
156
|
+
function rt(t) {
|
157
157
|
if (typeof t == "string") return [t];
|
158
158
|
if (!t) return [];
|
159
159
|
let e = Array.isArray(t) ? t : [t], r = [];
|
@@ -166,31 +166,31 @@ function ot(t) {
|
|
166
166
|
}
|
167
167
|
return r;
|
168
168
|
}
|
169
|
-
function
|
169
|
+
function R(t, e = "none") {
|
170
170
|
if (!t) return { none: [""] };
|
171
|
-
let r =
|
172
|
-
for (let
|
173
|
-
if (typeof
|
174
|
-
i[e] = i[e] ? i[e] : [], i[e].push(
|
171
|
+
let r = rt(t), i = {};
|
172
|
+
for (let s of r) {
|
173
|
+
if (typeof s == "string") {
|
174
|
+
i[e] = i[e] ? i[e] : [], i[e].push(s || "");
|
175
175
|
continue;
|
176
176
|
}
|
177
|
-
if (!
|
178
|
-
i[e] = i[e] ? i[e] : [], i[e].push(
|
177
|
+
if (!s["@language"]) {
|
178
|
+
i[e] = i[e] ? i[e] : [], i[e].push(s["@value"] || "");
|
179
179
|
continue;
|
180
180
|
}
|
181
|
-
let
|
182
|
-
i[
|
181
|
+
let n = s["@language"];
|
182
|
+
i[n] = i[n] ? i[n] : [], i[n].push(s["@value"] || "");
|
183
183
|
}
|
184
184
|
return Object.keys(i).length === 0 ? { none: [""] } : i;
|
185
185
|
}
|
186
|
-
function
|
187
|
-
if (Array.isArray(t)) return
|
188
|
-
if (
|
189
|
-
if (
|
190
|
-
if (
|
186
|
+
function Y(t) {
|
187
|
+
if (Array.isArray(t)) return Y(t.find((e) => typeof e == "string"));
|
188
|
+
if (xe.indexOf(t) !== -1) return "level2";
|
189
|
+
if (tt.indexOf(t) !== -1) return "level1";
|
190
|
+
if (Me.indexOf(t) !== -1) return "level0";
|
191
191
|
if (typeof t == "string") return t;
|
192
192
|
}
|
193
|
-
function
|
193
|
+
function it(t) {
|
194
194
|
let e = Array.isArray(t) ? t : [t];
|
195
195
|
for (let r of e) switch (r) {
|
196
196
|
case "http://iiif.io/api/image/2/context.json":
|
@@ -203,7 +203,7 @@ function ct(t) {
|
|
203
203
|
return "ImageApiSelector";
|
204
204
|
}
|
205
205
|
}
|
206
|
-
function
|
206
|
+
function st(t) {
|
207
207
|
switch (t) {
|
208
208
|
case "http://iiif.io/api/image/2/level0.json":
|
209
209
|
case "http://iiif.io/api/image/2/level1.json":
|
@@ -232,20 +232,20 @@ function lt(t) {
|
|
232
232
|
return "AutoCompleteService1";
|
233
233
|
}
|
234
234
|
}
|
235
|
-
function
|
235
|
+
function D(t) {
|
236
236
|
for (let e of ["sc", "oa", "dcterms", "dctypes", "iiif"]) if (t.startsWith(`${e}:`)) return t.slice(e.length + 1);
|
237
237
|
return t;
|
238
238
|
}
|
239
|
-
var
|
240
|
-
function
|
241
|
-
let e = t["@id"] || t.id, r = t["@type"] || t.type, i = t.profile || void 0,
|
239
|
+
var nt = ["Collection", "Manifest", "Annotation", "AnnotationPage", "Range", "Service"];
|
240
|
+
function k(t) {
|
241
|
+
let e = t["@id"] || t.id, r = t["@type"] || t.type, i = t.profile || void 0, s = t["@context"] || void 0;
|
242
242
|
if (i) {
|
243
|
-
let
|
244
|
-
if (
|
243
|
+
let n = st(i);
|
244
|
+
if (n) return n;
|
245
245
|
}
|
246
|
-
if (
|
247
|
-
let
|
248
|
-
if (
|
246
|
+
if (s) {
|
247
|
+
let n = it(s);
|
248
|
+
if (n) return n;
|
249
249
|
}
|
250
250
|
if (r) {
|
251
251
|
if (Array.isArray(r)) {
|
@@ -253,8 +253,8 @@ function O(t) {
|
|
253
253
|
if (r.indexOf("cnt:ContentAsText") !== -1) return "TextualBody";
|
254
254
|
r = r[0];
|
255
255
|
}
|
256
|
-
for (let
|
257
|
-
r = r.slice(
|
256
|
+
for (let n of ["sc", "oa", "dcterms", "dctypes", "iiif"]) if (r.startsWith(`${n}:`)) {
|
257
|
+
r = r.slice(n.length + 1);
|
258
258
|
break;
|
259
259
|
}
|
260
260
|
switch (r) {
|
@@ -266,7 +266,7 @@ function O(t) {
|
|
266
266
|
return "TextualBody";
|
267
267
|
}
|
268
268
|
}
|
269
|
-
if (r &&
|
269
|
+
if (r && nt.indexOf(r) !== -1) return r;
|
270
270
|
if (t.format) {
|
271
271
|
if (t.format.startsWith("image/")) return "Image";
|
272
272
|
if (t.format.startsWith("text/") || t.format === "application/pdf") return "Text";
|
@@ -274,53 +274,53 @@ function O(t) {
|
|
274
274
|
}
|
275
275
|
return e && (e.endsWith(".jpg") || e.endsWith(".png") || e.endsWith(".jpeg")) ? "Image" : r || "unknown";
|
276
276
|
}
|
277
|
-
var
|
278
|
-
function
|
279
|
-
let e = t.match(
|
277
|
+
var at = /http(s)?:\/\/(creativecommons.org|rightsstatements.org)[^"'\\<\n]+/gm;
|
278
|
+
function ot(t) {
|
279
|
+
let e = t.match(at);
|
280
280
|
return e ? e[0] : t;
|
281
281
|
}
|
282
|
-
function
|
283
|
-
let i = null,
|
284
|
-
for (let a of
|
285
|
-
let
|
286
|
-
if (
|
287
|
-
|
282
|
+
function ct(t, e = "Rights/License", r = "none") {
|
283
|
+
let i = null, s = [], n = Array.isArray(t) ? t : [t];
|
284
|
+
for (let a of n) {
|
285
|
+
let c = a ? ot(a) : void 0;
|
286
|
+
if (c && (c.indexOf("creativecommons.org") !== -1 || c.indexOf("rightsstatements.org") !== -1)) {
|
287
|
+
c.startsWith("https://") ? i = `http://${c.slice(8)}` : i = c;
|
288
288
|
continue;
|
289
289
|
}
|
290
|
-
|
290
|
+
c && s.push({ label: { [r]: [e] }, value: { [r]: [c] } });
|
291
291
|
}
|
292
|
-
return [i,
|
292
|
+
return [i, s];
|
293
293
|
}
|
294
|
-
var
|
295
|
-
function
|
294
|
+
var lt = ["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"];
|
295
|
+
function pt(t) {
|
296
296
|
if (t) {
|
297
297
|
let e = Array.isArray(t) ? t : [t], r = [];
|
298
|
-
for (let i of e) i === "http://iiif.io/api/presentation/2/context.json" && r.push("http://iiif.io/api/presentation/3/context.json"),
|
298
|
+
for (let i of e) i === "http://iiif.io/api/presentation/2/context.json" && r.push("http://iiif.io/api/presentation/3/context.json"), lt.indexOf(i) === -1 && r.push(i);
|
299
299
|
if (e.length) return r.length === 1 ? r[0] : r;
|
300
300
|
}
|
301
301
|
}
|
302
|
-
function
|
303
|
-
return t ? t.map((e) => ({ label:
|
302
|
+
function vt(t) {
|
303
|
+
return t ? t.map((e) => ({ label: R(e.label), value: R(e.value) })) : [];
|
304
304
|
}
|
305
|
-
var
|
306
|
-
function
|
305
|
+
var E = 0;
|
306
|
+
function Z(t, e) {
|
307
307
|
let r = encodeURI(t.id || t["@id"] || "").trim();
|
308
|
-
return r && e ? `${r}/${e}` : r || (
|
308
|
+
return r && e ? `${r}/${e}` : r || (E++, `http://example.org/${t["@type"]}${e ? `/${e}` : ""}/${E}`);
|
309
309
|
}
|
310
310
|
function d(t) {
|
311
311
|
let e = [...t.behavior || []];
|
312
312
|
t.viewingHint && e.push(t.viewingHint);
|
313
313
|
let r;
|
314
|
-
return Array.isArray(t.motivation) ? r = t.motivation.map(
|
314
|
+
return Array.isArray(t.motivation) ? r = t.motivation.map(D) : t.motivation && (r = D(t.motivation)), { "@context": t["@context"] ? pt(t["@context"]) : void 0, id: (t["@id"] || Z(t)).trim(), type: k(t), behavior: e.length ? e : void 0, height: t.height ? t.height : void 0, width: t.width ? t.width : void 0, motivation: r, viewingDirection: t.viewingDirection, profile: t.profile, format: t.format ? t.format : void 0, duration: void 0, timeMode: void 0 };
|
315
315
|
}
|
316
|
-
function
|
317
|
-
let [e, r] =
|
318
|
-
return { rights: e, metadata: i.length ? i : void 0, label: t.label ?
|
316
|
+
function y(t) {
|
317
|
+
let [e, r] = ct(t.license), i = [...t.metadata ? vt(t.metadata) : [], ...r];
|
318
|
+
return { rights: e, metadata: i.length ? i : void 0, label: t.label ? R(t.label) : void 0, requiredStatement: t.attribution ? { label: R(M.attributionLabel), value: R(t.attribution) } : void 0, navDate: t.navDate, summary: t.description ? R(t.description) : void 0, thumbnail: ht(t.thumbnail) };
|
319
319
|
}
|
320
|
-
function
|
320
|
+
function ht(t) {
|
321
321
|
return t && (Array.isArray(t) ? t : [t]).map((e) => typeof e == "string" ? { id: e, type: "Image" } : (e.type === "unknown" && (e.type = "Image"), e));
|
322
322
|
}
|
323
|
-
function
|
323
|
+
function ut(t) {
|
324
324
|
if (!t.within) return;
|
325
325
|
let e = Array.isArray(t.within) ? t.within : [t.within], r = [];
|
326
326
|
for (let i of e) if (typeof i == "string") {
|
@@ -329,46 +329,46 @@ function yt(t) {
|
|
329
329
|
r.push({ id: i, type: "Collection" });
|
330
330
|
break;
|
331
331
|
}
|
332
|
-
} else i["@id"] && r.push({ id: i["@id"], type:
|
332
|
+
} else i["@id"] && r.push({ id: i["@id"], type: k(i) });
|
333
333
|
return r.length ? r : void 0;
|
334
334
|
}
|
335
|
-
function
|
335
|
+
function C(t) {
|
336
336
|
let e = t.related ? Array.isArray(t.related) ? t.related : [t.related] : [], r = t.contentLayer;
|
337
|
-
return { provider: t.logo || e.length ? [{ id:
|
337
|
+
return { provider: t.logo || e.length ? [{ id: M.providerId, type: "Agent", homepage: e.length ? [e[0]] : void 0, logo: t.logo ? Array.isArray(t.logo) ? t.logo : [t.logo] : void 0, label: R(M.providerName) }] : void 0, partOf: ut(t), rendering: t.rendering, seeAlso: t.seeAlso, start: t.startCanvas, service: t.service ? b(t.service) : void 0, supplementary: r ? [r] : void 0 };
|
338
338
|
}
|
339
|
-
function
|
339
|
+
function ft(t) {
|
340
340
|
return { chars: t.chars, format: t.format ? t.format : void 0, language: t.language };
|
341
341
|
}
|
342
|
-
function
|
343
|
-
return
|
342
|
+
function mt(t) {
|
343
|
+
return u({ ...d(t), ...y(t), ...C(t), items: t.members });
|
344
344
|
}
|
345
|
-
function
|
345
|
+
function gt(t) {
|
346
346
|
let e = [], r = [], i;
|
347
|
-
for (let
|
348
|
-
let
|
349
|
-
return r.length && (
|
347
|
+
for (let n of t.sequences || []) n.canvases.length && e.push(...n.canvases), n.behavior && r.push(...n.behavior), n.startCanvas && (i = n.startCanvas);
|
348
|
+
let s = d(t);
|
349
|
+
return r.length && (s.behavior ? s.behavior.push(...r) : s.behavior = r), u({ ...s, ...y(t), ...C(t), start: i, items: e, structures: dt(t.structures) });
|
350
350
|
}
|
351
|
-
function
|
351
|
+
function dt(t) {
|
352
352
|
if (!t) return t;
|
353
353
|
let e = /* @__PURE__ */ new Map();
|
354
354
|
for (let i of t) e.set(i.id, i);
|
355
355
|
let r = [];
|
356
356
|
for (let i of t) if (i.items) {
|
357
|
-
let
|
358
|
-
i.items =
|
357
|
+
let s = i.items.map((n) => typeof n == "string" ? (r.push(n), e.get(n) || n) : n && n.id ? (r.push(n.id), e.get(n.id) || n) : n);
|
358
|
+
i.items = s;
|
359
359
|
}
|
360
360
|
return t.filter((i) => r.indexOf(i.id) === -1);
|
361
361
|
}
|
362
|
-
function
|
363
|
-
return
|
362
|
+
function yt(t) {
|
363
|
+
return u({ ...d(t), ...y(t), ...C(t), annotations: t.otherContent && t.otherContent.length ? t.otherContent : void 0, items: t.images && t.images.length ? [{ id: Z(t, "annotation-page"), type: "AnnotationPage", items: t.images }] : void 0 });
|
364
364
|
}
|
365
|
-
function
|
366
|
-
return
|
365
|
+
function At(t) {
|
366
|
+
return u({ ...d(t), ...y(t), ...C(t), items: t.resources && t.resources.length ? t.resources : void 0 });
|
367
367
|
}
|
368
|
-
function
|
368
|
+
function Ct(t) {
|
369
369
|
return !t.canvases || t.canvases.length === 0 ? { canvases: [], behavior: [] } : { canvases: t.canvases, behavior: t.viewingHint ? [t.viewingHint] : [], startCanvas: t.startCanvas };
|
370
370
|
}
|
371
|
-
function
|
371
|
+
function bt(t) {
|
372
372
|
function e(r) {
|
373
373
|
if (Array.isArray(r)) {
|
374
374
|
if (r.length > 1) return { type: "List", items: r.map(e) };
|
@@ -381,51 +381,51 @@ function St(t) {
|
|
381
381
|
else if (r.full["@type"] === "dctypes:Image") i = { id: r.full["@id"], type: "Image" };
|
382
382
|
else if (r.full["@type"] === "sc:Canvas") i = { id: r.full["@id"], type: "Canvas" };
|
383
383
|
else throw new Error(`Unsupported source type on annotation: ${r.full["@type"]}`);
|
384
|
-
return { type: "SpecificResource", source: i, selector:
|
384
|
+
return { type: "SpecificResource", source: i, selector: j(r.selector) };
|
385
385
|
} else return encodeURI(r["@id"]).trim();
|
386
386
|
}
|
387
|
-
return
|
387
|
+
return u({ ...d(t), ...y(t), ...C(t), target: e(t.on), body: Array.isArray(t.resource) ? t.resource.map(N) : N(t.resource) });
|
388
388
|
}
|
389
|
-
function
|
390
|
-
return t.type === "Choice" ? t :
|
389
|
+
function N(t) {
|
390
|
+
return t.type === "Choice" ? t : ee(t);
|
391
391
|
}
|
392
|
-
function
|
392
|
+
function ee(t) {
|
393
393
|
let e = t;
|
394
|
-
return
|
394
|
+
return u({ ...d(e), ...y(e), ...C(e), ...ft(e) });
|
395
395
|
}
|
396
|
-
function
|
396
|
+
function Rt(t) {
|
397
397
|
let e = [];
|
398
|
-
return t.default && t.default !== "rdf:nil" && e.push(t.default), t.item && t.item !== "rdf:nil" && e.push(...t.item),
|
398
|
+
return t.default && t.default !== "rdf:nil" && e.push(t.default), t.item && t.item !== "rdf:nil" && e.push(...t.item), u({ ...d(t), ...y(t), items: e });
|
399
399
|
}
|
400
|
-
function
|
401
|
-
return
|
400
|
+
function Lt(t) {
|
401
|
+
return u({ ...d(t), ...y(t), ...C(t), items: t.members });
|
402
402
|
}
|
403
|
-
function
|
404
|
-
let { "@id": e, "@type": r, "@context": i, profile:
|
405
|
-
return e && (a["@id"] = e), a["@type"] =
|
403
|
+
function wt(t) {
|
404
|
+
let { "@id": e, "@type": r, "@context": i, profile: s, ...n } = t, a = {};
|
405
|
+
return e && (a["@id"] = e), a["@type"] = k(t), a["@type"] === "unknown" && (i && i.length && (a["@context"] = i), a["@type"] = "Service"), s && (a.profile = Y(s)), u({ ...a, ...n });
|
406
406
|
}
|
407
|
-
function
|
408
|
-
return
|
407
|
+
function It(t) {
|
408
|
+
return u({ ...d(t), ...y(t), ...C(t) });
|
409
409
|
}
|
410
|
-
var
|
411
|
-
function
|
412
|
-
return t && t["@context"] && (t["@context"] === "http://iiif.io/api/presentation/2/context.json" || t["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || t["@context"] === "http://www.shared-canvas.org/ns/context.json") || t["@context"] === "http://iiif.io/api/image/2/context.json" ?
|
410
|
+
var St = new Oe({ collection: [mt], manifest: [gt], canvas: [yt], annotationList: [At], sequence: [Ct], annotation: [bt], contentResource: [ee], choice: [Rt], range: [Lt], service: [wt], layer: [It] });
|
411
|
+
function te(t) {
|
412
|
+
return t && t["@context"] && (t["@context"] === "http://iiif.io/api/presentation/2/context.json" || t["@context"].indexOf("http://iiif.io/api/presentation/2/context.json") !== -1 || t["@context"] === "http://www.shared-canvas.org/ns/context.json") || t["@context"] === "http://iiif.io/api/image/2/context.json" ? St.traverseUnknown(t) : t;
|
413
413
|
}
|
414
|
-
function
|
414
|
+
function j(t) {
|
415
415
|
if ((Array.isArray(t["@type"]) && t["@type"].includes("oa:SvgSelector") || t["@type"] == "oa:SvgSelector") && ("chars" in t || "value" in t)) return { type: "SvgSelector", value: "chars" in t ? t.chars : t.value };
|
416
416
|
if (t["@type"] === "oa:FragmentSelector") return { type: "FragmentSelector", value: t.value };
|
417
|
-
if (t["@type"] === "oa:Choice") return [
|
417
|
+
if (t["@type"] === "oa:Choice") return [j(t.default), ...(Array.isArray(t.item) ? t.item : [t.item]).map(j)];
|
418
418
|
if (t["@type"] == "iiif:ImageApiSelector") return { type: "ImageApiSelector", region: "region" in t ? t.region : void 0, rotation: "rotation" in t ? t.rotation : void 0 };
|
419
419
|
throw new Error(`Unsupported selector type: ${t["@type"]}`);
|
420
420
|
}
|
421
|
-
function
|
421
|
+
function x(t) {
|
422
422
|
return typeof t == "string" ? !1 : t && !t.type && "source" in t ? (t.type = "SpecificResource", !0) : !!t && t.type === "SpecificResource";
|
423
423
|
}
|
424
|
-
function
|
424
|
+
function S(...t) {
|
425
425
|
return (e) => t.reduce((r, i) => i(r), e);
|
426
426
|
}
|
427
427
|
var q = ["Collection", "Manifest", "Canvas", "AnnotationPage", "AnnotationCollection", "Annotation", "ContentResource", "Range", "Service", "Selector", "Agent"];
|
428
|
-
function
|
428
|
+
function Tt(t, e) {
|
429
429
|
if (typeof t > "u" || t === null) throw new Error("Null or undefined is not a valid entity.");
|
430
430
|
if (Array.isArray(t)) throw new Error("Array is not a valid entity");
|
431
431
|
if (typeof t != "object") {
|
@@ -439,18 +439,18 @@ function kt(t, e) {
|
|
439
439
|
if (t.profile) return "Service";
|
440
440
|
throw new Error("Resource type is not known");
|
441
441
|
}
|
442
|
-
var P = class
|
442
|
+
var P = class re {
|
443
443
|
constructor(e, r = {}) {
|
444
|
-
A(this, "traversals"), A(this, "options"), A(this, "_traverseManifest",
|
444
|
+
A(this, "traversals"), A(this, "options"), A(this, "_traverseManifest", S(this.traverseManifestItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseManifestStructures.bind(this), this.traverseInlineAnnotationPages.bind(this))), A(this, "_traverseCanvas", S(this.traverseCanvasItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this), this.traverseLinkedCanvases.bind(this), this.traverseInlineAnnotationPages.bind(this))), A(this, "_traverseAnnotationPage", S(this.traverseAnnotationPageItems.bind(this), this.traverseLinking.bind(this), this.traverseDescriptive.bind(this))), A(this, "_traverseRange", S(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: [], ...e }, this.options = { allowUndefinedReturn: !1, ...r };
|
445
445
|
}
|
446
446
|
static all(e) {
|
447
|
-
return new
|
447
|
+
return new re({ collection: [e], manifest: [e], canvas: [e], annotationCollection: [e], annotationPage: [e], annotation: [e], contentResource: [e], choice: [e], range: [e], service: [e], geoJson: [e], specificResource: [e], agent: [e] });
|
448
448
|
}
|
449
449
|
traverseDescriptive(e) {
|
450
|
-
return e.thumbnail && (e.thumbnail =
|
450
|
+
return e.thumbnail && (e.thumbnail = b(e.thumbnail).map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.provider && (e.provider = e.provider.map((r) => this.traverseAgent(r, e))), e;
|
451
451
|
}
|
452
452
|
traverseLinking(e) {
|
453
|
-
return e.seeAlso && (e.seeAlso = e.seeAlso.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.service && (e.service =
|
453
|
+
return e.seeAlso && (e.seeAlso = e.seeAlso.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.service && (e.service = b(e.service).map((r) => this.traverseService(r))), e.services && (e.services = b(e.services).map((r) => this.traverseService(r, e))), e.logo && (e.logo = e.logo.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.homepage && (e.homepage = b(e.homepage).map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.partOf && (e.partOf = e.partOf.map((r) => typeof r == "string" || !r.type ? this.traverseType(r, { parent: e }, this.traversals.contentResource) : r.type === "Canvas" ? this.traverseType(r, { parent: e }, this.traversals.canvas) : r.type === "AnnotationCollection" ? this.traverseType(r, { parent: e }, this.traversals.annotationCollection) : r.type === "Collection" ? this.traverseType(r, { parent: e }, this.traversals.collection) : this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.start && (x(e.start) ? e.start = this.traverseSpecificResource(e.start, "Canvas", e) : e.start = this.traverseType(e.start, { parent: e }, this.traversals.canvas)), e.rendering && (e.rendering = e.rendering.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e.supplementary && (e.supplementary = e.supplementary.map((r) => this.traverseType(r, { parent: e }, this.traversals.contentResource))), e;
|
454
454
|
}
|
455
455
|
traverseCollectionItems(e) {
|
456
456
|
return e.items && e.items.map((r) => r.type === "Collection" ? this.traverseCollection(r) : this.traverseManifest(r)), e;
|
@@ -498,17 +498,17 @@ var P = class ae {
|
|
498
498
|
return this.traverseType(this.traverseLinking(this.traverseAnnotationBody(this.traverseDescriptive(e))), { parent: r }, this.traversals.annotation);
|
499
499
|
}
|
500
500
|
traverseContentResourceLinking(e) {
|
501
|
-
return typeof e == "string" || !e || e && e.service && (e.service =
|
501
|
+
return typeof e == "string" || !e || e && e.service && (e.service = b(e.service || []).map((r) => this.traverseService(r, e))), e;
|
502
502
|
}
|
503
503
|
traverseContentResource(e, r) {
|
504
|
-
return e.type === "Choice" && (e.items = e.items.map((i) => this.traverseContentResource(i, e))),
|
504
|
+
return e.type === "Choice" && (e.items = e.items.map((i) => this.traverseContentResource(i, e))), x(e) ? this.traverseSpecificResource(e, "ContentResource") : this.traverseType(this.traverseInlineAnnotationPages(this.traverseContentResourceLinking(e)), { parent: r }, this.traversals.contentResource);
|
505
505
|
}
|
506
506
|
traverseSpecificResource(e, r, i) {
|
507
|
-
let
|
508
|
-
return typeof e.source == "string" && (
|
507
|
+
let s = e.source;
|
508
|
+
return typeof e.source == "string" && (s = { id: e.source, type: r || "unknown" }), this.traverseType({ ...e, source: r === "Canvas" || s.type === "Canvas" ? this.traverseType(s, { parent: i }, this.traversals.canvas) : r === "ContentResource" ? this.traverseContentResource(s, { parent: i }) : this.traverseUnknown(s, { parent: i, typeHint: r }) }, { parent: i }, this.traversals.specificResource);
|
509
509
|
}
|
510
510
|
traverseRangeRanges(e) {
|
511
|
-
return e.items && (e.items = e.items.map((r) => typeof r == "string" ? this.traverseCanvas({ id: r, type: "Canvas" }, e) :
|
511
|
+
return e.items && (e.items = e.items.map((r) => typeof r == "string" ? this.traverseCanvas({ id: r, type: "Canvas" }, e) : x(r) ? this.traverseSpecificResource(r, "Canvas", e) : r.type === "Manifest" ? this.traverseManifest(r, e) : this.traverseRange(r, e))), e;
|
512
512
|
}
|
513
513
|
traverseRange(e, r) {
|
514
514
|
return this.traverseType(this._traverseRange(e), { parent: r }, this.traversals.range);
|
@@ -517,18 +517,18 @@ var P = class ae {
|
|
517
517
|
return this.traverseType(this.traverseDescriptive(this.traverseLinking(e)), { parent: r }, this.traversals.agent);
|
518
518
|
}
|
519
519
|
traverseType(e, r, i) {
|
520
|
-
return i.reduce((
|
521
|
-
let a = s
|
522
|
-
return typeof a > "u" && !this.options.allowUndefinedReturn ?
|
520
|
+
return i.reduce((s, n) => {
|
521
|
+
let a = n(s, r);
|
522
|
+
return typeof a > "u" && !this.options.allowUndefinedReturn ? s : a;
|
523
523
|
}, e);
|
524
524
|
}
|
525
525
|
traverseService(e, r) {
|
526
526
|
let i = Object.assign({}, e);
|
527
|
-
return i && i.service && (i.service =
|
527
|
+
return i && i.service && (i.service = b(i.service).map((s) => this.traverseService(s))), this.traverseType(i, { parent: r }, this.traversals.service);
|
528
528
|
}
|
529
529
|
traverseUnknown(e, { parent: r, typeHint: i } = {}) {
|
530
|
-
let
|
531
|
-
switch (
|
530
|
+
let s = Tt(e, i);
|
531
|
+
switch (s) {
|
532
532
|
case "Collection":
|
533
533
|
return this.traverseCollection(e, r);
|
534
534
|
case "Manifest":
|
@@ -548,71 +548,71 @@ var P = class ae {
|
|
548
548
|
case "Agent":
|
549
549
|
return this.traverseAgent(e, r);
|
550
550
|
default:
|
551
|
-
throw new Error(`Unknown or unsupported resource type of ${
|
551
|
+
throw new Error(`Unknown or unsupported resource type of ${s}`);
|
552
552
|
}
|
553
553
|
}
|
554
554
|
};
|
555
|
-
const
|
556
|
-
const e =
|
555
|
+
const ie = (t) => h(t, "type").startsWith("ImageService") || t.profile && t.profile.toString().includes("iiif.io/api/image/"), se = (t) => {
|
556
|
+
const e = h(t, "type"), r = h(t, "context");
|
557
557
|
if (e === "ImageService2" || r != null && r.includes("image/2")) {
|
558
|
-
const i = t,
|
559
|
-
return { majorVersion: 2, profileLevel: (Array.isArray(i.profile) ? i.profile : [i.profile]).map((
|
558
|
+
const i = t, s = ["level0", "level1", "level2"];
|
559
|
+
return { majorVersion: 2, profileLevel: (Array.isArray(i.profile) ? i.profile : [i.profile]).map((c) => s.findIndex((l) => c.toString().includes(l))).filter((c) => c > -1).sort((c, l) => l - c)[0] };
|
560
560
|
} else if (e || r)
|
561
561
|
return { majorVersion: 3, profileLevel: parseInt(t.profile) };
|
562
|
-
},
|
563
|
-
const i =
|
564
|
-
if (typeof
|
562
|
+
}, _ = (t, e, r) => {
|
563
|
+
const i = h(t, "id"), s = t.profile || "";
|
564
|
+
if (typeof s == "string" && (s.includes("level0") || s.includes("level:0"))) {
|
565
565
|
if ("sizes" in t && Array.isArray(t.sizes)) {
|
566
|
-
const a = t.sizes.sort((
|
566
|
+
const a = t.sizes.sort((c, l) => l.width * l.height - c.width * c.height).filter((c) => c.width * c.height >= e * r)[0];
|
567
567
|
if (a)
|
568
568
|
return `${i}/full/${a.width},${a.height}/0/default.jpg`;
|
569
569
|
}
|
570
570
|
return `${i}/full/full/0/default.jpg`;
|
571
571
|
}
|
572
572
|
return `${i}/full/!${e},${r}/0/default.jpg`;
|
573
|
-
},
|
574
|
-
const i =
|
575
|
-
if (typeof
|
576
|
-
const { x: a, y:
|
577
|
-
return `${i}/${
|
578
|
-
},
|
573
|
+
}, xt = (t, e, r) => {
|
574
|
+
const i = h(t, "id"), s = t.profile || "";
|
575
|
+
if (typeof s == "string" && (s.includes("level0") || s.includes("level:0"))) return;
|
576
|
+
const { x: a, y: c, w: l, h: p } = e, v = l / p, f = v < 1, L = Math.ceil(f ? r / v : r), o = Math.ceil(f ? r : r / v), m = `${Math.round(a)},${Math.round(c)},${Math.round(l)},${Math.round(p)}`;
|
577
|
+
return `${i}/${m}/!${o},${L}/0/default.jpg`;
|
578
|
+
}, $t = (t) => (e, r = 400) => {
|
579
579
|
if (t.type === "dynamic")
|
580
|
-
return
|
580
|
+
return xt(t.service, e, r);
|
581
581
|
console.error("Level 0 or static image canvas: unspported");
|
582
|
-
},
|
583
|
-
const { width: i, height:
|
584
|
-
if (!i || !
|
585
|
-
const
|
582
|
+
}, Mt = (t, e = []) => (r = 400) => {
|
583
|
+
const { width: i, height: s } = t;
|
584
|
+
if (!i || !s) return;
|
585
|
+
const n = i / s, a = n < 1, c = Math.ceil(a ? r / n : r), l = Math.ceil(a ? r : r / n);
|
586
586
|
if (t.thumbnail && t.thumbnail.length > 0) {
|
587
|
-
const
|
588
|
-
if ("service" in
|
589
|
-
const
|
590
|
-
if (
|
591
|
-
return
|
587
|
+
const p = t.thumbnail[0];
|
588
|
+
if ("service" in p && Array.isArray(p.service)) {
|
589
|
+
const v = p.service.find((f) => ie(f));
|
590
|
+
if (v)
|
591
|
+
return _(v, l, c);
|
592
592
|
}
|
593
|
-
if ("id" in
|
593
|
+
if ("id" in p) return p.id;
|
594
594
|
}
|
595
|
-
for (const
|
596
|
-
if (
|
597
|
-
return
|
598
|
-
if (
|
599
|
-
return
|
595
|
+
for (const p of e) {
|
596
|
+
if (p.type === "dynamic" || p.type === "level0")
|
597
|
+
return _(p.service, l, c);
|
598
|
+
if (p.type === "static")
|
599
|
+
return p.url;
|
600
600
|
}
|
601
|
-
},
|
602
|
-
const { format: e, height: r, width: i } = t,
|
601
|
+
}, ne = (t) => t.endsWith("/info.json") ? t : `${t.endsWith("/") ? t : `${t}/`}info.json`, jt = (t) => {
|
602
|
+
const { format: e, height: r, width: i } = t, s = h(t, "id"), n = (t.service || []).find(ie), a = n ? se(n) : void 0;
|
603
603
|
if (a) {
|
604
|
-
const
|
604
|
+
const c = {
|
605
605
|
source: t,
|
606
606
|
type: a.profileLevel === 0 ? "level0" : "dynamic",
|
607
|
-
service:
|
607
|
+
service: n,
|
608
608
|
width: i,
|
609
609
|
height: r,
|
610
610
|
majorVersion: a.majorVersion,
|
611
|
-
serviceUrl:
|
611
|
+
serviceUrl: ne(h(n, "id"))
|
612
612
|
};
|
613
|
-
return a.profileLevel === 0 ?
|
614
|
-
...
|
615
|
-
getRegionURL:
|
613
|
+
return a.profileLevel === 0 ? c : {
|
614
|
+
...c,
|
615
|
+
getRegionURL: $t(c)
|
616
616
|
};
|
617
617
|
} else
|
618
618
|
return {
|
@@ -620,141 +620,57 @@ const oe = (t) => u(t, "type").startsWith("ImageService") || t.profile && t.prof
|
|
620
620
|
type: "static",
|
621
621
|
width: i,
|
622
622
|
height: r,
|
623
|
-
url:
|
623
|
+
url: s,
|
624
624
|
format: e
|
625
625
|
};
|
626
|
-
},
|
626
|
+
}, kt = (t) => {
|
627
627
|
const e = [];
|
628
628
|
return new P({
|
629
629
|
annotation: [(i) => {
|
630
630
|
if (i.motivation === "painting" || !i.motivation) {
|
631
|
-
const
|
632
|
-
e.push(...
|
631
|
+
const n = (i.body ? Array.isArray(i.body) ? i.body : [i.body] : []).filter((a) => a.type === "Image");
|
632
|
+
e.push(...n.map((a) => jt(a)));
|
633
633
|
}
|
634
634
|
}]
|
635
635
|
}).traverseCanvas(t), e;
|
636
|
-
},
|
637
|
-
const e = (
|
638
|
-
const
|
639
|
-
id:
|
636
|
+
}, Pt = (t) => () => {
|
637
|
+
const e = /* @__PURE__ */ new Map(), r = (a, c, l = 0) => {
|
638
|
+
const p = {
|
639
|
+
id: a.id,
|
640
640
|
type: "range",
|
641
|
-
|
641
|
+
source: a,
|
642
642
|
children: [],
|
643
|
-
|
644
|
-
|
643
|
+
navItems: [],
|
644
|
+
navSections: [],
|
645
|
+
parent: c,
|
646
|
+
level: l,
|
647
|
+
getLabel: a.getLabel
|
645
648
|
};
|
646
|
-
|
649
|
+
a.items && a.items.length > 0 && a.items.forEach((o) => {
|
647
650
|
if (o.source.type === "Range") {
|
648
|
-
const
|
649
|
-
|
651
|
+
const I = r(o, p, l + 1);
|
652
|
+
p.children.push(I);
|
650
653
|
} else
|
651
|
-
|
654
|
+
p.children.push({
|
652
655
|
id: o.id,
|
653
656
|
type: "canvas",
|
654
|
-
|
657
|
+
source: o,
|
655
658
|
children: [],
|
656
|
-
|
657
|
-
|
659
|
+
navItems: [],
|
660
|
+
navSections: [],
|
661
|
+
parent: p,
|
662
|
+
level: l + 1,
|
663
|
+
getLabel: o.getLabel
|
658
664
|
});
|
659
|
-
})
|
660
|
-
|
661
|
-
|
662
|
-
var n;
|
663
|
-
return (n = i.source.behavior) == null ? void 0 : n.includes("top");
|
664
|
-
}).map((i) => e(i, void 0));
|
665
|
-
}, p = [];
|
666
|
-
for (let t = 0; t < 256; ++t)
|
667
|
-
p.push((t + 256).toString(16).slice(1));
|
668
|
-
function Nt(t, e = 0) {
|
669
|
-
return (p[t[e + 0]] + p[t[e + 1]] + p[t[e + 2]] + p[t[e + 3]] + "-" + p[t[e + 4]] + p[t[e + 5]] + "-" + p[t[e + 6]] + p[t[e + 7]] + "-" + p[t[e + 8]] + p[t[e + 9]] + "-" + p[t[e + 10]] + p[t[e + 11]] + p[t[e + 12]] + p[t[e + 13]] + p[t[e + 14]] + p[t[e + 15]]).toLowerCase();
|
670
|
-
}
|
671
|
-
let $;
|
672
|
-
const _t = new Uint8Array(16);
|
673
|
-
function qt() {
|
674
|
-
if (!$) {
|
675
|
-
if (typeof crypto > "u" || !crypto.getRandomValues)
|
676
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
677
|
-
$ = crypto.getRandomValues.bind(crypto);
|
678
|
-
}
|
679
|
-
return $(_t);
|
680
|
-
}
|
681
|
-
const Ft = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), W = { randomUUID: Ft };
|
682
|
-
function Wt(t, e, r) {
|
683
|
-
var n;
|
684
|
-
if (W.randomUUID && !t)
|
685
|
-
return W.randomUUID();
|
686
|
-
t = t || {};
|
687
|
-
const i = t.random ?? ((n = t.rng) == null ? void 0 : n.call(t)) ?? qt();
|
688
|
-
if (i.length < 16)
|
689
|
-
throw new Error("Random bytes length must be >= 16");
|
690
|
-
return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, Nt(i);
|
691
|
-
}
|
692
|
-
const H = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ht = (t, e) => {
|
693
|
-
if (e) {
|
694
|
-
const r = t.annotations;
|
695
|
-
if (r.length > 0) {
|
696
|
-
const i = new RegExp(`${H(t.id)}/${H(e)}/page/p(\\d+)$`), n = r.reduce((s, a) => {
|
697
|
-
const o = a.id.match(i);
|
698
|
-
if (o && o[1]) {
|
699
|
-
const c = parseInt(o[1]);
|
700
|
-
return Math.max(s, c);
|
701
|
-
} else
|
702
|
-
return s;
|
703
|
-
}, 1);
|
704
|
-
return `${t.id}/${e}/annotations/page/p${n}`;
|
705
|
-
} else
|
706
|
-
return `${t.id}/${e}/annotations/page/p1`;
|
707
|
-
} else
|
708
|
-
return `${t.id}/annotations/page/${Wt()}`;
|
709
|
-
}, pe = (t, e, r) => {
|
710
|
-
const i = {
|
711
|
-
id: Ht(t, r),
|
712
|
-
type: "AnnotationPage",
|
713
|
-
items: e
|
714
|
-
};
|
715
|
-
return {
|
716
|
-
source: {
|
717
|
-
...t.source,
|
718
|
-
annotations: [...t.annotations, i]
|
719
|
-
},
|
720
|
-
id: t.id,
|
721
|
-
width: t.width,
|
722
|
-
height: t.height,
|
723
|
-
images: [...t.images],
|
724
|
-
annotations: [...t.annotations, i],
|
725
|
-
getLabel: t.getLabel,
|
726
|
-
getMetadata: t.getMetadata,
|
727
|
-
getThumbnailURL: t.getThumbnailURL
|
665
|
+
});
|
666
|
+
const v = p.children.map((o) => o.type === "canvas" ? o.source : o.children.length === 1 && o.children[0].type === "canvas" ? o.children[0].source : o.source), f = v.filter((o) => o.source.type === "Canvas"), L = v.filter((o) => o.source.type === "Range");
|
667
|
+
return p.navItems.push(...f), p.navSections.push(...L), e.set(p.id, p), p;
|
728
668
|
};
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
}, n = e.reduce((a, o) => {
|
735
|
-
const c = i(o);
|
736
|
-
return c && (a[c] || (a[c] = []), a[c].push(o)), a;
|
737
|
-
}, {}), s = t.canvases.map((a) => {
|
738
|
-
const o = n[a.id] || [];
|
739
|
-
return o.length > 0 ? pe(a, o, r) : a;
|
740
|
-
});
|
741
|
-
return {
|
742
|
-
source: {
|
743
|
-
...t.source,
|
744
|
-
items: s.map((a) => a.source)
|
745
|
-
},
|
746
|
-
id: t.id,
|
747
|
-
majorVersion: t.majorVersion,
|
748
|
-
canvases: s,
|
749
|
-
structure: t.structure,
|
750
|
-
getLabel: t.getLabel,
|
751
|
-
getMetadata: t.getMetadata,
|
752
|
-
getTableOfContents: t.getTableOfContents
|
753
|
-
};
|
754
|
-
}, Jt = (t, e, r) => t.source.type === "Canvas" ? pe(t, e, r) : Bt(t, e, r), zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
755
|
-
__proto__: null,
|
756
|
-
importAnnotations: Jt
|
757
|
-
}, Symbol.toStringTag, { value: "Module" })), Gt = async (t) => {
|
669
|
+
return { root: t.filter((a) => {
|
670
|
+
var c;
|
671
|
+
return (c = a.source.behavior) == null ? void 0 : c.includes("top");
|
672
|
+
}).map((a) => r(a, void 0)), getNode: (a) => e.get(a) };
|
673
|
+
}, Ot = async (t) => {
|
758
674
|
try {
|
759
675
|
new URL(t);
|
760
676
|
} catch {
|
@@ -792,7 +708,7 @@ const H = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ht = (t, e) => {
|
|
792
708
|
};
|
793
709
|
try {
|
794
710
|
const i = await e.json();
|
795
|
-
return
|
711
|
+
return ae(i, t);
|
796
712
|
} catch {
|
797
713
|
return {
|
798
714
|
type: "error",
|
@@ -800,15 +716,15 @@ const H = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ht = (t, e) => {
|
|
800
716
|
message: "Could not parse resource"
|
801
717
|
};
|
802
718
|
}
|
803
|
-
},
|
804
|
-
const r = Array.isArray(t["@context"]) ? t["@context"].find((
|
719
|
+
}, ae = (t, e) => {
|
720
|
+
const r = Array.isArray(t["@context"]) ? t["@context"].find((s) => s.includes("iiif.io/api/")) : t["@context"];
|
805
721
|
if (!r)
|
806
722
|
return {
|
807
723
|
type: "error",
|
808
724
|
code: "INVALID_MANIFEST",
|
809
725
|
message: "Missing @context"
|
810
726
|
};
|
811
|
-
const i =
|
727
|
+
const i = h(t, "id");
|
812
728
|
if (!i)
|
813
729
|
return {
|
814
730
|
type: "error",
|
@@ -816,23 +732,23 @@ const H = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ht = (t, e) => {
|
|
816
732
|
message: "Missing id property"
|
817
733
|
};
|
818
734
|
if (r.includes("presentation/2") || r.includes("presentation/3")) {
|
819
|
-
const
|
820
|
-
return
|
735
|
+
const s = r.includes("presentation/2") ? 2 : 3;
|
736
|
+
return h(t, "type").includes("Collection") ? {
|
821
737
|
type: "collection",
|
822
738
|
url: e || i,
|
823
|
-
resource:
|
739
|
+
resource: Ut(t, s)
|
824
740
|
} : {
|
825
741
|
type: "manifest",
|
826
742
|
url: e || i,
|
827
|
-
resource:
|
743
|
+
resource: Dt(t, s)
|
828
744
|
};
|
829
745
|
}
|
830
746
|
if (r.includes("image/2") || r.includes("image/3")) {
|
831
|
-
const
|
832
|
-
return
|
747
|
+
const s = Et(t);
|
748
|
+
return s ? {
|
833
749
|
type: "iiif-image",
|
834
750
|
url: e || i,
|
835
|
-
resource:
|
751
|
+
resource: s
|
836
752
|
} : {
|
837
753
|
type: "error",
|
838
754
|
code: "INVALID_MANIFEST",
|
@@ -844,76 +760,76 @@ const H = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ht = (t, e) => {
|
|
844
760
|
code: "INVALID_MANIFEST",
|
845
761
|
message: "JSON resource is not a recognized IIIF format"
|
846
762
|
};
|
847
|
-
},
|
848
|
-
const r = (
|
763
|
+
}, Ut = (t, e) => {
|
764
|
+
const r = (n) => {
|
849
765
|
const a = [];
|
850
766
|
return new P({
|
851
|
-
manifest: [(
|
852
|
-
}).traverseCollection(
|
853
|
-
id:
|
854
|
-
type:
|
855
|
-
getLabel: w(
|
856
|
-
source:
|
767
|
+
manifest: [(l) => a.push(l)]
|
768
|
+
}).traverseCollection(n), a.map((l) => ({
|
769
|
+
id: l.id,
|
770
|
+
type: l.type,
|
771
|
+
getLabel: w(l),
|
772
|
+
source: l
|
857
773
|
}));
|
858
|
-
}, i = e === 2 ?
|
774
|
+
}, i = e === 2 ? te(t) : t, s = r(i);
|
859
775
|
return {
|
860
776
|
source: i,
|
861
777
|
id: i.id,
|
862
778
|
majorVersion: e,
|
863
|
-
items:
|
779
|
+
items: s,
|
864
780
|
getLabel: w(i),
|
865
|
-
getMetadata:
|
781
|
+
getMetadata: $(i)
|
866
782
|
};
|
867
|
-
},
|
783
|
+
}, Dt = (t, e) => {
|
868
784
|
const r = (a) => {
|
869
|
-
const
|
785
|
+
const c = [], l = [];
|
870
786
|
new P({
|
871
|
-
canvas: [(
|
872
|
-
|
787
|
+
canvas: [(o) => {
|
788
|
+
o.items && c.push(o);
|
873
789
|
}],
|
874
|
-
range: [(
|
875
|
-
|
790
|
+
range: [(o) => {
|
791
|
+
o.type === "Range" && l.push(o);
|
876
792
|
}]
|
877
793
|
}).traverseManifest(a);
|
878
|
-
const
|
879
|
-
const
|
794
|
+
const v = c.map((o) => {
|
795
|
+
const m = kt(o);
|
880
796
|
return {
|
881
|
-
source:
|
882
|
-
id:
|
883
|
-
width:
|
884
|
-
height:
|
885
|
-
images:
|
886
|
-
annotations:
|
887
|
-
getLabel: w(
|
888
|
-
getMetadata:
|
889
|
-
getThumbnailURL:
|
797
|
+
source: o,
|
798
|
+
id: o.id,
|
799
|
+
width: o.width,
|
800
|
+
height: o.height,
|
801
|
+
images: m,
|
802
|
+
annotations: o.annotations || [],
|
803
|
+
getLabel: w(o),
|
804
|
+
getMetadata: $(o),
|
805
|
+
getThumbnailURL: Mt(o, m)
|
890
806
|
};
|
891
|
-
}),
|
892
|
-
const
|
807
|
+
}), f = (o) => {
|
808
|
+
const m = o.items || [], I = m.filter((g) => g.type === "Canvas").map((g) => v.find((T) => T.id === g.id)).filter(Boolean), O = m.filter((g) => g.type === "Range").map((g) => f(g)), oe = [...I, ...O];
|
893
809
|
return {
|
894
|
-
source:
|
895
|
-
id:
|
810
|
+
source: o,
|
811
|
+
id: o.id,
|
896
812
|
// Maintain original order
|
897
|
-
items:
|
898
|
-
canvases:
|
899
|
-
ranges:
|
900
|
-
getLabel: w(
|
813
|
+
items: m.map((g) => oe.find((T) => T.id === g.id)),
|
814
|
+
canvases: I,
|
815
|
+
ranges: O,
|
816
|
+
getLabel: w(o)
|
901
817
|
};
|
902
|
-
},
|
903
|
-
return { canvases:
|
904
|
-
}, i = e === 2 ?
|
818
|
+
}, L = l.map((o) => f(o));
|
819
|
+
return { canvases: v, ranges: L };
|
820
|
+
}, i = e === 2 ? te(t) : t, { canvases: s, ranges: n } = r(i);
|
905
821
|
return {
|
906
822
|
source: i,
|
907
823
|
id: i.id,
|
908
824
|
majorVersion: e,
|
909
|
-
canvases:
|
910
|
-
structure:
|
825
|
+
canvases: s,
|
826
|
+
structure: n,
|
911
827
|
getLabel: w(i),
|
912
|
-
getMetadata:
|
913
|
-
getTableOfContents:
|
828
|
+
getMetadata: $(i),
|
829
|
+
getTableOfContents: Pt(n)
|
914
830
|
};
|
915
|
-
},
|
916
|
-
const { width: e, height: r } = t, i =
|
831
|
+
}, Et = (t) => {
|
832
|
+
const { width: e, height: r } = t, i = se(t);
|
917
833
|
if (i)
|
918
834
|
return {
|
919
835
|
type: i.profileLevel === 0 ? "level0" : "dynamic",
|
@@ -921,22 +837,22 @@ const H = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), Ht = (t, e) => {
|
|
921
837
|
width: e,
|
922
838
|
height: r,
|
923
839
|
majorVersion: i.majorVersion,
|
924
|
-
serviceUrl:
|
840
|
+
serviceUrl: ne(h(t, "id"))
|
925
841
|
};
|
926
|
-
},
|
842
|
+
}, qt = { parse: ae, parseURL: Ot };
|
927
843
|
export {
|
928
|
-
|
929
|
-
|
930
|
-
|
844
|
+
qt as Cozy,
|
845
|
+
_ as getImageURLFromService,
|
846
|
+
kt as getImages,
|
931
847
|
w as getLabel,
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
848
|
+
$ as getMetadata,
|
849
|
+
h as getPropertyValue,
|
850
|
+
$t as getRegionURL,
|
851
|
+
xt as getRegionURLFromService,
|
852
|
+
Ft as getStringValue,
|
853
|
+
Pt as getTableOfContents,
|
854
|
+
Mt as getThumbnailURL,
|
855
|
+
ie as isImageService,
|
856
|
+
ne as normalizeServiceUrl,
|
857
|
+
se as parseImageService
|
942
858
|
};
|