@phun-ky/arclace 0.3.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/arclace.js CHANGED
@@ -1,134 +1,134 @@
1
- var _t = Object.defineProperty;
2
- var mt = (e) => {
1
+ var Bt = Object.defineProperty;
2
+ var xt = (e) => {
3
3
  throw TypeError(e);
4
4
  };
5
- var Rt = (e, t, n) => t in e ? _t(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
- var z = (e, t, n) => Rt(e, typeof t != "symbol" ? t + "" : t, n), et = (e, t, n) => t.has(e) || mt("Cannot " + n);
7
- var r = (e, t, n) => (et(e, t, "read from private field"), n ? n.call(e) : t.get(e)), p = (e, t, n) => t.has(e) ? mt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), l = (e, t, n, s) => (et(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), y = (e, t, n) => (et(e, t, "access private method"), n);
8
- class N extends Error {
5
+ var Ft = (e, t, n) => t in e ? Bt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
6
+ var M = (e, t, n) => Ft(e, typeof t != "symbol" ? t + "" : t, n), st = (e, t, n) => t.has(e) || xt("Cannot " + n);
7
+ var o = (e, t, n) => (st(e, t, "read from private field"), n ? n.call(e) : t.get(e)), p = (e, t, n) => t.has(e) ? xt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), l = (e, t, n, s) => (st(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n), m = (e, t, n) => (st(e, t, "access private method"), n);
8
+ class R extends Error {
9
9
  constructor(n, s) {
10
10
  super(`arclace: ${n}`, s);
11
- z(this, "name", "ArclaceError");
11
+ M(this, "name", "ArclaceError");
12
12
  }
13
13
  }
14
- const B = Object.freeze({
14
+ const Y = Object.freeze({
15
15
  top: Object.freeze({ x: 0, y: -1 }),
16
16
  right: Object.freeze({ x: 1, y: 0 }),
17
17
  bottom: Object.freeze({ x: 0, y: 1 }),
18
18
  left: Object.freeze({ x: -1, y: 0 })
19
- }), At = Object.freeze({
19
+ }), kt = Object.freeze({
20
20
  top: "bottom",
21
21
  right: "left",
22
22
  bottom: "top",
23
23
  left: "right"
24
- }), it = (e) => e === "left" || e === "right", J = (e) => ({
24
+ }), at = (e) => e === "left" || e === "right", Q = (e) => ({
25
25
  x: e.left + e.width / 2,
26
26
  y: e.top + e.height / 2
27
- }), q = (e, t, n = 1) => ({ x: e.x + t.x * n, y: e.y + t.y * n }), I = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), bt = (e) => Math.round(e * 100) / 100, O = (e) => `${bt(e.x)} ${bt(e.y)}`, jt = () => "_" + Math.random().toString(36).substring(2, 11), ct = Object.freeze([
27
+ }), X = (e, t, n = 1) => ({ x: e.x + t.x * n, y: e.y + t.y * n }), I = (e, t) => Math.hypot(t.x - e.x, t.y - e.y), wt = (e) => Math.round(e * 100) / 100, O = (e) => `${wt(e.x)} ${wt(e.y)}`, zt = () => "_" + Math.random().toString(36).substring(2, 11), ht = Object.freeze([
28
28
  "top",
29
29
  "right",
30
30
  "bottom",
31
31
  "left"
32
- ]), xt = Object.freeze([
33
- ...ct,
32
+ ]), Et = Object.freeze([
33
+ ...ht,
34
34
  "auto"
35
- ]), Lt = Object.freeze([
35
+ ]), It = Object.freeze([
36
36
  "bezier",
37
37
  "straight",
38
38
  "orthogonal"
39
- ]), It = Object.freeze([
39
+ ]), Wt = Object.freeze([
40
40
  "none",
41
41
  "start",
42
42
  "end",
43
43
  "both"
44
- ]), C = (e) => typeof e == "string" ? JSON.stringify(e) : e == null || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? "an array" : typeof e == "object" ? "an object" : `a ${typeof e}`, Z = (e, t) => {
44
+ ]), L = (e) => typeof e == "string" ? JSON.stringify(e) : e == null || typeof e == "number" || typeof e == "boolean" ? String(e) : Array.isArray(e) ? "an array" : typeof e == "object" ? "an object" : `a ${typeof e}`, et = (e, t) => {
45
45
  if (typeof e != "object" || e === null || Array.isArray(e))
46
46
  throw new TypeError(
47
- `arclace: ${t} must be an object, not ${C(e)}`
47
+ `arclace: ${t} must be an object, not ${L(e)}`
48
48
  );
49
- }, F = (e, t, n) => {
50
- const s = t.map((o) => `"${o}"`).join(", ");
49
+ }, W = (e, t, n) => {
50
+ const s = t.map((r) => `"${r}"`).join(", ");
51
51
  if (typeof e != "string")
52
52
  throw new TypeError(
53
- `arclace: ${n} must be one of ${s}, not ${C(e)}`
53
+ `arclace: ${n} must be one of ${s}, not ${L(e)}`
54
54
  );
55
55
  if (!t.includes(e))
56
56
  throw new RangeError(
57
- `arclace: ${n} must be one of ${s}, not ${C(e)}`
57
+ `arclace: ${n} must be one of ${s}, not ${L(e)}`
58
58
  );
59
59
  return e;
60
- }, A = (e, t, n) => {
60
+ }, S = (e, t, n) => {
61
61
  if (typeof e != "number" || !Number.isFinite(e))
62
62
  throw new TypeError(
63
- `arclace: ${t} must be a finite number, not ${C(e)}`
63
+ `arclace: ${t} must be a finite number, not ${L(e)}`
64
64
  );
65
65
  if (n !== void 0 && e < n)
66
66
  throw new RangeError(
67
- `arclace: ${t} must be ${n} or more, not ${C(e)}`
67
+ `arclace: ${t} must be ${n} or more, not ${L(e)}`
68
68
  );
69
69
  return e;
70
- }, G = (e, t) => {
70
+ }, J = (e, t) => {
71
71
  if (typeof e != "boolean")
72
72
  throw new TypeError(
73
- `arclace: ${t} must be true or false, not ${C(e)}`
73
+ `arclace: ${t} must be true or false, not ${L(e)}`
74
74
  );
75
75
  return e;
76
- }, Y = (e, t, n = !1) => {
76
+ }, H = (e, t, n = !1) => {
77
77
  if (typeof e != "string" || n && e === "")
78
78
  throw new TypeError(
79
- `arclace: ${t} must be a ${n ? "non-empty " : ""}string, not ${C(e)}`
79
+ `arclace: ${t} must be a ${n ? "non-empty " : ""}string, not ${L(e)}`
80
80
  );
81
81
  return e;
82
- }, K = (e, t) => {
83
- Z(e, t);
82
+ }, Z = (e, t) => {
83
+ et(e, t);
84
84
  const { x: n, y: s } = e;
85
- return A(n, `${t}.x`), A(s, `${t}.y`), e;
86
- }, Ft = Object.freeze({
87
- id: (e, t) => Y(e, t, !0),
88
- type: (e, t) => F(e, Lt, t),
89
- startSide: (e, t) => F(e, xt, t),
90
- endSide: (e, t) => F(e, xt, t),
91
- arrow: (e, t) => F(e, It, t),
92
- label: Y,
93
- color: Y,
94
- className: Y,
95
- strokeWidth: (e, t) => A(e, t, 0),
96
- dashed: G,
97
- animated: G,
98
- anchors: G,
99
- gap: (e, t) => A(e, t),
100
- spread: G,
101
- spacing: (e, t) => A(e, t, 0),
102
- curvature: (e, t) => A(e, t),
103
- radius: (e, t) => A(e, t, 0),
104
- offset: (e, t) => A(e, t, 0)
105
- }), dt = (e, t = "options") => {
106
- Z(e, t);
107
- for (const [n, s] of Object.entries(Ft)) {
108
- const o = Object.hasOwn(e, n) ? e[n] : void 0;
109
- o !== void 0 && s(o, `${t}.${n}`);
85
+ return S(n, `${t}.x`), S(s, `${t}.y`), e;
86
+ }, Dt = Object.freeze({
87
+ id: (e, t) => H(e, t, !0),
88
+ type: (e, t) => W(e, It, t),
89
+ startSide: (e, t) => W(e, Et, t),
90
+ endSide: (e, t) => W(e, Et, t),
91
+ arrow: (e, t) => W(e, Wt, t),
92
+ label: H,
93
+ color: H,
94
+ className: H,
95
+ strokeWidth: (e, t) => S(e, t, 0),
96
+ dashed: J,
97
+ animated: J,
98
+ anchors: J,
99
+ gap: (e, t) => S(e, t),
100
+ spread: J,
101
+ spacing: (e, t) => S(e, t, 0),
102
+ curvature: (e, t) => S(e, t),
103
+ radius: (e, t) => S(e, t, 0),
104
+ offset: (e, t) => S(e, t, 0)
105
+ }), mt = (e, t = "options") => {
106
+ et(e, t);
107
+ for (const [n, s] of Object.entries(Dt)) {
108
+ const r = Object.hasOwn(e, n) ? e[n] : void 0;
109
+ r !== void 0 && s(r, `${t}.${n}`);
110
110
  }
111
111
  return e;
112
- }, Wt = (e) => {
113
- Z(e, "options");
112
+ }, Ut = (e) => {
113
+ et(e, "options");
114
114
  const { autoUpdate: t, className: n, defaults: s } = e;
115
115
  if (t !== void 0 && typeof t != "boolean" && t !== "frame")
116
116
  throw new RangeError(
117
- `arclace: options.autoUpdate must be true, false or "frame", not ${C(t)}`
117
+ `arclace: options.autoUpdate must be true, false or "frame", not ${L(t)}`
118
118
  );
119
- if (n !== void 0 && Y(n, "options.className"), s !== void 0 && (dt(s, "options.defaults"), s.id !== void 0))
119
+ if (n !== void 0 && H(n, "options.className"), s !== void 0 && (mt(s, "options.defaults"), s.id !== void 0))
120
120
  throw new TypeError(
121
121
  "arclace: options.defaults cannot set an id; ids belong to single connections"
122
122
  );
123
123
  return e;
124
- }, Dt = (e, t = 1e3) => Math.min(e / t, 1), Ut = (e, t, n) => t + (n - t) * e, Bt = (e, t = 1.1, n = 3.5, s = 1e3) => Ut(Dt(e, s), t, n), St = (e, t, n, s) => {
125
- K(e, "start"), F(t, ct, "startSide"), K(n, "end"), F(s, ct, "endSide");
126
- }, qt = (e, t) => (K(e, "start"), K(t, "end"), {
124
+ }, qt = (e, t = 1e3) => Math.min(e / t, 1), Yt = (e, t, n) => t + (n - t) * e, Xt = (e, t = 1.1, n = 3.5, s = 1e3) => Yt(qt(e, s), t, n), Mt = (e, t, n, s) => {
125
+ Z(e, "start"), W(t, ht, "startSide"), Z(n, "end"), W(s, ht, "endSide");
126
+ }, Ht = (e, t) => (Z(e, "start"), Z(t, "end"), {
127
127
  d: `M ${O(e)} L ${O(t)}`,
128
128
  labelPoint: { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }
129
- }), Yt = (e, t, n, s, o = 1) => {
130
- St(e, t, n, s), A(o, "curvature");
131
- const i = I(e, n), c = i / Bt(i) * o, a = q(e, B[t], c), h = q(n, B[s], c);
129
+ }), Gt = (e, t, n, s, r = 1) => {
130
+ Mt(e, t, n, s), S(r, "curvature");
131
+ const i = I(e, n), c = i / Xt(i) * r, a = X(e, Y[t], c), h = X(n, Y[s], c);
132
132
  return {
133
133
  d: `M ${O(e)} C ${O(a)}, ${O(h)}, ${O(n)}`,
134
134
  // Point on the curve at t = 0.5
@@ -137,26 +137,26 @@ const B = Object.freeze({
137
137
  y: (e.y + 3 * a.y + 3 * h.y + n.y) / 8
138
138
  }
139
139
  };
140
- }, Xt = (e) => {
140
+ }, Vt = (e) => {
141
141
  const t = e.filter(
142
142
  (n, s) => s === 0 || I(n, e[s - 1]) > 0.01
143
143
  );
144
144
  return t.filter((n, s) => {
145
145
  if (s === 0 || s === t.length - 1) return !0;
146
- const o = t[s - 1], i = t[s + 1], c = (n.x - o.x) * (i.y - o.y) - (n.y - o.y) * (i.x - o.x);
146
+ const r = t[s - 1], i = t[s + 1], c = (n.x - r.x) * (i.y - r.y) - (n.y - r.y) * (i.x - r.x);
147
147
  return Math.abs(c) > 0.01;
148
148
  });
149
- }, Ht = (e, t) => {
149
+ }, Jt = (e, t) => {
150
150
  if (e.length === 0) return "";
151
- const n = (o, i, c) => {
152
- const a = I(o, i);
151
+ const n = (r, i, c) => {
152
+ const a = I(r, i);
153
153
  return {
154
- x: o.x + (i.x - o.x) / a * c,
155
- y: o.y + (i.y - o.y) / a * c
154
+ x: r.x + (i.x - r.x) / a * c,
155
+ y: r.y + (i.y - r.y) / a * c
156
156
  };
157
157
  }, s = [`M ${O(e[0])}`];
158
- for (let o = 1; o < e.length - 1; o++) {
159
- const i = e[o - 1], c = e[o], a = e[o + 1], h = Math.min(
158
+ for (let r = 1; r < e.length - 1; r++) {
159
+ const i = e[r - 1], c = e[r], a = e[r + 1], h = Math.min(
160
160
  t,
161
161
  I(i, c) / 2,
162
162
  I(c, a) / 2
@@ -171,68 +171,68 @@ const B = Object.freeze({
171
171
  );
172
172
  }
173
173
  return e.length > 1 && s.push(`L ${O(e[e.length - 1])}`), s.join(" ");
174
- }, Gt = (e) => {
175
- const t = e.slice(1).map((s, o) => I(e[o], s));
176
- let n = t.reduce((s, o) => s + o, 0) / 2;
174
+ }, Kt = (e) => {
175
+ const t = e.slice(1).map((s, r) => I(e[r], s));
176
+ let n = t.reduce((s, r) => s + r, 0) / 2;
177
177
  for (let s = 0; s < t.length; s++) {
178
178
  if (n <= t[s] && t[s] > 0) {
179
- const o = n / t[s];
179
+ const r = n / t[s];
180
180
  return {
181
- x: e[s].x + (e[s + 1].x - e[s].x) * o,
182
- y: e[s].y + (e[s + 1].y - e[s].y) * o
181
+ x: e[s].x + (e[s + 1].x - e[s].x) * r,
182
+ y: e[s].y + (e[s + 1].y - e[s].y) * r
183
183
  };
184
184
  }
185
185
  n -= t[s];
186
186
  }
187
187
  return { ...e[0] };
188
- }, gt = Object.freeze({
188
+ }, Ot = Object.freeze({
189
189
  top: "left",
190
190
  bottom: "right",
191
191
  left: "top",
192
192
  right: "bottom"
193
- }), nt = (e) => ({
193
+ }), ot = (e) => ({
194
194
  x: e.y,
195
195
  y: e.x
196
- }), kt = (e, t, n, s, o = 20) => {
197
- if (!it(t))
198
- return kt(
199
- nt(e),
200
- gt[t],
201
- nt(n),
202
- gt[s],
203
- o
204
- ).map(nt);
205
- const i = B[t], c = B[s], a = q(e, i, o), h = q(n, c, o);
206
- if (it(s)) {
207
- if (s === At[t]) {
196
+ }), Pt = (e, t, n, s, r = 20) => {
197
+ if (!at(t))
198
+ return Pt(
199
+ ot(e),
200
+ Ot[t],
201
+ ot(n),
202
+ Ot[s],
203
+ r
204
+ ).map(ot);
205
+ const i = Y[t], c = Y[s], a = X(e, i, r), h = X(n, c, r);
206
+ if (at(s)) {
207
+ if (s === kt[t]) {
208
208
  if ((h.x - a.x) * i.x >= 0) {
209
- const k = (e.x + n.x) / 2;
210
- return [e, { x: k, y: e.y }, { x: k, y: n.y }, n];
209
+ const $ = (e.x + n.x) / 2;
210
+ return [e, { x: $, y: e.y }, { x: $, y: n.y }, n];
211
211
  }
212
212
  const u = (a.y + h.y) / 2;
213
213
  return [e, a, { x: a.x, y: u }, { x: h.x, y: u }, h, n];
214
214
  }
215
- const d = i.x > 0 ? Math.max(a.x, h.x) : Math.min(a.x, h.x);
216
- return [e, { x: d, y: e.y }, { x: d, y: n.y }, n];
217
- }
218
- const f = { x: n.x, y: e.y };
219
- return (f.x - e.x) * i.x > 0 && (f.y - n.y) * c.y > 0 ? [e, f, n] : [e, a, { x: a.x, y: h.y }, h, n];
220
- }, Vt = (e, t, n, s, { radius: o = 8, offset: i = 20 } = {}) => {
221
- St(e, t, n, s), A(o, "radius", 0), A(i, "offset", 0);
222
- const c = Xt(
223
- kt(e, t, n, s, i)
215
+ const f = i.x > 0 ? Math.max(a.x, h.x) : Math.min(a.x, h.x);
216
+ return [e, { x: f, y: e.y }, { x: f, y: n.y }, n];
217
+ }
218
+ const d = { x: n.x, y: e.y };
219
+ return (d.x - e.x) * i.x > 0 && (d.y - n.y) * c.y > 0 ? [e, d, n] : [e, a, { x: a.x, y: h.y }, h, n];
220
+ }, Qt = (e, t, n, s, { radius: r = 8, offset: i = 20 } = {}) => {
221
+ Mt(e, t, n, s), S(r, "radius", 0), S(i, "offset", 0);
222
+ const c = Vt(
223
+ Pt(e, t, n, s, i)
224
224
  );
225
225
  return {
226
- d: Ht(c, o),
227
- labelPoint: Gt(c)
226
+ d: Jt(c, r),
227
+ labelPoint: Kt(c)
228
228
  };
229
- }, Jt = "http://www.w3.org/2000/svg", M = (e, t = {}) => {
230
- const n = document.createElementNS(Jt, e);
231
- return $(n, t), n;
232
- }, $ = (e, t) => {
229
+ }, Zt = "http://www.w3.org/2000/svg", P = (e, t = {}) => {
230
+ const n = document.createElementNS(Zt, e);
231
+ return v(n, t), n;
232
+ }, v = (e, t) => {
233
233
  for (const [n, s] of Object.entries(t))
234
234
  s == null ? e.removeAttribute(n) : e.setAttribute(n, String(s));
235
- }, Kt = Object.freeze({
235
+ }, te = Object.freeze({
236
236
  type: "bezier",
237
237
  startSide: "auto",
238
238
  endSide: "auto",
@@ -247,45 +247,49 @@ const B = Object.freeze({
247
247
  curvature: 1,
248
248
  radius: 8,
249
249
  offset: 20
250
- }), wt = (e) => Object.fromEntries(
250
+ }), $t = (e) => Object.fromEntries(
251
251
  Object.entries(e).filter(([, t]) => t !== void 0)
252
- ), st = 4;
253
- var P, X, _, R, H, j, w, E, m, zt, at, ht, Mt, Pt, Tt;
254
- const pt = class pt {
252
+ ), rt = 4;
253
+ var C, G, _, B, V, k, g, T, A, E, y, Tt, lt, ut, Ct, dt, Nt, Lt;
254
+ const bt = class bt {
255
255
  constructor(t) {
256
- p(this, m);
257
- z(this, "id");
258
- z(this, "startElement");
259
- z(this, "endElement");
256
+ p(this, y);
257
+ M(this, "id");
258
+ M(this, "startElement");
259
+ M(this, "endElement");
260
260
  /**
261
261
  * The `<g>` element holding everything this connection draws.
262
262
  */
263
- z(this, "element");
263
+ M(this, "element");
264
264
  /**
265
265
  * The `<path>` element of the line.
266
266
  */
267
- z(this, "path");
268
- p(this, P, null);
269
- p(this, X, !1);
267
+ M(this, "path");
268
+ p(this, C, null);
269
+ p(this, G, !1);
270
270
  p(this, _);
271
- p(this, R);
272
- p(this, H);
273
- p(this, j, null);
274
- p(this, w, null);
271
+ p(this, B);
272
+ p(this, V);
273
+ p(this, k, null);
274
+ p(this, g, null);
275
+ p(this, T, null);
276
+ // The background's box relative to the label's anchor point, measured once
277
+ // per label
278
+ p(this, A, null);
275
279
  p(this, E, null);
276
280
  const {
277
281
  id: n,
278
282
  startElement: s,
279
- endElement: o,
283
+ endElement: r,
280
284
  options: i,
281
285
  defaults: c = {},
282
286
  owner: a
283
287
  } = t;
284
- this.id = n, this.startElement = s, this.endElement = o, l(this, _, a), l(this, R, { ...i }), l(this, H, c), this.element = M("g", { "data-arc-id": n }), this.path = M("path", {
288
+ this.id = n, this.startElement = s, this.endElement = r, l(this, _, a), l(this, B, { ...i }), l(this, V, c), this.element = P("g", { "data-arc-id": n }), this.path = P("path", {
285
289
  class: "arc-path",
286
290
  fill: "none",
287
291
  stroke: "currentColor"
288
- }), this.element.appendChild(this.path), y(this, m, ht).call(this);
292
+ }), this.element.appendChild(this.path), m(this, y, ut).call(this);
289
293
  }
290
294
  /**
291
295
  * Creates a connection for its owner. Options must already be validated.
@@ -293,23 +297,23 @@ const pt = class pt {
293
297
  * @internal
294
298
  */
295
299
  static _create(t) {
296
- return new pt(t);
300
+ return new bt(t);
297
301
  }
298
302
  /**
299
303
  * The geometry from the last update, or `null` when the connection is
300
304
  * hidden because one of its elements is not rendered.
301
305
  */
302
306
  get geometry() {
303
- return r(this, P);
307
+ return o(this, C);
304
308
  }
305
309
  /**
306
310
  * The connection's options merged with the instance defaults.
307
311
  */
308
312
  get options() {
309
313
  return {
310
- ...Kt,
311
- ...wt(r(this, H)),
312
- ...wt(r(this, R)),
314
+ ...te,
315
+ ...$t(o(this, V)),
316
+ ...$t(o(this, B)),
313
317
  id: this.id
314
318
  };
315
319
  }
@@ -325,42 +329,42 @@ const pt = class pt {
325
329
  * @throws {ArclaceError} When the connection has been removed.
326
330
  */
327
331
  setOptions(t) {
328
- if (r(this, X))
329
- throw new N(`connection "${this.id}" has been removed`);
330
- if (dt(t), t.id !== void 0)
332
+ if (o(this, G))
333
+ throw new R(`connection "${this.id}" has been removed`);
334
+ if (mt(t), t.id !== void 0)
331
335
  throw new TypeError("arclace: setOptions() cannot change the id");
332
- return l(this, R, { ...r(this, R), ...t }), y(this, m, ht).call(this), r(this, _).update(), this;
336
+ return l(this, B, { ...o(this, B), ...t }), m(this, y, ut).call(this), o(this, _).update(), this;
333
337
  }
334
338
  /**
335
339
  * Redraws every connection of the owning instance.
336
340
  */
337
341
  update() {
338
- r(this, _).update();
342
+ o(this, _).update();
339
343
  }
340
344
  /**
341
345
  * Removes this connection.
342
346
  */
343
347
  remove() {
344
- r(this, _).disconnect(this);
348
+ o(this, _).disconnect(this);
345
349
  }
346
350
  /**
347
351
  * Draws the connection between two attachment points.
348
352
  *
349
353
  * @internal
350
354
  */
351
- _draw(t, n, s, o) {
352
- const { arrow: i, strokeWidth: c } = this.options, a = st * c, h = i === "start" || i === "both" ? y(this, m, at).call(this, t, n, s, a) : t, f = i === "end" || i === "both" ? y(this, m, at).call(this, s, o, t, a) : s, { d, labelPoint: u } = y(this, m, zt).call(this, h, n, f, o);
353
- l(this, P, Object.freeze({
355
+ _draw(t, n, s, r) {
356
+ const { arrow: i, strokeWidth: c } = this.options, a = rt * c, h = i === "start" || i === "both" ? m(this, y, lt).call(this, t, n, s, a) : t, d = i === "end" || i === "both" ? m(this, y, lt).call(this, s, r, t, a) : s, { d: f, labelPoint: u } = m(this, y, Tt).call(this, h, n, d, r);
357
+ l(this, C, Object.freeze({
354
358
  start: t,
355
359
  end: s,
356
360
  startSide: n,
357
- endSide: o,
361
+ endSide: r,
358
362
  labelPoint: u,
359
- d
360
- })), this.element.removeAttribute("display"), $(this.element, {
363
+ d: f
364
+ })), this.element.removeAttribute("display"), v(this.element, {
361
365
  "data-start-side": n,
362
- "data-end-side": o
363
- }), this.path.setAttribute("d", d), r(this, w) && $(r(this, w), { ...u }), r(this, E) && ($(r(this, E)[0], { cx: t.x, cy: t.y }), $(r(this, E)[1], { cx: s.x, cy: s.y }));
366
+ "data-end-side": r
367
+ }), this.path.setAttribute("d", f), o(this, g) && m(this, y, dt).call(this, u), o(this, E) && (v(o(this, E)[0], { cx: t.x, cy: t.y }), v(o(this, E)[1], { cx: s.x, cy: s.y }));
364
368
  }
365
369
  /**
366
370
  * Hides the connection.
@@ -368,7 +372,7 @@ const pt = class pt {
368
372
  * @internal
369
373
  */
370
374
  _hide() {
371
- l(this, P, null), this.element.setAttribute("display", "none");
375
+ l(this, C, null), this.element.setAttribute("display", "none");
372
376
  }
373
377
  /**
374
378
  * Removes the connection's elements from the overlay.
@@ -376,94 +380,120 @@ const pt = class pt {
376
380
  * @internal
377
381
  */
378
382
  _dispose() {
379
- l(this, X, !0), this.element.remove();
383
+ l(this, G, !0), this.element.remove();
380
384
  }
381
385
  };
382
- P = new WeakMap(), X = new WeakMap(), _ = new WeakMap(), R = new WeakMap(), H = new WeakMap(), j = new WeakMap(), w = new WeakMap(), E = new WeakMap(), m = new WeakSet(), zt = function(t, n, s, o) {
386
+ C = new WeakMap(), G = new WeakMap(), _ = new WeakMap(), B = new WeakMap(), V = new WeakMap(), k = new WeakMap(), g = new WeakMap(), T = new WeakMap(), A = new WeakMap(), E = new WeakMap(), y = new WeakSet(), Tt = function(t, n, s, r) {
383
387
  const { type: i, curvature: c, radius: a, offset: h } = this.options;
384
- return i === "straight" ? qt(t, s) : i === "orthogonal" ? Vt(t, n, s, o, {
388
+ return i === "straight" ? Ht(t, s) : i === "orthogonal" ? Qt(t, n, s, r, {
385
389
  radius: a,
386
390
  offset: h
387
- }) : Yt(t, n, s, o, c);
388
- }, at = function(t, n, s, o) {
389
- const i = I(t, s), c = Math.min(o, i / 3);
390
- return this.options.type !== "straight" ? q(t, B[n], c) : i === 0 ? t : {
391
+ }) : Gt(t, n, s, r, c);
392
+ }, lt = function(t, n, s, r) {
393
+ const i = I(t, s), c = Math.min(r, i / 3);
394
+ return this.options.type !== "straight" ? X(t, Y[n], c) : i === 0 ? t : {
391
395
  x: t.x + (s.x - t.x) / i * c,
392
396
  y: t.y + (s.y - t.y) / i * c
393
397
  };
394
- }, ht = function() {
398
+ }, ut = function() {
395
399
  const {
396
400
  type: t,
397
401
  arrow: n,
398
402
  label: s,
399
- color: o,
403
+ color: r,
400
404
  strokeWidth: i,
401
405
  dashed: c,
402
406
  animated: a,
403
407
  anchors: h,
404
- className: f
405
- } = this.options, d = ["arc-connection", `arc-${t}`];
406
- (c || a) && d.push("arc-dashed"), a && d.push("arc-animated"), f && d.push(...f.split(/\s+/).filter(Boolean)), $(this.element, {
407
- class: d.join(" "),
408
+ className: d
409
+ } = this.options, f = ["arc-connection", `arc-${t}`];
410
+ (c || a) && f.push("arc-dashed"), a && f.push("arc-animated"), d && f.push(...d.split(/\s+/).filter(Boolean)), v(this.element, {
411
+ class: f.join(" "),
408
412
  "data-type": t
409
- }), this.element.style.color = o ?? "", $(this.path, {
413
+ }), this.element.style.color = r ?? "", v(this.path, {
410
414
  "stroke-width": i,
411
415
  "stroke-dasharray": c || a ? "6 6" : null
412
- }), y(this, m, Mt).call(this, n), y(this, m, Pt).call(this, s), y(this, m, Tt).call(this, h, i);
413
- }, Mt = function(t) {
416
+ }), m(this, y, Ct).call(this, n), m(this, y, Nt).call(this, s), m(this, y, Lt).call(this, h, i);
417
+ }, Ct = function(t) {
414
418
  var s;
415
419
  if (t === "none") {
416
- (s = r(this, j)) == null || s.remove(), l(this, j, null), $(this.path, { "marker-start": null, "marker-end": null });
420
+ (s = o(this, k)) == null || s.remove(), l(this, k, null), v(this.path, { "marker-start": null, "marker-end": null });
417
421
  return;
418
422
  }
419
- r(this, j) || (l(this, j, M("marker", {
420
- id: `arc-arrow-${jt()}`,
423
+ o(this, k) || (l(this, k, P("marker", {
424
+ id: `arc-arrow-${zt()}`,
421
425
  class: "arc-marker",
422
426
  viewBox: "0 0 10 10",
423
427
  refX: 0,
424
428
  refY: 5,
425
- markerWidth: st,
426
- markerHeight: st,
429
+ markerWidth: rt,
430
+ markerHeight: rt,
427
431
  markerUnits: "strokeWidth",
428
432
  orient: "auto-start-reverse"
429
- })), r(this, j).appendChild(
430
- M("path", {
433
+ })), o(this, k).appendChild(
434
+ P("path", {
431
435
  d: "M 0 0 L 10 5 L 0 10 z",
432
436
  fill: "currentColor"
433
437
  })
434
- ), this.element.insertBefore(r(this, j), this.path));
435
- const n = `url(#${r(this, j).id})`;
436
- $(this.path, {
438
+ ), this.element.insertBefore(o(this, k), this.path));
439
+ const n = `url(#${o(this, k).id})`;
440
+ v(this.path, {
437
441
  "marker-start": t === "start" || t === "both" ? n : null,
438
442
  "marker-end": t === "end" || t === "both" ? n : null
439
443
  });
440
- }, Pt = function(t) {
444
+ }, dt = function(t) {
441
445
  var n;
442
- if (!t) {
443
- (n = r(this, w)) == null || n.remove(), l(this, w, null);
446
+ if (v(o(this, g), { ...t }), !((n = o(this, A)) != null && n.width) && typeof o(this, g).getBBox == "function") {
447
+ const { x: s, y: r, width: i, height: c } = o(this, g).getBBox(), a = getComputedStyle(o(this, T)), [h, d, f, u] = [
448
+ a.paddingTop,
449
+ a.paddingRight,
450
+ a.paddingBottom,
451
+ a.paddingLeft
452
+ ].map(($) => parseFloat($) || 0);
453
+ l(this, A, {
454
+ x: s - t.x - u,
455
+ y: r - t.y - h,
456
+ width: i + u + d,
457
+ height: c + h + f
458
+ });
459
+ }
460
+ o(this, A) && v(o(this, T), {
461
+ x: t.x + o(this, A).x,
462
+ y: t.y + o(this, A).y,
463
+ width: o(this, A).width,
464
+ height: o(this, A).height
465
+ });
466
+ }, Nt = function(t) {
467
+ var n, s;
468
+ if (l(this, A, null), !t) {
469
+ (n = o(this, g)) == null || n.remove(), (s = o(this, T)) == null || s.remove(), l(this, g, null), l(this, T, null);
444
470
  return;
445
471
  }
446
- r(this, w) || (l(this, w, M("text", {
472
+ o(this, g) || (l(this, g, P("text", {
447
473
  class: "arc-label",
448
474
  fill: "currentColor",
449
475
  "text-anchor": "middle",
450
476
  "dominant-baseline": "central"
451
- })), this.path.after(r(this, w)), r(this, P) && $(r(this, w), { ...r(this, P).labelPoint })), r(this, w).textContent = t;
452
- }, Tt = function(t, n) {
477
+ })), l(this, T, P("rect", {
478
+ class: "arc-label-bg",
479
+ fill: "none",
480
+ rx: 4
481
+ })), this.path.after(o(this, T), o(this, g))), o(this, g).textContent = t, o(this, C) && m(this, y, dt).call(this, o(this, C).labelPoint);
482
+ }, Lt = function(t, n) {
453
483
  var s;
454
484
  if (!t) {
455
- (s = r(this, E)) == null || s.forEach((o) => o.remove()), l(this, E, null);
485
+ (s = o(this, E)) == null || s.forEach((r) => r.remove()), l(this, E, null);
456
486
  return;
457
487
  }
458
- r(this, E) || (l(this, E, [
459
- M("circle", { class: "arc-anchor arc-anchor-start" }),
460
- M("circle", { class: "arc-anchor arc-anchor-end" })
461
- ]), this.element.append(...r(this, E))), r(this, E).forEach(
462
- (o) => $(o, { r: n + 2, fill: "currentColor" })
488
+ o(this, E) || (l(this, E, [
489
+ P("circle", { class: "arc-anchor arc-anchor-start" }),
490
+ P("circle", { class: "arc-anchor arc-anchor-end" })
491
+ ]), this.element.append(...o(this, E))), o(this, E).forEach(
492
+ (r) => v(r, { r: n + 2, fill: "currentColor" })
463
493
  );
464
494
  };
465
- let Q = pt;
466
- const Qt = (e) => {
495
+ let tt = bt;
496
+ const ee = (e) => {
467
497
  const t = e.getBoundingClientRect(), { clientWidth: n, clientHeight: s } = e;
468
498
  return {
469
499
  left: t.left,
@@ -471,28 +501,28 @@ const Qt = (e) => {
471
501
  scaleX: n > 0 && t.width > 0 ? t.width / n : 1,
472
502
  scaleY: s > 0 && t.height > 0 ? t.height / s : 1
473
503
  };
474
- }, Et = (e, t) => {
475
- const n = e.getBoundingClientRect(), s = (n.left - t.left) / t.scaleX, o = (n.top - t.top) / t.scaleY, i = n.width / t.scaleX, c = n.height / t.scaleY;
504
+ }, vt = (e, t) => {
505
+ const n = e.getBoundingClientRect(), s = (n.left - t.left) / t.scaleX, r = (n.top - t.top) / t.scaleY, i = n.width / t.scaleX, c = n.height / t.scaleY;
476
506
  return {
477
507
  left: s,
478
- top: o,
508
+ top: r,
479
509
  width: i,
480
510
  height: c,
481
511
  right: s + i,
482
- bottom: o + c
512
+ bottom: r + c
483
513
  };
484
- }, Ot = (e) => e.isConnected && e.getClientRects().length > 0, Ct = (e, t = "element") => {
514
+ }, At = (e) => e.isConnected && e.getClientRects().length > 0, Rt = (e, t = "element") => {
485
515
  try {
486
516
  return document.querySelector(e);
487
517
  } catch (n) {
488
- throw new N(`${t} "${e}" is not a valid selector`, {
518
+ throw new R(`${t} "${e}" is not a valid selector`, {
489
519
  cause: n
490
520
  });
491
521
  }
492
- }, V = (e, t = "element") => {
522
+ }, K = (e, t = "element") => {
493
523
  if (typeof e == "string") {
494
- const n = Ct(e, t);
495
- if (!n) throw new N(`no ${t} matches "${e}"`);
524
+ const n = Rt(e, t);
525
+ if (!n) throw new R(`no ${t} matches "${e}"`);
496
526
  return n;
497
527
  }
498
528
  if (!(e instanceof Element))
@@ -500,40 +530,40 @@ const Qt = (e) => {
500
530
  `arclace: ${t} must be an Element or a selector string`
501
531
  );
502
532
  return e;
503
- }, $t = (e, t) => {
504
- const n = J(e), s = J(t), o = s.x - n.x, i = s.y - n.y, c = Math.max(t.left - e.right, e.left - t.right), a = Math.max(t.top - e.bottom, e.top - t.bottom);
505
- return (c === a ? Math.abs(o) >= Math.abs(i) : c > a) ? o >= 0 ? "right" : "left" : i >= 0 ? "bottom" : "top";
506
- }, Zt = (e, t, n = "auto", s = "auto") => ({
507
- startSide: n === "auto" ? $t(e, t) : n,
508
- endSide: s === "auto" ? At[$t(e, t)] : s
509
- }), vt = (e, t, {
533
+ }, jt = (e, t) => {
534
+ const n = Q(e), s = Q(t), r = s.x - n.x, i = s.y - n.y, c = Math.max(t.left - e.right, e.left - t.right), a = Math.max(t.top - e.bottom, e.top - t.bottom);
535
+ return (c === a ? Math.abs(r) >= Math.abs(i) : c > a) ? r >= 0 ? "right" : "left" : i >= 0 ? "bottom" : "top";
536
+ }, ne = (e, t, n = "auto", s = "auto") => ({
537
+ startSide: n === "auto" ? jt(e, t) : n,
538
+ endSide: s === "auto" ? kt[jt(e, t)] : s
539
+ }), St = (e, t, {
510
540
  index: n = 0,
511
541
  count: s = 1,
512
- spacing: o = 16,
542
+ spacing: r = 16,
513
543
  gap: i = 0
514
544
  } = {}) => {
515
- const c = t === "top" || t === "bottom" ? e.width : e.height, a = s > 1 ? Math.min(o, c / s) : 0, h = (n - (s - 1) / 2) * a, { x: f, y: d } = J(e);
545
+ const c = t === "top" || t === "bottom" ? e.width : e.height, a = s > 1 ? Math.min(r, c / s) : 0, h = (n - (s - 1) / 2) * a, { x: d, y: f } = Q(e);
516
546
  let u;
517
547
  switch (t) {
518
548
  case "top":
519
- u = { x: f + h, y: e.top };
549
+ u = { x: d + h, y: e.top };
520
550
  break;
521
551
  case "bottom":
522
- u = { x: f + h, y: e.bottom };
552
+ u = { x: d + h, y: e.bottom };
523
553
  break;
524
554
  case "left":
525
- u = { x: e.left, y: d + h };
555
+ u = { x: e.left, y: f + h };
526
556
  break;
527
557
  case "right":
528
- u = { x: e.right, y: d + h };
558
+ u = { x: e.right, y: f + h };
529
559
  break;
530
560
  }
531
- return q(u, B[t], i);
532
- }, ot = (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : setTimeout(e, 16), rt = (e) => {
561
+ return X(u, Y[t], i);
562
+ }, it = (e) => typeof requestAnimationFrame == "function" ? requestAnimationFrame(e) : setTimeout(e, 16), ct = (e) => {
533
563
  typeof cancelAnimationFrame == "function" ? cancelAnimationFrame(e) : clearTimeout(e);
534
564
  };
535
- var W, b, v, L, T, x, D, U, g, lt, ut, ft, S, Nt;
536
- class te {
565
+ var D, b, j, F, N, x, U, q, w, ft, pt, yt, z, _t;
566
+ class se {
537
567
  /**
538
568
  * @throws {TypeError} When an option has the wrong type.
539
569
  * @throws {RangeError} When an option is out of range.
@@ -541,31 +571,31 @@ class te {
541
571
  * found.
542
572
  */
543
573
  constructor(t = {}) {
544
- p(this, g);
574
+ p(this, w);
545
575
  /**
546
576
  * The element the overlay was added to.
547
577
  */
548
- z(this, "container");
578
+ M(this, "container");
549
579
  /**
550
580
  * The SVG overlay all lines are drawn in.
551
581
  */
552
- z(this, "svg");
553
- p(this, W);
582
+ M(this, "svg");
583
+ p(this, D);
554
584
  p(this, b, /* @__PURE__ */ new Map());
555
- p(this, v, 0);
556
- p(this, L, 0);
557
- p(this, T, !1);
585
+ p(this, j, 0);
586
+ p(this, F, 0);
587
+ p(this, N, !1);
558
588
  p(this, x, null);
559
- p(this, D, null);
560
589
  p(this, U, null);
561
- p(this, S, () => {
562
- r(this, v) || r(this, T) || l(this, v, ot(() => {
563
- l(this, v, 0), this.update();
590
+ p(this, q, null);
591
+ p(this, z, () => {
592
+ o(this, j) || o(this, N) || l(this, j, it(() => {
593
+ l(this, j, 0), this.update();
564
594
  }));
565
595
  });
566
596
  if (typeof document > "u")
567
- throw new N("a DOM is required");
568
- l(this, W, Wt(t)), this.container = t.container ? V(t.container, "container") : document.body, this.container !== document.body && getComputedStyle(this.container).position === "static" && (l(this, U, this.container.style.position), this.container.style.position = "relative"), this.svg = M("svg", {
597
+ throw new R("a DOM is required");
598
+ l(this, D, Ut(t)), this.container = t.container ? K(t.container, "container") : document.body, this.container !== document.body && getComputedStyle(this.container).position === "static" && (l(this, q, this.container.style.position), this.container.style.position = "relative"), this.svg = P("svg", {
569
599
  class: ["arc-svg", t.className].filter(Boolean).join(" "),
570
600
  "aria-hidden": "true"
571
601
  }), Object.assign(this.svg.style, {
@@ -576,13 +606,13 @@ class te {
576
606
  height: "100%",
577
607
  overflow: "visible",
578
608
  pointerEvents: "none"
579
- }), this.container.prepend(this.svg), y(this, g, Nt).call(this);
609
+ }), this.container.prepend(this.svg), m(this, w, _t).call(this);
580
610
  }
581
611
  /**
582
612
  * All current connections, in the order they were made.
583
613
  */
584
614
  get connections() {
585
- return [...r(this, b).values()];
615
+ return [...o(this, b).values()];
586
616
  }
587
617
  /**
588
618
  * Connects two elements and draws the line right away.
@@ -600,8 +630,8 @@ class te {
600
630
  * ```
601
631
  */
602
632
  connect(t, n, s = {}) {
603
- const o = y(this, g, ut).call(this, y(this, g, lt).call(this, t, n, s, "options"));
604
- return this.update(), o;
633
+ const r = m(this, w, pt).call(this, m(this, w, ft).call(this, t, n, s, "options"));
634
+ return this.update(), r;
605
635
  }
606
636
  /**
607
637
  * Connects many pairs of elements and draws them in one go. Every
@@ -625,23 +655,23 @@ class te {
625
655
  throw new TypeError(
626
656
  "arclace: connectAll() needs an array of definitions"
627
657
  );
628
- const n = /* @__PURE__ */ new Set(), o = t.map((i, c) => {
658
+ const n = /* @__PURE__ */ new Set(), r = t.map((i, c) => {
629
659
  const a = `definitions[${c}]`;
630
- Z(i, a);
631
- const { startElement: h, endElement: f, ...d } = i, u = y(this, g, lt).call(this, h, f, d, a);
660
+ et(i, a);
661
+ const { startElement: h, endElement: d, ...f } = i, u = m(this, w, ft).call(this, h, d, f, a);
632
662
  if (n.has(u.id))
633
- throw new N(
663
+ throw new R(
634
664
  `${a}.id "${u.id}" is used more than once`
635
665
  );
636
666
  return n.add(u.id), u;
637
- }).map((i) => y(this, g, ut).call(this, i));
638
- return this.update(), o;
667
+ }).map((i) => m(this, w, pt).call(this, i));
668
+ return this.update(), r;
639
669
  }
640
670
  /**
641
671
  * Returns the connection with the given id.
642
672
  */
643
673
  get(t) {
644
- return r(this, b).get(t);
674
+ return o(this, b).get(t);
645
675
  }
646
676
  /**
647
677
  * Returns every connection that starts or ends at an element. A selector
@@ -651,7 +681,7 @@ class te {
651
681
  * @throws {ArclaceError} When the selector is invalid.
652
682
  */
653
683
  find(t) {
654
- const n = typeof t == "string" ? Ct(t) : V(t);
684
+ const n = typeof t == "string" ? Rt(t) : K(t);
655
685
  return n ? this.connections.filter(
656
686
  (s) => s.startElement === n || s.endElement === n
657
687
  ) : [];
@@ -675,10 +705,10 @@ class te {
675
705
  disconnect(t) {
676
706
  let n;
677
707
  if (t != null) {
678
- if (t instanceof Q)
708
+ if (t instanceof tt)
679
709
  n = [t];
680
- else if (typeof t == "string" && r(this, b).has(t))
681
- n = [r(this, b).get(t)];
710
+ else if (typeof t == "string" && o(this, b).has(t))
711
+ n = [o(this, b).get(t)];
682
712
  else if (typeof t == "string" || t instanceof Element)
683
713
  n = this.find(t);
684
714
  else
@@ -686,7 +716,7 @@ class te {
686
716
  "arclace: disconnect() needs a connection, an id, an element or a selector"
687
717
  );
688
718
  for (const s of n)
689
- r(this, b).get(s.id) === s && (r(this, b).delete(s.id), s._dispose(), y(this, g, ft).call(this, s.startElement), y(this, g, ft).call(this, s.endElement));
719
+ o(this, b).get(s.id) === s && (o(this, b).delete(s.id), s._dispose(), m(this, w, yt).call(this, s.startElement), m(this, w, yt).call(this, s.endElement));
690
720
  n.length > 0 && this.update();
691
721
  }
692
722
  }
@@ -695,9 +725,9 @@ class te {
695
725
  */
696
726
  clear() {
697
727
  var t;
698
- for (const n of r(this, b).values())
728
+ for (const n of o(this, b).values())
699
729
  n._dispose();
700
- r(this, b).clear(), (t = r(this, x)) == null || t.disconnect(), r(this, x) && r(this, x).observe(this.container);
730
+ o(this, b).clear(), (t = o(this, x)) == null || t.disconnect(), o(this, x) && o(this, x).observe(this.container);
701
731
  }
702
732
  /**
703
733
  * Remeasures every element and redraws every connection. Called
@@ -705,29 +735,29 @@ class te {
705
735
  * elements in ways the page can't observe.
706
736
  */
707
737
  update() {
708
- if (r(this, T)) return;
709
- r(this, v) && (rt(r(this, v)), l(this, v, 0));
710
- const t = Qt(this.svg), n = [], s = /* @__PURE__ */ new Map(), o = (i, c, a) => {
711
- const h = { index: 0, count: 1 }, f = J(a);
738
+ if (o(this, N)) return;
739
+ o(this, j) && (ct(o(this, j)), l(this, j, 0));
740
+ const t = ee(this.svg), n = [], s = /* @__PURE__ */ new Map(), r = (i, c, a) => {
741
+ const h = { index: 0, count: 1 }, d = Q(a);
712
742
  return s.has(i) || s.set(i, { top: [], right: [], bottom: [], left: [] }), s.get(i)[c].push({
713
743
  slot: h,
714
- key: it(c) ? f.y : f.x
744
+ key: at(c) ? d.y : d.x
715
745
  }), h;
716
746
  };
717
- for (const i of r(this, b).values()) {
747
+ for (const i of o(this, b).values()) {
718
748
  const { startElement: c, endElement: a } = i;
719
- if (!Ot(c) || !Ot(a)) {
749
+ if (!At(c) || !At(a)) {
720
750
  i._hide();
721
751
  continue;
722
752
  }
723
- const { spread: h, startSide: f, endSide: d } = i.options, u = Et(c, t), k = Et(a, t), tt = Zt(u, k, f, d), yt = { index: 0, count: 1 };
753
+ const { spread: h, startSide: d, endSide: f } = i.options, u = vt(c, t), $ = vt(a, t), nt = ne(u, $, d, f), gt = { index: 0, count: 1 };
724
754
  n.push({
725
755
  connection: i,
726
756
  startRect: u,
727
- endRect: k,
728
- ...tt,
729
- startSlot: h ? o(c, tt.startSide, k) : yt,
730
- endSlot: h ? o(a, tt.endSide, u) : { ...yt }
757
+ endRect: $,
758
+ ...nt,
759
+ startSlot: h ? r(c, nt.startSide, $) : gt,
760
+ endSlot: h ? r(a, nt.endSide, u) : { ...gt }
731
761
  });
732
762
  }
733
763
  for (const i of s.values())
@@ -736,16 +766,16 @@ class te {
736
766
  a.slot.index = h, a.slot.count = c.length;
737
767
  });
738
768
  for (const i of n) {
739
- const { connection: c, startRect: a, endRect: h, startSide: f, endSide: d } = i, { spacing: u, gap: k } = c.options;
769
+ const { connection: c, startRect: a, endRect: h, startSide: d, endSide: f } = i, { spacing: u, gap: $ } = c.options;
740
770
  c._draw(
741
- vt(a, f, {
771
+ St(a, d, {
742
772
  ...i.startSlot,
743
773
  spacing: u,
744
- gap: k
774
+ gap: $
745
775
  }),
746
- f,
747
- vt(h, d, { ...i.endSlot, spacing: u, gap: k }),
748
- d
776
+ d,
777
+ St(h, f, { ...i.endSlot, spacing: u, gap: $ }),
778
+ f
749
779
  );
750
780
  }
751
781
  }
@@ -755,70 +785,70 @@ class te {
755
785
  */
756
786
  destroy() {
757
787
  var t, n;
758
- r(this, T) || (this.clear(), l(this, T, !0), r(this, v) && rt(r(this, v)), r(this, L) && rt(r(this, L)), window.removeEventListener("resize", r(this, S)), document.removeEventListener("scroll", r(this, S), {
788
+ o(this, N) || (this.clear(), l(this, N, !0), o(this, j) && ct(o(this, j)), o(this, F) && ct(o(this, F)), window.removeEventListener("resize", o(this, z)), document.removeEventListener("scroll", o(this, z), {
759
789
  capture: !0
760
- }), (t = r(this, x)) == null || t.disconnect(), (n = r(this, D)) == null || n.disconnect(), this.svg.remove(), r(this, U) !== null && (this.container.style.position = r(this, U)));
790
+ }), (t = o(this, x)) == null || t.disconnect(), (n = o(this, U)) == null || n.disconnect(), this.svg.remove(), o(this, q) !== null && (this.container.style.position = o(this, q)));
761
791
  }
762
792
  }
763
- W = new WeakMap(), b = new WeakMap(), v = new WeakMap(), L = new WeakMap(), T = new WeakMap(), x = new WeakMap(), D = new WeakMap(), U = new WeakMap(), g = new WeakSet(), /**
793
+ D = new WeakMap(), b = new WeakMap(), j = new WeakMap(), F = new WeakMap(), N = new WeakMap(), x = new WeakMap(), U = new WeakMap(), q = new WeakMap(), w = new WeakSet(), /**
764
794
  * Checks a connection without adding anything, so a bad option can't leave
765
795
  * a connection behind that breaks every later update.
766
796
  */
767
- lt = function(t, n, s, o) {
768
- if (r(this, T))
769
- throw new N("this instance has been destroyed");
770
- dt(s, o);
771
- const i = V(t, "startElement"), c = V(n, "endElement"), a = s, h = a.id ?? `arc-${jt()}`;
772
- if (r(this, b).has(h))
773
- throw new N(`a connection with id "${h}" exists`);
797
+ ft = function(t, n, s, r) {
798
+ if (o(this, N))
799
+ throw new R("this instance has been destroyed");
800
+ mt(s, r);
801
+ const i = K(t, "startElement"), c = K(n, "endElement"), a = s, h = a.id ?? `arc-${zt()}`;
802
+ if (o(this, b).has(h))
803
+ throw new R(`a connection with id "${h}" exists`);
774
804
  return { id: h, startElement: i, endElement: c, options: a };
775
- }, ut = function({
805
+ }, pt = function({
776
806
  id: t,
777
807
  startElement: n,
778
808
  endElement: s,
779
- options: o
809
+ options: r
780
810
  }) {
781
811
  var c, a;
782
- const i = Q._create({
812
+ const i = tt._create({
783
813
  id: t,
784
814
  startElement: n,
785
815
  endElement: s,
786
- options: o,
787
- defaults: r(this, W).defaults,
816
+ options: r,
817
+ defaults: o(this, D).defaults,
788
818
  owner: this
789
819
  });
790
- return r(this, b).set(t, i), this.svg.appendChild(i.element), (c = r(this, x)) == null || c.observe(n), (a = r(this, x)) == null || a.observe(s), i;
791
- }, ft = function(t) {
792
- if (!r(this, x) || t === this.container) return;
820
+ return o(this, b).set(t, i), this.svg.appendChild(i.element), (c = o(this, x)) == null || c.observe(n), (a = o(this, x)) == null || a.observe(s), i;
821
+ }, yt = function(t) {
822
+ if (!o(this, x) || t === this.container) return;
793
823
  this.connections.some(
794
824
  (s) => s.startElement === t || s.endElement === t
795
- ) || r(this, x).unobserve(t);
796
- }, S = new WeakMap(), Nt = function() {
825
+ ) || o(this, x).unobserve(t);
826
+ }, z = new WeakMap(), _t = function() {
797
827
  var n;
798
- const { autoUpdate: t = !0 } = r(this, W);
828
+ const { autoUpdate: t = !0 } = o(this, D);
799
829
  if (t !== !1) {
800
830
  if (t === "frame") {
801
831
  const s = () => {
802
- this.update(), l(this, L, ot(s));
832
+ this.update(), l(this, F, it(s));
803
833
  };
804
- l(this, L, ot(s));
834
+ l(this, F, it(s));
805
835
  return;
806
836
  }
807
- window.addEventListener("resize", r(this, S)), document.addEventListener("scroll", r(this, S), {
837
+ window.addEventListener("resize", o(this, z)), document.addEventListener("scroll", o(this, z), {
808
838
  capture: !0,
809
839
  passive: !0
810
- }), typeof ResizeObserver < "u" && (l(this, x, new ResizeObserver(r(this, S))), r(this, x).observe(this.container)), typeof MutationObserver < "u" && (l(this, D, new MutationObserver((s) => {
811
- s.some((o) => !this.svg.contains(o.target)) && r(this, S).call(this);
812
- })), r(this, D).observe(this.container, {
840
+ }), typeof ResizeObserver < "u" && (l(this, x, new ResizeObserver(o(this, z))), o(this, x).observe(this.container)), typeof MutationObserver < "u" && (l(this, U, new MutationObserver((s) => {
841
+ s.some((r) => !this.svg.contains(r.target)) && o(this, z).call(this);
842
+ })), o(this, U).observe(this.container, {
813
843
  subtree: !0,
814
844
  childList: !0,
815
845
  attributes: !0,
816
846
  attributeFilter: ["style", "class", "hidden"]
817
- })), (n = document.fonts) == null || n.ready.then(r(this, S));
847
+ })), (n = document.fonts) == null || n.ready.then(o(this, z));
818
848
  }
819
849
  };
820
- const ne = (e, t) => {
821
- const n = new te(t);
850
+ const re = (e, t) => {
851
+ const n = new se(t);
822
852
  try {
823
853
  n.connectAll(e);
824
854
  } catch (s) {
@@ -827,13 +857,13 @@ const ne = (e, t) => {
827
857
  return n;
828
858
  };
829
859
  export {
830
- te as Arclace,
831
- N as ArclaceError,
832
- Q as Connection,
833
- Kt as DEFAULT_CONNECTION_OPTIONS,
834
- Yt as bezierPath,
835
- ne as createConnections,
836
- Vt as orthogonalPath,
837
- qt as straightPath
860
+ se as Arclace,
861
+ R as ArclaceError,
862
+ tt as Connection,
863
+ te as DEFAULT_CONNECTION_OPTIONS,
864
+ Gt as bezierPath,
865
+ re as createConnections,
866
+ Qt as orthogonalPath,
867
+ Ht as straightPath
838
868
  };
839
869
  //# sourceMappingURL=arclace.js.map