@annotorious/react 3.0.0-rc.4 → 3.0.0-rc.6

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