@annotorious/react 3.0.0-rc.1 → 3.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/Annotorious.d.ts +15 -14
  2. package/dist/Annotorious.d.ts.map +1 -1
  3. package/dist/AnnotoriousPlugin.d.ts +1 -1
  4. package/dist/AnnotoriousPlugin.d.ts.map +1 -1
  5. package/dist/AnnotoriousPopup.d.ts +1 -1
  6. package/dist/AnnotoriousPopup.d.ts.map +1 -1
  7. package/dist/ImageAnnotator.d.ts +4 -2
  8. package/dist/ImageAnnotator.d.ts.map +1 -1
  9. package/dist/annotorious-react.es.js +17 -26
  10. package/dist/annotorious-react.es.js.map +1 -1
  11. package/dist/annotorious-react.es10.js +8 -2
  12. package/dist/annotorious-react.es10.js.map +1 -1
  13. package/dist/annotorious-react.es11.js +153 -9
  14. package/dist/annotorious-react.es11.js.map +1 -1
  15. package/dist/annotorious-react.es12.js +6 -2
  16. package/dist/annotorious-react.es12.js.map +1 -1
  17. package/dist/annotorious-react.es13.js +2 -3756
  18. package/dist/annotorious-react.es13.js.map +1 -1
  19. package/dist/annotorious-react.es14.js +30 -25
  20. package/dist/annotorious-react.es14.js.map +1 -1
  21. package/dist/annotorious-react.es15.js +598 -35
  22. package/dist/annotorious-react.es15.js.map +1 -1
  23. package/dist/annotorious-react.es16.js +2 -16
  24. package/dist/annotorious-react.es16.js.map +1 -1
  25. package/dist/annotorious-react.es17.js +2 -4
  26. package/dist/annotorious-react.es17.js.map +1 -1
  27. package/dist/annotorious-react.es2.js +2 -2
  28. package/dist/annotorious-react.es2.js.map +1 -1
  29. package/dist/annotorious-react.es3.js.map +1 -1
  30. package/dist/annotorious-react.es4.js +2 -2
  31. package/dist/annotorious-react.es4.js.map +1 -1
  32. package/dist/annotorious-react.es5.js +18 -13
  33. package/dist/annotorious-react.es5.js.map +1 -1
  34. package/dist/annotorious-react.es8.js +80 -7
  35. package/dist/annotorious-react.es8.js.map +1 -1
  36. package/dist/annotorious-react.es9.js +6 -2
  37. package/dist/annotorious-react.es9.js.map +1 -1
  38. package/dist/index.d.ts +7 -10
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts +3 -1
  41. package/dist/openseadragon/OpenSeadragonAnnotator.d.ts.map +1 -1
  42. package/dist/openseadragon/OpenSeadragonViewer.d.ts.map +1 -1
  43. package/package.json +8 -1
  44. package/dist/annotorious-react.es18.js +0 -11
  45. package/dist/annotorious-react.es18.js.map +0 -1
  46. package/dist/annotorious-react.es19.js +0 -156
  47. package/dist/annotorious-react.es19.js.map +0 -1
  48. package/dist/annotorious-react.es20.js +0 -9
  49. package/dist/annotorious-react.es20.js.map +0 -1
  50. package/dist/annotorious-react.es21.js +0 -20596
  51. package/dist/annotorious-react.es21.js.map +0 -1
  52. package/dist/annotorious-react.es22.js +0 -35
  53. package/dist/annotorious-react.es22.js.map +0 -1
  54. package/dist/annotorious-react.es23.js +0 -5
  55. package/dist/annotorious-react.es23.js.map +0 -1
  56. package/dist/annotorious-react.es24.js +0 -33
  57. package/dist/annotorious-react.es24.js.map +0 -1
  58. package/dist/annotorious-react.es25.js +0 -602
  59. package/dist/annotorious-react.es25.js.map +0 -1
  60. package/dist/annotorious-react.es26.js +0 -5
  61. package/dist/annotorious-react.es26.js.map +0 -1
  62. package/dist/annotorious-react.es27.js +0 -5
  63. package/dist/annotorious-react.es27.js.map +0 -1
  64. package/dist/annotorious-react.es28.js +0 -20
  65. package/dist/annotorious-react.es28.js.map +0 -1
  66. package/dist/annotorious-react.es29.js +0 -24
  67. package/dist/annotorious-react.es29.js.map +0 -1
  68. package/dist/annotorious-react.es30.js +0 -5
  69. package/dist/annotorious-react.es30.js.map +0 -1
  70. package/dist/annotorious-react.es31.js +0 -7
  71. package/dist/annotorious-react.es31.js.map +0 -1
  72. package/dist/annotorious-react.es32.js +0 -11
  73. package/dist/annotorious-react.es32.js.map +0 -1
  74. package/dist/annotorious-react.es33.js +0 -10
  75. package/dist/annotorious-react.es33.js.map +0 -1
