col-browser 2.3.9 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +29 -0
  2. package/es/bibtex.js +2 -2
  3. package/es/chunks/{BibTex-CPaVr-5w.js → BibTex-79CCKAOK.js} +2 -2
  4. package/es/chunks/{BibTex-CPaVr-5w.js.map → BibTex-79CCKAOK.js.map} +1 -1
  5. package/es/chunks/{DatasetCitation-JpNSTWz-.js → DatasetCitation-BXtAmjdZ.js} +2 -2
  6. package/es/chunks/{DatasetCitation-JpNSTWz-.js.map → DatasetCitation-BXtAmjdZ.js.map} +1 -1
  7. package/es/chunks/{DatasetlogoWithFallback-BhWvpgDn.js → DatasetlogoWithFallback-Dava2uqZ.js} +2 -2
  8. package/es/chunks/{DatasetlogoWithFallback-BhWvpgDn.js.map → DatasetlogoWithFallback-Dava2uqZ.js.map} +1 -1
  9. package/es/chunks/{Distributions-CKn1-Qze.js → Distributions-Bd4hFYdS.js} +3 -3
  10. package/es/chunks/{Distributions-CKn1-Qze.js.map → Distributions-Bd4hFYdS.js.map} +1 -1
  11. package/es/chunks/{MergedDataBadge-DK4XUXsL.js → MergedDataBadge-C1CgoRFz.js} +2 -2
  12. package/es/chunks/{MergedDataBadge-DK4XUXsL.js.map → MergedDataBadge-C1CgoRFz.js.map} +1 -1
  13. package/es/chunks/{TaxonBreakdown-BYRnP8bH.js → TaxonBreakdown-DeWamLu_.js} +2 -2
  14. package/es/chunks/{TaxonBreakdown-BYRnP8bH.js.map → TaxonBreakdown-DeWamLu_.js.map} +1 -1
  15. package/es/chunks/{XrGutter-CORP2r5Y.js → XrGutter-CU7_QPAp.js} +2 -2
  16. package/es/chunks/{XrGutter-CORP2r5Y.js.map → XrGutter-CU7_QPAp.js.map} +1 -1
  17. package/es/chunks/config-D1NH4DTr.js +22 -0
  18. package/es/chunks/config-D1NH4DTr.js.map +1 -0
  19. package/es/chunks/{dataset-BuF063rn.js → dataset-BL6g4w0G.js} +2 -2
  20. package/es/chunks/{dataset-BuF063rn.js.map → dataset-BL6g4w0G.js.map} +1 -1
  21. package/es/chunks/{enumeration-CC8SblcI.js → enumeration-DM8Hb36g.js} +2 -2
  22. package/es/chunks/{enumeration-CC8SblcI.js.map → enumeration-DM8Hb36g.js.map} +1 -1
  23. package/es/chunks/{sector-Behb-WCC.js → sector-Qeo1zPxr.js} +2 -2
  24. package/es/chunks/{sector-Behb-WCC.js.map → sector-Qeo1zPxr.js.map} +1 -1
  25. package/es/chunks/withTheme-Dh6PRuII.js +17 -0
  26. package/es/chunks/withTheme-Dh6PRuII.js.map +1 -0
  27. package/es/config.js +5 -0
  28. package/es/config.js.map +1 -0
  29. package/es/index.js +4 -2
  30. package/es/index.js.map +1 -1
  31. package/es/search.js +14 -13
  32. package/es/search.js.map +1 -1
  33. package/es/sourceDataset.js +7 -6
  34. package/es/sourceDataset.js.map +1 -1
  35. package/es/sourceDatasetList.js +16 -15
  36. package/es/sourceDatasetList.js.map +1 -1
  37. package/es/taxon.js +215 -214
  38. package/es/taxon.js.map +1 -1
  39. package/es/taxonBreakdown.js +23 -22
  40. package/es/taxonBreakdown.js.map +1 -1
  41. package/es/taxonDistribution.js +20 -19
  42. package/es/taxonDistribution.js.map +1 -1
  43. package/es/tree.js +422 -411
  44. package/es/tree.js.map +1 -1
  45. package/package.json +5 -1
  46. package/types/config.d.ts +1 -0
  47. package/types/index.d.ts +21 -0
  48. package/umd/col-browser.js +42 -16
  49. package/umd/col-browser.js.map +1 -1
  50. package/umd/col-browser.min.js +4 -4
  51. package/umd/col-browser.min.js.map +1 -1
  52. package/es/chunks/config-B2Z9BaEd.js +0 -30
  53. package/es/chunks/config-B2Z9BaEd.js.map +0 -1
