triiiceratops 0.20.2 → 0.20.3
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/annotationAdapter-YY6mE8Lj.js +578 -0
- package/dist/{index-Da-IQTm1.js → index-Bxbso9AH.js} +530 -491
- package/dist/{index-Dt5nnlV1.js → index-DhE7yV99.js} +1 -1
- package/dist/plugins/pdf-export/exportPdf.d.ts +1 -0
- package/dist/plugins/pdf-export/exportPdf.js +48 -3
- package/dist/plugins/pdf-export/exportPdf.test.js +171 -0
- package/dist/plugins/pdf-export.js +1 -1
- package/dist/triiiceratops-bundle.js +1 -1
- package/dist/triiiceratops-element.iife.js +13 -13
- package/dist/utils/resolveCanvasImage.d.ts +2 -0
- package/dist/utils/resolveCanvasImage.js +45 -6
- package/dist/utils/resolveCanvasImage.test.js +14 -0
- package/package.json +1 -1
- package/dist/annotationAdapter-D1CVThou.js +0 -543
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
function Z(t, e = 200) {
|
|
2
|
+
var r, l;
|
|
3
|
+
let i = "";
|
|
4
|
+
try {
|
|
5
|
+
if (t.getThumbnail) {
|
|
6
|
+
const n = t.getThumbnail();
|
|
7
|
+
n && (i = typeof n == "string" ? n : n.id || n["@id"] || "");
|
|
8
|
+
}
|
|
9
|
+
} catch {
|
|
10
|
+
}
|
|
11
|
+
if (i) return i;
|
|
12
|
+
try {
|
|
13
|
+
let n = ((r = t.getImages) == null ? void 0 : r.call(t)) || [];
|
|
14
|
+
if ((!n || !n.length) && t.getContent && (n = t.getContent()), n && n.length > 0) {
|
|
15
|
+
const o = n[0];
|
|
16
|
+
let f = o.getResource ? o.getResource() : null;
|
|
17
|
+
if (!f && o.getBody) {
|
|
18
|
+
const s = o.getBody(), u = ((l = o.__jsonld) == null ? void 0 : l.body) || o.body;
|
|
19
|
+
if ((u == null ? void 0 : u.type) === "Choice" || (u == null ? void 0 : u.type) === "oa:Choice" || s && !Array.isArray(s) && (s.type === "Choice" || s.type === "oa:Choice")) {
|
|
20
|
+
let y = [];
|
|
21
|
+
Array.isArray(s) ? y = s : s && (s.items || s.item) ? y = s.items || s.item : u && (u.items || u.item) && (y = u.items || u.item), y.length > 0 && (f = y[0]);
|
|
22
|
+
} else Array.isArray(s) && s.length > 0 ? f = s[0] : s && (f = s);
|
|
23
|
+
}
|
|
24
|
+
if (f && !f.id && !f.__jsonld && (!f.getServices || f.getServices().length === 0) && (f = null), !f) {
|
|
25
|
+
const s = o.__jsonld || o;
|
|
26
|
+
if (s.body) {
|
|
27
|
+
let u = s.body;
|
|
28
|
+
(u.type === "Choice" || u.type === "oa:Choice") && (u = (u.items || u.item || [])[0] || null), f = Array.isArray(u) ? u[0] : u;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (f) {
|
|
32
|
+
const u = (() => {
|
|
33
|
+
let c = [];
|
|
34
|
+
if (f.getServices && (c = f.getServices()), !c || c.length === 0) {
|
|
35
|
+
const y = f.__jsonld || f;
|
|
36
|
+
y.service && (c = Array.isArray(y.service) ? y.service : [y.service]);
|
|
37
|
+
}
|
|
38
|
+
return c;
|
|
39
|
+
})();
|
|
40
|
+
if (u.length > 0) {
|
|
41
|
+
const c = u[0];
|
|
42
|
+
let y = "";
|
|
43
|
+
try {
|
|
44
|
+
if (y = c.getProfile ? c.getProfile() : c.profile || "", typeof y == "object" && y) {
|
|
45
|
+
const m = y;
|
|
46
|
+
y = m.value || m.id || m["@id"] || JSON.stringify(m);
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
}
|
|
50
|
+
const g = String(y ?? "").toLowerCase(), F = g.includes("level0") || g.includes("level-0"), a = c.id || c["@id"];
|
|
51
|
+
if (!F && a)
|
|
52
|
+
return `${a}/full/${e},/0/default.jpg`;
|
|
53
|
+
}
|
|
54
|
+
if (i = f.id || f["@id"] || f.__jsonld && (f.__jsonld.id || f.__jsonld["@id"]) || "", !i) {
|
|
55
|
+
let c = null;
|
|
56
|
+
if (o.__jsonld && o.__jsonld.body ? c = o.__jsonld.body : o.body && (c = o.body), c) {
|
|
57
|
+
let y = Array.isArray(c) ? c[0] : c;
|
|
58
|
+
(y.type === "Choice" || y.type === "oa:Choice") && (y = (y.items || y.item || [])[0] || y), i = y.id || y["@id"] || "";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
} catch {
|
|
64
|
+
}
|
|
65
|
+
return i;
|
|
66
|
+
}
|
|
67
|
+
function B(t, e) {
|
|
68
|
+
return t === "paged" && e.length > 1;
|
|
69
|
+
}
|
|
70
|
+
function b(t) {
|
|
71
|
+
var e, i;
|
|
72
|
+
return (t == null ? void 0 : t.id) || (t == null ? void 0 : t["@id"]) || ((e = t == null ? void 0 : t.getCanvasId) == null ? void 0 : e.call(t)) || ((i = t == null ? void 0 : t.getId) == null ? void 0 : i.call(t)) || null;
|
|
73
|
+
}
|
|
74
|
+
function v(t) {
|
|
75
|
+
var i, r;
|
|
76
|
+
if (!t) return [];
|
|
77
|
+
let e = ((i = t.getImages) == null ? void 0 : i.call(t)) || [];
|
|
78
|
+
if ((!e || !e.length) && t.getContent && (e = t.getContent()), !e || !e.length) return [];
|
|
79
|
+
for (const l of e) {
|
|
80
|
+
if (!l) continue;
|
|
81
|
+
const n = l.getBody ? l.getBody() : l.body || l.resource, o = ((r = l.__jsonld) == null ? void 0 : r.body) || l.body;
|
|
82
|
+
if ((o == null ? void 0 : o.type) === "Choice" || (o == null ? void 0 : o.type) === "oa:Choice" || n && !Array.isArray(n) && (n.type === "Choice" || n.type === "oa:Choice")) {
|
|
83
|
+
if (Array.isArray(n))
|
|
84
|
+
return n;
|
|
85
|
+
if (n && (n.items || n.item))
|
|
86
|
+
return n.items || n.item;
|
|
87
|
+
if (o && (o.items || o.item))
|
|
88
|
+
return o.items || o.item;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
function S({
|
|
94
|
+
canvases: t,
|
|
95
|
+
currentCanvasId: e,
|
|
96
|
+
currentCanvasIndex: i,
|
|
97
|
+
viewingMode: r,
|
|
98
|
+
pagedOffset: l
|
|
99
|
+
}) {
|
|
100
|
+
if (!e) return [];
|
|
101
|
+
if (i < 0 || i >= t.length) return [];
|
|
102
|
+
const n = [], o = t[i];
|
|
103
|
+
if (!o) return n;
|
|
104
|
+
if (r !== "paged" || i < l)
|
|
105
|
+
return n.push({
|
|
106
|
+
canvasId: e,
|
|
107
|
+
canvas: o
|
|
108
|
+
}), n;
|
|
109
|
+
const s = (i - l) % 2 === 0 ? i : i - 1, u = t[s], c = b(u);
|
|
110
|
+
if (!u || !c) return n;
|
|
111
|
+
n.push({
|
|
112
|
+
canvasId: c,
|
|
113
|
+
canvas: u
|
|
114
|
+
});
|
|
115
|
+
const y = t[s + 1], g = b(y);
|
|
116
|
+
return y && g && n.push({
|
|
117
|
+
canvasId: g,
|
|
118
|
+
canvas: y
|
|
119
|
+
}), n;
|
|
120
|
+
}
|
|
121
|
+
function J({
|
|
122
|
+
canvases: t,
|
|
123
|
+
currentCanvasId: e,
|
|
124
|
+
currentCanvasIndex: i,
|
|
125
|
+
viewingMode: r,
|
|
126
|
+
pagedOffset: l,
|
|
127
|
+
viewingDirection: n,
|
|
128
|
+
getSelectedChoice: o
|
|
129
|
+
}) {
|
|
130
|
+
const f = S({
|
|
131
|
+
canvases: t,
|
|
132
|
+
currentCanvasId: e,
|
|
133
|
+
currentCanvasIndex: i,
|
|
134
|
+
viewingMode: r,
|
|
135
|
+
pagedOffset: l
|
|
136
|
+
});
|
|
137
|
+
if (!f.length) return [];
|
|
138
|
+
const s = r === "paged" && n === "right-to-left", u = {};
|
|
139
|
+
if (r === "paged" && f.length === 2) {
|
|
140
|
+
const [c, y] = f;
|
|
141
|
+
u[c.canvasId] = s ? "right" : "left", u[y.canvasId] = s ? "left" : "right";
|
|
142
|
+
} else
|
|
143
|
+
u[f[0].canvasId] = s ? "right" : "left";
|
|
144
|
+
return f.map(({ canvasId: c, canvas: y }) => {
|
|
145
|
+
const g = v(y);
|
|
146
|
+
return g.length ? {
|
|
147
|
+
canvasId: c,
|
|
148
|
+
choices: g,
|
|
149
|
+
selectedChoiceId: o(c),
|
|
150
|
+
side: u[c] ?? "left"
|
|
151
|
+
} : null;
|
|
152
|
+
}).filter((c) => c !== null);
|
|
153
|
+
}
|
|
154
|
+
function p(t) {
|
|
155
|
+
var e, i;
|
|
156
|
+
return (t == null ? void 0 : t.id) || (t == null ? void 0 : t["@id"]) || ((e = t == null ? void 0 : t.__jsonld) == null ? void 0 : e.id) || ((i = t == null ? void 0 : t.__jsonld) == null ? void 0 : i["@id"]) || null;
|
|
157
|
+
}
|
|
158
|
+
function j(t) {
|
|
159
|
+
return t.endsWith("/info.json") ? t.slice(0, -10) : t;
|
|
160
|
+
}
|
|
161
|
+
function d(t) {
|
|
162
|
+
return typeof t == "number" && Number.isFinite(t) && t > 0 ? t : null;
|
|
163
|
+
}
|
|
164
|
+
function T(t) {
|
|
165
|
+
const e = (t == null ? void 0 : t.__jsonld) || t;
|
|
166
|
+
return {
|
|
167
|
+
width: d(t == null ? void 0 : t.width) || d(e == null ? void 0 : e.width) || (typeof (t == null ? void 0 : t.getWidth) == "function" ? d(t.getWidth()) : null),
|
|
168
|
+
height: d(t == null ? void 0 : t.height) || d(e == null ? void 0 : e.height) || (typeof (t == null ? void 0 : t.getHeight) == "function" ? d(t.getHeight()) : null)
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function w(t, e) {
|
|
172
|
+
return (e == null ? void 0 : e.type) === "Choice" || (e == null ? void 0 : e.type) === "oa:Choice" || !!t && !Array.isArray(t) && (t.type === "Choice" || t.type === "oa:Choice");
|
|
173
|
+
}
|
|
174
|
+
function _(t, e) {
|
|
175
|
+
return e && (e.items || e.item) ? e.items || e.item : Array.isArray(t) ? t : t && (t.items || t.item) ? t.items || t.item : [];
|
|
176
|
+
}
|
|
177
|
+
function R({
|
|
178
|
+
body: t,
|
|
179
|
+
rawBody: e,
|
|
180
|
+
canvasId: i,
|
|
181
|
+
getSelectedChoice: r
|
|
182
|
+
}) {
|
|
183
|
+
const l = Array.isArray(t) ? t : _(t, null), n = _(null, e), o = r == null ? void 0 : r(i);
|
|
184
|
+
if (o) {
|
|
185
|
+
const f = l.find(
|
|
186
|
+
(u) => p(u) === o
|
|
187
|
+
);
|
|
188
|
+
if (f)
|
|
189
|
+
return f;
|
|
190
|
+
const s = n.findIndex(
|
|
191
|
+
(u) => p(u) === o
|
|
192
|
+
);
|
|
193
|
+
if (s >= 0)
|
|
194
|
+
return l[s] || n[s];
|
|
195
|
+
}
|
|
196
|
+
return l[0] || n[0] || null;
|
|
197
|
+
}
|
|
198
|
+
function N(t) {
|
|
199
|
+
var i;
|
|
200
|
+
let e = ((i = t.getImages) == null ? void 0 : i.call(t)) || [];
|
|
201
|
+
return (!e || !e.length) && t.getContent && (e = t.getContent()), e || [];
|
|
202
|
+
}
|
|
203
|
+
function $(t) {
|
|
204
|
+
const e = (t == null ? void 0 : t.__jsonld) || t;
|
|
205
|
+
return !!(t && (t.id || t["@id"] || e != null && e.service || e != null && e.id || e != null && e["@id"]));
|
|
206
|
+
}
|
|
207
|
+
function H(t, e, i) {
|
|
208
|
+
var l;
|
|
209
|
+
let r = t.getResource ? t.getResource() : null;
|
|
210
|
+
if (!r && t.getBody) {
|
|
211
|
+
const n = t.getBody(), o = ((l = t.__jsonld) == null ? void 0 : l.body) || t.body;
|
|
212
|
+
w(n, o) ? r = R({
|
|
213
|
+
body: n,
|
|
214
|
+
rawBody: o,
|
|
215
|
+
canvasId: e,
|
|
216
|
+
getSelectedChoice: i
|
|
217
|
+
}) : Array.isArray(n) && n.length > 0 ? r = n[0] : n && (r = n);
|
|
218
|
+
}
|
|
219
|
+
if (r && !$(r) && (r = null), !r) {
|
|
220
|
+
const n = t.__jsonld || t;
|
|
221
|
+
if (n.body) {
|
|
222
|
+
let o = n.body;
|
|
223
|
+
if (o.type === "Choice" || o.type === "oa:Choice") {
|
|
224
|
+
const f = o.items || o.item || [], s = i == null ? void 0 : i(e);
|
|
225
|
+
o = (s ? f.find((c) => p(c) === s) : null) || f[0] || null;
|
|
226
|
+
}
|
|
227
|
+
r = Array.isArray(o) ? o[0] : o;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return r;
|
|
231
|
+
}
|
|
232
|
+
function x(t) {
|
|
233
|
+
return typeof t == "string" ? /^https?:\/\/iiif\.io\/api\/image\//.test(t) || t === "level0" || t === "level1" || t === "level2" : Array.isArray(t) ? t.some((e) => x(e)) : !1;
|
|
234
|
+
}
|
|
235
|
+
function L(t) {
|
|
236
|
+
return typeof t == "string" ? t || null : Array.isArray(t) && t.find(
|
|
237
|
+
(i) => typeof i == "string"
|
|
238
|
+
) || null;
|
|
239
|
+
}
|
|
240
|
+
function V(t) {
|
|
241
|
+
let e = [];
|
|
242
|
+
const i = (t == null ? void 0 : t.__jsonld) || t;
|
|
243
|
+
return i != null && i.service && (e = Array.isArray(i.service) ? i.service : [i.service]), !e.length && (t != null && t.getServices) && (e = t.getServices()), e.length && e.find((r) => {
|
|
244
|
+
const l = r.getType ? r.getType() : r.type || r["@type"] || "", n = r.getProfile ? r.getProfile() : r.profile || "";
|
|
245
|
+
return l === "ImageService1" || l === "ImageService2" || l === "ImageService3" || x(n);
|
|
246
|
+
}) || null;
|
|
247
|
+
}
|
|
248
|
+
function q(t) {
|
|
249
|
+
const e = V(t), i = p(e), r = e ? e.getProfile ? e.getProfile() : e.profile || "" : null;
|
|
250
|
+
return {
|
|
251
|
+
serviceId: i ? j(i) : null,
|
|
252
|
+
serviceProfile: L(r)
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function D(t) {
|
|
256
|
+
if (!t || !t.includes("/iiif/"))
|
|
257
|
+
return null;
|
|
258
|
+
const e = t.split("/"), i = e.findIndex(
|
|
259
|
+
(r) => r === "full" || /^\d+,\d+,\d+,\d+$/.test(r)
|
|
260
|
+
);
|
|
261
|
+
return i > 0 ? e.slice(0, i).join("/") : null;
|
|
262
|
+
}
|
|
263
|
+
function tt(t, e) {
|
|
264
|
+
var n, o, f;
|
|
265
|
+
const i = e === void 0 ? "Untitled canvas" : `Canvas ${e + 1}`;
|
|
266
|
+
try {
|
|
267
|
+
const s = (n = t.getLabel) == null ? void 0 : n.call(t);
|
|
268
|
+
if (Array.isArray(s) && s.length > 0)
|
|
269
|
+
return ((o = s[0]) == null ? void 0 : o.value) || i;
|
|
270
|
+
} catch {
|
|
271
|
+
}
|
|
272
|
+
const r = t.label || ((f = t.__jsonld) == null ? void 0 : f.label);
|
|
273
|
+
if (typeof r == "string")
|
|
274
|
+
return r;
|
|
275
|
+
const l = (r == null ? void 0 : r.none) || (r == null ? void 0 : r.en);
|
|
276
|
+
return Array.isArray(l) && l.length > 0 ? l[0] : i;
|
|
277
|
+
}
|
|
278
|
+
function O(t) {
|
|
279
|
+
var e, i;
|
|
280
|
+
return p(t) || ((e = t == null ? void 0 : t.getCanvasId) == null ? void 0 : e.call(t)) || ((i = t == null ? void 0 : t.getId) == null ? void 0 : i.call(t)) || "";
|
|
281
|
+
}
|
|
282
|
+
function E(t, e = {}) {
|
|
283
|
+
const i = O(t);
|
|
284
|
+
if (!i)
|
|
285
|
+
return null;
|
|
286
|
+
const r = N(t);
|
|
287
|
+
if (!r.length)
|
|
288
|
+
return null;
|
|
289
|
+
const l = r[0], n = H(
|
|
290
|
+
l,
|
|
291
|
+
i,
|
|
292
|
+
e.getSelectedChoice
|
|
293
|
+
);
|
|
294
|
+
if (!n)
|
|
295
|
+
return null;
|
|
296
|
+
const o = p(n), f = T(n), s = q(n), u = s.serviceId || D(o);
|
|
297
|
+
return {
|
|
298
|
+
canvasId: i,
|
|
299
|
+
annotation: l,
|
|
300
|
+
resource: n,
|
|
301
|
+
resourceId: o,
|
|
302
|
+
resourceWidth: f.width,
|
|
303
|
+
resourceHeight: f.height,
|
|
304
|
+
serviceId: u,
|
|
305
|
+
serviceProfile: s.serviceProfile
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function G(t, e = {}) {
|
|
309
|
+
const i = E(t, e);
|
|
310
|
+
return i ? i.serviceId ? `${i.serviceId}/info.json` : i.resourceId ? { type: "image", url: i.resourceId } : null : null;
|
|
311
|
+
}
|
|
312
|
+
function et(t, e = {
|
|
313
|
+
width: 1600
|
|
314
|
+
}) {
|
|
315
|
+
const i = j(t), r = e.quality || "default", l = e.format || "jpg", n = typeof e.width == "number" ? Math.max(1, Math.round(e.width)) : null, o = typeof e.height == "number" ? Math.max(1, Math.round(e.height)) : null, f = n ? `${n},` : `,${o || 1600}`;
|
|
316
|
+
return `${i}/full/${f}/0/${r}.${l}`;
|
|
317
|
+
}
|
|
318
|
+
function it({
|
|
319
|
+
canvases: t,
|
|
320
|
+
currentCanvasIndex: e,
|
|
321
|
+
currentCanvasId: i,
|
|
322
|
+
viewingMode: r,
|
|
323
|
+
pagedOffset: l,
|
|
324
|
+
getSelectedChoice: n
|
|
325
|
+
}) {
|
|
326
|
+
if (!t.length || e < 0 || !t[e])
|
|
327
|
+
return null;
|
|
328
|
+
let o = [t[e]];
|
|
329
|
+
r === "continuous" ? o = t : r === "paged" && (o = S({
|
|
330
|
+
canvases: t,
|
|
331
|
+
currentCanvasId: i,
|
|
332
|
+
currentCanvasIndex: e,
|
|
333
|
+
viewingMode: r,
|
|
334
|
+
pagedOffset: l
|
|
335
|
+
}).map(({ canvas: s }) => s));
|
|
336
|
+
const f = o.map((s) => G(s, { getSelectedChoice: n })).filter((s) => s !== null);
|
|
337
|
+
return f.length ? f : null;
|
|
338
|
+
}
|
|
339
|
+
function P(t) {
|
|
340
|
+
return t.id || t["@id"] || (typeof t.getId == "function" ? t.getId() : "");
|
|
341
|
+
}
|
|
342
|
+
function h(t) {
|
|
343
|
+
if (!t) return null;
|
|
344
|
+
const e = t.match(
|
|
345
|
+
/xywh=(?:pixel:)?([\d.]+),([\d.]+),([\d.]+),([\d.]+)/
|
|
346
|
+
);
|
|
347
|
+
return e ? {
|
|
348
|
+
x: parseFloat(e[1]),
|
|
349
|
+
y: parseFloat(e[2]),
|
|
350
|
+
w: parseFloat(e[3]),
|
|
351
|
+
h: parseFloat(e[4])
|
|
352
|
+
} : null;
|
|
353
|
+
}
|
|
354
|
+
function M(t) {
|
|
355
|
+
const e = z(t);
|
|
356
|
+
if (e)
|
|
357
|
+
return W(e);
|
|
358
|
+
const i = k(t);
|
|
359
|
+
return i ? {
|
|
360
|
+
type: "RECTANGLE",
|
|
361
|
+
x: i.x,
|
|
362
|
+
y: i.y,
|
|
363
|
+
w: i.w,
|
|
364
|
+
h: i.h
|
|
365
|
+
} : null;
|
|
366
|
+
}
|
|
367
|
+
function z(t) {
|
|
368
|
+
var i, r;
|
|
369
|
+
if (typeof t.getTarget == "function") {
|
|
370
|
+
const l = ((i = t.__jsonld) == null ? void 0 : i.on) || ((r = t.__jsonld) == null ? void 0 : r.target);
|
|
371
|
+
if (l)
|
|
372
|
+
return I(l);
|
|
373
|
+
}
|
|
374
|
+
const e = t.target || t.on;
|
|
375
|
+
return e ? I(e) : null;
|
|
376
|
+
}
|
|
377
|
+
function I(t) {
|
|
378
|
+
if (!t) return null;
|
|
379
|
+
if (Array.isArray(t))
|
|
380
|
+
for (const e of t) {
|
|
381
|
+
const i = C(e);
|
|
382
|
+
if (i) return i;
|
|
383
|
+
}
|
|
384
|
+
else
|
|
385
|
+
return C(t);
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
function C(t) {
|
|
389
|
+
var i;
|
|
390
|
+
if (!t) return null;
|
|
391
|
+
const e = t.selector || t;
|
|
392
|
+
if (Array.isArray(e)) {
|
|
393
|
+
const r = e.find((l) => l.type === "SvgSelector");
|
|
394
|
+
return r && r.value ? r.value : null;
|
|
395
|
+
}
|
|
396
|
+
return (e == null ? void 0 : e.type) === "SvgSelector" && e.value ? e.value : ((i = e == null ? void 0 : e.item) == null ? void 0 : i.type) === "SvgSelector" && e.item.value ? e.item.value : null;
|
|
397
|
+
}
|
|
398
|
+
function W(t) {
|
|
399
|
+
try {
|
|
400
|
+
const i = new DOMParser().parseFromString(t, "image/svg+xml");
|
|
401
|
+
if (i.documentElement.nodeName === "parsererror")
|
|
402
|
+
return console.warn("Failed to parse SVG selector:", t), null;
|
|
403
|
+
const r = [], l = i.querySelectorAll("polygon");
|
|
404
|
+
for (const s of l) {
|
|
405
|
+
const u = s.getAttribute("points");
|
|
406
|
+
if (u) {
|
|
407
|
+
const c = X(u);
|
|
408
|
+
r.push(...c);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
const n = i.querySelectorAll("path");
|
|
412
|
+
for (const s of n) {
|
|
413
|
+
const u = s.getAttribute("d");
|
|
414
|
+
if (u) {
|
|
415
|
+
const c = U(u);
|
|
416
|
+
r.push(...c);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const o = i.querySelectorAll("circle");
|
|
420
|
+
for (const s of o) {
|
|
421
|
+
const u = parseFloat(s.getAttribute("cx") || "0"), c = parseFloat(s.getAttribute("cy") || "0"), y = parseFloat(s.getAttribute("r") || "0"), g = Y(u, c, y);
|
|
422
|
+
r.push(...g);
|
|
423
|
+
}
|
|
424
|
+
const f = i.querySelectorAll("rect");
|
|
425
|
+
for (const s of f) {
|
|
426
|
+
const u = parseFloat(s.getAttribute("x") || "0"), c = parseFloat(s.getAttribute("y") || "0"), y = parseFloat(s.getAttribute("width") || "0"), g = parseFloat(s.getAttribute("height") || "0");
|
|
427
|
+
r.push([u, c], [u + y, c], [u + y, c + g], [u, c + g]);
|
|
428
|
+
}
|
|
429
|
+
return r.length === 0 ? null : {
|
|
430
|
+
type: "POLYGON",
|
|
431
|
+
points: r
|
|
432
|
+
};
|
|
433
|
+
} catch (e) {
|
|
434
|
+
return console.warn("Failed to convert SVG to polygon:", e), null;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
function X(t) {
|
|
438
|
+
const e = [], i = t.trim().split(/\s+/);
|
|
439
|
+
for (const r of i) {
|
|
440
|
+
const [l, n] = r.split(",").map((o) => parseFloat(o));
|
|
441
|
+
!isNaN(l) && !isNaN(n) && e.push([l, n]);
|
|
442
|
+
}
|
|
443
|
+
return e;
|
|
444
|
+
}
|
|
445
|
+
function U(t) {
|
|
446
|
+
const e = [], i = /[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;
|
|
447
|
+
let r;
|
|
448
|
+
for (; (r = i.exec(t)) !== null; ) {
|
|
449
|
+
const l = parseFloat(r[1]), n = parseFloat(r[2]);
|
|
450
|
+
!isNaN(l) && !isNaN(n) && e.push([l, n]);
|
|
451
|
+
}
|
|
452
|
+
return e;
|
|
453
|
+
}
|
|
454
|
+
function Y(t, e, i, r = 8) {
|
|
455
|
+
const l = [];
|
|
456
|
+
for (let n = 0; n < r; n++) {
|
|
457
|
+
const o = n / r * Math.PI * 2, f = t + i * Math.cos(o), s = e + i * Math.sin(o);
|
|
458
|
+
l.push([f, s]);
|
|
459
|
+
}
|
|
460
|
+
return l;
|
|
461
|
+
}
|
|
462
|
+
function k(t) {
|
|
463
|
+
var i;
|
|
464
|
+
if (typeof t.getTarget == "function") {
|
|
465
|
+
const r = t.getTarget();
|
|
466
|
+
if (typeof r == "string" && r.includes("xywh="))
|
|
467
|
+
return h(r);
|
|
468
|
+
const l = (i = t.__jsonld) == null ? void 0 : i.on;
|
|
469
|
+
if (l) {
|
|
470
|
+
const n = A(l);
|
|
471
|
+
if (n) return n;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const e = t.target || t.on;
|
|
475
|
+
return e ? A(e) : null;
|
|
476
|
+
}
|
|
477
|
+
function A(t) {
|
|
478
|
+
if (!t) return null;
|
|
479
|
+
if (Array.isArray(t))
|
|
480
|
+
for (const e of t) {
|
|
481
|
+
const i = A(e);
|
|
482
|
+
if (i) return i;
|
|
483
|
+
}
|
|
484
|
+
if (typeof t == "string" && t.includes("xywh="))
|
|
485
|
+
return h(t);
|
|
486
|
+
if (t.selector) {
|
|
487
|
+
const e = t.selector;
|
|
488
|
+
if (Array.isArray(e)) {
|
|
489
|
+
const r = e.find(
|
|
490
|
+
(n) => n.type === "FragmentSelector" && n.value && n.value.includes("xywh=")
|
|
491
|
+
);
|
|
492
|
+
if (r) return h(r.value);
|
|
493
|
+
const l = e.find(
|
|
494
|
+
(n) => n.value && n.value.includes("xywh=")
|
|
495
|
+
);
|
|
496
|
+
return l ? h(l.value) : null;
|
|
497
|
+
}
|
|
498
|
+
const i = e.item || e;
|
|
499
|
+
if (i.value && typeof i.value == "string" && i.value.includes("xywh="))
|
|
500
|
+
return h(i.value);
|
|
501
|
+
}
|
|
502
|
+
return null;
|
|
503
|
+
}
|
|
504
|
+
function K(t) {
|
|
505
|
+
const e = [];
|
|
506
|
+
if (typeof t.getBody == "function") {
|
|
507
|
+
const i = t.getBody();
|
|
508
|
+
if (i) {
|
|
509
|
+
const r = Array.isArray(i) ? i : [i];
|
|
510
|
+
for (const l of r) {
|
|
511
|
+
const n = l.getValue ? l.getValue() : "";
|
|
512
|
+
if (n) {
|
|
513
|
+
const o = l.getFormat ? l.getFormat() : "", f = l.getPurpose ? l.getPurpose() : void 0;
|
|
514
|
+
e.push({
|
|
515
|
+
value: n,
|
|
516
|
+
isHtml: o === "text/html" || o === "application/html",
|
|
517
|
+
purpose: f,
|
|
518
|
+
format: o
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
} else {
|
|
524
|
+
const i = (r) => {
|
|
525
|
+
const l = r.chars || r.value || r["cnt:chars"] || "";
|
|
526
|
+
if (l) {
|
|
527
|
+
const n = r.format === "text/html" || r.type === "TextualBody";
|
|
528
|
+
e.push({
|
|
529
|
+
value: l,
|
|
530
|
+
isHtml: n,
|
|
531
|
+
purpose: r.purpose,
|
|
532
|
+
format: r.format
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
t.resource ? (Array.isArray(t.resource) ? t.resource : [t.resource]).forEach(i) : t.body && (Array.isArray(t.body) ? t.body : [t.body]).forEach(i);
|
|
537
|
+
}
|
|
538
|
+
if (e.length === 0) {
|
|
539
|
+
let i = "";
|
|
540
|
+
typeof t.getLabel == "function" ? i = t.getLabel() || "" : t.label && (i = Array.isArray(t.label) ? t.label.join(" ") : t.label), i && e.push({ value: i, isHtml: !1, purpose: "commenting" });
|
|
541
|
+
}
|
|
542
|
+
return e.length === 0 && e.push({
|
|
543
|
+
value: "Annotation",
|
|
544
|
+
isHtml: !1,
|
|
545
|
+
purpose: "commenting"
|
|
546
|
+
}), e;
|
|
547
|
+
}
|
|
548
|
+
function Q(t, e, i = !1) {
|
|
549
|
+
const r = P(t) || `anno-${e}`, l = M(t);
|
|
550
|
+
if (!l)
|
|
551
|
+
return null;
|
|
552
|
+
const n = K(t);
|
|
553
|
+
return {
|
|
554
|
+
id: r,
|
|
555
|
+
geometry: l,
|
|
556
|
+
body: n,
|
|
557
|
+
isSearchHit: i
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function rt(t, e = /* @__PURE__ */ new Set()) {
|
|
561
|
+
return t.map((i, r) => {
|
|
562
|
+
const l = e.has(P(i));
|
|
563
|
+
return Q(i, r, l);
|
|
564
|
+
}).filter((i) => i !== null);
|
|
565
|
+
}
|
|
566
|
+
export {
|
|
567
|
+
J as a,
|
|
568
|
+
it as b,
|
|
569
|
+
Q as c,
|
|
570
|
+
tt as d,
|
|
571
|
+
K as e,
|
|
572
|
+
O as f,
|
|
573
|
+
Z as g,
|
|
574
|
+
et as h,
|
|
575
|
+
rt as p,
|
|
576
|
+
E as r,
|
|
577
|
+
B as s
|
|
578
|
+
};
|