@@ -1,3759 +1,5 @@
1
- function k() {
2
- }
3
- function ze(t, e) {
4
- for (const n in e)
5
- t[n] = e[n];
6
- return t;
7
- }
8
- function Re(t) {
9
- return t();
10
- }
11
- function ae() {
12
- return /* @__PURE__ */ Object.create(null);
13
- }
14
- function it(t) {
15
- t.forEach(Re);
16
- }
17
- function V(t) {
18
- return typeof t == "function";
19
- }
20
- function q(t, e) {
21
- return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
22
- }
23
- function We(t) {
24
- return Object.keys(t).length === 0;
25
- }
26
- function _e(t, ...e) {
27
- if (t == null)
28
- return k;
29
- const n = t.subscribe(...e);
30
- return n.unsubscribe ? () => n.unsubscribe() : n;
31
- }
32
- function se(t, e, n) {
33
- t.$$.on_destroy.push(_e(e, n));
34
- }
35
- function qe(t, e, n, o) {
36
- if (t) {
37
- const r = Ie(t, e, n, o);
38
- return t[0](r);
39
- }
40
- }
41
- function Ie(t, e, n, o) {
42
- return t[1] && o ? ze(n.ctx.slice(), t[1](o(e))) : n.ctx;
43
- }
44
- function Je(t, e, n, o) {
45
- if (t[2] && o) {
46
- const r = t[2](o(n));
47
- if (e.dirty === void 0)
48
- return r;
49
- if (typeof r == "object") {
50
- const i = [], a = Math.max(e.dirty.length, r.length);
51
- for (let s = 0; s < a; s += 1)
52
- i[s] = e.dirty[s] | r[s];
53
- return i;
54
- }
55
- return e.dirty | r;
56
- }
57
- return e.dirty;
58
- }
59
- function Qe(t, e, n, o, r, i) {
60
- if (r) {
61
- const a = Ie(e, n, o, i);
62
- t.p(a, r);
63
- }
64
- }
65
- function Ze(t) {
66
- if (t.ctx.length > 32) {
67
- const e = [], n = t.ctx.length / 32;
68
- for (let o = 0; o < n; o++)
69
- e[o] = -1;
70
- return e;
71
- }
72
- return -1;
73
- }
74
- function ct(t, e) {
75
- t.appendChild(e);
76
- }
77
- function O(t, e, n) {
78
- t.insertBefore(e, n || null);
79
- }
80
- function S(t) {
81
- t.parentNode && t.parentNode.removeChild(t);
82
- }
83
- function ee(t, e) {
84
- for (let n = 0; n < t.length; n += 1)
85
- t[n] && t[n].d(e);
86
- }
87
- function R(t) {
88
- return document.createElementNS("http://www.w3.org/2000/svg", t);
89
- }
90
- function Ne(t) {
91
- return document.createTextNode(t);
92
- }
93
- function K() {
94
- return Ne(" ");
95
- }
96
- function at() {
97
- return Ne("");
98
- }
99
- function C(t, e, n, o) {
100
- return t.addEventListener(e, n, o), () => t.removeEventListener(e, n, o);
101
- }
102
- function d(t, e, n) {
103
- n == null ? t.removeAttribute(e) : t.getAttribute(e) !== n && t.setAttribute(e, n);
104
- }
105
- function Ke(t) {
106
- return Array.from(t.childNodes);
107
- }
108
- function le(t, e, n) {
109
- t.classList[n ? "add" : "remove"](e);
110
- }
111
- function tn(t, e, { bubbles: n = !1, cancelable: o = !1 } = {}) {
112
- const r = document.createEvent("CustomEvent");
113
- return r.initCustomEvent(t, n, o, e), r;
114
- }
115
- let Bt;
116
- function Yt(t) {
117
- Bt = t;
118
- }
119
- function De() {
120
- if (!Bt)
121
- throw new Error("Function called outside component initialization");
122
- return Bt;
123
- }
124
- function Xt(t) {
125
- De().$$.on_mount.push(t);
126
- }
127
- function Mt() {
128
- const t = De();
129
- return (e, n, { cancelable: o = !1 } = {}) => {
130
- const r = t.$$.callbacks[e];
131
- if (r) {
132
- const i = tn(e, n, { cancelable: o });
133
- return r.slice().forEach((a) => {
134
- a.call(t, i);
135
- }), !i.defaultPrevented;
136
- }
137
- return !0;
138
- };
139
- }
140
- function Et(t, e) {
141
- const n = t.$$.callbacks[e.type];
142
- n && n.slice().forEach((o) => o.call(this, e));
143
- }
144
- const xt = [], At = [];
145
- let vt = [];
146
- const ce = [], en = /* @__PURE__ */ Promise.resolve();
147
- let Kt = !1;
148
- function nn() {
149
- Kt || (Kt = !0, en.then(ke));
150
- }
151
- function te(t) {
152
- vt.push(t);
153
- }
154
- const zt = /* @__PURE__ */ new Set();
155
- let yt = 0;
156
- function ke() {
157
- if (yt !== 0)
158
- return;
159
- const t = Bt;
160
- do {
161
- try {
162
- for (; yt < xt.length; ) {
163
- const e = xt[yt];
164
- yt++, Yt(e), on(e.$$);
165
- }
166
- } catch (e) {
167
- throw xt.length = 0, yt = 0, e;
168
- }
169
- for (Yt(null), xt.length = 0, yt = 0; At.length; )
170
- At.pop()();
171
- for (let e = 0; e < vt.length; e += 1) {
172
- const n = vt[e];
173
- zt.has(n) || (zt.add(n), n());
174
- }
175
- vt.length = 0;
176
- } while (xt.length);
177
- for (; ce.length; )
178
- ce.pop()();
179
- Kt = !1, zt.clear(), Yt(t);
180
- }
181
- function on(t) {
182
- if (t.fragment !== null) {
183
- t.update(), it(t.before_update);
184
- const e = t.dirty;
185
- t.dirty = [-1], t.fragment && t.fragment.p(t.ctx, e), t.after_update.forEach(te);
186
- }
187
- }
188
- function rn(t) {
189
- const e = [], n = [];
190
- vt.forEach((o) => t.indexOf(o) === -1 ? e.push(o) : n.push(o)), n.forEach((o) => o()), vt = e;
191
- }
192
- const Gt = /* @__PURE__ */ new Set();
193
- let ht;
194
- function ot() {
195
- ht = {
196
- r: 0,
197
- c: [],
198
- p: ht
199
- // parent group
200
- };
201
- }
202
- function rt() {
203
- ht.r || it(ht.c), ht = ht.p;
204
- }
205
- function I(t, e) {
206
- t && t.i && (Gt.delete(t), t.i(e));
207
- }
208
- function N(t, e, n, o) {
209
- if (t && t.o) {
210
- if (Gt.has(t))
211
- return;
212
- Gt.add(t), ht.c.push(() => {
213
- Gt.delete(t), o && (n && t.d(1), o());
214
- }), t.o(e);
215
- } else
216
- o && o();
217
- }
218
- function ft(t) {
219
- t && t.c();
220
- }
221
- function dt(t, e, n, o) {
222
- const { fragment: r, after_update: i } = t.$$;
223
- r && r.m(e, n), o || te(() => {
224
- const a = t.$$.on_mount.map(Re).filter(V);
225
- t.$$.on_destroy ? t.$$.on_destroy.push(...a) : it(a), t.$$.on_mount = [];
226
- }), i.forEach(te);
227
- }
228
- function ut(t, e) {
229
- const n = t.$$;
230
- n.fragment !== null && (rn(n.after_update), it(n.on_destroy), n.fragment && n.fragment.d(e), n.on_destroy = n.fragment = null, n.ctx = []);
231
- }
232
- function an(t, e) {
233
- t.$$.dirty[0] === -1 && (xt.push(t), nn(), t.$$.dirty.fill(0)), t.$$.dirty[e / 31 | 0] |= 1 << e % 31;
234
- }
235
- function tt(t, e, n, o, r, i, a, s = [-1]) {
236
- const l = Bt;
237
- Yt(t);
238
- const c = t.$$ = {
239
- fragment: null,
240
- ctx: [],
241
- // state
242
- props: i,
243
- update: k,
244
- not_equal: r,
245
- bound: ae(),
246
- // lifecycle
247
- on_mount: [],
248
- on_destroy: [],
249
- on_disconnect: [],
250
- before_update: [],
251
- after_update: [],
252
- context: new Map(e.context || (l ? l.$$.context : [])),
253
- // everything else
254
- callbacks: ae(),
255
- dirty: s,
256
- skip_bound: !1,
257
- root: e.target || l.$$.root
258
- };
259
- a && a(c.root);
260
- let h = !1;
261
- if (c.ctx = n ? n(t, e.props || {}, (u, f, ...p) => {
262
- const g = p.length ? p[0] : f;
263
- return c.ctx && r(c.ctx[u], c.ctx[u] = g) && (!c.skip_bound && c.bound[u] && c.bound[u](g), h && an(t, u)), f;
264
- }) : [], c.update(), h = !0, it(c.before_update), c.fragment = o ? o(c.ctx) : !1, e.target) {
265
- if (e.hydrate) {
266
- const u = Ke(e.target);
267
- c.fragment && c.fragment.l(u), u.forEach(S);
268
- } else
269
- c.fragment && c.fragment.c();
270
- e.intro && I(t.$$.fragment), dt(t, e.target, e.anchor, e.customElement), ke();
271
- }
272
- Yt(l);
273
- }
274
- class et {
275
- $destroy() {
276
- ut(this, 1), this.$destroy = k;
277
- }
278
- $on(e, n) {
279
- if (!V(n))
280
- return k;
281
- const o = this.$$.callbacks[e] || (this.$$.callbacks[e] = []);
282
- return o.push(n), () => {
283
- const r = o.indexOf(n);
284
- r !== -1 && o.splice(r, 1);
285
- };
286
- }
287
- $set(e) {
288
- this.$$set && !We(e) && (this.$$.skip_bound = !0, this.$$set(e), this.$$.skip_bound = !1);
289
- }
290
- }
291
- var F = /* @__PURE__ */ ((t) => (t.ELLIPSE = "ELLIPSE", t.POLYGON = "POLYGON", t.RECTANGLE = "RECTANGLE", t))(F || {});
292
- const ne = {}, oe = (t, e) => ne[t] = e, de = (t) => ne[t.type].area(t), sn = (t, e, n) => ne[t.type].intersects(t, e, n), Ut = (t) => {
293
- let e = 1 / 0, n = 1 / 0, o = -1 / 0, r = -1 / 0;
294
- return t.forEach(([i, a]) => {
295
- e = Math.min(e, i), n = Math.min(n, a), o = Math.max(o, i), r = Math.max(r, a);
296
- }), { minX: e, minY: n, maxX: o, maxY: r };
297
- }, ln = {
298
- area: (t) => Math.PI * t.geometry.rx * t.geometry.ry,
299
- intersects: (t, e, n) => {
300
- const { cx: o, cy: r, rx: i, ry: a } = t.geometry, s = 0, l = Math.cos(s), c = Math.sin(s), h = e - o, u = n - r, f = l * h + c * u, p = c * h - l * u;
301
- return f * f / (i * i) + p * p / (a * a) <= 1;
302
- }
303
- };
304
- oe(F.ELLIPSE, ln);
305
- const cn = {
306
- area: (t) => {
307
- const { points: e } = t.geometry;
308
- let n = 0, o = e.length - 1;
309
- for (let r = 0; r < e.length; r++)
310
- n += (e[o][0] + e[r][0]) * (e[o][1] - e[r][1]), o = r;
311
- return Math.abs(0.5 * n);
312
- },
313
- intersects: (t, e, n) => {
314
- const { points: o } = t.geometry;
315
- let r = !1;
316
- for (let i = 0, a = o.length - 1; i < o.length; a = i++) {
317
- const s = o[i][0], l = o[i][1], c = o[a][0], h = o[a][1];
318
- l > n != h > n && e < (c - s) * (n - l) / (h - l) + s && (r = !r);
319
- }
320
- return r;
321
- }
322
- };
323
- oe(F.POLYGON, cn);
324
- const dn = {
325
- area: (t) => t.geometry.w * t.geometry.h,
326
- intersects: (t, e, n) => e >= t.geometry.x && e <= t.geometry.x + t.geometry.w && n >= t.geometry.y && n <= t.geometry.y + t.geometry.h
327
- };
328
- oe(F.RECTANGLE, dn);
329
- const un = (t, e = !1) => {
330
- const n = typeof t == "string" ? t : t.value, o = /^(xywh)=(pixel|percent)?:?(.+?),(.+?),(.+?),(.+)*/g, r = [...n.matchAll(o)][0], [i, a, s, l, c, h, u] = r;
331
- if (a !== "xywh")
332
- throw new Error("Unsupported MediaFragment: " + n);
333
- if (s && s !== "pixel")
334
- throw new Error(`Unsupported MediaFragment unit: ${s}`);
335
- const [f, p, g, m] = [l, c, h, u].map(parseFloat);
336
- return {
337
- type: F.RECTANGLE,
338
- geometry: {
339
- x: f,
340
- y: p,
341
- w: g,
342
- h: m,
343
- bounds: {
344
- minX: f,
345
- minY: e ? p - m : p,
346
- maxX: f + g,
347
- maxY: e ? p : p + m
348
- }
349
- }
350
- };
351
- }, hn = (t) => {
352
- const { x: e, y: n, w: o, h: r } = t;
353
- return {
354
- type: "FragmentSelector",
355
- conformsTo: "http://www.w3.org/TR/media-frags/",
356
- value: `xywh=pixel:${e},${n},${o},${r}`
357
- };
358
- }, Ge = "http://www.w3.org/2000/svg", ue = (t) => {
359
- const e = (o) => {
360
- Array.from(o.attributes).forEach((r) => {
361
- r.name.startsWith("on") && o.removeAttribute(r.name);
362
- });
363
- }, n = t.getElementsByTagName("script");
364
- return Array.from(n).reverse().forEach((o) => o.parentNode.removeChild(o)), Array.from(t.querySelectorAll("*")).forEach(e), t;
365
- }, pn = (t) => {
366
- const e = new XMLSerializer().serializeToString(t.documentElement).replace("<svg>", `<svg xmlns="${Ge}">`);
367
- return new DOMParser().parseFromString(e, "image/svg+xml").documentElement;
368
- }, fn = (t) => {
369
- const e = new DOMParser().parseFromString(t, "image/svg+xml"), n = e.lookupPrefix(Ge), o = e.lookupNamespaceURI(null);
370
- return n || o ? ue(e).firstChild : ue(pn(e)).firstChild;
371
- }, gn = (t) => {
372
- const [e, n, o] = t.match(/(<polygon points=["|'])([^("|')]*)/) || [];
373
- if (!o)
374
- return;
375
- const r = o.split(" ").map((i) => i.split(",").map(parseFloat));
376
- return {
377
- type: F.POLYGON,
378
- geometry: {
379
- points: r,
380
- bounds: Ut(r)
381
- }
382
- };
383
- }, mn = (t) => {
384
- const e = fn(t), n = parseFloat(e.getAttribute("cx")), o = parseFloat(e.getAttribute("cy")), r = parseFloat(e.getAttribute("rx")), i = parseFloat(e.getAttribute("ry")), a = {
385
- minX: n - r,
386
- minY: o - i,
387
- maxX: n + r,
388
- maxY: o + i
389
- };
390
- return {
391
- type: F.ELLIPSE,
392
- geometry: {
393
- cx: n,
394
- cy: o,
395
- rx: r,
396
- ry: i,
397
- bounds: a
398
- }
399
- };
400
- }, yn = (t) => {
401
- const e = typeof t == "string" ? t : t.value;
402
- if (e.includes("<polygon points="))
403
- return gn(e);
404
- if (e.includes("<ellipse "))
405
- return mn(e);
406
- }, wn = (t) => {
407
- let e;
408
- if (t.type === F.POLYGON) {
409
- const n = t.geometry, { points: o } = n;
410
- e = `<svg><polygon points="${o.map((r) => r.join(",")).join(" ")}" /></svg>`;
411
- } else if (t.type === F.ELLIPSE) {
412
- const n = t.geometry;
413
- e = `<svg><ellipse cx="${n.cx}" cy="${n.cy}" rx="${n.rx}" ry="${n.ry}" /></svg>`;
414
- }
415
- if (e)
416
- return { type: "SvgSelector", value: e };
417
- throw `Unsupported shape type: ${t.type}`;
418
- };
419
- let Nt;
420
- const $n = new Uint8Array(16);
421
- function xn() {
422
- if (!Nt && (Nt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Nt))
423
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
424
- return Nt($n);
425
- }
426
- const j = [];
427
- for (let t = 0; t < 256; ++t)
428
- j.push((t + 256).toString(16).slice(1));
429
- function bn(t, e = 0) {
430
- return j[t[e + 0]] + j[t[e + 1]] + j[t[e + 2]] + j[t[e + 3]] + "-" + j[t[e + 4]] + j[t[e + 5]] + "-" + j[t[e + 6]] + j[t[e + 7]] + "-" + j[t[e + 8]] + j[t[e + 9]] + "-" + j[t[e + 10]] + j[t[e + 11]] + j[t[e + 12]] + j[t[e + 13]] + j[t[e + 14]] + j[t[e + 15]];
431
- }
432
- const En = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), he = {
433
- randomUUID: En
434
- };
435
- function Ue(t, e, n) {
436
- if (he.randomUUID && !e && !t)
437
- return he.randomUUID();
438
- t = t || {};
439
- const o = t.random || (t.rng || xn)();
440
- if (o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, e) {
441
- n = n || 0;
442
- for (let r = 0; r < 16; ++r)
443
- e[n + r] = o[r];
444
- return e;
445
- }
446
- return bn(o);
447
- }
448
- var pe = Object.prototype.hasOwnProperty;
449
- function pt(t, e) {
450
- var n, o;
451
- if (t === e)
452
- return !0;
453
- if (t && e && (n = t.constructor) === e.constructor) {
454
- if (n === Date)
455
- return t.getTime() === e.getTime();
456
- if (n === RegExp)
457
- return t.toString() === e.toString();
458
- if (n === Array) {
459
- if ((o = t.length) === e.length)
460
- for (; o-- && pt(t[o], e[o]); )
461
- ;
462
- return o === -1;
463
- }
464
- if (!n || typeof t == "object") {
465
- o = 0;
466
- for (n in t)
467
- if (pe.call(t, n) && ++o && !pe.call(e, n) || !(n in e) || !pt(t[n], e[n]))
468
- return !1;
469
- return Object.keys(e).length === o;
470
- }
471
- }
472
- return t !== t && e !== e;
473
- }
474
- const wt = [];
475
- function Ft(t, e = k) {
476
- let n;
477
- const o = /* @__PURE__ */ new Set();
478
- function r(s) {
479
- if (q(t, s) && (t = s, n)) {
480
- const l = !wt.length;
481
- for (const c of o)
482
- c[1](), wt.push(c, t);
483
- if (l) {
484
- for (let c = 0; c < wt.length; c += 2)
485
- wt[c][0](wt[c + 1]);
486
- wt.length = 0;
487
- }
488
- }
489
- }
490
- function i(s) {
491
- r(s(t));
492
- }
493
- function a(s, l = k) {
494
- const c = [s, l];
495
- return o.add(c), o.size === 1 && (n = e(r) || k), s(t), () => {
496
- o.delete(c), o.size === 0 && n && (n(), n = null);
497
- };
498
- }
499
- return { set: r, update: i, subscribe: a };
500
- }
501
- const vn = (t) => {
502
- const { subscribe: e, set: n } = Ft(null);
503
- let o = null;
504
- return e((r) => o = r), t.observe(({ changes: r }) => {
505
- if (o) {
506
- r.deleted.some((a) => a.id === o) && n(null);
507
- const i = r.updated.find(({ oldValue: a }) => a.id === o);
508
- i && n(i.newValue.id);
509
- }
510
- }), {
511
- get current() {
512
- return o;
513
- },
514
- subscribe: e,
515
- set: n
516
- };
517
- };
518
- var Fe = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Fe || {});
519
- const Wt = { selected: [] }, An = (t, e = "EDIT") => {
520
- const { subscribe: n, set: o } = Ft(Wt);
521
- let r = Wt;
522
- n((u) => r = u);
523
- const i = () => o(Wt), a = () => {
524
- var u;
525
- return ((u = r.selected) == null ? void 0 : u.length) === 0;
526
- }, s = (u) => {
527
- if (r.selected.length === 0)
528
- return !1;
529
- const f = typeof u == "string" ? u : u.id;
530
- return r.selected.some((p) => p.id === f);
531
- }, l = (u, f) => {
532
- const p = t.getAnnotation(u);
533
- if (p) {
534
- const g = Mn(p, e);
535
- o(g === "EDIT" ? { selected: [{ id: u, editable: !0 }], pointerEvent: f } : g === "SELECT" ? { selected: [{ id: u }], pointerEvent: f } : { selected: [], pointerEvent: f });
536
- } else
537
- console.warn("Invalid selection: " + u);
538
- }, c = (u, f = !0) => {
539
- const p = Array.isArray(u) ? u : [u], g = p.map((m) => t.getAnnotation(m)).filter((m) => m);
540
- o({ selected: g.map(({ id: m }) => ({ id: m, editable: f })) }), g.length !== p.length && console.warn("Invalid selection", u);
541
- }, h = (u) => {
542
- if (r.selected.length === 0)
543
- return !1;
544
- const { selected: f } = r;
545
- f.filter(({ id: p }) => u.includes(p)).length > 0 && o({ selected: f.filter(({ id: p }) => !u.includes(p)) });
546
- };
547
- return t.observe(({ changes: u }) => h(u.deleted.map((f) => f.id))), {
548
- clear: i,
549
- clickSelect: l,
550
- get selected() {
551
- return r ? [...r.selected] : null;
552
- },
553
- get pointerEvent() {
554
- return r ? r.pointerEvent : null;
555
- },
556
- isEmpty: a,
557
- isSelected: s,
558
- setSelected: c,
559
- subscribe: n
560
- };
561
- }, Mn = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT", Sn = (t, e) => {
562
- const n = new Set(t.bodies.map((o) => o.id));
563
- return e.bodies.filter((o) => !n.has(o.id));
564
- }, Ln = (t, e) => {
565
- const n = new Set(e.bodies.map((o) => o.id));
566
- return t.bodies.filter((o) => !n.has(o.id));
567
- }, On = (t, e) => e.bodies.map((n) => {
568
- const o = t.bodies.find((r) => r.id === n.id);
569
- return { newBody: n, oldBody: o && !pt(o, n) ? o : void 0 };
570
- }).filter(({ oldBody: n }) => n), Tn = (t, e) => !pt(t.target, e.target), Yn = (t, e) => ({
571
- oldValue: t,
572
- newValue: e,
573
- bodiesCreated: Sn(t, e),
574
- bodiesDeleted: Ln(t, e),
575
- bodiesUpdated: On(t, e),
576
- targetUpdated: Tn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
577
- });
578
- var G = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(G || {});
579
- const Bn = (t, e) => {
580
- var n, o;
581
- const { changes: r, origin: i } = e;
582
- if (!(!t.options.origin || t.options.origin === i))
583
- return !1;
584
- if (t.options.ignore) {
585
- const { ignore: a } = t.options, s = (l) => (l == null ? void 0 : l.length) > 0;
586
- if (!(s(r.created) || s(r.deleted))) {
587
- const l = (n = r.updated) == null ? void 0 : n.some((h) => s(h.bodiesCreated) || s(h.bodiesDeleted) || s(h.bodiesUpdated)), c = (o = r.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
588
- if (a === "BODY_ONLY" && l && !c || a === "TARGET_ONLY" && c && !l)
589
- return !1;
590
- }
591
- }
592
- if (t.options.annotations) {
593
- const a = /* @__PURE__ */ new Set([
594
- ...r.created.map((s) => s.id),
595
- ...r.deleted.map((s) => s.id),
596
- ...r.updated.map(({ oldValue: s }) => s.id)
597
- ]);
598
- return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => a.has(s));
599
- } else
600
- return !0;
601
- }, Xn = (t) => t.id !== void 0, Pn = () => {
602
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (y, $ = {}) => n.push({ onChange: y, options: $ }), r = (y) => {
603
- const $ = n.findIndex((w) => w.onChange == y);
604
- $ > -1 && n.splice($, 1);
605
- }, i = (y, $) => {
606
- const w = {
607
- origin: y,
608
- changes: {
609
- created: $.created || [],
610
- updated: $.updated || [],
611
- deleted: $.deleted || []
612
- },
613
- state: [...t.values()]
614
- };
615
- n.forEach((A) => {
616
- Bn(A, w) && A.onChange(w);
617
- });
618
- }, a = (y, $ = G.LOCAL) => {
619
- if (t.get(y.id))
620
- throw Error(`Cannot add annotation ${y.id} - exists already`);
621
- t.set(y.id, y), y.bodies.forEach((w) => e.set(w.id, y.id)), i($, { created: [y] });
622
- }, s = (y, $ = G.LOCAL, w = G.LOCAL) => {
623
- const A = Xn($) ? w : $, L = typeof y == "string" ? $ : y, P = typeof y == "string" ? y : y.id, J = t.get(P);
624
- if (J) {
625
- const U = Yn(J, L);
626
- P === L.id ? t.set(P, L) : (t.delete(P), t.set(L.id, L)), J.bodies.forEach((nt) => e.delete(nt.id)), L.bodies.forEach((nt) => e.set(nt.id, L.id)), i(A, { updated: [U] });
627
- } else
628
- throw Error(`Cannot update annotation ${P} - does not exist`);
629
- }, l = (y, $ = G.LOCAL) => {
630
- const w = t.get(y.annotation);
631
- if (w) {
632
- const A = {
633
- ...w,
634
- bodies: [...w.bodies, y]
635
- };
636
- t.set(w.id, A), e.set(y.id, A.id), i($, { updated: [{
637
- oldValue: w,
638
- newValue: A,
639
- bodiesCreated: [y]
640
- }] });
641
- } else
642
- console.warn(`Attempt to add body to missing annotation: ${y.annotation}`);
643
- }, c = () => [...t.values()], h = (y = G.LOCAL) => {
644
- const $ = [...t.values()];
645
- t.clear(), e.clear(), i(y, { deleted: $ });
646
- }, u = (y, $ = !0, w = G.LOCAL) => {
647
- if ($) {
648
- const A = [...t.values()];
649
- t.clear(), e.clear(), y.forEach((L) => {
650
- t.set(L.id, L), L.bodies.forEach((P) => e.set(P.id, L.id));
651
- }), i(w, { created: y, deleted: A });
652
- } else {
653
- const A = y.reduce((L, P) => {
654
- const J = t.get(P.id);
655
- return J ? [...L, J] : L;
656
- }, []);
657
- if (A.length > 0)
658
- throw Error(`Bulk insert would overwrite the following annotations: ${A.map((L) => L.id).join(", ")}`);
659
- y.forEach((L) => {
660
- t.set(L.id, L), L.bodies.forEach((P) => e.set(P.id, L.id));
661
- }), i(w, { created: y });
662
- }
663
- }, f = (y) => {
664
- const $ = typeof y == "string" ? y : y.id, w = t.get($);
665
- if (w)
666
- return t.delete($), w.bodies.forEach((A) => e.delete(A.id)), w;
667
- console.warn(`Attempt to delete missing annotation: ${$}`);
668
- }, p = (y, $ = G.LOCAL) => {
669
- const w = f(y);
670
- w && i($, { deleted: [w] });
671
- }, g = (y, $ = G.LOCAL) => {
672
- const w = y.reduce((A, L) => {
673
- const P = f(L);
674
- return P ? [...A, P] : A;
675
- }, []);
676
- w.length > 0 && i($, { deleted: w });
677
- }, m = (y, $ = G.LOCAL) => {
678
- const w = t.get(y.annotation);
679
- if (w) {
680
- const A = w.bodies.find((L) => L.id === y.id);
681
- if (A) {
682
- e.delete(A.id);
683
- const L = {
684
- ...w,
685
- bodies: w.bodies.filter((P) => P.id !== y.id)
686
- };
687
- t.set(w.id, L), i($, { updated: [{
688
- oldValue: w,
689
- newValue: L,
690
- bodiesDeleted: [A]
691
- }] });
692
- } else
693
- console.warn(`Attempt to delete missing body ${y.id} from annotation ${y.annotation}`);
694
- } else
695
- console.warn(`Attempt to delete body from missing annotation ${y.annotation}`);
696
- }, b = (y) => {
697
- const $ = t.get(y);
698
- return $ ? { ...$ } : void 0;
699
- }, E = (y) => {
700
- const $ = e.get(y);
701
- if ($) {
702
- const w = b($).bodies.find((A) => A.id === y);
703
- if (w)
704
- return w;
705
- console.error(`Store integrity error: body ${y} in index, but not in annotation`);
706
- } else
707
- console.warn(`Attempt to retrieve missing body: ${y}`);
708
- }, T = (y, $) => {
709
- if (y.annotation !== $.annotation)
710
- throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
711
- const w = t.get(y.annotation);
712
- if (w) {
713
- const A = w.bodies.find((P) => P.id === y.id), L = {
714
- ...w,
715
- bodies: w.bodies.map((P) => P.id === A.id ? $ : P)
716
- };
717
- return t.set(w.id, L), A.id !== $.id && (e.delete(A.id), e.set($.id, L.id)), {
718
- oldValue: w,
719
- newValue: L,
720
- bodiesUpdated: [{ oldBody: A, newBody: $ }]
721
- };
722
- } else
723
- console.warn(`Attempt to add body to missing annotation ${y.annotation}`);
724
- }, X = (y, $, w = G.LOCAL) => {
725
- const A = T(y, $);
726
- i(w, { updated: [A] });
727
- }, x = (y, $ = G.LOCAL) => {
728
- const w = y.map((A) => T({ id: A.id, annotation: A.annotation }, A));
729
- i($, { updated: w });
730
- }, _ = (y) => {
731
- const $ = t.get(y.annotation);
732
- if ($) {
733
- const w = {
734
- ...$,
735
- target: {
736
- ...$.target,
737
- ...y
738
- }
739
- };
740
- return t.set($.id, w), {
741
- oldValue: $,
742
- newValue: w,
743
- targetUpdated: {
744
- oldTarget: $.target,
745
- newTarget: y
746
- }
747
- };
748
- } else
749
- console.warn(`Attempt to update target on missing annotation: ${y.annotation}`);
750
- };
751
- return {
752
- addAnnotation: a,
753
- addBody: l,
754
- all: c,
755
- bulkAddAnnotation: u,
756
- bulkDeleteAnnotation: g,
757
- bulkUpdateBodies: x,
758
- bulkUpdateTargets: (y, $ = G.LOCAL) => {
759
- const w = y.map(_).filter((A) => A);
760
- w.length > 0 && i($, { updated: w });
761
- },
762
- clear: h,
763
- deleteAnnotation: p,
764
- deleteBody: m,
765
- getAnnotation: b,
766
- getBody: E,
767
- observe: o,
768
- unobserve: r,
769
- updateAnnotation: s,
770
- updateBody: X,
771
- updateTarget: (y, $ = G.LOCAL) => {
772
- const w = _(y);
773
- w && i($, { updated: [w] });
774
- }
775
- };
776
- }, Rn = (t) => ({
777
- ...t,
778
- subscribe: (e) => {
779
- const n = (o) => e(o.state);
780
- return t.observe(n), e(t.all()), () => t.unobserve(n);
781
- }
782
- }), _n = () => {
783
- const { subscribe: t, set: e } = Ft([]);
784
- return {
785
- subscribe: t,
786
- set: e
787
- };
788
- }, In = (t, e, n, o, r, i) => {
789
- const a = /* @__PURE__ */ new Map();
790
- let s = [], l, c;
791
- const h = (g, m) => {
792
- a.has(g) ? a.get(g).push(m) : a.set(g, [m]);
793
- }, u = (g, m) => {
794
- const b = a.get(g);
795
- b && b.indexOf(m) > 0 && b.splice(b.indexOf(m), 1);
796
- }, f = (g, m, b) => {
797
- a.has(g) && setTimeout(() => {
798
- a.get(g).forEach((E) => {
799
- if (r) {
800
- const T = Array.isArray(m) ? m.map((x) => r.serialize(x)) : r.serialize(m), X = b ? b instanceof PointerEvent ? b : r.serialize(b) : void 0;
801
- E(T, X);
802
- } else
803
- E(m, b);
804
- });
805
- }, 1);
806
- }, p = () => {
807
- const { selected: g } = e, m = g.map(({ id: b }) => t.getAnnotation(b));
808
- m.forEach((b) => {
809
- const E = s.find((T) => T.id === b.id);
810
- (!E || !pt(E, b)) && f("updateAnnotation", b, E);
811
- }), s = s.map((b) => m.find(({ id: T }) => T === b.id) || b);
812
- };
813
- return e.subscribe(({ selected: g }) => {
814
- if (!(s.length === 0 && g.length === 0)) {
815
- if (s.length === 0 && g.length > 0)
816
- s = g.map(({ id: m }) => t.getAnnotation(m));
817
- else if (s.length > 0 && g.length === 0)
818
- s.forEach((m) => {
819
- const b = t.getAnnotation(m.id);
820
- b && !pt(b, m) && f("updateAnnotation", b, m);
821
- }), s = [];
822
- else {
823
- const m = new Set(s.map((E) => E.id)), b = new Set(g.map(({ id: E }) => E));
824
- s.filter((E) => !b.has(E.id)).forEach((E) => {
825
- const T = t.getAnnotation(E.id);
826
- T && !pt(T, E) && f("updateAnnotation", T, E);
827
- }), s = [
828
- // Remove annotations that were deselected
829
- ...s.filter((E) => b.has(E.id)),
830
- // Add editable annotations that were selected
831
- ...g.filter(({ id: E }) => !m.has(E)).map(({ id: E }) => t.getAnnotation(E))
832
- ];
833
- }
834
- f("selectionChanged", s);
835
- }
836
- }), n.subscribe((g) => {
837
- !l && g ? f("mouseEnterAnnotation", t.getAnnotation(g)) : l && !g ? f("mouseLeaveAnnotation", t.getAnnotation(l)) : l && g && (f("mouseLeaveAnnotation", t.getAnnotation(l)), f("mouseEnterAnnotation", t.getAnnotation(g))), l = g;
838
- }), o == null || o.subscribe((g) => f("viewportIntersect", g.map(t.getAnnotation))), t.observe((g) => {
839
- i && (c && clearTimeout(c), c = setTimeout(p, 1e3));
840
- const { created: m, deleted: b } = g.changes;
841
- m.forEach((E) => f("createAnnotation", E)), b.forEach((E) => f("deleteAnnotation", E)), g.changes.updated.filter((E) => [
842
- ...E.bodiesCreated || [],
843
- ...E.bodiesDeleted || [],
844
- ...E.bodiesUpdated || []
845
- ].length > 0).forEach(({ oldValue: E, newValue: T }) => {
846
- const X = s.find((x) => x.id === E.id) || E;
847
- s = s.map((x) => x.id === E.id ? T : x), f("updateAnnotation", T, X);
848
- });
849
- }, { origin: G.LOCAL }), t.observe((g) => {
850
- if (s) {
851
- const m = new Set(s.map((E) => E.id)), b = g.changes.updated.filter(({ newValue: E }) => m.has(E.id)).map(({ newValue: E }) => E);
852
- b.length > 0 && (s = s.map((E) => b.find((X) => X.id === E.id) || E));
853
- }
854
- }, { origin: G.REMOTE }), { on: h, off: u, emit: f };
855
- }, Nn = (t) => (e) => e.reduce((n, o) => {
856
- const { parsed: r, error: i } = t.parse(o);
857
- return i ? {
858
- parsed: n.parsed,
859
- failed: [...n.failed, o]
860
- } : {
861
- parsed: [...n.parsed, r],
862
- failed: n.failed
863
- };
864
- }, { parsed: [], failed: [] }), Dn = (t, e) => {
865
- const n = (c) => {
866
- if (e) {
867
- const { parsed: h, error: u } = e.parse(c);
868
- h ? t.addAnnotation(h, G.REMOTE) : console.error(u);
869
- } else
870
- t.addAnnotation(c, G.REMOTE);
871
- }, o = () => t.clear(), r = (c) => {
872
- const h = t.getAnnotation(c);
873
- return e && h ? e.serialize(h) : h;
874
- }, i = () => e ? t.all().map(e.serialize) : t.all(), a = (c) => fetch(c).then((h) => h.json()).then((h) => (l(h), h)), s = (c) => {
875
- if (typeof c == "string") {
876
- const h = t.getAnnotation(c);
877
- return t.deleteAnnotation(c), e ? e.serialize(h) : h;
878
- } else {
879
- const h = e ? e.parse(c).parsed : c;
880
- return t.deleteAnnotation(h), c;
881
- }
882
- }, l = (c) => {
883
- if (e) {
884
- const { parsed: h, failed: u } = Nn(e)(c);
885
- u.length > 0 && console.warn(`Discarded ${u.length} invalid annotations`, u), t.bulkAddAnnotation(h, !0, G.REMOTE);
886
- } else
887
- t.bulkAddAnnotation(c, !0, G.REMOTE);
888
- };
889
- return {
890
- addAnnotation: n,
891
- clearAnnotations: o,
892
- getAnnotationById: r,
893
- getAnnotations: i,
894
- loadAnnotations: a,
895
- removeAnnotation: s,
896
- setAnnotations: l,
897
- updateAnnotation: (c) => {
898
- if (e) {
899
- const h = e.parse(c).parsed, u = e.serialize(t.getAnnotation(h.id));
900
- return t.updateAnnotation(h), u;
901
- } else {
902
- const h = t.getAnnotation(c.id);
903
- return t.updateAnnotation(c), h;
904
- }
905
- }
906
- };
907
- };
908
- let kn = (t) => crypto.getRandomValues(new Uint8Array(t)), Gn = (t, e, n) => {
909
- let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, r = -~(1.6 * o * e / t.length);
910
- return (i = e) => {
911
- let a = "";
912
- for (; ; ) {
913
- let s = n(r), l = r;
914
- for (; l--; )
915
- if (a += t[s[l] & o] || "", a.length === i)
916
- return a;
917
- }
918
- };
919
- }, Un = (t, e = 21) => Gn(t, e, kn), Fn = (t = 21) => crypto.getRandomValues(new Uint8Array(t)).reduce((e, n) => (n &= 63, n < 36 ? e += n.toString(36) : n < 62 ? e += (n - 26).toString(36).toUpperCase() : n > 62 ? e += "-" : e += "_", e), "");
920
- const Vn = () => ({ isGuest: !0, id: Un("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Hn = (t) => {
921
- const e = JSON.stringify(t);
922
- let n = 0;
923
- for (let o = 0, r = e.length; o < r; o++) {
924
- let i = e.charCodeAt(o);
925
- n = (n << 5) - n + i, n |= 0;
926
- }
927
- return `${n}`;
928
- }, jn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
929
- const { id: o, type: r, purpose: i, value: a, created: s, creator: l, ...c } = n;
930
- return {
931
- id: o || `temp-${Hn(n)}`,
932
- annotation: e,
933
- type: r,
934
- purpose: i,
935
- value: a,
936
- created: s,
937
- creator: l ? typeof l == "object" ? { ...l } : l : void 0,
938
- ...c
939
- };
940
- }), Cn = (t) => t.map((e) => {
941
- var n;
942
- const o = { ...e };
943
- return delete o.annotation, (n = o.id) != null && n.startsWith("temp-") && delete o.id, o;
944
- });
945
- Fn();
946
- const ar = (t, e = !1) => ({ parse: (n) => zn(n, e), serialize: (n) => Wn(n, t) }), zn = (t, e = !1) => {
947
- const n = t.id || Ue(), o = jn(t.body, n), r = Array.isArray(t.target) ? t.target[0] : t.target, i = Array.isArray(r.selector) ? r.selector[0] : r.selector, a = i.type === "FragmentSelector" ? un(i, e) : i.type === "SvgSelector" ? yn(i) : void 0;
948
- return a ? {
949
- parsed: {
950
- ...t,
951
- id: n,
952
- bodies: o,
953
- target: {
954
- annotation: n,
955
- selector: a
956
- }
957
- }
958
- } : {
959
- error: Error(`Unknown selector type: ${a.type}`)
960
- };
961
- }, Wn = (t, e) => {
962
- const n = t.target.selector, o = n.type == F.RECTANGLE ? hn(n.geometry) : wn(n);
963
- return {
964
- ...t,
965
- "@context": "http://www.w3.org/ns/anno.jsonld",
966
- id: t.id,
967
- type: "Annotation",
968
- body: Cn(t.bodies),
969
- target: {
970
- source: e,
971
- selector: o
972
- }
973
- };
974
- };
975
- function fe(t, e, n) {
976
- const o = t.slice();
977
- return o[11] = e[n], o[13] = n, o;
978
- }
979
- function ge(t) {
980
- let e, n, o, r, i;
981
- return {
982
- c() {
983
- e = R("rect"), d(e, "class", "a9s-corner-handle"), d(e, "x", n = /*point*/
984
- t[11][0] - /*handleSize*/
985
- t[3] / 2), d(e, "y", o = /*point*/
986
- t[11][1] - /*handleSize*/
987
- t[3] / 2), d(
988
- e,
989
- "height",
990
- /*handleSize*/
991
- t[3]
992
- ), d(
993
- e,
994
- "width",
995
- /*handleSize*/
996
- t[3]
997
- );
998
- },
999
- m(a, s) {
1000
- O(a, e, s), r || (i = C(e, "pointerdown", function() {
1001
- V(
1002
- /*grab*/
1003
- t[10](M(
1004
- /*idx*/
1005
- t[13]
1006
- ))
1007
- ) && t[10](M(
1008
- /*idx*/
1009
- t[13]
1010
- )).apply(this, arguments);
1011
- }), r = !0);
1012
- },
1013
- p(a, s) {
1014
- t = a, s & /*geom, handleSize*/
1015
- 24 && n !== (n = /*point*/
1016
- t[11][0] - /*handleSize*/
1017
- t[3] / 2) && d(e, "x", n), s & /*geom, handleSize*/
1018
- 24 && o !== (o = /*point*/
1019
- t[11][1] - /*handleSize*/
1020
- t[3] / 2) && d(e, "y", o), s & /*handleSize*/
1021
- 8 && d(
1022
- e,
1023
- "height",
1024
- /*handleSize*/
1025
- t[3]
1026
- ), s & /*handleSize*/
1027
- 8 && d(
1028
- e,
1029
- "width",
1030
- /*handleSize*/
1031
- t[3]
1032
- );
1033
- },
1034
- d(a) {
1035
- a && S(e), r = !1, i();
1036
- }
1037
- };
1038
- }
1039
- function qn(t) {
1040
- let e, n, o, r, i, a, s, l, c, h, u = (
1041
- /*geom*/
1042
- t[4].points
1043
- ), f = [];
1044
- for (let p = 0; p < u.length; p += 1)
1045
- f[p] = ge(fe(t, u, p));
1046
- return {
1047
- c() {
1048
- e = R("polygon"), r = K(), i = R("polygon"), s = K();
1049
- for (let p = 0; p < f.length; p += 1)
1050
- f[p].c();
1051
- l = at(), d(e, "class", "a9s-outer"), d(e, "style", n = /*computedStyle*/
1052
- t[1] ? "display:none;" : void 0), d(e, "points", o = /*geom*/
1053
- t[4].points.map(me).join(" ")), d(i, "class", "a9s-inner a9s-shape-handle"), d(
1054
- i,
1055
- "style",
1056
- /*computedStyle*/
1057
- t[1]
1058
- ), d(i, "points", a = /*geom*/
1059
- t[4].points.map(ye).join(" "));
1060
- },
1061
- m(p, g) {
1062
- O(p, e, g), O(p, r, g), O(p, i, g), O(p, s, g);
1063
- for (let m = 0; m < f.length; m += 1)
1064
- f[m] && f[m].m(p, g);
1065
- O(p, l, g), c || (h = [
1066
- C(e, "pointerdown", function() {
1067
- V(
1068
- /*grab*/
1069
- t[10](M.SHAPE)
1070
- ) && t[10](M.SHAPE).apply(this, arguments);
1071
- }),
1072
- C(i, "pointerdown", function() {
1073
- V(
1074
- /*grab*/
1075
- t[10](M.SHAPE)
1076
- ) && t[10](M.SHAPE).apply(this, arguments);
1077
- })
1078
- ], c = !0);
1079
- },
1080
- p(p, g) {
1081
- if (t = p, g & /*computedStyle*/
1082
- 2 && n !== (n = /*computedStyle*/
1083
- t[1] ? "display:none;" : void 0) && d(e, "style", n), g & /*geom*/
1084
- 16 && o !== (o = /*geom*/
1085
- t[4].points.map(me).join(" ")) && d(e, "points", o), g & /*computedStyle*/
1086
- 2 && d(
1087
- i,
1088
- "style",
1089
- /*computedStyle*/
1090
- t[1]
1091
- ), g & /*geom*/
1092
- 16 && a !== (a = /*geom*/
1093
- t[4].points.map(ye).join(" ")) && d(i, "points", a), g & /*geom, handleSize, grab, Handle*/
1094
- 1048) {
1095
- u = /*geom*/
1096
- t[4].points;
1097
- let m;
1098
- for (m = 0; m < u.length; m += 1) {
1099
- const b = fe(t, u, m);
1100
- f[m] ? f[m].p(b, g) : (f[m] = ge(b), f[m].c(), f[m].m(l.parentNode, l));
1101
- }
1102
- for (; m < f.length; m += 1)
1103
- f[m].d(1);
1104
- f.length = u.length;
1105
- }
1106
- },
1107
- d(p) {
1108
- p && S(e), p && S(r), p && S(i), p && S(s), ee(f, p), p && S(l), c = !1, it(h);
1109
- }
1110
- };
1111
- }
1112
- function Jn(t) {
1113
- let e, n;
1114
- return e = new He({
1115
- props: {
1116
- shape: (
1117
- /*shape*/
1118
- t[0]
1119
- ),
1120
- transform: (
1121
- /*transform*/
1122
- t[2]
1123
- ),
1124
- editor: (
1125
- /*editor*/
1126
- t[5]
1127
- ),
1128
- $$slots: {
1129
- default: [
1130
- qn,
1131
- ({ grab: o }) => ({ 10: o }),
1132
- ({ grab: o }) => o ? 1024 : 0
1133
- ]
1134
- },
1135
- $$scope: { ctx: t }
1136
- }
1137
- }), e.$on(
1138
- "change",
1139
- /*change_handler*/
1140
- t[7]
1141
- ), e.$on(
1142
- "grab",
1143
- /*grab_handler*/
1144
- t[8]
1145
- ), e.$on(
1146
- "release",
1147
- /*release_handler*/
1148
- t[9]
1149
- ), {
1150
- c() {
1151
- ft(e.$$.fragment);
1152
- },
1153
- m(o, r) {
1154
- dt(e, o, r), n = !0;
1155
- },
1156
- p(o, [r]) {
1157
- const i = {};
1158
- r & /*shape*/
1159
- 1 && (i.shape = /*shape*/
1160
- o[0]), r & /*transform*/
1161
- 4 && (i.transform = /*transform*/
1162
- o[2]), r & /*$$scope, geom, handleSize, grab, computedStyle*/
1163
- 17434 && (i.$$scope = { dirty: r, ctx: o }), e.$set(i);
1164
- },
1165
- i(o) {
1166
- n || (I(e.$$.fragment, o), n = !0);
1167
- },
1168
- o(o) {
1169
- N(e.$$.fragment, o), n = !1;
1170
- },
1171
- d(o) {
1172
- ut(e, o);
1173
- }
1174
- };
1175
- }
1176
- const me = (t) => t.join(","), ye = (t) => t.join(",");
1177
- function Qn(t, e, n) {
1178
- let o, r, { shape: i } = e, { computedStyle: a = void 0 } = e, { transform: s } = e, { viewportScale: l = 1 } = e;
1179
- const c = (p, g, m) => {
1180
- let b;
1181
- g === M.SHAPE ? b = p.geometry.points.map(([T, X]) => [T + m[0], X + m[1]]) : b = p.geometry.points.map(([T, X], x) => g === M(x) ? [T + m[0], X + m[1]] : [T, X]);
1182
- const E = Ut(b);
1183
- return { ...p, geometry: { points: b, bounds: E } };
1184
- };
1185
- function h(p) {
1186
- Et.call(this, t, p);
1187
- }
1188
- function u(p) {
1189
- Et.call(this, t, p);
1190
- }
1191
- function f(p) {
1192
- Et.call(this, t, p);
1193
- }
1194
- return t.$$set = (p) => {
1195
- "shape" in p && n(0, i = p.shape), "computedStyle" in p && n(1, a = p.computedStyle), "transform" in p && n(2, s = p.transform), "viewportScale" in p && n(6, l = p.viewportScale);
1196
- }, t.$$.update = () => {
1197
- t.$$.dirty & /*shape*/
1198
- 1 && n(4, o = i.geometry), t.$$.dirty & /*viewportScale*/
1199
- 64 && n(3, r = 10 / l);
1200
- }, [
1201
- i,
1202
- a,
1203
- s,
1204
- r,
1205
- o,
1206
- c,
1207
- l,
1208
- h,
1209
- u,
1210
- f
1211
- ];
1212
- }
1213
- class Zn extends et {
1214
- constructor(e) {
1215
- super(), tt(this, e, Qn, Jn, q, {
1216
- shape: 0,
1217
- computedStyle: 1,
1218
- transform: 2,
1219
- viewportScale: 6
1220
- });
1221
- }
1222
- }
1223
- function Kn(t) {
1224
- let e, n, o, r, i, a, s, l, c, h, u, f, p, g, m, b, E, T, X, x, _, y, $, w, A, L, P, J, U, nt, gt, mt, St, W, Y, z, H, D, st, lt, Ht, Q, Pt, Rt, jt, Z, _t, It, Ct, ie;
1225
- return {
1226
- c() {
1227
- e = R("rect"), s = K(), l = R("rect"), p = K(), g = R("rect"), T = K(), X = R("rect"), $ = K(), w = R("rect"), J = K(), U = R("rect"), St = K(), W = R("rect"), H = K(), D = R("rect"), Ht = K(), Q = R("rect"), jt = K(), Z = R("rect"), d(e, "class", "a9s-outer"), d(e, "style", n = /*computedStyle*/
1228
- t[1] ? "display:none;" : void 0), d(e, "x", o = /*geom*/
1229
- t[4].x), d(e, "y", r = /*geom*/
1230
- t[4].y), d(e, "width", i = /*geom*/
1231
- t[4].w), d(e, "height", a = /*geom*/
1232
- t[4].h), d(l, "class", "a9s-inner a9s-shape-handle"), d(
1233
- l,
1234
- "style",
1235
- /*computedStyle*/
1236
- t[1]
1237
- ), d(l, "x", c = /*geom*/
1238
- t[4].x), d(l, "y", h = /*geom*/
1239
- t[4].y), d(l, "width", u = /*geom*/
1240
- t[4].w), d(l, "height", f = /*geom*/
1241
- t[4].h), d(g, "class", "a9s-edge-handle a9s-edge-handle-top"), d(g, "x", m = /*geom*/
1242
- t[4].x), d(g, "y", b = /*geom*/
1243
- t[4].y), d(g, "height", 1), d(g, "width", E = /*geom*/
1244
- t[4].w), d(X, "class", "a9s-edge-handle a9s-edge-handle-right"), d(X, "x", x = /*geom*/
1245
- t[4].x + /*geom*/
1246
- t[4].w), d(X, "y", _ = /*geom*/
1247
- t[4].y), d(X, "height", y = /*geom*/
1248
- t[4].h), d(X, "width", 1), d(w, "class", "a9s-edge-handle a9s-edge-handle-bottom"), d(w, "x", A = /*geom*/
1249
- t[4].x), d(w, "y", L = /*geom*/
1250
- t[4].y + /*geom*/
1251
- t[4].h), d(w, "height", 1), d(w, "width", P = /*geom*/
1252
- t[4].w), d(U, "class", "a9s-edge-handle a9s-edge-handle-left"), d(U, "x", nt = /*geom*/
1253
- t[4].x), d(U, "y", gt = /*geom*/
1254
- t[4].y), d(U, "height", mt = /*geom*/
1255
- t[4].h), d(U, "width", 1), d(W, "class", "a9s-corner-handle a9s-corner-handle-topleft"), d(W, "x", Y = /*geom*/
1256
- t[4].x - /*handleSize*/
1257
- t[3] / 2), d(W, "y", z = /*geom*/
1258
- t[4].y - /*handleSize*/
1259
- t[3] / 2), d(
1260
- W,
1261
- "height",
1262
- /*handleSize*/
1263
- t[3]
1264
- ), d(
1265
- W,
1266
- "width",
1267
- /*handleSize*/
1268
- t[3]
1269
- ), d(D, "class", "a9s-corner-handle a9s-corner-handle-topright"), d(D, "x", st = /*geom*/
1270
- t[4].x + /*geom*/
1271
- t[4].w - /*handleSize*/
1272
- t[3] / 2), d(D, "y", lt = /*geom*/
1273
- t[4].y - /*handleSize*/
1274
- t[3] / 2), d(
1275
- D,
1276
- "height",
1277
- /*handleSize*/
1278
- t[3]
1279
- ), d(
1280
- D,
1281
- "width",
1282
- /*handleSize*/
1283
- t[3]
1284
- ), d(Q, "class", "a9s-corner-handle a9s-corner-handle-bottomright"), d(Q, "x", Pt = /*geom*/
1285
- t[4].x + /*geom*/
1286
- t[4].w - /*handleSize*/
1287
- t[3] / 2), d(Q, "y", Rt = /*geom*/
1288
- t[4].y + /*geom*/
1289
- t[4].h - /*handleSize*/
1290
- t[3] / 2), d(
1291
- Q,
1292
- "height",
1293
- /*handleSize*/
1294
- t[3]
1295
- ), d(
1296
- Q,
1297
- "width",
1298
- /*handleSize*/
1299
- t[3]
1300
- ), d(Z, "class", "a9s-corner-handle a9s-corner-handle-bottomleft"), d(Z, "x", _t = /*geom*/
1301
- t[4].x - /*handleSize*/
1302
- t[3] / 2), d(Z, "y", It = /*geom*/
1303
- t[4].y + /*geom*/
1304
- t[4].h - /*handleSize*/
1305
- t[3] / 2), d(
1306
- Z,
1307
- "height",
1308
- /*handleSize*/
1309
- t[3]
1310
- ), d(
1311
- Z,
1312
- "width",
1313
- /*handleSize*/
1314
- t[3]
1315
- );
1316
- },
1317
- m(B, v) {
1318
- O(B, e, v), O(B, s, v), O(B, l, v), O(B, p, v), O(B, g, v), O(B, T, v), O(B, X, v), O(B, $, v), O(B, w, v), O(B, J, v), O(B, U, v), O(B, St, v), O(B, W, v), O(B, H, v), O(B, D, v), O(B, Ht, v), O(B, Q, v), O(B, jt, v), O(B, Z, v), Ct || (ie = [
1319
- C(e, "pointerdown", function() {
1320
- V(
1321
- /*grab*/
1322
- t[10](M.SHAPE)
1323
- ) && t[10](M.SHAPE).apply(this, arguments);
1324
- }),
1325
- C(l, "pointerdown", function() {
1326
- V(
1327
- /*grab*/
1328
- t[10](M.SHAPE)
1329
- ) && t[10](M.SHAPE).apply(this, arguments);
1330
- }),
1331
- C(g, "pointerdown", function() {
1332
- V(
1333
- /*grab*/
1334
- t[10](M.TOP)
1335
- ) && t[10](M.TOP).apply(this, arguments);
1336
- }),
1337
- C(X, "pointerdown", function() {
1338
- V(
1339
- /*grab*/
1340
- t[10](M.RIGHT)
1341
- ) && t[10](M.RIGHT).apply(this, arguments);
1342
- }),
1343
- C(w, "pointerdown", function() {
1344
- V(
1345
- /*grab*/
1346
- t[10](M.BOTTOM)
1347
- ) && t[10](M.BOTTOM).apply(this, arguments);
1348
- }),
1349
- C(U, "pointerdown", function() {
1350
- V(
1351
- /*grab*/
1352
- t[10](M.LEFT)
1353
- ) && t[10](M.LEFT).apply(this, arguments);
1354
- }),
1355
- C(W, "pointerdown", function() {
1356
- V(
1357
- /*grab*/
1358
- t[10](M.TOP_LEFT)
1359
- ) && t[10](M.TOP_LEFT).apply(this, arguments);
1360
- }),
1361
- C(D, "pointerdown", function() {
1362
- V(
1363
- /*grab*/
1364
- t[10](M.TOP_RIGHT)
1365
- ) && t[10](M.TOP_RIGHT).apply(this, arguments);
1366
- }),
1367
- C(Q, "pointerdown", function() {
1368
- V(
1369
- /*grab*/
1370
- t[10](M.BOTTOM_RIGHT)
1371
- ) && t[10](M.BOTTOM_RIGHT).apply(this, arguments);
1372
- }),
1373
- C(Z, "pointerdown", function() {
1374
- V(
1375
- /*grab*/
1376
- t[10](M.BOTTOM_LEFT)
1377
- ) && t[10](M.BOTTOM_LEFT).apply(this, arguments);
1378
- })
1379
- ], Ct = !0);
1380
- },
1381
- p(B, v) {
1382
- t = B, v & /*computedStyle*/
1383
- 2 && n !== (n = /*computedStyle*/
1384
- t[1] ? "display:none;" : void 0) && d(e, "style", n), v & /*geom*/
1385
- 16 && o !== (o = /*geom*/
1386
- t[4].x) && d(e, "x", o), v & /*geom*/
1387
- 16 && r !== (r = /*geom*/
1388
- t[4].y) && d(e, "y", r), v & /*geom*/
1389
- 16 && i !== (i = /*geom*/
1390
- t[4].w) && d(e, "width", i), v & /*geom*/
1391
- 16 && a !== (a = /*geom*/
1392
- t[4].h) && d(e, "height", a), v & /*computedStyle*/
1393
- 2 && d(
1394
- l,
1395
- "style",
1396
- /*computedStyle*/
1397
- t[1]
1398
- ), v & /*geom*/
1399
- 16 && c !== (c = /*geom*/
1400
- t[4].x) && d(l, "x", c), v & /*geom*/
1401
- 16 && h !== (h = /*geom*/
1402
- t[4].y) && d(l, "y", h), v & /*geom*/
1403
- 16 && u !== (u = /*geom*/
1404
- t[4].w) && d(l, "width", u), v & /*geom*/
1405
- 16 && f !== (f = /*geom*/
1406
- t[4].h) && d(l, "height", f), v & /*geom*/
1407
- 16 && m !== (m = /*geom*/
1408
- t[4].x) && d(g, "x", m), v & /*geom*/
1409
- 16 && b !== (b = /*geom*/
1410
- t[4].y) && d(g, "y", b), v & /*geom*/
1411
- 16 && E !== (E = /*geom*/
1412
- t[4].w) && d(g, "width", E), v & /*geom*/
1413
- 16 && x !== (x = /*geom*/
1414
- t[4].x + /*geom*/
1415
- t[4].w) && d(X, "x", x), v & /*geom*/
1416
- 16 && _ !== (_ = /*geom*/
1417
- t[4].y) && d(X, "y", _), v & /*geom*/
1418
- 16 && y !== (y = /*geom*/
1419
- t[4].h) && d(X, "height", y), v & /*geom*/
1420
- 16 && A !== (A = /*geom*/
1421
- t[4].x) && d(w, "x", A), v & /*geom*/
1422
- 16 && L !== (L = /*geom*/
1423
- t[4].y + /*geom*/
1424
- t[4].h) && d(w, "y", L), v & /*geom*/
1425
- 16 && P !== (P = /*geom*/
1426
- t[4].w) && d(w, "width", P), v & /*geom*/
1427
- 16 && nt !== (nt = /*geom*/
1428
- t[4].x) && d(U, "x", nt), v & /*geom*/
1429
- 16 && gt !== (gt = /*geom*/
1430
- t[4].y) && d(U, "y", gt), v & /*geom*/
1431
- 16 && mt !== (mt = /*geom*/
1432
- t[4].h) && d(U, "height", mt), v & /*geom, handleSize*/
1433
- 24 && Y !== (Y = /*geom*/
1434
- t[4].x - /*handleSize*/
1435
- t[3] / 2) && d(W, "x", Y), v & /*geom, handleSize*/
1436
- 24 && z !== (z = /*geom*/
1437
- t[4].y - /*handleSize*/
1438
- t[3] / 2) && d(W, "y", z), v & /*handleSize*/
1439
- 8 && d(
1440
- W,
1441
- "height",
1442
- /*handleSize*/
1443
- t[3]
1444
- ), v & /*handleSize*/
1445
- 8 && d(
1446
- W,
1447
- "width",
1448
- /*handleSize*/
1449
- t[3]
1450
- ), v & /*geom, handleSize*/
1451
- 24 && st !== (st = /*geom*/
1452
- t[4].x + /*geom*/
1453
- t[4].w - /*handleSize*/
1454
- t[3] / 2) && d(D, "x", st), v & /*geom, handleSize*/
1455
- 24 && lt !== (lt = /*geom*/
1456
- t[4].y - /*handleSize*/
1457
- t[3] / 2) && d(D, "y", lt), v & /*handleSize*/
1458
- 8 && d(
1459
- D,
1460
- "height",
1461
- /*handleSize*/
1462
- t[3]
1463
- ), v & /*handleSize*/
1464
- 8 && d(
1465
- D,
1466
- "width",
1467
- /*handleSize*/
1468
- t[3]
1469
- ), v & /*geom, handleSize*/
1470
- 24 && Pt !== (Pt = /*geom*/
1471
- t[4].x + /*geom*/
1472
- t[4].w - /*handleSize*/
1473
- t[3] / 2) && d(Q, "x", Pt), v & /*geom, handleSize*/
1474
- 24 && Rt !== (Rt = /*geom*/
1475
- t[4].y + /*geom*/
1476
- t[4].h - /*handleSize*/
1477
- t[3] / 2) && d(Q, "y", Rt), v & /*handleSize*/
1478
- 8 && d(
1479
- Q,
1480
- "height",
1481
- /*handleSize*/
1482
- t[3]
1483
- ), v & /*handleSize*/
1484
- 8 && d(
1485
- Q,
1486
- "width",
1487
- /*handleSize*/
1488
- t[3]
1489
- ), v & /*geom, handleSize*/
1490
- 24 && _t !== (_t = /*geom*/
1491
- t[4].x - /*handleSize*/
1492
- t[3] / 2) && d(Z, "x", _t), v & /*geom, handleSize*/
1493
- 24 && It !== (It = /*geom*/
1494
- t[4].y + /*geom*/
1495
- t[4].h - /*handleSize*/
1496
- t[3] / 2) && d(Z, "y", It), v & /*handleSize*/
1497
- 8 && d(
1498
- Z,
1499
- "height",
1500
- /*handleSize*/
1501
- t[3]
1502
- ), v & /*handleSize*/
1503
- 8 && d(
1504
- Z,
1505
- "width",
1506
- /*handleSize*/
1507
- t[3]
1508
- );
1509
- },
1510
- d(B) {
1511
- B && S(e), B && S(s), B && S(l), B && S(p), B && S(g), B && S(T), B && S(X), B && S($), B && S(w), B && S(J), B && S(U), B && S(St), B && S(W), B && S(H), B && S(D), B && S(Ht), B && S(Q), B && S(jt), B && S(Z), Ct = !1, it(ie);
1512
- }
1513
- };
1514
- }
1515
- function to(t) {
1516
- let e, n;
1517
- return e = new He({
1518
- props: {
1519
- shape: (
1520
- /*shape*/
1521
- t[0]
1522
- ),
1523
- transform: (
1524
- /*transform*/
1525
- t[2]
1526
- ),
1527
- editor: (
1528
- /*editor*/
1529
- t[5]
1530
- ),
1531
- $$slots: {
1532
- default: [
1533
- Kn,
1534
- ({ grab: o }) => ({ 10: o }),
1535
- ({ grab: o }) => o ? 1024 : 0
1536
- ]
1537
- },
1538
- $$scope: { ctx: t }
1539
- }
1540
- }), e.$on(
1541
- "grab",
1542
- /*grab_handler*/
1543
- t[7]
1544
- ), e.$on(
1545
- "change",
1546
- /*change_handler*/
1547
- t[8]
1548
- ), e.$on(
1549
- "release",
1550
- /*release_handler*/
1551
- t[9]
1552
- ), {
1553
- c() {
1554
- ft(e.$$.fragment);
1555
- },
1556
- m(o, r) {
1557
- dt(e, o, r), n = !0;
1558
- },
1559
- p(o, [r]) {
1560
- const i = {};
1561
- r & /*shape*/
1562
- 1 && (i.shape = /*shape*/
1563
- o[0]), r & /*transform*/
1564
- 4 && (i.transform = /*transform*/
1565
- o[2]), r & /*$$scope, geom, handleSize, grab, computedStyle*/
1566
- 3098 && (i.$$scope = { dirty: r, ctx: o }), e.$set(i);
1567
- },
1568
- i(o) {
1569
- n || (I(e.$$.fragment, o), n = !0);
1570
- },
1571
- o(o) {
1572
- N(e.$$.fragment, o), n = !1;
1573
- },
1574
- d(o) {
1575
- ut(e, o);
1576
- }
1577
- };
1578
- }
1579
- function eo(t, e, n) {
1580
- let o, r, { shape: i } = e, { computedStyle: a = void 0 } = e, { transform: s } = e, { viewportScale: l = 1 } = e;
1581
- const c = (p, g, m) => {
1582
- const b = p.geometry.bounds;
1583
- let [E, T] = [b.minX, b.minY], [X, x] = [b.maxX, b.maxY];
1584
- const [_, y] = m;
1585
- if (g === M.SHAPE)
1586
- E += _, X += _, T += y, x += y;
1587
- else {
1588
- switch (g) {
1589
- case M.TOP:
1590
- case M.TOP_LEFT:
1591
- case M.TOP_RIGHT: {
1592
- T += y;
1593
- break;
1594
- }
1595
- case M.BOTTOM:
1596
- case M.BOTTOM_LEFT:
1597
- case M.BOTTOM_RIGHT: {
1598
- x += y;
1599
- break;
1600
- }
1601
- }
1602
- switch (g) {
1603
- case M.LEFT:
1604
- case M.TOP_LEFT:
1605
- case M.BOTTOM_LEFT: {
1606
- E += _;
1607
- break;
1608
- }
1609
- case M.RIGHT:
1610
- case M.TOP_RIGHT:
1611
- case M.BOTTOM_RIGHT: {
1612
- X += _;
1613
- break;
1614
- }
1615
- }
1616
- }
1617
- const $ = Math.min(E, X), w = Math.min(T, x), A = Math.abs(X - E), L = Math.abs(x - T);
1618
- return {
1619
- ...p,
1620
- geometry: {
1621
- x: $,
1622
- y: w,
1623
- w: A,
1624
- h: L,
1625
- bounds: {
1626
- minX: $,
1627
- minY: w,
1628
- maxX: $ + A,
1629
- maxY: w + L
1630
- }
1631
- }
1632
- };
1633
- };
1634
- function h(p) {
1635
- Et.call(this, t, p);
1636
- }
1637
- function u(p) {
1638
- Et.call(this, t, p);
1639
- }
1640
- function f(p) {
1641
- Et.call(this, t, p);
1642
- }
1643
- return t.$$set = (p) => {
1644
- "shape" in p && n(0, i = p.shape), "computedStyle" in p && n(1, a = p.computedStyle), "transform" in p && n(2, s = p.transform), "viewportScale" in p && n(6, l = p.viewportScale);
1645
- }, t.$$.update = () => {
1646
- t.$$.dirty & /*shape*/
1647
- 1 && n(4, o = i.geometry), t.$$.dirty & /*viewportScale*/
1648
- 64 && n(3, r = 10 / l);
1649
- }, [
1650
- i,
1651
- a,
1652
- s,
1653
- r,
1654
- o,
1655
- c,
1656
- l,
1657
- h,
1658
- u,
1659
- f
1660
- ];
1661
- }
1662
- class no extends et {
1663
- constructor(e) {
1664
- super(), tt(this, e, eo, to, q, {
1665
- shape: 0,
1666
- computedStyle: 1,
1667
- transform: 2,
1668
- viewportScale: 6
1669
- });
1670
- }
1671
- }
1672
- const Ve = /* @__PURE__ */ new Map([
1673
- [F.RECTANGLE, no],
1674
- [F.POLYGON, Zn]
1675
- ]), we = (t) => Ve.get(t.type), oo = (t, e) => Ve.set(t, e), M = (t) => `HANDLE-${t}`;
1676
- M.SHAPE = "SHAPE";
1677
- M.TOP = "TOP";
1678
- M.RIGHT = "RIGHT";
1679
- M.BOTTOM = "BOTTOM";
1680
- M.LEFT = "LEFT";
1681
- M.TOP_LEFT = "TOP_LEFT";
1682
- M.TOP_RIGHT = "TOP_RIGHT";
1683
- M.BOTTOM_RIGHT = "BOTTOM_RIGHT";
1684
- M.BOTTOM_LEFT = "BOTTOM_LEFT";
1685
- const ro = (t) => ({}), $e = (t) => ({ grab: (
1686
- /*onGrab*/
1687
- t[0]
1688
- ) });
1689
- function io(t) {
1690
- let e, n, o, r;
1691
- const i = (
1692
- /*#slots*/
1693
- t[7].default
1694
- ), a = qe(
1695
- i,
1696
- t,
1697
- /*$$scope*/
1698
- t[6],
1699
- $e
1700
- );
1701
- return {
1702
- c() {
1703
- e = R("g"), a && a.c(), d(e, "class", "a9s-annotation selected");
1704
- },
1705
- m(s, l) {
1706
- O(s, e, l), a && a.m(e, null), n = !0, o || (r = [
1707
- C(
1708
- e,
1709
- "pointerup",
1710
- /*onRelease*/
1711
- t[2]
1712
- ),
1713
- C(
1714
- e,
1715
- "pointermove",
1716
- /*onPointerMove*/
1717
- t[1]
1718
- )
1719
- ], o = !0);
1720
- },
1721
- p(s, [l]) {
1722
- a && a.p && (!n || l & /*$$scope*/
1723
- 64) && Qe(
1724
- a,
1725
- i,
1726
- s,
1727
- /*$$scope*/
1728
- s[6],
1729
- n ? Je(
1730
- i,
1731
- /*$$scope*/
1732
- s[6],
1733
- l,
1734
- ro
1735
- ) : Ze(
1736
- /*$$scope*/
1737
- s[6]
1738
- ),
1739
- $e
1740
- );
1741
- },
1742
- i(s) {
1743
- n || (I(a, s), n = !0);
1744
- },
1745
- o(s) {
1746
- N(a, s), n = !1;
1747
- },
1748
- d(s) {
1749
- s && S(e), a && a.d(s), o = !1, it(r);
1750
- }
1751
- };
1752
- }
1753
- function ao(t, e, n) {
1754
- let { $$slots: o = {}, $$scope: r } = e;
1755
- const i = Mt();
1756
- let { shape: a } = e, { editor: s } = e, { transform: l } = e, c = null, h, u = null;
1757
- const f = (m) => (b) => {
1758
- c = m, h = l.elementToImage(b.offsetX, b.offsetY), u = a, b.target.setPointerCapture(b.pointerId), i("grab");
1759
- }, p = (m) => {
1760
- if (c) {
1761
- const [b, E] = l.elementToImage(m.offsetX, m.offsetY), T = [b - h[0], E - h[1]];
1762
- n(3, a = s(u, c, T)), i("change", a);
1763
- }
1764
- }, g = (m) => {
1765
- m.target.releasePointerCapture(m.pointerId), c = null, u = a, i("release");
1766
- };
1767
- return t.$$set = (m) => {
1768
- "shape" in m && n(3, a = m.shape), "editor" in m && n(4, s = m.editor), "transform" in m && n(5, l = m.transform), "$$scope" in m && n(6, r = m.$$scope);
1769
- }, [f, p, g, a, s, l, r, o];
1770
- }
1771
- class He extends et {
1772
- constructor(e) {
1773
- super(), tt(this, e, ao, io, q, { shape: 3, editor: 4, transform: 5 });
1774
- }
1775
- }
1776
- const Vt = (t, e) => {
1777
- const n = typeof e == "function" ? e(t) : e;
1778
- if (n) {
1779
- const { fill: o, fillOpacity: r } = n;
1780
- let i = "";
1781
- return o && (i += `fill:${o};stroke:${o};`), i += `fill-opacity:${r || "0.25"};`, i;
1782
- }
1783
- };
1784
- function so(t, e, n) {
1785
- let o;
1786
- const r = Mt();
1787
- let { annotation: i } = e, { editor: a } = e, { style: s = void 0 } = e, { target: l } = e, { transform: c } = e, { viewportScale: h } = e, u;
1788
- return Xt(() => (n(6, u = new a({
1789
- target: l,
1790
- props: {
1791
- shape: i.target.selector,
1792
- computedStyle: o,
1793
- transform: c,
1794
- viewportScale: h
1795
- }
1796
- })), u.$on("change", (f) => {
1797
- u.$$set({ shape: f.detail }), r("change", f.detail);
1798
- }), u.$on("grab", (f) => r("grab", f.detail)), u.$on("release", (f) => r("release", f.detail)), () => {
1799
- u.$destroy();
1800
- })), t.$$set = (f) => {
1801
- "annotation" in f && n(0, i = f.annotation), "editor" in f && n(1, a = f.editor), "style" in f && n(2, s = f.style), "target" in f && n(3, l = f.target), "transform" in f && n(4, c = f.transform), "viewportScale" in f && n(5, h = f.viewportScale);
1802
- }, t.$$.update = () => {
1803
- t.$$.dirty & /*annotation, style*/
1804
- 5 && (o = Vt(i, s)), t.$$.dirty & /*editorComponent, transform*/
1805
- 80 && u && u.$set({ transform: c }), t.$$.dirty & /*editorComponent, viewportScale*/
1806
- 96 && u && u.$set({ viewportScale: h });
1807
- }, [i, a, s, l, c, h, u];
1808
- }
1809
- class lo extends et {
1810
- constructor(e) {
1811
- super(), tt(this, e, so, null, q, {
1812
- annotation: 0,
1813
- editor: 1,
1814
- style: 2,
1815
- target: 3,
1816
- transform: 4,
1817
- viewportScale: 5
1818
- });
1819
- }
1820
- }
1821
- function co(t, e, n) {
1822
- const o = Mt();
1823
- let { drawingMode: r } = e, { target: i } = e, { tool: a } = e, { transform: s } = e, { viewportScale: l } = e, c;
1824
- return Xt(() => {
1825
- const h = i.closest("svg"), u = [], f = (p, g, m) => {
1826
- h.addEventListener(p, g, m), u.push(() => h.removeEventListener(p, g, m));
1827
- };
1828
- return n(5, c = new a({
1829
- target: i,
1830
- props: {
1831
- addEventListener: f,
1832
- drawingMode: r,
1833
- transform: s,
1834
- viewportScale: l
1835
- }
1836
- })), c.$on("create", (p) => o("create", p.detail)), () => {
1837
- u.forEach((p) => p()), c.$destroy();
1838
- };
1839
- }), t.$$set = (h) => {
1840
- "drawingMode" in h && n(0, r = h.drawingMode), "target" in h && n(1, i = h.target), "tool" in h && n(2, a = h.tool), "transform" in h && n(3, s = h.transform), "viewportScale" in h && n(4, l = h.viewportScale);
1841
- }, t.$$.update = () => {
1842
- t.$$.dirty & /*toolComponent, transform*/
1843
- 40 && c && c.$set({ transform: s }), t.$$.dirty & /*toolComponent, viewportScale*/
1844
- 48 && c && c.$set({ viewportScale: l });
1845
- }, [r, i, a, s, l, c];
1846
- }
1847
- class uo extends et {
1848
- constructor(e) {
1849
- super(), tt(this, e, co, null, q, {
1850
- drawingMode: 0,
1851
- target: 1,
1852
- tool: 2,
1853
- transform: 3,
1854
- viewportScale: 4
1855
- });
1856
- }
1857
- }
1858
- function xe(t) {
1859
- let e, n;
1860
- return {
1861
- c() {
1862
- e = R("rect"), n = R("rect"), d(e, "class", "a9s-outer"), d(
1863
- e,
1864
- "x",
1865
- /*x*/
1866
- t[2]
1867
- ), d(
1868
- e,
1869
- "y",
1870
- /*y*/
1871
- t[3]
1872
- ), d(
1873
- e,
1874
- "width",
1875
- /*w*/
1876
- t[4]
1877
- ), d(
1878
- e,
1879
- "height",
1880
- /*h*/
1881
- t[5]
1882
- ), d(n, "class", "a9s-inner"), d(
1883
- n,
1884
- "x",
1885
- /*x*/
1886
- t[2]
1887
- ), d(
1888
- n,
1889
- "y",
1890
- /*y*/
1891
- t[3]
1892
- ), d(
1893
- n,
1894
- "width",
1895
- /*w*/
1896
- t[4]
1897
- ), d(
1898
- n,
1899
- "height",
1900
- /*h*/
1901
- t[5]
1902
- );
1903
- },
1904
- m(o, r) {
1905
- O(o, e, r), O(o, n, r);
1906
- },
1907
- p(o, r) {
1908
- r & /*x*/
1909
- 4 && d(
1910
- e,
1911
- "x",
1912
- /*x*/
1913
- o[2]
1914
- ), r & /*y*/
1915
- 8 && d(
1916
- e,
1917
- "y",
1918
- /*y*/
1919
- o[3]
1920
- ), r & /*w*/
1921
- 16 && d(
1922
- e,
1923
- "width",
1924
- /*w*/
1925
- o[4]
1926
- ), r & /*h*/
1927
- 32 && d(
1928
- e,
1929
- "height",
1930
- /*h*/
1931
- o[5]
1932
- ), r & /*x*/
1933
- 4 && d(
1934
- n,
1935
- "x",
1936
- /*x*/
1937
- o[2]
1938
- ), r & /*y*/
1939
- 8 && d(
1940
- n,
1941
- "y",
1942
- /*y*/
1943
- o[3]
1944
- ), r & /*w*/
1945
- 16 && d(
1946
- n,
1947
- "width",
1948
- /*w*/
1949
- o[4]
1950
- ), r & /*h*/
1951
- 32 && d(
1952
- n,
1953
- "height",
1954
- /*h*/
1955
- o[5]
1956
- );
1957
- },
1958
- d(o) {
1959
- o && S(e), o && S(n);
1960
- }
1961
- };
1962
- }
1963
- function ho(t) {
1964
- let e, n = (
1965
- /*origin*/
1966
- t[1] && xe(t)
1967
- );
1968
- return {
1969
- c() {
1970
- e = R("g"), n && n.c(), d(e, "class", "a9s-annotation a9s-rubberband");
1971
- },
1972
- m(o, r) {
1973
- O(o, e, r), n && n.m(e, null), t[9](e);
1974
- },
1975
- p(o, [r]) {
1976
- o[1] ? n ? n.p(o, r) : (n = xe(o), n.c(), n.m(e, null)) : n && (n.d(1), n = null);
1977
- },
1978
- i: k,
1979
- o: k,
1980
- d(o) {
1981
- o && S(e), n && n.d(), t[9](null);
1982
- }
1983
- };
1984
- }
1985
- function po(t, e, n) {
1986
- const o = Mt();
1987
- let { addEventListener: r } = e, { drawingMode: i } = e, { transform: a } = e, s, l, c, h, u, f, p, g;
1988
- const m = (x) => {
1989
- l = performance.now(), i === "drag" && (n(1, c = a.elementToImage(x.offsetX, x.offsetY)), h = c, n(2, u = c[0]), n(3, f = c[1]), n(4, p = 1), n(5, g = 1));
1990
- }, b = (x) => {
1991
- c && (h = a.elementToImage(x.offsetX, x.offsetY), n(2, u = Math.min(h[0], c[0])), n(3, f = Math.min(h[1], c[1])), n(4, p = Math.abs(h[0] - c[0])), n(5, g = Math.abs(h[1] - c[1])));
1992
- }, E = (x) => {
1993
- const _ = performance.now() - l;
1994
- if (i === "click") {
1995
- if (_ > 300)
1996
- return;
1997
- x.stopPropagation(), c ? T() : (n(1, c = a.elementToImage(x.offsetX, x.offsetY)), h = c, n(2, u = c[0]), n(3, f = c[1]), n(4, p = 1), n(5, g = 1));
1998
- } else
1999
- c && (_ > 300 || p * g > 100 ? (x.stopPropagation(), T()) : (n(1, c = null), h = null));
2000
- }, T = () => {
2001
- if (p * g > 15) {
2002
- const x = {
2003
- type: F.RECTANGLE,
2004
- geometry: {
2005
- bounds: {
2006
- minX: u,
2007
- minY: f,
2008
- maxX: u + p,
2009
- maxY: f + g
2010
- },
2011
- x: u,
2012
- y: f,
2013
- w: p,
2014
- h: g
2015
- }
2016
- };
2017
- o("create", x);
2018
- }
2019
- n(1, c = null), h = null;
2020
- };
2021
- Xt(() => {
2022
- r("pointerdown", m), r("pointermove", b), r("pointerup", E, !0);
2023
- });
2024
- function X(x) {
2025
- At[x ? "unshift" : "push"](() => {
2026
- s = x, n(0, s);
2027
- });
2028
- }
2029
- return t.$$set = (x) => {
2030
- "addEventListener" in x && n(6, r = x.addEventListener), "drawingMode" in x && n(7, i = x.drawingMode), "transform" in x && n(8, a = x.transform);
2031
- }, [
2032
- s,
2033
- c,
2034
- u,
2035
- f,
2036
- p,
2037
- g,
2038
- r,
2039
- i,
2040
- a,
2041
- X
2042
- ];
2043
- }
2044
- class fo extends et {
2045
- constructor(e) {
2046
- super(), tt(this, e, po, ho, q, {
2047
- addEventListener: 6,
2048
- drawingMode: 7,
2049
- transform: 8
2050
- });
2051
- }
2052
- }
2053
- const be = (t, e) => {
2054
- const n = Math.abs(e[0] - t[0]), o = Math.abs(e[1] - t[1]);
2055
- return Math.sqrt(Math.pow(n, 2) + Math.pow(o, 2));
2056
- }, go = (t, e) => {
2057
- const { naturalWidth: n, naturalHeight: o } = t;
2058
- if (!n && !o) {
2059
- const { width: r, height: i } = t;
2060
- e.setAttribute("viewBox", `0 0 ${r} ${i}`), t.addEventListener("load", (a) => {
2061
- const s = a.target;
2062
- e.setAttribute("viewBox", `0 0 ${s.naturalWidth} ${s.naturalHeight}`);
2063
- });
2064
- } else
2065
- e.setAttribute("viewBox", `0 0 ${n} ${o}`);
2066
- }, mo = (t, e) => {
2067
- go(t, e);
2068
- const { subscribe: n, set: o } = Ft(1);
2069
- let r;
2070
- return window.ResizeObserver && (r = new ResizeObserver(() => {
2071
- const i = e.getBoundingClientRect(), { width: a, height: s } = e.viewBox.baseVal, l = Math.max(
2072
- i.width / a,
2073
- i.height / s
2074
- );
2075
- o(l);
2076
- }), r.observe(e.parentElement)), { destroy: () => {
2077
- r && r.disconnect();
2078
- }, subscribe: n };
2079
- };
2080
- function qt(t) {
2081
- const e = t.slice(), n = (
2082
- /*isClosable*/
2083
- (e[3] ? (
2084
- /*points*/
2085
- e[1]
2086
- ) : [
2087
- .../*points*/
2088
- e[1],
2089
- /*cursor*/
2090
- e[2]
2091
- ]).map((o) => o.join(",")).join(" ")
2092
- );
2093
- return e[17] = n, e;
2094
- }
2095
- function Ee(t) {
2096
- let e, n, o, r, i, a = (
2097
- /*isClosable*/
2098
- t[3] && ve(t)
2099
- );
2100
- return {
2101
- c() {
2102
- e = R("polygon"), o = R("polygon"), a && a.c(), i = at(), d(e, "class", "a9s-outer"), d(e, "points", n = /*coords*/
2103
- t[17]), d(o, "class", "a9s-inner"), d(o, "points", r = /*coords*/
2104
- t[17]);
2105
- },
2106
- m(s, l) {
2107
- O(s, e, l), O(s, o, l), a && a.m(s, l), O(s, i, l);
2108
- },
2109
- p(s, l) {
2110
- l & /*isClosable, points, cursor*/
2111
- 14 && n !== (n = /*coords*/
2112
- s[17]) && d(e, "points", n), l & /*isClosable, points, cursor*/
2113
- 14 && r !== (r = /*coords*/
2114
- s[17]) && d(o, "points", r), /*isClosable*/
2115
- s[3] ? a ? a.p(s, l) : (a = ve(s), a.c(), a.m(i.parentNode, i)) : a && (a.d(1), a = null);
2116
- },
2117
- d(s) {
2118
- s && S(e), s && S(o), a && a.d(s), s && S(i);
2119
- }
2120
- };
2121
- }
2122
- function ve(t) {
2123
- let e, n, o;
2124
- return {
2125
- c() {
2126
- e = R("rect"), d(e, "class", "a9s-corner-handle"), d(e, "x", n = /*points*/
2127
- t[1][0][0] - /*handleSize*/
2128
- t[4] / 2), d(e, "y", o = /*points*/
2129
- t[1][0][1] - /*handleSize*/
2130
- t[4] / 2), d(
2131
- e,
2132
- "height",
2133
- /*handleSize*/
2134
- t[4]
2135
- ), d(
2136
- e,
2137
- "width",
2138
- /*handleSize*/
2139
- t[4]
2140
- );
2141
- },
2142
- m(r, i) {
2143
- O(r, e, i);
2144
- },
2145
- p(r, i) {
2146
- i & /*points, handleSize*/
2147
- 18 && n !== (n = /*points*/
2148
- r[1][0][0] - /*handleSize*/
2149
- r[4] / 2) && d(e, "x", n), i & /*points, handleSize*/
2150
- 18 && o !== (o = /*points*/
2151
- r[1][0][1] - /*handleSize*/
2152
- r[4] / 2) && d(e, "y", o), i & /*handleSize*/
2153
- 16 && d(
2154
- e,
2155
- "height",
2156
- /*handleSize*/
2157
- r[4]
2158
- ), i & /*handleSize*/
2159
- 16 && d(
2160
- e,
2161
- "width",
2162
- /*handleSize*/
2163
- r[4]
2164
- );
2165
- },
2166
- d(r) {
2167
- r && S(e);
2168
- }
2169
- };
2170
- }
2171
- function yo(t) {
2172
- let e, n = (
2173
- /*cursor*/
2174
- t[2] && Ee(qt(t))
2175
- );
2176
- return {
2177
- c() {
2178
- e = R("g"), n && n.c(), d(e, "class", "a9s-annotation a9s-rubberband");
2179
- },
2180
- m(o, r) {
2181
- O(o, e, r), n && n.m(e, null), t[9](e);
2182
- },
2183
- p(o, [r]) {
2184
- o[2] ? n ? n.p(qt(o), r) : (n = Ee(qt(o)), n.c(), n.m(e, null)) : n && (n.d(1), n = null);
2185
- },
2186
- i: k,
2187
- o: k,
2188
- d(o) {
2189
- o && S(e), n && n.d(), t[9](null);
2190
- }
2191
- };
2192
- }
2193
- const wo = 20;
2194
- function $o(t, e, n) {
2195
- let o;
2196
- const r = Mt();
2197
- let { addEventListener: i } = e, { drawingMode: a } = e, { transform: s } = e, { viewportScale: l = 1 } = e, c, h, u = [], f = null, p = !1;
2198
- const g = (x) => {
2199
- if (h = performance.now(), a === "drag" && u.length === 0) {
2200
- const _ = s.elementToImage(x.offsetX, x.offsetY);
2201
- u.push(_), n(2, f = _);
2202
- }
2203
- }, m = (x) => {
2204
- if (u.length > 0 && (n(2, f = s.elementToImage(x.offsetX, x.offsetY)), u.length > 2)) {
2205
- const _ = be(f, u[0]) * l;
2206
- n(3, p = _ < wo);
2207
- }
2208
- }, b = (x) => {
2209
- const _ = performance.now() - h;
2210
- if (a === "click") {
2211
- if (_ > 300)
2212
- return;
2213
- if (x.stopPropagation(), p)
2214
- T();
2215
- else if (u.length === 0) {
2216
- const y = s.elementToImage(x.offsetX, x.offsetY);
2217
- u.push(y), n(2, f = y);
2218
- } else
2219
- u.push(f);
2220
- } else {
2221
- if (u.length === 1 && be(u[0], f) <= 4) {
2222
- n(1, u = []), n(2, f = null);
2223
- return;
2224
- }
2225
- x.stopImmediatePropagation(), p ? T() : u.push(f);
2226
- }
2227
- }, E = () => {
2228
- console.log("dblclick");
2229
- const x = [...u, f], _ = {
2230
- type: F.POLYGON,
2231
- geometry: { bounds: Ut(x), points: x }
2232
- };
2233
- n(1, u = []), n(2, f = null), r("create", _);
2234
- }, T = () => {
2235
- const x = {
2236
- type: F.POLYGON,
2237
- geometry: {
2238
- bounds: Ut(u),
2239
- points: [...u]
2240
- }
2241
- };
2242
- n(1, u = []), n(2, f = null), r("create", x);
2243
- };
2244
- Xt(() => {
2245
- i("pointerdown", g, !0), i("pointermove", m), i("pointerup", b, !0), i("dblclick", E, !0);
2246
- });
2247
- function X(x) {
2248
- At[x ? "unshift" : "push"](() => {
2249
- c = x, n(0, c);
2250
- });
2251
- }
2252
- return t.$$set = (x) => {
2253
- "addEventListener" in x && n(5, i = x.addEventListener), "drawingMode" in x && n(6, a = x.drawingMode), "transform" in x && n(7, s = x.transform), "viewportScale" in x && n(8, l = x.viewportScale);
2254
- }, t.$$.update = () => {
2255
- t.$$.dirty & /*viewportScale*/
2256
- 256 && n(4, o = 10 / l);
2257
- }, [
2258
- c,
2259
- u,
2260
- f,
2261
- p,
2262
- o,
2263
- i,
2264
- a,
2265
- s,
2266
- l,
2267
- X
2268
- ];
2269
- }
2270
- class xo extends et {
2271
- constructor(e) {
2272
- super(), tt(this, e, $o, yo, q, {
2273
- addEventListener: 5,
2274
- drawingMode: 6,
2275
- transform: 7,
2276
- viewportScale: 8
2277
- });
2278
- }
2279
- }
2280
- const re = /* @__PURE__ */ new Map([
2281
- ["rectangle", { tool: fo }],
2282
- ["polygon", { tool: xo }]
2283
- ]), bo = () => [...re.keys()], je = (t) => re.get(t), Eo = (t, e, n) => re.set(t, { tool: e, opts: n });
2284
- function vo(t) {
2285
- let e, n, o, r, i;
2286
- return {
2287
- c() {
2288
- e = R("g"), n = R("ellipse"), r = R("ellipse"), d(n, "class", "a9s-outer"), d(n, "style", o = /*computedStyle*/
2289
- t[1] ? "display:none;" : void 0), d(
2290
- n,
2291
- "cx",
2292
- /*cx*/
2293
- t[2]
2294
- ), d(
2295
- n,
2296
- "cy",
2297
- /*cy*/
2298
- t[3]
2299
- ), d(
2300
- n,
2301
- "rx",
2302
- /*rx*/
2303
- t[4]
2304
- ), d(
2305
- n,
2306
- "ry",
2307
- /*ry*/
2308
- t[5]
2309
- ), d(r, "class", "a9s-inner"), d(
2310
- r,
2311
- "style",
2312
- /*computedStyle*/
2313
- t[1]
2314
- ), d(
2315
- r,
2316
- "cx",
2317
- /*cx*/
2318
- t[2]
2319
- ), d(
2320
- r,
2321
- "cy",
2322
- /*cy*/
2323
- t[3]
2324
- ), d(
2325
- r,
2326
- "rx",
2327
- /*rx*/
2328
- t[4]
2329
- ), d(
2330
- r,
2331
- "ry",
2332
- /*ry*/
2333
- t[5]
2334
- ), d(e, "data-id", i = /*annotation*/
2335
- t[0].id);
2336
- },
2337
- m(a, s) {
2338
- O(a, e, s), ct(e, n), ct(e, r);
2339
- },
2340
- p(a, [s]) {
2341
- s & /*computedStyle*/
2342
- 2 && o !== (o = /*computedStyle*/
2343
- a[1] ? "display:none;" : void 0) && d(n, "style", o), s & /*computedStyle*/
2344
- 2 && d(
2345
- r,
2346
- "style",
2347
- /*computedStyle*/
2348
- a[1]
2349
- ), s & /*annotation*/
2350
- 1 && i !== (i = /*annotation*/
2351
- a[0].id) && d(e, "data-id", i);
2352
- },
2353
- i: k,
2354
- o: k,
2355
- d(a) {
2356
- a && S(e);
2357
- }
2358
- };
2359
- }
2360
- function Ao(t, e, n) {
2361
- let o, { annotation: r } = e, { geom: i } = e, { style: a = void 0 } = e;
2362
- const { cx: s, cy: l, rx: c, ry: h } = i;
2363
- return t.$$set = (u) => {
2364
- "annotation" in u && n(0, r = u.annotation), "geom" in u && n(6, i = u.geom), "style" in u && n(7, a = u.style);
2365
- }, t.$$.update = () => {
2366
- t.$$.dirty & /*annotation, style*/
2367
- 129 && n(1, o = Vt(r, a));
2368
- }, [r, o, s, l, c, h, i, a];
2369
- }
2370
- class Mo extends et {
2371
- constructor(e) {
2372
- super(), tt(this, e, Ao, vo, q, { annotation: 0, geom: 6, style: 7 });
2373
- }
2374
- }
2375
- function So(t) {
2376
- let e, n, o, r, i;
2377
- return {
2378
- c() {
2379
- e = R("g"), n = R("polygon"), r = R("polygon"), d(n, "class", "a9s-outer"), d(n, "style", o = /*computedStyle*/
2380
- t[1] ? "display:none;" : void 0), d(
2381
- n,
2382
- "points",
2383
- /*points*/
2384
- t[2].map(Lo).join(" ")
2385
- ), d(r, "class", "a9s-inner"), d(
2386
- r,
2387
- "style",
2388
- /*computedStyle*/
2389
- t[1]
2390
- ), d(
2391
- r,
2392
- "points",
2393
- /*points*/
2394
- t[2].map(Oo).join(" ")
2395
- ), d(e, "data-id", i = /*annotation*/
2396
- t[0].id);
2397
- },
2398
- m(a, s) {
2399
- O(a, e, s), ct(e, n), ct(e, r);
2400
- },
2401
- p(a, [s]) {
2402
- s & /*computedStyle*/
2403
- 2 && o !== (o = /*computedStyle*/
2404
- a[1] ? "display:none;" : void 0) && d(n, "style", o), s & /*computedStyle*/
2405
- 2 && d(
2406
- r,
2407
- "style",
2408
- /*computedStyle*/
2409
- a[1]
2410
- ), s & /*annotation*/
2411
- 1 && i !== (i = /*annotation*/
2412
- a[0].id) && d(e, "data-id", i);
2413
- },
2414
- i: k,
2415
- o: k,
2416
- d(a) {
2417
- a && S(e);
2418
- }
2419
- };
2420
- }
2421
- const Lo = (t) => t.join(","), Oo = (t) => t.join(",");
2422
- function To(t, e, n) {
2423
- let o, { annotation: r } = e, { geom: i } = e, { style: a = void 0 } = e;
2424
- const { points: s } = i;
2425
- return t.$$set = (l) => {
2426
- "annotation" in l && n(0, r = l.annotation), "geom" in l && n(3, i = l.geom), "style" in l && n(4, a = l.style);
2427
- }, t.$$.update = () => {
2428
- t.$$.dirty & /*annotation, style*/
2429
- 17 && n(1, o = Vt(r, a));
2430
- }, [r, o, s, i, a];
2431
- }
2432
- class Yo extends et {
2433
- constructor(e) {
2434
- super(), tt(this, e, To, So, q, { annotation: 0, geom: 3, style: 4 });
2435
- }
2436
- }
2437
- function Bo(t) {
2438
- let e, n, o, r, i;
2439
- return {
2440
- c() {
2441
- e = R("g"), n = R("rect"), r = R("rect"), d(n, "class", "a9s-outer"), d(n, "style", o = /*computedStyle*/
2442
- t[1] ? "display:none;" : void 0), d(
2443
- n,
2444
- "x",
2445
- /*x*/
2446
- t[2]
2447
- ), d(
2448
- n,
2449
- "y",
2450
- /*y*/
2451
- t[3]
2452
- ), d(
2453
- n,
2454
- "width",
2455
- /*w*/
2456
- t[4]
2457
- ), d(
2458
- n,
2459
- "height",
2460
- /*h*/
2461
- t[5]
2462
- ), d(r, "class", "a9s-inner"), d(
2463
- r,
2464
- "style",
2465
- /*computedStyle*/
2466
- t[1]
2467
- ), d(
2468
- r,
2469
- "x",
2470
- /*x*/
2471
- t[2]
2472
- ), d(
2473
- r,
2474
- "y",
2475
- /*y*/
2476
- t[3]
2477
- ), d(
2478
- r,
2479
- "width",
2480
- /*w*/
2481
- t[4]
2482
- ), d(
2483
- r,
2484
- "height",
2485
- /*h*/
2486
- t[5]
2487
- ), d(e, "data-id", i = /*annotation*/
2488
- t[0].id);
2489
- },
2490
- m(a, s) {
2491
- O(a, e, s), ct(e, n), ct(e, r);
2492
- },
2493
- p(a, [s]) {
2494
- s & /*computedStyle*/
2495
- 2 && o !== (o = /*computedStyle*/
2496
- a[1] ? "display:none;" : void 0) && d(n, "style", o), s & /*computedStyle*/
2497
- 2 && d(
2498
- r,
2499
- "style",
2500
- /*computedStyle*/
2501
- a[1]
2502
- ), s & /*annotation*/
2503
- 1 && i !== (i = /*annotation*/
2504
- a[0].id) && d(e, "data-id", i);
2505
- },
2506
- i: k,
2507
- o: k,
2508
- d(a) {
2509
- a && S(e);
2510
- }
2511
- };
2512
- }
2513
- function Xo(t, e, n) {
2514
- let o, { annotation: r } = e, { geom: i } = e, { style: a = void 0 } = e;
2515
- const { x: s, y: l, w: c, h } = i;
2516
- return t.$$set = (u) => {
2517
- "annotation" in u && n(0, r = u.annotation), "geom" in u && n(6, i = u.geom), "style" in u && n(7, a = u.style);
2518
- }, t.$$.update = () => {
2519
- t.$$.dirty & /*annotation, style*/
2520
- 129 && n(1, o = Vt(r, a));
2521
- }, [r, o, s, l, c, h, i, a];
2522
- }
2523
- class Po extends et {
2524
- constructor(e) {
2525
- super(), tt(this, e, Xo, Bo, q, { annotation: 0, geom: 6, style: 7 });
2526
- }
2527
- }
2528
- const Ro = (t) => ({
2529
- elementToImage: (e, n) => {
2530
- const o = t.createSVGPoint();
2531
- o.x = e, o.y = n;
2532
- const { x: r, y: i } = o.matrixTransform(t.getCTM().inverse());
2533
- return [r, i];
2534
- }
2535
- }), _o = 250, Io = (t, e) => {
2536
- const n = Mt();
2537
- let o;
2538
- return { onPointerDown: () => o = performance.now(), onPointerUp: (r) => {
2539
- if (performance.now() - o < _o) {
2540
- const { x: i, y: a } = No(r, t), s = e.getAt(i, a);
2541
- s ? n("click", { originalEvent: r, annotation: s }) : n("click", { originalEvent: r });
2542
- }
2543
- } };
2544
- }, No = (t, e) => {
2545
- const n = e.createSVGPoint(), o = e.getBoundingClientRect(), r = t.clientX - o.x, i = t.clientY - o.y, { left: a, top: s } = e.getBoundingClientRect();
2546
- return n.x = r + a, n.y = i + s, n.matrixTransform(e.getScreenCTM().inverse());
2547
- };
2548
- function Ae(t, e, n) {
2549
- const o = t.slice();
2550
- return o[28] = e[n], o;
2551
- }
2552
- function Me(t, e, n) {
2553
- const o = t.slice();
2554
- return o[31] = e[n], o;
2555
- }
2556
- function Jt(t) {
2557
- const e = t.slice(), n = (
2558
- /*annotation*/
2559
- e[31].target.selector
2560
- );
2561
- return e[34] = n, e;
2562
- }
2563
- function Se(t) {
2564
- let e = (
2565
- /*annotation*/
2566
- t[31].id
2567
- ), n, o, r = Le(t);
2568
- return {
2569
- c() {
2570
- r.c(), n = at();
2571
- },
2572
- m(i, a) {
2573
- r.m(i, a), O(i, n, a), o = !0;
2574
- },
2575
- p(i, a) {
2576
- a[0] & /*$store*/
2577
- 4096 && q(e, e = /*annotation*/
2578
- i[31].id) ? (ot(), N(r, 1, 1, k), rt(), r = Le(i), r.c(), I(r, 1), r.m(n.parentNode, n)) : r.p(i, a);
2579
- },
2580
- i(i) {
2581
- o || (I(r), o = !0);
2582
- },
2583
- o(i) {
2584
- N(r), o = !1;
2585
- },
2586
- d(i) {
2587
- i && S(n), r.d(i);
2588
- }
2589
- };
2590
- }
2591
- function Do(t) {
2592
- let e, n;
2593
- return e = new Yo({
2594
- props: {
2595
- annotation: (
2596
- /*annotation*/
2597
- t[31]
2598
- ),
2599
- geom: (
2600
- /*selector*/
2601
- t[34].geometry
2602
- ),
2603
- style: (
2604
- /*style*/
2605
- t[1]
2606
- )
2607
- }
2608
- }), {
2609
- c() {
2610
- ft(e.$$.fragment);
2611
- },
2612
- m(o, r) {
2613
- dt(e, o, r), n = !0;
2614
- },
2615
- p(o, r) {
2616
- const i = {};
2617
- r[0] & /*$store*/
2618
- 4096 && (i.annotation = /*annotation*/
2619
- o[31]), r[0] & /*$store*/
2620
- 4096 && (i.geom = /*selector*/
2621
- o[34].geometry), r[0] & /*style*/
2622
- 2 && (i.style = /*style*/
2623
- o[1]), e.$set(i);
2624
- },
2625
- i(o) {
2626
- n || (I(e.$$.fragment, o), n = !0);
2627
- },
2628
- o(o) {
2629
- N(e.$$.fragment, o), n = !1;
2630
- },
2631
- d(o) {
2632
- ut(e, o);
2633
- }
2634
- };
2635
- }
2636
- function ko(t) {
2637
- let e, n;
2638
- return e = new Po({
2639
- props: {
2640
- annotation: (
2641
- /*annotation*/
2642
- t[31]
2643
- ),
2644
- geom: (
2645
- /*selector*/
2646
- t[34].geometry
2647
- ),
2648
- style: (
2649
- /*style*/
2650
- t[1]
2651
- )
2652
- }
2653
- }), {
2654
- c() {
2655
- ft(e.$$.fragment);
2656
- },
2657
- m(o, r) {
2658
- dt(e, o, r), n = !0;
2659
- },
2660
- p(o, r) {
2661
- const i = {};
2662
- r[0] & /*$store*/
2663
- 4096 && (i.annotation = /*annotation*/
2664
- o[31]), r[0] & /*$store*/
2665
- 4096 && (i.geom = /*selector*/
2666
- o[34].geometry), r[0] & /*style*/
2667
- 2 && (i.style = /*style*/
2668
- o[1]), e.$set(i);
2669
- },
2670
- i(o) {
2671
- n || (I(e.$$.fragment, o), n = !0);
2672
- },
2673
- o(o) {
2674
- N(e.$$.fragment, o), n = !1;
2675
- },
2676
- d(o) {
2677
- ut(e, o);
2678
- }
2679
- };
2680
- }
2681
- function Go(t) {
2682
- let e, n;
2683
- return e = new Mo({
2684
- props: {
2685
- annotation: (
2686
- /*annotation*/
2687
- t[31]
2688
- ),
2689
- geom: (
2690
- /*selector*/
2691
- t[34].geometry
2692
- ),
2693
- style: (
2694
- /*style*/
2695
- t[1]
2696
- )
2697
- }
2698
- }), {
2699
- c() {
2700
- ft(e.$$.fragment);
2701
- },
2702
- m(o, r) {
2703
- dt(e, o, r), n = !0;
2704
- },
2705
- p(o, r) {
2706
- const i = {};
2707
- r[0] & /*$store*/
2708
- 4096 && (i.annotation = /*annotation*/
2709
- o[31]), r[0] & /*$store*/
2710
- 4096 && (i.geom = /*selector*/
2711
- o[34].geometry), r[0] & /*style*/
2712
- 2 && (i.style = /*style*/
2713
- o[1]), e.$set(i);
2714
- },
2715
- i(o) {
2716
- n || (I(e.$$.fragment, o), n = !0);
2717
- },
2718
- o(o) {
2719
- N(e.$$.fragment, o), n = !1;
2720
- },
2721
- d(o) {
2722
- ut(e, o);
2723
- }
2724
- };
2725
- }
2726
- function Le(t) {
2727
- let e, n, o, r;
2728
- const i = [Go, ko, Do], a = [];
2729
- function s(l, c) {
2730
- return (
2731
- /*selector*/
2732
- l[34].type === F.ELLIPSE ? 0 : (
2733
- /*selector*/
2734
- l[34].type === F.RECTANGLE ? 1 : (
2735
- /*selector*/
2736
- l[34].type === F.POLYGON ? 2 : -1
2737
- )
2738
- )
2739
- );
2740
- }
2741
- return ~(e = s(t)) && (n = a[e] = i[e](t)), {
2742
- c() {
2743
- n && n.c(), o = at();
2744
- },
2745
- m(l, c) {
2746
- ~e && a[e].m(l, c), O(l, o, c), r = !0;
2747
- },
2748
- p(l, c) {
2749
- let h = e;
2750
- e = s(l), e === h ? ~e && a[e].p(l, c) : (n && (ot(), N(a[h], 1, 1, () => {
2751
- a[h] = null;
2752
- }), rt()), ~e ? (n = a[e], n ? n.p(l, c) : (n = a[e] = i[e](l), n.c()), I(n, 1), n.m(o.parentNode, o)) : n = null);
2753
- },
2754
- i(l) {
2755
- r || (I(n), r = !0);
2756
- },
2757
- o(l) {
2758
- N(n), r = !1;
2759
- },
2760
- d(l) {
2761
- ~e && a[e].d(l), l && S(o);
2762
- }
2763
- };
2764
- }
2765
- function Oe(t) {
2766
- let e = !/*isEditable*/
2767
- t[7](
2768
- /*annotation*/
2769
- t[31]
2770
- ), n, o, r = e && Se(Jt(t));
2771
- return {
2772
- c() {
2773
- r && r.c(), n = at();
2774
- },
2775
- m(i, a) {
2776
- r && r.m(i, a), O(i, n, a), o = !0;
2777
- },
2778
- p(i, a) {
2779
- a[0] & /*isEditable, $store*/
2780
- 4224 && (e = !/*isEditable*/
2781
- i[7](
2782
- /*annotation*/
2783
- i[31]
2784
- )), e ? r ? (r.p(Jt(i), a), a[0] & /*isEditable, $store*/
2785
- 4224 && I(r, 1)) : (r = Se(Jt(i)), r.c(), I(r, 1), r.m(n.parentNode, n)) : r && (ot(), N(r, 1, 1, () => {
2786
- r = null;
2787
- }), rt());
2788
- },
2789
- i(i) {
2790
- o || (I(r), o = !0);
2791
- },
2792
- o(i) {
2793
- N(r), o = !1;
2794
- },
2795
- d(i) {
2796
- r && r.d(i), i && S(n);
2797
- }
2798
- };
2799
- }
2800
- function Te(t) {
2801
- let e, n, o, r;
2802
- const i = [Fo, Uo], a = [];
2803
- function s(l, c) {
2804
- return (
2805
- /*editableAnnotations*/
2806
- l[6] ? 0 : (
2807
- /*tool*/
2808
- l[2] && /*drawingEnabled*/
2809
- l[0] ? 1 : -1
2810
- )
2811
- );
2812
- }
2813
- return ~(e = s(t)) && (n = a[e] = i[e](t)), {
2814
- c() {
2815
- n && n.c(), o = at();
2816
- },
2817
- m(l, c) {
2818
- ~e && a[e].m(l, c), O(l, o, c), r = !0;
2819
- },
2820
- p(l, c) {
2821
- let h = e;
2822
- e = s(l), e === h ? ~e && a[e].p(l, c) : (n && (ot(), N(a[h], 1, 1, () => {
2823
- a[h] = null;
2824
- }), rt()), ~e ? (n = a[e], n ? n.p(l, c) : (n = a[e] = i[e](l), n.c()), I(n, 1), n.m(o.parentNode, o)) : n = null);
2825
- },
2826
- i(l) {
2827
- r || (I(n), r = !0);
2828
- },
2829
- o(l) {
2830
- N(n), r = !1;
2831
- },
2832
- d(l) {
2833
- ~e && a[e].d(l), l && S(o);
2834
- }
2835
- };
2836
- }
2837
- function Uo(t) {
2838
- let e = (
2839
- /*tool*/
2840
- t[2]
2841
- ), n, o, r = Ye(t);
2842
- return {
2843
- c() {
2844
- r.c(), n = at();
2845
- },
2846
- m(i, a) {
2847
- r.m(i, a), O(i, n, a), o = !0;
2848
- },
2849
- p(i, a) {
2850
- a[0] & /*tool*/
2851
- 4 && q(e, e = /*tool*/
2852
- i[2]) ? (ot(), N(r, 1, 1, k), rt(), r = Ye(i), r.c(), I(r, 1), r.m(n.parentNode, n)) : r.p(i, a);
2853
- },
2854
- i(i) {
2855
- o || (I(r), o = !0);
2856
- },
2857
- o(i) {
2858
- N(r), o = !1;
2859
- },
2860
- d(i) {
2861
- i && S(n), r.d(i);
2862
- }
2863
- };
2864
- }
2865
- function Fo(t) {
2866
- let e, n, o = (
2867
- /*editableAnnotations*/
2868
- t[6]
2869
- ), r = [];
2870
- for (let a = 0; a < o.length; a += 1)
2871
- r[a] = Xe(Ae(t, o, a));
2872
- const i = (a) => N(r[a], 1, 1, () => {
2873
- r[a] = null;
2874
- });
2875
- return {
2876
- c() {
2877
- for (let a = 0; a < r.length; a += 1)
2878
- r[a].c();
2879
- e = at();
2880
- },
2881
- m(a, s) {
2882
- for (let l = 0; l < r.length; l += 1)
2883
- r[l] && r[l].m(a, s);
2884
- O(a, e, s), n = !0;
2885
- },
2886
- p(a, s) {
2887
- if (s[0] & /*editableAnnotations, drawingEl, style, transform, $scale, onChangeSelected*/
2888
- 140370) {
2889
- o = /*editableAnnotations*/
2890
- a[6];
2891
- let l;
2892
- for (l = 0; l < o.length; l += 1) {
2893
- const c = Ae(a, o, l);
2894
- r[l] ? (r[l].p(c, s), I(r[l], 1)) : (r[l] = Xe(c), r[l].c(), I(r[l], 1), r[l].m(e.parentNode, e));
2895
- }
2896
- for (ot(), l = o.length; l < r.length; l += 1)
2897
- i(l);
2898
- rt();
2899
- }
2900
- },
2901
- i(a) {
2902
- if (!n) {
2903
- for (let s = 0; s < o.length; s += 1)
2904
- I(r[s]);
2905
- n = !0;
2906
- }
2907
- },
2908
- o(a) {
2909
- r = r.filter(Boolean);
2910
- for (let s = 0; s < r.length; s += 1)
2911
- N(r[s]);
2912
- n = !1;
2913
- },
2914
- d(a) {
2915
- ee(r, a), a && S(e);
2916
- }
2917
- };
2918
- }
2919
- function Ye(t) {
2920
- let e, n;
2921
- return e = new uo({
2922
- props: {
2923
- target: (
2924
- /*drawingEl*/
2925
- t[4]
2926
- ),
2927
- tool: (
2928
- /*tool*/
2929
- t[2]
2930
- ),
2931
- drawingMode: (
2932
- /*drawingMode*/
2933
- t[11]
2934
- ),
2935
- transform: (
2936
- /*transform*/
2937
- t[10]
2938
- ),
2939
- viewportScale: (
2940
- /*$scale*/
2941
- t[13]
2942
- )
2943
- }
2944
- }), e.$on(
2945
- "create",
2946
- /*onSelectionCreated*/
2947
- t[16]
2948
- ), {
2949
- c() {
2950
- ft(e.$$.fragment);
2951
- },
2952
- m(o, r) {
2953
- dt(e, o, r), n = !0;
2954
- },
2955
- p(o, r) {
2956
- const i = {};
2957
- r[0] & /*drawingEl*/
2958
- 16 && (i.target = /*drawingEl*/
2959
- o[4]), r[0] & /*tool*/
2960
- 4 && (i.tool = /*tool*/
2961
- o[2]), r[0] & /*drawingMode*/
2962
- 2048 && (i.drawingMode = /*drawingMode*/
2963
- o[11]), r[0] & /*transform*/
2964
- 1024 && (i.transform = /*transform*/
2965
- o[10]), r[0] & /*$scale*/
2966
- 8192 && (i.viewportScale = /*$scale*/
2967
- o[13]), e.$set(i);
2968
- },
2969
- i(o) {
2970
- n || (I(e.$$.fragment, o), n = !0);
2971
- },
2972
- o(o) {
2973
- N(e.$$.fragment, o), n = !1;
2974
- },
2975
- d(o) {
2976
- ut(e, o);
2977
- }
2978
- };
2979
- }
2980
- function Be(t) {
2981
- let e, n;
2982
- return e = new lo({
2983
- props: {
2984
- target: (
2985
- /*drawingEl*/
2986
- t[4]
2987
- ),
2988
- editor: we(
2989
- /*editable*/
2990
- t[28].target.selector
2991
- ),
2992
- annotation: (
2993
- /*editable*/
2994
- t[28]
2995
- ),
2996
- style: (
2997
- /*style*/
2998
- t[1]
2999
- ),
3000
- transform: (
3001
- /*transform*/
3002
- t[10]
3003
- ),
3004
- viewportScale: (
3005
- /*$scale*/
3006
- t[13]
3007
- )
3008
- }
3009
- }), e.$on("change", function() {
3010
- V(
3011
- /*onChangeSelected*/
3012
- t[17](
3013
- /*editable*/
3014
- t[28]
3015
- )
3016
- ) && t[17](
3017
- /*editable*/
3018
- t[28]
3019
- ).apply(this, arguments);
3020
- }), {
3021
- c() {
3022
- ft(e.$$.fragment);
3023
- },
3024
- m(o, r) {
3025
- dt(e, o, r), n = !0;
3026
- },
3027
- p(o, r) {
3028
- t = o;
3029
- const i = {};
3030
- r[0] & /*drawingEl*/
3031
- 16 && (i.target = /*drawingEl*/
3032
- t[4]), r[0] & /*editableAnnotations*/
3033
- 64 && (i.editor = we(
3034
- /*editable*/
3035
- t[28].target.selector
3036
- )), r[0] & /*editableAnnotations*/
3037
- 64 && (i.annotation = /*editable*/
3038
- t[28]), r[0] & /*style*/
3039
- 2 && (i.style = /*style*/
3040
- t[1]), r[0] & /*transform*/
3041
- 1024 && (i.transform = /*transform*/
3042
- t[10]), r[0] & /*$scale*/
3043
- 8192 && (i.viewportScale = /*$scale*/
3044
- t[13]), e.$set(i);
3045
- },
3046
- i(o) {
3047
- n || (I(e.$$.fragment, o), n = !0);
3048
- },
3049
- o(o) {
3050
- N(e.$$.fragment, o), n = !1;
3051
- },
3052
- d(o) {
3053
- ut(e, o);
3054
- }
3055
- };
3056
- }
3057
- function Xe(t) {
3058
- let e = (
3059
- /*editable*/
3060
- t[28].id
3061
- ), n, o, r = Be(t);
3062
- return {
3063
- c() {
3064
- r.c(), n = at();
3065
- },
3066
- m(i, a) {
3067
- r.m(i, a), O(i, n, a), o = !0;
3068
- },
3069
- p(i, a) {
3070
- a[0] & /*editableAnnotations*/
3071
- 64 && q(e, e = /*editable*/
3072
- i[28].id) ? (ot(), N(r, 1, 1, k), rt(), r = Be(i), r.c(), I(r, 1), r.m(n.parentNode, n)) : r.p(i, a);
3073
- },
3074
- i(i) {
3075
- o || (I(r), o = !0);
3076
- },
3077
- o(i) {
3078
- N(r), o = !1;
3079
- },
3080
- d(i) {
3081
- i && S(n), r.d(i);
3082
- }
3083
- };
3084
- }
3085
- function Vo(t) {
3086
- let e, n, o, r, i, a, s = (
3087
- /*$store*/
3088
- t[12]
3089
- ), l = [];
3090
- for (let u = 0; u < s.length; u += 1)
3091
- l[u] = Oe(Me(t, s, u));
3092
- const c = (u) => N(l[u], 1, 1, () => {
3093
- l[u] = null;
3094
- });
3095
- let h = (
3096
- /*drawingEl*/
3097
- t[4] && Te(t)
3098
- );
3099
- return {
3100
- c() {
3101
- e = R("svg"), n = R("g");
3102
- for (let u = 0; u < l.length; u += 1)
3103
- l[u].c();
3104
- o = R("g"), h && h.c(), d(o, "class", "drawing"), d(e, "class", "a9s-annotationlayer"), le(
3105
- e,
3106
- "drawing",
3107
- /*tool*/
3108
- t[2]
3109
- );
3110
- },
3111
- m(u, f) {
3112
- O(u, e, f), ct(e, n);
3113
- for (let p = 0; p < l.length; p += 1)
3114
- l[p] && l[p].m(n, null);
3115
- ct(e, o), h && h.m(o, null), t[24](o), t[25](e), r = !0, i || (a = [
3116
- C(e, "pointerup", function() {
3117
- V(
3118
- /*onPointerUp*/
3119
- t[8]
3120
- ) && t[8].apply(this, arguments);
3121
- }),
3122
- C(e, "pointerdown", function() {
3123
- V(
3124
- /*onPointerDown*/
3125
- t[9]
3126
- ) && t[9].apply(this, arguments);
3127
- })
3128
- ], i = !0);
3129
- },
3130
- p(u, f) {
3131
- if (t = u, f[0] & /*$store, style, isEditable*/
3132
- 4226) {
3133
- s = /*$store*/
3134
- t[12];
3135
- let p;
3136
- for (p = 0; p < s.length; p += 1) {
3137
- const g = Me(t, s, p);
3138
- l[p] ? (l[p].p(g, f), I(l[p], 1)) : (l[p] = Oe(g), l[p].c(), I(l[p], 1), l[p].m(n, null));
3139
- }
3140
- for (ot(), p = s.length; p < l.length; p += 1)
3141
- c(p);
3142
- rt();
3143
- }
3144
- t[4] ? h ? (h.p(t, f), f[0] & /*drawingEl*/
3145
- 16 && I(h, 1)) : (h = Te(t), h.c(), I(h, 1), h.m(o, null)) : h && (ot(), N(h, 1, 1, () => {
3146
- h = null;
3147
- }), rt()), (!r || f[0] & /*tool*/
3148
- 4) && le(
3149
- e,
3150
- "drawing",
3151
- /*tool*/
3152
- t[2]
3153
- );
3154
- },
3155
- i(u) {
3156
- if (!r) {
3157
- for (let f = 0; f < s.length; f += 1)
3158
- I(l[f]);
3159
- I(h), r = !0;
3160
- }
3161
- },
3162
- o(u) {
3163
- l = l.filter(Boolean);
3164
- for (let f = 0; f < l.length; f += 1)
3165
- N(l[f]);
3166
- N(h), r = !1;
3167
- },
3168
- d(u) {
3169
- u && S(e), ee(l, u), h && h.d(), t[24](null), t[25](null), i = !1, it(a);
3170
- }
3171
- };
3172
- }
3173
- function Ho(t, e, n) {
3174
- let o, r, i, a, s, l, c, h, u = k, f = () => (u(), u = _e(A, (Y) => n(13, h = Y)), A);
3175
- t.$$.on_destroy.push(() => u());
3176
- let { drawingEnabled: p } = e, { image: g } = e, { preferredDrawingMode: m } = e, { state: b } = e, { style: E = void 0 } = e, { tool: T, opts: X } = je("rectangle"), { tool: x = T, opts: _ = X } = e, { user: y } = e, $, w, A;
3177
- Xt(() => f(n(5, A = mo(g, w))));
3178
- const { selection: L, store: P } = b;
3179
- se(t, L, (Y) => n(23, l = Y)), se(t, P, (Y) => n(12, c = Y));
3180
- let J = null, U = null;
3181
- const nt = (Y) => {
3182
- P.unobserve(J);
3183
- const z = Y.filter(({ editable: H }) => H).map(({ id: H }) => H);
3184
- z.length > 0 ? (n(6, U = z.map((H) => P.getAnnotation(H))), J = (H) => {
3185
- const { updated: D } = H.changes;
3186
- n(6, U = D.map((st) => st.newValue));
3187
- }, P.observe(J, { annotations: z })) : n(6, U = null);
3188
- }, gt = (Y) => {
3189
- const z = Ue(), H = {
3190
- id: z,
3191
- bodies: [],
3192
- target: {
3193
- annotation: z,
3194
- selector: Y.detail,
3195
- creator: y,
3196
- created: /* @__PURE__ */ new Date()
3197
- }
3198
- };
3199
- P.addAnnotation(H), L.setSelected(H.id);
3200
- }, mt = (Y) => (z) => {
3201
- var H;
3202
- const { target: D } = Y, st = 10 * 60 * 1e3, lt = ((H = D.creator) == null ? void 0 : H.id) !== y.id || !D.created || (/* @__PURE__ */ new Date()).getTime() - D.created.getTime() > st;
3203
- P.updateTarget({
3204
- ...D,
3205
- selector: z.detail,
3206
- created: lt ? D.created : /* @__PURE__ */ new Date(),
3207
- updated: lt ? /* @__PURE__ */ new Date() : null,
3208
- updatedBy: lt ? y : null
3209
- });
3210
- };
3211
- function St(Y) {
3212
- At[Y ? "unshift" : "push"](() => {
3213
- $ = Y, n(4, $);
3214
- });
3215
- }
3216
- function W(Y) {
3217
- At[Y ? "unshift" : "push"](() => {
3218
- w = Y, n(3, w);
3219
- });
3220
- }
3221
- return t.$$set = (Y) => {
3222
- "drawingEnabled" in Y && n(0, p = Y.drawingEnabled), "image" in Y && n(18, g = Y.image), "preferredDrawingMode" in Y && n(19, m = Y.preferredDrawingMode), "state" in Y && n(20, b = Y.state), "style" in Y && n(1, E = Y.style), "tool" in Y && n(2, x = Y.tool), "opts" in Y && n(21, _ = Y.opts), "user" in Y && n(22, y = Y.user);
3223
- }, t.$$.update = () => {
3224
- t.$$.dirty[0] & /*opts, preferredDrawingMode*/
3225
- 2621440 && n(11, o = (_ == null ? void 0 : _.drawingMode) || m), t.$$.dirty[0] & /*svgEl*/
3226
- 8 && n(10, r = Ro(w)), t.$$.dirty[0] & /*svgEl*/
3227
- 8 && n(9, { onPointerDown: i, onPointerUp: a } = Io(w, P), i, (n(8, a), n(3, w))), t.$$.dirty[0] & /*$selection*/
3228
- 8388608 && n(7, s = (Y) => l.selected.find((z) => z.id === Y.id && z.editable)), t.$$.dirty[0] & /*$selection*/
3229
- 8388608 && nt(l.selected);
3230
- }, [
3231
- p,
3232
- E,
3233
- x,
3234
- w,
3235
- $,
3236
- A,
3237
- U,
3238
- s,
3239
- a,
3240
- i,
3241
- r,
3242
- o,
3243
- c,
3244
- h,
3245
- L,
3246
- P,
3247
- gt,
3248
- mt,
3249
- g,
3250
- m,
3251
- b,
3252
- _,
3253
- y,
3254
- l,
3255
- St,
3256
- W
3257
- ];
3258
- }
3259
- class jo extends et {
3260
- constructor(e) {
3261
- super(), tt(
3262
- this,
3263
- e,
3264
- Ho,
3265
- Vo,
3266
- q,
3267
- {
3268
- drawingEnabled: 0,
3269
- image: 18,
3270
- preferredDrawingMode: 19,
3271
- state: 20,
3272
- style: 1,
3273
- tool: 2,
3274
- opts: 21,
3275
- user: 22
3276
- },
3277
- null,
3278
- [-1, -1]
3279
- );
3280
- }
3281
- }
3282
- function Co(t, e, n, o, r) {
3283
- Ce(t, e, n || 0, o || t.length - 1, r || zo);
3284
- }
3285
- function Ce(t, e, n, o, r) {
3286
- for (; o > n; ) {
3287
- if (o - n > 600) {
3288
- var i = o - n + 1, a = e - n + 1, s = Math.log(i), l = 0.5 * Math.exp(2 * s / 3), c = 0.5 * Math.sqrt(s * l * (i - l) / i) * (a - i / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(e - a * l / i + c)), u = Math.min(o, Math.floor(e + (i - a) * l / i + c));
3289
- Ce(t, e, h, u, r);
3290
- }
3291
- var f = t[e], p = n, g = o;
3292
- for (Lt(t, n, e), r(t[o], f) > 0 && Lt(t, n, o); p < g; ) {
3293
- for (Lt(t, p, g), p++, g--; r(t[p], f) < 0; )
3294
- p++;
3295
- for (; r(t[g], f) > 0; )
3296
- g--;
3297
- }
3298
- r(t[n], f) === 0 ? Lt(t, n, g) : (g++, Lt(t, g, o)), g <= e && (n = g + 1), e <= g && (o = g - 1);
3299
- }
3300
- }
3301
- function Lt(t, e, n) {
3302
- var o = t[e];
3303
- t[e] = t[n], t[n] = o;
3304
- }
3305
- function zo(t, e) {
3306
- return t < e ? -1 : t > e ? 1 : 0;
3307
- }
3308
- class Wo {
3309
- constructor(e = 9) {
3310
- this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
3311
- }
3312
- all() {
3313
- return this._all(this.data, []);
3314
- }
3315
- search(e) {
3316
- let n = this.data;
3317
- const o = [];
3318
- if (!kt(e, n))
3319
- return o;
3320
- const r = this.toBBox, i = [];
3321
- for (; n; ) {
3322
- for (let a = 0; a < n.children.length; a++) {
3323
- const s = n.children[a], l = n.leaf ? r(s) : s;
3324
- kt(e, l) && (n.leaf ? o.push(s) : Zt(e, l) ? this._all(s, o) : i.push(s));
3325
- }
3326
- n = i.pop();
3327
- }
3328
- return o;
3329
- }
3330
- collides(e) {
3331
- let n = this.data;
3332
- if (!kt(e, n))
3333
- return !1;
3334
- const o = [];
3335
- for (; n; ) {
3336
- for (let r = 0; r < n.children.length; r++) {
3337
- const i = n.children[r], a = n.leaf ? this.toBBox(i) : i;
3338
- if (kt(e, a)) {
3339
- if (n.leaf || Zt(e, a))
3340
- return !0;
3341
- o.push(i);
3342
- }
3343
- }
3344
- n = o.pop();
3345
- }
3346
- return !1;
3347
- }
3348
- load(e) {
3349
- if (!(e && e.length))
3350
- return this;
3351
- if (e.length < this._minEntries) {
3352
- for (let o = 0; o < e.length; o++)
3353
- this.insert(e[o]);
3354
- return this;
3355
- }
3356
- let n = this._build(e.slice(), 0, e.length - 1, 0);
3357
- if (!this.data.children.length)
3358
- this.data = n;
3359
- else if (this.data.height === n.height)
3360
- this._splitRoot(this.data, n);
3361
- else {
3362
- if (this.data.height < n.height) {
3363
- const o = this.data;
3364
- this.data = n, n = o;
3365
- }
3366
- this._insert(n, this.data.height - n.height - 1, !0);
3367
- }
3368
- return this;
3369
- }
3370
- insert(e) {
3371
- return e && this._insert(e, this.data.height - 1), this;
3372
- }
3373
- clear() {
3374
- return this.data = bt([]), this;
3375
- }
3376
- remove(e, n) {
3377
- if (!e)
3378
- return this;
3379
- let o = this.data;
3380
- const r = this.toBBox(e), i = [], a = [];
3381
- let s, l, c;
3382
- for (; o || i.length; ) {
3383
- if (o || (o = i.pop(), l = i[i.length - 1], s = a.pop(), c = !0), o.leaf) {
3384
- const h = qo(e, o.children, n);
3385
- if (h !== -1)
3386
- return o.children.splice(h, 1), i.push(o), this._condense(i), this;
3387
- }
3388
- !c && !o.leaf && Zt(o, r) ? (i.push(o), a.push(s), s = 0, l = o, o = o.children[0]) : l ? (s++, o = l.children[s], c = !1) : o = null;
3389
- }
3390
- return this;
3391
- }
3392
- toBBox(e) {
3393
- return e;
3394
- }
3395
- compareMinX(e, n) {
3396
- return e.minX - n.minX;
3397
- }
3398
- compareMinY(e, n) {
3399
- return e.minY - n.minY;
3400
- }
3401
- toJSON() {
3402
- return this.data;
3403
- }
3404
- fromJSON(e) {
3405
- return this.data = e, this;
3406
- }
3407
- _all(e, n) {
3408
- const o = [];
3409
- for (; e; )
3410
- e.leaf ? n.push(...e.children) : o.push(...e.children), e = o.pop();
3411
- return n;
3412
- }
3413
- _build(e, n, o, r) {
3414
- const i = o - n + 1;
3415
- let a = this._maxEntries, s;
3416
- if (i <= a)
3417
- return s = bt(e.slice(n, o + 1)), $t(s, this.toBBox), s;
3418
- r || (r = Math.ceil(Math.log(i) / Math.log(a)), a = Math.ceil(i / Math.pow(a, r - 1))), s = bt([]), s.leaf = !1, s.height = r;
3419
- const l = Math.ceil(i / a), c = l * Math.ceil(Math.sqrt(a));
3420
- Pe(e, n, o, c, this.compareMinX);
3421
- for (let h = n; h <= o; h += c) {
3422
- const u = Math.min(h + c - 1, o);
3423
- Pe(e, h, u, l, this.compareMinY);
3424
- for (let f = h; f <= u; f += l) {
3425
- const p = Math.min(f + l - 1, u);
3426
- s.children.push(this._build(e, f, p, r - 1));
3427
- }
3428
- }
3429
- return $t(s, this.toBBox), s;
3430
- }
3431
- _chooseSubtree(e, n, o, r) {
3432
- for (; r.push(n), !(n.leaf || r.length - 1 === o); ) {
3433
- let i = 1 / 0, a = 1 / 0, s;
3434
- for (let l = 0; l < n.children.length; l++) {
3435
- const c = n.children[l], h = Qt(c), u = Zo(e, c) - h;
3436
- u < a ? (a = u, i = h < i ? h : i, s = c) : u === a && h < i && (i = h, s = c);
3437
- }
3438
- n = s || n.children[0];
3439
- }
3440
- return n;
3441
- }
3442
- _insert(e, n, o) {
3443
- const r = o ? e : this.toBBox(e), i = [], a = this._chooseSubtree(r, this.data, n, i);
3444
- for (a.children.push(e), Tt(a, r); n >= 0 && i[n].children.length > this._maxEntries; )
3445
- this._split(i, n), n--;
3446
- this._adjustParentBBoxes(r, i, n);
3447
- }
3448
- // split overflowed node into two
3449
- _split(e, n) {
3450
- const o = e[n], r = o.children.length, i = this._minEntries;
3451
- this._chooseSplitAxis(o, i, r);
3452
- const a = this._chooseSplitIndex(o, i, r), s = bt(o.children.splice(a, o.children.length - a));
3453
- s.height = o.height, s.leaf = o.leaf, $t(o, this.toBBox), $t(s, this.toBBox), n ? e[n - 1].children.push(s) : this._splitRoot(o, s);
3454
- }
3455
- _splitRoot(e, n) {
3456
- this.data = bt([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, $t(this.data, this.toBBox);
3457
- }
3458
- _chooseSplitIndex(e, n, o) {
3459
- let r, i = 1 / 0, a = 1 / 0;
3460
- for (let s = n; s <= o - n; s++) {
3461
- const l = Ot(e, 0, s, this.toBBox), c = Ot(e, s, o, this.toBBox), h = Ko(l, c), u = Qt(l) + Qt(c);
3462
- h < i ? (i = h, r = s, a = u < a ? u : a) : h === i && u < a && (a = u, r = s);
3463
- }
3464
- return r || o - n;
3465
- }
3466
- // sorts node children by the best axis for split
3467
- _chooseSplitAxis(e, n, o) {
3468
- const r = e.leaf ? this.compareMinX : Jo, i = e.leaf ? this.compareMinY : Qo, a = this._allDistMargin(e, n, o, r), s = this._allDistMargin(e, n, o, i);
3469
- a < s && e.children.sort(r);
3470
- }
3471
- // total margin of all possible split distributions where each node is at least m full
3472
- _allDistMargin(e, n, o, r) {
3473
- e.children.sort(r);
3474
- const i = this.toBBox, a = Ot(e, 0, n, i), s = Ot(e, o - n, o, i);
3475
- let l = Dt(a) + Dt(s);
3476
- for (let c = n; c < o - n; c++) {
3477
- const h = e.children[c];
3478
- Tt(a, e.leaf ? i(h) : h), l += Dt(a);
3479
- }
3480
- for (let c = o - n - 1; c >= n; c--) {
3481
- const h = e.children[c];
3482
- Tt(s, e.leaf ? i(h) : h), l += Dt(s);
3483
- }
3484
- return l;
3485
- }
3486
- _adjustParentBBoxes(e, n, o) {
3487
- for (let r = o; r >= 0; r--)
3488
- Tt(n[r], e);
3489
- }
3490
- _condense(e) {
3491
- for (let n = e.length - 1, o; n >= 0; n--)
3492
- e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : $t(e[n], this.toBBox);
3493
- }
3494
- }
3495
- function qo(t, e, n) {
3496
- if (!n)
3497
- return e.indexOf(t);
3498
- for (let o = 0; o < e.length; o++)
3499
- if (n(t, e[o]))
3500
- return o;
3501
- return -1;
3502
- }
3503
- function $t(t, e) {
3504
- Ot(t, 0, t.children.length, e, t);
3505
- }
3506
- function Ot(t, e, n, o, r) {
3507
- r || (r = bt(null)), r.minX = 1 / 0, r.minY = 1 / 0, r.maxX = -1 / 0, r.maxY = -1 / 0;
3508
- for (let i = e; i < n; i++) {
3509
- const a = t.children[i];
3510
- Tt(r, t.leaf ? o(a) : a);
3511
- }
3512
- return r;
3513
- }
3514
- function Tt(t, e) {
3515
- return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
3516
- }
3517
- function Jo(t, e) {
3518
- return t.minX - e.minX;
3519
- }
3520
- function Qo(t, e) {
3521
- return t.minY - e.minY;
3522
- }
3523
- function Qt(t) {
3524
- return (t.maxX - t.minX) * (t.maxY - t.minY);
3525
- }
3526
- function Dt(t) {
3527
- return t.maxX - t.minX + (t.maxY - t.minY);
3528
- }
3529
- function Zo(t, e) {
3530
- return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
3531
- }
3532
- function Ko(t, e) {
3533
- const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), r = Math.min(t.maxX, e.maxX), i = Math.min(t.maxY, e.maxY);
3534
- return Math.max(0, r - n) * Math.max(0, i - o);
3535
- }
3536
- function Zt(t, e) {
3537
- return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
3538
- }
3539
- function kt(t, e) {
3540
- return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
3541
- }
3542
- function bt(t) {
3543
- return {
3544
- children: t,
3545
- height: 1,
3546
- leaf: !0,
3547
- minX: 1 / 0,
3548
- minY: 1 / 0,
3549
- maxX: -1 / 0,
3550
- maxY: -1 / 0
3551
- };
3552
- }
3553
- function Pe(t, e, n, o, r) {
3554
- const i = [e, n];
3555
- for (; i.length; ) {
3556
- if (n = i.pop(), e = i.pop(), n - e <= o)
3557
- continue;
3558
- const a = e + Math.ceil((n - e) / o / 2) * o;
3559
- Co(t, a, e, n, r), i.push(e, a, a, n);
3560
- }
3561
- }
3562
- const tr = () => {
3563
- const t = new Wo(), e = /* @__PURE__ */ new Map(), n = () => [...e.values()], o = () => {
3564
- t.clear(), e.clear();
3565
- }, r = (a) => {
3566
- const { minX: s, minY: l, maxX: c, maxY: h } = a.selector.geometry.bounds, u = { minX: s, minY: l, maxX: c, maxY: h, target: a };
3567
- t.insert(u), e.set(a.annotation, u);
3568
- }, i = (a) => {
3569
- const s = e.get(a.annotation);
3570
- t.remove(s), e.delete(a.annotation);
3571
- };
3572
- return {
3573
- all: n,
3574
- clear: o,
3575
- getAt: (a, s) => {
3576
- const l = t.search({
3577
- minX: a,
3578
- minY: s,
3579
- maxX: a,
3580
- maxY: s
3581
- }).map((c) => c.target).filter((c) => c.selector.type === F.RECTANGLE || sn(c.selector, a, s));
3582
- if (l.length > 0)
3583
- return l.sort((c, h) => de(c.selector) - de(h.selector)), l[0];
3584
- },
3585
- getIntersecting: (a, s, l, c) => t.search({
3586
- minX: a,
3587
- minY: s,
3588
- maxX: a + l,
3589
- maxY: s + c
3590
- }).map((h) => h.target),
3591
- insert: r,
3592
- remove: i,
3593
- set: (a, s = !0) => {
3594
- s && o();
3595
- const l = a.map((c) => {
3596
- const { minX: h, minY: u, maxX: f, maxY: p } = c.selector.geometry.bounds;
3597
- return { minX: h, minY: u, maxX: f, maxY: p, target: c };
3598
- });
3599
- l.forEach((c) => e.set(c.target.annotation, c)), t.load(l);
3600
- },
3601
- size: () => t.all().length,
3602
- update: (a, s) => {
3603
- i(a), r(s);
3604
- }
3605
- };
3606
- }, er = (t) => {
3607
- const e = Pn(), n = tr(), o = An(e, t.pointerSelectAction), r = vn(e), i = _n();
3608
- return e.observe(({ changes: a }) => {
3609
- n.set(a.created.map((s) => s.target), !1), a.deleted.forEach((s) => n.remove(s.target)), a.updated.forEach(({ oldValue: s, newValue: l }) => n.update(s.target, l.target));
3610
- }), {
3611
- store: {
3612
- ...e,
3613
- getAt: (a, s) => {
3614
- const l = n.getAt(a, s);
3615
- return l ? e.getAnnotation(l.annotation) : void 0;
3616
- },
3617
- getIntersecting: (a, s, l, c) => n.getIntersecting(a, s, l, c).map((h) => e.getAnnotation(h.annotation))
3618
- },
3619
- selection: o,
3620
- hover: r,
3621
- viewport: i
3622
- };
3623
- }, nr = (t) => {
3624
- const e = er(t);
3625
- return {
3626
- ...e,
3627
- store: Rn(e.store)
3628
- };
3629
- }, or = (t) => {
3630
- let e, n;
3631
- if (t.nodeName === "CANVAS")
3632
- e = t, n = e.getContext("2d", { willReadFrequently: !0 });
3633
- else {
3634
- const r = t;
3635
- e = document.createElement("canvas"), e.width = r.width, e.height = r.height, n = e.getContext("2d", { willReadFrequently: !0 }), n.drawImage(r, 0, 0, r.width, r.height);
3636
- }
3637
- let o = 0;
3638
- for (let r = 1; r < 10; r++)
3639
- for (let i = 1; i < 10; i++) {
3640
- const a = Math.round(i * e.width / 10), s = Math.round(r * e.height / 10), l = n.getImageData(a, s, 1, 1).data, c = (0.299 * l[0] + 0.587 * l[1] + 0.114 * l[2]) / 255;
3641
- o += c;
3642
- }
3643
- return o / 81;
3644
- }, rr = (t, e) => {
3645
- const n = or(t), o = n > 0.6 ? "dark" : "light";
3646
- console.log(`[Annotorious] Image brightness: ${n.toFixed(1)}. Setting ${o} theme.`), e.setAttribute("data-theme", o);
3647
- }, ir = (t) => ({
3648
- ...t,
3649
- drawingEnabled: t.drawingEnabled === void 0 ? !0 : t.drawingEnabled,
3650
- drawingMode: t.drawingMode || "drag",
3651
- pointerSelectAction: t.pointerSelectAction || Fe.EDIT
3652
- }), sr = (t, e = {}) => {
3653
- if (!t)
3654
- throw "Missing argument: image";
3655
- const n = typeof t == "string" ? document.getElementById(t) : t, o = ir(e), r = nr(o), { hover: i, selection: a, store: s } = r, l = In(
3656
- s,
3657
- a,
3658
- i,
3659
- void 0,
3660
- o.adapter,
3661
- o.autoSave
3662
- );
3663
- let c = Vn(), h = o.style;
3664
- const u = document.createElement("DIV");
3665
- u.style.position = "relative", u.style.display = "inline-block", n.style.display = "block", n.parentNode.insertBefore(u, n), u.appendChild(n), rr(n, u);
3666
- const f = new jo({
3667
- target: u,
3668
- props: {
3669
- drawingEnabled: o.drawingEnabled,
3670
- image: n,
3671
- preferredDrawingMode: o.drawingMode,
3672
- state: r,
3673
- style: h,
3674
- user: c
3675
- }
3676
- });
3677
- f.$on("click", ($) => {
3678
- const { originalEvent: w, annotation: A } = $.detail;
3679
- A ? a.clickSelect(A.id, w) : a.isEmpty() || a.clear();
3680
- });
3681
- const p = Dn(s, o.adapter), g = ($) => {
3682
- h = $, f.$set({ style: h });
3683
- }, m = () => {
3684
- f.$destroy(), u.parentNode.insertBefore(n, u), u.parentNode.removeChild(u);
3685
- }, b = () => c, E = ($, w, A) => Eo($, w, A), T = ($, w) => oo($, w), X = ($) => {
3686
- const { tool: w, opts: A } = je($);
3687
- f.$set({ tool: w, opts: A });
3688
- }, x = ($) => f.$set({ drawingEnabled: $ }), _ = ($) => {
3689
- $ ? a.setSelected($) : a.clear();
3690
- }, y = ($) => {
3691
- c = $, f.$set({ user: $ });
3692
- };
3693
- return {
3694
- ...p,
3695
- get style() {
3696
- return h;
3697
- },
3698
- set style($) {
3699
- g($);
3700
- },
3701
- destroy: m,
3702
- getUser: b,
3703
- listDrawingTools: bo,
3704
- on: l.on,
3705
- off: l.off,
3706
- registerDrawingTool: E,
3707
- registerShapeEditor: T,
3708
- setDrawingEnabled: x,
3709
- setDrawingTool: X,
3710
- setSelected: _,
3711
- setUser: y,
3712
- state: r
3713
- };
3714
- };
1
+ var e = { exports: {} };
3715
2
  export {
3716
- He as Editor,
3717
- lo as EditorMount,
3718
- M as Handle,
3719
- Zn as PolygonEditor,
3720
- no as RectangleEditor,
3721
- dn as RectangleUtil,
3722
- fo as RubberbandRectangle,
3723
- jo as SVGAnnotationLayer,
3724
- F as ShapeType,
3725
- uo as ToolMount,
3726
- ar as W3CImageFormat,
3727
- Io as addEventListeners,
3728
- Ut as boundsFromPoints,
3729
- de as computeArea,
3730
- Vn as createAnonymousGuest,
3731
- Dn as createBaseAnnotator,
3732
- sr as createImageAnnotator,
3733
- er as createImageAnnotatorState,
3734
- Ro as createSVGTransform,
3735
- nr as createSvelteImageAnnotatorState,
3736
- Yn as diffAnnotations,
3737
- be as distance,
3738
- mo as enableResponsive,
3739
- ir as fillDefaults,
3740
- we as getEditor,
3741
- je as getTool,
3742
- sn as intersects,
3743
- bo as listDrawingTools,
3744
- Nn as parseAll,
3745
- un as parseFragmentSelector,
3746
- yn as parseSVGSelector,
3747
- jn as parseW3CBodies,
3748
- zn as parseW3CImageAnnotation,
3749
- oo as registerEditor,
3750
- oe as registerShapeUtil,
3751
- Eo as registerTool,
3752
- or as sampleBrightness,
3753
- hn as serializeFragmentSelector,
3754
- wn as serializeSVGSelector,
3755
- Cn as serializeW3CBodies,
3756
- Wn as serializeW3CImageAnnotation,
3757
- rr as setTheme
3
+ e as __module
3758
4
  };
3759
5
  //# sourceMappingURL=annotorious-react.es13.js.map