package/es/tree.js CHANGED
@@ -1,158 +1,159 @@
1
- var J = Object.defineProperty;
2
- var Q = (m, x, e) => x in m ? J(m, x, { enumerable: !0, configurable: !0, writable: !0, value: e }) : m[x] = e;
3
- var p = (m, x, e) => Q(m, typeof x != "symbol" ? x + "" : x, e);
4
- import { a as X } from "./chunks/withDatasetKey-BgMY05XE.js";
5
- import { c as T, w as Y } from "./chunks/config-B2Z9BaEd.js";
6
- import { j as t } from "./chunks/jsx-runtime-BzflLqGi.js";
7
- import j, { createContext as ee } from "react";
8
- import { Popover as te, Divider as se, Spin as R, Tag as ae, Alert as b, Skeleton as oe, Tree as ne, Button as ie, Row as re, Col as v, Checkbox as $ } from "antd";
9
- import { sortBy as N, get as y, isUndefined as I, flatten as le, isArray as A } from "lodash-es";
10
- import { L, c as D, R as U, s as de, b as he } from "./chunks/router-CssZk5qZ.js";
11
- import S from "dataloader";
12
- import { c as W, b as H, g as ce } from "./chunks/dataset-BuF063rn.js";
13
- import { M as pe } from "./chunks/MergedDataBadge-DK4XUXsL.js";
14
- import { E as ue } from "./chunks/ErrorMsg-K8k5PPTp.js";
15
- import { g as fe } from "./chunks/sector-Behb-WCC.js";
16
- import { C as F, N as xe } from "./chunks/DatasetCitation-JpNSTWz-.js";
17
- import { r as O, w as M } from "./chunks/storage-BgdCo9fV.js";
18
- const w = ee({
1
+ var Y = Object.defineProperty;
2
+ var tt = (x, y, t) => y in x ? Y(x, y, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[y] = t;
3
+ var u = (x, y, t) => tt(x, typeof y != "symbol" ? y + "" : y, t);
4
+ import { a as et } from "./chunks/withDatasetKey-BgMY05XE.js";
5
+ import { w as st } from "./chunks/withTheme-Dh6PRuII.js";
6
+ import { j as e } from "./chunks/jsx-runtime-BzflLqGi.js";
7
+ import j, { createContext as at } from "react";
8
+ import { Popover as ot, Divider as it, Spin as q, Tag as nt, Alert as w, Skeleton as rt, Tree as lt, Button as dt, Row as ht, Col as I, Checkbox as N } from "antd";
9
+ import { sortBy as _, get as m, isUndefined as A, flatten as ct, isArray as O } from "lodash-es";
10
+ import { L as P, c as K, R as H, s as ut, b as pt } from "./chunks/router-CssZk5qZ.js";
11
+ import { c as D } from "./chunks/config-D1NH4DTr.js";
12
+ import L from "dataloader";
13
+ import { c as V, b as z, g as ft } from "./chunks/dataset-BL6g4w0G.js";
14
+ import { M as xt } from "./chunks/MergedDataBadge-C1CgoRFz.js";
15
+ import { E as gt } from "./chunks/ErrorMsg-K8k5PPTp.js";
16
+ import { g as yt } from "./chunks/sector-Qeo1zPxr.js";
17
+ import { C as R, N as mt } from "./chunks/DatasetCitation-BXtAmjdZ.js";
18
+ import { r as F, w as M } from "./chunks/storage-BgdCo9fV.js";
19
+ const E = at({
19
20
  datasetLoader: null,
20
21
  publisherLoader: null
21
- }), B = (m) => ({
22
- datasetLoader: new S((x) => H(x, m)),
23
- publisherLoader: new S(
24
- (x) => W(x, m)
22
+ }), B = (x) => ({
23
+ datasetLoader: new L((y) => z(y, x)),
24
+ publisherLoader: new L(
25
+ (y) => V(y, x)
25
26
  )
26
27
  });
27
- class V extends j.Component {
28
- constructor(e) {
29
- super(e);
28
+ class G extends j.Component {
29
+ constructor(t) {
30
+ super(t);
30
31
  // Returns the shared cache from TreeCacheContext if available, or a
31
32
  // throwaway local DataLoader so the popover still works even if context
32
33
  // doesn't reach this instance (which used to leave the spinner stuck
33
34
  // because getData early-returned with no loading state set).
34
- p(this, "getDatasetLoader", () => {
35
- var s;
36
- const { datasetKey: e } = this.props;
37
- return (s = this.context) != null && s.datasetLoader ? this.context.datasetLoader : (this._localDatasetLoader || (this._localDatasetLoader = new S(
38
- (o) => H(o, e)
35
+ u(this, "getDatasetLoader", () => {
36
+ var a;
37
+ const { datasetKey: t } = this.props;
38
+ return (a = this.context) != null && a.datasetLoader ? this.context.datasetLoader : (this._localDatasetLoader || (this._localDatasetLoader = new L(
39
+ (o) => z(o, t)
39
40
  )), this._localDatasetLoader);
40
41
  });
41
- p(this, "getPublisherLoader", () => {
42
- var s;
43
- const { datasetKey: e } = this.props;
44
- return (s = this.context) != null && s.publisherLoader ? this.context.publisherLoader : (this._localPublisherLoader || (this._localPublisherLoader = new S(
45
- (o) => W(o, e)
42
+ u(this, "getPublisherLoader", () => {
43
+ var a;
44
+ const { datasetKey: t } = this.props;
45
+ return (a = this.context) != null && a.publisherLoader ? this.context.publisherLoader : (this._localPublisherLoader || (this._localPublisherLoader = new L(
46
+ (o) => V(o, t)
46
47
  )), this._localPublisherLoader);
47
48
  });
48
- p(this, "componentDidMount", () => {
49
- const { sourceDatasetKeys: e } = this.props;
50
- e && e.length < 4 && this.setState({ showInNode: !0 }, this.getData);
49
+ u(this, "componentDidMount", () => {
50
+ const { sourceDatasetKeys: t } = this.props;
51
+ t && t.length < 4 && this.setState({ showInNode: !0 }, this.getData);
51
52
  });
52
- p(this, "getData", () => {
53
- const { sourceDatasetKeys: e } = this.props;
54
- if (!(e != null && e.length)) return;
53
+ u(this, "getData", () => {
54
+ const { sourceDatasetKeys: t } = this.props;
55
+ if (!(t != null && t.length)) return;
55
56
  this.setState({ loading: !0 });
56
- const s = this.getDatasetLoader();
57
+ const a = this.getDatasetLoader();
57
58
  Promise.all(
58
- e.map((o) => s.load(o).catch(() => null))
59
+ t.map((o) => a.load(o).catch(() => null))
59
60
  ).then((o) => {
60
- this.setState({ data: N(o, ["alias"]), loading: !1 });
61
+ this.setState({ data: _(o, ["alias"]), loading: !1 });
61
62
  }).catch(() => {
62
63
  this.setState({ data: [], loading: !1 });
63
64
  });
64
65
  });
65
- p(this, "getPublisherData", () => {
66
- const { publisherDatasetKeys: e } = this.props;
67
- if (!e) return;
68
- const s = this.getPublisherLoader();
66
+ u(this, "getPublisherData", () => {
67
+ const { publisherDatasetKeys: t } = this.props;
68
+ if (!t) return;
69
+ const a = this.getPublisherLoader();
69
70
  Promise.all(
70
- Object.keys(e).map(
71
- (o) => s.load(o).then((r) => ({
71
+ Object.keys(t).map(
72
+ (o) => a.load(o).then((r) => ({
72
73
  ...r,
73
- datasets: e[o]
74
+ datasets: t[o]
74
75
  })).catch(() => null)
75
76
  )
76
77
  ).then((o) => {
77
- this.setState({ publishers: N(o.filter(Boolean), ["alias"]) });
78
+ this.setState({ publishers: _(o.filter(Boolean), ["alias"]) });
78
79
  }).catch(() => {
79
80
  this.setState({ publishers: [] });
80
81
  });
81
82
  });
82
- p(this, "render", () => {
83
- const { data: e, showInNode: s, popOverVisible: o, loading: r } = this.state, { taxon: h, datasetKey: c } = this.props, n = { color: "orange", fontSize: "11px" }, f = (a) => `${T.clbPortal}/dataset/${c}/publisher/${a}`;
84
- return s ? e.filter((a) => !!a).map((a, l) => /* @__PURE__ */ t.jsx(
85
- L,
83
+ u(this, "render", () => {
84
+ const { data: t, showInNode: a, popOverVisible: o, loading: r } = this.state, { taxon: l, datasetKey: d } = this.props, i = { color: "orange", fontSize: "11px" }, f = (s) => `${D.clbPortal}/dataset/${d}/publisher/${s}`;
85
+ return a ? t.filter((s) => !!s).map((s, n) => /* @__PURE__ */ e.jsx(
86
+ P,
86
87
  {
87
88
  to: "source",
88
- args: a.key,
89
+ args: s.key,
89
90
  className: "col-tree-data-source",
90
- style: n,
91
- children: (l ? ", " : "") + (a.alias || a.key)
91
+ style: i,
92
+ children: (n ? ", " : "") + (s.alias || s.key)
92
93
  },
93
- a.key
94
- )) : /* @__PURE__ */ t.jsx("div", { style: { display: "inline" }, id: `taxon_sources_${h.id}`, children: /* @__PURE__ */ t.jsx(
95
- te,
94
+ s.key
95
+ )) : /* @__PURE__ */ e.jsx("div", { style: { display: "inline" }, id: `taxon_sources_${l.id}`, children: /* @__PURE__ */ e.jsx(
96
+ ot,
96
97
  {
97
- getPopupContainer: () => document.getElementById(`taxon_sources_${h.id}`),
98
- content: r || e.length === 0 ? /* @__PURE__ */ t.jsx(
98
+ getPopupContainer: () => document.getElementById(`taxon_sources_${l.id}`),
99
+ content: r || t.length === 0 ? /* @__PURE__ */ e.jsx(
99
100
  "div",
100
101
  {
101
102
  style: { minWidth: "200px", textAlign: "center", padding: "8px 0" },
102
- children: /* @__PURE__ */ t.jsx(R, { size: "small" })
103
+ children: /* @__PURE__ */ e.jsx(q, { size: "small" })
103
104
  }
104
- ) : /* @__PURE__ */ t.jsxs("div", { style: { maxWidth: "500px" }, children: [
105
- e.length > 0 && /* @__PURE__ */ t.jsx("div", { children: e.filter((a) => !!a).map((a, l) => /* @__PURE__ */ t.jsx(
106
- L,
105
+ ) : /* @__PURE__ */ e.jsxs("div", { style: { maxWidth: "500px" }, children: [
106
+ t.length > 0 && /* @__PURE__ */ e.jsx("div", { children: t.filter((s) => !!s).map((s, n) => /* @__PURE__ */ e.jsx(
107
+ P,
107
108
  {
108
109
  to: "source",
109
- args: a.key,
110
+ args: s.key,
110
111
  className: "col-tree-data-source",
111
- style: n,
112
- children: (l ? ", " : "") + (a.alias || a.key)
112
+ style: i,
113
+ children: (n ? ", " : "") + (s.alias || s.key)
113
114
  },
114
- a.key
115
+ s.key
115
116
  )) }),
116
- this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */ t.jsxs("div", { style: { marginTop: "12px" }, children: [
117
- /* @__PURE__ */ t.jsx("strong", { children: "Publishers" }),
118
- /* @__PURE__ */ t.jsx("div", { children: this.state.publishers.filter((a) => !!a).map((a, l) => {
119
- var u;
120
- return /* @__PURE__ */ t.jsxs(
117
+ this.state.publishers && this.state.publishers.length > 0 && /* @__PURE__ */ e.jsxs("div", { style: { marginTop: "12px" }, children: [
118
+ /* @__PURE__ */ e.jsx("strong", { children: "Publishers" }),
119
+ /* @__PURE__ */ e.jsx("div", { children: this.state.publishers.filter((s) => !!s).map((s, n) => {
120
+ var p;
121
+ return /* @__PURE__ */ e.jsxs(
121
122
  "a",
122
123
  {
123
- href: f(a.id),
124
+ href: f(s.id),
124
125
  target: "_blank",
125
126
  rel: "noopener noreferrer",
126
- style: n,
127
+ style: i,
127
128
  children: [
128
- (l ? ", " : "") + (a.alias || a.id),
129
- (u = a.datasets) != null && u.length ? ` (${a.datasets.length.toLocaleString("en-GB")})` : ""
129
+ (n ? ", " : "") + (s.alias || s.id),
130
+ (p = s.datasets) != null && p.length ? ` (${s.datasets.length.toLocaleString("en-GB")})` : ""
130
131
  ]
131
132
  },
132
- a.id
133
+ s.id
133
134
  );
134
135
  }) })
135
136
  ] })
136
137
  ] }),
137
- title: /* @__PURE__ */ t.jsxs("div", { style: { padding: "4px 0" }, children: [
138
- /* @__PURE__ */ t.jsx("span", { style: { fontWeight: 500 }, children: "Sources for " }),
139
- /* @__PURE__ */ t.jsx("em", { children: h == null ? void 0 : h.name }),
140
- /* @__PURE__ */ t.jsx(se, { style: { margin: "8px 0 0" } })
138
+ title: /* @__PURE__ */ e.jsxs("div", { style: { padding: "4px 0" }, children: [
139
+ /* @__PURE__ */ e.jsx("span", { style: { fontWeight: 500 }, children: "Sources for " }),
140
+ /* @__PURE__ */ e.jsx("em", { children: l == null ? void 0 : l.name }),
141
+ /* @__PURE__ */ e.jsx(it, { style: { margin: "8px 0 0" } })
141
142
  ] }),
142
143
  open: o,
143
- onOpenChange: (a) => this.setState({ popOverVisible: a }, () => {
144
- a && this.state.data.length === 0 && this.getData(), a && this.props.publisherDatasetKeys && !this.state.publishers && this.getPublisherData();
144
+ onOpenChange: (s) => this.setState({ popOverVisible: s }, () => {
145
+ s && this.state.data.length === 0 && this.getData(), s && this.props.publisherDatasetKeys && !this.state.publishers && this.getPublisherData();
145
146
  }),
146
147
  trigger: "click",
147
148
  placement: "rightTop",
148
- children: /* @__PURE__ */ t.jsx(
149
+ children: /* @__PURE__ */ e.jsx(
149
150
  "a",
150
151
  {
151
152
  className: "col-tree-data-source",
152
153
  role: "button",
153
154
  tabIndex: 0,
154
155
  style: { cursor: "pointer", color: "orange", fontSize: "11px" },
155
- onClick: (a) => a.preventDefault(),
156
+ onClick: (s) => s.preventDefault(),
156
157
  children: "Multiple sources"
157
158
  }
158
159
  )
@@ -166,44 +167,44 @@ class V extends j.Component {
166
167
  };
167
168
  }
168
169
  }
169
- p(V, "contextType", w);
170
- const z = j.createContext();
170
+ u(G, "contextType", E);
171
+ const X = j.createContext();
171
172
  class k extends j.Component {
172
- constructor(e) {
173
- super(e);
174
- p(this, "rankIsAboveSpecies", (e) => this.props.rank.indexOf(e) < this.props.rank.indexOf("species"));
175
- p(this, "render", () => {
173
+ constructor(t) {
174
+ super(t);
175
+ u(this, "rankIsAboveSpecies", (t) => this.props.rank.indexOf(t) < this.props.rank.indexOf("species"));
176
+ u(this, "render", () => {
176
177
  const {
177
- taxon: e,
178
- taxon: { sector: s, sourceDatasetKeys: o, publisherDatasetKeys: r },
179
- datasetKey: h
180
- } = this.props, c = y(s, "dataset"), n = (o || []).filter((a) => (s == null ? void 0 : s.subjectDatasetKey) !== a).length > 0;
181
- e.estimate && e.estimates && e.estimates.find((a) => a.estimate === e.estimate);
182
- const f = typeof e.id == "string" && e.id.indexOf("incertae-sedis") > -1;
183
- return /* @__PURE__ */ t.jsx(z.Consumer, { children: ({ showInfo: a }) => /* @__PURE__ */ t.jsxs("div", { id: e.id, children: [
184
- /* @__PURE__ */ t.jsxs("span", { children: [
185
- /* @__PURE__ */ t.jsxs("span", { className: "tree-node-rank", children: [
186
- e.rank,
178
+ taxon: t,
179
+ taxon: { sector: a, sourceDatasetKeys: o, publisherDatasetKeys: r },
180
+ datasetKey: l
181
+ } = this.props, d = m(a, "dataset"), i = (o || []).filter((s) => (a == null ? void 0 : a.subjectDatasetKey) !== s).length > 0;
182
+ t.estimate && t.estimates && t.estimates.find((s) => s.estimate === t.estimate);
183
+ const f = typeof t.id == "string" && t.id.indexOf("incertae-sedis") > -1;
184
+ return /* @__PURE__ */ e.jsx(X.Consumer, { children: ({ showInfo: s }) => /* @__PURE__ */ e.jsxs("div", { id: t.id, children: [
185
+ /* @__PURE__ */ e.jsxs("span", { children: [
186
+ /* @__PURE__ */ e.jsxs("span", { className: "tree-node-rank", children: [
187
+ t.rank,
187
188
  ": "
188
189
  ] }),
189
- f ? /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) : /* @__PURE__ */ t.jsx(L, { to: "taxon", args: e.id, children: /* @__PURE__ */ t.jsx("span", { dangerouslySetInnerHTML: { __html: e.labelHtml } }) }),
190
- (e == null ? void 0 : e.merged) && /* @__PURE__ */ t.jsx(pe, { style: { marginLeft: "4px" }, datasetKey: e == null ? void 0 : e.datasetKey, verbatimSourceKey: e == null ? void 0 : e.verbatimSourceKey })
190
+ f ? /* @__PURE__ */ e.jsx("span", { dangerouslySetInnerHTML: { __html: t.labelHtml } }) : /* @__PURE__ */ e.jsx(P, { to: "taxon", args: t.id, children: /* @__PURE__ */ e.jsx("span", { dangerouslySetInnerHTML: { __html: t.labelHtml } }) }),
191
+ (t == null ? void 0 : t.merged) && /* @__PURE__ */ e.jsx(xt, { style: { marginLeft: "4px" }, datasetKey: t == null ? void 0 : t.datasetKey, verbatimSourceKey: t == null ? void 0 : t.verbatimSourceKey })
191
192
  ] }),
192
- a && e.status === "provisionally accepted" && /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
193
+ s && t.status === "provisionally accepted" && /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
193
194
  " • ",
194
- /* @__PURE__ */ t.jsx(ae, { color: "warning", style: { marginRight: 0 }, children: "prov." })
195
+ /* @__PURE__ */ e.jsx(nt, { color: "warning", style: { marginRight: 0 }, children: "prov." })
195
196
  ] }),
196
- !I(e.count) && this.rankIsAboveSpecies(e == null ? void 0 : e.rank) && /* @__PURE__ */ t.jsxs("span", { children: [
197
+ !A(t.count) && this.rankIsAboveSpecies(t == null ? void 0 : t.rank) && /* @__PURE__ */ e.jsxs("span", { children: [
197
198
  " ",
198
199
  "• ",
199
- Number(e.count).toLocaleString(),
200
+ Number(t.count).toLocaleString(),
200
201
  " ",
201
- a && !I(e.speciesEstimate) && /* @__PURE__ */ t.jsxs("span", { children: [
202
+ s && !A(t.speciesEstimate) && /* @__PURE__ */ e.jsxs("span", { children: [
202
203
  " ",
203
204
  "of",
204
205
  " ",
205
206
  Number(
206
- e.speciesEstimate
207
+ t.speciesEstimate
207
208
  ).toLocaleString(),
208
209
  " ",
209
210
  "est.",
@@ -211,31 +212,31 @@ class k extends j.Component {
211
212
  ] }),
212
213
  "spp."
213
214
  ] }),
214
- a && s && /* @__PURE__ */ t.jsxs("span", { children: [
215
- /* @__PURE__ */ t.jsx("span", { children: " • " }),
216
- /* @__PURE__ */ t.jsxs(
217
- L,
215
+ s && a && /* @__PURE__ */ e.jsxs("span", { children: [
216
+ /* @__PURE__ */ e.jsx("span", { children: " • " }),
217
+ /* @__PURE__ */ e.jsxs(
218
+ P,
218
219
  {
219
220
  to: "source",
220
- args: s.subjectDatasetKey,
221
- style: n ? { fontWeight: "bold" } : null,
221
+ args: a.subjectDatasetKey,
222
+ style: i ? { fontWeight: "bold" } : null,
222
223
  className: "col-tree-data-source",
223
224
  children: [
224
- y(c, "alias") || s.subjectDatasetKey,
225
- n && ", "
225
+ m(d, "alias") || a.subjectDatasetKey,
226
+ i && ", "
226
227
  ]
227
228
  }
228
229
  )
229
230
  ] }),
230
- a && n && /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
231
+ s && i && /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
231
232
  " ",
232
- /* @__PURE__ */ t.jsx(
233
- V,
233
+ /* @__PURE__ */ e.jsx(
234
+ G,
234
235
  {
235
236
  sourceDatasetKeys: o,
236
237
  publisherDatasetKeys: r,
237
- taxon: e,
238
- datasetKey: h
238
+ taxon: t,
239
+ datasetKey: l
239
240
  }
240
241
  )
241
242
  ] })
@@ -248,46 +249,46 @@ class k extends j.Component {
248
249
  };
249
250
  }
250
251
  }
251
- const K = 1e3;
252
- class ge extends j.Component {
253
- constructor(e) {
254
- super(e);
255
- p(this, "onClick", () => {
252
+ const b = 1e3, Z = "__loadMoreBTN__", W = (x) => `${Z}${x}`, U = (x) => typeof x == "string" && x.startsWith(Z);
253
+ class Ct extends j.Component {
254
+ constructor(t) {
255
+ super(t);
256
+ u(this, "onClick", () => {
256
257
  this.setState(
257
258
  { loading: !0 },
258
259
  () => this.props.onClick().then(() => this.setState({ loading: !1 }))
259
260
  );
260
261
  });
261
- p(this, "render", () => {
262
- const { loading: e } = this.state;
263
- return /* @__PURE__ */ t.jsxs(j.Fragment, { children: [
264
- e && /* @__PURE__ */ t.jsx(R, {}),
265
- !e && /* @__PURE__ */ t.jsx("a", { onClick: this.onClick, children: /* @__PURE__ */ t.jsx("strong", { children: "Load more..." }) })
262
+ u(this, "render", () => {
263
+ const { loading: t } = this.state;
264
+ return /* @__PURE__ */ e.jsxs(j.Fragment, { children: [
265
+ t && /* @__PURE__ */ e.jsx(q, {}),
266
+ !t && /* @__PURE__ */ e.jsx("a", { onClick: this.onClick, children: /* @__PURE__ */ e.jsx("strong", { children: "Load more..." }) })
266
267
  ] });
267
268
  });
268
269
  this.state = { loading: !1 };
269
270
  }
270
271
  }
271
- class G extends j.Component {
272
- constructor(e) {
273
- super(e);
274
- p(this, "componentDidMount", () => {
275
- const { datasetKey: e } = this.props;
276
- this.loadRoot(), this.sectorLoader = new S(
277
- (o) => fe(o, e)
272
+ class J extends j.Component {
273
+ constructor(t) {
274
+ super(t);
275
+ u(this, "componentDidMount", () => {
276
+ const { datasetKey: t } = this.props;
277
+ this.loadRoot(), this.sectorLoader = new L(
278
+ (o) => yt(o, t)
278
279
  ), this.getRank();
279
- const { treeRef: s } = this.props;
280
- s(this);
280
+ const { treeRef: a } = this.props;
281
+ a(this);
281
282
  });
282
- p(this, "componentDidUpdate", (e) => {
283
- (e.defaultExpandKey !== this.props.defaultExpandKey || e.hideExtinct !== this.props.hideExtinct || e.insertPlaceholder !== this.props.insertPlaceholder) && this.reloadRoot();
283
+ u(this, "componentDidUpdate", (t) => {
284
+ (t.defaultExpandKey !== this.props.defaultExpandKey || t.hideExtinct !== this.props.hideExtinct || t.insertPlaceholder !== this.props.insertPlaceholder) && this.reloadRoot();
284
285
  });
285
- p(this, "getRank", () => {
286
- D(`${T.dataApi}vocab/rank`).then(
287
- (e) => this.setState({ rank: e.data.map((s) => s.name) })
286
+ u(this, "getRank", () => {
287
+ K(`${D.dataApi}vocab/rank`).then(
288
+ (t) => this.setState({ rank: t.data.map((a) => a.name) })
288
289
  );
289
290
  });
290
- p(this, "reloadRoot", () => this.setState(
291
+ u(this, "reloadRoot", () => this.setState(
291
292
  {
292
293
  rootLoading: !0,
293
294
  treeData: [],
@@ -298,245 +299,255 @@ class G extends j.Component {
298
299
  },
299
300
  this.loadRoot
300
301
  ));
301
- p(this, "loadRoot", async () => {
302
+ // `append` is only set by the "Load more" button, which pages in the next
303
+ // batch of root taxa; every other caller loads page one from scratch.
304
+ // Each call takes a request id and a response is merged only while its id is
305
+ // still the current one. Without that, two overlapping loads — React
306
+ // StrictMode's double mount in dev, or a prop change while a load is in
307
+ // flight — both merged their page into treeData, so every root appeared
308
+ // twice and antd warned "Same 'key' exist in the Tree" (issue #59).
309
+ u(this, "loadRoot", async (t = !1) => {
302
310
  const {
303
- showSourceTaxon: e,
304
- datasetKey: s,
305
- hideExtinct: o,
306
- insertPlaceholder: r,
307
- type: h,
308
- expandedTaxonKey: c
309
- } = this.props, n = c, { defaultTaxonKey: f } = this.props;
310
- return this.setState({ rootLoading: !0, treeData: [] }), D(
311
- `${T.dataApi}dataset/${s}/tree?projectKey=${s}${h ? "&type=" + h : ""}&limit=${K}&offset=${this.state.treeData.length}${o ? "&extinct=false&extinct=" : ""}${r ? "&insertPlaceholder=true" : ""}`
312
- ).then(this.decorateWithSectorsAndDataset).then((a) => {
313
- const l = a.data.result || [], u = a.data.total, g = l.map((d) => {
314
- let i = {
315
- taxon: d,
316
- key: d.id,
317
- datasetKey: s,
318
- childCount: d.childCount,
319
- isLeaf: d.childCount === 0,
311
+ showSourceTaxon: a,
312
+ datasetKey: o,
313
+ hideExtinct: r,
314
+ insertPlaceholder: l,
315
+ type: d,
316
+ expandedTaxonKey: i
317
+ } = this.props, f = i, { defaultTaxonKey: s } = this.props, n = ++this.rootRequestId, p = t ? this.state.treeData.length : 0;
318
+ return this.setState(
319
+ t ? { rootLoading: !0 } : { rootLoading: !0, treeData: [] }
320
+ ), K(
321
+ `${D.dataApi}dataset/${o}/tree?projectKey=${o}${d ? "&type=" + d : ""}&limit=${b}&offset=${p}${r ? "&extinct=false&extinct=" : ""}${l ? "&insertPlaceholder=true" : ""}`
322
+ ).then(this.decorateWithSectorsAndDataset).then((C) => {
323
+ if (n !== this.rootRequestId) return;
324
+ const c = C.data.result || [], h = C.data.total, g = c.map((S) => {
325
+ let T = {
326
+ taxon: S,
327
+ key: S.id,
328
+ datasetKey: o,
329
+ childCount: S.childCount,
330
+ isLeaf: S.childCount === 0,
320
331
  childOffset: 0
321
332
  };
322
- return i.title = /* @__PURE__ */ t.jsx(
333
+ return T.title = /* @__PURE__ */ e.jsx(
323
334
  k,
324
335
  {
325
- taxon: d,
326
- datasetKey: s,
327
- showSourceTaxon: e,
328
- reloadChildren: () => this.fetchChildPage(i, !0),
336
+ taxon: S,
337
+ datasetKey: o,
338
+ showSourceTaxon: a,
339
+ reloadChildren: () => this.fetchChildPage(T, !0),
329
340
  rank: this.state.rank
330
341
  }
331
- ), i.ref = i, i;
342
+ ), T.ref = T, T;
332
343
  });
333
344
  this.setState(
334
- {
335
- rootTotal: u,
345
+ (S) => ({
346
+ rootTotal: h,
336
347
  rootLoading: !1,
337
- treeData: [...this.state.treeData, ...g],
348
+ treeData: t ? [...S.treeData, ...g] : g,
338
349
  // Nothing is auto-expanded by default. Consumers open a specific root
339
350
  // (or deep taxon) by passing `defaultTaxonKey`/`expandedTaxonKey` —
340
351
  // e.g. defaultTaxonKey="CS5HF" opens Eukaryota in current COL releases.
341
352
  expandedKeys: [],
342
353
  error: null
343
- },
354
+ }),
344
355
  () => {
345
- if (n)
346
- return this.expandToTaxon(n);
347
356
  if (f)
348
357
  return this.expandToTaxon(f);
358
+ if (s)
359
+ return this.expandToTaxon(s);
349
360
  }
350
361
  ), g.length === 1 && this.fetchChildPage(g[g.length - 1]);
351
- }).catch((a) => {
352
- this.setState({
362
+ }).catch((C) => {
363
+ n === this.rootRequestId && this.setState({
353
364
  treeData: [],
354
365
  rootLoading: !1,
355
366
  expandedKeys: [],
356
- error: a
367
+ error: C
357
368
  });
358
369
  });
359
370
  });
360
- p(this, "expandToTaxon", async (e) => {
371
+ u(this, "expandToTaxon", async (t) => {
361
372
  const {
362
- showSourceTaxon: s,
373
+ showSourceTaxon: a,
363
374
  datasetKey: o,
364
375
  hideExtinct: r,
365
- type: h
376
+ type: l
366
377
  } = this.props;
367
378
  this.setState({
368
379
  rootLoading: !0
369
380
  /* , treeData: [] */
370
381
  });
371
- const { data: c } = await D(
372
- `${T.dataApi}dataset/${o}/tree/${e}?projectKey=${o}&insertPlaceholder=true${h ? "&type=" + h : ""}${r ? "&extinct=false" : ""}`
382
+ const { data: d } = await K(
383
+ `${D.dataApi}dataset/${o}/tree/${t}?projectKey=${o}&insertPlaceholder=true${l ? "&type=" + l : ""}${r ? "&extinct=false" : ""}`
373
384
  ).then(
374
- (d) => this.decorateWithSectorsAndDataset({
375
- data: { result: d.data }
376
- }).then(() => d)
385
+ (c) => this.decorateWithSectorsAndDataset({
386
+ data: { result: c.data }
387
+ }).then(() => c)
377
388
  );
378
- if (c.length === 0)
389
+ if (d.length === 0)
379
390
  return this.setState(
380
391
  {
381
392
  error: {
382
- message: `No classification found for Taxon ID: ${e}`
393
+ message: `No classification found for Taxon ID: ${t}`
383
394
  }
384
395
  },
385
396
  this.loadRoot
386
397
  );
387
- const n = c[c.length - 1];
398
+ const i = d[d.length - 1];
388
399
  let f = {
389
- taxon: n,
390
- key: n.id,
400
+ taxon: i,
401
+ key: i.id,
391
402
  datasetKey: o,
392
- childCount: n.childCount,
393
- isLeaf: n.childCount === 0,
403
+ childCount: i.childCount,
404
+ isLeaf: i.childCount === 0,
394
405
  childOffset: 0
395
406
  };
396
- f.title = /* @__PURE__ */ t.jsx(
407
+ f.title = /* @__PURE__ */ e.jsx(
397
408
  k,
398
409
  {
399
- taxon: n,
410
+ taxon: i,
400
411
  datasetKey: o,
401
- showSourceTaxon: s,
412
+ showSourceTaxon: a,
402
413
  rank: this.state.rank,
403
414
  reloadChildren: () => this.fetchChildPage(f, !0)
404
415
  }
405
416
  ), f.ref = f;
406
- const a = f;
407
- for (let d = c.length - 2; d >= 0; d--) {
408
- const i = c[d], C = {
409
- taxon: i,
410
- key: i.id,
417
+ const s = f;
418
+ for (let c = d.length - 2; c >= 0; c--) {
419
+ const h = d[c], g = {
420
+ taxon: h,
421
+ key: h.id,
411
422
  datasetKey: o,
412
- childCount: i.childCount,
413
- isLeaf: i.childCount === 0,
423
+ childCount: h.childCount,
424
+ isLeaf: h.childCount === 0,
414
425
  childOffset: 0
415
426
  };
416
- C.ref = C, C.title = /* @__PURE__ */ t.jsx(
427
+ g.ref = g, g.title = /* @__PURE__ */ e.jsx(
417
428
  k,
418
429
  {
419
- taxon: i,
430
+ taxon: h,
420
431
  datasetKey: o,
421
- showSourceTaxon: s,
432
+ showSourceTaxon: a,
422
433
  rank: this.state.rank,
423
- reloadChildren: () => this.fetchChildPage(C, !0)
434
+ reloadChildren: () => this.fetchChildPage(g, !0)
424
435
  }
425
- ), f.children = [C], f = C;
436
+ ), f.children = [g], f = g;
426
437
  }
427
- const { treeData: l } = this.state;
428
- var u = l.findIndex((d) => d.key == a.key);
429
- l[u] = a;
430
- const g = [...c.map((d) => d.id).reverse()];
438
+ const { treeData: n } = this.state;
439
+ var p = n.findIndex((c) => c.key == s.key);
440
+ n[p] = s;
441
+ const C = [...d.map((c) => c.id).reverse()];
431
442
  this.setState(
432
- { treeData: l },
433
- () => this.reloadLoadedKeys(g, e)
443
+ { treeData: n },
444
+ () => this.reloadLoadedKeys(C, t)
434
445
  );
435
446
  });
436
- p(this, "fetchChildPage", async (e, s, o) => {
447
+ u(this, "fetchChildPage", async (t, a, o) => {
437
448
  const {
438
449
  showSourceTaxon: r,
439
- datasetKey: h,
440
- hideExtinct: c,
441
- insertPlaceholder: n,
450
+ datasetKey: l,
451
+ hideExtinct: d,
452
+ insertPlaceholder: i,
442
453
  type: f
443
454
  } = this.props;
444
- y(e, "childCount");
445
- const a = K, l = y(e, "childOffset"), u = await D(
446
- `${T.dataApi}dataset/${h}/tree/${e.taxon.id}/children?limit=${a}&offset=${l}&projectKey=${h}${f ? "&type=" + f : ""}${c ? "&extinct=false" : ""}${n ? "&insertPlaceholder=true" : ""}`
455
+ m(t, "childCount");
456
+ const s = b, n = m(t, "childOffset"), p = await K(
457
+ `${D.dataApi}dataset/${l}/tree/${t.taxon.id}/children?limit=${s}&offset=${n}&projectKey=${l}${f ? "&type=" + f : ""}${d ? "&extinct=false" : ""}${i ? "&insertPlaceholder=true" : ""}`
447
458
  );
448
- await this.decorateWithSectorsAndDataset(u);
449
- const g = u.data.result ? u.data.result.map((d) => {
450
- let i = {
451
- taxon: d,
452
- key: d.id,
453
- datasetKey: h,
454
- childCount: d.childCount,
455
- isLeaf: d.childCount === 0,
459
+ await this.decorateWithSectorsAndDataset(p);
460
+ const C = p.data.result ? p.data.result.map((c) => {
461
+ let h = {
462
+ taxon: c,
463
+ key: c.id,
464
+ datasetKey: l,
465
+ childCount: c.childCount,
466
+ isLeaf: c.childCount === 0,
456
467
  childOffset: 0,
457
- parent: e,
458
- name: d.name
468
+ parent: t,
469
+ name: c.name
459
470
  };
460
- return i.title = /* @__PURE__ */ t.jsx(
471
+ return h.title = /* @__PURE__ */ e.jsx(
461
472
  k,
462
473
  {
463
- taxon: d,
464
- datasetKey: h,
474
+ taxon: c,
475
+ datasetKey: l,
465
476
  showSourceTaxon: r,
466
477
  rank: this.state.rank,
467
- reloadChildren: () => this.fetchChildPage(i, !0)
478
+ reloadChildren: () => this.fetchChildPage(h, !0)
468
479
  }
469
- ), i.ref = i, i;
480
+ ), h.ref = h, h;
470
481
  }) : [];
471
- if (e.children = e.children && l !== 0 && !s ? [...e.children, ...g] : g, u.data.last && e.childCount > e.children.length && (e.childCount = e.children.length), !u.data.last) {
472
- const d = () => (e.childOffset += K, e.children[e.children.length - 1].key === "__loadMoreBTN__" && (e.children = e.children.slice(0, -1)), this.fetchChildPage(e, !1));
473
- e.children = [
474
- ...e.children,
482
+ if (t.children = t.children && n !== 0 && !a ? [...t.children, ...C] : C, p.data.last && t.childCount > t.children.length && (t.childCount = t.children.length), !p.data.last) {
483
+ const c = () => (t.childOffset += b, U(m(t.children[t.children.length - 1], "key")) && (t.children = t.children.slice(0, -1)), this.fetchChildPage(t, !1));
484
+ t.children = [
485
+ ...t.children,
475
486
  {
476
- title: /* @__PURE__ */ t.jsx(
477
- ge,
487
+ title: /* @__PURE__ */ e.jsx(
488
+ Ct,
478
489
  {
479
- onClick: d
490
+ onClick: c
480
491
  },
481
- "__loadMoreBTN__"
492
+ W(t.key)
482
493
  ),
483
- key: "__loadMoreBTN__",
494
+ key: W(t.key),
484
495
  childCount: 0,
485
496
  isLeaf: !0
486
497
  }
487
498
  ];
488
499
  }
489
- o || this.setState((d) => ({
490
- treeData: [...d.treeData],
491
- loadedKeys: [.../* @__PURE__ */ new Set([...d.loadedKeys, e.key])]
500
+ o || this.setState((c) => ({
501
+ treeData: [...c.treeData],
502
+ loadedKeys: [.../* @__PURE__ */ new Set([...c.loadedKeys, t.key])]
492
503
  }));
493
504
  });
494
- p(this, "decorateWithSectorsAndDataset", (e) => e.data.result ? Promise.all(
495
- e.data.result.filter((s) => !!s.sectorDatasetKey).map(
496
- (s) => this.datasetLoader.load(s.sectorDatasetKey).then(
497
- (o) => s.sector = {
498
- id: s.sectorKey,
499
- subjectDatasetKey: s.sectorDatasetKey,
505
+ u(this, "decorateWithSectorsAndDataset", (t) => t.data.result ? Promise.all(
506
+ t.data.result.filter((a) => !!a.sectorDatasetKey).map(
507
+ (a) => this.datasetLoader.load(a.sectorDatasetKey).then(
508
+ (o) => a.sector = {
509
+ id: a.sectorKey,
510
+ subjectDatasetKey: a.sectorDatasetKey,
500
511
  dataset: o
501
512
  }
502
513
  )
503
514
  )
504
- ).then(() => e) : e);
505
- p(this, "onLoadData", (e, s = !1) => (s && (e.childOffset = 0), this.fetchChildPage(e.ref, s)));
506
- p(this, "findNode", (e, s) => {
515
+ ).then(() => t) : t);
516
+ u(this, "onLoadData", (t, a = !1) => (a && (t.childOffset = 0), this.fetchChildPage(t.ref, a)));
517
+ u(this, "findNode", (t, a) => {
507
518
  let o = null;
508
- if (o = s.find((r) => y(r, "taxon.id") === e), o)
519
+ if (o = a.find((r) => m(r, "taxon.id") === t), o)
509
520
  return o;
510
521
  {
511
- const r = s.map((c) => y(c, "children") || []), h = le(r);
512
- return h.length === 0 ? null : this.findNode(e, h);
522
+ const r = a.map((d) => m(d, "children") || []), l = ct(r);
523
+ return l.length === 0 ? null : this.findNode(t, l);
513
524
  }
514
525
  });
515
- p(this, "pageThroughChildrenUntilTaxonFound", async (e, s) => {
526
+ u(this, "pageThroughChildrenUntilTaxonFound", async (t, a) => {
516
527
  let o;
517
- for (; !o && e.children.length < e.childCount; )
518
- e.childOffset += K, e.children[e.children.length - 1].key === "__loadMoreBTN__" && (e.children = e.children.slice(0, -1)), await this.fetchChildPage(e, !1, !0), o = this.findNode(s, e.children);
519
- return o || (o = e.children.find(
520
- (r) => y(r, "taxon.id") ? r.taxon.id.indexOf("incertae-sedis") > -1 : !1
528
+ for (; !o && t.children.length < t.childCount; )
529
+ t.childOffset += b, U(m(t.children[t.children.length - 1], "key")) && (t.children = t.children.slice(0, -1)), await this.fetchChildPage(t, !1, !0), o = this.findNode(a, t.children);
530
+ return o || (o = t.children.find(
531
+ (r) => m(r, "taxon.id") ? r.taxon.id.indexOf("incertae-sedis") > -1 : !1
521
532
  )), o;
522
533
  });
523
- p(this, "reloadLoadedKeys", async (e, s, o = !0) => {
534
+ u(this, "reloadLoadedKeys", async (t, a, o = !0) => {
524
535
  this.setState({ rootLoading: !0 });
525
536
  const { loadedKeys: r } = this.state;
526
- let { treeData: h } = this.state;
527
- const c = s ? this.findNode(s, h) : null, n = e ? [...e] : [...r];
528
- for (let a = 0; a < n.length; a++) {
529
- let l = this.findNode(n[a], h);
530
- if (!l && c && n[a - 1]) {
531
- const u = this.findNode(n[a - 1], h);
532
- u && A(y(u, "children")) && u.children.length > 0 && (l = await this.pageThroughChildrenUntilTaxonFound(
533
- u,
534
- n[a]
535
- ), l ? n.splice(a, 0, l.taxon.id) : this.setState(
537
+ let { treeData: l } = this.state;
538
+ const d = a ? this.findNode(a, l) : null, i = t ? [...t] : [...r];
539
+ for (let s = 0; s < i.length; s++) {
540
+ let n = this.findNode(i[s], l);
541
+ if (!n && d && i[s - 1]) {
542
+ const p = this.findNode(i[s - 1], l);
543
+ p && O(m(p, "children")) && p.children.length > 0 && (n = await this.pageThroughChildrenUntilTaxonFound(
544
+ p,
545
+ i[s]
546
+ ), n ? i.splice(s, 0, n.taxon.id) : this.setState(
536
547
  {
537
- nodeNotFoundErr: /* @__PURE__ */ t.jsxs("span", { children: [
548
+ nodeNotFoundErr: /* @__PURE__ */ e.jsxs("span", { children: [
538
549
  "Cannot find taxon ",
539
- s,
550
+ a,
540
551
  " in tree 😥"
541
552
  ] }),
542
553
  rootLoading: !1
@@ -552,37 +563,37 @@ class G extends j.Component {
552
563
  } */
553
564
  ));
554
565
  }
555
- if (l) {
556
- await this.fetchChildPage(l, !0, !0);
557
- let u = l.children.find(
558
- (g) => y(g, "taxon.id") === y(c, "taxon.id")
566
+ if (n) {
567
+ await this.fetchChildPage(n, !0, !0);
568
+ let p = n.children.find(
569
+ (C) => m(C, "taxon.id") === m(d, "taxon.id")
559
570
  );
560
- c && a === n.length - 2 && y(l, "taxon.id") !== y(c, "taxon.id") && A(l.children) && !u && l.children.length < l.childCount && (u = await this.pageThroughChildrenUntilTaxonFound(
561
- l,
562
- y(c, "taxon.id")
563
- ), u ? this.setState({ treeData: [...this.state.treeData] }, () => {
571
+ d && s === i.length - 2 && m(n, "taxon.id") !== m(d, "taxon.id") && O(n.children) && !p && n.children.length < n.childCount && (p = await this.pageThroughChildrenUntilTaxonFound(
572
+ n,
573
+ m(d, "taxon.id")
574
+ ), p ? this.setState({ treeData: [...this.state.treeData] }, () => {
564
575
  setTimeout(() => {
565
- document.getElementById(s).scrollIntoView({ behavior: "smooth", block: "center" });
576
+ document.getElementById(a).scrollIntoView({ behavior: "smooth", block: "center" });
566
577
  }, 100);
567
578
  }) : this.setState(
568
579
  {
569
- nodeNotFoundErr: /* @__PURE__ */ t.jsxs("span", { children: [
580
+ nodeNotFoundErr: /* @__PURE__ */ e.jsxs("span", { children: [
570
581
  "Cannot find taxon ",
571
- s,
582
+ a,
572
583
  " in tree 😥"
573
584
  ] }),
574
585
  rootLoading: !1
575
586
  },
576
587
  () => {
577
- this.props.treeType === "CATALOGUE" && typeof this.props.addMissingTargetKey == "function" && this.props.addMissingTargetKey(s);
588
+ this.props.treeType === "CATALOGUE" && typeof this.props.addMissingTargetKey == "function" && this.props.addMissingTargetKey(a);
578
589
  }
579
590
  ));
580
591
  }
581
592
  }
582
- const f = { loadedKeys: n, rootLoading: !1 };
583
- o && (f.expandedKeys = n), this.setState(f, () => {
584
- s && setTimeout(() => {
585
- document.getElementById(s).scrollIntoView({ behavior: "smooth", block: "center" });
593
+ const f = { loadedKeys: i, rootLoading: !1 };
594
+ o && (f.expandedKeys = i), this.setState(f, () => {
595
+ a && setTimeout(() => {
596
+ document.getElementById(a).scrollIntoView({ behavior: "smooth", block: "center" });
586
597
  }, 100);
587
598
  });
588
599
  });
@@ -595,7 +606,7 @@ class G extends j.Component {
595
606
  error: null,
596
607
  nodeNotFoundErr: null,
597
608
  rank: []
598
- }, this.treeRef = j.createRef();
609
+ }, this.treeRef = j.createRef(), this.rootRequestId = 0;
599
610
  }
600
611
  // datasetLoader comes from the shared TreeCacheContext so multiple tree
601
612
  // nodes (and TaxonSources instances) share one in-memory cache instead
@@ -605,222 +616,222 @@ class G extends j.Component {
605
616
  }
606
617
  render() {
607
618
  const {
608
- error: e,
609
- rootTotal: s,
619
+ error: t,
620
+ rootTotal: a,
610
621
  rootLoading: o,
611
622
  treeData: r,
612
- defaultExpandAll: h,
613
- nodeNotFoundErr: c,
614
- loadedKeys: n,
623
+ defaultExpandAll: l,
624
+ nodeNotFoundErr: d,
625
+ loadedKeys: i,
615
626
  expandedKeys: f
616
- } = this.state, { treeType: a, dataset: l, height: u, expandedTaxonKey: g } = this.props, d = g;
617
- return /* @__PURE__ */ t.jsxs("div", { children: [
618
- e && /* @__PURE__ */ t.jsx(j.Fragment, { children: y(e, "response.data.code") !== 404 ? /* @__PURE__ */ t.jsx(
619
- b,
627
+ } = this.state, { treeType: s, dataset: n, height: p, expandedTaxonKey: C } = this.props, c = C;
628
+ return /* @__PURE__ */ e.jsxs("div", { children: [
629
+ t && /* @__PURE__ */ e.jsx(j.Fragment, { children: m(t, "response.data.code") !== 404 ? /* @__PURE__ */ e.jsx(
630
+ w,
620
631
  {
621
632
  closable: !0,
622
633
  onClose: () => this.setState({ error: null }),
623
634
  style: { marginTop: "8px" },
624
- message: /* @__PURE__ */ t.jsx(ue, { error: e }),
635
+ message: /* @__PURE__ */ e.jsx(gt, { error: t }),
625
636
  type: "error"
626
637
  }
627
- ) : /* @__PURE__ */ t.jsx(
628
- b,
638
+ ) : /* @__PURE__ */ e.jsx(
639
+ w,
629
640
  {
630
641
  closable: !0,
631
642
  onClose: () => this.setState({ error: null }),
632
643
  style: { marginTop: "8px" },
633
- message: /* @__PURE__ */ t.jsx(
644
+ message: /* @__PURE__ */ e.jsx(
634
645
  Custom404,
635
646
  {
636
- error: e,
637
- treeType: a,
638
- dataset: l,
647
+ error: t,
648
+ treeType: s,
649
+ dataset: n,
639
650
  loadRoot: this.loadRoot
640
651
  }
641
652
  ),
642
653
  type: "warning"
643
654
  }
644
655
  ) }),
645
- c && /* @__PURE__ */ t.jsx(
646
- b,
656
+ d && /* @__PURE__ */ e.jsx(
657
+ w,
647
658
  {
648
659
  closable: !0,
649
660
  onClose: () => this.setState({ nodeNotFoundErr: null }),
650
661
  style: { marginTop: "8px" },
651
- message: c,
662
+ message: d,
652
663
  type: "warning"
653
664
  }
654
665
  ),
655
- o && /* @__PURE__ */ t.jsx(oe, { paragraph: { rows: 10 }, active: !0 }),
656
- !o && r.length > 0 && /* @__PURE__ */ t.jsx(
657
- ne,
666
+ o && /* @__PURE__ */ e.jsx(rt, { paragraph: { rows: 10 }, active: !0 }),
667
+ !o && r.length > 0 && /* @__PURE__ */ e.jsx(
668
+ lt,
658
669
  {
659
670
  ref: this.treeRef,
660
- defaultExpandAll: h,
671
+ defaultExpandAll: l,
661
672
  loadData: this.onLoadData,
662
- onLoad: (i) => this.setState({ loadedKeys: i }),
663
- loadedKeys: n,
673
+ onLoad: (h) => this.setState({ loadedKeys: h }),
674
+ loadedKeys: i,
664
675
  expandedKeys: f,
665
676
  treeData: r,
666
- filterTreeNode: (i) => i.key === d,
667
- onExpand: (i, C) => {
668
- this.setState({ expandedKeys: i }), this.props.onExpandedTaxonKeyChange && this.props.onExpandedTaxonKeyChange(
669
- C.expanded ? C.node.key : null
677
+ filterTreeNode: (h) => h.key === c,
678
+ onExpand: (h, g) => {
679
+ this.setState({ expandedKeys: h }), this.props.onExpandedTaxonKeyChange && this.props.onExpandedTaxonKeyChange(
680
+ g.expanded ? g.node.key : null
670
681
  );
671
682
  }
672
683
  }
673
684
  ),
674
- !e && r.length < s && /* @__PURE__ */ t.jsxs(ie, { loading: o, onClick: this.loadRoot, children: [
685
+ !t && r.length < a && /* @__PURE__ */ e.jsxs(dt, { loading: o, onClick: () => this.loadRoot(!0), children: [
675
686
  "Load more",
676
687
  " "
677
688
  ] })
678
689
  ] });
679
690
  }
680
691
  }
681
- p(G, "contextType", w);
682
- const ye = [
692
+ u(J, "contextType", E);
693
+ const jt = [
683
694
  "infraspecific name",
684
695
  "species",
685
696
  "variety",
686
697
  "form"
687
698
  ];
688
- class Z extends j.Component {
689
- constructor(e) {
690
- super(e);
691
- p(this, "componentDidMount", async () => {
692
- const { datasetKey: e, citation: s } = this.props;
693
- if (s)
699
+ class Q extends j.Component {
700
+ constructor(t) {
701
+ super(t);
702
+ u(this, "componentDidMount", async () => {
703
+ const { datasetKey: t, citation: a } = this.props;
704
+ if (a)
694
705
  try {
695
- const { data: o } = await ce(e);
706
+ const { data: o } = await ft(t);
696
707
  this.setState({ dataset: o });
697
708
  } catch {
698
709
  }
699
710
  });
700
- p(this, "render", () => {
711
+ u(this, "render", () => {
701
712
  const {
702
- datasetKey: e,
703
- defaultTaxonKey: s,
713
+ datasetKey: t,
714
+ defaultTaxonKey: a,
704
715
  expandedTaxonKey: o,
705
716
  onExpandedTaxonKeyChange: r,
706
- showTreeOptions: h,
707
- linkToSpeciesPage: c,
708
- citation: n,
717
+ showTreeOptions: l,
718
+ linkToSpeciesPage: d,
719
+ citation: i,
709
720
  type: f,
710
- insertPlaceholder: a = !0
711
- } = this.props, { hideExtinct: l, dataset: u } = this.state, g = (i) => {
712
- var P, _;
713
- const C = y(i, "key");
714
- if (!C) return;
715
- const q = y(i, "rank");
716
- if (c && ye.includes(q)) {
717
- const E = (_ = (P = this.context) == null ? void 0 : P.taxon) == null ? void 0 : _.onNavigate;
718
- E && E(C);
719
- } else r && (r(C), this.treeRef && this.treeRef.reloadRoot && this.treeRef.reloadRoot());
720
- }, d = () => {
721
+ insertPlaceholder: s = !0
722
+ } = this.props, { hideExtinct: n, dataset: p } = this.state, C = (h) => {
723
+ var T, $;
724
+ const g = m(h, "key");
725
+ if (!g) return;
726
+ const S = m(h, "rank");
727
+ if (d && jt.includes(S)) {
728
+ const v = ($ = (T = this.context) == null ? void 0 : T.taxon) == null ? void 0 : $.onNavigate;
729
+ v && v(g);
730
+ } else r && (r(g), this.treeRef && this.treeRef.reloadRoot && this.treeRef.reloadRoot());
731
+ }, c = () => {
721
732
  r && r(null);
722
733
  };
723
- return /* @__PURE__ */ t.jsxs("div", { className: "catalogue-of-life", children: [
724
- n === "top" && u && /* @__PURE__ */ t.jsx(F, { dataset: u }),
725
- /* @__PURE__ */ t.jsx(w.Provider, { value: this.cache, children: /* @__PURE__ */ t.jsxs(z.Provider, { value: this.state, children: [
726
- /* @__PURE__ */ t.jsxs(re, { children: [
727
- /* @__PURE__ */ t.jsx(v, { flex: "auto", children: /* @__PURE__ */ t.jsx(
728
- xe,
734
+ return /* @__PURE__ */ e.jsxs("div", { className: "catalogue-of-life", children: [
735
+ i === "top" && p && /* @__PURE__ */ e.jsx(R, { dataset: p }),
736
+ /* @__PURE__ */ e.jsx(E.Provider, { value: this.cache, children: /* @__PURE__ */ e.jsxs(X.Provider, { value: this.state, children: [
737
+ /* @__PURE__ */ e.jsxs(ht, { children: [
738
+ /* @__PURE__ */ e.jsx(I, { flex: "auto", children: /* @__PURE__ */ e.jsx(
739
+ mt,
729
740
  {
730
- hideExtinct: l,
731
- datasetKey: e,
741
+ hideExtinct: n,
742
+ datasetKey: t,
732
743
  style: {
733
744
  width: "100%",
734
745
  paddingTop: "5px",
735
746
  paddingBottom: "5px"
736
747
  },
737
748
  defaultTaxonKey: o || null,
738
- onSelectName: g,
739
- onResetSearch: d
749
+ onSelectName: C,
750
+ onResetSearch: c
740
751
  }
741
752
  ) }),
742
- h && /* @__PURE__ */ t.jsxs(v, { style: { paddingLeft: "8px" }, children: [
743
- /* @__PURE__ */ t.jsx(
744
- $,
753
+ l && /* @__PURE__ */ e.jsxs(I, { style: { paddingLeft: "8px" }, children: [
754
+ /* @__PURE__ */ e.jsx(
755
+ N,
745
756
  {
746
757
  defaultChecked: this.state.showInfo,
747
- onChange: ({ target: { checked: i } }) => {
748
- this.setState({ showInfo: i }), M("tree-show-source", i);
758
+ onChange: ({ target: { checked: h } }) => {
759
+ this.setState({ showInfo: h }), M("tree-show-source", h);
749
760
  },
750
761
  children: "Source"
751
762
  }
752
763
  ),
753
- /* @__PURE__ */ t.jsx(
754
- $,
764
+ /* @__PURE__ */ e.jsx(
765
+ N,
755
766
  {
756
767
  defaultChecked: this.state.hideExtinct,
757
- onChange: ({ target: { checked: i } }) => {
758
- this.setState({ hideExtinct: i }), M("tree-extant-only", i);
768
+ onChange: ({ target: { checked: h } }) => {
769
+ this.setState({ hideExtinct: h }), M("tree-extant-only", h);
759
770
  },
760
771
  children: "Extant only"
761
772
  }
762
773
  )
763
774
  ] })
764
775
  ] }),
765
- /* @__PURE__ */ t.jsx(
766
- G,
776
+ /* @__PURE__ */ e.jsx(
777
+ J,
767
778
  {
768
- insertPlaceholder: a,
769
- hideExtinct: l,
770
- datasetKey: e,
771
- defaultTaxonKey: s,
779
+ insertPlaceholder: s,
780
+ hideExtinct: n,
781
+ datasetKey: t,
782
+ defaultTaxonKey: a,
772
783
  expandedTaxonKey: o,
773
784
  onExpandedTaxonKeyChange: r,
774
- treeRef: (i) => this.treeRef = i,
785
+ treeRef: (h) => this.treeRef = h,
775
786
  type: f
776
787
  }
777
788
  )
778
789
  ] }) }),
779
- n === "bottom" && u && /* @__PURE__ */ t.jsx(F, { dataset: u })
790
+ i === "bottom" && p && /* @__PURE__ */ e.jsx(R, { dataset: p })
780
791
  ] });
781
792
  });
782
- de(this.props.auth), this.state = {
783
- hideExtinct: O("tree-extant-only", !1),
784
- showInfo: O("tree-show-source", !1),
793
+ ut(this.props.auth), this.state = {
794
+ hideExtinct: F("tree-extant-only", !1),
795
+ showInfo: F("tree-show-source", !1),
785
796
  dataset: null
786
797
  }, this.cache = B(this.props.datasetKey);
787
798
  }
788
- componentDidUpdate(e) {
789
- e.datasetKey !== this.props.datasetKey && (this.cache = B(this.props.datasetKey));
799
+ componentDidUpdate(t) {
800
+ t.datasetKey !== this.props.datasetKey && (this.cache = B(this.props.datasetKey));
790
801
  }
791
802
  }
792
- p(Z, "contextType", U);
793
- function me({
794
- datasetKey: m,
795
- defaultTaxonKey: x,
796
- expandedTaxonKey: e,
797
- onExpandedTaxonKeyChange: s,
803
+ u(Q, "contextType", H);
804
+ function St({
805
+ datasetKey: x,
806
+ defaultTaxonKey: y,
807
+ expandedTaxonKey: t,
808
+ onExpandedTaxonKeyChange: a,
798
809
  showTreeOptions: o,
799
810
  linkToSpeciesPage: r,
800
- citation: h,
801
- type: c,
802
- insertPlaceholder: n,
811
+ citation: l,
812
+ type: d,
813
+ insertPlaceholder: i,
803
814
  auth: f,
804
- ...a
815
+ ...s
805
816
  }) {
806
- return /* @__PURE__ */ t.jsx(U.Provider, { value: he(a), children: /* @__PURE__ */ t.jsx(
807
- Z,
817
+ return /* @__PURE__ */ e.jsx(H.Provider, { value: pt(s), children: /* @__PURE__ */ e.jsx(
818
+ Q,
808
819
  {
809
- datasetKey: m,
810
- defaultTaxonKey: x,
811
- expandedTaxonKey: e,
812
- onExpandedTaxonKeyChange: s,
820
+ datasetKey: x,
821
+ defaultTaxonKey: y,
822
+ expandedTaxonKey: t,
823
+ onExpandedTaxonKeyChange: a,
813
824
  showTreeOptions: o,
814
825
  linkToSpeciesPage: r,
815
- citation: h,
816
- type: c,
817
- insertPlaceholder: n,
826
+ citation: l,
827
+ type: d,
828
+ insertPlaceholder: i,
818
829
  auth: f
819
830
  }
820
831
  ) });
821
832
  }
822
- const Ne = Y(X(me));
833
+ const Rt = st(et(St));
823
834
  export {
824
- Ne as Tree
835
+ Rt as Tree
825
836
  };
826
837
  //# sourceMappingURL=tree.js.map