@bigplay/tree-view-core 0.3.1 → 0.4.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/index.js CHANGED
@@ -1,47 +1,48 @@
1
- const U = {
1
+ const H = {
2
2
  nodeWidth: 180,
3
3
  nodeHeight: 64,
4
4
  levelGap: 60,
5
5
  siblingGap: 16,
6
6
  direction: "top-to-bottom",
7
- linkStyle: "elbow"
7
+ linkStyle: "elbow",
8
+ levelLayout: "tree"
8
9
  };
9
- function Y(e) {
10
- return { ...U, ...e };
10
+ function G(e) {
11
+ return { ...H, ...e };
11
12
  }
12
- function X(e) {
13
+ function U(e) {
13
14
  return e?.children;
14
15
  }
15
- function W(e) {
16
+ function R(e) {
16
17
  return e?.id;
17
18
  }
18
- function at(e, t = {}) {
19
+ function ut(e, t = {}) {
19
20
  if (e == null) return [];
20
21
  const n = Array.isArray(e) ? e : [e];
21
- return n.length === 0 ? [] : t.getParentId ? F(n, t) : G(n, t);
22
+ return n.length === 0 ? [] : t.getParentId ? X(n, t) : Y(n, t);
22
23
  }
23
- function G(e, t) {
24
- const n = t.getId ?? W, i = t.getChildren ?? X, o = /* @__PURE__ */ new Set();
24
+ function Y(e, t) {
25
+ const n = t.getId ?? R, i = t.getChildren ?? U, o = /* @__PURE__ */ new Set();
25
26
  function s(r, h, c, l) {
26
- const d = k(n(r), l);
27
- A(d, o);
28
- const p = (i(r) ?? []).map((a, f) => s(a, h + 1, d, `${l}.${f}`));
29
- return { id: d, data: r, depth: h, parentId: c, children: p, hasChildren: p.length > 0, collapsed: !1 };
27
+ const a = A(n(r), l);
28
+ W(a, o);
29
+ const u = (i(r) ?? []).map((f, p) => s(f, h + 1, a, `${l}.${p}`));
30
+ return { id: a, data: r, depth: h, parentId: c, children: u, hasChildren: u.length > 0, collapsed: !1 };
30
31
  }
31
32
  return e.map((r, h) => s(r, 0, null, String(h)));
32
33
  }
33
- function F(e, t) {
34
- const n = t.getId ?? W, i = /* @__PURE__ */ new Set(), o = e.map((c, l) => {
35
- const d = k(n(c), String(l));
36
- return A(d, i), { id: d, data: c, depth: 0, parentId: null, children: [], hasChildren: !1, collapsed: !1 };
34
+ function X(e, t) {
35
+ const n = t.getId ?? R, i = /* @__PURE__ */ new Set(), o = e.map((c, l) => {
36
+ const a = A(n(c), String(l));
37
+ return W(a, i), { id: a, data: c, depth: 0, parentId: null, children: [], hasChildren: !1, collapsed: !1 };
37
38
  }), s = new Map(o.map((c) => [c.id, c])), r = [];
38
39
  if (o.forEach((c, l) => {
39
- const d = t.getParentId(e[l]), u = d == null ? void 0 : s.get(String(d));
40
- if (!u) {
40
+ const a = t.getParentId(e[l]), d = a == null ? void 0 : s.get(String(a));
41
+ if (!d) {
41
42
  r.push(c);
42
43
  return;
43
44
  }
44
- c.parentId = u.id, u.children.push(c), u.hasChildren = !0;
45
+ c.parentId = d.id, d.children.push(c), d.hasChildren = !0;
45
46
  }), N(r) !== o.length)
46
47
  throw new Error("[tree-view] В данных есть цикл: часть узлов ссылается друг на друга по кругу.");
47
48
  return r;
@@ -55,20 +56,20 @@ function N(e) {
55
56
  }
56
57
  return t.length;
57
58
  }
58
- function k(e, t) {
59
+ function A(e, t) {
59
60
  return e == null || e === "" ? t : String(e);
60
61
  }
61
- function A(e, t) {
62
+ function W(e, t) {
62
63
  if (t.has(e))
63
64
  throw new Error(`[tree-view] Повторяющийся id узла: "${e}". Идентификаторы должны быть уникальными.`);
64
65
  t.add(e);
65
66
  }
66
- function dt(e, t = {}) {
67
+ function ft(e, t = {}) {
67
68
  const n = e.filter((s) => s.length > 0);
68
69
  if (n.length === 0) return [];
69
70
  const i = n.length - 1, o = n.map(
70
71
  (s, r) => s.map((h, c) => ({
71
- id: V(h, r, c, t.getId),
72
+ id: F(h, r, c, t.getId),
72
73
  data: h,
73
74
  // Финал — корень, поэтому глубина считается от последнего уровня.
74
75
  depth: i - r,
@@ -80,18 +81,18 @@ function dt(e, t = {}) {
80
81
  );
81
82
  for (let s = 0; s < i; s += 1) {
82
83
  const r = o[s], h = o[s + 1], c = Math.ceil(r.length / h.length);
83
- r.forEach((l, d) => {
84
- const u = h[Math.min(Math.floor(d / c), h.length - 1)];
85
- l.parentId = u.id, u.children.push(l), u.hasChildren = !0;
84
+ r.forEach((l, a) => {
85
+ const d = h[Math.min(Math.floor(a / c), h.length - 1)];
86
+ l.parentId = d.id, d.children.push(l), d.hasChildren = !0;
86
87
  });
87
88
  }
88
89
  return o[i];
89
90
  }
90
- function V(e, t, n, i) {
91
+ function F(e, t, n, i) {
91
92
  const o = i ? i(e, t, n) : e?.id;
92
93
  return o == null || o === "" ? `${t}.${n}` : String(o);
93
94
  }
94
- function ut(e, t) {
95
+ function pt(e, t) {
95
96
  if (t.size === 0) return e;
96
97
  function n(i) {
97
98
  const o = t.has(i.id);
@@ -103,13 +104,13 @@ function ut(e, t) {
103
104
  }
104
105
  return e.map(n);
105
106
  }
106
- function ft(e, t) {
107
+ function gt(e, t) {
107
108
  const n = new Set(e);
108
109
  return n.delete(t) || n.add(t), n;
109
110
  }
110
- const _ = 2, Z = 40;
111
- function pt(e, t = {}) {
112
- const n = e?.teams ?? [], i = Math.max(t.rows ?? _, n.length), o = t.techDefeatLabel ?? "ТП", s = n.map((r, h) => {
111
+ const z = 2, V = 40;
112
+ function mt(e, t = {}) {
113
+ const n = e?.teams ?? [], i = Math.max(t.rows ?? z, n.length), o = t.techDefeatLabel ?? "ТП", s = n.map((r, h) => {
113
114
  const c = r.isTechDefeat === !0, l = r.isWinner === !0;
114
115
  return {
115
116
  key: String(r.id ?? `team-${h}`),
@@ -135,48 +136,61 @@ function pt(e, t = {}) {
135
136
  });
136
137
  return { rows: s, hasMyTeam: n.some((r) => r.isMyTeam === !0) };
137
138
  }
138
- function mt(e, t = {}) {
139
+ function wt(e, t = {}) {
139
140
  const n = e?.teams ?? [];
140
- return Math.max(t.rows ?? _, n.length) * (t.rowHeight ?? Z);
141
+ return Math.max(t.rows ?? z, n.length) * (t.rowHeight ?? V);
141
142
  }
142
- const $ = { min: 0.2, max: 3 }, M = { x: 0, y: 0, scale: 1 };
143
- function v(e, t, n) {
143
+ const I = { min: 0.2, max: 3 }, S = { x: 0, y: 0, scale: 1 };
144
+ function L(e, t, n) {
144
145
  return Math.min(Math.max(e, t), n);
145
146
  }
146
- function q(e, t, n = 24, i = $) {
147
+ function Z(e, t, n = 24, i = I) {
147
148
  if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0)
148
- return { ...M };
149
- const o = Math.max(t.width - n * 2, 1), s = Math.max(t.height - n * 2, 1), r = Math.min(o / e.width, s / e.height, 1), h = v(r, i.min, i.max);
149
+ return { ...S };
150
+ const o = Math.max(t.width - n * 2, 1), s = Math.max(t.height - n * 2, 1), r = Math.min(o / e.width, s / e.height, 1), h = L(r, i.min, i.max);
150
151
  return {
151
152
  scale: h,
152
153
  x: (t.width - e.width * h) / 2,
153
154
  y: (t.height - e.height * h) / 2
154
155
  };
155
156
  }
156
- function K(e, t, n) {
157
+ function q(e, t, n) {
157
158
  return { ...e, x: e.x + t, y: e.y + n };
158
159
  }
159
- function L(e, t, n, i = $) {
160
- const o = v(e.scale * t, i.min, i.max);
160
+ function $(e, t, n, i = I) {
161
+ const o = L(e.scale * t, i.min, i.max);
161
162
  if (o === e.scale) return e;
162
163
  const s = (n.x - e.x) / e.scale, r = (n.y - e.y) / e.scale;
163
164
  return { scale: o, x: n.x - s * o, y: n.y - r * o };
164
165
  }
165
- function gt(e) {
166
+ function yt(e) {
166
167
  return `translate(${e.x}px, ${e.y}px) scale(${e.scale})`;
167
168
  }
168
- function wt(e, t) {
169
+ function xt(e, t) {
169
170
  const n = t.nodeWidth + t.levelGap, i = (e ?? []).map((o, s) => {
170
171
  const r = o.id ?? s;
171
172
  return { key: String(r), id: r, name: o.name, index: s, width: n };
172
173
  });
173
174
  return { columns: i, width: n * i.length, offset: t.levelGap / 2 };
174
175
  }
175
- function yt(e) {
176
+ function Et(e) {
176
177
  const t = e.left + e.width / 2 - e.viewport / 2;
177
- return v(t, 0, Math.max(0, e.scrollWidth - e.viewport));
178
+ return L(t, 0, Math.max(0, e.scrollWidth - e.viewport));
179
+ }
180
+ function Mt(e, t) {
181
+ return Math.max(0, e - t);
182
+ }
183
+ function Lt(e, t, n) {
184
+ return t <= 0 || n <= 0 ? 0 : L(Math.round(e / t), 0, n - 1);
178
185
  }
179
- function xt(e) {
186
+ function vt(e, t, n) {
187
+ return n ? t - 1 - e : e;
188
+ }
189
+ const K = 4;
190
+ function Ct(e, t) {
191
+ return t * L(e, 1, K);
192
+ }
193
+ function bt(e) {
180
194
  if (typeof window > "u") return null;
181
195
  let t = e?.parentElement ?? null;
182
196
  for (; t; ) {
@@ -186,7 +200,7 @@ function xt(e) {
186
200
  }
187
201
  return null;
188
202
  }
189
- function Et(e, t) {
203
+ function $t(e, t) {
190
204
  if (typeof e.scrollTo == "function") {
191
205
  e.scrollTo({ left: t, behavior: "smooth" });
192
206
  return;
@@ -197,30 +211,51 @@ function j(e, t) {
197
211
  return e.getBoundingClientRect().left - t.getBoundingClientRect().left + t.scrollLeft;
198
212
  }
199
213
  const Q = ".tree-view__node";
200
- function Ct(e, t, n, i) {
214
+ function St(e, t, n, i) {
201
215
  const o = e.getBoundingClientRect().left + i;
202
216
  return Array.from(e.querySelectorAll(Q)).filter((r) => {
203
217
  const h = r.getBoundingClientRect();
204
218
  return Math.floor((h.left + h.width / 2 - o) / n) === t;
205
219
  });
206
220
  }
207
- function Lt(e, t) {
221
+ function It(e, t) {
208
222
  return { left: j(e, t), width: e.getBoundingClientRect().width };
209
223
  }
210
- const Mt = "(max-width: 768px)";
211
- function $t(e, t) {
224
+ const J = "tv-hidden";
225
+ function Pt(e, t, n) {
226
+ e.querySelectorAll("[data-depth]").forEach((i) => {
227
+ const o = Number(i.getAttribute("data-depth"));
228
+ i.classList.toggle(J, n(o) < t);
229
+ });
230
+ }
231
+ const Tt = "(max-width: 768px)";
232
+ function Dt(e, t) {
212
233
  if (typeof window > "u" || typeof window.matchMedia != "function") return () => {
213
234
  };
214
235
  const n = window.matchMedia(e), i = () => t(n.matches);
215
236
  return i(), typeof n.addEventListener == "function" ? (n.addEventListener("change", i), () => n.removeEventListener("change", i)) : (n.addListener(i), () => n.removeListener(i));
216
237
  }
217
- function m(e) {
238
+ function Rt(e, t) {
239
+ if (!e) return () => {
240
+ };
241
+ if (t(e.clientWidth), typeof ResizeObserver > "u") return () => {
242
+ };
243
+ const n = new ResizeObserver(() => t(e.clientWidth));
244
+ return n.observe(e), () => n.disconnect();
245
+ }
246
+ function At(e, t) {
247
+ if (!e || typeof MutationObserver > "u") return () => {
248
+ };
249
+ const n = new MutationObserver(t);
250
+ return n.observe(e, { childList: !0, subtree: !0 }), () => n.disconnect();
251
+ }
252
+ function E(e) {
218
253
  return Math.round(e * 100) / 100;
219
254
  }
220
- function J(e) {
255
+ function tt(e) {
221
256
  return e === "top-to-bottom" || e === "bottom-to-top";
222
257
  }
223
- function tt(e, t, n) {
258
+ function et(e, t, n) {
224
259
  const i = e.x + e.width / 2, o = e.y + e.height / 2, s = t.x + t.width / 2, r = t.y + t.height / 2;
225
260
  switch (n) {
226
261
  case "top-to-bottom":
@@ -233,102 +268,138 @@ function tt(e, t, n) {
233
268
  return { from: { x: e.x, y: o }, to: { x: t.x + t.width, y: r } };
234
269
  }
235
270
  }
236
- function et(e, t, n, i) {
237
- const o = m(e.x), s = m(e.y), r = m(t.x), h = m(t.y);
271
+ function nt(e, t, n, i) {
272
+ const o = E(e.x), s = E(e.y), r = E(t.x), h = E(t.y);
238
273
  if (n === "straight")
239
274
  return `M ${o} ${s} L ${r} ${h}`;
240
- const c = J(i), l = m((o + r) / 2), d = m((s + h) / 2);
241
- return n === "elbow" ? c ? `M ${o} ${s} L ${o} ${d} L ${r} ${d} L ${r} ${h}` : `M ${o} ${s} L ${l} ${s} L ${l} ${h} L ${r} ${h}` : c ? `M ${o} ${s} C ${o} ${d} ${r} ${d} ${r} ${h}` : `M ${o} ${s} C ${l} ${s} ${l} ${h} ${r} ${h}`;
275
+ const c = tt(i), l = E((o + r) / 2), a = E((s + h) / 2);
276
+ return n === "elbow" ? c ? `M ${o} ${s} L ${o} ${a} L ${r} ${a} L ${r} ${h}` : `M ${o} ${s} L ${l} ${s} L ${l} ${h} L ${r} ${h}` : c ? `M ${o} ${s} C ${o} ${a} ${r} ${a} ${r} ${h}` : `M ${o} ${s} C ${l} ${s} ${l} ${h} ${r} ${h}`;
242
277
  }
243
- function nt(e, t) {
278
+ function it(e, t) {
244
279
  const n = new Map(e.map((o) => [o.id, o])), i = [];
245
280
  for (const o of e) {
246
281
  const s = o.parentId == null ? void 0 : n.get(o.parentId);
247
282
  if (!s) continue;
248
- const { from: r, to: h } = tt(s, o, t.direction);
283
+ const { from: r, to: h } = et(s, o, t.direction);
249
284
  i.push({
250
285
  id: `${s.id}->${o.id}`,
251
286
  source: s,
252
287
  target: o,
253
- path: et(r, h, t.linkStyle, t.direction)
288
+ path: nt(r, h, t.linkStyle, t.direction)
254
289
  });
255
290
  }
256
291
  return i;
257
292
  }
258
- function R(e, t) {
293
+ function C(e, t) {
259
294
  return typeof e == "function" ? e(t) : e;
260
295
  }
261
- function it(e, t) {
262
- const n = t.direction === "top-to-bottom" || t.direction === "bottom-to-top", i = /* @__PURE__ */ new Map(), o = [];
296
+ function O(e, t, n) {
297
+ return typeof e == "function" ? e(t, n) : e;
298
+ }
299
+ function ot(e) {
300
+ const t = [];
301
+ for (const n of P(e)) t[n.depth] = (t[n.depth] ?? 0) + 1;
302
+ return t;
303
+ }
304
+ function k(e, t, n) {
305
+ const i = [];
306
+ let o = 0;
307
+ for (let c = 0; c < t.length; c += 1)
308
+ i[c] = o, o += (t[c] ?? 0) + n;
263
309
  let s = 0;
264
- const r = [];
265
- function h(a) {
266
- const f = R(t.nodeWidth, a), I = R(t.nodeHeight, a), S = n ? I : f, y = n ? f : I;
267
- r[a.depth] = Math.max(r[a.depth] ?? 0, S);
268
- const T = s, O = o.length;
269
- let g = s;
270
- if (a.children.length > 0) {
271
- const E = a.children.map(h), P = E[0], b = E[E.length - 1], B = P.across + P.acrossSize / 2, H = b.across + b.acrossSize / 2;
272
- g = (B + H) / 2 - y / 2;
273
- const D = T - g;
274
- if (D > 0) {
275
- for (let C = O; C < o.length; C += 1) o[C].across += D;
276
- g = T;
310
+ for (const c of e) {
311
+ const l = t[c.depth] ?? c.alongSize;
312
+ c.along = i[c.depth] + (l - c.alongSize) / 2, s = Math.max(s, c.across + c.acrossSize);
313
+ }
314
+ const r = t.length - 1;
315
+ return { alongExtent: r < 0 ? 0 : i[r] + t[r], acrossExtent: s };
316
+ }
317
+ function rt(e, t) {
318
+ const n = t.direction === "top-to-bottom" || t.direction === "bottom-to-top", i = /* @__PURE__ */ new Map(), o = [], s = [], r = [];
319
+ for (const a of P(e)) (r[a.depth] ??= []).push(a);
320
+ const h = [], c = [];
321
+ r.forEach((a, d) => {
322
+ const u = [];
323
+ let f = 0;
324
+ for (const m of a) {
325
+ const g = C(t.nodeWidth, m), w = C(t.nodeHeight, m), y = n ? w : g, M = n ? g : w;
326
+ s[d] = Math.max(s[d] ?? 0, y);
327
+ const x = { depth: d, along: 0, across: f, alongSize: y, acrossSize: M };
328
+ i.set(m.id, x), u.push(x), o.push(x), f += M + O(t.siblingGap, m, a.length);
329
+ }
330
+ const p = u[u.length - 1];
331
+ h[d] = u, c[d] = p ? p.across + p.acrossSize : 0;
332
+ });
333
+ const l = Math.max(0, ...c);
334
+ return h.forEach((a, d) => {
335
+ const u = (l - (c[d] ?? 0)) / 2;
336
+ if (u > 0) for (const f of a) f.across += u;
337
+ }), { byId: i, ...k(o, s, t.levelGap) };
338
+ }
339
+ function st(e, t) {
340
+ if (t.levelLayout === "stack") return rt(e, t);
341
+ const n = t.direction === "top-to-bottom" || t.direction === "bottom-to-top", i = ot(e), o = /* @__PURE__ */ new Map(), s = [];
342
+ let r = 0;
343
+ const h = [];
344
+ function c(l) {
345
+ const a = C(t.nodeWidth, l), d = C(t.nodeHeight, l), u = n ? d : a, f = n ? a : d;
346
+ h[l.depth] = Math.max(h[l.depth] ?? 0, u);
347
+ const p = r, m = s.length;
348
+ let g = r;
349
+ if (l.children.length > 0) {
350
+ const y = l.children.map(c), M = y[0], x = y[y.length - 1], _ = M.across + M.acrossSize / 2, B = x.across + x.acrossSize / 2;
351
+ g = (_ + B) / 2 - f / 2;
352
+ const T = p - g;
353
+ if (T > 0) {
354
+ for (let b = m; b < s.length; b += 1) s[b].across += T;
355
+ g = p;
277
356
  }
278
357
  }
279
- const x = { depth: a.depth, along: 0, across: g, alongSize: S, acrossSize: y };
280
- return i.set(a.id, x), o.push(x), s = Math.max(s, g + y + t.siblingGap), x;
281
- }
282
- e.forEach(h);
283
- const c = [];
284
- let l = 0;
285
- for (let a = 0; a < r.length; a += 1)
286
- c[a] = l, l += (r[a] ?? 0) + t.levelGap;
287
- let d = 0;
288
- for (const a of o) {
289
- const f = r[a.depth] ?? a.alongSize;
290
- a.along = c[a.depth] + (f - a.alongSize) / 2, d = Math.max(d, a.across + a.acrossSize);
358
+ const w = { depth: l.depth, along: 0, across: g, alongSize: u, acrossSize: f };
359
+ return o.set(l.id, w), s.push(w), r = Math.max(
360
+ r,
361
+ g + f + O(t.siblingGap, l, i[l.depth] ?? 1)
362
+ ), w;
291
363
  }
292
- const u = r.length - 1, p = u < 0 ? 0 : c[u] + r[u];
293
- return { byId: i, alongExtent: p, acrossExtent: d };
364
+ return e.forEach(c), { byId: o, ...k(s, h, t.levelGap) };
294
365
  }
295
- function ot(e) {
366
+ function P(e) {
296
367
  const t = [];
297
368
  function n(i) {
298
369
  t.push(i), i.children.forEach(n);
299
370
  }
300
371
  return e.forEach(n), t;
301
372
  }
302
- function vt(e, t) {
303
- const n = Y(t);
373
+ function Wt(e, t) {
374
+ const n = G(t);
304
375
  if (e.length === 0)
305
376
  return { nodes: [], links: [], width: 0, height: 0 };
306
- const i = n.direction === "top-to-bottom" || n.direction === "bottom-to-top", { byId: o, alongExtent: s, acrossExtent: r } = it(e, n), h = n.direction === "bottom-to-top" || n.direction === "right-to-left", c = ot(e).map((l) => {
307
- const { along: d, across: u, alongSize: p, acrossSize: a } = o.get(l.id), f = h ? s - p - d : d;
377
+ const i = n.direction === "top-to-bottom" || n.direction === "bottom-to-top", { byId: o, alongExtent: s, acrossExtent: r } = st(e, n), h = n.direction === "bottom-to-top" || n.direction === "right-to-left", c = P(e).map((l) => {
378
+ const { along: a, across: d, alongSize: u, acrossSize: f } = o.get(l.id), p = h ? s - u - a : a;
308
379
  return {
309
380
  id: l.id,
310
381
  data: l.data,
311
382
  depth: l.depth,
312
383
  parentId: l.parentId,
313
- x: i ? u : f,
314
- y: i ? f : u,
315
- width: i ? a : p,
316
- height: i ? p : a,
384
+ x: i ? d : p,
385
+ y: i ? p : d,
386
+ width: i ? f : u,
387
+ height: i ? u : f,
317
388
  hasChildren: l.hasChildren,
318
389
  collapsed: l.collapsed
319
390
  };
320
391
  });
321
392
  return {
322
393
  nodes: c,
323
- links: nt(c, n),
394
+ links: it(c, n),
324
395
  width: i ? r : s,
325
396
  height: i ? s : r
326
397
  };
327
398
  }
328
- const w = 1.2;
329
- class It {
399
+ const v = 1.2;
400
+ class zt {
330
401
  constructor(t) {
331
- this.params = t, this.transform = { ...M }, this.element = null, this.pointers = /* @__PURE__ */ new Map(), this.lastPinchDistance = 0, this.onPointerDown = (n) => {
402
+ this.params = t, this.transform = { ...S }, this.element = null, this.pointers = /* @__PURE__ */ new Map(), this.lastPinchDistance = 0, this.onPointerDown = (n) => {
332
403
  this.isPannable() && (n.target?.closest?.("[data-tv-no-pan]") || (this.pointers.set(n.pointerId, { x: n.clientX, y: n.clientY }), this.element?.setPointerCapture?.(n.pointerId)));
333
404
  }, this.onPointerMove = (n) => {
334
405
  const i = this.pointers.get(n.pointerId);
@@ -337,15 +408,15 @@ class It {
337
408
  this.pinch();
338
409
  return;
339
410
  }
340
- this.set(K(this.transform, n.clientX - i.x, n.clientY - i.y));
411
+ this.set(q(this.transform, n.clientX - i.x, n.clientY - i.y));
341
412
  }
342
413
  }, this.onPointerUp = (n) => {
343
414
  this.pointers.delete(n.pointerId), this.pointers.size < 2 && (this.lastPinchDistance = 0);
344
415
  }, this.onWheel = (n) => {
345
416
  if (!this.isZoomable()) return;
346
417
  n.preventDefault();
347
- const i = n.deltaY < 0 ? w : 1 / w;
348
- this.set(L(this.transform, i, this.toLocalPoint(n), this.limits));
418
+ const i = n.deltaY < 0 ? v : 1 / v;
419
+ this.set($(this.transform, i, this.toLocalPoint(n), this.limits));
349
420
  };
350
421
  }
351
422
  /** Подписывается на события элемента. Повторный вызов сначала отписывается. */
@@ -361,7 +432,7 @@ class It {
361
432
  fit(t, n = 24) {
362
433
  const i = this.element;
363
434
  i && this.set(
364
- q(
435
+ Z(
365
436
  t,
366
437
  { width: i.clientWidth, height: i.clientHeight },
367
438
  n,
@@ -370,20 +441,20 @@ class It {
370
441
  );
371
442
  }
372
443
  zoomIn() {
373
- this.zoomToCenter(w);
444
+ this.zoomToCenter(v);
374
445
  }
375
446
  zoomOut() {
376
- this.zoomToCenter(1 / w);
447
+ this.zoomToCenter(1 / v);
377
448
  }
378
449
  reset() {
379
- this.set({ ...M });
450
+ this.set({ ...S });
380
451
  }
381
452
  /** Устанавливает состояние напрямую (например, восстановление после перезагрузки). */
382
453
  set(t) {
383
454
  this.transform = { ...t }, this.params.onChange(this.transform);
384
455
  }
385
456
  get limits() {
386
- return this.params.limits?.() ?? $;
457
+ return this.params.limits?.() ?? I;
387
458
  }
388
459
  isPannable() {
389
460
  return this.params.pannable?.() ?? !0;
@@ -398,7 +469,7 @@ class It {
398
469
  }
399
470
  zoomToCenter(t) {
400
471
  const n = this.element, i = { x: (n?.clientWidth ?? 0) / 2, y: (n?.clientHeight ?? 0) / 2 };
401
- this.set(L(this.transform, t, i, this.limits));
472
+ this.set($(this.transform, t, i, this.limits));
402
473
  }
403
474
  /** Два пальца: масштабируем вокруг точки ровно между ними. */
404
475
  pinch() {
@@ -411,21 +482,21 @@ class It {
411
482
  clientX: (t.x + n.x) / 2,
412
483
  clientY: (t.y + n.y) / 2
413
484
  });
414
- this.set(L(this.transform, i / this.lastPinchDistance, o, this.limits));
485
+ this.set($(this.transform, i / this.lastPinchDistance, o, this.limits));
415
486
  }
416
487
  this.lastPinchDistance = i;
417
488
  }
418
489
  }
419
- function St(e, t = "tree-view-styles") {
490
+ function Ot(e, t = "tree-view-styles") {
420
491
  if (typeof document > "u" || document.getElementById(t)) return;
421
492
  const n = document.createElement("style");
422
493
  n.id = t, n.textContent = e, document.head.appendChild(n);
423
494
  }
424
- const rt = 400, st = 150;
425
- function z(e, t) {
495
+ const ct = 400, ht = 150;
496
+ function D(e, t) {
426
497
  return e.x <= t.x + t.width && e.x + e.width >= t.x && e.y <= t.y + t.height && e.y + e.height >= t.y;
427
498
  }
428
- function ht(e) {
499
+ function lt(e) {
429
500
  const { source: t, target: n } = e, i = Math.min(t.x, n.x), o = Math.min(t.y, n.y);
430
501
  return {
431
502
  x: i,
@@ -434,24 +505,24 @@ function ht(e) {
434
505
  height: Math.max(t.y + t.height, n.y + n.height) - o
435
506
  };
436
507
  }
437
- function ct(e, t) {
508
+ function at(e, t) {
438
509
  return { x: e.x - t, y: e.y - t, width: e.width + t * 2, height: e.height + t * 2 };
439
510
  }
440
- function Tt(e, t, n = rt) {
441
- if (!t || e.nodes.length < st) return e;
511
+ function kt(e, t, n = ct) {
512
+ if (!t || e.nodes.length < ht) return e;
442
513
  if (t.width <= 0 || t.height <= 0)
443
514
  return { nodes: [], links: [], width: e.width, height: e.height };
444
- const i = ct(t, n), o = [], s = [];
515
+ const i = at(t, n), o = [], s = [];
445
516
  for (const r of e.nodes)
446
- z(i, r) && o.push(r);
517
+ D(i, r) && o.push(r);
447
518
  for (const r of e.links)
448
- z(i, ht(r)) && s.push(r);
519
+ D(i, lt(r)) && s.push(r);
449
520
  return { nodes: o, links: s, width: e.width, height: e.height };
450
521
  }
451
- function Pt() {
522
+ function _t() {
452
523
  return typeof window > "u" ? null : { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight };
453
524
  }
454
- function bt(e, t) {
525
+ function Bt(e, t) {
455
526
  if (!e || typeof window > "u" || t <= 0) return null;
456
527
  const n = e.getBoundingClientRect(), i = Math.max(n.left, 0), o = Math.max(n.top, 0), s = Math.min(n.right, window.innerWidth), r = Math.min(n.bottom, window.innerHeight);
457
528
  return s <= i || r <= o ? { x: 0, y: 0, width: 0, height: 0 } : {
@@ -462,47 +533,56 @@ function bt(e, t) {
462
533
  };
463
534
  }
464
535
  export {
465
- _ as DEFAULT_BRACKET_ROWS,
466
- Z as DEFAULT_BRACKET_ROW_HEIGHT,
467
- U as DEFAULT_OPTIONS,
468
- rt as DEFAULT_OVERSCAN,
469
- $ as DEFAULT_SCALE_LIMITS,
470
- M as IDENTITY_TRANSFORM,
471
- Mt as MOBILE_MEDIA_QUERY,
472
- It as PanZoomController,
536
+ z as DEFAULT_BRACKET_ROWS,
537
+ V as DEFAULT_BRACKET_ROW_HEIGHT,
538
+ H as DEFAULT_OPTIONS,
539
+ ct as DEFAULT_OVERSCAN,
540
+ I as DEFAULT_SCALE_LIMITS,
541
+ J as HIDDEN_CLASS,
542
+ S as IDENTITY_TRANSFORM,
543
+ K as MAX_GAP_STEPS,
544
+ Tt as MOBILE_MEDIA_QUERY,
545
+ zt as PanZoomController,
473
546
  Q as TREE_NODE_SELECTOR,
474
- st as VIRTUALIZE_THRESHOLD,
475
- w as ZOOM_STEP,
476
- ut as applyCollapsed,
477
- mt as bracketCardHeight,
478
- pt as buildBracketCard,
479
- wt as buildBracketRounds,
480
- nt as buildLinks,
481
- et as buildPath,
482
- v as clamp,
483
- Pt as estimateVisibleRect,
484
- ct as expandRect,
485
- xt as findScrollParent,
486
- q as fitToViewport,
487
- ot as flatten,
488
- dt as fromLevels,
489
- tt as getAnchors,
490
- Lt as horizontalBox,
491
- St as injectStyles,
492
- vt as layoutTree,
493
- bt as measureVisibleRect,
494
- Ct as nodesInColumn,
547
+ ht as VIRTUALIZE_THRESHOLD,
548
+ v as ZOOM_STEP,
549
+ pt as applyCollapsed,
550
+ wt as bracketCardHeight,
551
+ mt as buildBracketCard,
552
+ xt as buildBracketRounds,
553
+ it as buildLinks,
554
+ nt as buildPath,
555
+ L as clamp,
556
+ _t as estimateVisibleRect,
557
+ at as expandRect,
558
+ bt as findScrollParent,
559
+ Z as fitToViewport,
560
+ P as flatten,
561
+ ft as fromLevels,
562
+ et as getAnchors,
563
+ Pt as hideRoundsBefore,
564
+ It as horizontalBox,
565
+ Ot as injectStyles,
566
+ Wt as layoutTree,
567
+ Mt as levelGapForWidth,
568
+ Bt as measureVisibleRect,
569
+ St as nodesInColumn,
495
570
  j as offsetWithin,
496
- K as panBy,
497
- it as placeNodes,
498
- Y as resolveOptions,
499
- yt as roundScrollLeft,
500
- Et as smoothScrollLeft,
501
- gt as toCssTransform,
502
- at as toTree,
503
- ft as toggleCollapsed,
504
- Tt as visibleLayout,
505
- $t as watchMedia,
506
- L as zoomAtPoint
571
+ q as panBy,
572
+ st as placeNodes,
573
+ G as resolveOptions,
574
+ Lt as roundAtScroll,
575
+ vt as roundOfDepth,
576
+ Et as roundScrollLeft,
577
+ Ct as roundSiblingGap,
578
+ $t as smoothScrollLeft,
579
+ yt as toCssTransform,
580
+ ut as toTree,
581
+ gt as toggleCollapsed,
582
+ kt as visibleLayout,
583
+ At as watchChildren,
584
+ Dt as watchMedia,
585
+ Rt as watchWidth,
586
+ $ as zoomAtPoint
507
587
  };
508
588
  //# sourceMappingURL=index.js.map