@bigplay/tree-view-core 0.2.1 → 0.3.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
@@ -1,4 +1,4 @@
1
- const Y = {
1
+ const U = {
2
2
  nodeWidth: 180,
3
3
  nodeHeight: 64,
4
4
  levelGap: 60,
@@ -6,45 +6,45 @@ const Y = {
6
6
  direction: "top-to-bottom",
7
7
  linkStyle: "elbow"
8
8
  };
9
- function X(e) {
10
- return { ...Y, ...e };
9
+ function Y(e) {
10
+ return { ...U, ...e };
11
11
  }
12
- function B(e) {
12
+ function X(e) {
13
13
  return e?.children;
14
14
  }
15
- function k(e) {
15
+ function W(e) {
16
16
  return e?.id;
17
17
  }
18
- function ct(e, t = {}) {
18
+ function at(e, t = {}) {
19
19
  if (e == null) return [];
20
20
  const n = Array.isArray(e) ? e : [e];
21
- return n.length === 0 ? [] : t.getParentId ? G(n, t) : F(n, t);
21
+ return n.length === 0 ? [] : t.getParentId ? F(n, t) : G(n, t);
22
22
  }
23
- function F(e, t) {
24
- const n = t.getId ?? k, i = t.getChildren ?? B, o = /* @__PURE__ */ new Set();
25
- function r(s, h, c, l) {
26
- const d = A(n(s), l);
27
- R(d, o);
28
- const p = (i(s) ?? []).map((a, f) => r(a, h + 1, d, `${l}.${f}`));
29
- return { id: d, data: s, depth: h, parentId: c, children: p, hasChildren: p.length > 0, collapsed: !1 };
23
+ function G(e, t) {
24
+ const n = t.getId ?? W, i = t.getChildren ?? X, o = /* @__PURE__ */ new Set();
25
+ 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 };
30
30
  }
31
- return e.map((s, h) => r(s, 0, null, String(h)));
31
+ return e.map((r, h) => s(r, 0, null, String(h)));
32
32
  }
33
- function G(e, t) {
34
- const n = t.getId ?? k, i = /* @__PURE__ */ new Set(), o = e.map((c, l) => {
35
- const d = A(n(c), String(l));
36
- return R(d, i), { id: d, data: c, depth: 0, parentId: null, children: [], hasChildren: !1, collapsed: !1 };
37
- }), r = new Map(o.map((c) => [c.id, c])), s = [];
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 };
37
+ }), s = new Map(o.map((c) => [c.id, c])), r = [];
38
38
  if (o.forEach((c, l) => {
39
- const d = t.getParentId(e[l]), u = d == null ? void 0 : r.get(String(d));
39
+ const d = t.getParentId(e[l]), u = d == null ? void 0 : s.get(String(d));
40
40
  if (!u) {
41
- s.push(c);
41
+ r.push(c);
42
42
  return;
43
43
  }
44
44
  c.parentId = u.id, u.children.push(c), u.hasChildren = !0;
45
- }), N(s) !== o.length)
45
+ }), N(r) !== o.length)
46
46
  throw new Error("[tree-view] В данных есть цикл: часть узлов ссылается друг на друга по кругу.");
47
- return s;
47
+ return r;
48
48
  }
49
49
  function N(e) {
50
50
  const t = [...e];
@@ -55,32 +55,32 @@ function N(e) {
55
55
  }
56
56
  return t.length;
57
57
  }
