@bigplay/tree-view-core 0.5.0 → 0.6.1

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