markmap-view 0.18.4 → 0.18.5-alpha.7

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,11 +1,11 @@
1
- import { Hook as at, getId as lt, debounce as ct, addClass as ht, walkTree as C, childSelector as v, noop as w } from "markmap-common";
2
- import { loadCSS as xe, loadJS as ye } from "markmap-common";
3
- import { scaleOrdinal as G, schemeCategory10 as dt, linkHorizontal as pt, zoomTransform as S, select as ut, zoom as mt, min as P, max as W, zoomIdentity as gt, minIndex as ft } from "d3";
4
- const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), xt = G(dt), U = {
1
+ import { Hook as ht, getId as dt, debounce as pt, addClass as ut, walkTree as R, noop as X } from "markmap-common";
2
+ import { loadCSS as Ee, loadJS as ze } from "markmap-common";
3
+ import { scaleOrdinal as Y, schemeCategory10 as gt, linkHorizontal as mt, zoomTransform as z, select as ft, zoom as xt, min as K, max as G, zoomIdentity as yt, minIndex as kt } from "d3";
4
+ const Z = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), vt = Y(gt), q = {
5
5
  autoFit: !1,
6
6
  color: (e) => {
7
7
  var t;
8
- return xt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
8
+ return vt(`${((t = e.state) == null ? void 0 : t.path) || ""}`);
9
9
  },
10
10
  duration: 500,
11
11
  embedGlobalCSS: !0,
@@ -14,7 +14,7 @@ const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), x
14
14
  maxWidth: 0,
15
15
  nodeMinHeight: 16,
16
16
  paddingX: 8,
17
- scrollForPan: V,
17
+ scrollForPan: Z,
18
18
  spacingHorizontal: 80,
19
19
  spacingVertical: 5,
20
20
  initialExpandLevel: -1,
@@ -22,24 +22,24 @@ const V = typeof navigator < "u" && navigator.userAgent.includes("Macintosh"), x
22
22
  pan: !0,
23
23
  toggleRecursively: !1
24
24
  };
25
- function ue(e) {
26
- const t = {}, s = { ...e }, { color: n, colorFreezeLevel: o } = s;
25
+ function ye(e) {
26
+ const t = {}, i = { ...e }, { color: n, colorFreezeLevel: o } = i;
27
27
  if ((n == null ? void 0 : n.length) === 1) {
28
- const r = n[0];
29
- t.color = () => r;
28
+ const s = n[0];
29
+ t.color = () => s;
30
30
  } else if (n != null && n.length) {
31
- const r = G(n);
32
- t.color = (c) => r(`${c.state.path}`);
31
+ const s = Y(n);
32
+ t.color = (c) => s(`${c.state.path}`);
33
33
  }
34
34
  if (o) {
35
- const r = t.color || U.color;
35
+ const s = t.color || q.color;
36
36
  t.color = (c) => (c = {
37
37
  ...c,
38
38
  state: {
39
39
  ...c.state,
40
40
  path: c.state.path.split(".").slice(0, o).join(".")
41
41
  }
42
- }, r(c));
42
+ }, s(c));
43
43
  }