58
- function A(e, t) {
58
+ function k(e, t) {
59
59
  return e == null || e === "" ? t : String(e);
60
60
  }
61
- function R(e, t) {
61
+ function A(e, t) {
62
62
  if (t.has(e))
63
63
  throw new Error(`[tree-view] Повторяющийся id узла: "${e}". Идентификаторы должны быть уникальными.`);
64
64
  t.add(e);
65
65
  }
66
- function lt(e, t = {}) {
67
- const n = e.filter((r) => r.length > 0);
66
+ function dt(e, t = {}) {
67
+ const n = e.filter((s) => s.length > 0);
68
68
  if (n.length === 0) return [];
69
69
  const i = n.length - 1, o = n.map(
70
- (r, s) => r.map((h, c) => ({
71
- id: V(h, s, c, t.getId),
70
+ (s, r) => s.map((h, c) => ({
71
+ id: V(h, r, c, t.getId),
72
72
  data: h,
73
73
  // Финал — корень, поэтому глубина считается от последнего уровня.
74
- depth: i - s,
74
+ depth: i - r,
75
75
  parentId: null,
76
76
  children: [],
77
77
  hasChildren: !1,
78
78
  collapsed: !1
79
79
  }))
80
80
  );
81
- for (let r = 0; r < i; r += 1) {
82
- const s = o[r], h = o[r + 1], c = Math.ceil(s.length / h.length);
83
- s.forEach((l, d) => {
81
+ for (let s = 0; s < i; s += 1) {
82
+ const r = o[s], h = o[s + 1], c = Math.ceil(r.length / h.length);
83
+ r.forEach((l, d) => {
84
84
  const u = h[Math.min(Math.floor(d / c), h.length - 1)];
85
85
  l.parentId = u.id, u.children.push(l), u.hasChildren = !0;
86
86
  });
@@ -91,7 +91,7 @@ function V(e, t, n, i) {
91
91
  const o = i ? i(e, t, n) : e?.id;
92
92
  return o == null || o === "" ? `${t}.${n}` : String(o);
93
93
  }
94
- function at(e, t) {
94
+ function ut(e, t) {
95
95
  if (t.size === 0) return e;
96
96
  function n(i) {
97
97
  const o = t.has(i.id);
@@ -103,28 +103,28 @@ function at(e, t) {
103
103
  }
104
104
  return e.map(n);
105
105
  }
106
- function dt(e, t) {
106
+ function ft(e, t) {
107
107
  const n = new Set(e);
108
108
  return n.delete(t) || n.add(t), n;
109
109
  }
110
- const W = 2, Z = 40;
111
- function ut(e, t = {}) {
112
- const n = e?.teams ?? [], i = Math.max(t.rows ?? W, n.length), o = t.techDefeatLabel ?? "ТП", r = n.map((s, h) => {
113
- const c = s.isTechDefeat === !0, l = s.isWinner === !0;
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) => {
113
+ const c = r.isTechDefeat === !0, l = r.isWinner === !0;
114
114
  return {
115
- key: String(s.id ?? `team-${h}`),
116
- team: s,
117
- score: c ? o : String(s.score ?? ""),
115
+ key: String(r.id ?? `team-${h}`),
116
+ team: r,
117
+ score: c ? o : String(r.score ?? ""),
118
118
  isWinner: l,
119
119
  isLoser: !l,
120
- isMyTeam: s.isMyTeam === !0,
120
+ isMyTeam: r.isMyTeam === !0,
121
121
  isTechDefeat: c,
122
122
  isEmpty: !1
123
123
  };
124
124
  });
125
- for (let s = n.length; s < i; s += 1)
126
- r.push({
127
- key: `empty-${s}`,
125
+ for (let r = n.length; r < i; r += 1)
126
+ s.push({
127
+ key: `empty-${r}`,
128
128
  team: null,
129
129
  score: "",
130
130
  isWinner: !1,
@@ -133,103 +133,178 @@ function ut(e, t = {}) {
133
133
  isTechDefeat: !1,
134
134
  isEmpty: !0
135
135
  });
136
- return { rows: r, hasMyTeam: n.some((s) => s.isMyTeam === !0) };
136
+ return { rows: s, hasMyTeam: n.some((r) => r.isMyTeam === !0) };
137
137
  }
138
- function ft(e, t = {}) {
138
+ function mt(e, t = {}) {
139
139
  const n = e?.teams ?? [];
140
- return Math.max(t.rows ?? W, n.length) * (t.rowHeight ?? Z);
140
+ return Math.max(t.rows ?? _, n.length) * (t.rowHeight ?? Z);
141
+ }
142
+ const $ = { min: 0.2, max: 3 }, M = { x: 0, y: 0, scale: 1 };
143
+ function v(e, t, n) {
144
+ return Math.min(Math.max(e, t), n);
145
+ }
146
+ function q(e, t, n = 24, i = $) {
147
+ 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);
150
+ return {
151
+ scale: h,
152
+ x: (t.width - e.width * h) / 2,
153
+ y: (t.height - e.height * h) / 2
154
+ };
155
+ }
156
+ function K(e, t, n) {
157
+ return { ...e, x: e.x + t, y: e.y + n };
158
+ }
159
+ function L(e, t, n, i = $) {
160
+ const o = v(e.scale * t, i.min, i.max);
161
+ if (o === e.scale) return e;
162
+ const s = (n.x - e.x) / e.scale, r = (n.y - e.y) / e.scale;
163
+ return { scale: o, x: n.x - s * o, y: n.y - r * o };
164
+ }
165
+ function gt(e) {
166
+ return `translate(${e.x}px, ${e.y}px) scale(${e.scale})`;
167
+ }
168
+ function wt(e, t) {
169
+ const n = t.nodeWidth + t.levelGap, i = (e ?? []).map((o, s) => {
170
+ const r = o.id ?? s;
171
+ return { key: String(r), id: r, name: o.name, index: s, width: n };
172
+ });
173
+ return { columns: i, width: n * i.length, offset: t.levelGap / 2 };
174
+ }
175
+ function yt(e) {
176
+ const t = e.left + e.width / 2 - e.viewport / 2;
177
+ return v(t, 0, Math.max(0, e.scrollWidth - e.viewport));
178
+ }
179
+ function xt(e) {
180
+ if (typeof window > "u") return null;
181
+ let t = e?.parentElement ?? null;
182
+ for (; t; ) {
183
+ const { overflowX: n } = window.getComputedStyle(t);
184
+ if ((n === "auto" || n === "scroll") && t.scrollWidth > t.clientWidth) return t;
185
+ t = t.parentElement;
186
+ }
187
+ return null;
188
+ }
189
+ function Et(e, t) {
190
+ if (typeof e.scrollTo == "function") {
191
+ e.scrollTo({ left: t, behavior: "smooth" });
192
+ return;
193
+ }
194
+ e.scrollLeft = t;
195
+ }
196
+ function j(e, t) {
197
+ return e.getBoundingClientRect().left - t.getBoundingClientRect().left + t.scrollLeft;
198
+ }
199
+ const Q = ".tree-view__node";
200
+ function Ct(e, t, n, i) {
201
+ const o = e.getBoundingClientRect().left + i;
202
+ return Array.from(e.querySelectorAll(Q)).filter((r) => {
203
+ const h = r.getBoundingClientRect();
204
+ return Math.floor((h.left + h.width / 2 - o) / n) === t;
205
+ });
206
+ }
207
+ function Lt(e, t) {
208
+ return { left: j(e, t), width: e.getBoundingClientRect().width };
209
+ }
210
+ const Mt = "(max-width: 768px)";
211
+ function $t(e, t) {
212
+ if (typeof window > "u" || typeof window.matchMedia != "function") return () => {
213
+ };
214
+ const n = window.matchMedia(e), i = () => t(n.matches);
215
+ return i(), typeof n.addEventListener == "function" ? (n.addEventListener("change", i), () => n.removeEventListener("change", i)) : (n.addListener(i), () => n.removeListener(i));
141
216
  }
142
217
  function m(e) {
143
218
  return Math.round(e * 100) / 100;
144
219
  }
145
- function q(e) {
220
+ function J(e) {
146
221
  return e === "top-to-bottom" || e === "bottom-to-top";
147
222
  }
148
- function K(e, t, n) {
149
- 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;
223
+ function tt(e, t, n) {
224
+ 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;
150
225
  switch (n) {
151
226
  case "top-to-bottom":
152
- return { from: { x: i, y: e.y + e.height }, to: { x: r, y: t.y } };
227
+ return { from: { x: i, y: e.y + e.height }, to: { x: s, y: t.y } };
153
228
  case "bottom-to-top":
154
- return { from: { x: i, y: e.y }, to: { x: r, y: t.y + t.height } };
229
+ return { from: { x: i, y: e.y }, to: { x: s, y: t.y + t.height } };
155
230
  case "left-to-right":
156
- return { from: { x: e.x + e.width, y: o }, to: { x: t.x, y: s } };
231
+ return { from: { x: e.x + e.width, y: o }, to: { x: t.x, y: r } };
157
232
  case "right-to-left":
158
- return { from: { x: e.x, y: o }, to: { x: t.x + t.width, y: s } };
233
+ return { from: { x: e.x, y: o }, to: { x: t.x + t.width, y: r } };
159
234
  }
160
235
  }
161
- function j(e, t, n, i) {
162
- const o = m(e.x), r = m(e.y), s = m(t.x), h = m(t.y);
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);
163
238
  if (n === "straight")
164
- return `M ${o} ${r} L ${s} ${h}`;
165
- const c = q(i), l = m((o + s) / 2), d = m((r + h) / 2);
166
- return n === "elbow" ? c ? `M ${o} ${r} L ${o} ${d} L ${s} ${d} L ${s} ${h}` : `M ${o} ${r} L ${l} ${r} L ${l} ${h} L ${s} ${h}` : c ? `M ${o} ${r} C ${o} ${d} ${s} ${d} ${s} ${h}` : `M ${o} ${r} C ${l} ${r} ${l} ${h} ${s} ${h}`;
239
+ 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}`;
167
242
  }
168
- function J(e, t) {
243
+ function nt(e, t) {
169
244
  const n = new Map(e.map((o) => [o.id, o])), i = [];
170
245
  for (const o of e) {
171
- const r = o.parentId == null ? void 0 : n.get(o.parentId);
172
- if (!r) continue;
173
- const { from: s, to: h } = K(r, o, t.direction);
246
+ const s = o.parentId == null ? void 0 : n.get(o.parentId);
247
+ if (!s) continue;
248
+ const { from: r, to: h } = tt(s, o, t.direction);
174
249
  i.push({
175
- id: `${r.id}->${o.id}`,
176
- source: r,
250
+ id: `${s.id}->${o.id}`,
251
+ source: s,
177
252
  target: o,
178
- path: j(s, h, t.linkStyle, t.direction)
253
+ path: et(r, h, t.linkStyle, t.direction)
179
254
  });
180
255
  }
181
256
  return i;
182
257
  }
183
- function D(e, t) {
258
+ function R(e, t) {
184
259
  return typeof e == "function" ? e(t) : e;
185
260
  }
186
- function Q(e, t) {
261
+ function it(e, t) {
187
262
  const n = t.direction === "top-to-bottom" || t.direction === "bottom-to-top", i = /* @__PURE__ */ new Map(), o = [];
188
- let r = 0;
189
- const s = [];
263
+ let s = 0;
264
+ const r = [];
190
265
  function h(a) {
191
- const f = D(t.nodeWidth, a), I = D(t.nodeHeight, a), b = n ? I : f, w = n ? f : I;
192
- s[a.depth] = Math.max(s[a.depth] ?? 0, b);
193
- const P = r, O = o.length;
194
- let g = r;
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;
195
270
  if (a.children.length > 0) {
196
- const $ = a.children.map(h), S = $[0], T = $[$.length - 1], U = S.across + S.acrossSize / 2, _ = T.across + T.acrossSize / 2;
197
- g = (U + _) / 2 - w / 2;
198
- const v = P - g;
199
- if (v > 0) {
200
- for (let M = O; M < o.length; M += 1) o[M].across += v;
201
- g = P;
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;
202
277
  }
203
278
  }
204
- const y = { depth: a.depth, along: 0, across: g, alongSize: b, acrossSize: w };
205
- return i.set(a.id, y), o.push(y), r = Math.max(r, g + w + t.siblingGap), y;
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;
206
281
  }
207
282
  e.forEach(h);
208
283
  const c = [];
209
284
  let l = 0;
210
- for (let a = 0; a < s.length; a += 1)
211
- c[a] = l, l += (s[a] ?? 0) + t.levelGap;
285
+ for (let a = 0; a < r.length; a += 1)
286
+ c[a] = l, l += (r[a] ?? 0) + t.levelGap;
212
287
  let d = 0;
213
288
  for (const a of o) {
214
- const f = s[a.depth] ?? a.alongSize;
289
+ const f = r[a.depth] ?? a.alongSize;
215
290
  a.along = c[a.depth] + (f - a.alongSize) / 2, d = Math.max(d, a.across + a.acrossSize);
216
291
  }
217
- const u = s.length - 1, p = u < 0 ? 0 : c[u] + s[u];
292
+ const u = r.length - 1, p = u < 0 ? 0 : c[u] + r[u];
218
293
  return { byId: i, alongExtent: p, acrossExtent: d };
219
294
  }
220
- function tt(e) {
295
+ function ot(e) {
221
296
  const t = [];
222
297
  function n(i) {
223
298
  t.push(i), i.children.forEach(n);
224
299
  }
225
300
  return e.forEach(n), t;
226
301
  }
227
- function pt(e, t) {
228
- const n = X(t);
302
+ function vt(e, t) {
303
+ const n = Y(t);
229
304
  if (e.length === 0)
230
305
  return { nodes: [], links: [], width: 0, height: 0 };
231
- const i = n.direction === "top-to-bottom" || n.direction === "bottom-to-top", { byId: o, alongExtent: r, acrossExtent: s } = Q(e, n), h = n.direction === "bottom-to-top" || n.direction === "right-to-left", c = tt(e).map((l) => {
232
- const { along: d, across: u, alongSize: p, acrossSize: a } = o.get(l.id), f = h ? r - p - d : d;
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;
233
308
  return {
234
309
  id: l.id,
235
310
  data: l.data,
@@ -245,41 +320,15 @@ function pt(e, t) {
245
320
  });
246
321
  return {
247
322
  nodes: c,
248
- links: J(c, n),
249
- width: i ? s : r,
250
- height: i ? r : s
323
+ links: nt(c, n),
324
+ width: i ? r : s,
325
+ height: i ? s : r
251
326
  };
252
327
  }
253
- const L = { min: 0.2, max: 3 }, E = { x: 0, y: 0, scale: 1 };
254
- function H(e, t, n) {
255
- return Math.min(Math.max(e, t), n);
256
- }
257
- function et(e, t, n = 24, i = L) {
258
- if (e.width <= 0 || e.height <= 0 || t.width <= 0 || t.height <= 0)
259
- return { ...E };
260
- 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), h = H(s, i.min, i.max);
261
- return {
262
- scale: h,
263
- x: (t.width - e.width * h) / 2,
264
- y: (t.height - e.height * h) / 2
265
- };
266
- }
267
- function nt(e, t, n) {
268
- return { ...e, x: e.x + t, y: e.y + n };
269
- }
270
- function C(e, t, n, i = L) {
271
- const o = H(e.scale * t, i.min, i.max);
272
- if (o === e.scale) return e;
273
- const r = (n.x - e.x) / e.scale, s = (n.y - e.y) / e.scale;
274
- return { scale: o, x: n.x - r * o, y: n.y - s * o };
275
- }
276
- function mt(e) {
277
- return `translate(${e.x}px, ${e.y}px) scale(${e.scale})`;
278
- }
279
- const x = 1.2;
280
- class gt {
328
+ const w = 1.2;
329
+ class It {
281
330
  constructor(t) {
282
- this.params = t, this.transform = { ...E }, this.element = null, this.pointers = /* @__PURE__ */ new Map(), this.lastPinchDistance = 0, this.onPointerDown = (n) => {
331
+ this.params = t, this.transform = { ...M }, this.element = null, this.pointers = /* @__PURE__ */ new Map(), this.lastPinchDistance = 0, this.onPointerDown = (n) => {
283
332
  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)));
284
333
  }, this.onPointerMove = (n) => {
285
334
  const i = this.pointers.get(n.pointerId);
@@ -288,15 +337,15 @@ class gt {
288
337
  this.pinch();
289
338
  return;
290
339
  }
291
- this.set(nt(this.transform, n.clientX - i.x, n.clientY - i.y));
340
+ this.set(K(this.transform, n.clientX - i.x, n.clientY - i.y));
292
341
  }
293
342
  }, this.onPointerUp = (n) => {
294
343
  this.pointers.delete(n.pointerId), this.pointers.size < 2 && (this.lastPinchDistance = 0);
295
344
  }, this.onWheel = (n) => {
296
345
  if (!this.isZoomable()) return;
297
346
  n.preventDefault();
298
- const i = n.deltaY < 0 ? x : 1 / x;
299
- this.set(C(this.transform, i, this.toLocalPoint(n), this.limits));
347
+ const i = n.deltaY < 0 ? w : 1 / w;
348
+ this.set(L(this.transform, i, this.toLocalPoint(n), this.limits));
300
349
  };
301
350
  }
302
351
  /** Подписывается на события элемента. Повторный вызов сначала отписывается. */
@@ -312,7 +361,7 @@ class gt {
312
361
  fit(t, n = 24) {
313
362
  const i = this.element;
314
363
  i && this.set(
315
- et(
364
+ q(
316
365
  t,
317
366
  { width: i.clientWidth, height: i.clientHeight },
318
367
  n,
@@ -321,20 +370,20 @@ class gt {
321
370
  );
322
371
  }
323
372
  zoomIn() {
324
- this.zoomToCenter(x);
373
+ this.zoomToCenter(w);
325
374
  }
326
375
  zoomOut() {
327
- this.zoomToCenter(1 / x);
376
+ this.zoomToCenter(1 / w);
328
377
  }
329
378
  reset() {
330
- this.set({ ...E });
379
+ this.set({ ...M });
331
380
  }
332
381
  /** Устанавливает состояние напрямую (например, восстановление после перезагрузки). */
333
382
  set(t) {
334
383
  this.transform = { ...t }, this.params.onChange(this.transform);
335
384
  }
336
385
  get limits() {
337
- return this.params.limits?.() ?? L;
386
+ return this.params.limits?.() ?? $;
338
387
  }
339
388
  isPannable() {
340
389
  return this.params.pannable?.() ?? !0;
@@ -349,7 +398,7 @@ class gt {
349
398
  }
350
399
  zoomToCenter(t) {
351
400
  const n = this.element, i = { x: (n?.clientWidth ?? 0) / 2, y: (n?.clientHeight ?? 0) / 2 };
352
- this.set(C(this.transform, t, i, this.limits));
401
+ this.set(L(this.transform, t, i, this.limits));
353
402
  }
354
403
  /** Два пальца: масштабируем вокруг точки ровно между ними. */
355
404
  pinch() {
@@ -362,21 +411,21 @@ class gt {
362
411
  clientX: (t.x + n.x) / 2,
363
412
  clientY: (t.y + n.y) / 2
364
413
  });
365
- this.set(C(this.transform, i / this.lastPinchDistance, o, this.limits));
414
+ this.set(L(this.transform, i / this.lastPinchDistance, o, this.limits));
366
415
  }
367
416
  this.lastPinchDistance = i;
368
417
  }
369
418
  }
370
- function xt(e, t = "tree-view-styles") {
419
+ function St(e, t = "tree-view-styles") {
371
420
  if (typeof document > "u" || document.getElementById(t)) return;
372
421
  const n = document.createElement("style");
373
422
  n.id = t, n.textContent = e, document.head.appendChild(n);
374
423
  }
375
- const it = 400, ot = 150;
424
+ const rt = 400, st = 150;
376
425
  function z(e, t) {
377
426
  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;
378
427
  }
379
- function st(e) {
428
+ function ht(e) {
380
429
  const { source: t, target: n } = e, i = Math.min(t.x, n.x), o = Math.min(t.y, n.y);
381
430
  return {
382
431
  x: i,
@@ -385,65 +434,75 @@ function st(e) {
385
434
  height: Math.max(t.y + t.height, n.y + n.height) - o
386
435
  };
387
436
  }
388
- function rt(e, t) {
437
+ function ct(e, t) {
389
438
  return { x: e.x - t, y: e.y - t, width: e.width + t * 2, height: e.height + t * 2 };
390
439
  }
391
- function wt(e, t, n = it) {
392
- if (!t || e.nodes.length < ot) return e;
440
+ function Tt(e, t, n = rt) {
441
+ if (!t || e.nodes.length < st) return e;
393
442
  if (t.width <= 0 || t.height <= 0)
394
443
  return { nodes: [], links: [], width: e.width, height: e.height };
395
- const i = rt(t, n), o = [], r = [];
396
- for (const s of e.nodes)
397
- z(i, s) && o.push(s);
398
- for (const s of e.links)
399
- z(i, st(s)) && r.push(s);
400
- return { nodes: o, links: r, width: e.width, height: e.height };
401
- }
402
- function yt() {
444
+ const i = ct(t, n), o = [], s = [];
445
+ for (const r of e.nodes)
446
+ z(i, r) && o.push(r);
447
+ for (const r of e.links)
448
+ z(i, ht(r)) && s.push(r);
449
+ return { nodes: o, links: s, width: e.width, height: e.height };
450
+ }
451
+ function Pt() {
403
452
  return typeof window > "u" ? null : { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight };
404
453
  }
405
- function $t(e, t) {
454
+ function bt(e, t) {
406
455
  if (!e || typeof window > "u" || t <= 0) return null;
407
- 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);
408
- return r <= i || s <= o ? { x: 0, y: 0, width: 0, height: 0 } : {
456
+ 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
+ return s <= i || r <= o ? { x: 0, y: 0, width: 0, height: 0 } : {
409
458
  x: (i - n.left) / t,
410
459
  y: (o - n.top) / t,
411
- width: (r - i) / t,
412
- height: (s - o) / t
460
+ width: (s - i) / t,
461
+ height: (r - o) / t
413
462
  };
414
463
  }
415
464
  export {
416
- W as DEFAULT_BRACKET_ROWS,
465
+ _ as DEFAULT_BRACKET_ROWS,
417
466
  Z as DEFAULT_BRACKET_ROW_HEIGHT,
418
- Y as DEFAULT_OPTIONS,
419
- it as DEFAULT_OVERSCAN,
420
- L as DEFAULT_SCALE_LIMITS,
421
- E as IDENTITY_TRANSFORM,
422
- gt as PanZoomController,
423
- ot as VIRTUALIZE_THRESHOLD,
424
- x as ZOOM_STEP,
425
- at as applyCollapsed,
426
- ft as bracketCardHeight,
427
- ut as buildBracketCard,
428
- J as buildLinks,
429
- j as buildPath,
430
- H as clamp,
431
- yt as estimateVisibleRect,
432
- rt as expandRect,
433
- et as fitToViewport,
434
- tt as flatten,
435
- lt as fromLevels,
436
- K as getAnchors,
437
- xt as injectStyles,
438
- pt as layoutTree,
439
- $t as measureVisibleRect,
440
- nt as panBy,
441
- Q as placeNodes,
442
- X as resolveOptions,
443
- mt as toCssTransform,
444
- ct as toTree,
445
- dt as toggleCollapsed,
446
- wt as visibleLayout,
447
- C as zoomAtPoint
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,
473
+ 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,
495
+ 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
448
507
  };
449
508
  //# sourceMappingURL=index.js.map