triiiceratops 0.20.0 → 0.20.2

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.
@@ -12,19 +12,19 @@ function k(e, t = 200) {
12
12
  try {
13
13
  let n = ((i = e.getImages) == null ? void 0 : i.call(e)) || [];
14
14
  if ((!n || !n.length) && e.getContent && (n = e.getContent()), n && n.length > 0) {
15
- const o = n[0];
16
- let u = o.getResource ? o.getResource() : null;
17
- if (!u && o.getBody) {
18
- const l = o.getBody(), f = ((s = o.__jsonld) == null ? void 0 : s.body) || o.body;
19
- if ((f == null ? void 0 : f.type) === "Choice" || (f == null ? void 0 : f.type) === "oa:Choice" || l && !Array.isArray(l) && (l.type === "Choice" || l.type === "oa:Choice")) {
15
+ const l = n[0];
16
+ let u = l.getResource ? l.getResource() : null;
17
+ if (!u && l.getBody) {
18
+ const o = l.getBody(), f = ((s = l.__jsonld) == null ? void 0 : s.body) || l.body;
19
+ if ((f == null ? void 0 : f.type) === "Choice" || (f == null ? void 0 : f.type) === "oa:Choice" || o && !Array.isArray(o) && (o.type === "Choice" || o.type === "oa:Choice")) {
20
20
  let y = [];
21
- Array.isArray(l) ? y = l : l && (l.items || l.item) ? y = l.items || l.item : f && (f.items || f.item) && (y = f.items || f.item), y.length > 0 && (u = y[0]);
22
- } else Array.isArray(l) && l.length > 0 ? u = l[0] : l && (u = l);
21
+ Array.isArray(o) ? y = o : o && (o.items || o.item) ? y = o.items || o.item : f && (f.items || f.item) && (y = f.items || f.item), y.length > 0 && (u = y[0]);
22
+ } else Array.isArray(o) && o.length > 0 ? u = o[0] : o && (u = o);
23
23
  }
24
24
  if (u && !u.id && !u.__jsonld && (!u.getServices || u.getServices().length === 0) && (u = null), !u) {
25
- const l = o.__jsonld || o;
26
- if (l.body) {
27
- let f = l.body;
25
+ const o = l.__jsonld || l;
26
+ if (o.body) {
27
+ let f = o.body;
28
28
  (f.type === "Choice" || f.type === "oa:Choice") && (f = (f.items || f.item || [])[0] || null), u = Array.isArray(f) ? f[0] : f;
29
29
  }
30
30
  }
@@ -53,7 +53,7 @@ function k(e, t = 200) {
53
53
  }
54
54
  if (r = u.id || u["@id"] || u.__jsonld && (u.__jsonld.id || u.__jsonld["@id"]) || "", !r) {
55
55
  let c = null;
56
- if (o.__jsonld && o.__jsonld.body ? c = o.__jsonld.body : o.body && (c = o.body), c) {
56
+ if (l.__jsonld && l.__jsonld.body ? c = l.__jsonld.body : l.body && (c = l.body), c) {
57
57
  let y = Array.isArray(c) ? c[0] : c;
58
58
  (y.type === "Choice" || y.type === "oa:Choice") && (y = (y.items || y.item || [])[0] || y), r = y.id || y["@id"] || "";
59
59
  }
@@ -78,14 +78,14 @@ function P(e) {
78
78
  if ((!t || !t.length) && e.getContent && (t = e.getContent()), !t || !t.length) return [];
79
79
  for (const s of t) {
80
80
  if (!s) continue;
81
- const n = s.getBody ? s.getBody() : s.body || s.resource, o = ((i = s.__jsonld) == null ? void 0 : i.body) || s.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")) {
81
+ const n = s.getBody ? s.getBody() : s.body || s.resource, l = ((i = s.__jsonld) == null ? void 0 : i.body) || s.body;
82
+ if ((l == null ? void 0 : l.type) === "Choice" || (l == null ? void 0 : l.type) === "oa:Choice" || n && !Array.isArray(n) && (n.type === "Choice" || n.type === "oa:Choice")) {
83
83
  if (Array.isArray(n))
84
84
  return n;
85
85
  if (n && (n.items || n.item))
86
86
  return n.items || n.item;
87
- if (o && (o.items || o.item))
88
- return o.items || o.item;
87
+ if (l && (l.items || l.item))
88
+ return l.items || l.item;
89
89
  }
90
90
  }
91
91
  return [];
@@ -99,20 +99,20 @@ function C({
99
99
  }) {
100
100
  if (!t) return [];
101
101
  if (r < 0 || r >= e.length) return [];
102
- const n = [], o = e[r];
103
- if (!o) return n;
102
+ const n = [], l = e[r];
103
+ if (!l) return n;
104
104
  if (i !== "paged" || r < s)
105
105
  return n.push({
106
106
  canvasId: t,
107
- canvas: o
107
+ canvas: l
108
108
  }), n;
109
- const l = (r - s) % 2 === 0 ? r : r - 1, f = e[l], c = a(f);
109
+ const o = (r - s) % 2 === 0 ? r : r - 1, f = e[o], c = a(f);
110
110
  if (!f || !c) return n;
111
111
  n.push({
112
112
  canvasId: c,
113
113
  canvas: f
114
114
  });
115
- const y = e[l + 1], g = a(y);
115
+ const y = e[o + 1], g = a(y);
116
116
  return y && g && n.push({
117
117
  canvasId: g,
118
118
  canvas: y
@@ -125,7 +125,7 @@ function Q({
125
125
  viewingMode: i,
126
126
  pagedOffset: s,
127
127
  viewingDirection: n,
128
- getSelectedChoice: o
128
+ getSelectedChoice: l
129
129
  }) {
130
130
  const u = C({
131
131
  canvases: e,
@@ -135,18 +135,18 @@ function Q({
135
135
  pagedOffset: s
136
136
  });
137
137
  if (!u.length) return [];
138
- const l = i === "paged" && n === "right-to-left", f = {};
138
+ const o = i === "paged" && n === "right-to-left", f = {};
139
139
  if (i === "paged" && u.length === 2) {
140
140
  const [c, y] = u;
141
- f[c.canvasId] = l ? "right" : "left", f[y.canvasId] = l ? "left" : "right";
141
+ f[c.canvasId] = o ? "right" : "left", f[y.canvasId] = o ? "left" : "right";
142
142
  } else
143
- f[u[0].canvasId] = l ? "right" : "left";
143
+ f[u[0].canvasId] = o ? "right" : "left";
144
144
  return u.map(({ canvasId: c, canvas: y }) => {
145
145
  const g = P(y);
146
146
  return g.length ? {
147
147
  canvasId: c,
148
148
  choices: g,
149
- selectedChoiceId: o(c),
149
+ selectedChoiceId: l(c),
150
150
  side: f[c] ?? "left"
151
151
  } : null;
152
152
  }).filter((c) => c !== null);
@@ -169,29 +169,29 @@ function T(e) {
169
169
  let t = ((r = e.getImages) == null ? void 0 : r.call(e)) || [];
170
170
  return (!t || !t.length) && e.getContent && (t = e.getContent()), t || [];
171
171
  }
172
- function N(e) {
172
+ function $(e) {
173
173
  const t = (e == null ? void 0 : e.__jsonld) || e;
174
174
  return !!(e && (e.id || e["@id"] || t != null && t.service || t != null && t.id || t != null && t["@id"]));
175
175
  }
176
- function R(e, t, r) {
176
+ function N(e, t, r) {
177
177
  var s;
178
178
  let i = e.getResource ? e.getResource() : null;
179
179
  if (!i && e.getBody) {
180
- const n = e.getBody(), o = ((s = e.__jsonld) == null ? void 0 : s.body) || e.body;
181
- if (F(n, o)) {
182
- const u = v(n, o), l = r == null ? void 0 : r(t);
183
- i = (l ? u.find((c) => p(c) === l) : null) || u[0] || null;
180
+ const n = e.getBody(), l = ((s = e.__jsonld) == null ? void 0 : s.body) || e.body;
181
+ if (F(n, l)) {
182
+ const u = v(n, l), o = r == null ? void 0 : r(t);
183
+ i = (o ? u.find((c) => p(c) === o) : null) || u[0] || null;
184
184
  } else Array.isArray(n) && n.length > 0 ? i = n[0] : n && (i = n);
185
185
  }
186
- if (i && !N(i) && (i = null), !i) {
186
+ if (i && !$(i) && (i = null), !i) {
187
187
  const n = e.__jsonld || e;
188
188
  if (n.body) {
189
- let o = n.body;
190
- if (o.type === "Choice" || o.type === "oa:Choice") {
191
- const u = o.items || o.item || [], l = r == null ? void 0 : r(t);
192
- o = (l ? u.find((c) => p(c) === l) : null) || u[0] || null;
189
+ let l = n.body;
190
+ if (l.type === "Choice" || l.type === "oa:Choice") {
191
+ const u = l.items || l.item || [], o = r == null ? void 0 : r(t);
192
+ l = (o ? u.find((c) => p(c) === o) : null) || u[0] || null;
193
193
  }
194
- i = Array.isArray(o) ? o[0] : o;
194
+ i = Array.isArray(l) ? l[0] : l;
195
195
  }
196
196
  }
197
197
  return i;
@@ -199,12 +199,12 @@ function R(e, t, r) {
199
199
  function S(e) {
200
200
  return typeof e == "string" ? /^https?:\/\/iiif\.io\/api\/image\//.test(e) || e === "level0" || e === "level1" || e === "level2" : Array.isArray(e) ? e.some((t) => S(t)) : !1;
201
201
  }
202
- function $(e) {
202
+ function R(e) {
203
203
  return typeof e == "string" ? e || null : Array.isArray(e) && e.find(
204
204
  (r) => typeof r == "string"
205
205
  ) || null;
206
206
  }
207
- function L(e) {
207
+ function w(e) {
208
208
  let t = [];
209
209
  const r = (e == null ? void 0 : e.__jsonld) || e;
210
210
  return r != null && r.service && (t = Array.isArray(r.service) ? r.service : [r.service]), !t.length && (e != null && e.getServices) && (t = e.getServices()), t.length && t.find((i) => {
@@ -212,14 +212,14 @@ function L(e) {
212
212
  return s === "ImageService1" || s === "ImageService2" || s === "ImageService3" || S(n);
213
213
  }) || null;
214
214
  }
215
- function V(e) {
216
- const t = L(e), r = p(t), i = t ? t.getProfile ? t.getProfile() : t.profile || "" : null;
215
+ function L(e) {
216
+ const t = w(e), r = p(t), i = t ? t.getProfile ? t.getProfile() : t.profile || "" : null;
217
217
  return {
218
218
  serviceId: r ? I(r) : null,
219
- serviceProfile: $(i)
219
+ serviceProfile: R(i)
220
220
  };
221
221
  }
222
- function q(e) {
222
+ function V(e) {
223
223
  if (!e || !e.includes("/iiif/"))
224
224
  return null;
225
225
  const t = e.split("/"), r = t.findIndex(
@@ -228,12 +228,12 @@ function q(e) {
228
228
  return r > 0 ? t.slice(0, r).join("/") : null;
229
229
  }
230
230
  function Z(e, t) {
231
- var n, o, u;
231
+ var n, l, u;
232
232
  const r = t === void 0 ? "Untitled canvas" : `Canvas ${t + 1}`;
233
233
  try {
234
- const l = (n = e.getLabel) == null ? void 0 : n.call(e);
235
- if (Array.isArray(l) && l.length > 0)
236
- return ((o = l[0]) == null ? void 0 : o.value) || r;
234
+ const o = (n = e.getLabel) == null ? void 0 : n.call(e);
235
+ if (Array.isArray(o) && o.length > 0)
236
+ return ((l = o[0]) == null ? void 0 : l.value) || r;
237
237
  } catch {
238
238
  }
239
239
  const i = e.label || ((u = e.__jsonld) == null ? void 0 : u.label);
@@ -242,31 +242,31 @@ function Z(e, t) {
242
242
  const s = (i == null ? void 0 : i.none) || (i == null ? void 0 : i.en);
243
243
  return Array.isArray(s) && s.length > 0 ? s[0] : r;
244
244
  }
245
- function w(e) {
245
+ function q(e) {
246
246
  var t, r;
247
247
  return p(e) || ((t = e == null ? void 0 : e.getCanvasId) == null ? void 0 : t.call(e)) || ((r = e == null ? void 0 : e.getId) == null ? void 0 : r.call(e)) || "";
248
248
  }
249
249
  function O(e, t = {}) {
250
- const r = w(e);
250
+ const r = q(e);
251
251
  if (!r)
252
252
  return null;
253
253
  const i = T(e);
254
254
  if (!i.length)
255
255
  return null;
256
- const s = i[0], n = R(
256
+ const s = i[0], n = N(
257
257
  s,
258
258
  r,
259
259
  t.getSelectedChoice
260
260
  );
261
261
  if (!n)
262
262
  return null;
263
- const o = p(n), u = V(n), l = u.serviceId || q(o);
263
+ const l = p(n), u = L(n), o = u.serviceId || V(l);
264
264
  return {
265
265
  canvasId: r,
266
266
  annotation: s,
267
267
  resource: n,
268
- resourceId: o,
269
- serviceId: l,
268
+ resourceId: l,
269
+ serviceId: o,
270
270
  serviceProfile: u.serviceProfile
271
271
  };
272
272
  }
@@ -277,8 +277,8 @@ function E(e, t = {}) {
277
277
  function B(e, t = {
278
278
  width: 1600
279
279
  }) {
280
- const r = I(e), i = t.quality || "default", s = t.format || "jpg";
281
- return `${r}/full/${Math.max(1, Math.round(t.width))},/0/${i}.${s}`;
280
+ const r = I(e), i = t.quality || "default", s = t.format || "jpg", n = typeof t.width == "number" ? Math.max(1, Math.round(t.width)) : null, l = typeof t.height == "number" ? Math.max(1, Math.round(t.height)) : null, u = n ? `${n},` : `,${l || 1600}`;
281
+ return `${r}/full/${u}/0/${i}.${s}`;
282
282
  }
283
283
  function J({
284
284
  canvases: e,
@@ -290,15 +290,15 @@ function J({
290
290
  }) {
291
291
  if (!e.length || t < 0 || !e[t])
292
292
  return null;
293
- let o = [e[t]];
294
- i === "continuous" ? o = e : i === "paged" && (o = C({
293
+ let l = [e[t]];
294
+ i === "continuous" ? l = e : i === "paged" && (l = C({
295
295
  canvases: e,
296
296
  currentCanvasId: r,
297
297
  currentCanvasIndex: t,
298
298
  viewingMode: i,
299
299
  pagedOffset: s
300
- }).map(({ canvas: l }) => l));
301
- const u = o.map((l) => E(l, { getSelectedChoice: n })).filter((l) => l !== null);
300
+ }).map(({ canvas: o }) => o));
301
+ const u = l.map((o) => E(o, { getSelectedChoice: n })).filter((o) => o !== null);
302
302
  return u.length ? u : null;
303
303
  }
304
304
  function j(e) {
@@ -319,7 +319,7 @@ function d(e) {
319
319
  function G(e) {
320
320
  const t = H(e);
321
321
  if (t)
322
- return D(t);
322
+ return M(t);
323
323
  const r = U(e);
324
324
  return r ? {
325
325
  type: "RECTANGLE",
@@ -360,35 +360,35 @@ function _(e) {
360
360
  }
361
361
  return (t == null ? void 0 : t.type) === "SvgSelector" && t.value ? t.value : ((r = t == null ? void 0 : t.item) == null ? void 0 : r.type) === "SvgSelector" && t.item.value ? t.item.value : null;
362
362
  }
363
- function D(e) {
363
+ function M(e) {
364
364
  try {
365
365
  const r = new DOMParser().parseFromString(e, "image/svg+xml");
366
366
  if (r.documentElement.nodeName === "parsererror")
367
367
  return console.warn("Failed to parse SVG selector:", e), null;
368
368
  const i = [], s = r.querySelectorAll("polygon");
369
- for (const l of s) {
370
- const f = l.getAttribute("points");
369
+ for (const o of s) {
370
+ const f = o.getAttribute("points");
371
371
  if (f) {
372
- const c = X(f);
372
+ const c = z(f);
373
373
  i.push(...c);
374
374
  }
375
375
  }
376
376
  const n = r.querySelectorAll("path");
377
- for (const l of n) {
378
- const f = l.getAttribute("d");
377
+ for (const o of n) {
378
+ const f = o.getAttribute("d");
379
379
  if (f) {
380
- const c = z(f);
380
+ const c = D(f);
381
381
  i.push(...c);
382
382
  }
383
383
  }
384
- const o = r.querySelectorAll("circle");
385
- for (const l of o) {
386
- const f = parseFloat(l.getAttribute("cx") || "0"), c = parseFloat(l.getAttribute("cy") || "0"), y = parseFloat(l.getAttribute("r") || "0"), g = M(f, c, y);
384
+ const l = r.querySelectorAll("circle");
385
+ for (const o of l) {
386
+ const f = parseFloat(o.getAttribute("cx") || "0"), c = parseFloat(o.getAttribute("cy") || "0"), y = parseFloat(o.getAttribute("r") || "0"), g = X(f, c, y);
387
387
  i.push(...g);
388
388
  }
389
389
  const u = r.querySelectorAll("rect");
390
- for (const l of u) {
391
- const f = parseFloat(l.getAttribute("x") || "0"), c = parseFloat(l.getAttribute("y") || "0"), y = parseFloat(l.getAttribute("width") || "0"), g = parseFloat(l.getAttribute("height") || "0");
390
+ for (const o of u) {
391
+ const f = parseFloat(o.getAttribute("x") || "0"), c = parseFloat(o.getAttribute("y") || "0"), y = parseFloat(o.getAttribute("width") || "0"), g = parseFloat(o.getAttribute("height") || "0");
392
392
  i.push([f, c], [f + y, c], [f + y, c + g], [f, c + g]);
393
393
  }
394
394
  return i.length === 0 ? null : {
@@ -399,15 +399,15 @@ function D(e) {
399
399
  return console.warn("Failed to convert SVG to polygon:", t), null;
400
400
  }
401
401
  }
402
- function X(e) {
402
+ function z(e) {
403
403
  const t = [], r = e.trim().split(/\s+/);
404
404
  for (const i of r) {
405
- const [s, n] = i.split(",").map((o) => parseFloat(o));
405
+ const [s, n] = i.split(",").map((l) => parseFloat(l));
406
406
  !isNaN(s) && !isNaN(n) && t.push([s, n]);
407
407
  }
408
408
  return t;
409
409
  }
410
- function z(e) {
410
+ function D(e) {
411
411
  const t = [], r = /[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;
412
412
  let i;
413
413
  for (; (i = r.exec(e)) !== null; ) {
@@ -416,11 +416,11 @@ function z(e) {
416
416
  }
417
417
  return t;
418
418
  }
419
- function M(e, t, r, i = 8) {
419
+ function X(e, t, r, i = 8) {
420
420
  const s = [];
421
421
  for (let n = 0; n < i; n++) {
422
- const o = n / i * Math.PI * 2, u = e + r * Math.cos(o), l = t + r * Math.sin(o);
423
- s.push([u, l]);
422
+ const l = n / i * Math.PI * 2, u = e + r * Math.cos(l), o = t + r * Math.sin(l);
423
+ s.push([u, o]);
424
424
  }
425
425
  return s;
426
426
  }
@@ -475,12 +475,12 @@ function W(e) {
475
475
  for (const s of i) {
476
476
  const n = s.getValue ? s.getValue() : "";
477
477
  if (n) {
478
- const o = s.getFormat ? s.getFormat() : "", u = s.getPurpose ? s.getPurpose() : void 0;
478
+ const l = s.getFormat ? s.getFormat() : "", u = s.getPurpose ? s.getPurpose() : void 0;
479
479
  t.push({
480
480
  value: n,
481
- isHtml: o === "text/html" || o === "application/html",
481
+ isHtml: l === "text/html" || l === "application/html",
482
482
  purpose: u,
483
- format: o
483
+ format: l
484
484
  });
485
485
  }
486
486
  }
@@ -534,7 +534,7 @@ export {
534
534
  Y as c,
535
535
  Z as d,
536
536
  W as e,
537
- w as f,
537
+ q as f,
538
538
  k as g,
539
539
  B as h,
540
540
  ee as p,