44
44
  return [
45
45
  "duration",
@@ -51,174 +51,185 @@ function ue(e) {
51
51
  "paddingX",
52
52
  "spacingHorizontal",
53
53
  "spacingVertical"
54
- ].forEach((r) => {
55
- const c = s[r];
56
- typeof c == "number" && (t[r] = c);
57
- }), ["zoom", "pan"].forEach((r) => {
58
- const c = s[r];
59
- c != null && (t[r] = !!c);
54
+ ].forEach((s) => {
55
+ const c = i[s];
56
+ typeof c == "number" && (t[s] = c);
57
+ }), ["zoom", "pan"].forEach((s) => {
58
+ const c = i[s];
59
+ c != null && (t[s] = !!c);
60
60
  }), t;
61
61
  }
62
- function yt(e) {
62
+ function bt(e) {
63
63
  let t = 0;
64
- for (let s = 0; s < e.length; s++)
65
- t = (t << 5) - t + e.charCodeAt(s) | 0;
64
+ for (let i = 0; i < e.length; i++)
65
+ t = (t << 5) - t + e.charCodeAt(i) | 0;
66
66
  return (t >>> 0).toString(36);
67
67
  }
68
- function kt(e) {
69
- var t = 0, s = e.children, n = s && s.length;
68
+ function k(e) {
69
+ if (typeof e == "string") {
70
+ const i = e;
71
+ e = (n) => n.matches(i);
72
+ }
73
+ const t = e;
74
+ return function() {
75
+ let n = Array.from(this.childNodes);
76
+ return t && (n = n.filter((o) => t(o))), n;
77
+ };
78
+ }
79
+ function Et(e) {
80
+ var t = 0, i = e.children, n = i && i.length;
70
81
  if (!n) t = 1;
71
- else for (; --n >= 0; ) t += s[n].value;
82
+ else for (; --n >= 0; ) t += i[n].value;
72
83
  e.value = t;
73
84
  }
74
- function vt() {
75
- return this.eachAfter(kt);
85
+ function zt() {
86
+ return this.eachAfter(Et);
76
87
  }
77
- function bt(e) {
78
- var t = this, s, n = [t], o, a, l;
88
+ function wt(e) {
89
+ var t = this, i, n = [t], o, a, l;
79
90
  do
80
- for (s = n.reverse(), n = []; t = s.pop(); )
91
+ for (i = n.reverse(), n = []; t = i.pop(); )
81
92
  if (e(t), o = t.children, o) for (a = 0, l = o.length; a < l; ++a)
82
93
  n.push(o[a]);
83
94
  while (n.length);
84
95
  return this;
85
96
  }
86
- function zt(e) {
87
- for (var t = this, s = [t], n, o; t = s.pop(); )
97
+ function Ct(e) {
98
+ for (var t = this, i = [t], n, o; t = i.pop(); )
88
99
  if (e(t), n = t.children, n) for (o = n.length - 1; o >= 0; --o)
89
- s.push(n[o]);
100
+ i.push(n[o]);
90
101
  return this;
91
102
  }
92
- function Et(e) {
93
- for (var t = this, s = [t], n = [], o, a, l; t = s.pop(); )
103
+ function St(e) {
104
+ for (var t = this, i = [t], n = [], o, a, l; t = i.pop(); )
94
105
  if (n.push(t), o = t.children, o) for (a = 0, l = o.length; a < l; ++a)
95
- s.push(o[a]);
106
+ i.push(o[a]);
96
107
  for (; t = n.pop(); )
97
108
  e(t);
98
109
  return this;
99
110
  }
100
- function Ct(e) {
111
+ function Rt(e) {
101
112
  return this.eachAfter(function(t) {
102
- for (var s = +e(t.data) || 0, n = t.children, o = n && n.length; --o >= 0; ) s += n[o].value;
103
- t.value = s;
113
+ for (var i = +e(t.data) || 0, n = t.children, o = n && n.length; --o >= 0; ) i += n[o].value;
114
+ t.value = i;
104
115
  });
105
116
  }
106
- function wt(e) {
117
+ function Xt(e) {
107
118
  return this.eachBefore(function(t) {
108
119
  t.children && t.children.sort(e);
109
120
  });
110
121
  }
111
- function St(e) {
112
- for (var t = this, s = Rt(t, e), n = [t]; t !== s; )
122
+ function jt(e) {
123
+ for (var t = this, i = _t(t, e), n = [t]; t !== i; )
113
124
  t = t.parent, n.push(t);
114
- for (var o = n.length; e !== s; )
125
+ for (var o = n.length; e !== i; )
115
126
  n.splice(o, 0, e), e = e.parent;
116
127
  return n;
117
128
  }
118
- function Rt(e, t) {
129
+ function _t(e, t) {
119
130
  if (e === t) return e;
120
- var s = e.ancestors(), n = t.ancestors(), o = null;
121
- for (e = s.pop(), t = n.pop(); e === t; )
122
- o = e, e = s.pop(), t = n.pop();
131
+ var i = e.ancestors(), n = t.ancestors(), o = null;
132
+ for (e = i.pop(), t = n.pop(); e === t; )
133
+ o = e, e = i.pop(), t = n.pop();
123
134
  return o;
124
135
  }
125
- function Xt() {
136
+ function Mt() {
126
137
  for (var e = this, t = [e]; e = e.parent; )
127
138
  t.push(e);
128
139
  return t;
129
140
  }
130
- function Mt() {
141
+ function Ot() {
131
142
  var e = [];
132
143
  return this.each(function(t) {
133
144
  e.push(t);
134
145
  }), e;
135
146
  }
136
- function jt() {
147
+ function At() {
137
148
  var e = [];
138
149
  return this.eachBefore(function(t) {
139
150
  t.children || e.push(t);
140
151
  }), e;
141
152
  }
142
- function Ot() {
153
+ function Tt() {
143
154
  var e = this, t = [];
144
- return e.each(function(s) {
145
- s !== e && t.push({ source: s.parent, target: s });
155
+ return e.each(function(i) {
156
+ i !== e && t.push({ source: i.parent, target: i });
146
157
  }), t;
147
158
  }
148
- function B(e, t) {
149
- var s = new R(e), n = +e.value && (s.value = e.value), o, a = [s], l, r, c, p;
150
- for (t == null && (t = At); o = a.pop(); )
151
- if (n && (o.value = +o.data.value), (r = t(o.data)) && (p = r.length))
159
+ function H(e, t) {
160
+ var i = new j(e), n = +e.value && (i.value = e.value), o, a = [i], l, s, c, p;
161
+ for (t == null && (t = Bt); o = a.pop(); )
162
+ if (n && (o.value = +o.data.value), (s = t(o.data)) && (p = s.length))
152
163
  for (o.children = new Array(p), c = p - 1; c >= 0; --c)
153
- a.push(l = o.children[c] = new R(r[c])), l.parent = o, l.depth = o.depth + 1;
154
- return s.eachBefore(Ft);
164
+ a.push(l = o.children[c] = new j(s[c])), l.parent = o, l.depth = o.depth + 1;
165
+ return i.eachBefore(Dt);
155
166
  }
156
- function Bt() {
157
- return B(this).eachBefore($t);
167
+ function Ht() {
168
+ return H(this).eachBefore(Lt);
158
169
  }
159
- function At(e) {
170
+ function Bt(e) {
160
171
  return e.children;
161
172
  }
162
- function $t(e) {
173
+ function Lt(e) {
163
174
  e.data = e.data.data;
164
175
  }
165
- function Ft(e) {
176
+ function Dt(e) {
166
177
  var t = 0;
167
178
  do
168
179
  e.height = t;
169
180
  while ((e = e.parent) && e.height < ++t);
170
181
  }
171
- function R(e) {
182
+ function j(e) {
172
183
  this.data = e, this.depth = this.height = 0, this.parent = null;
173
184
  }
174
- R.prototype = B.prototype = {
175
- constructor: R,
176
- count: vt,
177
- each: bt,
178
- eachAfter: Et,
179
- eachBefore: zt,
180
- sum: Ct,
181
- sort: wt,
182
- path: St,
183
- ancestors: Xt,
184
- descendants: Mt,
185
- leaves: jt,
186
- links: Ot,
187
- copy: Bt
185
+ j.prototype = H.prototype = {
186
+ constructor: j,
187
+ count: zt,
188
+ each: wt,
189
+ eachAfter: St,
190
+ eachBefore: Ct,
191
+ sum: Rt,
192
+ sort: Xt,
193
+ path: jt,
194
+ ancestors: Mt,
195
+ descendants: Ot,
196
+ leaves: At,
197
+ links: Tt,
198
+ copy: Ht
188
199
  };
189
- const Tt = "d3-flextree", Dt = "2.1.2", _t = "build/d3-flextree.js", Ht = "index", Nt = { name: "Chris Maloney", url: "http://chrismaloney.org" }, Lt = "Flexible tree layout algorithm that allows for variable node sizes.", Pt = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"], Wt = "https://github.com/klortho/d3-flextree", It = "WTFPL", Kt = { type: "git", url: "https://github.com/klortho/d3-flextree.git" }, Gt = { clean: "rm -rf build demo test", "build:demo": "rollup -c --environment BUILD:demo", "build:dev": "rollup -c --environment BUILD:dev", "build:prod": "rollup -c --environment BUILD:prod", "build:test": "rollup -c --environment BUILD:test", build: "rollup -c", lint: "eslint index.js src", "test:main": "node test/bundle.js", "test:browser": "node test/browser-tests.js", test: "npm-run-all test:*", prepare: "npm-run-all clean build lint test" }, Vt = { "d3-hierarchy": "^1.1.5" }, Ut = { "babel-plugin-external-helpers": "^6.22.0", "babel-preset-es2015-rollup": "^3.0.0", d3: "^4.13.0", "d3-selection-multi": "^1.0.1", eslint: "^4.19.1", jsdom: "^11.6.2", "npm-run-all": "^4.1.2", rollup: "^0.55.3", "rollup-plugin-babel": "^2.7.1", "rollup-plugin-commonjs": "^8.0.2", "rollup-plugin-copy": "^0.2.3", "rollup-plugin-json": "^2.3.0", "rollup-plugin-node-resolve": "^3.0.2", "rollup-plugin-uglify": "^3.0.0", "uglify-es": "^3.3.9" }, Yt = {
190
- name: Tt,
191
- version: Dt,
192
- main: _t,
193
- module: Ht,
200
+ const Ft = "d3-flextree", $t = "2.1.2", Nt = "build/d3-flextree.js", It = "index", Pt = { name: "Chris Maloney", url: "http://chrismaloney.org" }, Wt = "Flexible tree layout algorithm that allows for variable node sizes.", Kt = ["d3", "d3-module", "layout", "tree", "hierarchy", "d3-hierarchy", "plugin", "d3-plugin", "infovis", "visualization", "2d"], Gt = "https://github.com/klortho/d3-flextree", Vt = "WTFPL", Ut = { type: "git", url: "https://github.com/klortho/d3-flextree.git" }, Yt = { clean: "rm -rf build demo test", "build:demo": "rollup -c --environment BUILD:demo", "build:dev": "rollup -c --environment BUILD:dev", "build:prod": "rollup -c --environment BUILD:prod", "build:test": "rollup -c --environment BUILD:test", build: "rollup -c", lint: "eslint index.js src", "test:main": "node test/bundle.js", "test:browser": "node test/browser-tests.js", test: "npm-run-all test:*", prepare: "npm-run-all clean build lint test" }, Zt = { "d3-hierarchy": "^1.1.5" }, qt = { "babel-plugin-external-helpers": "^6.22.0", "babel-preset-es2015-rollup": "^3.0.0", d3: "^4.13.0", "d3-selection-multi": "^1.0.1", eslint: "^4.19.1", jsdom: "^11.6.2", "npm-run-all": "^4.1.2", rollup: "^0.55.3", "rollup-plugin-babel": "^2.7.1", "rollup-plugin-commonjs": "^8.0.2", "rollup-plugin-copy": "^0.2.3", "rollup-plugin-json": "^2.3.0", "rollup-plugin-node-resolve": "^3.0.2", "rollup-plugin-uglify": "^3.0.0", "uglify-es": "^3.3.9" }, Jt = {
201
+ name: Ft,
202
+ version: $t,
203
+ main: Nt,
204
+ module: It,
194
205
  "jsnext:main": "index",
195
- author: Nt,
196
- description: Lt,
197
- keywords: Pt,
198
- homepage: Wt,
199
- license: It,
200
- repository: Kt,
201
- scripts: Gt,
202
- dependencies: Vt,
203
- devDependencies: Ut
204
- }, { version: Zt } = Yt, qt = Object.freeze({
206
+ author: Pt,
207
+ description: Wt,
208
+ keywords: Kt,
209
+ homepage: Gt,
210
+ license: Vt,
211
+ repository: Ut,
212
+ scripts: Yt,
213
+ dependencies: Zt,
214
+ devDependencies: qt
215
+ }, { version: Qt } = Jt, te = Object.freeze({
205
216
  children: (e) => e.children,
206
217
  nodeSize: (e) => e.data.size,
207
218
  spacing: 0
208
219
  });
209
- function Z(e) {
210
- const t = Object.assign({}, qt, e);
211
- function s(r) {
212
- const c = t[r];
220
+ function Q(e) {
221
+ const t = Object.assign({}, te, e);
222
+ function i(s) {
223
+ const c = t[s];
213
224
  return typeof c == "function" ? c : () => c;
214
225
  }
215
- function n(r) {
216
- const c = l(a(), r, (p) => p.children);
226
+ function n(s) {
227
+ const c = l(a(), s, (p) => p.children);
217
228
  return c.update(), c.data;
218
229
  }
219
230
  function o() {
220
- const r = s("nodeSize"), c = s("spacing");
221
- return class Y extends B.prototype.constructor {
231
+ const s = i("nodeSize"), c = i("spacing");
232
+ return class J extends H.prototype.constructor {
222
233
  constructor(h) {
223
234
  super(h);
224
235
  }
@@ -227,7 +238,7 @@ function Z(e) {
227
238
  return h.each((u) => u.data = u.data.data), h;
228
239
  }
229
240
  get size() {
230
- return r(this);
241
+ return s(this);
231
242
  }
232
243
  spacing(h) {
233
244
  return c(this, h);
@@ -274,7 +285,7 @@ function Z(e) {
274
285
  }
275
286
  get extents() {
276
287
  return (this.children || []).reduce(
277
- (h, u) => Y.maxExtents(h, u.extents),
288
+ (h, u) => J.maxExtents(h, u.extents),
278
289
  this.nodeExtents
279
290
  );
280
291
  }
@@ -297,8 +308,8 @@ function Z(e) {
297
308
  };
298
309
  }
299
310
  function a() {
300
- const r = o(), c = s("nodeSize"), p = s("spacing");
301
- return class extends r {
311
+ const s = o(), c = i("nodeSize"), p = i("spacing");
312
+ return class extends s {
302
313
  constructor(h) {
303
314
  super(h), Object.assign(this, {
304
315
  x: 0,
@@ -334,196 +345,196 @@ function Z(e) {
334
345
  this.data.y = h;
335
346
  }
336
347
  update() {
337
- return q(this), J(this), this;
348
+ return tt(this), et(this), this;
338
349
  }
339
350
  };
340
351
  }
341
- function l(r, c, p) {
342
- const h = (u, m) => {
343
- const g = new r(u);
344
- Object.assign(g, {
345
- parent: m,
346
- depth: m === null ? 0 : m.depth + 1,
352
+ function l(s, c, p) {
353
+ const h = (u, g) => {
354
+ const m = new s(u);
355
+ Object.assign(m, {
356
+ parent: g,
357
+ depth: g === null ? 0 : g.depth + 1,
347
358
  height: 0,
348
359
  length: 1
349
360
  });
350
361
  const y = p(u) || [];
351
- return g.children = y.length === 0 ? null : y.map((x) => h(x, g)), g.children && Object.assign(g, g.children.reduce(
352
- (x, b) => ({
353
- height: Math.max(x.height, b.height + 1),
354
- length: x.length + b.length
362
+ return m.children = y.length === 0 ? null : y.map((f) => h(f, m)), m.children && Object.assign(m, m.children.reduce(
363
+ (f, b) => ({
364
+ height: Math.max(f.height, b.height + 1),
365
+ length: f.length + b.length
355
366
  }),
356
- g
357
- )), g;
367
+ m
368
+ )), m;
358
369
  };
359
370
  return h(c, null);
360
371
  }
361
372
  return Object.assign(n, {
362
- nodeSize(r) {
363
- return arguments.length ? (t.nodeSize = r, n) : t.nodeSize;
373
+ nodeSize(s) {
374
+ return arguments.length ? (t.nodeSize = s, n) : t.nodeSize;
364
375
  },
365
- spacing(r) {
366
- return arguments.length ? (t.spacing = r, n) : t.spacing;
376
+ spacing(s) {
377
+ return arguments.length ? (t.spacing = s, n) : t.spacing;
367
378
  },
368
- children(r) {
369
- return arguments.length ? (t.children = r, n) : t.children;
379
+ children(s) {
380
+ return arguments.length ? (t.children = s, n) : t.children;
370
381
  },
371
- hierarchy(r, c) {
382
+ hierarchy(s, c) {
372
383
  const p = typeof c > "u" ? t.children : c;
373
- return l(o(), r, p);
384
+ return l(o(), s, p);
374
385
  },
375
- dump(r) {
376
- const c = s("nodeSize"), p = (h) => (u) => {
377
- const m = h + " ", g = h + " ", { x: y, y: x } = u, b = c(u), k = u.children || [], z = k.length === 0 ? " " : `,${m}children: [${g}${k.map(p(g)).join(g)}${m}],${h}`;
378
- return `{ size: [${b.join(", ")}],${m}x: ${y}, y: ${x}${z}},`;
386
+ dump(s) {
387
+ const c = i("nodeSize"), p = (h) => (u) => {
388
+ const g = h + " ", m = h + " ", { x: y, y: f } = u, b = c(u), v = u.children || [], w = v.length === 0 ? " " : `,${g}children: [${m}${v.map(p(m)).join(m)}${g}],${h}`;
389
+ return `{ size: [${b.join(", ")}],${g}x: ${y}, y: ${f}${w}},`;
379
390
  };
380
391
  return p(`
381
- `)(r);
392
+ `)(s);
382
393
  }
383
394
  }), n;
384
395
  }
385
- Z.version = Zt;
386
- const q = (e, t = 0) => (e.y = t, (e.children || []).reduce((s, n) => {
387
- const [o, a] = s;
388
- q(n, e.y + e.ySize);
396
+ Q.version = Qt;
397
+ const tt = (e, t = 0) => (e.y = t, (e.children || []).reduce((i, n) => {
398
+ const [o, a] = i;
399
+ tt(n, e.y + e.ySize);
389
400
  const l = (o === 0 ? n.lExt : n.rExt).bottom;
390
- o !== 0 && Qt(e, o, a);
391
- const r = ae(l, o, a);
392
- return [o + 1, r];
393
- }, [0, null]), Jt(e), oe(e), e), J = (e, t, s) => {
394
- typeof t > "u" && (t = -e.relX - e.prelim, s = 0);
401
+ o !== 0 && re(e, o, a);
402
+ const s = he(l, o, a);
403
+ return [o + 1, s];
404
+ }, [0, null]), ee(e), ce(e), e), et = (e, t, i) => {
405
+ typeof t > "u" && (t = -e.relX - e.prelim, i = 0);
395
406
  const n = t + e.relX;
396
- return e.relX = n + e.prelim - s, e.prelim = 0, e.x = s + e.relX, (e.children || []).forEach((o) => J(o, n, e.x)), e;
397
- }, Jt = (e) => {
398
- (e.children || []).reduce((t, s) => {
399
- const [n, o] = t, a = n + s.shift, l = o + a + s.change;
400
- return s.relX += l, [a, l];
407
+ return e.relX = n + e.prelim - i, e.prelim = 0, e.x = i + e.relX, (e.children || []).forEach((o) => et(o, n, e.x)), e;
408
+ }, ee = (e) => {
409
+ (e.children || []).reduce((t, i) => {
410
+ const [n, o] = t, a = n + i.shift, l = o + a + i.change;
411
+ return i.relX += l, [a, l];
401
412
  }, [0, 0]);
402
- }, Qt = (e, t, s) => {
413
+ }, re = (e, t, i) => {
403
414
  const n = e.children[t - 1], o = e.children[t];
404
- let a = n, l = n.relX, r = o, c = o.relX, p = !0;
405
- for (; a && r; ) {
406
- a.bottom > s.lowY && (s = s.next);
407
- const h = l + a.prelim - (c + r.prelim) + a.xSize / 2 + r.xSize / 2 + a.spacing(r);
408
- (h > 0 || h < 0 && p) && (c += h, te(o, h), ee(e, t, s.index, h)), p = !1;
409
- const u = a.bottom, m = r.bottom;
410
- u <= m && (a = ne(a), a && (l += a.relX)), u >= m && (r = re(r), r && (c += r.relX));
415
+ let a = n, l = n.relX, s = o, c = o.relX, p = !0;
416
+ for (; a && s; ) {
417
+ a.bottom > i.lowY && (i = i.next);
418
+ const h = l + a.prelim - (c + s.prelim) + a.xSize / 2 + s.xSize / 2 + a.spacing(s);
419
+ (h > 0 || h < 0 && p) && (c += h, ne(o, h), ie(e, t, i.index, h)), p = !1;
420
+ const u = a.bottom, g = s.bottom;
421
+ u <= g && (a = oe(a), a && (l += a.relX)), u >= g && (s = se(s), s && (c += s.relX));
411
422
  }
412
- !a && r ? se(e, t, r, c) : a && !r && ie(e, t, a, l);
413
- }, te = (e, t) => {
423
+ !a && s ? ae(e, t, s, c) : a && !s && le(e, t, a, l);
424
+ }, ne = (e, t) => {
414
425
  e.relX += t, e.lExtRelX += t, e.rExtRelX += t;
415
- }, ee = (e, t, s, n) => {
416
- const o = e.children[t], a = t - s;
426
+ }, ie = (e, t, i, n) => {
427
+ const o = e.children[t], a = t - i;
417
428
  if (a > 1) {
418
429
  const l = n / a;
419
- e.children[s + 1].shift += l, o.shift -= l, o.change -= n - l;
430
+ e.children[i + 1].shift += l, o.shift -= l, o.change -= n - l;
420
431
  }
421
- }, re = (e) => e.hasChildren ? e.firstChild : e.lThr, ne = (e) => e.hasChildren ? e.lastChild : e.rThr, se = (e, t, s, n) => {
432
+ }, se = (e) => e.hasChildren ? e.firstChild : e.lThr, oe = (e) => e.hasChildren ? e.lastChild : e.rThr, ae = (e, t, i, n) => {
422
433
  const o = e.firstChild, a = o.lExt, l = e.children[t];
423
- a.lThr = s;
424
- const r = n - s.relX - o.lExtRelX;
425
- a.relX += r, a.prelim -= r, o.lExt = l.lExt, o.lExtRelX = l.lExtRelX;
426
- }, ie = (e, t, s, n) => {
434
+ a.lThr = i;
435
+ const s = n - i.relX - o.lExtRelX;
436
+ a.relX += s, a.prelim -= s, o.lExt = l.lExt, o.lExtRelX = l.lExtRelX;
437
+ }, le = (e, t, i, n) => {
427
438
  const o = e.children[t], a = o.rExt, l = e.children[t - 1];
428
- a.rThr = s;
429
- const r = n - s.relX - o.rExtRelX;
430
- a.relX += r, a.prelim -= r, o.rExt = l.rExt, o.rExtRelX = l.rExtRelX;
431
- }, oe = (e) => {
439
+ a.rThr = i;
440
+ const s = n - i.relX - o.rExtRelX;
441
+ a.relX += s, a.prelim -= s, o.rExt = l.rExt, o.rExtRelX = l.rExtRelX;
442
+ }, ce = (e) => {
432
443
  if (e.hasChildren) {
433
- const t = e.firstChild, s = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + s.relX + s.prelim + s.xSize / 2) / 2;
444
+ const t = e.firstChild, i = e.lastChild, n = (t.prelim + t.relX - t.xSize / 2 + i.relX + i.prelim + i.xSize / 2) / 2;
434
445
  Object.assign(e, {
435
446
  prelim: n,
436
447
  lExt: t.lExt,
437
448
  lExtRelX: t.lExtRelX,
438
- rExt: s.rExt,
439
- rExtRelX: s.rExtRelX
449
+ rExt: i.rExt,
450
+ rExtRelX: i.rExtRelX
440
451
  });
441
452
  }
442
- }, ae = (e, t, s) => {
443
- for (; s !== null && e >= s.lowY; )
444
- s = s.next;
453
+ }, he = (e, t, i) => {
454
+ for (; i !== null && e >= i.lowY; )
455
+ i = i.next;
445
456
  return {
446
457
  lowY: e,
447
458
  index: t,
448
- next: s
459
+ next: i
449
460
  };
450
- }, Q = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", me = Q, j = pt();
451
- function I(e) {
461
+ }, rt = ".markmap{--markmap-max-width: 9999px;--markmap-a-color: #0097e6;--markmap-a-hover-color: #00a8ff;--markmap-code-bg: #f0f0f0;--markmap-code-color: #555;--markmap-highlight-bg: #ffeaa7;--markmap-table-border: 1px solid currentColor;--markmap-font: 300 16px/20px sans-serif;--markmap-circle-open-bg: #fff;--markmap-text-color: #333;--markmap-highlight-node-bg: #ff02;font:var(--markmap-font);color:var(--markmap-text-color)}.markmap-link{fill:none}.markmap-node>circle{cursor:pointer}.markmap-foreign{display:inline-block}.markmap-foreign p{margin:0}.markmap-foreign a{color:var(--markmap-a-color)}.markmap-foreign a:hover{color:var(--markmap-a-hover-color)}.markmap-foreign code{padding:.25em;font-size:calc(1em - 2px);color:var(--markmap-code-color);background-color:var(--markmap-code-bg);border-radius:2px}.markmap-foreign pre{margin:0}.markmap-foreign pre>code{display:block}.markmap-foreign del{text-decoration:line-through}.markmap-foreign em{font-style:italic}.markmap-foreign strong{font-weight:700}.markmap-foreign mark{background:var(--markmap-highlight-bg)}.markmap-foreign table,.markmap-foreign th,.markmap-foreign td{border-collapse:collapse;border:var(--markmap-table-border)}.markmap-foreign img{display:inline-block}.markmap-foreign svg{fill:currentColor}.markmap-foreign>div{width:var(--markmap-max-width);text-align:left}.markmap-foreign>div>div{display:inline-block}.markmap-highlight rect{fill:var(--markmap-highlight-node-bg)}.markmap-dark .markmap{--markmap-code-bg: #1a1b26;--markmap-code-color: #ddd;--markmap-circle-open-bg: #444;--markmap-text-color: #eee}", ke = rt, O = "g.markmap-node", de = "path.markmap-link", pe = "g.markmap-highlight", A = mt();
462
+ function V(e) {
452
463
  return Math.max(4 - 2 * e.state.depth, 1.5);
453
464
  }
454
- function K(e, t) {
455
- const s = ft(e, t);
456
- return e[s];
465
+ function U(e, t) {
466
+ const i = kt(e, t);
467
+ return e[i];
457
468
  }
458
- function O(e) {
469
+ function T(e) {
459
470
  e.stopPropagation();
460
471
  }
461
- const le = new at();
462
- class tt {
463
- constructor(t, s) {
464
- this.options = U, this.revokers = [], this.handleZoom = (n) => {
472
+ const ue = new ht();
473
+ class nt {
474
+ constructor(t, i) {
475
+ this.options = q, this._disposeList = [], this.handleZoom = (n) => {
465
476
  const { transform: o } = n;
466
477
  this.g.attr("transform", o);
467
478
  }, this.handlePan = (n) => {
468
479
  n.preventDefault();
469
- const o = S(this.svg.node()), a = o.translate(
480
+ const o = z(this.svg.node()), a = o.translate(
470
481
  -n.deltaX / o.k,
471
482
  -n.deltaY / o.k
472
483
  );
473
484
  this.svg.call(this.zoom.transform, a);
474
485
  }, this.handleClick = (n, o) => {
475
486
  let a = this.options.toggleRecursively;
476
- (V ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(o, a);
477
- }, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ut(t), this.styleNode = this.svg.append("style"), this.zoom = mt().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(s), this.state = {
478
- id: this.options.id || this.svg.attr("id") || lt(),
487
+ (Z ? n.metaKey : n.ctrlKey) && (a = !a), this.toggleNode(o, a);
488
+ }, this.ensureView = this.ensureVisible, this.svg = t.datum ? t : ft(t), this.styleNode = this.svg.append("style"), this.zoom = xt().filter((n) => this.options.scrollForPan && n.type === "wheel" ? n.ctrlKey && !n.button : (!n.ctrlKey || n.type === "wheel") && !n.button).on("zoom", this.handleZoom), this.setOptions(i), this.state = {
489
+ id: this.options.id || this.svg.attr("id") || dt(),
479
490
  rect: { x1: 0, y1: 0, x2: 0, y2: 0 }
480
- }, this.g = this.svg.append("g"), this.observer = new ResizeObserver(
481
- ct(() => {
491
+ }, this.g = this.svg.append("g"), this.g.append("g").attr("class", "markmap-highlight"), this._observer = new ResizeObserver(
492
+ pt(() => {
482
493
  this.renderData();
483
494
  }, 100)
484
- ), this.revokers.push(
485
- le.tap(() => {
495
+ ), this._disposeList.push(
496
+ ue.tap(() => {
486
497
  this.setData();
487
498
  }),
488
- () => this.observer.disconnect()
499
+ () => this._observer.disconnect()
489
500
  );
490
501
  }
491
502
  getStyleContent() {
492
- const { style: t } = this.options, { id: s } = this.state, n = typeof t == "function" ? t(s) : "";
493
- return [this.options.embedGlobalCSS && Q, n].filter(Boolean).join(`
503
+ const { style: t } = this.options, { id: i } = this.state, n = typeof t == "function" ? t(i) : "";
504
+ return [this.options.embedGlobalCSS && rt, n].filter(Boolean).join(`
494
505
  `);
495
506
  }
496
507
  updateStyle() {
497
508
  this.svg.attr(
498
509
  "class",
499
- ht(this.svg.attr("class"), "markmap", this.state.id)
510
+ ut(this.svg.attr("class"), "markmap", this.state.id)
500
511
  );
501
512
  const t = this.getStyleContent();
502
513
  this.styleNode.text(t);
503
514
  }
504
- async toggleNode(t, s = !1) {
515
+ async toggleNode(t, i = !1) {
505
516
  var o, a;
506
517
  const n = (o = t.payload) != null && o.fold ? 0 : 1;
507
- s ? C(t, (l, r) => {
518
+ i ? R(t, (l, s) => {
508
519
  l.payload = {
509
520
  ...l.payload,
510
521
  fold: n
511
- }, r();
522
+ }, s();
512
523
  }) : t.payload = {
513
524
  ...t.payload,
514
525
  fold: (a = t.payload) != null && a.fold ? 0 : 1
515
526
  }, await this.renderData(t);
516
527
  }
517
528
  _initializeData(t) {
518
- let s = 0;
529
+ let i = 0;
519
530
  const { color: n, initialExpandLevel: o } = this.options;
520
531
  let a = 0, l = 0;
521
- C(t, (r, c, p) => {
522
- var u, m, g, y;
523
- l += 1, r.children = (u = r.children) == null ? void 0 : u.map((x) => ({ ...x })), s += 1, r.state = {
524
- ...r.state,
532
+ return R(t, (s, c, p) => {
533
+ var u, g, m, y;
534
+ l += 1, s.children = (u = s.children) == null ? void 0 : u.map((f) => ({ ...f })), i += 1, s.state = {
535
+ ...s.state,
525
536
  depth: l,
526
- id: s,
537
+ id: i,
527
538
  rect: {
528
539
  x: 0,
529
540
  y: 0,
@@ -531,47 +542,47 @@ class tt {
531
542
  height: 0
532
543
  },
533
544
  size: [0, 0]
534
- }, r.state.key = [(m = p == null ? void 0 : p.state) == null ? void 0 : m.id, r.state.id].filter(Boolean).join(".") + yt(r.content), r.state.path = [(g = p == null ? void 0 : p.state) == null ? void 0 : g.path, r.state.id].filter(Boolean).join("."), n(r);
535
- const h = ((y = r.payload) == null ? void 0 : y.fold) === 2;
536
- h ? a += 1 : (a || o >= 0 && r.state.depth >= o) && (r.payload = { ...r.payload, fold: 1 }), c(), h && (a -= 1), l -= 1;
537
- });
545
+ }, s.state.key = [(g = p == null ? void 0 : p.state) == null ? void 0 : g.id, s.state.id].filter(Boolean).join(".") + bt(s.content), s.state.path = [(m = p == null ? void 0 : p.state) == null ? void 0 : m.path, s.state.id].filter(Boolean).join("."), n(s);
546
+ const h = ((y = s.payload) == null ? void 0 : y.fold) === 2;
547
+ h ? a += 1 : (a || o >= 0 && s.state.depth >= o) && (s.payload = { ...s.payload, fold: 1 }), c(), h && (a -= 1), l -= 1;
548
+ }), t;
538
549
  }
539
550
  _relayout() {
540
551
  if (!this.state.data) return;
541
- this.g.selectAll(v("g")).selectAll(
542
- v("foreignObject")
543
- ).each(function(r) {
552
+ this.g.selectAll(k(O)).selectAll(
553
+ k("foreignObject")
554
+ ).each(function(s) {
544
555
  var h;
545
556
  const c = (h = this.firstChild) == null ? void 0 : h.firstChild, p = [c.scrollWidth, c.scrollHeight];
546
- r.state.size = p;
557
+ s.state.size = p;
547
558
  });
548
- const { spacingHorizontal: t, paddingX: s, spacingVertical: n } = this.options, o = Z({}).children((r) => {
559
+ const { spacingHorizontal: t, paddingX: i, spacingVertical: n } = this.options, o = Q({}).children((s) => {
549
560
  var c;
550
- if (!((c = r.payload) != null && c.fold)) return r.children;
551
- }).nodeSize((r) => {
552
- const [c, p] = r.data.state.size;
553
- return [p, c + (c ? s * 2 : 0) + t];
554
- }).spacing((r, c) => r.parent === c.parent ? n : n * 2), a = o.hierarchy(this.state.data);
561
+ if (!((c = s.payload) != null && c.fold)) return s.children;
562
+ }).nodeSize((s) => {
563
+ const [c, p] = s.data.state.size;
564
+ return [p, c + (c ? i * 2 : 0) + t];
565
+ }).spacing((s, c) => s.parent === c.parent ? n : n * 2), a = o.hierarchy(this.state.data);
555
566
  o(a);
556
567
  const l = a.descendants();
557
- l.forEach((r) => {
558
- const c = r.data;
568
+ l.forEach((s) => {
569
+ const c = s.data;
559
570
  c.state.rect = {
560
- x: r.y,
561
- y: r.x - r.xSize / 2,
562
- width: r.ySize - t,
563
- height: r.xSize
571
+ x: s.y,
572
+ y: s.x - s.xSize / 2,
573
+ width: s.ySize - t,
574
+ height: s.xSize
564
575
  };
565
576
  }), this.state.rect = {
566
- x1: P(l, (r) => r.data.state.rect.x) || 0,
567
- y1: P(l, (r) => r.data.state.rect.y) || 0,
568
- x2: W(
577
+ x1: K(l, (s) => s.data.state.rect.x) || 0,
578
+ y1: K(l, (s) => s.data.state.rect.y) || 0,
579
+ x2: G(
569
580
  l,
570
- (r) => r.data.state.rect.x + r.data.state.rect.width
581
+ (s) => s.data.state.rect.x + s.data.state.rect.width
571
582
  ) || 0,
572
- y2: W(
583
+ y2: G(
573
584
  l,
574
- (r) => r.data.state.rect.y + r.data.state.rect.height
585
+ (s) => s.data.state.rect.y + s.data.state.rect.height
575
586
  ) || 0
576
587
  };
577
588
  }
@@ -581,215 +592,227 @@ class tt {
581
592
  ...t
582
593
  }, this.options.zoom ? this.svg.call(this.zoom) : this.svg.on(".zoom", null), this.options.pan ? this.svg.on("wheel", this.handlePan) : this.svg.on("wheel", null);
583
594
  }
584
- async setData(t, s) {
585
- s && this.setOptions(s), t && (this.state.data = t), this.state.data && (this._initializeData(this.state.data), this.updateStyle(), await this.renderData());
595
+ async setData(t, i) {
596
+ i && this.setOptions(i), t && (this.state.data = this._initializeData(t)), this.state.data && (this.updateStyle(), await this.renderData());
597
+ }
598
+ async setHighlight(t) {
599
+ this.state.highlight = t || void 0, await this.renderData();
600
+ }
601
+ _getHighlightRect(t) {
602
+ const i = this.svg.node(), o = 4 / z(i).k, a = {
603
+ ...t.state.rect
604
+ };
605
+ return a.x -= o, a.y -= o, a.width += 2 * o, a.height += 2 * o, a;
586
606
  }
587
607
  async renderData(t) {
588
- const { paddingX: s, autoFit: n, color: o, maxWidth: a } = this.options, l = this.state.data;
608
+ const { paddingX: i, autoFit: n, color: o, maxWidth: a } = this.options, l = this.state.data;
589
609
  if (!l) return;
590
- const r = {}, c = {}, p = [];
591
- C(l, (i, d, f) => {
610
+ const s = {}, c = {}, p = [];
611
+ R(l, (r, d, x) => {
592
612
  var E;
593
- (E = i.payload) != null && E.fold || d(), r[i.state.id] = i, f && (c[i.state.id] = f.state.id), p.push(i);
613
+ (E = r.payload) != null && E.fold || d(), s[r.state.id] = r, x && (c[r.state.id] = x.state.id), p.push(r);
594
614
  });
595
- const h = {}, u = {}, m = (i) => {
596
- !i || h[i.state.id] || C(i, (d, f) => {
597
- h[d.state.id] = i.state.id, f();
615
+ const h = {}, u = {}, g = (r) => {
616
+ !r || h[r.state.id] || R(r, (d, x) => {
617
+ h[d.state.id] = r.state.id, x();
598
618
  });
599
- }, g = (i) => u[h[i.state.id]] || l.state.rect, y = (i) => (r[h[i.state.id]] || l).state.rect;
600
- u[l.state.id] = l.state.rect, t && m(t);
601
- const x = this.g.selectAll(v("g")).each((i) => {
602
- u[i.state.id] = i.state.rect;
603
- }).data(p, (i) => i.state.key), b = x.enter().append("g").attr("data-depth", (i) => i.state.depth).attr("data-path", (i) => i.state.path).each((i) => {
604
- m(r[c[i.state.id]]);
605
- }), k = x.exit().each((i) => {
606
- m(r[c[i.state.id]]);
607
- }), z = x.merge(b).attr(
619
+ }, m = (r) => u[h[r.state.id]] || l.state.rect, y = (r) => (s[h[r.state.id]] || l).state.rect;
620
+ u[l.state.id] = l.state.rect, t && g(t);
621
+ const { highlight: f } = this.state;
622
+ let b = this.g.selectAll(k(pe)).selectAll(k("rect")).data(f ? [this._getHighlightRect(f)] : []).join("rect").attr("x", (r) => r.x).attr("y", (r) => r.y).attr("width", (r) => r.width).attr("height", (r) => r.height);
623
+ const v = this.g.selectAll(k(O)).each((r) => {
624
+ u[r.state.id] = r.state.rect;
625
+ }).data(p, (r) => r.state.key), w = v.enter().append("g").attr("data-depth", (r) => r.state.depth).attr("data-path", (r) => r.state.path).each((r) => {
626
+ g(s[c[r.state.id]]);
627
+ }), C = v.exit().each((r) => {
628
+ g(s[c[r.state.id]]);
629
+ }), S = v.merge(w).attr(
608
630
  "class",
609
- (i) => {
631
+ (r) => {
610
632
  var d;
611
- return ["markmap-node", ((d = i.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
633
+ return ["markmap-node", ((d = r.payload) == null ? void 0 : d.fold) && "markmap-fold"].filter(Boolean).join(" ");
612
634
  }
613
- ), A = z.selectAll(v("line")).data(
614
- (i) => [i],
615
- (i) => i.state.key
616
- ), $ = A.enter().append("line").attr("stroke", (i) => o(i)).attr("stroke-width", 0), F = A.merge($), T = z.selectAll(v("circle")).data(
617
- (i) => {
635
+ ), B = S.selectAll(k("line")).data(
636
+ (r) => [r],
637
+ (r) => r.state.key
638
+ ), L = B.enter().append("line").attr("stroke", (r) => o(r)).attr("stroke-width", 0), D = B.merge(L), F = S.selectAll(k("circle")).data(
639
+ (r) => {
618
640
  var d;
619
- return (d = i.children) != null && d.length ? [i] : [];
641
+ return (d = r.children) != null && d.length ? [r] : [];
620
642
  },
621
- (i) => i.state.key
622
- ), D = T.enter().append("circle").attr("stroke-width", 0).attr("r", 0).on("click", (i, d) => this.handleClick(i, d)).on("mousedown", O).merge(T).attr("stroke", (i) => o(i)).attr(
643
+ (r) => r.state.key
644
+ ), $ = F.enter().append("circle").attr("stroke-width", 0).attr("r", 0).on("click", (r, d) => this.handleClick(r, d)).on("mousedown", T).merge(F).attr("stroke", (r) => o(r)).attr(
623
645
  "fill",
624
- (i) => {
646
+ (r) => {
625
647
  var d;
626
- return (d = i.payload) != null && d.fold && i.children ? o(i) : "var(--markmap-circle-open-bg)";
648
+ return (d = r.payload) != null && d.fold && r.children ? o(r) : "var(--markmap-circle-open-bg)";
627
649
  }
628
- ), _ = this.observer, H = z.selectAll(v("foreignObject")).data(
629
- (i) => [i],
630
- (i) => i.state.key
631
- ), X = H.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", s).attr("y", 0).style("opacity", 0).on("mousedown", O).on("dblclick", O);
632
- X.append("xhtml:div").append("xhtml:div").html((i) => i.content).attr("xmlns", "http://www.w3.org/1999/xhtml"), X.each(function() {
650
+ ), N = this._observer, I = S.selectAll(k("foreignObject")).data(
651
+ (r) => [r],
652
+ (r) => r.state.key
653
+ ), _ = I.enter().append("foreignObject").attr("class", "markmap-foreign").attr("x", i).attr("y", 0).style("opacity", 0).on("mousedown", T).on("dblclick", T);
654
+ _.append("xhtml:div").append("xhtml:div").html((r) => r.content).attr("xmlns", "http://www.w3.org/1999/xhtml"), _.each(function() {
633
655
  var d;
634
- const i = (d = this.firstChild) == null ? void 0 : d.firstChild;
635
- _.observe(i);
656
+ const r = (d = this.firstChild) == null ? void 0 : d.firstChild;
657
+ N.observe(r);
636
658
  });
637
- const N = k.selectAll(
638
- v("foreignObject")
659
+ const P = C.selectAll(
660
+ k("foreignObject")
639
661
  );
640
- N.each(function() {
662
+ P.each(function() {
641
663
  var d;
642
- const i = (d = this.firstChild) == null ? void 0 : d.firstChild;
643
- _.unobserve(i);
664
+ const r = (d = this.firstChild) == null ? void 0 : d.firstChild;
665
+ N.unobserve(r);
644
666
  });
645
- const L = X.merge(H), et = p.flatMap(
646
- (i) => {
667
+ const W = _.merge(I), it = p.flatMap(
668
+ (r) => {
647
669
  var d;
648
- return (d = i.payload) != null && d.fold ? [] : i.children.map((f) => ({ source: i, target: f }));
670
+ return (d = r.payload) != null && d.fold ? [] : r.children.map((x) => ({ source: r, target: x }));
649
671
  }
650
- ), M = this.g.selectAll(v("path")).data(et, (i) => i.target.state.key), rt = M.exit(), nt = M.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (i) => i.target.state.depth).attr("data-path", (i) => i.target.state.path).attr("d", (i) => {
651
- const d = g(i.target), f = [
672
+ ), M = this.g.selectAll(k(de)).data(it, (r) => r.target.state.key), st = M.exit(), ot = M.enter().insert("path", "g").attr("class", "markmap-link").attr("data-depth", (r) => r.target.state.depth).attr("data-path", (r) => r.target.state.path).attr("d", (r) => {
673
+ const d = m(r.target), x = [
652
674
  d.x + d.width,
653
675
  d.y + d.height
654
676
  ];
655
- return j({ source: f, target: f });
677
+ return A({ source: x, target: x });
656
678
  }).attr("stroke-width", 0).merge(M);
657
679
  this.svg.style(
658
680
  "--markmap-max-width",
659
681
  a ? `${a}px` : null
660
- ), await new Promise(requestAnimationFrame), this._relayout(), b.attr("transform", (i) => {
661
- const d = g(i);
662
- return `translate(${d.x + d.width - i.state.rect.width},${d.y + d.height - i.state.rect.height})`;
663
- }), this.transition(k).attr("transform", (i) => {
664
- const d = y(i), f = d.x + d.width - i.state.rect.width, E = d.y + d.height - i.state.rect.height;
665
- return `translate(${f},${E})`;
666
- }).remove(), this.transition(z).attr(
682
+ ), await new Promise(requestAnimationFrame), this._relayout(), b = b.data(f ? [this._getHighlightRect(f)] : []).join("rect"), this.transition(b).attr("x", (r) => r.x).attr("y", (r) => r.y).attr("width", (r) => r.width).attr("height", (r) => r.height), w.attr("transform", (r) => {
683
+ const d = m(r);
684
+ return `translate(${d.x + d.width - r.state.rect.width},${d.y + d.height - r.state.rect.height})`;
685
+ }), this.transition(C).attr("transform", (r) => {
686
+ const d = y(r), x = d.x + d.width - r.state.rect.width, E = d.y + d.height - r.state.rect.height;
687
+ return `translate(${x},${E})`;
688
+ }).remove(), this.transition(S).attr(
667
689
  "transform",
668
- (i) => `translate(${i.state.rect.x},${i.state.rect.y})`
690
+ (r) => `translate(${r.state.rect.x},${r.state.rect.y})`
669
691
  );
670
- const st = k.selectAll(
671
- v("line")
692
+ const at = C.selectAll(
693
+ k("line")
672
694
  );
673
- this.transition(st).attr("x1", (i) => i.state.rect.width).attr("stroke-width", 0), $.attr("x1", (i) => i.state.rect.width).attr("x2", (i) => i.state.rect.width), F.attr("y1", (i) => i.state.rect.height).attr("y2", (i) => i.state.rect.height), this.transition(F).attr("x1", -1).attr("x2", (i) => i.state.rect.width + 2).attr("stroke", (i) => o(i)).attr("stroke-width", I);
674
- const it = k.selectAll(
675
- v("circle")
695
+ this.transition(at).attr("x1", (r) => r.state.rect.width).attr("stroke-width", 0), L.attr("x1", (r) => r.state.rect.width).attr("x2", (r) => r.state.rect.width), D.attr("y1", (r) => r.state.rect.height).attr("y2", (r) => r.state.rect.height), this.transition(D).attr("x1", -1).attr("x2", (r) => r.state.rect.width + 2).attr("stroke", (r) => o(r)).attr("stroke-width", V);
696
+ const lt = C.selectAll(
697
+ k("circle")
676
698
  );
677
- this.transition(it).attr("r", 0).attr("stroke-width", 0), D.attr("cx", (i) => i.state.rect.width).attr("cy", (i) => i.state.rect.height), this.transition(D).attr("r", 6).attr("stroke-width", "1.5"), this.transition(N).style("opacity", 0), L.attr("width", (i) => Math.max(0, i.state.rect.width - s * 2)).attr("height", (i) => i.state.rect.height), this.transition(L).style("opacity", 1), this.transition(rt).attr("d", (i) => {
678
- const d = y(i.target), f = [
699
+ this.transition(lt).attr("r", 0).attr("stroke-width", 0), $.attr("cx", (r) => r.state.rect.width).attr("cy", (r) => r.state.rect.height), this.transition($).attr("r", 6).attr("stroke-width", "1.5"), this.transition(P).style("opacity", 0), W.attr("width", (r) => Math.max(0, r.state.rect.width - i * 2)).attr("height", (r) => r.state.rect.height), this.transition(W).style("opacity", 1), this.transition(st).attr("d", (r) => {
700
+ const d = y(r.target), x = [
679
701
  d.x + d.width,
680
702
  d.y + d.height
681
703
  ];
682
- return j({ source: f, target: f });
683
- }).attr("stroke-width", 0).remove(), this.transition(nt).attr("stroke", (i) => o(i.target)).attr("stroke-width", (i) => I(i.target)).attr("d", (i) => {
684
- const d = i.source, f = i.target, E = [
704
+ return A({ source: x, target: x });
705
+ }).attr("stroke-width", 0).remove(), this.transition(ot).attr("stroke", (r) => o(r.target)).attr("stroke-width", (r) => V(r.target)).attr("d", (r) => {
706
+ const d = r.source, x = r.target, E = [
685
707
  d.state.rect.x + d.state.rect.width,
686
708
  d.state.rect.y + d.state.rect.height
687
- ], ot = [
688
- f.state.rect.x,
689
- f.state.rect.y + f.state.rect.height
709
+ ], ct = [
710
+ x.state.rect.x,
711
+ x.state.rect.y + x.state.rect.height
690
712
  ];
691
- return j({ source: E, target: ot });
713
+ return A({ source: E, target: ct });
692
714
  }), n && this.fit();
693
715
  }
694
716
  transition(t) {
695
- const { duration: s } = this.options;
696
- return t.transition().duration(s);
717
+ const { duration: i } = this.options;
718
+ return t.transition().duration(i);
697
719
  }
698
720
  /**
699
721
  * Fit the content to the viewport.
700
722
  */
701
723
  async fit(t = this.options.maxInitialScale) {
702
- const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), { fitRatio: a } = this.options, { x1: l, y1: r, x2: c, y2: p } = this.state.rect, h = c - l, u = p - r, m = Math.min(
724
+ const i = this.svg.node(), { width: n, height: o } = i.getBoundingClientRect(), { fitRatio: a } = this.options, { x1: l, y1: s, x2: c, y2: p } = this.state.rect, h = c - l, u = p - s, g = Math.min(
703
725
  n / h * a,
704
726
  o / u * a,
705
727
  t
706
- ), g = gt.translate(
707
- (n - h * m) / 2 - l * m,
708
- (o - u * m) / 2 - r * m
709
- ).scale(m);
710
- return this.transition(this.svg).call(this.zoom.transform, g).end().catch(w);
728
+ ), m = yt.translate(
729
+ (n - h * g) / 2 - l * g,
730
+ (o - u * g) / 2 - s * g
731
+ ).scale(g);
732
+ return this.transition(this.svg).call(this.zoom.transform, m).end().catch(X);
711
733
  }
712
734
  findElement(t) {
713
- let s;
714
- return this.g.selectAll(v("g")).each(function(o) {
715
- o === t && (s = {
735
+ let i;
736
+ return this.g.selectAll(k(O)).each(function(o) {
737
+ o === t && (i = {
716
738
  data: o,
717
739
  g: this
718
740
  });
719
- }), s;
741
+ }), i;
720
742
  }
721
743
  /**
722
744
  * Pan the content to make the provided node visible in the viewport.
723
745
  */
724
- async ensureVisible(t, s) {
746
+ async ensureVisible(t, i) {
725
747
  var b;
726
748
  const n = (b = this.findElement(t)) == null ? void 0 : b.data;
727
749
  if (!n) return;
728
- const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), [r, c] = [
750
+ const o = this.svg.node(), a = o.getBoundingClientRect(), l = z(o), [s, c] = [
729
751
  n.state.rect.x,
730
752
  n.state.rect.x + n.state.rect.width + 2
731
- ].map((k) => k * l.k + l.x), [p, h] = [
753
+ ].map((v) => v * l.k + l.x), [p, h] = [
732
754
  n.state.rect.y,
733
755
  n.state.rect.y + n.state.rect.height
734
- ].map((k) => k * l.k + l.y), u = {
756
+ ].map((v) => v * l.k + l.y), u = {
735
757
  left: 0,
736
758
  right: 0,
737
759
  top: 0,
738
760
  bottom: 0,
739
- ...s
740
- }, m = [u.left - r, a.width - u.right - c], g = [u.top - p, a.height - u.bottom - h], y = m[0] * m[1] > 0 ? K(m, Math.abs) / l.k : 0, x = g[0] * g[1] > 0 ? K(g, Math.abs) / l.k : 0;
741
- if (y || x) {
742
- const k = l.translate(y, x);
743
- return this.transition(this.svg).call(this.zoom.transform, k).end().catch(w);
761
+ ...i
762
+ }, g = [u.left - s, a.width - u.right - c], m = [u.top - p, a.height - u.bottom - h], y = g[0] * g[1] > 0 ? U(g, Math.abs) / l.k : 0, f = m[0] * m[1] > 0 ? U(m, Math.abs) / l.k : 0;
763
+ if (y || f) {
764
+ const v = l.translate(y, f);
765
+ return this.transition(this.svg).call(this.zoom.transform, v).end().catch(X);
744
766
  }
745
767
  }
746
- async centerNode(t, s) {
768
+ async centerNode(t, i) {
747
769
  var y;
748
770
  const n = (y = this.findElement(t)) == null ? void 0 : y.data;
749
771
  if (!n) return;
750
- const o = this.svg.node(), a = o.getBoundingClientRect(), l = S(o), r = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
772
+ const o = this.svg.node(), a = o.getBoundingClientRect(), l = z(o), s = (n.state.rect.x + n.state.rect.width / 2) * l.k + l.x, c = (n.state.rect.y + n.state.rect.height / 2) * l.k + l.y, p = {
751
773
  left: 0,
752
774
  right: 0,
753
775
  top: 0,
754
776
  bottom: 0,
755
- ...s
756
- }, h = (p.left + a.width - p.right) / 2, u = (p.top + a.height - p.bottom) / 2, m = (h - r) / l.k, g = (u - c) / l.k;
757
- if (m || g) {
758
- const x = l.translate(m, g);
759
- return this.transition(this.svg).call(this.zoom.transform, x).end().catch(w);
777
+ ...i
778
+ }, h = (p.left + a.width - p.right) / 2, u = (p.top + a.height - p.bottom) / 2, g = (h - s) / l.k, m = (u - c) / l.k;
779
+ if (g || m) {
780
+ const f = l.translate(g, m);
781
+ return this.transition(this.svg).call(this.zoom.transform, f).end().catch(X);
760
782
  }
761
783
  }
762
784
  /**
763
785
  * Scale content with it pinned at the center of the viewport.
764
786
  */
765
787
  async rescale(t) {
766
- const s = this.svg.node(), { width: n, height: o } = s.getBoundingClientRect(), a = n / 2, l = o / 2, r = S(s), c = r.translate(
767
- (a - r.x) * (1 - t) / r.k,
768
- (l - r.y) * (1 - t) / r.k
788
+ const i = this.svg.node(), { width: n, height: o } = i.getBoundingClientRect(), a = n / 2, l = o / 2, s = z(i), c = s.translate(
789
+ (a - s.x) * (1 - t) / s.k,
790
+ (l - s.y) * (1 - t) / s.k
769
791
  ).scale(t);
770
- return this.transition(this.svg).call(this.zoom.transform, c).end().catch(w);
792
+ return this.transition(this.svg).call(this.zoom.transform, c).end().catch(X);
771
793
  }
772
794
  destroy() {
773
- this.svg.on(".zoom", null), this.svg.html(null), this.revokers.forEach((t) => {
795
+ this.svg.on(".zoom", null), this.svg.html(null), this._disposeList.forEach((t) => {
774
796
  t();
775
797
  });
776
798
  }
777
- static create(t, s, n = null) {
778
- const o = new tt(t, s);
799
+ static create(t, i, n = null) {
800
+ const o = new nt(t, i);
779
801
  return n && o.setData(n).then(() => {
780
802
  o.fit();
781
803
  }), o;
782
804
  }
783
805
  }
784
806
  export {
785
- tt as Markmap,
786
- xt as defaultColorFn,
787
- U as defaultOptions,
788
- ue as deriveOptions,
789
- me as globalCSS,
790
- V as isMacintosh,
791
- xe as loadCSS,
792
- ye as loadJS,
793
- le as refreshHook,
794
- yt as simpleHash
807
+ nt as Markmap,
808
+ k as childSelector,
809
+ vt as defaultColorFn,
810
+ q as defaultOptions,
811
+ ye as deriveOptions,
812
+ ke as globalCSS,
813
+ Z as isMacintosh,
814
+ Ee as loadCSS,
815
+ ze as loadJS,
816
+ ue as refreshHook,
817
+ bt as simpleHash
795
818
  };